Esempio n. 1
0
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     parent::save();
     $data = array('title' => $this->title, 'alias' => $this->alias, 'description' => $this->description, 'metaDescription' => $this->metaDescription, 'metaKeywords' => $this->metaKeywords, 'allowIndexing' => $this->allowIndexing, 'parentID' => $this->parentID ?: null, 'showOrder' => $this->showOrder, 'invisible' => $this->invisible, 'menuItemID' => $this->menuItemID ?: null, 'isCommentable' => $this->isCommentable, 'availableDuringOfflineMode' => $this->availableDuringOfflineMode, 'allowSubscribing' => $this->allowSubscribing, 'styleID' => $this->styleID ?: null, 'sidebarOrientation' => $this->sidebarOrientation);
     // publication
     if ($this->enableDelayedPublication) {
         $data['isPublished'] = 0;
         $dateTime = \DateTime::createFromFormat('Y-m-d H:i', $this->publicationDate, WCF::getUser()->getTimeZone());
         $data['publicationDate'] = $dateTime->getTimestamp();
     }
     if ($this->enableDelayedDeactivation) {
         $dateTime = \DateTime::createFromFormat('Y-m-d H:i', $this->deactivationDate, WCF::getUser()->getTimeZone());
         $data['deactivationDate'] = $dateTime->getTimestamp();
     }
     $pageData = array('data' => $data, 'stylesheetIDs' => $this->stylesheetIDs);
     $this->objectAction = new PageAction(array(), 'create', $pageData);
     $returnValues = $this->objectAction->executeAction();
     $pageEditor = new PageEditor($returnValues['returnValues']);
     $updateData = array();
     // save ACL
     ACLHandler::getInstance()->save($pageEditor->pageID, $this->objectTypeID);
     // save multilingual inputs
     if (!I18nHandler::getInstance()->isPlainValue('title')) {
         $updateData['title'] = 'cms.page.title' . $pageEditor->pageID;
         I18nHandler::getInstance()->save('title', $updateData['title'], 'cms.page');
     }
     if (!I18nHandler::getInstance()->isPlainValue('description')) {
         $updateData['description'] = 'cms.page.description' . $pageEditor->pageID;
         I18nHandler::getInstance()->save('description', $updateData['description'], 'cms.page');
     }
     if (!I18nHandler::getInstance()->isPlainValue('metaDescription')) {
         $updateData['metaDescription'] = 'cms.page.metaDescription' . $pageEditor->pageID;
         I18nHandler::getInstance()->save('metaDescription', $updateData['metaDescription'], 'cms.page');
     }
     if (!I18nHandler::getInstance()->isPlainValue('metaKeywords')) {
         $updateData['metaKeywords'] = 'cms.page.metaKeywords' . $pageEditor->pageID;
         I18nHandler::getInstance()->save('metaKeywords', $updateData['metaKeywords'], 'cms.page');
     }
     // create menu item for page
     if ($this->createMenuItem) {
         // set menu item of parent page as parent menu item
         if ($pageEditor->getParentPage() !== null && $pageEditor->getParentPage()->menuItemID) {
             $parentMenuItem = new PageMenuItem($pageEditor->getParentPage()->menuItemID);
         }
         $menuItemData = array('className' => 'cms\\system\\menu\\page\\CMSPageMenuItemProvider', 'menuItemController' => 'cms\\page\\PagePage', 'menuItemLink' => 'id=' . $pageEditor->pageID, 'menuPosition' => 'header', 'packageID' => PACKAGE_ID, 'parentMenuItem' => isset($parentMenuItem) && $parentMenuItem->menuItemID ? $parentMenuItem->menuItem : '', 'showOrder' => 0);
         $menuItemAction = new PageMenuItemAction(array(), 'create', array('data' => $menuItemData));
         $menuItemReturnValues = $menuItemAction->executeAction();
         $menuItem = $menuItemReturnValues['returnValues'];
         // save multilingual title
         I18nHandler::getInstance()->register('menuItemTitle');
         I18nHandler::getInstance()->setValues('menuItemTitle', I18nHandler::getInstance()->getValues('title'));
         $menuItemData = array('menuItem' => 'wcf.page.menuItem' . $menuItem->menuItemID);
         I18nHandler::getInstance()->save('menuItemTitle', $menuItemData['menuItem'], 'wcf.page');
         $menuItemEditor = new PageMenuItemEditor($menuItem);
         $menuItemEditor->update($menuItemData);
         // save menu item with page
         $updateData['menuItemID'] = $menuItem->menuItemID;
     }
     // save new information
     $pageEditor->update($updateData);
     // create revision
     $objectAction = new PageAction(array($pageEditor->pageID), 'createRevision', array('action' => 'create'));
     $objectAction->executeAction();
     // update search index
     $objectAction = new PageAction(array($pageEditor->pageID), 'refreshSearchIndex');
     $objectAction->executeAction();
     $this->saved();
     WCF::getTPL()->assign('success', true);
     // reset values
     $this->alias = $this->deactivationDate = $this->description = $this->metaDescription = $this->metaKeywords = $this->publicationDate = '';
     $this->enableDelayedDeactivation = $this->enableDelayedPublication = $this->invisible = $this->menuItemID = $this->parentID = $this->showOrder = $this->styleID = 0;
     $this->stylesheetIDs = array();
     $this->allowIndexing = CMS_PAGES_DEFAULT_ALLOW_INDEXING;
     $this->allowSubscribing = CMS_PAGES_DEFAULT_ALLOW_SUBSCRIBING;
     $this->availableDuringOfflineMode = CMS_PAGES_DEFAULT_OFFLINE;
     $this->createMenuItem = CMS_PAGES_DEFAULT_MENU_ITEM;
     $this->isCommentable = CMS_PAGES_DEFAULT_COMMENTS;
     $this->sidebarOrientation = CMS_PAGES_DEFAULT_SIDEBAR;
     I18nHandler::getInstance()->reset();
     ACLHandler::getInstance()->disableAssignVariables();
 }
 /**
  * @see	\wcf\data\IToggleAction::toggle()
  */
 public function toggle()
 {
     $this->menuItemEditor->update(array('isDisabled' => $this->menuItemEditor->isDisabled ? 0 : 1));
 }
	/**
	 * @see	wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::cleanup()
	 */
	protected function cleanup() {
		PageMenuItemEditor::updateLandingPage();
	}
 /**
  * @see	\wcf\data\ISortableAction::updatePosition()
  */
 public function updatePosition()
 {
     $sql = "UPDATE\twcf" . WCF_N . "_page_menu_item\n\t\t\tSET\tparentMenuItem = ?,\n\t\t\t\tshowOrder = ?\n\t\t\tWHERE\tmenuItemID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     WCF::getDB()->beginTransaction();
     foreach ($this->parameters['data']['structure'] as $parentMenuItemID => $menuItems) {
         foreach ($menuItems as $showOrder => $menuItemID) {
             $statement->execute(array($parentMenuItemID ? $this->menuItems[$parentMenuItemID]->menuItem : '', $showOrder + 1, $menuItemID));
         }
     }
     WCF::getDB()->commitTransaction();
     // update landing page
     if ($this->parameters['menuPosition'] == 'header') {
         PageMenuItemEditor::updateLandingPage();
     }
 }
Esempio n. 5
0
	/**
	 * @see	wcf\form\IForm::save()
	 */
	public function save() {
		parent::save();
		
		$this->objectAction = new PageMenuItemAction(array(), 'create', array('data' => array(
			'isDisabled' => ($this->isDisabled) ? 1 : 0,
			'menuItem' => $this->pageMenuItem,
			'menuItemController' => $this->menuItemController,
			'menuItemLink' => $this->menuItemLink,
			'menuPosition' => $this->menuPosition,
			'parentMenuItem' => $this->parentMenuItem,
			'showOrder' => $this->showOrder
		)));
		$this->objectAction->executeAction();
		
		$returnValues = $this->objectAction->getReturnValues();
		$menuItem = $returnValues['returnValues'];
		$data = array();
		if (!I18nHandler::getInstance()->isPlainValue('menuItemLink')) {
			I18nHandler::getInstance()->save('menuItemLink', 'wcf.page.menuItemLink'.$menuItem->menuItemID, 'wcf.page');
			$data['menuItemLink'] = 'wcf.page.menuItemLink'.$menuItem->menuItemID;
		}
		
		// save menu item
		I18nHandler::getInstance()->save('pageMenuItem', 'wcf.page.menuItem'.$menuItem->menuItemID, 'wcf.page');
		$data['menuItem'] = 'wcf.page.menuItem'.$menuItem->menuItemID;
		
		// update i18n values
		$menuItemEditor = new PageMenuItemEditor($menuItem);
		$menuItemEditor->update($data);
		
		// call saved event
		$this->saved();
		
		// show success
		WCF::getTPL()->assign('success', true);
		
		// reset variables
		$this->isDisabled = $this->isInternalLink = false;
		$this->menuPosition = 'header';
		$this->menuItemController = $this->menuItemLink = $this->pageMenuItem = $this->parentMenuItem = '';
		$this->showOrder = 0;
		
		// reload parent menu items
		if ($menuItem->menuPosition == 'header' && $menuItem->parentMenuItem != '') {
			$this->readAvailableParentMenuItems();
		}
	}