Example #1
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;
 }
Example #2
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();
 }