/** * Handles adding a new content node. * * @return string */ public function actionNodeOptions() { // Create AJAX view for html replacement $view = new vB_View_AJAXHTML('vbcms_options_view'); // Add location info for where the new content will reside $view->rawtitle = $this->node->getTitle(); vB::$vbulletin->options['description'] = $this->node->getDescription(); vB::$vbulletin->options['keywords'] = $this->node->getKeywords(); vB::$vbulletin->input->clean_array_gpc('p', array( 'do' => vB_Input::TYPE_STR, 'style' => vB_Input::TYPE_UINT, 'layout' => vB_Input::TYPE_UINT, 'url' => vB_Input::TYPE_NOHTMLCOND, 'title' => vB_Input::TYPE_NOHTML, 'contenttype' => vB_Input::TYPE_UINT )); if ((vB::$vbulletin->GPC['do'] == 'update') AND $this->verifyPostId()) { // update the node $nodedm = $this->node->getDM(); $nodedm->set('url', vB::$vbulletin->GPC['url']); $nodedm->set('userid', vB::$vbulletin->userinfo['userid']); $nodedm->set('title', vB::$vbulletin->GPC['title']); $nodedm->set('title', vB::$vbulletin->GPC['title']); if (vB::$vbulletin->GPC['style']) { $nodedm->set('styleid', vB::$vbulletin->GPC['style']); } if (vB::$vbulletin->GPC['layout']) { $nodedm->set('layoutid', vB::$vbulletin->GPC['layout']); } if (!$nodedm->save()) { $fieldnames = array( 'title' => new vB_Phrase('vbcms', 'title'), 'url' => new vB_Phrase('vbcms', 'url_segment') ); $view->addErrors($nodedm->getErrors(array_keys($fieldnames)), $fieldnames); return $this->saveError($view, 'Node DM save failed'); } $finishurl = vBCms_Route_Content::getURL(array('node' => $this->node->getUrlSegment())); $view->setUrl(vB_View_AJAXHTML::URL_FINISHED, $finishurl); $view->setStatus(vB_View_AJAXHTML::STATUS_FINISHED, new vB_Phrase('vbcms', 'page_updated')); } else { // get the content controller $this->content = vBCms_Content::create($this->node->getPackage(), $this->node->getClass(), $this->node->getContentId()); // add the node as content $this->content->castFrom($this->node); // create the form view $formview = new vB_View('vbcms_node_options_form'); $formview->title = $this->node->getTitle(); // add the available styles // TODO: Allow configured constraints $formview->styles = vB_Style::getStyles(); $formview->style_phrase = new vB_Phrase('vbcms', 'style'); $formview->current_style = $this->node->getStyleSetting(); // add the available layouts // TODO: Allow configured constraints. $layout_collection = new vBCms_Collection_Layout(); $layouts = array(); foreach ($layout_collection AS $id => $layout) { $layouts[$id]['id'] = $id; $layouts[$id]['title'] = $layout->getTitle(); $layouts[$id]['selected'] = ($id == $this->node->getLayoutSetting()); } unset($layout_collection); $formview->layouts = $layouts; $formview->layout_phrase = new vB_Phrase('vbcms', 'layout'); // some useful phrases $formview->url_segment_phrase = new vB_Phrase('vbcms', 'url_segment'); $formview->title_phrase = new vB_Phrase('vbcms', 'title'); $formview->dont_change_phrase = new vB_Phrase('vbcms', 'dont_change'); $formview->url_segment = $this->node->getUrlTitle(); // item id to ensure form is submitted to us $this->addPostId($formview); // add form to the html replacement output $view->setContent($formview); // send the view // TODO: update overlay handler to accept an empty status $view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, ' '); } return $view->render(true); }