本文整理汇总了PHP中CampCache类的典型用法代码示例。如果您正苦于以下问题:PHP CampCache类的具体用法?PHP CampCache怎么用?PHP CampCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CampCache类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getCache
/**
* Get cache object
* @return CampCache
*/
public function getCache()
{
if ($this->cache === NULL) {
$this->cache = CampCache::singleton();
}
return $this->cache;
}
开发者ID:sourcefabric,项目名称:newscoop,代码行数:11,代码来源:Widget.php
示例2: GetList
/**
* Gets an issues list based on the given parameters.
*
* @param integer $p_context_id
* The Context Box Identifier
* @param string $p_order
* An array of columns and directions to order by
* @param integer $p_start
* The record number to start the list
* @param integer $p_limit
* The offset. How many records from $p_start will be retrieved.
* @param integer $p_count
* The total count of the elements; this count is computed without
* applying the start ($p_start) and limit parameters ($p_limit)
*
* @return array $issuesList
* An array of Issue objects
*/
public static function GetList(array $params, $p_order = null, $p_start = 0, $p_limit = 0, &$p_count, $p_skipCache = false)
{
global $g_ado_db;
if (!$p_skipCache && CampCache::IsEnabled()) {
$paramsArray['parameters'] = serialize($params);
$paramsArray['order'] = is_null($p_order) ? 'id' : $p_order;
$paramsArray['start'] = $p_start;
$paramsArray['limit'] = $p_limit;
$cacheListObj = new CampCacheList($paramsArray, __METHOD__);
$issuesList = $cacheListObj->fetchFromCache();
if ($issuesList !== false && is_array($issuesList)) {
return $issuesList;
}
}
if (isset($params['role']) && $params['role'] == 'child') {
$sql = 'SELECT b.fk_article_no FROM context_boxes b, Articles a0' . ' WHERE a0.Number = b.fk_article_no AND ' . ' a0.Type = "dossier" AND ' . ' b.id IN (SELECT c.fk_context_id ' . ' FROM Articles a, context_articles c ' . ' WHERE c.fk_article_no = ' . $params['article'] . ' AND a.Number = c.fk_article_no)' . ' ORDER BY a0.PublishDate DESC';
} else {
$sql = 'SELECT fk_article_no FROM context_articles' . ' WHERE fk_context_id = ' . $params['context_box'] . ' ORDER BY id';
}
if ($p_limit > 0) {
$sql .= ' LIMIT ' . $p_limit;
}
$returnArray = array();
$rows = $g_ado_db->GetAll($sql);
if (is_array($rows)) {
foreach ($rows as $row) {
$returnArray[] = $row['fk_article_no'];
}
}
$p_count = count($returnArray);
return $returnArray;
}
开发者ID:alvsgithub,项目名称:Newscoop,代码行数:50,代码来源:ContextBoxArticle.php
示例3: GetList
/**
* Gets an issues list based on the given parameters.
*
* @param integer $p_context_id
* The Context Box Identifier
* @param string $p_order
* An array of columns and directions to order by
* @param integer $p_start
* The record number to start the list
* @param integer $p_limit
* The offset. How many records from $p_start will be retrieved.
* @param integer $p_count
* The total count of the elements; this count is computed without
* applying the start ($p_start) and limit parameters ($p_limit)
*
* @return array $issuesList
* An array of Issue objects
*/
public static function GetList($p_context_id, $p_order = null, $p_start = 0, $p_limit = 0, &$p_count, $p_skipCache = false)
{
global $g_ado_db;
if (!$p_skipCache && CampCache::IsEnabled()) {
$paramsArray['parameters'] = serialize($p_parameters);
$paramsArray['order'] = is_null($p_order) ? 'id desc' : $p_order;
$paramsArray['start'] = $p_start;
$paramsArray['limit'] = $p_limit;
$cacheListObj = new CampCacheList($paramsArray, __METHOD__);
$issuesList = $cacheListObj->fetchFromCache();
if ($issuesList !== false && is_array($issuesList)) {
return $issuesList;
}
}
$returnArray = array();
$sql = 'SELECT fk_article_no FROM context_articles
WHERE fk_context_id = ' . $p_context_id . '
ORDER BY id desc';
$rows = $g_ado_db->GetAll($sql);
if (is_array($rows)) {
foreach ($rows as $row) {
$returnArray[] = $row['fk_article_no'];
}
}
$p_count = count($returnArray);
return array_reverse($returnArray);
}
开发者ID:nidzix,项目名称:Newscoop,代码行数:45,代码来源:ContextBoxArticle.php
示例4: _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');
}
}
开发者ID:sourcefabric,项目名称:newscoop,代码行数:36,代码来源:Bootstrap.php
示例5: delete
public function delete()
{
$deleted = parent::delete();
$CampCache = CampCache::singleton();
$CampCache->clear('user');
return $deleted;
}
开发者ID:nidzix,项目名称:Newscoop,代码行数:7,代码来源:Soundcloud.php
示例6: singleton
/**
* Singleton function that returns the global class object.
*
* @return CampCache
*/
public static function singleton()
{
if (is_null(self::$m_instance)) {
$preferencesService = \Zend_Registry::get('container')->getService('system_preferences_service');
self::$m_instance = new CampCache($preferencesService->DBCacheEngine);
}
return self::$m_instance;
}
开发者ID:sourcefabric,项目名称:newscoop,代码行数:13,代码来源:CampCache.php
示例7: _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');
}
}
开发者ID:nidzix,项目名称:Newscoop,代码行数:52,代码来源:Bootstrap.php
示例8: 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');
}
开发者ID:nidzix,项目名称:Newscoop,代码行数:46,代码来源:LegacyController.php
示例9: deleteFromCache
public function deleteFromCache()
{
if (CampCache::IsEnabled()) {
CampCache::singleton()->delete($this->getCacheKey());
}
}
开发者ID:sourcefabric,项目名称:newscoop,代码行数:6,代码来源:CampCacheList.php
示例10:
<tr><td colspan="2"><hr/></td></tr>
<tr><td>init:</td><td style="text-align: right"><?php echo $initTime; ?></td></tr>
<tr><td>template render:</td><td style="text-align: right"><?php echo $renderTemplate; ?></td></tr>
<tr><td>end event:</td><td style="text-align: right"><?php echo $endEvent; ?></td></tr>
<tr><td colspan="2"><hr/></td></tr>
<tr><th>total:</th><th style="text-align: right"><?php echo $totalTime; ?></th></tr>
</table>
</td>
<td style="width: 220px; text-align: left; vertical-align: top">
<table style="border-style: ridge; border-right-style: ridge; border-width: thin; padding: 5px;">
<tr><th colspan="2">Cache</th></tr>
<tr><td colspan="2"><hr/></td></tr>
<tr><td>store requests:</td><td style="text-align: right"><?php echo CampCache::GetStoreRequests(); ?></td></tr>
<tr><td>fetch requests:</td><td style="text-align: right"><?php echo CampCache::GetFetchRequests(); ?></td></tr>
<tr><td>hits:</td><td style="text-align: right"><?php echo CampCache::GetHits(); ?></td></tr>
</table>
</td>
<td style="width: 300px; text-align: left; vertical-align: top">
<table style="border-style: ridge; border-right-style: ridge; border-width: thin; padding: 5px;">
<tr><th>Init Event</th><th>Time (msec)</th></tr>
<tr><td colspan="2"><hr/></td></tr>
<tr><td>load base init:</td><td style="text-align: right"><?php echo $initPaths; ?></td></tr>
<!-- <tr><td>campsite object:</td><td style="text-align: right"><?php echo $initCampsite; ?></td></tr> -->
<tr><td>load config:</td><td style="text-align: right"><?php echo $loadConfig; ?></td></tr>
<!-- <tr><td>session object:</td><td style="text-align: right"><?php echo $initSession; ?></td></tr> -->
<tr><td>context object:</td><td style="text-align: right"><?php echo $initContext; ?></td></tr>
<tr><td>dispatch:</td><td style="text-align: right"><?php echo $dispatch; ?></td></tr>
<tr><td>load translation:</td><td style="text-align: right"><?php echo $loadTranslation; ?></td></tr>
</table>
开发者ID:nistormihai,项目名称:Newscoop,代码行数:31,代码来源:index-debug.php
示例11: GetLanguages
/**
* Return an array of Language objects based on the given contraints.
*
* @param int $p_id
* @param string $p_languageCode
* @param string $p_name
* @param array $p_excludedLanguages
* @param array $p_order
* @return array
*/
public static function GetLanguages($p_id = null, $p_languageCode = null, $p_name = null, array $p_excludedLanguages = array(), array $p_order = array(), $p_skipCache = false)
{
global $g_ado_db;
if (!$p_skipCache && CampCache::IsEnabled()) {
$paramsArray['id'] = is_null($p_id) ? 'null' : $p_id;
$paramsArray['language_code'] = is_null($p_languageCode) ? 'null' : $p_languageCode;
$paramsArray['name'] = is_null($p_name) ? 'null' : $p_name;
$paramsArray['excluded_languages'] = $p_excludedLanguages;
$paramsArray['order'] = $p_order;
$cacheListObj = new CampCacheList($paramsArray, __METHOD__);
$languages = $cacheListObj->fetchFromCache();
if ($languages !== false && is_array($languages)) {
return $languages;
}
}
$selectClauseObj = new SQLSelectClause();
$tmpLanguage = new Language();
$selectClauseObj->setTable($tmpLanguage->getDbTableName());
if (!is_null($p_id)) {
$selectClauseObj->addWhere($g_ado_db->escapeKeyVal('Id', (int) $p_id));
}
if (!is_null($p_languageCode)) {
$selectClauseObj->addWhere($g_ado_db->escapeKeyVal('Code', $p_languageCode));
}
if (!is_null($p_name)) {
$selectClauseObj->addWhere($g_ado_db->escapeKeyVal('Name', $p_name));
}
if (count($p_excludedLanguages) > 0) {
$excludedLanguages = array();
foreach ($p_excludedLanguages as $excludedLanguage) {
$excludedLanguages[] = (int) $excludedLanguage;
}
$selectClauseObj->addWhere("Id NOT IN (" . implode(', ', $excludedLanguages) . ")");
}
$order = Language::ProcessLanguageListOrder($p_order);
foreach ($order as $orderDesc) {
$selectClauseObj->addOrderBy($orderDesc['field'] . ' ' . $orderDesc['dir']);
}
$selectClause = $selectClauseObj->buildQuery();
$languages = DbObjectArray::Create('Language', $selectClause);
if (!$p_skipCache && CampCache::IsEnabled()) {
$cacheListObj->storeInCache($languages);
}
return $languages;
}
开发者ID:nidzix,项目名称:Newscoop,代码行数:55,代码来源:Language.php
示例12: delete
/**
* Delete record from database.
*
* @return boolean
*/
function delete()
{
// delete correspondending Attachment object if not used by other DebateAnswers
$DebateAnswerAttachments = DebateAnswerAttachment::getDebateAnswerAttachments(null, null, $this->getProperty('fk_attachment_id'));
if (count($DebateAnswerAttachments) === 1) {
$DebateAnswerAttachment = current($DebateAnswerAttachments);
$DebateAnswerAttachment->getAttachment()->delete();
}
// Delete record from the database
$deleted = parent::delete();
/*
if ($deleted) {
if (function_exists("camp_load_translation_strings")) {
camp_load_translation_strings("api");
}
$logtext = getGS('Article #$1: "$2" ($3) deleted.',
$this->m_data['Number'], $this->m_data['Name'], $this->getLanguageName())
." (".getGS("Publication")." ".$this->m_data['IdPublication'].", "
." ".getGS("Issue")." ".$this->m_data['NrIssue'].", "
." ".getGS("Section")." ".$this->m_data['NrSection'].")";
Log::Message($logtext, null, 32);
}
*/
$CampCache = CampCache::singleton();
$CampCache->clear('user');
return $deleted;
}
开发者ID:nidzix,项目名称:Newscoop,代码行数:32,代码来源:DebateAnswerAttachment.php
示例13: storeInCache
private function storeInCache()
{
if (CampCache::IsEnabled()) {
CampCache::singleton()->store($this->getCacheKey(), $this, $this->m_defaultTTL);
}
}
开发者ID:nistormihai,项目名称:Newscoop,代码行数:6,代码来源:ListObject.php
示例14: GetList
/**
* Returns an articles list based on the given parameters.
*
* @param array $p_parameters
* An array of ComparisonOperation objects
* @param string $p_order
* An array of columns and directions to order by
* @param integer $p_start
* The record number to start the list
* @param integer $p_limit
* The offset. How many records from $p_start will be retrieved.
* @param integer $p_count
* The total count of the elements; this count is computed without
* applying the start ($p_start) and limit parameters ($p_limit)
*
* @return array $articlesList
* An array of Article objects
*/
public static function GetList(array $p_parameters, $p_order = null, $p_start = 0, $p_limit = 0, &$p_count, $p_skipCache = false, $returnObjs = true)
{
global $g_ado_db;
if (!$p_skipCache && CampCache::IsEnabled()) {
$paramsArray['parameters'] = serialize($p_parameters);
$paramsArray['order'] = is_null($p_order) ? 'null' : $p_order;
$paramsArray['start'] = $p_start;
$paramsArray['limit'] = $p_limit;
$cacheListObj = new CampCacheList($paramsArray, __METHOD__);
$articlesList = $cacheListObj->fetchFromCache();
if ($articlesList !== false && is_array($articlesList)) {
return $articlesList;
}
}
$matchAllTopics = false;
$hasTopics = array();
$hasNotTopics = array();
$selectClauseObj = new SQLSelectClause();
$otherTables = array();
// sets the name of the table for the this database object
$tmpArticle = new Article();
$articleTable = $tmpArticle->getDbTableName();
$selectClauseObj->setTable($articleTable);
unset($tmpArticle);
$languageId = null;
$em = Zend_Registry::get('container')->getService('em');
$request = Zend_Registry::get('container')->getService('request');
$repository = $em->getRepository('Newscoop\\NewscoopBundle\\Entity\\Topic');
// parses the given parameters in order to build the WHERE part of
// the SQL SELECT sentence
foreach ($p_parameters as $param) {
$comparisonOperation = self::ProcessListParameters($param, $otherTables);
$leftOperand = strtolower($comparisonOperation['left']);
if ($leftOperand == 'idlanguage' && $comparisonOperation['symbol'] == '=') {
$languageId = $comparisonOperation['right'];
}
if (array_key_exists($leftOperand, Article::$s_regularParameters)) {
// regular article field, having a direct correspondent in the
// Article table fields
$whereCondition = Article::$s_regularParameters[$leftOperand] . ' ' . $comparisonOperation['symbol'] . " " . $g_ado_db->escape($comparisonOperation['right']) . " ";
if ($leftOperand == 'reads' && strstr($comparisonOperation['symbol'], '=') !== false && $comparisonOperation['right'] == 0) {
$selectClauseObj->addConditionalWhere($whereCondition);
$isNullCond = Article::$s_regularParameters[$leftOperand] . ' IS NULL';
$selectClauseObj->addConditionalWhere($isNullCond);
} elseif ($leftOperand == 'type' && $comparisonOperation['symbol'] == '=') {
$selectClauseObj->addConditionalWhere($whereCondition);
} elseif ($leftOperand == 'workflow_status' && isset($comparisonOperation['pending'])) {
$selectClauseObj->addConditionalWhere('Articles.NrIssue = 0');
$selectClauseObj->addConditionalWhere('Articles.NrSection = 0');
$selectClauseObj->addWhere($whereCondition);
} else {
$selectClauseObj->addWhere($whereCondition);
}
} elseif ($leftOperand == 'matchalltopics') {
// set the matchAllTopics flag
$matchAllTopics = true;
} elseif ($leftOperand == 'topic') {
// add the topic to the list of match/do not match topics depending
// on the operator
$topic = $repository->getTopicByIdOrName($comparisonOperation['right'], $request->getLocale())->getOneOrNullResult();
if ($topic) {
$topicIds = array();
foreach ($topic->getChildren() as $child) {
$topicIds[] = $child->getId();
}
$topicIds[] = $comparisonOperation['right'];
if ($comparisonOperation['symbol'] == '=') {
$hasTopics[] = $topicIds;
} else {
$hasNotTopics[] = $topicIds;
}
}
} elseif ($leftOperand == 'topic_strict') {
$topic = $repository->getTopicByIdOrName($comparisonOperation['right'], $request->getLocale())->getOneOrNullResult();
if ($topic) {
$topicIds[] = $comparisonOperation['right'];
if ($comparisonOperation['symbol'] == '=') {
$hasTopics[] = $topicIds;
} else {
$hasNotTopics[] = $topicIds;
}
}
//.........这里部分代码省略.........
开发者ID:alvsgithub,项目名称:Newscoop,代码行数:101,代码来源:Article.php
示例15: GetList
/**
* Returns an article images list based on the given parameters.
*
* @param array $p_parameters
* An array of ComparisonOperation objects
* @param string $p_order
* An array of columns and directions to order by
* @param integer $p_start
* The record number to start the list
* @param integer $p_limit
* The offset. How many records from $p_start will be retrieved.
* @param integer $p_count
* The total count of the elements; this count is computed without
* applying the start ($p_start) and limit parameters ($p_limit)
*
* @return array $articleImagesList
* An array of Image objects
*/
public static function GetList(array $p_parameters, array $p_order = array(), $p_start = 0, $p_limit = 0, &$p_count, $p_skipCache = false)
{
global $g_ado_db;
if (!$p_skipCache && CampCache::IsEnabled()) {
$paramsArray['parameters'] = serialize($p_parameters);
$paramsArray['order'] = is_null($p_order) ? 'null' : $p_order;
$paramsArray['start'] = $p_start;
$paramsArray['limit'] = $p_limit;
$cacheListObj = new CampCacheList($paramsArray, __METHOD__);
$articleImagesList = $cacheListObj->fetchFromCache();
if ($articleImagesList !== false && is_array($articleImagesList)) {
return $articleImagesList;
}
}
$hasArticleNr = false;
$selectClauseObj = new SQLSelectClause();
$countClauseObj = new SQLSelectClause();
// sets the where conditions
foreach ($p_parameters as $param) {
$comparisonOperation = self::ProcessListParameters($param);
if (sizeof($comparisonOperation) < 3) {
break;
}
if (strpos($comparisonOperation['left'], 'NrArticle')) {
$hasArticleNr = true;
}
$whereCondition = $g_ado_db->escapeOperation($comparisonOperation);
$selectClauseObj->addWhere($whereCondition);
$countClauseObj->addWhere($whereCondition);
}
// validates whether article number was given
if ($hasArticleNr === false) {
CampTemplate::singleton()->trigger_error('Missing parameter Article ' . 'Number in statement list_article_images');
return;
}
// sets the columns to be fetched
$tmpImage = new Image();
$columnNames = $tmpImage->getColumnNames(true);
foreach ($columnNames as $columnName) {
$selectClauseObj->addColumn($columnName);
}
$countClauseObj->addColumn('COUNT(*)');
// sets the base table Attachment
$selectClauseObj->setTable($tmpImage->getDbTableName());
$countClauseObj->setTable($tmpImage->getDbTableName());
unset($tmpImage);
// adds the ArticleImages join and condition to the query
$selectClauseObj->addTableFrom('ArticleImages');
$selectClauseObj->addWhere('ArticleImages.IdImage = Images.Id');
$countClauseObj->addTableFrom('ArticleImages');
$countClauseObj->addWhere('ArticleImages.IdImage = Images.Id');
// sets the ORDER BY condition
$p_order = array_merge($p_order, self::$s_defaultOrder);
$order = self::ProcessListOrder($p_order);
foreach ($order as $orderDesc) {
$orderColumn = $orderDesc['field'];
$orderDirection = $orderDesc['dir'];
$selectClauseObj->addOrderBy($orderColumn . ' ' . $orderDirection);
}
// sets the limit
$selectClauseObj->setLimit($p_start, $p_limit);
// builds the query executes it
$selectQuery = $selectClauseObj->buildQuery();
$images = $g_ado_db->GetAll($selectQuery);
if (is_array($images)) {
$countQuery = $countClauseObj->buildQuery();
$p_count = $g_ado_db->GetOne($countQuery);
// builds the array of image objects
$articleImagesList = array();
foreach ($images as $image) {
$imgObj = new Image($image['Id']);
if ($imgObj->exists()) {
$articleImagesList[] = $imgObj;
}
}
} else {
$articleImagesList = array();
$p_count = 0;
}
if (!$p_skipCache && CampCache::IsEnabled()) {
$cacheListObj->storeInCache($articleImagesList);
}
//.........这里部分代码省略.........
开发者ID:alvsgithub,项目名称:Newscoop,代码行数:101,代码来源:ArticleImage.php
示例16: camp_session_get
$request = camp_session_get("request_$requestId", '');
if (!empty($request)) {
$request = unserialize($request);
// Update security token.
$token_field = SecurityToken::SECURITY_TOKEN;
$request['post'][$token_field] = SecurityToken::GetToken();
// Set values.
foreach ($request['post'] as $key => $val) {
$_POST[$key] = $_REQUEST[$key] = $val;
}
}
if (file_exists($Campsite['HTML_DIR'] . '/reset_cache')) {
CampCache::singleton()->clear('user');
unlink($GLOBALS['g_campsiteDir'] . '/reset_cache');
}
require_once($Campsite['HTML_DIR'] . "/$ADMIN_DIR/init_content.php");
// Get the main content
ob_start();
require_once($path_name);
$content = ob_get_clean();
// We create the top menu AFTER the main content because
// of the localizer screen. It will update the strings, which
// need to be reflected immediately in the menu.
$_top_menu = '';
if ($needs_menu) {
ob_start();
开发者ID:nistormihai,项目名称:Newscoop,代码行数:31,代码来源:admin.php
示例17: GetList
/**
* Returns an articles list based on the given parameters.
*
* @param array $p_parameters
* An array of ComparisonOperation objects
* @param string $p_order
* An array of columns and directions to order by
* @param integer $p_start
* The record number to start the list
* @param integer $p_limit
* The offset. How many records from $p_start will be retrieved.
* @param integer $p_count
* The total count of the elements; this count is computed without
* applying the start ($p_start) and limit parameters ($p_limit)
*
* @return array $articlesList
* An array of Article objects
*/
public static function GetList(array $p_parameters, $p_order = null,
$p_start = 0, $p_limit = 0, &$p_count, $p_skipCache = false)
{
global $g_ado_db;
if (!$p_skipCache && CampCache::IsEnabled()) {
$paramsArray['parameters'] = serialize($p_parameters);
$paramsArray['order'] = (is_null($p_order)) ? 'null' : $p_order;
$paramsArray['start'] = $p_start;
$paramsArray['limit'] = $p_limit;
$cacheListObj = new CampCacheList($paramsArray, __METHOD__);
$articlesList = $cacheListObj->fetchFromCache();
if ($articlesList !== false && is_array($articlesList)) {
return $articlesList;
}
}
$matchAllTopics = false;
$hasTopics = array();
$hasNotTopics = array();
$selectClauseObj = new SQLSelectClause();
$otherTables = array();
// sets the name of the table for the this database object
$tmpArticle = new Article();
$articleTable = $tmpArticle->getDbTableName();
$selectClauseObj->setTable($articleTable);
unset($tmpArticle);
$languageId = null;
// parses the given parameters in order to build the WHERE part of
// the SQL SELECT sentence
foreach ($p_parameters as $param) {
$comparisonOperation = self::ProcessListParameters($param, $otherTables);
$leftOperand = strtolower($comparisonOperation['left']);
if ($leftOperand == 'idlanguage' && $comparisonOperation['symbol'] == '=') {
$languageId = $comparisonOperation['right'];
}
if (array_key_exists($leftOperand, Article::$s_regularParameters)) {
// regular article field, having a direct correspondent in the
// Article table fields
$whereCondition = Article::$s_regularParameters[$leftOperand]
. ' ' . $comparisonOperation['symbol']
. " '" . $g_ado_db->escape($comparisonOperation['right']) . "' ";
if ($leftOperand == 'reads'
&& strstr($comparisonOperation['symbol'], '=') !== false
&& $comparisonOperation['right'] == 0) {
$selectClauseObj->addConditionalWhere($whereCondition);
$isNullCond = Article::$s_regularParameters[$leftOperand]
. ' IS NULL';
$selectClauseObj->addConditionalWhere($isNullCond);
} elseif ($leftOperand == 'type' && $comparisonOperation['symbol'] == '=' ) {
$selectClauseObj->addConditionalWhere($whereCondition);
} else {
$selectClauseObj->addWhere($whereCondition);
}
} elseif ($leftOperand == 'matchalltopics') {
// set the matchAllTopics flag
$matchAllTopics = true;
} elseif ($leftOperand == 'topic') {
// add the topic to the list of match/do not match topics depending
// on the operator
$topic = new Topic($comparisonOperation['right']);
if ($topic->exists()) {
$topicIds = $topic->getSubtopics(true, 0);
$topicIds[] = $comparisonOperation['right'];
if ($comparisonOperation['symbol'] == '=') {
$hasTopics[] = $topicIds;
} else {
$hasNotTopics[] = $topicIds;
}
}
} elseif ($leftOperand == 'author') {
$otherTables['ArticleAuthors'] = array('__JOIN' => ',');
$author = Author::ReadName($comparisonOperation['right']);
$symbol = $comparisonOperation['symbol'];
$valModifier = strtolower($symbol) == 'like' ? '%' : '';
$firstName = $g_ado_db->escape($author['first_name']);
$lastName = $g_ado_db->escape($author['last_name']);
//.........这里部分代码省略.........
开发者ID:nistormihai,项目名称:Newscoop,代码行数:101,代码来源:Article.php
示例18: execute
/**
*
*/
protected function execute()
{
$input = CampRequest::GetInput('post');
$session = CampSession::singleton();
$this->m_step = (!empty($input['step'])) ? $input['step'] : $this->m_defaultStep;
switch($this->m_step) {
case 'precheck':
break;
case 'license':
$session->unsetData('config.db', 'installation');
$session->unsetData('config.site', 'installation');
$session->unsetData('config.demo', 'installation');
$this->preInstallationCheck();
break;
case 'database':
$this->license();
break;
case 'mainconfig':
$prevStep = (isset($input['this_step'])) ? $input['this_step'] : '';
if ($prevStep != 'loaddemo'
&& $this->databaseConfiguration($input)) {
$session->setData('config.db', $this->m_config['database'], 'installation', true);
}
break;
case 'loaddemo':
$prevStep = (isset($input['this_step'])) ? $input['this_step'] : '';
if ($prevStep != 'loaddemo'
&& $this->generalConfiguration($input)) {
$session->setData('config.site', $this->m_config['mainconfig'], 'installation', true);
}
break;
case 'cronjobs':
if (isset($input['install_demo'])) {
$session->setData('config.demo', array('loaddemo' => $input['install_demo']), 'installation', true);
if ($input['install_demo'] != '0') {
if (!$this->loadDemoSite()) {
break;
}
}
}
break;
case 'finish':
if (isset($input['install_demo'])) {
$session->setData('config.demo', array('loaddemo' => $input['install_demo']), 'installation', true);
if ($input['install_demo'] != '0') {
if (!$this->loadDemoSite()) {
break;
}
}
}
$this->saveCronJobsScripts();
if ($this->finish()) {
$this->saveConfiguration();
self::InstallPlugins();
require_once($GLOBALS['g_campsiteDir'].'/classes/SystemPref.php');
SystemPref::DeleteSystemPrefsFromCache();
// clear all cache
require_once($GLOBALS['g_campsiteDir'].'/classes/CampCache.php');
CampCache::singleton()->clear('user');
CampCache::singleton()->clear();
CampTemplate::singleton()->clearCache();
}
break;
}
} // fn execute
开发者ID:nistormihai,项目名称:Newscoop,代码行数:72,代码来源:CampInstallationBase.php
示例19: CampSite
// initiates the campsite site
$campsite = new CampSite();
// loads site configuration settings
$campsite->loadConfiguration(CS_PATH_CONFIG . DIR_SEP . 'configuration.php');
// starts the session
$campsite->initSession();
$session = CampSite::GetSessionInstance();
$configDb = array('hostname' => $Campsite['db']['host'], 'hostport' => $Campsite['db']['port'], 'username' => $Campsite['db']['user'], 'userpass' => $Campsite['db']['pass'], 'database' => $Campsite['db']['name']);
$session->setData('config.db', $configDb, 'installation');
// upgrading the database
$res = camp_upgrade_database($Campsite['DATABASE_NAME'], true, true);
if ($res !== 0) {
display_upgrade_error("While upgrading the database: {$res}");
}
CampCache::singleton(
|
请发表评论