/** * Returns the config view for the widget. * * @return vBCms_View_Widget - The view result */ public function getConfigView($widget = false) { global $vbulletin, $messagearea, $vbphrase; $this->assertWidget(); require_once DIR . '/includes/functions_editor.php'; require_once DIR . '/packages/vbcms/wysiwyghtmlparser.php'; require_once DIR . '/packages/vbcms/editor/override.php'; require_once DIR . '/packages/vbcms/bbcode/html.php'; require_once DIR . '/packages/vbcms/bbcode/wysiwyg.php'; require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('posting'); vB::$vbulletin->input->clean_array_gpc('r', array( 'do' => vB_Input::TYPE_STR, 'message' => vB_Input::TYPE_STR, 'wysiwyg' => vB_Input::TYPE_BOOL, 'template_name' => vB_Input::TYPE_STR )); $view = new vB_View_AJAXHTML('cms_widget_config'); $view->title = new vB_Phrase('vbcms', 'configuring_widget_x', $this->widget->getTitle()); $config = $this->widget->getConfig(); if ((vB::$vbulletin->GPC['do'] == 'config') AND $this->verifyPostId()) { if (vB::$vbulletin->GPC['wysiwyg']) { $html_parser = new vBCms_WysiwygHtmlParser(vB::$vbulletin); $message = $html_parser->parse(vB::$vbulletin->GPC['message']); } else { $message = convert_urlencoded_unicode(vB::$vbulletin->GPC['message']); } $widgetdm = new vBCms_DM_Widget($this->widget); if (vB::$vbulletin->GPC_exists['template_name']) { $config['template_name'] = vB::$vbulletin->GPC['template_name']; } $widgetdm->set('config', $config); if ($this->content) { $widgetdm->setConfigNode($this->content->getNodeId()); } $widgetdm->save(); if (!$widgetdm->hasErrors()) { if ($this->content) { $segments = array('node' => $this->content->getNodeURLSegment(), '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($widgetdm->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'); if (!isset($config['template_name']) OR ($config['template_name'] == '') ) { $config['template_name'] = 'vbcms_widget_staticbb_page'; } // add the config content $configview->template_name = $config['template_name']; //make the editor $configview->editorid = construct_edit_toolbar( $pagetext, false, new vBCms_Editor_Override(vB::$vbulletin), true, true, true, 'cms_article', '', array() ); $templater = vB_Template::create('vbcms_widgetcontent_editor'); $templater->register('values', $values); $templater->register('widgetid', $this->widget->getId()); $templater->register('disablesmiliesoption', true); $templater->register('editorid', $configview->editorid); $templater->register('messagearea', $messagearea); $configview->editor = $templater->render(); // $configview->editor = $this->getConfigEditorView(); // item id to ensure form is submitted to us $this->addPostId($configview); $view->setContent($configview); // send the view $view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_widget')); } return $view; }
/** * Returns the config view for the widget. * * @return vBCms_View_Widget - The view result */ public function getConfigView($widget = false) { require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('cpcms'); fetch_phrase_group('search'); $this->assertWidget(); vB::$vbulletin->input->clean_array_gpc('r', array( 'do' => vB_Input::TYPE_STR, 'forumchoice' => vB_Input::TYPE_ARRAY, 'template_name' => vB_Input::TYPE_STR, 'cache_ttl' => vB_Input::TYPE_INT, 'days' => vB_Input::TYPE_INT, 'allow_html' => vB_Input::TYPE_INT, 'count' => vB_Input::TYPE_INT )); $view = new vB_View_AJAXHTML('cms_widget_config'); $view->title = new vB_Phrase('vbcms', 'configuring_widget_x', $this->widget->getTitle()); $config = $this->widget->getConfig(); if ((vB::$vbulletin->GPC['do'] == 'config') AND $this->verifyPostId()) { $widgetdm = new vBCms_DM_Widget($this->widget); if (vB::$vbulletin->GPC_exists['template_name']) { $config['template_name'] = vB::$vbulletin->GPC['template_name']; } //make sure we have actual values for forumchoice if (vB::$vbulletin->GPC_exists['forumchoice']) { $config['forumchoice'] = vB::$vbulletin->GPC['forumchoice']; } if (vB::$vbulletin->GPC_exists['count']) { $config['count'] = vB::$vbulletin->GPC['count']; } if (vB::$vbulletin->GPC_exists['days']) { $config['days'] = vB::$vbulletin->GPC['days']; } if (vB::$vbulletin->GPC_exists['cache_ttl']) { $config['cache_ttl'] = vB::$vbulletin->GPC['cache_ttl']; } if (vB::$vbulletin->GPC_exists['template_name']) { $config['template_name'] = vB::$vbulletin->GPC['template_name']; } $config['allow_html'] = vB::$vbulletin->GPC_exists['allow_html'] ? 1 : 0; $widgetdm->set('config', $config); if ($this->content) { $widgetdm->setConfigNode($this->content->getNodeId()); } $widgetdm->save(); if (!$widgetdm->hasErrors()) { if ($this->content) { $segments = array('node' => $this->content->getNodeURLSegment(), '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($widgetdm->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'); if (!isset($config['template_name']) OR ($config['template_name'] == '') ) { $config['template_name'] = 'vbcms_widget_staticbb_page'; } // add the config content $configview->template_name = $config['template_name']; $configview->forumchoice_select = $this->getForums($config); $configview->days = $config['days']; $configview->count = $config['count']; $this->addPostId($configview); $configview->cache_ttl = $config['cache_ttl']; $configview->allow_html = $config['allow_html']; $view->setContent($configview); // send the view $view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_widget')); } return $view; }