/** * Fetches the view for configuring a content item. * * @param mixed $parameters - Request parameters * @return vB_View | bool - Returns a view or false */ public function getConfigView($parameters = false) { $view = new vB_View_AJAXHTML('cms_content_config'); $view->title = new vB_Phrase('vbcms', 'configuring_content_x', $this->content->getTitle()); vB::$vbulletin->input->clean_array_gpc('p', array( 'do' => vB_Input::TYPE_STR, 'font' => vB_Input::TYPE_STR, 'size' => vB_Input::TYPE_UINT )); if (vB::$vbulletin->GPC['do'] == 'config' AND $this->verifyPostId()) { $nodedm = new vBCms_DM_Node($this->content); $nodedm->set('config', array('font' => vB::$vbulletin->GPC['font'], 'size' => vB::$vbulletin->GPC['size'])); $nodedm->save(); if (!$nodedm->hasErrors()) { $segments = array( 'node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage')); $view->setUrl(vB_View_AJAXHTML::URL_FINISHED, vBCms_Route_Content::getURL($segments)); $view->setStatus(vB_View_AJAXHTML::STATUS_FINISHED, new vB_Phrase('vbcms', 'configuration_saved')); } else { if (vB::$vbulletin->debug) { $view->addErrors($nodedm->getErrors()); } // only send a message $view->setStatus(vB_View_AJAXHTML::STATUS_MESSAGE, new vB_Phrase('vbcms', 'configuration_failed')); } } else { // add the config content $configview = $this->createView('config'); $config = $this->content->getConfig(); $configview->font = $config['font']; $configview->size = $config['size']; $configview->title = $vbphrase['new_page']; $configview->html_title = $vbphrase['new_page']; $configview->addArray(array('description' => $this->content->getDescription())); $configview->package = $this->package; $configview->class = $this->class; $this->addPostId($configview); $view->setContent($configview); //Set the class and package $view->package = $this->package; $view->class = $this->class; // send the view $view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_content')); } return $view; }
/** * Main entry point for the controller. * * @return string - The final page output */ public function actionPublishNode() { // Create AJAX view for html replacement $view = new vB_View_AJAXHTML('cms_publish_view'); $view->title = new vB_Phrase('vbcms', 'publishing_page'); vB::$vbulletin->input->clean_array_gpc('r', array( 'do' => vB_Input::TYPE_STR, 'publishdate' => vB_Input::TYPE_UNIXTIME )); if ((vB::$vbulletin->GPC['do'] == 'save') AND $this->verifyPostId()) { $publishdate = vB::$vbulletin->GPC['publishdate']; $nodedm = new vBCms_DM_Node(); $nodedm->setExisting($this->node); $nodedm->set('publishdate', vB::$vbulletin->GPC['publishdate']); if (!$nodedm->save()) { $view->addErrors($nodedm->getErrors()); return $this->saveError($view, 'Node DM save failed'); } //We need to see if we have a content node to index. $contenttypeid = $this->node->getContenttypeId(); $index_controller = vB_Search_Core::get_instance()->get_index_controller_by_id($contenttypeid); if (!($index_controller instanceof vb_Search_Indexcontroller_Null)) { $classinfo = vB_Types::instance()->getContentClassFromId($contenttypeid); vB_Search_Indexcontroller_Queue::indexQueue($classinfo['package'], $classinfo['class'], 'index', $this->node->getId()); } $published = ($publishdate AND ($publishdate <= TIMENOW)); if ($published != $this->node->isPublished()) { $finishurl = vBCms_Route_Content::getURL(array('node' => $this->node->getNodeId(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'))); $view->setUrl(vB_View_AJAXHTML::URL_FINISHED, $finishurl); } $status_phrase = new vB_Phrase('vbcms', $published ? 'page_published' : 'page_unpublished'); $view->setStatus(vB_View_AJAXHTML::STATUS_FINISHED, $status_phrase); } else { // get the delete view $publishview = new vB_View('vbcms_publish_form'); // add datepicker for date $publishview->datepicker = new vB_View_DatePicker(); $publishview->datepicker->setDate($this->node->getPublishDate()); $publishview->datepicker->setLabel(new vB_Phrase('vbcms', 'publish_date')); $publishview->datepicker->setDateVar('publishdate'); // item id to ensure form is submitted to us $this->addPostId($publishview); // add form to the html replacement output $view->setContent($publishview); // send the view // TODO: update overlay handler to accept an empty status $view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, ' '); } return $view->render(true); }
/** * Creates a new, empty content item to add to a node. * * @param vBCms_DM_Node $nodedm - The DM of the node that the content is being created for * @return int | false - The id of the new content or false if not applicable */ public function createDefaultContent(vBCms_DM_Node $nodedm) { global $vbphrase; require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('cpcms'); vB::$vbulletin->input->clean_array_gpc('r', array( 'nodeid' => vB_Input::TYPE_UINT, 'parentnode' => vB_Input::TYPE_UINT, 'parentid' => vB_Input::TYPE_UINT, 'pagecontent' => vB_Input::TYPE_STR, )); //We should have a nodeid, but a parentnode is even better. ($hook = vBulletinHook::fetch_hook($this->content_start_hook)) ? eval($hook) : false; if ($this->parent_node) { $parentnode = $this->parent_node; } else if (vB::$vbulletin->GPC_exists['parentnode'] AND intval(vB::$vbulletin->GPC['parentnode'] )) { $parentnode = vB::$vbulletin->GPC['parentnode']; } else if (vB::$vbulletin->GPC_exists['parentid'] AND intval(vB::$vbulletin->GPC['parentid'] )) { $parentnode = vB::$vbulletin->GPC['parentid']; } else if (vB::$vbulletin->GPC_exists['nodeid'] AND intval(vB::$vbulletin->GPC['nodeid'] ) and $record = vB::$vbulletin->db->query_first("SELECT contenttypeid, nodeid, parentnode FROM " . TABLE_PREFIX . "cms_node where nodeid = " . vB::$vbulletin->GPC['nodeid'] )) { $parentnode = vB_Types::instance()->getContentTypeID("vBCms_Section") == $record['contenttypeid'] ? $record['nodeid'] : $record['parentnode']; } else { throw (new vB_Exception_Content('No valid parent node')); } $contenttypeid = vB_Types::instance()->getContentTypeID($this->package . '_' . $this->class); //Verify Permissions if (!vBCMS_Permissions::canUseHtml($parentnode, $contenttypeid, vB::$vbulletin->userinfo['userid'])) { throw (new vB_Exception_AccessDenied()); } $this->config = array('pagetext' => $vbphrase['pagetext_goes_here'], 'previewtext' => $vbphrase['preview_goes_here_desc']); $nodedm->set('config', $this->config); $nodedm->set('contenttypeid', $contenttypeid); $nodedm->set('parentnode', $parentnode); $nodedm->set('publicpreview', 1); $nodedm->set('comments_enabled', 1); $title = new vB_Phrase('vbcms', 'new_static_page'); $nodedm->set('description', $title); $nodedm->set('title', $title); if (!($contentid = $nodedm->save())) { throw (new vB_Exception_Content('Failed to create default content for contenttype ' . get_class($this))); } ($hook = vBulletinHook::fetch_hook($this->content_end_hook)) ? eval($hook) : false; return $contentid; }
/** * Additional tasks to perform after a delete. * * @param mixed - The result of execDelete() */ function postDelete($result) { $this->assertItem(); $nodeid = intval($this->item->getNodeId()); $nodedm = new vBCms_DM_Node(); $nodedm->setExisting($nodeid); $nodedm->set('nodeid', $nodeid); $nodedm->removeRating(intval($this->item->getVote())); $nodedm->save(); return $result; }