本文整理汇总了PHP中CampCache::singleton方法的典型用法代码示例。如果您正苦于以下问题:PHP CampCache::singleton方法的具体用法?PHP CampCache::singleton怎么用?PHP CampCache::singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CampCache
的用法示例。
在下文中一共展示了CampCache::singleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCache
/**
* Get cache object
* @return CampCache
*/
public function getCache()
{
if ($this->cache === NULL) {
$this->cache = CampCache::singleton();
}
return $this->cache;
}
示例2: _initNewscoop
/**
* Legacy admin bootstrap
*/
protected function _initNewscoop()
{
global $ADMIN, $g_user, $prefix, $Campsite;
defined('WWW_DIR') || define('WWW_DIR', realpath(APPLICATION_PATH . '/../'));
defined('LIBS_DIR') || define('LIBS_DIR', WWW_DIR . '/admin-files/libs');
$GLOBALS['g_campsiteDir'] = WWW_DIR;
require_once $GLOBALS['g_campsiteDir'] . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'campsite_constants.php';
require_once CS_PATH_CONFIG . DIR_SEP . 'install_conf.php';
// goes to install process if configuration files does not exist yet
if (!file_exists(CS_PATH_CONFIG . DIR_SEP . 'configuration.php') || !file_exists(CS_PATH_CONFIG . DIR_SEP . 'database_conf.php')) {
header('Location: ' . $Campsite['SUBDIR'] . '/install/');
exit;
}
require_once CS_PATH_CONFIG . DIR_SEP . 'database_conf.php';
require_once CS_PATH_SITE . DIR_SEP . 'include' . DIR_SEP . 'campsite_init.php';
require_once CS_PATH_SITE . DIR_SEP . 'classes' . DIR_SEP . 'CampTemplateCache.php';
// detect extended login/logout files
$prefix = file_exists(CS_PATH_SITE . DIR_SEP . 'admin-files' . DIR_SEP . 'ext_login.php') ? '/ext_' : '/';
require_once CS_PATH_SITE . '/admin-files/camp_html.php';
require_once CS_PATH_CLASSES . DIR_SEP . 'SecurityToken.php';
if (php_sapi_name() !== 'cli') {
set_error_handler(function ($p_number, $p_string, $p_file, $p_line) {
error_log(sprintf('Newscoop error: %s in %s:%d', $p_string, $p_file, $p_line));
global $Campsite;
require_once $Campsite['HTML_DIR'] . "/admin-files/bugreporter/bug_handler_main.php";
camp_bug_handler_main($p_number, $p_string, $p_file, $p_line);
}, error_reporting());
}
if (file_exists($Campsite['HTML_DIR'] . '/reset_cache')) {
CampCache::singleton()->clear('user');
unlink($GLOBALS['g_campsiteDir'] . '/reset_cache');
}
}
示例3: delete
public function delete()
{
$deleted = parent::delete();
$CampCache = CampCache::singleton();
$CampCache->clear('user');
return $deleted;
}
示例4: delete
/**
* Delete the language, this will also delete the language files unless
* the parameter specifies otherwise.
*
* @return boolean
*/
public function delete($p_deleteLanguageFiles = true)
{
if (is_link($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php')) {
unlink($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php');
}
$tmpData = $this->m_data;
$success = parent::delete();
if ($success) {
CampCache::singleton()->clear('user');
}
return $success;
}
示例5: _initNewscoop
/**
* Legacy admin bootstrap
*/
protected function _initNewscoop()
{
global $ADMIN_DIR, $ADMIN, $g_user, $prefix, $Campsite;
defined('WWW_DIR') || define('WWW_DIR', realpath(APPLICATION_PATH . '/../'));
defined('LIBS_DIR') || define('LIBS_DIR', WWW_DIR . '/admin-files/libs');
$GLOBALS['g_campsiteDir'] = WWW_DIR;
require_once $GLOBALS['g_campsiteDir'] . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'campsite_constants.php';
require_once CS_PATH_CONFIG . DIR_SEP . 'install_conf.php';
// goes to install process if configuration files does not exist yet
if (!file_exists(CS_PATH_CONFIG . DIR_SEP . 'configuration.php') || !file_exists(CS_PATH_CONFIG . DIR_SEP . 'database_conf.php')) {
header('Location: ' . $Campsite['SUBDIR'] . '/install/');
exit;
}
require_once CS_PATH_CONFIG . DIR_SEP . 'database_conf.php';
require_once CS_PATH_SITE . DIR_SEP . 'include' . DIR_SEP . 'campsite_init.php';
require_once CS_PATH_SITE . DIR_SEP . 'classes' . DIR_SEP . 'CampTemplateCache.php';
// detect extended login/logout files
$prefix = file_exists(CS_PATH_SITE . DIR_SEP . 'admin-files' . DIR_SEP . 'ext_login.php') ? '/ext_' : '/';
require_once CS_PATH_SITE . DIR_SEP . $ADMIN_DIR . DIR_SEP . 'camp_html.php';
require_once CS_PATH_CLASSES . DIR_SEP . 'SecurityToken.php';
// load if possible before setting camp_report_bug error handler
// to prevent error messages
include_once 'HTML/QuickForm.php';
include_once 'HTML/QuickForm/RuleRegistry.php';
include_once 'HTML/QuickForm/group.php';
if (!defined('IN_PHPUNIT') && !getenv('PLZSTOPTHISERRORHANDLERBIZNIS')) {
set_error_handler(function ($p_number, $p_string, $p_file, $p_line) {
if (($p_number & error_reporting()) === 0) {
return;
// respect php settings
}
global $ADMIN_DIR, $Campsite;
require_once $Campsite['HTML_DIR'] . "/{$ADMIN_DIR}/bugreporter/bug_handler_main.php";
camp_bug_handler_main($p_number, $p_string, $p_file, $p_line);
}, E_ALL);
}
camp_load_translation_strings("api");
$plugins = CampPlugin::GetEnabled(true);
foreach ($plugins as $plugin) {
camp_load_translation_strings("plugin_" . $plugin->getName());
}
// Load common translation strings
camp_load_translation_strings('globals');
require_once APPLICATION_PATH . "/../{$ADMIN_DIR}/init_content.php";
if (file_exists($Campsite['HTML_DIR'] . '/reset_cache')) {
CampCache::singleton()->clear('user');
unlink($GLOBALS['g_campsiteDir'] . '/reset_cache');
}
}
示例6: indexAction
public function indexAction()
{
global $controller;
$controller = $this;
require_once $GLOBALS['g_campsiteDir'] . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'campsite_constants.php';
require_once CS_PATH_CONFIG . DIR_SEP . 'install_conf.php';
$local_path = dirname(__FILE__) . '/include';
set_include_path($local_path . PATH_SEPARATOR . get_include_path());
require_once CS_PATH_INCLUDES . DIR_SEP . 'campsite_init.php';
if (file_exists(CS_PATH_SITE . DIR_SEP . 'reset_cache')) {
CampCache::singleton()->clear('user');
@unlink(CS_PATH_SITE . DIR_SEP . 'reset_cache');
}
// initializes the campsite object
$campsite = new CampSite();
// loads site configuration settings
$campsite->loadConfiguration(CS_PATH_CONFIG . DIR_SEP . 'configuration.php');
// starts the session
$campsite->initSession();
if (file_exists(CS_PATH_SITE . DIR_SEP . 'conf' . DIR_SEP . 'upgrading.php')) {
$this->upgrade();
exit(0);
}
// initiates the context
$campsite->init();
// dispatches campsite
$campsite->dispatch();
// triggers an event before render the page.
// looks for preview language if any.
$previewLang = $campsite->event('beforeRender');
if (!is_null($previewLang)) {
require_once $GLOBALS['g_campsiteDir'] . '/template_engine/classes/SyntaxError.php';
set_error_handler('templateErrorHandler');
// loads translations strings in the proper language for the error messages display
camp_load_translation_strings('preview', $previewLang);
} else {
set_error_handler(create_function('', 'return true;'));
}
if ($this->_request->getParam('logout') == 'true') {
$this->_redirect('/auth/logout/?url=' . urlencode($this->getRequest()->getPathInfo()));
}
// renders the site
$campsite->render();
// triggers an event after displaying
$campsite->event('afterRender');
}
示例7: RunIndexer
//.........这里部分代码省略.........
$article['IdLanguage'] = ($row['IdLanguage']) ? (int)$row['IdLanguage'] : 0;
$article['Type'] = ($row['Type']) ? $row['Type'] : '';
$article['Keywords'] = ($row['Keywords']) ? $row['Keywords'] : '';
$article['Name'] = ($row['Name']) ? $row['Name'] : '';
// deletes from index
$sql_query = 'DELETE FROM ArticleIndex '
. 'WHERE IdPublication = ' . $article['IdPublication']
. ' AND IdLanguage = ' . $article['IdLanguage']
. ' AND NrIssue = ' . $article['NrIssue']
. ' AND NrSection = ' . $article['NrSection']
. ' AND NrArticle = ' . $article['Number'];
if (!$g_ado_db->Execute($sql_query)) {
throw new Exception('Error deleting the old article index');
}
$nr_art++;
$keywordsHash = array();
self::BuildKeywordsList($article, $keywordsHash);
foreach ($keywordsHash as $keyword=>$isSet) {
if (empty($keyword)) {
continue;
}
$nr_word++;
if (isset($existing_words[$keyword])) {
$kwd_id = $existing_words[$keyword];
$word_cache_hits++;
} else {
$sql_query = 'SELECT Id FROM KeywordIndex '
. "WHERE Keyword = '" . $g_ado_db->escape($keyword) ."'";
$kwd_id = 0 + $g_ado_db->GetOne($sql_query);
$existing_words[$keyword] = $kwd_id;
}
if ($kwd_id == 0) {
$sql_query = 'SELECT MAX(Id) AS Id FROM KeywordIndex';
$last_kwd_id = 0 + $g_ado_db->GetOne($sql_query);
$kwd_id = $last_kwd_id + 1;
// inserts in keyword list
$sql_query = 'INSERT IGNORE INTO KeywordIndex '
. "SET Keyword = '" . $g_ado_db->escape($keyword) . "', "
. "Id = $kwd_id";
if (!$g_ado_db->Execute($sql_query)) {
throw new Exception('Error adding keyword');
}
$existing_words[$keyword] = $kwd_id;
$nr_new++;
}
if (!self::BatchAddArticleWord($articleWordsBatch, $article,
$kwd_id, $wordInsertQueries)) {
throw new Exception('Error adding article to index');
}
}
self::RunArticleWordBatch($articleWordsBatch, $wordInsertQueries);
unset($article['Name']);
unset($article['Keywords']);
unset($article['Type']);
$sql_query = "UPDATE Articles SET IsIndexed = 'Y' "
. 'WHERE IdPublication = ' . $article['IdPublication']
. ' AND NrIssue = ' . $article['NrIssue']
. ' AND NrSection = ' . $article['NrSection']
. ' AND Number = ' . $article['Number']
. ' AND IdLanguage = ' . $article['IdLanguage'];
if (!$g_ado_db->Execute($sql_query)) {
throw new Exception('Error updating the article');
}
if ($p_articlesLimit > 0 && $nr_art >= $p_articlesLimit) {
break;
}
$runTime = microtime(true) - $startTime;
$articleTime = $runTime / $nr_art;
if ($p_timeLimit > 0 && $runTime >= ($p_timeLimit - $articleTime)) {
break;
}
}
} catch (Exception $ex) {
CampCache::singleton()->clear('user');
flock($lockFile, LOCK_UN); // release the lock
return new PEAR_Error($ex->getMessage() . ': ' . $g_ado_db->ErrorMsg());
}
CampCache::singleton()->clear('user');
flock($lockFile, LOCK_UN); // release the lock
$totalTime = microtime(true) - $startTime;
$articleTime = $nr_art > 0 ? $totalTime / $nr_art : 0;
return array('articles'=>$nr_art, 'words'=>$nr_word, 'new words'=>$nr_new,
'total articles'=>$total_art, 'total time'=>$totalTime, 'article time'=>$articleTime,
'word cache hits'=>$word_cache_hits, 'word insert queries'=>$wordInsertQueries);
} // fn RunIndexer
示例8: DeleteActionsFromCache
public static function DeleteActionsFromCache()
{
if (CampCache::IsEnabled()) {
return CampCache::singleton()->delete(self::CACHE_KEY_LIST_OF_ACTIONS);
}
return false;
}
示例9: setProperty
/**
* Method to call parent::setProperty
* with clening the cache.
*
* @param string $p_name
* @param sring $p_value
*/
function setProperty($p_name, $p_value)
{
$return = parent::setProperty($p_name, $p_value);
$CampCache = CampCache::singleton();
$CampCache->clear('user');
return $return;
}
示例10: deleteFromCache
public function deleteFromCache()
{
if (CampCache::IsEnabled()) {
CampCache::singleton()->delete($this->getCacheKey());
}
}
示例11: delete
function delete()
{
$entry_id = $this->getProperty('entry_id');
$blog_id = $this->getProperty('fk_blog_id');
foreach (BlogComment::getComments(array('entry_id' => $this->getProperty('entry_id'))) as $Comment) {
$Comment->delete();
}
parent::delete();
BlogImageHelper::RemoveImageDerivates('entry', $entry_id);
BlogentryTopic::OnBlogentryDelete($entry_id);
Blog::TriggerCounters($blog_id);
$CampCache = CampCache::singleton();
$CampCache->clear('user');
}
示例12: OnIssuePublish
/**
* Set the article workflow on issue status change. Articles to be
* published with the issue will be published on article publish.
* Published articles are set to "publish with issue" on issue
* unpublish.
*
* @param int $p_publicationId
* @param int $p_languageId
* @param int $p_issueNo
* @param int $p_publish
*/
public static function OnIssuePublish($p_publicationId, $p_languageId,
$p_issueNo, $p_publish = true)
{
global $g_ado_db;
settype($p_publicationId, 'integer');
settype($p_languageId, 'integer');
settype($p_issueNo, 'integer');
$issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo);
if (!$issueObj->exists()) {
return false;
}
if (($issueObj->isPublished() && $p_publish)
|| (!$issueObj->isPublished() && !$p_publish)) {
return false;
}
$fromState = $p_publish ? 'M' : 'Y';
$toState = $p_publish ? 'Y' : 'M';
$sql = "UPDATE Articles SET Published = '$toState' WHERE "
. "IdPublication = $p_publicationId AND IdLanguage = $p_languageId"
. " AND NrIssue = $p_issueNo AND Published = '$fromState'";
$res = $g_ado_db->Execute($sql);
CampCache::singleton()->clear('user');
if (CampTemplateCache::factory()) {
CampTemplateCache::factory()->update(array(
'language' => $p_languageId,
'publication' => $p_publicationId,
'issue' => $p_issueNo,
'section' => null,
'article' => null,
));
}
return $res;
}
示例13: GetArticleComments
/**
* Get all comments associated with the given article.
*
* @param int $p_articleNumber
* @param int $p_languageId
* @param string $p_status
* This can be NULL if you dont care about the status,
* "approved" or "unapproved".
* @param boolean $p_countOnly
* @return array
*/
public static function GetArticleComments($p_articleNumber, $p_languageId,
$p_status = null, $p_countOnly = false,
$p_skipCache = true)
{
global $PHORUM, $g_ado_db;
if (CampCache::IsEnabled() && !$p_skipCache) {
$cacheKey = __METHOD__ . '_' . (int)$p_articleNumber . '_'
. (int)$p_languageId . '_' . $p_status . '_' . (int)$p_count_only;
$result = CampCache::singleton()->fetch($cacheKey);
if ($result !== false) {
return $result;
}
}
$threadId = ArticleComment::GetCommentThreadId($p_articleNumber, $p_languageId);
if (!$threadId) {
$result = $p_countOnly ? 0 : null;
if (CampCache::IsEnabled()) {
CampCache::singleton()->store($cacheKey, $result);
}
return $result;
}
// Are we counting or getting the comments?
$selectClause = "*";
if ($p_countOnly) {
$selectClause = "COUNT(*)";
}
// Only getting comments with a specific status?
$whereClause = "";
if (!is_null($p_status)) {
if ($p_status == "approved") {
$whereClause = " AND status=".PHORUM_STATUS_APPROVED;
} elseif ($p_status == "unapproved") {
$whereClause = " AND status=".PHORUM_STATUS_HIDDEN;
}
}
$queryStr = "SELECT $selectClause "
." FROM ".$PHORUM['message_table']
." WHERE thread=$threadId"
." AND message_id != thread"
. $whereClause
." ORDER BY message_id";
if ($p_countOnly) {
$result = $g_ado_db->GetOne($queryStr);
} else {
$result = DbObjectArray::Create("Phorum_message", $queryStr);
}
if (CampCache::IsEnabled() && !$p_skipCache) {
CampCache::singleton()->store($cacheKey, $result, self::DEFAULT_TTL);
}
return $result;
} // fn GetArticleComments
示例14: DoPendingActions
/**
* Execute all pending actions.
* @return void
*/
public static function DoPendingActions()
{
$actions = IssuePublish::GetPendingActions();
foreach ($actions as $issuePublishObj) {
$issuePublishObj->doAction();
}
if (count($actions) > 0) {
CampCache::singleton()->clear('user');
}
return count($actions);
}
示例15: setProperty
public function setProperty($p_name, $p_value)
{
switch ($p_name) {
case 'question':
case 'answer':
if ($this->getProperty($p_name) == '') {
parent::setProperty($p_name.'_date', date('Y-m-d H:i:s'));
}
break;
}
$return = parent::setProperty($p_name, $p_value);
$CampCache = CampCache::singleton();
$CampCache->clear('user');
return $return;
}