Ejemplo n.º 1
0
	/**
	 * @see	wcf\page\IPage::readData()
	 */
	public function readData() {
		parent::readData();
		
		$menuItemList = new PageMenuItemList();
		$menuItemList->sqlOrderBy = "page_menu_item.parentMenuItem ASC, page_menu_item.showOrder ASC";
		$menuItemList->readObjects();
		
		foreach ($menuItemList as $menuItem) {
			if ($menuItem->menuPosition == 'footer') {
				if ($menuItem->parentMenuItem) {
					$this->footerItems[$menuItem->parentMenuItem]->addChild($menuItem);
				}
				else {
					$this->footerItems[$menuItem->menuItem] = $menuItem;
				}
			}
			else {
				if ($menuItem->parentMenuItem) {
					$this->headerItems[$menuItem->parentMenuItem]->addChild($menuItem);
				}
				else {
					$this->headerItems[$menuItem->menuItem] = new ViewablePageMenuItem($menuItem);
				}
			}
		}
	}
Ejemplo n.º 2
0
 /**
  * @see	\wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
  */
 public function rebuild(array $parameters)
 {
     $data = array();
     $menuItemList = new PageMenuItemList();
     $menuItemList->getConditionBuilder()->add("(page_menu_item.isDisabled = ? OR page_menu_item.isLandingPage = ?)", array(0, 1));
     $menuItemList->sqlOrderBy = "page_menu_item.showOrder ASC";
     $menuItemList->readObjects();
     foreach ($menuItemList as $menuItem) {
         $index = $menuItem->parentMenuItem ? $menuItem->parentMenuItem : $menuItem->menuPosition;
         $data[$index][] = $menuItem;
     }
     return $data;
 }
Ejemplo n.º 3
0
 /**
  * @see	\wcf\data\IDeleteAction::delete()
  */
 public function delete()
 {
     $returnValues = parent::delete();
     $menuItemIDs = $pageIDs = array();
     foreach ($this->objects as $pageEditor) {
         $pageIDs[] = $pageEditor->pageID;
         if ($pageEditor->menuItemID) {
             $menuItemIDs[] = $pageEditor->menuItemID;
         }
     }
     // update search index
     if (!empty($pageIDs)) {
         SearchIndexManager::getInstance()->delete('de.codequake.cms.page', $pageIDs);
     }
     // delete related menu items
     if (!empty($menuItemIDs)) {
         $menuItemList = new PageMenuItemList();
         $menuItemList->setObjectIDs($menuItemIDs);
         $menuItemList->readObjects();
         $deleteMenuItemIDs = array();
         foreach ($menuItemList as $menuItem) {
             if ($menuItem->getProcessor() instanceof CMSPageMenuItemProvider) {
                 $page = $menuItem->getProcessor()->getPage();
                 if (in_array($page->pageID, $pageIDs)) {
                     $deleteMenuItemIDs[] = $menuItem->menuItemID;
                 }
             }
         }
         if (!empty($deleteMenuItemIDs)) {
             $pageMenuItemAction = new PageMenuItemAction($deleteMenuItemIDs, 'delete');
             $pageMenuItemAction->executeAction();
         }
     }
     return $returnValues;
 }
Ejemplo n.º 4
0
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // set default values
     if (empty($_POST)) {
         $dateTime = DateUtil::getDateTimeByTimestamp(TIME_NOW);
         $dateTime->setTimezone(WCF::getUser()->getTimeZone());
         $this->deactivationDate = $this->publicationDate = $dateTime->format('c');
     }
     $pageNodeTree = new PageNodeTree();
     $this->pageList = $pageNodeTree->getIterator();
     $this->stylesheetList = new StylesheetList();
     $this->stylesheetList->readObjects();
     // load menu items
     $menuItemList = new PageMenuItemList();
     $menuItemList->getConditionBuilder()->add('page_menu_item.menuPosition = ?', array('header'));
     $menuItemList->sqlOrderBy = 'page_menu_item.parentMenuItem ASC, page_menu_item.showOrder ASC';
     $menuItemList->readObjects();
     foreach ($menuItemList as $menuItem) {
         if ($menuItem->parentMenuItem) {
             if (isset($this->menuItems[$menuItem->parentMenuItem])) {
                 $this->menuItems[$menuItem->parentMenuItem]->addChild($menuItem);
             }
         } else {
             $this->menuItems[$menuItem->menuItem] = new ViewablePageMenuItem($menuItem);
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * @see	\wcf\data\ISortableAction::validateUpdatePosition()
  */
 public function validateUpdatePosition()
 {
     WCF::getSession()->checkPermissions(array('admin.display.canManagePageMenu'));
     if (!isset($this->parameters['data']) || !isset($this->parameters['data']['structure']) || !is_array($this->parameters['data']['structure'])) {
         throw new UserInputException('structure');
     }
     if (!isset($this->parameters['menuPosition']) || !in_array($this->parameters['menuPosition'], array('footer', 'header'))) {
         throw new UserInputException('structure');
     }
     if ($this->parameters['menuPosition'] == 'footer') {
         if (count($this->parameters['data']['structure']) > 1 || !isset($this->parameters['data']['structure'][0])) {
             throw new UserInputException('structure');
         }
     }
     $menuItemIDs = array();
     foreach ($this->parameters['data']['structure'] as $menuItems) {
         $menuItemIDs = array_merge($menuItemIDs, $menuItems);
     }
     $menuItemList = new PageMenuItemList();
     $menuItemList->getConditionBuilder()->add("page_menu_item.menuItemID IN (?)", array($menuItemIDs));
     $menuItemList->getConditionBuilder()->add("page_menu_item.menuPosition = ?", array($this->parameters['menuPosition']));
     $menuItemList->readObjects();
     $this->menuItems = $menuItemList->getObjects();
     if (count($this->menuItems) != count($menuItemIDs)) {
         throw new UserInputException('structure');
     }
     foreach ($this->parameters['data']['structure'] as $parentMenuItemID => $menuItems) {
         if ($parentMenuItemID && !isset($this->menuItems[$parentMenuItemID])) {
             throw new UserInputException('structure');
         }
     }
 }
Ejemplo n.º 6
0
	/**
	 * Reads a list of available parent menu items.
	 */
	protected function readAvailableParentMenuItems() {
		$this->initAvailableParentMenuItems();
		
		$this->availableParentMenuItems->readObjects();
	}