if (!$type) { $type = array('enabled' => 1); print_table_header($vbphrase['add_new_extension']); } print_input_row($vbphrase['extension'], 'type[extension]', $type['extension']); print_input_row(construct_phrase($vbphrase['maximum_filesize_dfn']), 'type[size]', $type['size']); print_input_row($vbphrase['max_width_dfn'], 'type[width]', $type['width']); print_input_row($vbphrase['max_height_dfn'], 'type[height]', $type['height']); print_textarea_row($vbphrase['mime_type_dfn'], 'type[mimetype]', $type['mimetype']); ($hook = vBulletinHook::fetch_hook('admin_attachmenttype')) ? eval($hook) : false; $existing = @unserialize($type['contenttypes']); print_table_break(); print_table_header($vbphrase['content_type'], 4); print_cells_row(array($vbphrase['product'], $vbphrase['location'], $vbphrase['new_window'], $vbphrase['enabled']), 1, 'tcat'); $indexed_types = array(); $collection = new vB_Collection_ContentType(); $collection->filterAttachable(true); foreach ($collection as $type) { $value['package'] = $type->getPackageClass(); $value['class'] = $type->getClass(); $indexed_types[$type->getID()] = $value; } foreach ($indexed_types as $contenttypeid => $content) { if (!isset($existing["{$contenttypeid}"]['e'])) { $existing["{$contenttypeid}"]['e'] = true; } print_cells_row(array($content['package'], $vbphrase['contenttype_' . strtolower($content['package']) . '_' . strtolower($content['class'])], "<input type=\"hidden\" name=\"default[{$contenttypeid}][n]\" value=\"1\" />" . "<input type=\"checkbox\" tabindex=\"1\" name=\"contenttype[{$contenttypeid}][n]\" value=\"1\"" . ($existing["{$contenttypeid}"]['n'] ? 'checked="checked"' : '') . ' />', "<input type=\"hidden\" name=\"default[{$contenttypeid}][e]\" value=\"1\" />" . "<input type=\"checkbox\" tabindex=\"1\" name=\"contenttype[{$contenttypeid}][e]\" value=\"1\"" . ($existing["{$contenttypeid}"]['e'] ? 'checked="checked"' : '') . ' />')); } print_submit_row($vbulletin->GPC['extension'] ? $vbphrase['update'] : $vbphrase['save'], '_default_', 4); } // ###################### Update File Type ####################
/** * Constructor * Sets registry * * @param vB_Registry * * @return void */ public function __construct(&$registry) { $this->registry =& $registry; if (!is_subclass_of($this, 'vB_Attachment_Display_Multiple')) { $indexed_types = array(); $collection = new vB_Collection_ContentType(); $collection->filterAttachable(true); foreach ($collection as $type) { $value['package'] = $type->getPackageClass(); $value['class'] = $type->getClass(); $indexed_types[$type->getID()] = $value; } foreach ($indexed_types as $contenttypeid => $content) { $selectclass = "vB_Attachment_Display_Multiple_{$content['package']}_{$content['class']}"; //we check if the class exists, but also don't want warnings if the content file exists. $include_file = DIR . '/packages/' . strtolower($content['package']) . '/attach/' . strtolower($content['class']) . '.php'; if (!file_exists($include_file)) { continue; } include_once $include_file; if (!class_exists($selectclass)) { continue; } $this->contentref["{$contenttypeid}"] = new $selectclass($this->registry, $contenttypeid); if (!$this->contentref["{$contenttypeid}"]->usable) { unset($this->contentref["{$contenttypeid}"]); } } } }
private function fetch_tagcloud($type = 'usage') { $vbulletin = &$this->registry; $tags = array(); if ($vbulletin->options['tagcloud_usergroup'] > 0 AND !isset($vbulletin->usergroupcache[$vbulletin->options['tagcloud_usergroup']])) { // handle a usergroup being deleted: default to live permission checking $vbulletin->options['tagcloud_usergroup'] = -1; } require_once(DIR . '/includes/class_taggablecontent.php'); $collection = new vB_Collection_ContentType(); $collection->filterTaggable(true); //create dummy content item objects. We use these to call a couple of (what? - Darren) $type_objects = array(); foreach ($collection AS $contenttype) { $type_objects[$contenttype->getID()] = vB_Taggable_Content_Item::create($vbulletin, $contenttype->getID(), null); } unset($collection, $contenttype); $cacheable = true; foreach ($type_objects AS $content) { if (!$content->is_cloud_cachable()) { $cacheable = false; break; } } if (!$cacheable) { $cloud = null; } else { switch ($type) { case 'search': if (isset($vbulletin->searchcloud)) { $cloud = $vbulletin->searchcloud; } break; case 'usage': default: $cloud = $vbulletin->tagcloud; break; } } $cloud = null; if (!is_array($cloud) OR $cloud['dateline'] < (TIMENOW - (60 * $vbulletin->options['tagcloud_cachetime']))) { if ($type == 'search') { $tags_result = $vbulletin->db->query_read_slave(" SELECT tagsearch.tagid, tag.tagtext, COUNT(*) AS searchcount FROM " . TABLE_PREFIX . "tagsearch AS tagsearch INNER JOIN " . TABLE_PREFIX . "tag AS tag ON (tagsearch.tagid = tag.tagid) " . ($vbulletin->options['tagcloud_searchhistory'] ? "WHERE tagsearch.dateline > " . (TIMENOW - (60 * 60 * 24 * $vbulletin->options['tagcloud_searchhistory'])) : '') . " GROUP BY tagsearch.tagid, tag.tagtext ORDER BY searchcount DESC LIMIT " . $vbulletin->options['tagcloud_tags'] ); } else { //get the query bits from the type objects. If two objects return the same exact join/where information //we can collapse the subqueries. This is particularly useful for the cms content types which are //largely the same under the hood. $bit_ids = array(); $bit_values = array(); foreach ($type_objects AS $type => $content) { $contenttypeid = vB_Types::instance()->getContentTypeID($type); $bits = $content->fetch_tag_cloud_query_bits(); if ($bits) { $pos = array_search($bits, $bit_values); if ($pos === false) { $bit_ids[] = array($contenttypeid); $bit_values[] = $bits; } else { $bit_ids[$pos][] = $contenttypeid; } } } //build the subqueries from the bits. $subqueries = array(); foreach ($bit_values AS $key => $bits) { $timelimit = (TIMENOW - (60 * 60 * 24 * $vbulletin->options['tagcloud_usagehistory'])); $query = " SELECT tagcontent.tagid, tag.tagtext, COUNT(*) AS searchcount FROM " . TABLE_PREFIX . "tagcontent AS tagcontent INNER JOIN " . TABLE_PREFIX . "tag AS tag ON (tagcontent.tagid = tag.tagid) " . implode("\n", $bits['join']) . " WHERE tagcontent.contenttypeid IN (" . implode(",", $bit_ids[$key]) . ") AND tagcontent.dateline > $timelimit AND " . implode(" AND ", $bits['where']) . " GROUP BY tagcontent.tagid, tag.tagtext "; $subqueries[] = $query; } if (count($subqueries)) { $query = " SELECT data.tagid, data.tagtext, SUM(data.searchcount) AS searchcount FROM (" . implode(" UNION ALL ", $subqueries) . ") AS data GROUP BY data.tagid, data.tagtext ORDER BY searchcount DESC LIMIT " . $vbulletin->options['tagcloud_tags']; $tags_result = $vbulletin->db->query_read_slave($query); while ($currenttag = $vbulletin->db->fetch_array($tags_result)) { $tags["$currenttag[tagtext]"] = $currenttag; $totals[$currenttag['tagid']] = $currenttag['searchcount']; } } } while ($currenttag = $vbulletin->db->fetch_array($tags_result)) { $tags["$currenttag[tagtext]"] = $currenttag; $totals[$currenttag['tagid']] = $currenttag['searchcount']; } // fetch the stddev levels $levels = fetch_standard_deviated_levels($totals, $vbulletin->options['tagcloud_levels']); // assign the levels back to the tags foreach ($tags AS $tagtext => $tag) { $tags[$tagtext]['level'] = $levels[$tag['tagid']]; $tags[$tagtext]['tagtext_url'] = urlencode(unhtmlspecialchars($tag['tagtext'])); } // sort the categories by title uksort($tags, 'strnatcasecmp'); $cloud = array( 'tags' => $tags, 'count' => sizeof($tags), 'dateline' => TIMENOW ); if ($cacheable) { if ($type == 'search' OR $type == 'selectlist') { $vbulletin->searchcloud = $cloud; } else { $vbulletin->tagcloud = $cloud; } } } if (empty($cloud['tags'])) { return ''; } $cloud['links'] = ''; return $cloud; }
/** * Builds the toolbar view for managing the page. * * @param bool $edit_mode - Whether the user is currently in edit mode * @return vB_View */ protected function getToolbarView($edit_mode = false) { global $vbulletin; global $vbphrase; if (!$this->content->canCreate() AND !$this->content->canEdit() AND !$this->content->canPublish()) { return; } require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('cpcms'); // Create view $view = new vB_View('vbcms_toolbar'); $view->edit_mode = $edit_mode; $view->page_url = vB_Router::getURL(); $view->access = ($this->content->publicCanView() ? $vbphrase['public'] : $vbphrase['public']); // Setup a new route to get URLs $route = new vBCms_Route_Content(); $route->node = $this->node->getURLSegment(); $view->view_url = $route->getCurrentURL(array('action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'))); $view->edit_url = $route->getCurrentURL(array('action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'))); $view->edit_label = new vB_Phrase('vbcms', 'edit_this_page'); // New content options $view->add_url = $route->getCurrentURL(array('action' => vB_Router::getUserAction('vBCms_Controller_Content', 'AddNode'))); $view->add_label = new vB_Phrase('vbcms', 'create_new'); // Get placable contenttypes. TODO: This should be a method of vB_Types for reuse if (!($view->contenttypes = vB_Cache::instance()->read('vbcms_controller_content.place_nonaggs', true, true))) { $contenttype_collection = new vB_Collection_ContentType(); $contenttype_collection->filterPlaceable(true); $contenttype_collection->filterNonAggregators(true); $contenttypes = array(); $permissionsfrom = $this->content->getPermissionsFrom(); foreach ($contenttype_collection AS $contenttype) { $this_type = vBCms_Content::create($contenttype->getPackageClass(), $contenttype->getClass(), 0); if ($this_type->canCreateHere($permissionsfrom)) { $title = (string)$contenttype->getTitle(); $contenttypes[$title] = array('id' => $contenttype->getId(), 'title' => $title); }; unset($this_type); } ksort($contenttypes); $view->contenttypes = $contenttypes; unset($contenttype_collection, $contenttypes); vB_Cache::instance()->write('vbcms_controller_content.place_nonaggs', $view->contenttypes, false, vB_Types::instance()->getContentTypeCacheEvents()); } // Set the publish state description if ($this->node->isPublished()) { $view->publish_status = new vB_Phrase('vbcms', 'page_is_published'); } else if ($this->node->getPendingParentId()) { $pending_title = $this->node->getPendingParentTitle(); $pending_route = vB_Route::create('vBCms_Route_Content')->getCurrentURL(array('node' => $this->node->getPendingParentId())); $view->publish_status = new vB_Phrase('vbcms', 'section_x_not_published', $pending_route, $pending_title); } else if ($date = $this->node->getPublishDate()) { $date = vbdate(vB::$vbulletin->options['dateformat'], $date, true); $view->publish_status = new vB_Phrase('vbcms', 'page_will_be_published_x', $date); } else { $view->publish_status = new vB_Phrase('vbcms', 'page_not_published'); } $view->can_publish = $this->content->canPublish(); $view->can_edit = $this->content->canEdit(); $view->can_create = $this->content->canCreate(); // Add postid $this->addPostId($view); return $view; }
public function get_indexed_types() { if (is_null($this->indexed_types)) { $collection = new vB_Collection_ContentType(); $collection->filterSearchable(true); $this->indexed_types = array(); foreach ($collection as $type) { $search_type = $this->get_search_type_from_id($type->getID()); if ($search_type->is_enabled()) { $value = array(); $value['contenttypeid'] = $type->getID(); $value['package'] = $type->getPackageClass(); $value['class'] = $type->getClass(); $this->indexed_types[$type->getID()] = $value; } } } return $this->indexed_types; }
/** * Build list of indexes, required for used content types. * */ protected function _get_sphinx_indices($content_types = null) { $indexes = array(); if (!empty($content_types) and !is_array($content_types)) { $content_types = array(vB_Types::instance()->getContentTypeId($content_types)); } elseif (empty($content_types)) { global $vbulletin; // Additional setting for our product. // Show quick search results as snippets or as threads if ($vbulletin->options['sph_quick_search_results_as_post']) { // If show as threads - grouping required $this->_require_grouping = true; } } $collection = new vB_Collection_ContentType(); $collection->filterSearchable(true); foreach ($collection as $type) { $content_type_id = $type->getID(); if ($content_type_id == vB_Types::instance()->getContentTypeId('vBForum_Thread')) { // We use the same index for Posts & Threads $content_type_id = vB_Types::instance()->getContentTypeId('vBForum_Post'); } if (!empty($content_types) and !in_array($content_type_id, $content_types)) { continue; } $sphinx_index = vBSphinxSearch_Core::get_sphinx_index_map($content_type_id); if (!empty($sphinx_index)) { if ($this->_single_index_enabled) { $indexes[] = $sphinx_index[0]; } else { $indexes[] = implode(",", $sphinx_index); } } } return implode(", ", $indexes); }