本文整理汇总了PHP中vB_Cache::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP vB_Cache::instance方法的具体用法?PHP vB_Cache::instance怎么用?PHP vB_Cache::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vB_Cache
的用法示例。
在下文中一共展示了vB_Cache::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTitles
/**
* fetches the help hierarchy, title phrases are included but text phrases are not
* @return array
* * titles contains the hierarchy which sub-help items under the 'children' key
* * firstItem contains the first help item to display
*/
public function getTitles()
{
$cache = vB_Cache::instance(vB_Cache::CACHE_LARGE);
$titles = $cache->read('vb_FAQ_Titles');
if (empty($titles)) {
$assertor = vB::getDbAssertor();
$phrases = $assertor->getColumn('vBForum:phrase', 'text', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'fieldname' => array('faqtext', 'faqtitle'), 'languageid' => array(-1, 0, vB::getCurrentSession()->get('languageid'))), false, 'varname');
$faqs = $assertor->getRows('vBForum:faq', array(), 'displayorder', 'faqname');
foreach ($faqs as $faqname => &$faq) {
if ($faqname == 'faqroot') {
continue;
}
$faq['title_phrase'] = $faq['faqname'] . '_gfaqtitle';
$faq['text_phrase'] = $faq['faqname'] . '_gfaqtext';
$faq['title'] = $phrases[$faq['title_phrase']];
$faq['text'] = $phrases[$faq['text_phrase']];
$parentPath = '';
$parent = $faq['faqparent'];
while ($parent != 'faqroot' and isset($faqs[$parent])) {
$parentPath = $faqs[$parent]['faqname'] . '/' . $parentPath;
$parent = $faqs[$parent]['faqparent'];
}
$faq['path'] = $parentPath . $faq['faqname'];
$faqs[$faq['faqparent']]['children'][$faq['faqname']] =& $faq;
}
$titles = $faqs['faqroot']['children'];
$cache->write('vb_FAQ_Titles', $titles, 300, 'vB_FAQ_chg');
}
return array('titles' => $titles, 'firstItem' => $this->findFirst($titles));
}
示例2: parse
public static function parse($text, $options = array(), $attachments = array(), $cacheInfo = array())
{
//if we have a nodeid, let's try to cache this.
if (!empty($cacheInfo)) {
//TODO- Find a caching method that doesn't break collapsed mode.
if (!empty($cacheInfo['nodeid'])) {
$cacheKey = 'vbNodeText' . $cacheInfo['nodeid'];
} else {
if (!empty($cacheInfo['signatureid'])) {
$cacheKey = 'vbSig' . $cacheInfo['signatureid'];
}
}
if (!empty($cacheKey)) {
$cacheKey .= strval($options);
$parsed = vB_Cache::instance()->read($cacheKey);
if ($parsed) {
return $parsed;
}
}
}
$result = self::parseInternal(new vB5_Template_BbCode(), $text, $options, $attachments);
if (!empty($cacheKey)) {
if (!empty($cacheInfo['nodeid'])) {
$cacheEvent = 'nodeChg_' . $cacheInfo['nodeid'];
} else {
if (!empty($cacheInfo['signatureid'])) {
$cacheEvent = 'userChg_' . $cacheInfo['signatureid'];
}
}
vB_Cache::instance()->write($cacheKey, $result, 86400, $cacheEvent);
}
return $result;
}
示例3: getRedirect301
/**
* discard all query parameters
* caches the new route and return it every time
* this is the simplest form of redirection
* if subclass is any complicate than this, override is needed
*/
public function getRedirect301()
{
$this->queryParameters = array();
$cache = vB_Cache::instance(vB_Cache::CACHE_STD);
$cacheKey = get_class($this);
$data = $cache->read($cacheKey);
if (!$data) {
$data = $this->getNewRouteInfo();
$cache->write($cacheKey, $data, 86400);
}
return $data;
}
示例4: getFullCategoryList
function getFullCategoryList(&$channelInfoArray = array(), $tabsize = 1, $tabchar = "--", $tabspace = " ")
{
$cache = vB_Cache::instance(vB_Cache::CACHE_STD);
$cacheKey = "vBAdminCP_CMS_Categories";
$categories = $cache->read($cacheKey);
$writeCache = false;
$cacheEvents = array();
if (empty($categories)) {
$categories = vB::getDbAssertor()->getRows('vBAdminCP:getCMSChannels', array('articleChannelId' => vB_Api::instanceInternal('node')->fetchArticleChannel(), 'channelcontenttype' => vB_Api::instanceInternal('ContentType')->fetchContentTypeIdFromClass('Channel')));
$writeCache = true;
}
$categoriesList = array();
// The query result is sorted by depth first. We have to group/sort into a hierarchical order, such that
// children come immediately after a parent.
$parent_position = array();
// parentid => position
$nodeid_index = array();
// nodeid => search result index
foreach ($categories as $index => $category) {
$cacheEvents[] = 'nodeChg_' . $category['nodeid'];
$parentid = $category['parentid'];
$nodeid_index[$category['nodeid']] = $index;
if (empty($parent_position)) {
$parent_position[$category['nodeid']] = 0;
} else {
$position = $parent_position[$parentid] + 1;
// increment positions of parents whose positions are after $position
foreach ($parent_position as $pid => $pos) {
if ($pos >= $position) {
$parent_position[$pid]++;
}
}
// node will be positioned after its parent, but above any siblings. This is why all but the depth is sort order DESC in the query.
$parent_position[$category['nodeid']] = $position;
}
}
// sort parent_position by position
asort($parent_position);
foreach ($parent_position as $nodeid => $position) {
$category = $categories[$nodeid_index[$nodeid]];
$channelInfoArray[$category['nodeid']] = array("title" => $category['htmltitle'], "parentid" => $category['parentid'], "showpublished" => $category['showpublished'], "textcount" => $category['textcount'], "displayorder" => $category['displayorder'], "description" => $category['description']);
$tab = str_repeat($tabchar, $category['depth'] * $tabsize) . $tabspace;
$categoriesList[$category['nodeid']] = $tab . $category['htmltitle'];
}
if ($writeCache) {
$cache->write($cacheKey, $categories, 1440, $cacheEvents);
}
return $categoriesList;
}
示例5: getPage
protected function getPage()
{
if ($this->page === NULL and isset($this->arguments['pageid'])) {
$cache = vB_Cache::instance(vB_Cache::CACHE_FAST);
$hashkey = 'vbPage_' . $this->arguments['pageid'];
$this->page = $cache->read($hashkey);
if (empty($this->page)) {
$this->page = vB::getDbAssertor()->getRow('page', array('pageid' => intval($this->arguments['pageid'])));
// use phrased page title & meta desc for breadcrumb
$guidforphrase = vB_Library::instance('phrase')->cleanGuidForPhrase($this->page['guid']);
$phrases = vB_Api::instanceInternal('phrase')->fetch(array('page_' . $guidforphrase . '_title', 'page_' . $guidforphrase . '_metadesc'));
$this->page['title'] = !empty($phrases['page_' . $guidforphrase . '_title']) ? $phrases['page_' . $guidforphrase . '_title'] : $this->page['title'];
$this->page['metadescription'] = !empty($phrases['page_' . $guidforphrase . '_metadesc']) ? $phrases['page_' . $guidforphrase . '_metadesc'] : $this->page['metadescription'];
$cache->write($hashkey, $this->page, 86400, 'vbPageChg_' . $this->arguments['pageid']);
}
}
return $this->page;
}
示例6: getUrl
public function getUrl()
{
$cache = vB_Cache::instance(vB_Cache::CACHE_FAST);
$hashKey = 'vbRouteURLIndent_' . $this->arguments['nodeid'];
$urlident = $cache->read($hashKey);
if (empty($urlident)) {
$node = vB_Library::instance('node')->getNodeBare($this->arguments['nodeid']);
$urlident = $node['urlident'];
$cache->write($hashKey, $urlident);
} elseif (is_array($urlident) and !empty($urlident['urlident'])) {
$urlident = $urlident['urlident'];
}
$url = '/album/' . $this->arguments['nodeid'] . '-' . $urlident;
if (strtolower(vB_String::getCharset()) != 'utf-8') {
$url = vB_String::encodeUtf8Url($url);
}
return $url;
}
示例7: deletePerms
/** this deletes an existing permission
*
* @return mixed either permissionid(single or array), or nodeid and usergroupid. A single Nodeid is required and usergroup is optional and may be an array
***/
public function deletePerms($params)
{
if (!empty($params['permissionid'])) {
//We don't allow deleting permissions from page 1.
$existing = vB::getDbAssertor()->getRow('vBForum:permission', array('permissionid' => $params['permissionid']));
if (empty($existing) or !empty($existing['errors']) or $existing['nodeid'] == 1) {
return false;
}
$qryParams['permissionid'] = $params['permissionid'];
} else {
if (!empty($params['nodeid']) and intval($params['nodeid'])) {
$qryParams['nodeid'] = intval($params['nodeid']);
if (!empty($params['groupid'])) {
$qryParams['groupid'] = $params['groupid'];
}
} else {
return false;
}
}
$qryParams[vB_dB_Query::TYPE_KEY] = vB_dB_Query::QUERY_DELETE;
$result = vB::getDbAssertor()->assertQuery('vBForum:permission', $qryParams);
vB_Cache::instance()->event('perms_changed');
//force reloading the group access cache
vB::getUserContext()->rebuildGroupAccess();
return $result;
}
示例8: foreach
}
}
foreach ($productcodes_versions as $version) {
foreach ($productcodes_grouped["{$version}"] as $productcode) {
eval($productcode['uninstallcode']);
}
}
//remove some common resources that a product may have registered.
//tags
$db->query_write("\r\n\t\tDELETE tagcontent\r\n\t\tFROM " . TABLE_PREFIX . "package AS package JOIN\r\n\t\t\t" . TABLE_PREFIX . "contenttype AS contenttype ON\r\n\t\t\t\tcontenttype.packageid = package.packageid JOIN\r\n\t\t\t" . TABLE_PREFIX . "tagcontent AS tagcontent ON\r\n\t\t\t\tcontenttype.contenttypeid = tagcontent.contenttypeid\r\n\t\tWHERE productid = '{$safe_productid}'\r\n\t");
// Packages, routes, actions, contenttypes
$db->query_write("\r\n\t\tDELETE package, route, action, contenttype\r\n\t\tFROM " . TABLE_PREFIX . "package AS package\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "route AS route\r\n\t\t\tON route.packageid = package.packageid\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "action AS action\r\n\t\t\tON action.routeid = route.routeid\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "contenttype AS contenttype\r\n\t\t\tON contenttype.packageid = package.packageid\r\n\t\tWHERE productid = '{$safe_productid}'\r\n\t");
// Clear routes from datastore
build_datastore('routes', serialize(array()), 1);
//clear the type cache.
vB_Cache::instance()->purge('vb_types.types');
// need to remove the language columns for this product as well
require_once DIR . '/includes/class_dbalter.php';
$db_alter = new vB_Database_Alter_MySQL($db);
if ($db_alter->fetch_table_info('language')) {
$phrasetypes = $db->query_read("\r\n\t\t\tSELECT fieldname\r\n\t\t\tFROM " . TABLE_PREFIX . "phrasetype\r\n\t\t\tWHERE product = '" . $db->escape_string($vbulletin->GPC['productid']) . "'\r\n\t\t");
while ($phrasetype = $db->fetch_array($phrasetypes)) {
$db_alter->drop_field("phrasegroup_{$phrasetype['fieldname']}");
}
}
delete_product($vbulletin->GPC['productid']);
build_all_styles();
vBulletinHook::build_datastore($db);
require_once DIR . '/includes/adminfunctions_language.php';
build_language();
build_options();
示例9: preDelete
/**
* Additional tasks to perform before a delete.
*
* Return false to indicate that the entire delete process was not a success.
*
* @param mixed - The result of execDelete()
*/
protected function preDelete($result)
{
$this->assertItem();
require_once DIR . '/includes/class_taggablecontent.php';
$taggable = vB_Taggable_Content_Item::create(vB::$vbulletin,
vB_Types::instance()->getContentTypeID("vBCms_Article"),
intval($this->item->getId()));
$taggable->delete_tag_attachments();
vB::$db->query_write("
DELETE FROM " . TABLE_PREFIX . "cms_nodecategory
WHERE nodeid = " . intval($this->item->getNodeId())
);
vB::$db->query_write("
DELETE FROM " . TABLE_PREFIX . "cms_article
WHERE contentid = " . intval($this->item->getId())
);
vB_Cache::instance()->event('categories_updated');
return parent::preDelete($result);
}
示例10: delete
/**
* Permanently deletes a node
* @param integer The nodeid of the record to be deleted
*
* @return boolean
*/
public function delete($nodeid)
{
//We need to update the parent counts, but first we need to get the status
$node = $this->assertor->getRow('vBForum:node', array('nodeid' => $nodeid));
//We have to get this before we delete
if ($node['showpublished']) {
$parents = vB_Library::instance('Node')->getParents($nodeid);
}
//do the delete
parent::delete($nodeid);
//delete videoitems
$this->assertor->assertQuery('videoitem', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_DELETE, 'nodeid' => $nodeid));
vB_Cache::instance(vB_Cache::CACHE_FAST)->event("nodeChg_{$nodeid}");
vB_Cache::instance()->event("nodeChg_{$nodeid}");
}
示例11: array
// get usergroups who should be displayed on showgroups
// Scans too many rows. Usergroup Rows * User Rows
// VBIV-6689 Caching.
$groupcache = array();
if ($vbulletin->options['flcache']) {
$groupcache = vB_Cache::instance()->read('showgroups.groupcache');
}
if (empty($groupcache)) {
$users = $db->query_read_slave("\n\t\tSELECT user.*,\n\t\t\tusergroup.title,\n\t\t\tuser.options, usertextfield.buddylist,\n\t\t\t" . ($show['locationfield'] ? 'userfield.field2,' : '') . "\n\t\t\tIF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid\n\t\t\t" . ($vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,\n\t\t\tcustomavatar.width AS avwidth,customavatar.height AS avheight, customavatar.width_thumb AS avwidth_thumb, customavatar.height_thumb AS avheight_thumb, \n\t\t\tfiledata_thumb, NOT ISNULL(customavatar.userid) AS hascustom" : "") . "\n\t\t{$hook_query_fields}\n\t\tFROM " . TABLE_PREFIX . "user AS user\n\t\tLEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup ON(usergroup.usergroupid = user.usergroupid OR FIND_IN_SET(usergroup.usergroupid, user.membergroupids))\n\t\tLEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid=user.userid)\n\t\t" . ($vbulletin->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) \n\t\t\tLEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "\n\t\t{$hook_query_joins}\n\t\tWHERE (usergroup.genericoptions & " . $vbulletin->bf_ugp_genericoptions['showgroup'] . ")\n\t\t{$hook_query_where}\n\t");
while ($user = $db->fetch_array($users)) {
$t = strtoupper($user['title']);
$u = strtoupper($user['username']);
$groupcache["{$t}"]["{$u}"] = $user;
}
if ($vbulletin->options['flcache']) {
vB_Cache::instance()->write('showgroups.groupcache', $groupcache, $vbulletin->options['flcache']);
}
}
$usergroups = '';
if (sizeof($groupcache) >= 1) {
ksort($groupcache);
// alphabetically sort usergroups
foreach ($groupcache as $users) {
ksort($users);
// alphabetically sort users
$usergroupbits = '';
foreach ($users as $user) {
exec_switch_bg();
$user = process_showgroups_userinfo($user);
if ($vbulletin->options['enablepms'] and $vbulletin->userinfo['permissions']['pmquota'] and ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'] or $user['receivepm'] and $user['permissions']['pmquota'] and (!$user['receivepmbuddies'] or can_moderate() or strpos(" {$user['buddylist']} ", ' ' . $vbulletin->userinfo['userid'] . ' ') !== false))) {
$show['pmlink'] = true;
示例12: postSave
/**
* Performs additional queries or tasks after saving.
* Updates the node description with the title.
*
* @param mixed - The save result
* @param bool $deferred - Save was deferred
* @param bool $replace - Save used REPLACE
* @param bool $ignore - Save used IGNORE if inserting
* @return bool - Whether the save can be considered a success
*/
protected function postSave($result, $deferred, $replace, $ignore)
{
//result will normally be the nodeid if this was an insert. Let's check.
if ($this->isUpdating())
{
$nodeid = $this->item->getNodeId();
}
else if (is_array($result))
{
$nodeid = $result['nodeid'];
}
else
{
$nodeid = $result;
}
if (!$result)
{
return false;
}
parent::postSave($result, $deferred, $replace, $ignore);
//We need to update category information. Let's figure out what the current categories
// are and only make the necessary changes.
vB::$vbulletin->input->clean_array_gpc('r', array('categoryids' =>TYPE_ARRAY));
//if we don't have a categoryids variable around, we don't want to update categories.
if (vB::$vbulletin->GPC_exists['categoryids'])
{
$newcategories = array();
$currcategories = array();
foreach (vB::$vbulletin->GPC['categoryids'] as $categoryid)
{
if (isset($_REQUEST["cb_category_$categoryid"]))
{
$newcategories[]= $categoryid;
}
}
$newcategories = array_unique($newcategories);
if ($rst = vB::$vbulletin->db->query_read("SELECT categoryid FROM "
. TABLE_PREFIX . "cms_nodecategory WHERE nodeid =" . $nodeid))
{
while($row = vB::$vbulletin->db->fetch_array($rst))
{
$currcategories[] = $row['categoryid'];
}
}
if (count($update = array_diff($newcategories, $currcategories)))
{
foreach ($update as $categoryid)
{
vB::$vbulletin->db->query_write("INSERT INTO ". TABLE_PREFIX .
"cms_nodecategory (nodeid, categoryid) values (" . $nodeid .
", $categoryid) ");
}
}
if (count($update = array_diff($currcategories, $newcategories)))
{
vB::$vbulletin->db->query_write("DELETE FROM ". TABLE_PREFIX .
"cms_nodecategory WHERE nodeid =" . $nodeid .
" AND categoryid in (" . implode(', ', $update) . ")" );
}
vB_Cache::instance()->event('categories_updated');
vB_Cache::instance()->event($this->item->getContentCacheEvent());
}
if ($this->index_search)
{
$this->indexSearchContent();
}
vB_Cache::instance()->event('cms_count_published');
}
示例13: post_save_each
/**
* Additional data to update after a save call (such as denormalized values in other tables).
*
* @param boolean Do the query?
*/
function post_save_each($doquery = true)
{
$moderatorid = $this->fetch_field('moderatorid');
// update usergroupid / membergroupids
if (!$this->condition and !in_array($this->moderator['userid'], explode(',', $this->config['SpecialUsers']['undeletableusers'])) and can_administer('canadminusers')) {
$update_usergroupid = $this->info['usergroupid'] > 0;
$update_membergroup = (!empty($this->info['membergroupids']) and is_array($this->info['membergroupids']));
if ($update_usergroupid or $update_membergroup) {
$userdata = new vB_Datamanager_User($this->registry, vB_DataManager_Constants::ERRTYPE_SILENT);
if (!$this->info['user'] and $this->moderator['userid']) {
$this->info['user'] = fetch_userinfo($this->moderator['userid']);
}
$userdata->set_existing($this->info['user']);
cache_permissions($this->info['user'], false);
$displaygroupid = $update_usergroupid ? $this->info['usergroupid'] : $this->info['user']['displaygroupid'];
$this->usergroupcache = vB::getDatastore()->get_value('usergroupcache');
$userdata->set_usertitle($this->info['user']['customtitle'] ? $this->info['user']['usertitle'] : '', false, $this->usergroupcache["{$displaygroupid}"], ($this->info['user']['customtitle'] == 1 or $this->info['user']['permissions']['genericpermissions'] & $this->bf_ugp_genericpermissions['canusecustomtitle']) ? true : false, $this->info['user']['customtitle'] == 1 ? true : false);
$userdata->set_failure_callback(array(&$this, 'update_user_failed_insert'));
if ($update_usergroupid) {
$userdata->set('usergroupid', $this->info['usergroupid']);
$userdata->set('displaygroupid', $this->info['usergroupid']);
}
if ($update_membergroup) {
$membergroupids = preg_split('#,#', $this->info['user']['membergroupids'], -1, PREG_SPLIT_NO_EMPTY);
$membergroupids = array_unique(array_merge($membergroupids, $this->info['membergroupids']));
if ($key = array_search($this->info['user']['usergroupid'], $membergroupids)) {
unset($membergroupids["{$key}"]);
}
sort($membergroupids);
$userdata->set('membergroupids', $membergroupids);
}
if ($userdata->errors) {
$this->errors = array_merge($this->errors, $userdata->errors);
return;
}
$userdata->save();
}
}
if (!$this->condition and !$this->options['ignoremods']) {
$rebuild_ignore_list = array();
$ignored_moderators = $this->assertor->getRows('userlist', array('relationid' => $this->fetch_field('userid'), 'type' => 'ignore'));
foreach ($ignored_moderators as $ignored_moderator) {
$rebuild_ignore_list[] = $ignored_moderator['userid'];
}
if (!empty($rebuild_ignore_list)) {
require_once DIR . '/includes/functions_databuild.php';
$this->assertor->delete('userlist', array('relationid' => $this->fetch_field('userid'), 'type' => 'ignore'));
foreach ($rebuild_ignore_list as $userid) {
build_userlist($userid);
}
}
}
// Legacy Hook 'moderatordata_postsave' Removed //
vB_Cache::instance(vB_Cache::CACHE_FAST)->event('userPerms_' . $this->moderator['userid']);
}
示例14: bulkFetchUrls
/**
* Build URLs using a single instance for the class. It does not check permissions
* @param string $className
* @param array $URLInfoList
* - route
* - data
* - extra
* - anchor
* - options
* @return array
*/
protected static function bulkFetchUrls($className, $URLInfoList)
{
$results = array();
$cache = vB_Cache::instance(vB_Cache::CACHE_FAST);
foreach ($URLInfoList as $hash => $info) {
try {
// we need different instances, since we need to instantiate different action classes
$route = new $className($info['routeInfo'], $info['data'], http_build_query($info['extra']), $info['anchor']);
$options = explode('|', $info['route']);
$routeId = $options[0];
$fullURL = $route->getFullUrl($options);
$cache->write($info['innerHash'], $fullURL, 1440, array('routeChg_' . $routeId));
} catch (Exception $e) {
$fullURL = '';
}
$results[$hash] = $fullURL;
}
return $results;
}
示例15: cleanContentCache
/**
* Cleans the cache of all of the parent sections.
*/
protected function cleanContentCache()
{
$events = $this->getCleanCacheEvents();
vB_Cache::instance()->event($this->getCleanCacheEvents())->cleanNow();
}