public function setNavArray($nodes) { //We need to set the indent level and the url $indentlevel = array(); //What is the current section $sectionid = 1; //because we're ordered by nodeleft, we'll always see parents before children foreach ($nodes as $key => $node) { //get the url $nodeurl = $node['nodeid'] . ($node['url'] ? '-' . $node['url'] : ''); $segments = array('node' => $nodeurl, 'action' => 'view'); $nodes[$key]['url'] = vBCms_Route_Content::getURL($segments); //get the indent if (isset($node['parentnode'])) { if (array_key_exists($node['parentnode'], $indentlevel)) { //This is the root node $indent = $indentlevel[$node['parentnode']] + 1; $indentlevel[$node['nodeid']] = $indent; $nodes[$key]['indent'] = $indent; } else { $nodes[$key]['indent'] = 1; $indentlevel[$node['nodeid']] = 1; } } else { //This is the root node unset($nodes[$key]); continue; } //Set a flag to tell the template if it's the current page. //In my experience with templates, 0/1 is more reliable than true-false $nodes[$key]['current_page'] = $sectionid == $node['nodeid'] ? 1 : 0; } return $nodes; }
} $xml->add_tag('time', TIMENOW); $xml->close_group(); $xml->print_xml(true); // ############################################################################# // ############################################################################# // ############################################################################# } else { // if this is a CMS article comment, perform the redirect back to the article if ($vbulletin->GPC_exists['return_node'] AND intval($vbulletin->GPC['return_node'])) { $url = vBCms_Route_Content::getURL(array('node' => $vbulletin->GPC['return_node'])); $vbulletin->url = str_ireplace('&', '&', $url); if (is_facebookenabled()) { publishtofacebook_articlecomment($threadinfo['title'], $newpost['message'], create_full_url($vbulletin->url)); } exec_header_redirect($url); } if ($vbulletin->GPC['multiquoteempty']) { // setting cookies -- need to force a redirect on IIS because of // some issues with location-based redirects and set-cookie headers $forceredirect = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false); if ($vbulletin->GPC['multiquoteempty'] == 'only')
/** * Fetches breadcrumb info. * * @return array mixed */ public function getBreadcrumbInfo() { // Ensure parent info is loaded $this->Load(self::INFO_PARENTS); $breadcrumbs = array(); if ($this->parents) { $nodes = $this->parents; // don't include the root node in the breadcrumb array_shift($nodes); foreach ($nodes AS $node) { if (!$node['hidden']) { // TODO: use breadcrumb item? $breadcrumb = array(); $breadcrumb['title'] = $node['title']; $breadcrumb['description'] = $node['description']; $breadcrumb['nodeid'] = $node['nodeid']; $breadcrumb['url'] = $node['url']; $breadcrumb['link'] = vBCms_Route_Content::getURL(array('node' => $node['nodeid'] . '-' . $node['url'])); $breadcrumbs[] = $breadcrumb; } } } // The last item of cms breadcrumb should be no link and has been set in view/page.php. so we don't need this /* if ($this->contenttypeid == vb_Types::instance()->getContentTypeID("vBCms_Section") AND !$this->isRoot()) { $breadcrumb = array(); $breadcrumb['title'] = $this->title; $breadcrumb['description'] = $this->description; $breadcrumb['nodeid'] = $this->nodeid; $breadcrumb['url'] = $this->url; $breadcrumb['link'] = vBCms_Route_Content::getURL(array('node' => $this->nodeid . '-' . $this->url)); $breadcrumbs[] = $breadcrumb; } */ return $breadcrumbs; }
/** * Parses the post for BB code. */ function parse_bbcode() { $this->bbcode_parser->attachments =& $this->post['attachments']; $this->bbcode_parser->unsetattach = true; //If the pagetext_html is not set, we need to see whether this is a // cms comment thread. If so, we need to set the comment link information. if (empty($this->post['pagetext_html']) AND $this->registry->products['vbcms'] AND isset($this->registry->options['vbcmsforumid'])) { //We need to see if this post is for a forum article; if (!isset($this->post['nodeid'])) { $associatedinfo = $this->registry->db->query_first("SELECT node.nodeid, node.url FROM " . TABLE_PREFIX . "cms_nodeinfo AS info INNER JOIN " . TABLE_PREFIX . "cms_node AS node ON node.nodeid = info.nodeid WHERE info.associatedthreadid = " . $this->post['threadid']); $this->post['nodeid'] = $associatedinfo['nodeid']; $this->post['url'] = $associatedinfo['url']; } if (intval($this->post['nodeid'])) { //we need to set the parser to render this quotes as a links to the article // rather than showthread. //We need the router, which requires the boot. require_once(DIR . '/includes/class_bootstrap_framework.php'); vB_Bootstrap_Framework::init(); $nodeinfo = $this->post['nodeid'] . (empty($this->post['url']) ? '' : '-' . $this->post['url']); $page_url = vBCms_Route_Content::getURL(array('node' => $nodeinfo, 'action' =>'view')); $this->bbcode_parser->set_quote_template('vbcms_bbcode_quote'); $this->bbcode_parser->set_quote_vars(array('page_url' => $page_url . (strpos($page_url, '?') == false ? '?' : '&'))); } } $this->post['message'] = $this->bbcode_parser->parse( $this->post['pagetext'], $this->forum['forumid'], $this->post['allowsmilie'], false, $this->post['pagetext_html'], $this->post['hasimages'], $this->cachable, $this->post['htmlstate'] ); $this->post_cache =& $this->bbcode_parser->cached; //Unset the flags we set above if necessary. if (isset($nodeinfo)) { $this->bbcode_parser->set_quote_template('bbcode_quote'); $this->bbcode_parser->set_quote_vars(false); } }
/** * Returns the config view for the widget. * * @return vBCms_View_Widget - The view result */ public function getConfigView() { $this->assertWidget(); global $vbphrase; require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('vbcms'); vB::$vbulletin->input->clean_array_gpc('r', array( 'do' => vB_Input::TYPE_STR, 'days' => vB_Input::TYPE_UINT, 'item_id' => vB_Input::TYPE_UINT, 'count' => vB_Input::TYPE_UINT, 'rb_type' => vB_Input::TYPE_UINT, 'template_name' => vB_Input::TYPE_STR, 'contenttypeid' => vB_Input::TYPE_ARRAY )); $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_exists['days']) { $config['days'] = vB::$vbulletin->GPC['days']; } if (vB::$vbulletin->GPC_exists['count']) { $config['count'] = vB::$vbulletin->GPC['count']; } if (vB::$vbulletin->GPC_exists['template_name']) { $config['template_name'] = vB::$vbulletin->GPC['template_name']; } if ( vB::$vbulletin->GPC_exists['rb_type'] AND intval(vB::$vbulletin->GPC['rb_type'])) { $config['contenttypeid'] = vB::$vbulletin->GPC['rb_type']; vB::$vbulletin->input->clean_array_gpc('p', array( 'template_' . vB::$vbulletin->GPC['rb_type'] => vB_Input::TYPE_STR)); $config['template'] = (vB::$vbulletin->GPC_exists['template_' . vB::$vbulletin->GPC['rb_type']] ? vB::$vbulletin->GPC['template_' . vB::$vbulletin->GPC['rb_type']] : 'vbcms_searchresult_' . vB_Types::instance()->getPackageClass(vB::$vbulletin->GPC['rb_type']) ); } else { $config['contenttypeid'] = vB_Types::instance()->getContentTypeID('vBForum_Post'); $config[ 'template'] = 'vbcms_searchresult_post'; } $widgetdm = $this->widget->getDM(); $widgetdm->set('config', $config); if ($this->content) { $widgetdm->setConfigNode($this->content->getNodeId()); } $widgetdm->save(); //clear the cache vB_Cache::instance()->event('widget_config_' . $this->widget->getId()); vB_Cache::instance()->cleanNow(); 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'); $contenttypes = array() ; require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('search'); foreach (vB_Search_Core::get_instance()->get_indexed_types() as $type) { $contenttypes[$type['contenttypeid']] = array('name' => $type['class'], 'contenttypeid' => $type['contenttypeid'], 'template' => ((intval($type['contenttypeid']) == intval($config['contenttypeid'])) and isset($config['template'])) ? $config['template'] : 'vbcms_searchresult_' . strtolower($type['class']), 'checked' => intval($type['contenttypeid']) == intval($config['contenttypeid']) ? 'checked="checked"' : '') ; } $configview->contenttypes = $contenttypes; $show_checked = array(); // Contenttype select $select_types = ''; foreach (vB_Search_Core::get_instance()->get_indexed_types() as $type) { $contenttypes[$type['contenttypeid']] = array('name' => $type['class'], 'contenttypeid' => $type['contenttypeid'], 'template' => ((intval($type['contenttypeid']) == intval($config['contenttypeid'])) and isset($config['template'])) ? $config['template'] : 'vbcms_searchresult_' . strtolower($type['class']), 'checked' => intval($type['contenttypeid']) == intval($config['contenttypeid']) ? 'checked="checked"' : '') ; } $configview->contenttypes = $contenttypes; $configview->count = $config['count']; $configview->days = $config['days']; $configview->template_name = ($config['template_name'] ? $config['template_name'] : 'vbcms_widget_searchwidget_page'); // add id to form $this->addPostId($configview); $view->setContent($configview); // send the view $view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_widget')); } return $view; }
function create_associated_thread($article) { $foruminfo = fetch_foruminfo(vB::$vbulletin->options['vbcmsforumid']); if (!$foruminfo) { return false; } $dataman =& datamanager_init('Thread_FirstPost', vB::$vbulletin, ERRTYPE_ARRAY, 'threadpost'); //$dataman->set('prefixid', $post['prefixid']); // set info $dataman->set_info('preview', ''); $dataman->set_info('parseurl', true); $dataman->set_info('posthash', ''); $dataman->set_info('forum', $foruminfo); $dataman->set_info('thread', array()); $dataman->set_info('show_title_error', false); // set options $dataman->set('showsignature', true); $dataman->set('allowsmilie', false); // set data //title and message are needed for dupcheck later $title = new vB_Phrase('vbcms', 'comment_thread_title', htmlspecialchars_decode($article->getTitle())); $message = new vB_Phrase('vbcms', 'comment_thread_firstpost', vBCms_Route_Content::getURL(array('node' => $article->getUrlSegment()))); $dataman->set('userid', $article->getUserId()); $dataman->set('title', $title); $dataman->set('pagetext', $message); $dataman->set('iconid', ''); $dataman->set('visible', 1); $dataman->setr('forumid', $foruminfo['forumid']); $errors = array(); $dataman->pre_save(); $errors = array_merge($errors, $dataman->errors); vB_Cache::instance()->event($article->getCacheEvents()); if (sizeof($errors) > 0) { return false; } if (!($id = $dataman->save())) { throw new vB_Exception_Content('Could not create comments thread for content'); } return $id; }
/** * Return item-specific url to the owner of an attachment * * @param array Content information * * @return string */ protected function fetch_content_url_instance($contentinfo) { return vBCms_Route_Content::getURL(array('node' => vBCms_Item_Content::buildUrlSegment($contentinfo['nodeid'], $contentinfo['url']))); }
/** * Returns the config view for the widget. * * @param vB_Widget $widget * @return vBCms_View_Widget - The view result */ public function getConfigView($widget = false) { $this->assertWidget(); require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('cpcms'); fetch_phrase_group('vbblock'); fetch_phrase_group('vbblocksettings'); vB::$vbulletin->input->clean_array_gpc('r', array( 'do' => vB_Input::TYPE_STR, 'template_name' => vB_Input::TYPE_STR, 'cache_ttl' => vB_Input::TYPE_INT, 'commentusernames' => vB_Input::TYPE_STR, 'postusernames' => vB_Input::TYPE_STR, 'taglist' => vB_Input::TYPE_STR, 'blogid' => vB_Input::TYPE_STR, 'cat_case_sensitive' => vB_Input::TYPE_INT, 'messagemaxchars' => vB_Input::TYPE_INT, 'categories' => vB_Input::TYPE_STR, 'days' => 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']; } if (vB::$vbulletin->GPC_exists['days']) { $config['days'] = vB::$vbulletin->GPC['days']; } if (vB::$vbulletin->GPC_exists['count']) { $config['count'] = vB::$vbulletin->GPC['count']; } if (vB::$vbulletin->GPC_exists['cache_ttl']) { $config['cache_ttl'] = vB::$vbulletin->GPC['cache_ttl']; } if (vB::$vbulletin->GPC_exists['messagemaxchars']) { $config['messagemaxchars'] = vB::$vbulletin->GPC['messagemaxchars']; } if (vB::$vbulletin->GPC_exists['commentusernames']) { //We could be passed an empty string. If so, clear the existing value if (empty(vB::$vbulletin->GPC['commentusernames'])) { $config['commentuserid'] = ''; } else { //We are passed names. We need to turn those into user id's $usernames = explode(',', vB::$vbulletin->GPC['commentusernames']); foreach ($usernames as $key => $username) { $usernames[$key] = "'" . vB::$db->escape_string(trim($username)) . "'"; } $sql = "SELECT username, userid FROM " . TABLE_PREFIX . "user WHERE username IN (" . implode(',', $usernames) . ") ORDER BY lower(username)"; if ($rst = vB::$db->query_read($sql)) { $userids = array(); while($record = vB::$db->fetch_array($rst)) { $userids[$record['userid']] = $record['username']; } } $config['commentuserid'] = $userids; } } if (vB::$vbulletin->GPC_exists['postusernames']) { //We could be passed an empty string. If so, clear the existing value if (empty(vB::$vbulletin->GPC['postusernames'])) { $config['postuserid'] = ''; } else { //We are passed names. We need to turn those into user id's $usernames = explode(',', vB::$vbulletin->GPC['postusernames']); foreach ($usernames as $key => $username) { $usernames[$key] = "'" . vB::$db->escape_string(trim($username)) . "'"; } $sql = "SELECT username, userid FROM " . TABLE_PREFIX . "user WHERE username IN (" . implode(',', $usernames) . ") ORDER BY lower(username)"; if ($rst = vB::$db->query_read($sql)) { $userids = array(); while($record = vB::$db->fetch_array($rst)) { $userids[$record['userid']] = $record['username']; } } $config['postuserid'] = $userids; } } if (vB::$vbulletin->GPC_exists['taglist']) { //We could be passed an empty string. If so, clear the existing value if (empty(vB::$vbulletin->GPC['taglist'])) { $config['taglist'] = ''; } else { //We need to confirm these are valid tags $tags = explode(',', vB::$vbulletin->GPC['taglist']); foreach ($tags as $key => $tag) { $tags[$key] = "'" . vB::$db->escape_string(trim($tag)) . "'"; } $sql = "SELECT tagid, tagtext FROM " . TABLE_PREFIX . "tag WHERE tagtext IN (" . implode(',', $tags) . ") ORDER BY tagtext"; if ($rst = vB::$db->query_read($sql)) { $tagids = array(); while($record = vB::$db->fetch_array($rst)) { $tagids[$record['tagid']] = $record['tagtext']; } } $config['taglist'] = $tagids; } } if (vB::$vbulletin->GPC_exists['blogid']) { //We could be passed an empty string. If so, clear the existing value if (empty(vB::$vbulletin->GPC['blogid'])) { $config['blogid'] = ''; } else { //We need to confirm these are valid ids $blogids = explode(',', vB::$vbulletin->GPC['blogid']); $blogid_checked = array(); foreach ($blogids as $key => $blogid) { if (intval(intval($blogid))) { } $blogid_checked[] = intval($blogid); } $sql = "SELECT blogid FROM " . TABLE_PREFIX . "blog WHERE blogid IN (" . implode(',', $blogid_checked) . ")"; if ($rst = vB::$db->query_read($sql)) { $blogids = array(); while($record = vB::$db->fetch_array($rst)) { $blogids[] = $record['blogid']; } } $config['blogid'] = implode(',', $blogids); } } if (vB::$vbulletin->GPC_exists['categories']) { //We could be passed an empty string. If so, clear the existing value if (vB::$vbulletin->GPC['categories'] == '') { $config['categories'] = ''; } else { $categories = explode(',', vB::$vbulletin->GPC['categories']); foreach ($categories as $key => $category) { $categories[$key] = "'" . vB::$db->escape_string(trim($category)) . "'"; } $sql = "SELECT title, blogcategoryid FROM " . TABLE_PREFIX . "blog_category WHERE title IN (" . implode(',', $categories) . ")"; if ($rst = vB::$db->query_read($sql)) { $categories = array(); while($record = vB::$db->fetch_array($rst)) { $categories[$record['blogcategoryid']] = $record['title']; } } $config['categories'] = $categories; } } $widgetdm->set('config', $config); $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_recentblog_page'; } // add the config content $configview->template_name = $config['template_name']; $configview->days = $config['days']; $configview->count = $config['count']; $configview->messagemaxchars = $config['messagemaxchars']; $configview->blogid = $config['blogid']; if (!empty($config['postuserid'])) { $configview->postusernames = implode(',', $config['postuserid']); } if (!empty($config['commentuserid'])) { $configview->commentusernames = implode(',', $config['commentuserid']); } if (!empty($config['taglist'])) { $configview->taglist = implode(',', $config['taglist']); } //Case sensitivity is an interesting issue. We will do the // search based on the db collation, which defaults to case // insensitive. But let's display in the stored value case $categories = array(); if (!empty($config['categories'])) { $lcase_categories = array(); foreach($config['categories'] as $category) { if (!in_array(strtolower($category), $lcase_categories)) { $categories[] = $category; $lcase_categories[] = strtolower($category); } } $configview->categories = implode(',', $config['categories']); } $configview->categories = implode(',', $categories); $configview->cache_ttl = $config['cache_ttl']; $this->addPostId($configview); $view->setContent($configview); // send the view $view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_widget')); } return $view; }
/** * Parses the post for BB code. */ function parse_bbcode() { static $nodecache = array(); $this->bbcode_parser->attachments =& $this->post['attachments']; $this->bbcode_parser->unsetattach = true; //If the pagetext_html is not set, we need to see whether this is a // cms comment thread. If so, we need to set the comment link information. if ($this->registry->products['vbcms'] and $this->registry->options['vbcmsforumid'] > 0 and $this->registry->options['vbcmsforumid'] == $this->thread['forumid'] and empty($this->post['pagetext_html'])) { //We need to see if this post is for a forum article; if (!isset($this->post['nodeid'])) { if (!isset($nodecache[$this->post['threadid']])) { $nodecache[$this->post['threadid']] = $this->registry->db->query_first("\n\t\t\t\t\t\tSELECT node.nodeid, node.url\n\t\t\t\t\t\tFROM " . TABLE_PREFIX . "cms_nodeinfo AS info\n\t\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "cms_node AS node ON node.nodeid = info.nodeid\n\t\t\t\t\t\tWHERE info.associatedthreadid = " . intval($this->post['threadid']) . "\n\t\t\t\t\t"); } $this->post['nodeid'] = $nodecache[$this->post['threadid']]['nodeid']; $this->post['url'] = $nodecache[$this->post['threadid']]['url']; } $this->post['nodeid'] = intval($this->post['nodeid']); if ($this->post['nodeid']) { //we need to set the parser to render this quotes as a links to the article // rather than showthread. $nodeinfo = $this->post['nodeid'] . (empty($this->post['url']) ? '' : '-' . $this->post['url']); $page_url = vBCms_Route_Content::getURL(array('node' => $nodeinfo, 'action' => 'view')); $this->bbcode_parser->set_quote_template('vbcms_bbcode_quote'); $this->bbcode_parser->set_quote_vars(array('page_url' => $page_url . (strpos($page_url, '?') == false ? '?' : '&'))); } } $this->post['message'] = $this->bbcode_parser->parse($this->post['pagetext'], $this->forum['forumid'], $this->post['allowsmilie'], false, $this->post['pagetext_html'], $this->post['hasimages'], $this->cachable, $this->post['htmlstate']); $this->post_cache =& $this->bbcode_parser->cached; //Unset the flags we set above if necessary. if (isset($nodeinfo)) { $this->bbcode_parser->set_quote_template('bbcode_quote'); $this->bbcode_parser->set_quote_vars(false); } }
/** * Returns the config view for the widget. * * @return vBCms_View_Widget - The view result */ public function getConfigView() { global $vbphrase; $this->assertWidget(); require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('contenttypes'); vB::$vbulletin->input->clean_array_gpc('r', array( 'do' => vB_Input::TYPE_STR, 'days' => vB_Input::TYPE_UINT, 'count' => vB_Input::TYPE_UINT, 'rb_type' => vB_Input::TYPE_UINT, 'username' => vB_Input::TYPE_STR, 'friends' => vB_Input::TYPE_BOOL, 'childforums' => vB_Input::TYPE_BOOL, 'keywords' => vB_Input::TYPE_STR, 'template_name' => vB_Input::TYPE_STR, 'contenttypeid' => vB_Input::TYPE_UINT, 'group_text' => vB_Input::TYPE_STR, 'forumchoice' => vB_Input::TYPE_ARRAY, 'cat' => vB_Input::TYPE_ARRAY, 'prefixchoice' => vB_Input::TYPE_ARRAY, 'srch_tag_text' => 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_exists['days']) { $config['days'] = vB::$vbulletin->GPC['days']; } if (vB::$vbulletin->GPC_exists['template_name']) { $config['template_name'] = vB::$vbulletin->GPC['template_name']; } if (vB::$vbulletin->GPC_exists['count']) { $config['count'] = vB::$vbulletin->GPC['count']; } $config['username'] = vB::$vbulletin->GPC_exists['username']? convert_urlencoded_unicode(vB::$vbulletin->GPC['username']) : null; $config['friends'] = vB::$vbulletin->GPC_exists['friends']; $config['childforums'] = vB::$vbulletin->GPC_exists['childforums']; $config['keywords'] = convert_urlencoded_unicode(vB::$vbulletin->GPC['keywords']); //the contenttype array gets special handling. $type_info = array() ; if ( vB::$vbulletin->GPC_exists['rb_type'] AND intval(vB::$vbulletin->GPC['rb_type'])) { $config['contenttypeid'] = vB::$vbulletin->GPC['rb_type']; vB::$vbulletin->input->clean_array_gpc('p', array( 'template_' . vB::$vbulletin->GPC['rb_type'] => vB_Input::TYPE_STR)); $config['template'] = (vB::$vbulletin->GPC_exists['template_' . vB::$vbulletin->GPC['rb_type']] ? vB::$vbulletin->GPC['template_' . vB::$vbulletin->GPC['rb_type']] : 'vbcms_searchresult_' . vB_Types::instance()->getPackageClass(vB::$vbulletin->GPC['rb_type']) ); } else { $config['contenttypeid'] = vB_Types::instance()->getContentTypeID('vBForum_Post'); $config[ 'template'] = 'vbcms_searchresult_post'; } $config['group'] = vB::$vbulletin->GPC_exists['group_text']? convert_urlencoded_unicode(vB::$vbulletin->GPC['group_text']) : null; $config['forumchoice'] = vB::$vbulletin->GPC_exists['forumchoice']? vB::$vbulletin->GPC['forumchoice'] : null; $config['cat'] = vB::$vbulletin->GPC_exists['cat']? vB::$vbulletin->GPC['cat'] : null; $config['prefixchoice'] = vB::$vbulletin->GPC_exists['prefixchoice']? vB::$vbulletin->GPC['prefixchoice'] : null; $config['tag'] = vB::$vbulletin->GPC_exists['srch_tag_text']? convert_urlencoded_unicode(vB::$vbulletin->GPC['srch_tag_text']) : null; $widgetdm = $this->widget->getDM(); $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')); vB_Cache::instance()->event($this->getCacheEvent()); } 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 { $configview = $this->createView('config'); // Contenttype multiselect $contenttypes = array() ; require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('search'); foreach (vB_Search_Core::get_instance()->get_indexed_types() as $type) { $phrasekey = 'contenttype_' . strtolower($type['package']) . '_' . strtolower($type['class']); $contenttypes[$type['contenttypeid']] = array('name' => $vbphrase[$phrasekey] , 'contenttypeid' => $type['contenttypeid'], 'template' => ((intval($type['contenttypeid']) == intval($config['contenttypeid'])) and isset($config['template'])) ? $config['template'] : 'vbcms_searchresult_' . strtolower($type['class']), 'checked' => intval($type['contenttypeid']) == intval($config['contenttypeid']) ? 'checked="checked"' : '') ; } $configview->contenttypes = $contenttypes; $configview->days = (isset($config['days']) ? $config['days'] : 14); $configview->count = $config['count']; $configview->username = $config['username'] ? $config['username'] : ''; $configview->friendschecked = ($config['friends'] ? 'checked="checked"' : ''); $configview->childforumschecked = ($config['childforums'] ? 'checked="checked"' : ''); $configview->keywords = $config['keywords']; $configview->template_name = ($config['template_name'] ? $config['template_name'] : 'vbcms_widget_searchwidget_page'); $configview->group = $config['group']; $configview->tag = $config['tag']; $configview->type_select = $select_types; $configview->cat_select = $this->getGroupCategories($config); $configview->prefixchoice_select = $this->getPrefixes($config) . '</select>'; $configview->forumchoice_select = $this->getForums($config); // 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; }
if ((!$threadinfo['visible'] or $threadinfo['isdeleted']) and !can_moderate($threadinfo['forumid'])) { eval(standard_error(fetch_error('invalidid', $vbphrase['thread'], $vbulletin->options['contactuslink']))); } ($hook = vBulletinHook::fetch_hook('report_start')) ? eval($hook) : false; if ($_REQUEST['do'] == 'report') { // draw breadcrumbs depending on type $navbits = array(); if ($report_type == 'article_comment') { vB::$vbulletin->options['selectednavtab'] = 'vbcms'; $home_url = vB::$vbulletin->options['site_tab_url'] . (stripos('?', vB::$vbulletin->options['site_tab_url']) === false ? '?' : '&') . "s=" . vB::$vbulletin->session->vars['sessionhash']; $navbits[$home_url] = $vbphrase['vbcms_title']; $breadcrumbs = $content->getBreadcrumbInfo(); foreach ($breadcrumbs as $breadcrumb) { $navbits[$breadcrumb['link']] = $breadcrumb['title']; } $url = vBCms_Route_Content::getURL(array('node' => $vbulletin->GPC['return_node'] . '-' . $content->getUrl())); $navbits[$url] = $content->getTitle(); $navbits[''] = $vbphrase['report_bad_articlecomment']; } else { $navbits[fetch_seo_url('forumhome', array())] = $vbphrase['forum']; $parentlist = array_reverse(explode(',', $foruminfo['parentlist'])); foreach ($parentlist as $forumID) { $forumTitle = $vbulletin->forumcache["{$forumID}"]['title']; $navbits[fetch_seo_url('forum', array('forumid' => $forumID, 'title' => $forumTitle))] = $forumTitle; } $navbits[fetch_seo_url('thread', $threadinfo, array('p' => $postid)) . "#post{$postid}"] = $threadinfo['prefix_plain_html'] . ' ' . $threadinfo['title']; $url = fetch_seo_url('thread', $threadinfo, array('p' => $postid)) . "#post{$postid}"; $navbits[''] = $vbphrase['report_bad_post']; } $navbits = construct_navbits($navbits); $usernamecode = vB_Template::create('newpost_usernamecode')->render();
/** * This does the actual work of creating the navigation elements. This needs some * styling, but I'll do that later. * The logic is: * depending on the flags, get the appropriate arrays. * Get the configuration * If showtop is on, then show any top-level elements that sort above our top * If showparent is on, then show the trail to our level. * If showsiblings is on, then show siblings that sort above us. * Show our children. * If showsiblings is on, then show siblings that sort below us. * If showtop is on, then show any top-level elements that sort below our top * * @return string; */ private function makeNav($link_nodes) { $router = new vBCms_Route_Content; $result = ''; $space = ' '; $spacer = ''; $this_nodeid = $this->content->getNodeId(); $split_title = false; //Now at this point we mostly can ignore the config settings, because the //nodes we don't want to show aren't there. //First home. If we are using parentnodes, then home will be the first. $prior_nodes = array(); $parent_nodes = array(); $child_nodes = array(); $after_nodes = array(); if (count($link_nodes['parentnodes'])) { $home = current($link_nodes['parentnodes']); $url = $router->getURL(array('node' => $home['nodeid'] . '-' . $home['url'], 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'))); $node = array(); $node['url'] = $url; $node['title'] = $home['title']; $prior_nodes[] = $node; $home = next($link_nodes['parentnodes']); reset($link_nodes['parentnodes']); $split_title = $home['title']; $split_nodeid = $home['nodeid']; $spacer = $space; } //next the top-level items. foreach ($link_nodes['topnodes'] as $nodeinfo) { if ($split_nodeid AND ($nodeinfo['title'] > $split_title OR $nodeinfo['nodeid'] == $split_nodeid) ) { $split_title = $nodeinfo['title']; break; } $url = $router->getURL(array('node' => $nodeinfo['nodeid'] . '-' . $nodeinfo['url'], 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'))); $node = array(); $node['url'] = $url; $node['title'] = $spacer . $nodeinfo['title']; $prior_nodes[] = $node; } //Now the parent tree. if (count($link_nodes['parentnodes'])) { $spacer = ''; //we can skip the first, which is the root and we've already displayed. foreach($link_nodes['parentnodes'] as $counter => $nodeinfo) { if ($counter == 0) { continue; } $url = $router->getURL(array('node' => $nodeinfo['nodeid'] . '-' . $nodeinfo['url'], 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'))); $node = array(); $node['url'] = $url; $node['title'] = $spacer . $nodeinfo['title']; $parent_nodes[] = $node; $node = array(); if ($nodeinfo['nodeid'] == $firstid) { $node['url'] = $url; $node['title'] = $spacer . $nodeinfo['title']; } else { $node['title'] = $spacer . ' '. $nodeinfo['title']; } $parent_nodes[] = $node; $spacer .= $space; } } //Now siblings. foreach ($link_nodes['siblingnodes'] as $nodeid => $nodeinfo) { if ($nodeinfo['title'] > $this->content->getTitle() OR $nodeid == $this->widgetid) { break; } $url = $router->getURL(array('node' => $nodeid . '-' . $nodeinfo['url'], 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'))); $node = array(); $node['url'] = $url; $node['title'] = $spacer . $nodeinfo['title']; $prior_nodes[] = $node; } //Now me, just for reference $this_node .= "$spacer" . $this->content->getTitle() ; //Now children foreach ($link_nodes['childnodes'] as $nodeid => $nodeinfo) { $url = $router->getURL(array('node' => $nodeid . '-' . $nodeinfo['url'], 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'))); $node = array(); $node['url'] = $url; $node['title'] = $spacer . $nodeinfo['title']; $child_nodes[] = $node; } //Now remaining siblings. foreach ($link_nodes['siblingnodes'] as $nodeid => $nodeinfo) { if ($nodeinfo['title'] < $this->content->getTitle() OR $nodeid == $this->widgetid) { continue; } $url = $router->getURL(array('node' => $nodeid . '-' . $nodeinfo['url'], 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'))); $node = array(); $node['url'] = $url; $node['title'] = $spacer . $nodeinfo['title']; $after_nodes[] = $node; } //Finally, any remaining top-level nodes foreach ($link_nodes['topnodes'] as $nodeinfo) { if ($nodeinfo['title'] <= $split_title) { continue; } $url = $router->getURL(array('node' => $nodeinfo['nodeid'] . '-' . $nodeinfo['url'], 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'))); $node = array(); $node['url'] = $url; $node['title'] = $space . $nodeinfo['title']; $after_nodes[] = $node; } return array( 'this_node' => $this_node, 'prior_nodes' => $prior_nodes, 'child_nodes' => $child_nodes, 'after_nodes' => $after_nodes ); }
/** * Sets information regarding the report * * @param array Information regarding the report * */ function set_reportinfo(&$reportinfo) { $content = new vBCms_Item_Content_Article($this->extrainfo['node']); parent::set_reportinfo($reportinfo); $reportinfo = array_merge($reportinfo, array('entrytitle' => unhtmlspecialchars($content->getTitle()), 'node' => $this->extrainfo['node'], 'itemlink' => vBCms_Route_Content::getURL(array('node' => $this->extrainfo['node'] . '-' . $content->getUrl())), 'postid' => $this->iteminfo['postid'])); }
public function getInlineEditBodyView() { global $vbphrase; require_once DIR . '/includes/functions_databuild.php'; require_once DIR . '/includes/functions.php'; fetch_phrase_group('cpcms'); $this->config = $this->content->getConfig(); $this->editing = true; //confirm that the user has edit rights if ( (!$this->content->canEdit() AND !$this->content->canUseHtml(vB::$vbulletin->userinfo['userid']) ) OR !$this->content->canPublish() ) { return $vb_phrase['no_edit_permissions']; } vB::$vbulletin->input->clean_array_gpc('r', array( 'do' => vB_Input::TYPE_STR, )); if ($_REQUEST['do'] == 'delete') { $dm = $this->content->getDM(); $dm->delete(); $this->cleanContentCache(); return $vbphrase['article_deleted']; } $view = new vB_View('vbcms_content_' . strtolower($this->class). '_inline'); if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update') { $this->saveData($view); } $this->config = $this->content->getConfig(); require_once DIR . '/packages/vbcms/contentmanager.php'; // Load the content item if (!$this->loadContent($this->getViewInfoFlags(self::VIEW_PAGE))) { throw (new vB_Exception_404()); } global $show; $show['img_bbcode'] = true; // Create view //make sure we have template names. if (empty($this->config['previewtemplate'])) { $this->config['previewtemplate'] = $this->default_previewtemplate; } if (empty($this->config['template'])) { $this->config['template'] = $this->default_template; } // Add the content to the view $view = $this->populateViewContent($view, self::VIEW_PAGE, false); //the configuration settings foreach ($this->config as $key => $value) { if (($key == 'preview_image') OR ($key == 'title')) { $view->$key = htmlspecialchars_uni($value); } else { $view->$key = $value; } } $view->formid = "cms_content_data"; $view->can_edit = $this->content->canEdit() AND $this->content->canUseHtml(vB::$vbulletin->userinfo['userid']); $view->url = $this->content->getUrl(); $view->type = new vB_Phrase('vbcms', 'content'); $view->adding = new vB_Phrase('cpcms', 'adding_x', $vbphrase['article']); $view->html_title = $this->content->getHtmlTitle(); $view->title = $this->content->getTitle(); $view->metadata = $this->content->getMetadataEditor(); $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')); $view->view_url = vBCms_Route_Content::getURL($segments); // Add URL to submit to $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage')); $view->submit_url = vBCms_Route_Content::getURL($segments); $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')); $view->editbar = $this->content->getEditBar($view->submit_url, vBCms_Route_Content::getURL($segments), $view->formid); $view->publisher = $this->content->getPublishEditor($view->submit_url, $view->formid, true, true, $this->content->getPublicPreview(), $this->content->getComments_Enabled()); $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->parentid = $this->content->getParentId(); $view->comment_count = ($this->content->getReplyCount()); $view->contentid = $this->content->getContentId(true); $view->show_threaded = true; $view->per_page = 10; $view->indent_per_level = 5; $view->max_level = 4; // Add form check $this->addPostId($view); return $view; }
/** * Returns the config view for the widget. * * @return vBCms_View_Widget - The view result */ public function getConfigView() { global $vbphrase; require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('cpcms'); $this->assertWidget(); vB::$vbulletin->input->clean_array_gpc('r', array( 'do' => vB_Input::TYPE_STR, 'days' => vB_Input::TYPE_UINT, 'recent_type' => vB_Input::TYPE_STR, 'count' => vB_Input::TYPE_UINT, 'forumchoice' => vB_Input::TYPE_ARRAY, 'template_name' => vB_Input::TYPE_STR, 'min_replies' => vB_Input::TYPE_UINT, 'main_template' => vB_Input::TYPE_STR, 'childforums' => vB_Input::TYPE_BOOL )); $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_exists['days']) { $config['days'] = vB::$vbulletin->GPC['days']; } if (vB::$vbulletin->GPC_exists['min_replies']) { $config['min_replies'] = vB::$vbulletin->GPC['min_replies']; } if (vB::$vbulletin->GPC_exists['count']) { $config['count'] = vB::$vbulletin->GPC['count']; } if (vB::$vbulletin->GPC_exists['recent_type']) { $config['recent_type'] = vB::$vbulletin->GPC['recent_type']; } if (vB::$vbulletin->GPC_exists['template_name']) { $config['template_name'] = vB::$vbulletin->GPC['template_name']; } if (vB::$vbulletin->GPC_exists['main_template']) { $config['main_template'] = vB::$vbulletin->GPC['main_template']; } if (vB::$vbulletin->GPC_exists['forumchoice']) { $config['forumchoice'] = vB::$vbulletin->GPC['forumchoice']; } $config['childforums'] = vB::$vbulletin->GPC_exists['childforums']; $widgetdm = $this->widget->getDM(); $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')); vB_Cache::instance()->event($this->getCacheEvent()); } 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 { $configview = $this->createView('config'); require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('search'); $configview->forumchoice_select = $this->getForums($config); $configview->childforumschecked = ($config['childforums'] ? 'checked="checked"' : ''); $configview->count = $config['count']; $configview->template_name = (isset($config['template_name']) ? $config['template_name'] : 'vbcms_searchresult_thread'); $configview->main_template = (isset($config['main_template']) ? $config['main_template'] : 'vbcms_widget_recent_page'); $configview->min_replies = $config['min_replies']; $configview->days = $config['days']; $typeselected = array(); $recent_typeselected[0]= ($config['recent_type'] == 'active' ? 'checked="checked"' : ''); $recent_typeselected[1]= ($config['recent_type'] == 'recent' ? 'checked="checked"' : ''); $recent_typeselected[2]= ($config['recent_type'] == 'viewed' ? 'checked="checked"' : ''); $recent_typeselected[3]= ($config['recent_type'] == 'mostrated' ? 'checked="checked"' : ''); $recent_typeselected[4]= ($config['recent_type'] == 'bestrated' ? 'checked="checked"' : ''); $configview->recent_typeselected = $recent_typeselected; // 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; }
public function getInlineEditBodyView() { global $vbphrase; require_once DIR . '/includes/functions_databuild.php'; require_once DIR . '/includes/functions.php'; fetch_phrase_group('cpcms'); $this->editing = true; //confirm that the user has edit rights if (!$this->content->canEdit() AND !($this->getUserId() == vB::$vbulletin->userinfo['userid']) AND !$this->content->canPublish()) { return $vb_phrase['no_edit_permissions']; } vB::$vbulletin->input->clean_array_gpc('r', array( 'postid' => vB_Input::TYPE_UINT, 'blogcommentid' => vB_Input::TYPE_UINT, 'do' => vB_Input::TYPE_STR, 'blogid' => TYPE_UINT )); if ($_REQUEST['do'] == 'delete') { $dm = $this->content->getDM(); $dm->delete(); $this->cleanContentCache(); return $vbphrase['article_deleted']; } if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update') { $this->SaveData($view); } require_once DIR . '/packages/vbcms/contentmanager.php'; // Load the content item if (!$this->loadContent($this->getViewInfoFlags(self::VIEW_PAGE))) { throw (new vB_Exception_404()); } global $show; $show['img_bbcode'] = true; // Get smiliecache and bbcodecache vB::$vbulletin->datastore->fetch(array('smiliecache','bbcodecache')); // Create view $view = $this->createView('inline', self::VIEW_PAGE); // Add the content to the view $view = $this->populateViewContent($view, self::VIEW_PAGE, false); $pagetext = $this->content->getPageText(); // Get postings phrasegroup // need posting group require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('posting'); // Build editor global $messagearea; require_once DIR . '/includes/functions_file.php'; require_once DIR . '/includes/functions_editor.php'; require_once(DIR . '/packages/vbattach/attach.php'); $view->formid = "cms_content_data"; $view->can_edit = $this->content->canEdit(); if ($this->content->canEdit()) { $attach = new vB_Attach_Display_Content(vB::$vbulletin, 'vBCms_Article'); //this will set a number of its parameters if they are not already set. $posthash = null; $poststarttime = null; $postattach = array(); $attachcount = 0; $values = "values[f]=" . $this->content->getNodeId() ; $attachmentoption = $attach->fetch_edit_attachments($posthash, $poststarttime, $postattach, $this->content->getNodeId(), $values, '', $attachcount); $attachinfo = fetch_attachmentinfo($posthash, $poststarttime, $this->getContentTypeId(), array('f' => $this->content->getNodeId())); $view->editorid = construct_edit_toolbar( $pagetext, false, new vBCms_Editor_Override(vB::$vbulletin), true, true, true, 'cms_article', '', $attachinfo ); $templater = vB_Template::create('vbcms_article_editor'); $templater->register('attachmentoption', $attachmentoption); $templater->register('attachmentoption', $attachmentoption); $templater->register('posthash', $posthash); $templater->register('poststarttime', $poststarttime); $templater->register('contenttypeid', $this->getContentTypeId()); $templater->register('values', $values); $templater->register('contentid', $this->content->getNodeId()); $templater->register('insertinline ', 1); $templater->register('checked', $checked); $templater->register('disablesmiliesoption', $disablesmiliesoption); $templater->register('editorid', $view->editorid); $templater->register('messagearea', $messagearea); $tag_delimiters = addslashes_js(vB::$vbulletin->options['tagdelimiter']); $templater->register('tag_delimiters', $tag_delimiters); $content = $templater->render(); $view->editor = $content; } else { $view->previewtext = $this->content->getPreviewText();; } $view->url = $this->content->getUrl(); $view->type = new vB_Phrase('vbcms', 'content'); $view->adding = new vB_Phrase('cpcms', 'adding_x', $vbphrase['article']); $view->html_title = $this->content->getHtmlTitle(); $view->title = $this->content->getTitle(); $view->metadata = $this->content->getMetadataEditor(); $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')); $view->view_url = vBCms_Route_Content::getURL($segments); // Add URL to submit to $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage')); $view->submit_url = vBCms_Route_Content::getURL($segments); $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')); $view->editbar = $this->content->getEditBar($view->submit_url, vBCms_Route_Content::getURL($segments), $view->formid); $view->publisher = $this->content->getPublishEditor($view->submit_url, $view->formid, true, true, $this->content->getPublicPreview(), $this->content->getComments_Enabled()); $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->parentid = $this->content->getParentId(); $view->post_started = ($this->content->getPostStarted()); $view->post_posted = ($this->content->getPostPosted()); $view->comment_count = ($this->content->getReplyCount()); $view->contentid = $this->content->getContentId(true); $view->show_threaded = true; $view->per_page = 10; $view->indent_per_level = 5; $view->max_level = 4; // Add form check $this->addPostId($view); return $view; }
/** * Returns the config view for the widget. * * @return vBCms_View_Widget - The view result */ public function getConfigView() { global $vbphrase; require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('cpcms'); $this->assertWidget(); vB::$vbulletin->input->clean_array_gpc('r', array( 'do' => vB_Input::TYPE_STR, 'days' => vB_Input::TYPE_UINT, 'count' => vB_Input::TYPE_UINT, 'template' => vB_Input::TYPE_STR, 'inner_template' => vB_Input::TYPE_STR, 'cache_ttl' => vB_Input::TYPE_UINT, )); $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_exists['days']) { $config['days'] = vB::$vbulletin->GPC['days']; } if (vB::$vbulletin->GPC_exists['count']) { $config['count'] = vB::$vbulletin->GPC['count']; } if (vB::$vbulletin->GPC_exists['template']) { $config['template'] = vB::$vbulletin->GPC['template']; } if (vB::$vbulletin->GPC_exists['inner_template']) { $config['inner_template'] = vB::$vbulletin->GPC['inner_template']; } if (vB::$vbulletin->GPC_exists['cache_ttl']) { $config['cache_ttl'] = vB::$vbulletin->GPC['cache_ttl']; } $widgetdm = $this->widget->getDM(); $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 { $configview = $this->createView('config'); $configview->days = $config['days']; $configview->count = $config['count']; $configview->cache_ttl = $config['cache_ttl']; if (!isset($config['template']) OR ($config['template'] == '') ) { $config['template'] = 'vbcms_widget_recentcmscomments_page'; } if (!isset($config['inner_template']) OR ($config['inner_template'] == '') ) { $config['inner_template'] = 'vbcms_searchresult_newcomment'; } $configview->template = $config['template']; $configview->inner_template = $config['inner_template']; // 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) { global $vbphrase; $this->assertWidget(); vB::$vbulletin->input->clean_array_gpc('r', array( 'do' => vB_Input::TYPE_STR, '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(); $widgetdm = $this->widget->getDM(); if ((vB::$vbulletin->GPC['do'] == 'config') AND $this->verifyPostId()) { if (vB::$vbulletin->GPC_exists['template_name']) { $config['template_name'] = vB::$vbulletin->GPC['template_name']; } if ($this->content) { $widgetdm->setConfigNode($this->content->getNodeId()); } $widgetdm->set('config', $config); $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')); } } if (!isset($config['template_name']) OR ($config['template_name'] == '') ) { $config['template_name'] = 'vbcms_widget_sectionnav_page'; } // add the config content $configview = $this->createView('config'); $configview->template_name = $config['template_name']; // 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; }
/** * 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); }
/** * Fetches the default page URL to the content. * * @return string - The url or boolean false */ public function getEditURL($parameters = false) { $this->loadContent(); return vBCms_Route_Content::getURL(array('node' => $this->getNodeURLSegment(), 'action' => 'edit' )); }
/** * Populates the view with details about the widget. * * @param vB_View $view */ protected function populateViewContent(vB_View $view) { $this->loadWidget(); $view->title = $this->widget->getTitle(); $view->description = $this->widget->getDescription(); $view->id = $this->widget->getId(); $view->package = $this->widget->getPackage(); $view->class = $this->widget->getClass(); $view->page_url = vBCms_Route_Content::getURL(); }
/** * 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; }
/** * Fetches a rich page view of the specified content item. * This method can accept parameters from the client code which are usually * derived from user input. Parameters are passed as an array in the order that * they were received. Parameters do not normally have assoc keys. * * Note: Parameters are always passed raw, so ensure that validation and * escaping is performed where required. * * Skip permissions should allow content to be rendered regardless of the * current user's permissions. * * Child classes will inevitably override this with wildly different * implementations. * * @param array mixed $parameters - Request parameters * @param bool $skip_permissions - Whether to skip can view permission checking * @return vB_View | bool - Returns a view or false */ public function getInlineEditBodyView($parameters = false) { global $vbphrase; require_once DIR . '/includes/functions_databuild.php' ; fetch_phrase_group('cpcms'); //confirm that the user has edit rights if (!$this->content->canEdit()) { return $vb_phrase['no_edit_permissions']; } if ($_REQUEST['do'] == 'delete') { $dm = $this->content->getDM(); $dm->delete(); $this->cleanContentCache(); return $vbphrase['item_deleted']; } // Load the content item if (!$this->loadContent($this->getViewInfoFlags(self::VIEW_PAGE ))) { throw (new vB_Exception_404()); } if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->SaveData(); } // Create view $view = $this->createView('inline', self::VIEW_PAGE); // Add the content to the view $this->populateViewContent($view, self::VIEW_PAGE, false); // Check if inline form was submitted // postback content // TODO: Don't need to escape this with new template syntax $view->formid = 'cms_statichtml_data'; $view->type = new vB_Phrase('vbcms', 'statichtml'); $view->adding = new vB_Phrase('cpcms', 'adding_x', $vbphrase['article']); $view->typetitle = $this->content->getTypeTitle(); $view->metadata = $this->content->getMetadataEditor(); $view->comments_enabled = ($this->content->getComments_Enabled()); $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')); $view->view_url = vBCms_Route_Content::getURL($segments); // Add URL to submit to $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage')); $view->submit_url = vBCms_Route_Content::getURL($segments); $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')); $view->editbar = $this->content->getEditBar($view->submit_url, vBCms_Route_Content::getURL($segments), $view->formid); $view->publisher = $this->content->getPublishEditor($view->submit_url, $view->formid); $view->show_threaded = true; $view->per_page = 10; $this->addPostId($view); return $view; }
/** * Fetches a rich page view of the specified content item. * This method can accept parameters from the client code which are usually * derived from user input. Parameters are passed as an array in the order that * they were received. Parameters do not normally have assoc keys. * * Note: Parameters are always passed raw, so ensure that validation and * escaping is performed where required. * * Skip permissions should allow content to be rendered regardless of the * current user's permissions. * * Child classes will inevitably override this with wildly different * implementations. * * @param array mixed $parameters - Request parameters * @param bool $skip_permissions - Whether to skip can view permission checking * @return vB_View | bool - Returns a view or false */ public function getInlineEditBodyView($parameters = false) { global $vbphrase; require_once DIR . '/includes/functions.php'; require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('cpcms'); $this->editing = true; //confirm that the user has edit rights if (!$this->content->canPublish()) { return new vB_Phrase('cpcms', 'no_edit_permissions'); } if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->checkSaveData($view); unset($_REQUEST['do']); } $this->content->requireInfo(vBCms_Item_Content::INFO_BASIC & vBCms_Item_Content::INFO_CONFIG & vBCms_Item_Content::INFO_NODE & vBCms_Item_Content::INFO_NAVIGATION & vBCms_Item_Content::INFO_PARENTS); $this->content->isValid(); $config = $this->content->getConfig(); //See if we're deleting if ($_REQUEST['do'] == 'delete') { //We can't delete if there is content below if ($record = vB::$vbulletin->db->query_first("SELECT nodeid FROM " . TABLE_PREFIX . "cms_node WHERE parentnode = " . $this->content->getNodeId() . " limit 1") and intval($record['nodeid'])) { return new vB_Phrase('cpcms', 'cannot_delete_with_subnodes'); } $dm = $this->content->getDM(); $dm->delete(); $events = $this->getCleanCacheEvents(); vB_Cache::instance()->event($events); vB_Cache::instance()->cleanNow(); return new vB_Phrase('cpcms', 'section_deleted'); } vB::$vbulletin->input->clean_array_gpc('r', array( 'sortby' => vB_Input::TYPE_STR, 'dir' => vB_Input::TYPE_STR, 'page' => vB_Input::TYPE_INT, 'item_count' => vB_Input::TYPE_INT, 'per_page' => TYPE_INT, 'simple_paging' => TYPE_INT, 'page' => TYPE_INT )); // Load the content item if (!$this->loadContent($this->getViewInfoFlags(self::VIEW_PAGE))) { throw (new vB_Exception_404()); } // Create view $view = $this->createView('inline', self::VIEW_PAGE); // Add the content to the view parent::populateViewContent($view, self::VIEW_PAGE); $this->config = $this->getConfig(); $view->formid = 'cms_content_data'; $view->title = $this->content->getTitle(); $view->html_title = $this->content->getHtmlTitle(); $view->url = $this->content->getUrl(); $view->contentfrom = $this->config['contentfrom']; $view->editshowchildren = $this->content->getEditShowchildren() ? 1 : 0; $view->layout_select = vBCms_ContentManager::getLayoutSelect($this->content->getLayoutSetting(), $this->getParentId()); $view->style_select = vBCms_ContentManager::getStyleSelect($this->content->getStyleSetting()) ; $view->display_order_select = vBCms_ContentManager::getSectionPrioritySelect($this->config['section_priority']) ; $view->content_layout_select = $tmp = vBCms_ContentManager::getContentLayoutSelect($this->config['content_layout']); $view->simple_paging = $this->config['simple_paging']; $view->per_page = $this->config['items_perhomepage']; $view->nodeid = $this->content->getNodeId(); $view->dateformat = vB::$vbulletin->options['dateformat'] . " " . vB::$vbulletin->options['timeformat']; if (intval($this->content->getPublishDate)) { $view->publishdate = $this->content->getPublishDate(); } $aggregate = new vBCms_Collection_Content_Section(); switch(vB::$vbulletin->GPC['sortby']) { case 'title' : $aggregate->setSortBy('ORDER BY title ' . vB::$vbulletin->GPC['dir']); break; case 'setpublish' : $aggregate->setSortBy('ORDER BY setpublish ' . vB::$vbulletin->GPC['dir']); break; case 'displayorder' : $aggregate->setSortBy('ORDER BY displayorder ' . vB::$vbulletin->GPC['dir']); break; case 'username' : $aggregate->setSortBy('ORDER BY username ' . vB::$vbulletin->GPC['dir']); break; case 'publishdate' : $aggregate->setSortBy('ORDER BY publishdate ' . vB::$vbulletin->GPC['dir']); break; case 'pageviews' : $aggregate->setSortBy('ORDER BY viewcount ' . vB::$vbulletin->GPC['dir']); break; case 'replycount': $aggregate->setSortBy('ORDER BY replycount ' . vB::$vbulletin->GPC['dir']); ; break; case 'section': $aggregate->setSortBy('ORDER BY parenttitle ' . vB::$vbulletin->GPC['dir']); ; break; default: $aggregate->setOrderBy(1); ; } // switch //See if we need to hide the children $filter_node = $this->content->getEditShowchildren(); if (!$filter_node) { $aggregate->setFilterNodeExact($this->content->getNodeId()); } else { $aggregate->filterNode($this->content->getNodeId()); } $nodes = array(); $sequence = 0; $candelete = 1; if (vB::$vbulletin->GPC_exists['perpage'] AND intval(vB::$vbulletin->GPC['perpage'])) { $perpage = vB::$vbulletin->GPC['perpage']; } else { $perpage = vBCms_ContentManager::getPerPage(new vB_Legacy_CurrentUser()); } $current_page = (vB::$vbulletin->GPC_exists['page'] AND intval(vB::$vbulletin->GPC['page']) ) ? vB::$vbulletin->GPC['page'] : 1; $aggregate->paginate(); $aggregate->paginateQuantity($perpage); $aggregate->paginatePage($current_page); foreach ($aggregate as $id => $content_node) { $candelete = 0; if ($content_node->getContentTypeid() != vb_Types::instance()->getContentTypeID("vBCms_Section") ) { $sequence++; $nodes[] = array('sequence' => $sequence, 'class' => $content_node->getClass(), 'title' => $content_node->getTitle(), 'html_title' => $content_node->getHtmlTitle(), 'nodeid' => $content_node->getNodeid(), 'prev_checked' => ($content_node->getPublicPreview() ? " checked=\"checked\" " : ''), 'publicpreview' => $content_node->publicpreview, 'parenttitle' => $content_node->getParentTitle(), 'published_select' => vBCms_ContentManager::getPublishedSelect($content_node->getSetPublish(), $content_node->getPublishDate()), 'order_select' => vBCms_ContentManager::getOrderSelect($content_node->getDisplayOrder($this->content->getNodeId()), $this->content->getNodeId()), 'author' => $content_node->getUsername(), 'pub_date' => (intval($content_node->getPublishDate()) ? vbdate(vB::$vbulletin->options['dateformat'], $content_node->getPublishDate()) : '') , 'viewcount' => $content_node->getViewCount(), 'view_url' => vBCms_Route_Content::getURL(array('node' => $content_node->getUrlSegment())), 'replycount' => $content_node->getReplyCount()); } } if (vB::$vbulletin->GPC_exists['item_count']) { $item_count = vB::$vbulletin->GPC['item_count']; } else { $aggregate->filterNoSections(1); $item_count = $aggregate->getCount(); } $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')); $view->view_url = vBCms_Route_Content::getURL($segments); $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage')); $view->submit_url = vBCms_Route_Content::getURL($segments); $base_url = $view->submit_url; $base_url .= strpos($base_url, '?') ? '&' : '?'; $view->record_count = count($aggregate); $view->item_count = $item_count; $pagination = construct_page_nav($current_page, $perpage, $item_count, $view->submit_url); $view->pagination = $pagination; $perpage_select .= '<select name="perpage" onchange="checkShouldSave(\'' . $view->formid . '\', \'perpage\', \'' . vB_Template_Runtime::escapeJS(new vB_Phrase('cpcms', 'confirm_save_section')) . '\', \'' . vB_Template_Runtime::escapeJS($view->submit_url) . '\');">' . "\n"; foreach (array(5,10,15,20,25,50,75,100,200, 250, 500) as $this_perpage) { $perpage_select .= "<option value=\"$this_perpage\"" . (intval($this_perpage) == intval($perpage) ? ' selected="selected" ' : '') . ">$this_perpage</option>\n" ; } $perpage_select .= "</select>"; $view->perpage_select = $perpage_select; $record = vB::$vbulletin->db->query_first("SELECT SUM(childinfo.viewcount) AS viewcount, SUM(CASE when child.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") ." THEN 1 ELSE 0 END) AS content, SUM(CASE when (child.parentnode = node.nodeid AND child.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") .") THEN 1 ELSE 0 END) AS children, SUM(CASE when child.contenttypeid =" . vb_Types::instance()->getContentTypeID("vBCms_Section") ." AND child.parentnode = node.nodeid THEN 1 ELSE 0 END) AS subsections FROM " . TABLE_PREFIX . "cms_node AS node LEFT JOIN " . TABLE_PREFIX . "cms_node AS child ON (child.nodeleft >= node.nodeleft AND child.nodeleft <= node.noderight AND child.nodeid <> node.nodeid AND child.new != 1) LEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo AS childinfo ON childinfo.nodeid = child.nodeid AND child.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") ." WHERE node.nodeid = " . $this->content->getNodeId()); $view->viewcount = $record['viewcount']; $view->content = $record['content']; $view->children = $record['children']; $view->subsections = $record['subsections']; $view->nodes = $nodes; $view->metadata = $this->content->getMetadataEditor(); //Here we create some url's. This should allow to sort in reverse direction $view->sorttitle_url = $base_url . 'sortby=title&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'title' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sortpub_url = $base_url . 'sortby=setpublish&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'setpublish' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sortorder_url = $base_url . 'sortby=displayorder&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'displayorder' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sortauthor_url = $base_url . 'sortby=username&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'username' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sortdate_url = $base_url . 'sortby=publishdate&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'publishdate' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sorthits_url = $base_url . 'sortby=pageviews&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'pageviews' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sortreplycount_url = $base_url . 'sortby=replycount&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'replycount' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sortsection_url = $base_url . 'sortby=section&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'section' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->editbar = $this->content->getEditBar($view->submit_url, $view->view_url, $view->formid, (intval($this->content->getNodeId()) ? 'edit' : 'add'), $candelete); $view->publisher = $this->content->getPublishEditor($view->submit_url, $view->formid, false, false, false, false, $this->config['pagination_links']); $view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Section"); $this->addPostId($view); // Sub menu if (!$this->content->isRoot()) { $view->inherit_section = $this->content->getNavigationParentTitle(); $view->inherited = !$this->content->hasNavigation(); } $navigation_nodes = $this->content->getNavigationNodes(); $subnav_nodes = vBCms_ContentManager::getSections(false, true); // array for the navigation display order drop-down menu $displayorder_array = array(0 => ''); $count = max(count($nodes), 40); for ($i=1; $i <= $count; $i++) { $displayorder_array[$i] = $i; } // populate sub-nav configuration menu with all cms sections $sections = array(); $subnav = new vB_View('vbcms_content_section_subnavedit'); $subnav->displayorder_array = $displayorder_array; foreach ($subnav_nodes AS $node) { $nodeid = $node['nodeid']; // check if the section has already been selected for the menu nav // if so, its position in the array (key+1) is its display order $displayorder = 0; //default display order is 0 $selected = false; if (isset($navigation_nodes) AND is_array($navigation_nodes)) { if ($selected = in_array($nodeid, $navigation_nodes)) { $displayorder = array_search($nodeid, $navigation_nodes) + 1; } } $sections[] = array('id' => $nodeid, 'title' => $node['title'], 'depth' => $node['depth'], 'selected' => $selected, 'displayorder' => $displayorder); } $subnav->sections = $sections; $subnav_rendered = $subnav->render(); $view->subnav = $subnav_rendered; unset($nodes, $subnav_nodes, $sections); return $view; }
/** * Returns the config view for the widget. * * @return vBCms_View_Widget - The view result */ public function getConfigView() { require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('cpcms'); $this->assertWidget(); vB::$vbulletin->input->clean_array_gpc('r', array( 'do' => vB_Input::TYPE_STR, 'url' => vB_Input::TYPE_STR, 'template_name' => vB_Input::TYPE_STR, 'use_rss_title' => vB_Input::TYPE_BOOL, 'max_items' => 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()) { $config['url'] = convert_urlencoded_unicode(vB::$vbulletin->GPC['url']); $config['use_rss_title'] = vB::$vbulletin->GPC['use_rss_title']; if (vB::$vbulletin->GPC_exists['template_name']) { $config['template_name'] = vB::$vbulletin->GPC['template_name']; } if (vB::$vbulletin->GPC_exists['max_items']) { $config['max_items'] = vB::$vbulletin->GPC['max_items']; } $widgetdm = $this->widget->getDM(); $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_rss_page'; } // add the config content $configview->use_rss_title = $config['use_rss_title']; $configview->template_name = $config['template_name']; $configview->max_items = $config['max_items']; $configview->url = $config['url'] ? htmlspecialchars_uni($config['url']) : $config['url']; // 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() { $this->assertWidget(); vB::$vbulletin->input->clean_array_gpc('r', array( 'do' => vB_Input::TYPE_STR, 'days' => vB_Input::TYPE_UINT, 'ids' => vB_Input::TYPE_STR, 'count' => vB_Input::TYPE_UINT, 'forumchoice' => vB_Input::TYPE_ARRAY, 'childforums' => vB_Input::TYPE_BOOL, 'template_name' => vB_Input::TYPE_STR, 'detail_template' => 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_exists['days']) { $config['days'] = vB::$vbulletin->GPC['days']; } if (vB::$vbulletin->GPC_exists['count']) { $config['count'] = vB::$vbulletin->GPC['count']; } if (vB::$vbulletin->GPC_exists['template_name']) { $config['template_name'] = vB::$vbulletin->GPC['template_name']; } if (vB::$vbulletin->GPC_exists['detail_template']) { $config['detail_template'] = vB::$vbulletin->GPC['detail_template']; } if (vB::$vbulletin->GPC_exists['ids']) { $ids = array_unique(explode(',', vB::$vbulletin->GPC['ids'])); $cleaned = array(); foreach ($ids as $id) { if (intval($id) ) { $cleaned[] = intval($id); } } $ids = implode(',', $cleaned); $config['ids'] = $ids ; } if (vB::$vbulletin->GPC_exists['forumchoice']) { $config['forumchoice'] = vB::$vbulletin->GPC['forumchoice']; } $config['childforums'] = vB::$vbulletin->GPC_exists['childforums']; $widgetdm = $this->widget->getDM(); $widgetdm->set('config', $config); if ($this->content) { $widgetdm->setConfigNode($this->content->getNodeId()); } $widgetdm->save(); //clear the cache for this widget vB_Cache::instance()->event('poll_widget_' . $this->widget->getId()); 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 { $configview = $this->createView('config'); require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('search'); if (!isset($config['template_name']) OR ($config['template_name'] == '') ) { $config['template_name'] = 'vbcms_widget_poll_page'; } if (!isset($config['detail_template']) OR ($config['detail_template'] == '') ) { $config['detail_template'] = 'vbcms_widget_poll_resultdetail'; } // add the config content $configview->template_name = $config['template_name']; $configview->detail_template = $config['detail_template']; $configview->forumchoice_select = $this->getForums($config); $configview->childforumschecked = ($config['childforums'] ? 'checked="checked"' : ''); $configview->count = $config['count']; $configview->days = $config['days']; $configview->ids = $config['ids']; // 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; }