$this->parameters['data']['packageID'] = PACKAGE_ID;
}
+ // calculate show order
+ $this->parameters['data']['showOrder'] = PageMenuItemEditor::getShowOrder($this->parameters['data']['showOrder'], $this->parameters['data']['menuPosition'], $this->parameters['data']['parentMenuItem']);
+
$menuItem = parent::create();
if ($menuItem->menuPosition == 'header') {
*/
protected static $baseClass = 'wcf\data\page\menu\item\PageMenuItem';
- /**
- * @see wcf\data\IEditableObject::create()
- */
- public static function create(array $parameters = array()) {
- // calculate show order
- $parameters['showOrder'] = self::getShowOrder($parameters['showOrder'], $parameters['menuPosition'], $parameters['parentMenuItem']);
-
- return parent::create($parameters);
- }
-
/**
* @see wcf\data\IEditableObject::delete()
*/
* @param string $menuPosition
* @return integer
*/
- protected static function getShowOrder($showOrder, $menuPosition, $parentMenuItem = '') {
+ public static function getShowOrder($showOrder, $menuPosition, $parentMenuItem = '') {
if ($showOrder == 0) {
// get next number in row
$sql = "SELECT MAX(showOrder) AS showOrder
* @return integer
*/
protected function getShowOrder($showOrder, $parentName = null, $columnName = null, $tableNameExtension = '') {
- if ($this instanceof PageMenuPackageInstallationPlugin) {
- file_put_contents(WCF_DIR.'__pageMenu.log', "\tWARNING: Accessed AbstractXMLPackageInstallationPlugin::getShowOrder() (page menu pip has own method: " . (method_exists('wcf\system\package\plugin\PageMenuPackageInstallationPlugin', 'getShowOrder') ? 'yes' : 'no') . ")\n", FILE_APPEND);
- }
-
if ($showOrder === null) {
// get greatest showOrder value
$conditions = new PreparedStatementConditionBuilder();
* @return integer
*/
protected function getMenuItemPosition(array $data) {
- file_put_contents(WCF_DIR.'__pageMenu.log', "Resolving menu position for '" . $data['menuItem'] . "' (" . $data['menuPosition'] . ") ...\n", FILE_APPEND);
- file_put_contents(WCF_DIR.'__pageMenu.log', " showOrder = ".($data['showOrder'] === null ? 'null' : $data['showOrder']) . "\n", FILE_APPEND);
- file_put_contents(WCF_DIR.'__pageMenu.log', " parentMenuItem = ". $data['parentMenuItem'] . "\n", FILE_APPEND);
-
if ($data['showOrder'] === null) {
// get greatest showOrder value
$conditions = new PreparedStatementConditionBuilder();
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
$maxShowOrder = $statement->fetchArray();
- //return (!$maxShowOrder) ? 1 : ($maxShowOrder['showOrder'] + 1);
- $showOrder = (!$maxShowOrder) ? 1 : ($maxShowOrder['showOrder'] + 1);
+ return (!$maxShowOrder) ? 1 : ($maxShowOrder['showOrder'] + 1);
}
else {
- file_put_contents(WCF_DIR.'__pageMenu.log', "\tINCREASING SHOW ORDER\n", FILE_APPEND);
// increase all showOrder values which are >= $showOrder
$sql = "UPDATE wcf".WCF_N."_".$this->tableName."
SET showOrder = showOrder + 1
$statement->execute($parameters);
// return the wanted showOrder level
- //return $data['showOrder'];
- $showOrder = $data['showOrder'];
+ return $data['showOrder'];
}
-
- file_put_contents(WCF_DIR.'__pageMenu.log', " calculated show order = ". $showOrder . "\n\n", FILE_APPEND);
- return $showOrder;
}
}