protected function fetchParentTitle($nodeid) { if (!$this->content['cms_section']) { $sections = vBCms_ContentManager::getSections(); foreach ($sections as $key => $section) { $this->content['cms_section'][$section['nodeid']] = $section; } } return $this->content['cms_section'][$nodeid]['title']; }
protected function saveData($view) { if ($this->data_saved) { return true; } $this->data_saved = true; if (!$this->content->canEdit() AND !$this->content->canPublish() ) { return $vb_phrase['no_edit_permissions']; } require_once DIR . '/includes/functions.php'; // collect error messages $errors = array(); vB::$vbulletin->input->clean_array_gpc('p', array( 'do' => vB_Input::TYPE_STR, 'cms_node_title' => vB_Input::TYPE_STR, 'cms_node_url' => vB_Input::TYPE_STR, 'message' => vB_Input::TYPE_STR, 'url' => vB_Input::TYPE_NOHTML, 'title' => vB_Input::TYPE_NOHTML, 'setpublish' => vB_Input::TYPE_UINT, 'publishdate' => vB_Input::TYPE_UINT, 'html_title' => vB_Input::TYPE_NOHTML, 'publicpreview' => vB_Input::TYPE_UINT, 'new_parentid' => vB_Input::TYPE_UINT, 'comments_enabled' => vB_Input::TYPE_UINT, 'wysiwyg' => vB_Input::TYPE_BOOL, 'parseurl' => vB_Input::TYPE_BOOL, 'posthash' => vB_Input::TYPE_NOHTML, 'poststarttime' => vB_Input::TYPE_UINT, 'htmlstate' => vB_Input::TYPE_NOHTML, )); ($hook = vBulletinHook::fetch_hook('vbcms_article_save_start')) ? eval($hook) : false; $dm = $this->content->getDM(); $dm->set('contentid', $this->content->getId()); if ($this->content->canEdit()) { // get pagetext $pagetext = vB::$vbulletin->GPC['message']; $html_title = vB::$vbulletin->GPC['html_title']; $title = vB::$vbulletin->GPC['title']; // unwysiwygify the incoming data if (vB::$vbulletin->GPC['wysiwyg']) { $html_parser = new vBCms_WysiwygHtmlParser(vB::$vbulletin); $pagetext = $html_parser->parse($pagetext); } $dm->info['parseurl'] = true; $dm->set('pagetext', $pagetext); if ($title) { $dm->set('title', $pagetext); } $bbcodesearch = array(); $video_location = stripos($pagetext, '[video'); $found_image = false; // populate the preview image field with [img] if we can find one if (($i = stripos($pagetext, '[IMG]')) !== false and ($j = stripos($pagetext, '[/IMG]')) AND $j > $i) { $previewimage = htmlspecialchars_uni(substr($pagetext, $i+5, $j - $i - 5)); $image_location = $i; if ($size = @getimagesize($previewimage)) { $dm->set('previewimage', $previewimage); $dm->set('imagewidth', $size[0]); $dm->set('imageheight', $size[1]); $bbcodesearch[] = substr($pagetext, $i, $j + 6); $found_image = true; } } // or populate the preview image field with [attachment] if we can find one if (!$found_image) { $i = stripos($pagetext, "[ATTACH=CONFIG]"); $j = stripos($pagetext, '[/ATTACH]'); if ($j !== false) { if ($i === false) { $i = stripos($pagetext, "[ATTACH]"); if ($i !== false AND ($i > $j)) { $attachmentid = substr($pagetext, $i + 15, $j - $i - 15); $found_image = $this->getAttachData($attachmentid, $dm, $bbcodesearch); } } else if ($i > $j) { $attachmentid = substr($pagetext, $i + 15, $j - $i - 15); $found_image = $this->getAttachData($attachmentid, $dm, $bbcodesearch); } } } if (!$found_image AND $this->content->canDownload()) { require_once(DIR . '/packages/vbattach/attach.php'); $attach = new vB_Attach_Display_Content(vB::$vbulletin, 'vBCms_Article'); $attachments = $attach->fetch_postattach(0, $this->content->getNodeId(), $this->content->getUserId()); if (!empty($attachments)) { foreach($attachments as $attachment) { if ($attachment['hasthumbnail']) { $found_image = $this->getAttachData($attachment['attachmentid'], $dm, $bbcodesearch); if ($found_image) { break; } } } } } // if there are no images in the article body, make sure we unset the preview in the db if (!$found_image ) { $dm->set('previewimage', ''); $dm->set('imagewidth', 0); $dm->set('imageheight', 0); $image_location = intval($video_location) + 1; } $parseurl = false; $providers = $search = $replace = $previewvideo = array(); ($hook = vBulletinHook::fetch_hook('data_preparse_bbcode_video_start')) ? eval($hook) : false; // Convert video bbcode with no option if ((($video_location !== false) AND (intval($video_location) < intval($image_location))) OR $parseurl) { if (!$providers) { $bbcodes = vB::$db->query_read_slave(" SELECT provider, url, regex_url, regex_scrape, tagoption FROM " . TABLE_PREFIX . "bbcode_video ORDER BY priority "); while ($bbcode = vB::$db->fetch_array($bbcodes)) { $providers["$bbcode[tagoption]"] = $bbcode; } } $scraped = 0; if (!empty($providers) AND preg_match_all('#\[video[^\]]*\](.*?)\[/video\]#si', $pagetext, $matches)) { foreach ($matches[1] AS $key => $url) { $match = false; foreach ($providers AS $provider) { $addcaret = ($provider['regex_url'][0] != '^') ? '^' : ''; if (preg_match('#' . $addcaret . $provider['regex_url'] . '#si', $url, $match)) { break; } } if ($match) { if (!$provider['regex_scrape'] AND $match[1]) { $previewvideo['provider'] = $provider['tagoption']; $previewvideo['code'] = $match[1]; $previewvideo['url'] = $url; $bbcodesearch[] = $matches[0][$key]; break; } else if ($provider['regex_scrape'] AND vB::$vbulletin->options['bbcode_video_scrape'] > 0 AND $scraped < vB::$vbulletin->options['bbcode_video_scrape']) { require_once(DIR . '/includes/functions_file.php'); $result = fetch_body_request($url); if (preg_match('#' . $provider['regex_scrape'] . '#si', $result, $scrapematch)) { $previewvideo['provider'] = $provider['tagoption']; $previewvideo['code'] = $scrapematch[1]; $previewvideo['url'] = $url; $bbcodesearch[] = $matches[0][$key]; break; } $scraped++; } } } } } $htmlstate = vB::$vbulletin->GPC_exists['htmlstate'] ? vB::$vbulletin->GPC['htmlstate'] : $this->content->getHtmlState(); // Try to populate previewvideo html if ($previewvideo) { $templater = vB_Template::create('bbcode_video'); $templater->register('url', $previewvideo['url']); $templater->register('provider', $previewvideo['provider']); $templater->register('code', $previewvideo['code']); $dm->set('previewvideo', $templater->render()); $dm->set('previewimage', ''); $dm->set('imagewidth', 0); $dm->set('imageheight', 0); $image_location = -1; } else { $dm->set('previewvideo', ''); } } if ($this->content->canPublish()) { $old_sectionid = $this->content->getParentId(); //set the values, for the dm and update the content. if ( vB::$vbulletin->GPC_exists['new_parentid'] AND intval(vB::$vbulletin->GPC['new_parentid'])) { vBCms_ContentManager::moveSection(array($this->content->getNodeId()), vB::$vbulletin->GPC['new_parentid']); $new_sectionid = vB::$vbulletin->GPC['new_parentid']; } if (vB::$vbulletin->GPC_exists['publicpreview']) { $dm->set('publicpreview', vB::$vbulletin->GPC['publicpreview']); } if (vB::$vbulletin->GPC_exists['comments_enabled']) { $dm->set('comments_enabled', vB::$vbulletin->GPC['comments_enabled']); } if (vB::$vbulletin->GPC_exists['setpublish']) { $dm->set('setpublish', vB::$vbulletin->GPC['setpublish']); } } if (vB::$vbulletin->GPC_exists['html_title']) { $dm->set('html_title', vB::$vbulletin->GPC['html_title']); } if (vB::$vbulletin->GPC_exists['url']) { $dm->set('url', vB::$vbulletin->GPC['url']); } if (vB::$vbulletin->GPC_exists['htmlstate']) { $dm->set('htmlstate', vB::$vbulletin->GPC['htmlstate']); } //We may have some processing to do for public preview. Let's see if comments // are enabled. We never enable them for sections, and they might be turned off globally. vB::$vbulletin->input->clean_array_gpc('r', array( 'publicpreview' => TYPE_UINT)); $success = $dm->saveFromForm($this->content->getNodeId()); $this->changed = true; if ($dm->hasErrors()) { $fieldnames = array( 'html_title' => new vB_Phrase('vbcms', 'html_title'), 'title' => new vB_Phrase('global', 'title') ); $view->errors = $dm->getErrors(array_keys($fieldnames)); $view->error_summary = self::getErrorSummary($dm->getErrors(array_keys($fieldnames)), $fieldnames); $view->status = $view->error_view->title; } else { $view->status = new vB_Phrase('vbcms', 'content_saved'); $this->cleanContentCache(); // Make sure the posthash is valid if (md5(vB::$vbulletin->GPC['poststarttime'] . vB::$vbulletin->userinfo['userid'] . vB::$vbulletin->userinfo['salt']) == vB::$vbulletin->GPC['posthash']) { vB::$vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . "attachment SET posthash = '', contentid = " . intval($this->content->getNodeId()) . " WHERE posthash = '" . vB::$vbulletin->db->escape_string(vB::$vbulletin->GPC['posthash']) . "' AND contenttypeid = " . intval(vB_Types::instance()->getContentTypeID("vBCms_Article")) . " "); } // only publish to Facebook if we are going from not-published to published, and the date is in the past if (is_facebookenabled() AND $this->content->isPublished()) { $message = new vB_Phrase('posting', 'fbpublish_message_newarticle', vB::$vbulletin->options['bbtitle']); $fblink = vBCms_Route_Content::getURL(array( 'node' => $this->content->getUrlSegment(), 'action' =>'view' )); $fblink = str_ireplace('&', '&', $fblink); publishtofacebook_newarticle($message, $this->content->getTitle(), $this->content->getPageText(), create_full_url($fblink)); } } ($hook = vBulletinHook::fetch_hook('vbcms_article_save_end')) ? eval($hook) : false; //invalidate the navigation cache. vB_Cache::instance()->event('sections_updated'); vB_Cache::instance()->event('articles_updated'); vB_Cache::instance()->event(array_merge($this->content->getCacheEvents(), array($this->content->getContentCacheEvent()))); //Make sure comment count will be updated when a comment is posted if ($threadid = $this->content->getAssociatedThreadId()) { vB_Cache::instance()->event("cms_comments_thread_$threadid"); } vB_Cache::instance()->cleanNow(); $this->content->reset(); //reset the required information $this->content->requireInfo(vBCms_Item_Content::INFO_BASIC); $this->content->requireInfo(vBCms_Item_Content::INFO_CONTENT); $this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG); $this->content->requireInfo(vBCms_Item_Content::INFO_NODE); $this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS); }
protected function saveData($view) { //confirm that the user has edit rights if (!(($this->content->canEdit() OR ($this->getUserId() == vB::$vbulletin->userinfo['userid'])) AND $this->content->canUseHtml(vB::$vbulletin->userinfo['userid'])) AND !$this->content->canPublish()) { return new vB_Phrase('global', 'no_edit_permissions'); } $this->config = $this->content->getConfig(); require_once DIR . '/includes/functions.php'; // collect error messages $errors = array(); //We don't need to change the cache lifetime for static page, our descendants will vB::$vbulletin->input->clean_array_gpc('p', array( 'do' => vB_Input::TYPE_STR, 'message' => vB_Input::TYPE_STR, 'url' => vB_Input::TYPE_NOHTML, 'title' => vB_Input::TYPE_NOHTML, 'cms_node_title' => vB_Input::TYPE_NOHTML, 'setpublish' => vB_Input::TYPE_UINT, 'html_title' => vB_Input::TYPE_NOHTML, 'publicpreview' => vB_Input::TYPE_UINT, 'new_parentid' => vB_Input::TYPE_UINT, 'cache_ttl' => vB_Input::TYPE_UINT, 'comments_enabled' => vB_Input::TYPE_UINT, 'parseurl' => vB_Input::TYPE_BOOL, 'posthash' => vB_Input::TYPE_NOHTML, 'htmlstate' => vB_Input::TYPE_NOHTML, 'pagetext' => vB_Input::TYPE_STR, 'previewtext' => vB_Input::TYPE_STR, 'previewtemplate' => vB_Input::TYPE_STR, 'template' => vB_Input::TYPE_STR, 'preview_image' => vB_Input::TYPE_STR, )); ($hook = vBulletinHook::fetch_hook($this->savestarthook)) ? eval($hook) : false; $dm = $this->content->getDM(); if ($this->content->canEdit() AND $this->content->canUseHtml(vB::$vbulletin->userinfo['userid'])) { $html_title = vB::$vbulletin->GPC['html_title']; if (vB::$vbulletin->GPC_exists['pagetext']) { $this->config['pagetext'] = vB::$vbulletin->GPC['pagetext']; } if (vB::$vbulletin->GPC_exists['preview_image']) { $this->config['preview_image'] = vB::$vbulletin->GPC['preview_image']; } if (vB::$vbulletin->GPC_exists['previewtext']) { $this->config['previewtext'] = vB::$vbulletin->GPC['previewtext']; } //make sure we have preview text. if (empty($this->config['previewtext']) AND !empty($this->config['pagetext'])) { $this->config['previewtext'] = htmlspecialchars_uni(fetch_censored_text( trim(fetch_trimmed_title(strip_bbcode($this->config['pagetext'], true, false, false), vB::$vbulletin->options['default_cms_previewlength'])))); } if (vB::$vbulletin->GPC_exists['previewtemplate']) { $this->config['previewtemplate'] = vB::$vbulletin->GPC['previewtemplate']; } if (vB::$vbulletin->GPC_exists['template']) { $this->config['template'] = vB::$vbulletin->GPC['template']; } //For the descendants, at least phpeval if (vB::$vbulletin->GPC_exists['cache_ttl']) { $this->config['cache_ttl'] = vB::$vbulletin->GPC['cache_ttl']; } if (count($this->config)) { $dm->set('config', $this->config); $this->content->setConfig($this->config); } if (vB::$vbulletin->GPC_exists['cms_node_title']) { $title = vB::$vbulletin->GPC['cms_node_title']; $dm->set('title', $title); } } if ($this->content->canPublish()) { $old_sectionid = $this->content->getParentId(); //set the values, for the dm and update the content. if ( vB::$vbulletin->GPC_exists['new_parentid'] AND intval(vB::$vbulletin->GPC['new_parentid'])) { vBCms_ContentManager::moveSection(array($this->content->getNodeId()), vB::$vbulletin->GPC['new_parentid']); $new_sectionid = vB::$vbulletin->GPC['new_parentid']; } if (vB::$vbulletin->GPC_exists['publicpreview']) { $dm->set('publicpreview', vB::$vbulletin->GPC['publicpreview']); } if (vB::$vbulletin->GPC_exists['comments_enabled']) { $dm->set('comments_enabled', vB::$vbulletin->GPC['comments_enabled']); } if (vB::$vbulletin->GPC_exists['setpublish']) { $dm->set('setpublish', vB::$vbulletin->GPC['setpublish']); } } if (vB::$vbulletin->GPC_exists['html_title']) { $dm->set('html_title', vB::$vbulletin->GPC['html_title']); } if (vB::$vbulletin->GPC_exists['url']) { $dm->set('url', vB::$vbulletin->GPC['url']); } //We may have some processing to do for public preview. Let's see if comments // are enabled. We never enable them for sections, and they might be turned off globally. vB::$vbulletin->input->clean_array_gpc('r', array( 'publicpreview' => TYPE_UINT)); $dm->set('contentid', $this->content->getNodeId()); $success = $dm->saveFromForm($this->content->getNodeId()); //Make sure that items we render don't decide to save random data. $_POST['do'] = ''; $_REQUEST['do'] = ''; vB::$vbulletin->GPC['do'] = ''; vB::$vbulletin->GPC_exists['do'] = false; if ($dm->hasErrors()) { $fieldnames = array( 'html_title' => new vB_Phrase('vbcms', 'html_title'), 'title' => new vB_Phrase('global', 'title') ); $view->errors = $dm->getErrors(array_keys($fieldnames)); $view->error_summary = self::getErrorSummary($dm->getErrors(array_keys($fieldnames)), $fieldnames); $view->status = $view->error_view->title; } else { $view->status = new vB_Phrase('vbcms', 'content_saved'); $this->cleanContentCache(); } ($hook = vBulletinHook::fetch_hook($this->saveendhook)) ? eval($hook) : false; //invalidate the appropriate cache entries. vB_Cache::instance()->event(array_merge($this->content->getCacheEvents(),array('sections_updated','articles_updated', $this->content->getContentCacheEvent()))); vB_Cache::instance()->cleanNow(); $view->html_title = $html_title; $view->title = $title; $this->content->reset(); $this->changed = true; }
/** * 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; }
/** * Displays and controls the AJAX config UI for the page content. * * @return string */ public function actionConfigContent() { // Create the page view $view = new vB_View_Page('vbcms_edit_page'); $view->page_url = vB_Router::getURL(); // Get content if (! $this->content) { $this->content = vBCms_Content::create($this->node->getPackage(), $this->node->getClass(), $this->node->getContentId()); } $view->rawtitle = $this->node->getTitle(); vB::$vbulletin->options['description'] = $this->node->getDescription(); vB::$vbulletin->options['keywords'] = $this->node->getKeywords(); // Render the content's config view and return $view->content = $this->content->getConfigView(); //Here's some javascript we need in page content; $view->showscripts = vBCms_ContentManager::showJs('.'); // Add general page info $view->setBreadcrumbInfo($this->node->getBreadcrumbInfo()); $view->setPageTitle($this->content->getTitle()); $view->pagedescription = $this->content->getDescription(); $view->published = $this->node->isPublished(); // Render the content's config view and return return $view; }
public function getPreviewText($forceload = false) { $context = new vB_Context($this->package . '_' . $this->class . '_previewtext_' . $this->nodeid); $hashkey = strval($context); if (!$forceload AND ($rendered = vB_Cache::instance()->read($hashkey, true, true))) { return $rendered; } require_once DIR . '/includes/functions.php'; $this->Load(self::INFO_CONTENT); //First, parse the bbcode. $html_parser = new vBCms_WysiwygHtmlParser(vB::$vbulletin); //if we have any video code we need to throw it away. The parser doesn't do that. $previewtext = vBCms_ContentManager::makePreviewText($this->pagetext, vB::$vbulletin->options['default_cms_previewlength'], $this->canUseHtml($this->userid), $this->htmlstate); vB_Cache::instance()->write($hashkey , $previewtext, 1440, array_merge($this->getCacheEvents(), array($this->getContentCacheEvent()))); return fetch_censored_text($previewtext) ; }
protected function saveData() { // collect error messages $errors = array(); vB::$vbulletin->input->clean_array_gpc('p', array( 'do' => vB_Input::TYPE_STR, 'html' => vB_Input::TYPE_STR, 'title' => vB_Input::TYPE_STR, 'new_parentid' => TYPE_INT, 'html_title' => vB_Input::TYPE_STR, 'publicpreview' => TYPE_INT, 'item_id' => vB_Input::TYPE_INT )); if (vB::$vbulletin->GPC['do'] == 'movenode' and vB::$vbulletin->GPC_exists['new_parentid'] AND intval(vB::$vbulletin->GPC['new_parentid'])) { vBCms_ContentManager::moveSection(array($this->content->getNodeId()), vB::$vbulletin->GPC['new_parentid']); $new_sectionid = vB::$vbulletin->GPC['new_parentid']; } $new_values = array(); // create DM and save $dm = $this->content->getDM(); $dm->set('contentid', $this->content->getId()); $dm->set('item_id', $this->content->getId()); if (vB::$vbulletin->GPC_exists['html_title']) { $new_values['html_title'] = vB::$vbulletin->GPC['html_title']; $dm->set('html_title', vB::$vbulletin->GPC['html_title']); } if (vB::$vbulletin->GPC_exists['html']) { $new_values['html'] = vB::$vbulletin->GPC['html']; $dm->set('html', vB::$vbulletin->GPC['html']); } if (vB::$vbulletin->GPC_exists['comments_enabled']) { $new_values['comments_enabled'] = vB::$vbulletin->GPC['comments_enabled']; $dm->set('comments_enabled', vB::$vbulletin->GPC['comments_enabled']); } if (vB::$vbulletin->GPC_exists['title']) { $new_values['title'] = vB::$vbulletin->GPC['title']; $dm->set('title', vB::$vbulletin->GPC['title']); } if (vB::$vbulletin->GPC_exists['publicpreview']) { $new_values['publicpreview'] = vB::$vbulletin->GPC['publicpreview']; $dm->set('publicpreview', vB::$vbulletin->GPC['publicpreview']); } // add node info $dm->setNodeTitle($title); // set the node segment if it's empty if (!$this->content->getUrlTitle()) { $dm->setNodeURLSegment($title); } $success = $dm->saveFromForm($this->content->getNodeId()); //invalidate the navigation cache. vB_Cache::instance()->event(array('sections_updated' )); vBCms_Content::cleanContentCache(); if ($dm->hasErrors()) { $fieldnames = array( 'html' => new vB_Phrase('vbcms', 'html') ); $view->errors = $dm->getErrors(array_keys($fieldnames)); $view->error_summary = self::getErrorSummary($dm->getErrors(array_keys($fieldnames)), $fieldnames); $view->status = $view->error_view->title; } else { $view->status = new vB_Phrase('vbcms', 'content_saved'); $this->cleanContentCache(); } // postback content $view->html_title = $new_values['html_title']; $view->title = $new_values['title']; }
public function saveFromForm($nodeid) { vB::$vbulletin->input->clean_array_gpc('r', array( 'html_title' => vB_Input::TYPE_NOHTML, 'cms_node_title' => vB_Input::TYPE_NOHTML, 'cms_node_url' => vB_Input::TYPE_STR, 'description' => vB_Input::TYPE_NOHTML, 'layoutid' => vB_Input::TYPE_INT, 'section_styleid' => vB_Input::TYPE_NOCLEAN, 'setpublish' => vB_Input::TYPE_INT, 'publishdate' => vB_Input::TYPE_STR, 'publishtime' => vB_Input::TYPE_ARRAY, 'publicpreview' => vB_Input::TYPE_INT, 'comments_enabled' => vB_Input::TYPE_INT, 'keywords' => vB_Input::TYPE_NOHTML, 'section_menu_inherit' => TYPE_BOOL, 'section_menu_sections' => TYPE_ARRAY_INT, 'showtitle' => vB_Input::TYPE_INT, 'showuser' => vB_Input::TYPE_INT, 'showpreviewonly' => vB_Input::TYPE_INT, 'showupdated' => vB_Input::TYPE_INT, 'showviewcount' => vB_Input::TYPE_INT, 'showpublishdate' => vB_Input::TYPE_INT, 'settingsforboth' => vB_Input::TYPE_INT, 'includechildren' => vB_Input::TYPE_INT, 'showall' => vB_Input::TYPE_INT, 'editshowchildren' => vB_Input::TYPE_INT, 'showrating' => vB_Input::TYPE_INT, 'hidden' => vB_Input::TYPE_INT, 'shownav' => vB_Input::TYPE_INT, 'nosearch' => vB_Input::TYPE_INT, 'display_order_select' => TYPE_ARRAY_INT )); $this->set('nodeid', $nodeid); //set the values if (vB::$vbulletin->GPC_exists['cms_node_url'] and vB::$vbulletin->GPC['cms_node_url'] != '') { //Let's do some cleanup of the url. $this->set('url', vB_Friendly_Url::clean_entities(vB::$vbulletin->GPC['cms_node_url'], true)); $this->item->setInfo(array('url'=> vB::$vbulletin->GPC['cms_node_url'])); } if (vB::$vbulletin->GPC_exists['description']) { $this->set('description', vB::$vbulletin->GPC['description']); $this->item->setInfo(array('description'=> vB::$vbulletin->GPC['description'])); } if (vB::$vbulletin->GPC_exists['cms_node_title']) { $this->set('title', vB::$vbulletin->GPC['cms_node_title']); $this->item->setInfo(array('title'=> vB::$vbulletin->GPC['cms_node_title'])); $this->setNodeTitle(vB::$vbulletin->GPC['cms_node_title']); } if (vB::$vbulletin->GPC_exists['html_title']) { $this->set('html_title', vB::$vbulletin->GPC['html_title']); $this->item->setInfo(array('html_title'=> vB::$vbulletin->GPC['html_title'])); } if (vB::$vbulletin->GPC_exists['setpublish']) { $this->set('setpublish', vB::$vbulletin->GPC['setpublish']); $this->item->setInfo(array('setpublish'=> vB::$vbulletin->GPC['setpublish'])); } if (vB::$vbulletin->GPC_exists['publishdate'] AND intval(vB::$vbulletin->GPC['publishdate'])) { $str_date = str_replace('-', '/', vB::$vbulletin->GPC['publishdate']); //if the user set a time it's from a different variable. if (vB::$vbulletin->GPC_exists['publishtime']) { $str_date .= ' ' . vB::$vbulletin->GPC['publishtime']['hour'] . ':' . vB::$vbulletin->GPC['publishtime']['minute'] . ' ' . vB::$vbulletin->GPC['publishtime']['offset']; } // make sure we adjust for local time before saving publish timestamp $offset = vBCms_ContentManager::getTimeOffset(vB::$vbulletin->userinfo, false) - date('Z'); $publishdate = strtotime($str_date,0) - $offset; $this->set('publishdate', $publishdate); $this->item->setInfo(array('publishdate'=> $publishdate)); } if (vB::$vbulletin->GPC_exists['keywords']) { $this->set('keywords', vB::$vbulletin->GPC['keywords']); $this->item->setInfo(array('keywords'=> vB::$vbulletin->GPC['keywords'])); } if (vB::$vbulletin->GPC_exists['section_styleid']) { $this->set('styleid', vB::$vbulletin->GPC['section_styleid']); $this->item->setInfo(array('styleid'=> vB::$vbulletin->GPC['section_styleid'])); } if (vB::$vbulletin->GPC_exists['layoutid']) { $this->set('layoutid', vB::$vbulletin->GPC['layoutid']); $this->item->setInfo(array('layoutid'=> vB::$vbulletin->GPC['layoutid'])); } if (vB::$vbulletin->GPC_exists['publicpreview']) { $this->set('publicpreview', vB::$vbulletin->GPC['publicpreview']); $this->item->setInfo(array('publicpreview'=> vB::$vbulletin->GPC['publicpreview'])); } if (vB::$vbulletin->GPC_exists['comments_enabled']) { $this->set('comments_enabled', vB::$vbulletin->GPC['comments_enabled']); $this->item->setInfo(array('comments_enabled'=> vB::$vbulletin->GPC['comments_enabled'])); } if (vB::$vbulletin->GPC_exists['showtitle']) { $this->set('showtitle', vB::$vbulletin->GPC['showtitle']); $this->item->setInfo(array('showtitle'=> vB::$vbulletin->GPC['showtitle'])); } if (vB::$vbulletin->GPC_exists['showuser']) { $this->set('showuser', vB::$vbulletin->GPC['showuser']); $this->item->setInfo(array('showuser'=> vB::$vbulletin->GPC['showuser'])); } if (vB::$vbulletin->GPC_exists['showpreviewonly']) { $this->set('showpreviewonly', vB::$vbulletin->GPC['showpreviewonly']); $this->item->setInfo(array('showpreviewonly'=> vB::$vbulletin->GPC['showpreviewonly'])); } if (vB::$vbulletin->GPC_exists['showupdated']) { $this->set('showupdated', vB::$vbulletin->GPC['showupdated']); $this->item->setInfo(array('showupdated'=> vB::$vbulletin->GPC['showupdated'])); } if (vB::$vbulletin->GPC_exists['showviewcount']) { $this->set('showviewcount', vB::$vbulletin->GPC['showviewcount']); $this->item->setInfo(array('showviewcount'=> vB::$vbulletin->GPC['showviewcount'])); } if (vB::$vbulletin->GPC_exists['showpublishdate']) { $this->set('showpublishdate', vB::$vbulletin->GPC['showpublishdate']); $this->item->setInfo(array('showpublishdate'=> vB::$vbulletin->GPC['showpublishdate'])); } if (vB::$vbulletin->GPC_exists['settingsforboth']) { $this->set('settingsforboth', vB::$vbulletin->GPC['settingsforboth']); $this->item->setInfo(array('settingsforboth'=> vB::$vbulletin->GPC['settingsforboth'])); } if (vB::$vbulletin->GPC_exists['includechildren']) { $this->set('includechildren', vB::$vbulletin->GPC['includechildren']); $this->item->setInfo(array('includechildren'=> vB::$vbulletin->GPC['includechildren'])); } if (vB::$vbulletin->GPC_exists['showall']) { $this->set('showall', vB::$vbulletin->GPC['showall']); $this->item->setInfo(array('showall'=> vB::$vbulletin->GPC['showall'])); } if (vB::$vbulletin->GPC_exists['showrating']) { $this->set('showrating', vB::$vbulletin->GPC['showrating']); $this->item->setInfo(array('showrating'=> vB::$vbulletin->GPC['showrating'])); } if (vB::$vbulletin->GPC_exists['hidden']) { $this->set('hidden', vB::$vbulletin->GPC['hidden']); $this->item->setInfo(array('hidden'=> vB::$vbulletin->GPC['hidden'])); } if (vB::$vbulletin->GPC_exists['shownav']) { $this->set('shownav', vB::$vbulletin->GPC['shownav']); $this->item->setInfo(array('shownav'=> vB::$vbulletin->GPC['shownav'])); } if (vB::$vbulletin->GPC_exists['nosearch']) { $this->set('nosearch', vB::$vbulletin->GPC['nosearch']); $this->item->setInfo(array('nosearch'=> vB::$vbulletin->GPC['nosearch'])); } $this->set('editshowchildren',vB::$vbulletin->GPC_exists['editshowchildren'] ? vB::$vbulletin->GPC['editshowchildren'] : 0); $this->item->setInfo(array('editshowchildren'=> vB::$vbulletin->GPC['editshowchildren'])); if (vB::$vbulletin->GPC['section_menu_inherit']) { $section_menu = false; } else { $pre_sorted_section_menu = vB::$vbulletin->GPC['section_menu_sections']; $section_menu = array(); ////////////////////////////////////////////////////// // sort section_menu based on display order array ////////////////////////////////////////////////////// $display_order = vB::$vbulletin->GPC['display_order_select']; asort($display_order, SORT_NUMERIC); // loop through sorted display order array, and grab correlating values from the // pre-sorted section menu array and put them into the sorted section menu foreach ($display_order as $key => $value) { // if display order is zero, or that item was not selected to be in the menu // we can ignore that item from the display order array if ($value != '0' AND isset($pre_sorted_section_menu[$key])) { $section_menu[] = $pre_sorted_section_menu[$key]; unset($pre_sorted_section_menu[$key]); } } // if there are any section items that did not have a display order, we do not // care about their order and can add them into the section menu wherever we want foreach ($pre_sorted_section_menu as $value) { $section_menu[] = $value; } } $this->set('navigation', $section_menu); // add node info $result = $this->save(); //That's the main data. Creating an associatedthreadid, if necessary, // is handled in vbcms/dm/content.php return $result; }
public static function construct_section_chooser_options($topname = null) { require_once DIR . '/packages/vbcms/contentmanager.php'; $selectoptions = array(); if ($topname) { $selectoptions['-1'] = $topname; } // get section array $nodelist = vBCms_ContentManager::getNodes(1); foreach ($nodelist as $list) { $node = 0; $option = ''; foreach ($list as $section) { if (is_array($section)) { $node = $section['nodeid']; $option .= $section['title']; } else { $option .= $section . '>'; } } $selectoptions[$node] = $option; } return $selectoptions; }
private function getPublished($year, $month) { //Getting the start date is easy. Getting the end date is a bit complex. Leap years and all that. //Easiest way is to get the start of the next month and subract a second. //Ensure permissions are loaded $hash = self::getMyHash($year, $month); if (!($articles = vB_Cache::instance()->read($hash, true, false))) { $offset = vBCms_ContentManager::getTimeOffset(vB::$vbulletin->userinfo); $start = gmmktime (0, 0, 0, $month, 1, $year); $weekday = gmdate('w', $start); $start -= $offset; $end = gmmktime (0, 0, 0, ($month == 12 ? 1 : $month + 1 ), 1, ($month == 12 ? $year + 1 : $year )) - $offset - 1; $articles = array(); $rst = vB::$vbulletin->db->query_read($sql = "SELECT node.nodeid, node.publishdate, node.setpublish FROM " . TABLE_PREFIX . "cms_node AS node INNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info ON info.nodeid = node.nodeid WHERE node.setpublish > 0 AND node.publishdate BETWEEN $start AND $end AND node.contenttypeid <> " . vB_Types::instance()->getContentTypeID("vBCms_Section") . " AND " . vBCMS_Permissions::getPermissionString() . " AND hidden = 0 ORDER BY node.publishdate LIMIT 5000" ); $nextday = $start + 86400; $dom = 1; $articles[1] = array('data' => array(), 'time' => $start + 1, 'wday' => $weekday); //Now we want to end with an array of day => array('data ' => array, 'time' => unixtime) //So we need to build the array as we go. while($record = vB::$vbulletin->db->fetch_array($rst)) { //see if we need to advance to a new date if (intval($record['publishdate']) > $nextday) { while (intval($record['publishdate']) > $nextday) { $nextday += 86400; $start += 86400; $dom ++; $weekday = ($weekday == 6 ? 0 : ($weekday + 1)); $articles[$dom] = array('data' => array(), 'time' => $start + 1, 'wday' => $weekday); } } if ($record['setpublish']) { $articles[$dom]['data'][] = $record; } } //we may have some days at the end without articles. while($end > $start + 86400 ) { $dom++; $weekday = ($weekday == 6 ? 0 : ($weekday + 1)); $articles[$dom] = array('data' => array(), 'time' => $start + 1, 'wday' => $weekday); $start += 86400; } vB_Cache::instance()->write($hash , $articles, 1440, array('cms_calendar_published', 'sections_updated')); } //Now we want to turn this into an array of week=>(array(1-7); $week = 1; $calendar = array(1 => array()); //Pad the start with empty records as needed if ($articles[1]['wday'] != 0) { for ($i = 0; $i < $articles[1]['wday']; $i++) { $calendar[1][$i] = array('count' => 0, 'url' => '', 'day' => ''); } } $monthday = 1; $route = new vBCms_Route_List; while($monthday <= count($articles)) { //If we've filled a week, we need to advance $count = 0; foreach ($articles[$monthday]['data'] as $record) { $count = 1; $url = $route->getCurrentUrl(array('type' =>'day', 'value' => $articles[$monthday]['time'])) ; break; } $calendar[$week][$articles[$monthday]['wday']] = array('count' => $count, 'url' => $url, 'day' =>($monthday ? $monthday : '') ); if (($articles[$monthday]['wday'] == 6) AND ($monthday < count($articles))) { $week++; $calendar[$week] = array(); } $monthday++; } //We need to fill out a full week. Note that monthday is now one past the last day of the month if ($articles[$monthday - 1]['wday'] < 6) { for ($i = $articles[$monthday - 1]['wday'] + 1; $i <= 6 ; $i++) $calendar[$week][$i] = array('count' => 0, 'url' => '', 'day' => ''); } unset($route); return $calendar; }
/** * load the existing data * */ private function load_data() { //See if we need to bootstrap require_once(DIR . '/includes/class_bootstrap_framework.php'); vB_Bootstrap_Framework::init(); $sections = vBCms_ContentManager::getSections(); $perms = vBCMS_Permissions::getPerms(0); $this->custom_priority['cms'] = array(); $level = array(); foreach ($sections as $nodeid => $section) { if ((!$section['hidden']) AND (in_array($section['permissionsfrom'], $perms['canview']))) { $section['priority'] = false; $this->custom_priority['cms'][$section['nodeid']] = $section; } } $this->set_priorities('cms'); }
/** generates the section options list * @param string $section_str * @return string */ private function getSectionList($section_str) { $current_sections = explode(',', $section_str); $sections = vBCms_ContentManager::getSections(false); $select = '<option value="0">' . new vB_Phrase('global', 'all') . "</option>\n"; foreach ($sections as $section) { $select .= "<option value=\"" . $section['nodeid'] . '" ' . (in_array($section['nodeid'], $current_sections) ? 'selected="selected"' : '' ) . '>' . $section['title'] . " (" . $section['publish_count'] . ")</option>\n"; } return $select; }
protected function postSave($result, $deferred, $replace, $ignore) { if (! $this->save_children) { return true; } vB::$vbulletin->input->clean_array_gpc('p', array( 'ids' => vB_Input::TYPE_ARRAY)); //The parent classes insist on setting new=1, but we want new=0; vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "cms_node SET new = 0 WHERE nodeid = " . (isset($this->set_fields['nodeid']) ? $this->set_fields['nodeid'] : $this->primary_id)); //We have a minor issue here. The edit screen does not have a time and date //So- if the item is currently published and is still published, we should do nothing. //To make that decision we need to know what's currently published. $existing = array(); if (count(vB::$vbulletin->GPC['ids'])) { $rst = $record = vB::$vbulletin->db->query_read($sql = "SELECT nodeid, publishdate, setpublish, publicpreview FROM " . TABLE_PREFIX . "cms_node AS node WHERE nodeid in (" . implode(', ', vB::$vbulletin->GPC['ids']) . ")"); if ($rst) { while($record = vB::$vbulletin->db->fetch_array($rst)) { $existing[$record['nodeid']] = $record; } } } $orders = array(); foreach (vB::$vbulletin->GPC['ids'] as $nodeid) { vB::$vbulletin->input->clean_array_gpc('p', array( "cb_preview_$nodeid" => vB_Input::TYPE_INT, "cb_delete_$nodeid" => vB_Input::TYPE_INT, "order_$nodeid" => vB_Input::TYPE_INT, "published_$nodeid" => vB_Input::TYPE_INT )); //If we're deleting we need to instantiate the appropriate data manager // and use that to delete. Otherwise we know where the variables are and // can just update them directly. if (vB::$vbulletin->GPC_exists["cb_delete_$nodeid"]) { if ($record = vB::$vbulletin->db->query_first("SELECT contenttype.class, package.class AS package FROM " . TABLE_PREFIX . "cms_node node INNER JOIN " . TABLE_PREFIX . "contenttype AS contenttype ON contenttype.contenttypeid = node.contenttypeid INNER JOIN " . TABLE_PREFIX . "package AS package ON package.packageid = contenttype.packageid WHERE nodeid = " . $nodeid)) { $item = vB_Item_Content::create($record['package'], $record['class'], $nodeid); $dm = $item->getDM(); $dm->delete(); } } else { //Check the order. This is fairly tricky. If we do the order updates // out of sequence, things get scrambled and we are sure to wind up incorrect. So we // need to index them and do them in order. if (intval( vB::$vbulletin->GPC["order_$nodeid"])) { $orders[$nodeid] = vB::$vbulletin->GPC["order_$nodeid"]; } else { $orders[$nodeid] = 0; } $updates = array(); //Check the preview status $newpreview = vB::$vbulletin->GPC_exists["cb_preview_$nodeid"] ? 1 : 0; if (($newpreview == 1) AND (array_key_exists($nodeid, $existing)) AND (intval($existing[$nodeid]['publicpreview']) != 1)) { $updates[] = " publicpreview = 1"; } else if (($newpreview == 0) AND (array_key_exists($nodeid, $existing)) AND (intval($existing[$nodeid]['publicpreview']) != 0)) { $updates[] = " publicpreview = 0"; } //Check the published status. Remember we set published = 2; if (array_key_exists($nodeid, $existing) AND vB::$vbulletin->GPC_exists["published_$nodeid"] AND (vB::$vbulletin->GPC["published_$nodeid"] == 2) AND ($existing[$nodeid]['setpublish'] != 1)) { $updates[] = " setpublish = 1, publishdate = " . (TIMENOW - vBCms_ContentManager::getTimeOffset(vB::$vbulletin->userinfo, false) ); } else if (array_key_exists($nodeid, $existing) AND vB::$vbulletin->GPC_exists["published_$nodeid"] AND (vB::$vbulletin->GPC["published_$nodeid"] == 1) AND ($existing[$nodeid]['setpublish'] != 0)) { $updates[] = " setpublish = 0 " ; } if (count($updates)) { $sql = "UPDATE " . TABLE_PREFIX . "cms_node set " . implode(', ' , $updates) . " WHERE nodeid = $nodeid"; vB::$vbulletin->db->query_write($sql); } } } asort($orders); $min_sequence = 1; foreach ($orders as $nodeid => $order) { if ($order == 0) { vBCms_ContentManager::setDisplayOrder($this->set_fields['nodeid'], $nodeid, 0); } else { $order = max($min_sequence, intval($order)); $min_sequence++; vBCms_ContentManager::setDisplayOrder($this->set_fields['nodeid'], $nodeid, $order); } } return parent::postSave($result, $deferred, $replace, $ignore); }
/** Creates the publish editor at the top right of the edit section * * @return mixed * ****/ public function getPublishEditor($submit_url, $formid, $showpreview = true, $showcomments = true, $publicpreview = false, $comments_enabled = false, $pagination_links = 1) { if ($this->canPublish()) { $pub_view = new vB_View('vbcms_edit_publisher'); $pub_view->formid = $formid; $pub_view->setpublish = $this->setpublish; // if this is an unpublished article then we display publish to facebook if (is_facebookenabled() AND vB::$vbulletin->options['fbfeednewarticle'] AND !$this->setpublish) { // only display box if user is connectected to facebook $pub_view->showfbpublishcheckbox = is_userfbconnected(); } //Get date is a most annoying function for us. It takes a Unix time stamp // and converts it to server local time. We need to compensate for the difference between // server time (date('Z')) and usertime (vBCms_ContentManager::getTimeOffset(vB::$vbulletin->userinfo)) $offset = vBCms_ContentManager::getTimeOffset(vB::$vbulletin->userinfo) - date('Z'); if (intval($this->publishdate)) { $pub_view->publishdate = $this->publishdate ; } else { // get the current date/time dependent on user locality $pub_view->publishdate = TIMENOW; } $then = getdate(intval($pub_view->publishdate) + $offset); $pub_view->hour = $then['hours']; $pub_view->minute = $then['minutes']; //we need to parse out the date and time //Are we using a 24 hour clock? if ((strpos(vB::$vbulletin->options['timeformat'], 'G') !== false) OR (strpos( vB::$vbulletin->options['timeformat'], 'H') !== false)) { $pub_view->show24 = 1; } else { $pub_view->show24 = 0; $pub_view->offset = $pub_view->hour >= 12 ? 'PM' : 'AM'; if ($pub_view->hour > 12) { $pub_view->hour -= 12; } } $pub_view->title = $this->title; $pub_view->html_title = $this->html_title; $pub_view->username = $this->username; $pub_view->dateformat = vB::$vbulletin->options['dateformat']; // get the appropriate date format string for the // publish date calendar based on user's locale $pub_view->calendardateformat = (!empty(vB::$vbulletin->userinfo['lang_dateoverride']) ? '%Y/%m/%d' : 'Y/m/d'); $pub_view->groups = $this->getReaderGroups(); $pub_view->parents = $this->getParentage(); $pub_view->submit_url = $submit_url; $pub_view->sectiontypeid = vb_Types::instance()->getContentTypeID("vBCms_Section"); $pub_view->parents = $this->getParentage(); $pub_view->showtitle = $this->getShowTitle(); $pub_view->showuser = $this->getShowUser(); $pub_view->showpreviewonly = $this->getShowPreviewonly(); $pub_view->showupdated = $this->getShowUpdated(); $pub_view->showviewcount = $this->getShowViewcount(); $pub_view->showpublishdate = $this->getShowPublishdate(); $pub_view->settingsforboth = $this->getSettingsForboth(); $pub_view->showall = $this->getShowall(); $pub_view->includechildren = $this->getIncludeChildren(); $pub_view->showrating = $this->getShowRating(); $pub_view->hidden = $this->getHidden(); $pub_view->pagination_links = $pagination_links; $pub_view->show_pagination_link = ($this->contenttypeid == vb_Types::instance()->getContentTypeID("vBCms_Section") ) ? 1 : 0; $pub_view->shownav = $this->getShowNav(); $pub_view->show_shownav = ($this->contenttypeid == vb_Types::instance()->getContentTypeID("vBCms_Section") ) ? 0 : 1; $pub_view->nosearch = $this->getNoSearch(); $sectionid = (1 == $this->nodeid) ? 1 : $this->parentnode; $pub_view->hours24 = vB::$vbulletin->options['dateformat']; if ($this->contenttypeid == $pub_view->sectiontypeid) { $pub_view->show_categories = 0; $pub_view->is_section = 1; $pub_view->show_showsettings = 0; } else { $pub_view->show_categories = 1; $pub_view->categories = $this->getThisCategories(); $pub_view->show_showsettings = 1; $pub_view->is_section = 0; $pub_view->sectionid = $this->parentnode; } if ($pub_view->show_htmloption = ( $this->contenttypeid == vb_Types::instance()->getContentTypeID("vBCms_Article") // this is limited here to article but could be moved to any contenttype AND $this->canusehtml // this is set by some of the member functions above... )) { $pub_view->htmloption = $this->htmlstate; } $pub_view->show_categories = ($this->contenttypeid == $pub_view->sectiontypeid ? 0 : 1); //get the nodes $nodelist = vBCms_ContentManager::getSections(false); if (! isset(vB::$vbulletin->userinfo['permissions']['cms']) ) { vBCMS_Permissions::getUserPerms(); } foreach ($nodelist as $key => $node) { if (in_array(strval($node['permissionsfrom']), vB::$vbulletin->userinfo['permissions']['cms']['canpublish'])) { $nodelist[$key]['selected'] = ($sectionid == $node['nodeid'] ? 'selected="selected"' : ''); } else { unset($nodelist[$key]); } } $pub_view->nodelist = $nodelist; $pub_view->showpreview = $showpreview; $pub_view->showcomments = $showcomments; $pub_view->publicpreview = $publicpreview; $pub_view->hidden = $this->hidden; $pub_view->comments_enabled = $comments_enabled; $pub_view->show_sections = (1 != $this->nodeid); return $pub_view; } }
public static function construct_section_chooser_options($topname = null) { require_once(DIR . '/includes/class_bootstrap_framework.php'); require_once(DIR . '/packages/vbcms/contentmanager.php'); vB_Bootstrap_Framework::init(); $selectoptions = array(); if ($topname) { $selectoptions['-1'] = $topname; } // get category options $nodelist = vBCms_ContentManager::getNodes(1, array('contenttypeid' => 'node2.contenttypeid = ' . vb_Types::instance()->getContentTypeID("vBCms_Section"))); foreach ($nodelist as $section) { $selectoptions[$section['nodeid']] = str_replace('>', '>', $section['parent']) . $section['leaf']; } return $selectoptions; }
public static function getPermissionString($userid = false) { if (($userid === false) AND ($userid !== 0)) { $userid = vB::$vbulletin->userinfo['userid']; } if (($userid == vB::$vbulletin->userinfo['userid']) AND self::$permission_string) { return self::$permission_string; } require_once DIR . '/includes/class_bootstrap_framework.php' ; vB_Bootstrap_Framework::init(); $can_view = array(); $blocked = array(); $perms = self::getPerms($userid); //We need to block out unpublished sections. $sections = vBCms_ContentManager::getSections(); foreach($sections as $section) { $can_view_this = (intval($section['setpublish']) > 0) && ($section['publishdate'] < TIMENOW); if (!$can_view_this) { $blocked[$section['nodeid']] = 1; if (isset($can_view[$section['nodeid']])) { unset($can_view[$section['nodeid']]); } } else if (!isset($can_view[$section['nodeid']]) AND ! isset($blocked[$section['nodeid']])) { $can_view[$section['nodeid']] = 1; } } $canedit = array_unique(array_merge($perms['canedit'], $perms['canpublish'])); self::$permission_string = "( (node.permissionsfrom IN (" . implode(',', $canedit) . "))"; if (intval($userid)) { self::$permission_string .= " OR (node.userid =" . vB::$vbulletin->userinfo['userid'] . ") "; } if (!empty($can_view)) { self::$permission_string .= " OR ( node.permissionsfrom in (" . implode(',', $perms['canview']) . ") AND (node.parentnode IN (" . implode(',', array_keys($can_view)) . ")" . (isset($can_view[1]) ? " OR node.nodeid = 1" : "") . "))"; } self::$permission_string .= ")"; return self::$permission_string; }
} else { if ($vbulletin->GPC_exists['sentfrom'] and $vbulletin->GPC['sentfrom'] == 'nodes') { print_cp_header($vbphrase['content_manager']); vBCms_ContentManager::updateSections(); echo vBCms_ContentManager::showNodes($per_page); print_cp_footer(); } } } case 'fix_nodes': print_cp_header($vbphrase['vbcms']); echo vBCms_ContentManager::fixNodeLR(); print_cp_message($vbphrase['nodetable_repaired']); print_cp_footer(); break; case 'list': //This is our default action. We need to display a list of items. //This is our default action. We need to display a list of items. default: $vbulletin->input->clean_array_gpc('r', array('sortby' => TYPE_STR, 'sortdir' => TYPE_STR, 'title_filter' => TYPE_STR, 'submit' => TYPE_STR, 'state_filter' => TYPE_INT, 'author_filter' => TYPE_UINT, 'filter_section' => TYPE_UINT, 'contenttypeid' => TYPE_INT)); print_cp_header($vbphrase['content_manager']); echo vBCms_ContentManager::showNodes($per_page); print_cp_footer(); break; } /*======================================================================*\ || #################################################################### || # Downloaded: 03:13, Sat Sep 7th 2013 || # SVN: $Revision: 27874 $ || #################################################################### \*======================================================================*/
/** * Fetches the standard page view for a widget. * * @param bool $skip_errors - If using a collection, omit widgets that throw errors * @return vBCms_View_Widget - The resolved view, or array of views */ public function getPageView() { $this->assertWidget(); if (! isset($vbulletin->userinfo['permissions']['cms'])) { vBCMS_Permissions::getUserPerms(); } // Create view $config = $this->widget->getConfig(); if (!isset($config['template_name']) OR ($config['template_name'] == '') ) { $config['template_name'] = 'vbcms_widget_sectionnav_page'; } $canviewlist = implode(', ', vB::$vbulletin->userinfo['permissions']['cms']['viewonly']); $caneditlist = implode(', ', vB::$vbulletin->userinfo['permissions']['cms']['canedit']); $for_node = intval($this->content->getContentTypeId()) == intval(vb_Types::instance()->getContentTypeID("vBCms_Section")) ? $this->content->getNodeId() : $this->content->getParentId(); // Create view $view = new vBCms_View_Widget($config['template_name']); if ( $link_nodes = vB_Cache::instance()->read($cache_key = $this->getHash($this->widget->getId(), $for_node), false, true)) { $links_before = $link_nodes['links_before']; $links_above = $link_nodes['links_above']; $links_sibling = $link_nodes['links_sibling']; $links_children = $link_nodes['links_children']; $links_after = $link_nodes['links_after']; $myself = $link_nodes['myself']; } else { //If we're on a section, we show for this nodeid. If we're on // on a leaf-type node we show for the parent $section_possibles = vBCms_ContentManager::getSections(); $my_left = $this->content->getNodeLeft(); $my_right = $this->content->getNodeRight(); $my_parent = $this->content->getParentId(); $my_nodeid = $this->content->getNodeId(); $my_title = ''; $links_above = array(); $links_before = array(); $links_above = array(); $links_sibling = array(); $links_after = array(); $links_children = array(); $top_level = array(); if (! isset(vB::$vbulletin->userinfo['permissions']['cms']) ) { vBCMS_Permissions::getUserPerms(); } $route = new vBCms_Route_Content(); $route->setParameter('action', 'view'); $homeid = $sections[0]['nodeid']; //Now let's scan the array; $indent = 0; $i = 1; $noderight = 0; //Let's remove items we're not supposed to see. $sections= array(); foreach ($section_possibles as $key => $section) { if (/** This user has permissions to view this record **/ ( in_array($section['permissionsfrom'], vB::$vbulletin->userinfo['permissions']['cms']['canedit']) OR (in_array($section['permissionsfrom'],vB::$vbulletin->userinfo['permissions']['cms']['canview'] ) AND $section['setpublish'] == '1' AND $section['publishdate'] < TIMENOW )) AND /** This user also has rights to the parents **/ ($section['noderight'] > $noderight)) { $sections[] = $section; } else { //So the children will be skipped $noderight = $section['noderight']; } } //First the sections ahead of us while($i < count($sections) AND $my_left > $sections[$i]['nodeleft']) { $route->node = $sections[$i]['nodeid'] . (strlen($sections[$i]['url']) ? '-' . $sections[$i]['url'] : '' ); //see if it's a top-level if ($sections[$i]['parentnode'] == $homeid) { $links_before[] = array('title' => $sections[$i]['title'], 'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => 0); }//is it a sibling? else if ($my_parent == $sections[$i]['parentnode']) { $links_sibling[] = array('title' => $sections[$i]['title'], 'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => 0); } $i++; } //Now our parentage and children while($i < count($sections) AND $my_right > $sections[$i]['nodeleft']) { $route->node = $sections[$i]['nodeid'] . (strlen($sections[$i]['url']) ? '-' . $sections[$i]['url'] : '' ); if ($my_nodeid == $sections[$i]['parentnode']) { $links_children[] = array('title' => $sections[$i]['title'], 'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => ($indent) * 10); } else if ($my_nodeid == $sections[$i]['nodeid']) { $myself = array('title' => $sections[$i]['title'], 'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => $indent * 10); } else { $links_above[] = array('title' => $sections[$i]['title'], 'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => $indent * 10); $my_title = $sections[$i]['title']; $indent++; } $i++; } //Now the afters while ($i < count($sections)) { $route->node = $sections[$i]['nodeid'] . (strlen($sections[$i]['url']) ? '-' . $sections[$i]['url'] : '' ); if ($sections[$i]['parentnode'] == $homeid) { $links_after[] = array('title' => $sections[$i]['title'], 'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => 0); } else if ($my_parent == $sections[$i]['parentnode']) { $links_sibling[] = array('title' => $sections[$i]['title'], 'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => 0); } $i++; } foreach($links_sibling as $key => $value) { $links_sibling[$key]['indent'] = $indent * 10; } $route->node = $sections[1]['nodeid'] . (strlen($sections[1]['url']) ? '-' . $sections[1]['url'] : '' ); //We have the pieces, now let's string them together; //Top level first $links_before = array_merge(array(array('title' => $sections[0]['title'], 'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => 0)), $links_before); //Now write to the cache vB_Cache::instance()->write($cache_key, array('links_before' => $links_before, 'links_above' => $links_above, 'links_sibling' => $links_sibling , 'links_after' => $links_after, 'links_children' => $links_children, 'myself' => $myself ), $this->cache_ttl, array('section_nav_' . $for_node, 'sections_updated')); } //The first record is the root $view->links_before = $links_before; $view->links_above = $links_above; $view->links_sibling = $links_sibling; $view->links_children = $links_children; $view->links_after = $links_after; $view->myself = $myself; $view->widget_title = $this->widget->getTitle(); return $view; }
/** * load the existing data * */ private function load_data() { $sections = vBCms_ContentManager::getSections(); $perms = vBCMS_Permissions::getPerms(0); $this->custom_priority['cms'] = array(); $level = array(); foreach ($sections as $nodeid => $section) { if (!$section['hidden'] and in_array($section['permissionsfrom'], $perms['canview'])) { $section['priority'] = false; $this->custom_priority['cms'][$section['nodeid']] = $section; } } $this->set_priorities('cms'); }
if ($_REQUEST['do'] == 'checkurl') { if (! count($phrasegroups)) { $phrasegroups = array('vbcms', 'global', 'cpcms', 'cphome'); $globaltemplates = array( 'pagenav_curpage', 'pagenav_pagelinkrel', 'pagenav_pagelink','pagenav' ); } require_once('./global.php'); require_once DIR . '/packages/vbcms/contentmanager.php'; vBCms_ContentManager::checkUrlAvailable(); } if ($_REQUEST['do'] == 'perms_section' or $_REQUEST['do'] == 'del_perms') { require_once DIR . '/' . $vbulletin->config['Misc']['admincpdir'] . '/cms_permissions.php'; //and that page will do all the work. } //This is for the calendar widget paging; if ($_REQUEST['do'] == 'calwidget' ) { $vbulletin->input->clean_array_gpc('r', array( 'year' => TYPE_UINT, 'month' => TYPE_UINT));
/** * Fetches the standard page view for a widget. * * @param bool $skip_errors - If using a collection, omit widgets that throw errors * @return vBCms_View_Widget - The resolved view, or array of views */ public function getPageView() { $this->assertWidget(); $config = $this->widget->getConfig(); if (!isset($config['template_name']) OR ($config['template_name'] == '') ) { $config['template_name'] = 'vbcms_widget_categorynav_page'; } // Create view $view = new vBCms_View_Widget($config['template_name']); $this->sectionid = $this->content->getContentTypeId() == vb_Types::instance()->getContentTypeID("vBCms_Section") ? $this->content->getNodeId() : $this->content->getParentId(); try { $categoryid = max(1, intval(vB_Router::getSegment('value'))); } catch (vB_Exception_Router $e) { $categoryid = 0; } $nodes = vBCms_ContentManager::getAllCategories(); ksort($nodes); foreach ($nodes as $nodeid => $record) { $route = vB_Route::create('vBCms_Route_List', "category/" . $record['route_info'] . "/1")->getCurrentURL(); $nodes[$nodeid]['view_url'] = $route; } // Modify $nodes to add myself var (currently selected category) $view->widget_title = $this->widget->getTitle(); $view->nodes = $nodes; return $view; }