本文整理汇总了PHP中cms_utils类的典型用法代码示例。如果您正苦于以下问题:PHP cms_utils类的具体用法?PHP cms_utils怎么用?PHP cms_utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了cms_utils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _get_items_array
/**
* Not part of the api
*/
private function _get_items_array($selItems = array())
{
$AdvancedContent =& cms_utils::get_module('AdvancedContent');
$items = array();
if ($this->GetBlockProperty('items') != '') {
foreach (explode($this->GetBlockProperty('delimiter'), $this->GetBlockProperty('items')) as $key => $val) {
$items[$key]['id'] = munge_string_to_url(trim($val));
$items[$key]['label'] = trim($val);
if ($this->GetBlockProperty('translate_labels')) {
$items[$key]['label'] = $AdvancedContent->lang($items[$key]['label']);
}
$items[$key]['value'] = $items[$key]['label'];
$items[$key]['selected'] = in_array($items[$key]['label'], $selItems);
}
}
if ($this->GetBlockProperty('values') != '') {
foreach (explode($this->GetBlockProperty('delimiter'), $this->GetBlockProperty('values')) as $key => $val) {
$items[$key]['value'] = trim($val);
if ($this->GetBlockProperty('translate_values')) {
$items[$key]['value'] = $AdvancedContent->lang($items[$key]['value']);
}
$items[$key]['selected'] = in_array($items[$key]['value'], $selItems);
if (!isset($items[$key]['label'])) {
$items[$key]['label'] = $items[$key]['value'];
}
}
}
return $items;
}
开发者ID:aldrymaulana,项目名称:cmsdepdagri,代码行数:32,代码来源:class.acBlockType_select_multiple.php
示例2: get_generator
/**
* Given a dataref object, find and instantiate a LinkDefinitionGenerator
* that can generate links for this type of dataref
*
* @param DataRef $dataref
* @return LinkDefinitionGenerator
*/
public function get_generator(DataRef $dataref)
{
if (strtolower($dataref->key1) == 'page' && (int) $dataref->key2 > 0) {
$dataref->key3 = $dataref->key2;
$dataref->key2 = 'Page';
$dataref->key1 = 'Core';
}
if (in_array($dataref->key1, array('Core', 'core', 'CORE', 'CMSMS'))) {
$obj = new CoreLinkDefinitionGenerator();
$obj->set_dataref($dataref);
return $obj;
}
// assume key1 is a module name
$mod = \cms_utils::get_module($dataref->key1);
if (is_object($mod)) {
$str = $dataref->key1 . '\\LinkDefinitionGenerator';
if (class_exists($str)) {
$obj = new $str();
$obj->set_dataref($dataref);
return $obj;
}
$str = $dataref->key1 . '_LinkDefinitionGenerator';
if (class_exists($str)) {
$obj = new $str();
$obj->set_dataref($dataref);
return $obj;
}
}
throw new \RuntimeException('Could not find an appropriate link generator for data definitions of type ' . $dataref->key1);
}
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:37,代码来源:class.LinkDefinitionGeneratorFactory.php
示例3: GetBlockTypeProperties
public function GetBlockTypeProperties($access = 'backend')
{
if ($access == 'backend') {
$AdvancedContent =& cms_utils::get_module('AdvancedContent');
$multi_input_ids = $this->content_obj->CleanArray(explode(',', $this->GetBlockProperty('inputs')));
$multiInput_props = $this->content_obj->GetBlockTypeProperties('multi_input');
foreach ($multi_input_ids as $k1 => $multi_input_id) {
if (!isset($multiInput_props[$multi_input_id])) {
$multiInput_props = array_merge($multiInput_props, $AdvancedContent->GetMultiInputFull($multi_input_ids));
if (!isset($multiInput_props[$multi_input_id])) {
continue;
}
$multiInput_props[$multi_input_id]['template'] = $AdvancedContent->GetTemplate($multiInput_props[$multi_input_id]['tpl_name']);
$matches = array();
$result = preg_match_all(AC_BLOCK_PATTERN, $multiInput_props[$multi_input_id]['input_fields'], $matches);
if ($result && count($matches[1]) > 0) {
foreach ($matches[1] as $k2 => $wholetag) {
if (!($inputBlock = $this->content_obj->CreateContentBlock($wholetag))) {
continue;
}
if ($inputBlock->GetBlockProperty('type') == 'multi_input') {
continue;
# ToDo: display message?
}
$multiInput_props[$multi_input_id]['elements'][$k2] = $inputBlock;
}
}
}
}
return $multiInput_props;
}
}
开发者ID:aldrymaulana,项目名称:cmsdepdagri,代码行数:32,代码来源:class.acBlockType_multi_input.php
示例4: ExportExaCSS
private static function ExportExaCSS($mod)
{
$db = cmsms()->GetDb();
$ExaCSS = cms_utils::get_module('ExaCSS');
if ($ExaCSS == false) {
return;
}
// Création du sous-dossier
$subdir = "ExaCSS";
te_base::CreateSubDir($mod, $subdir);
// Récupération du répertoire d'exportation
$cache_path = te_base::GetCachePath($mod);
// Récupération de l'extension du fichier
$stylesheet_extension = $mod->GetPreference('stylesheet_extension');
// Récupération de la liste des feuilles de styles
$stylesheets = ExaCSSstylesheet::Get();
$stylesheets = $stylesheets['list'];
// Exportation de chaque feuille de style dans des fichiers séparés
foreach ($stylesheets as $stylesheet) {
$fname = cms_join_path($cache_path, $subdir, te_base::escapeFilename("style_" . $stylesheet['name']) . '.' . $stylesheet_extension);
$fp = fopen($fname, 'w');
// Conversion du CRLF vers le LF pour la compatibilité Unix
fwrite($fp, te_base::escapeContent($stylesheet['content']));
fclose($fp);
// Rendre chaque fichier disponible en écriture
chmod($fname, 0666);
// Modifier la date du fichier avec la date de modification du CSS
touch($fname, $db->UnixTimeStamp($stylesheet['date_modification']));
}
// Récupération de la liste des feuilles de variables
$variables = ExaCSSvariable::Get();
$variables = $variables['list'];
// Exportation de chaque feuille de variables dans des fichiers séparés
foreach ($variables as $variable) {
$fname = cms_join_path($cache_path, $subdir, te_base::escapeFilename("variable_" . $variable['name']) . '.' . $stylesheet_extension);
$fp = fopen($fname, 'w');
// Conversion du CRLF vers le LF pour la compatibilité Unix
fwrite($fp, te_base::escapeContent($variable['content']));
fclose($fp);
// Rendre chaque fichier disponible en écriture
chmod($fname, 0666);
// Modifier la date du fichier avec la date de modification du CSS
touch($fname, $db->UnixTimeStamp($variable['date_modification']));
}
// Récupération de la liste des feuilles de mixins
$mixins = ExaCSSmixin::Get();
$mixins = $mixins['list'];
// Exportation de chaque feuille de mixins dans des fichiers séparés
foreach ($mixins as $mixin) {
$fname = cms_join_path($cache_path, $subdir, te_base::escapeFilename("mixin_" . $mixin['name']) . '.' . $stylesheet_extension);
$fp = fopen($fname, 'w');
// Conversion du CRLF vers le LF pour la compatibilité Unix
fwrite($fp, te_base::escapeContent($mixin['content']));
fclose($fp);
// Rendre chaque fichier disponible en écriture
chmod($fname, 0666);
// Modifier la date du fichier avec la date de modification du CSS
touch($fname, $db->UnixTimeStamp($mixin['date_modification']));
}
}
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:60,代码来源:class.te_export.php
示例5: __construct
/**
* Takes an exception message of the form [module]%%key[%%suffix]
* and format a language string
*
* @param string $str The exception message
* @param int $code The exception code
* @param \Exception $parent a parent exception
*/
public function __construct($str = '', $code = 0, \Exception $parent = null)
{
if (strpos($str, '%%')) {
$parts = explode('%%', $str, 3);
if (count($parts) > 1) {
$module = trim($parts[0]);
$key = trim($parts[1]);
if (!$module) {
$module = cge_tmpdata::get('module');
if (!$module) {
$smarty = cmsms()->GetSmarty();
$obj = $smarty->get_template_vars('mod');
if (is_object($obj)) {
$module = $obj->GetName();
}
}
}
if ($module && $key) {
$mod = \cms_utils::get_module($module);
if ($mod) {
$str = $mod->Lang($key);
}
if (isset($parts[2]) && $parts[2]) {
$str .= ' ' . $parts[2];
}
}
}
}
parent::__construct($str, $code, $parent);
}
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:38,代码来源:class.cg_exception.php
示例6: on_success
public function on_success($time = '')
{
if (!$time) {
$time = time();
}
$mod = cms_utils::get_module('CGSmartImage');
$mod->SetPreference('clearcache_lastrun', $time);
}
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:8,代码来源:class.CGSmartImage_ClearCacheTask.php
示例7: GetModuleInstance
function GetModuleInstance()
{
$mod = cms_utils::get_module($this->ModuleName());
if ($mod) {
return $mod;
}
return 'ModuleName() not defined properly';
}
开发者ID:RTR-ITF,项目名称:usse-cms,代码行数:8,代码来源:class.CMSModuleContentType.php
示例8: get_categories
public static function get_categories($id, $params, $returnid = -1)
{
$db = cmsms()->GetDb();
$depth = 1;
$query = '
SELECT news_category_id, news_category_name, hierarchy, long_name
FROM ' . cms_db_prefix() . 'module_news_categories
WHERE hierarchy not like \'\'
';
if (isset($params['category']) && $params['category'] != '') {
$categories = explode(',', $params['category']);
$query .= ' AND (';
$count = 0;
foreach ($categories as $onecat) {
if ($count > 0) {
$query .= ' OR ';
}
if (strpos($onecat, '|') !== FALSE || strpos($onecat, '*') !== FALSE) {
$query .= "upper(long_name) like upper('" . trim(str_replace('*', '%', $onecat)) . "')";
} else {
$query .= "news_category_name = '" . trim($onecat) . "'";
}
$count++;
}
$query .= ') ';
}
$query .= ' ORDER by hierarchy';
$dbresult = $db->Execute($query);
$rowcounter = 0;
while ($dbresult && ($row = $dbresult->FetchRow())) {
$q2 = "SELECT COUNT(news_id) as cnt FROM " . cms_db_prefix() . "module_news WHERE news_category_id=?";
if (isset($params['showarchive']) && $params['showarchive'] == true) {
$q2 .= " AND (end_time < " . $db->DBTimeStamp(time()) . ") ";
} else {
$q2 .= " AND ((" . $db->IfNull('end_time', $db->DBTimeStamp(1)) . " = " . $db->DBTimeStamp(1) . ") OR (end_time > " . $db->DBTimeStamp(time()) . ")) ";
}
$q2 .= ' AND status = \'published\'';
$dbres2 = $db->Execute($q2, array($row['news_category_id']));
$count = $dbres2->FetchRow();
$row['index'] = $rowcounter++;
$row['count'] = $count['cnt'];
$row['prevdepth'] = $depth;
$depth = count(explode('.', $row['hierarchy']));
$row['depth'] = $depth;
// changes so that parameters supplied to the tag
// gets carried down through the links
// screw pretty urls
$parms = $params;
unset($parms['browsecat']);
unset($parms['category']);
$parms['category_id'] = $row['news_category_id'];
$pageid = isset($params['detailpage']) && $params['detailpage'] != '' ? $params['detailpage'] : $returnid;
$mod = cms_utils::get_module('News');
$row['url'] = $mod->CreateLink($id, 'default', $pageid, $row['news_category_name'], $parms, '', true);
$items[] = $row;
}
return $items;
}
开发者ID:aldrymaulana,项目名称:cmsdepdagri,代码行数:58,代码来源:class.news_ops.php
示例9: __construct
public function __construct($module_name)
{
$this->_module_name = trim($module_name);
$this->_mod = \cms_utils::get_module($module_name);
if (!$this->_mod) {
throw new \RuntimeException(cgex_lang('err_modulenotfound', $module_name));
}
$dir = $this->_mod->GetModulePath();
$this->_cdat = $dir . '/_c1.dat';
$this->_ddat = $dir . '/_d1.dat';
}
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:11,代码来源:class.ModuleIntegrityValidator.php
示例10: _cgcalDeleteField
function _cgcalDeleteField($field_oldname)
{
$db = cmsms()->GetDb();
$mod = cms_utils::get_module('CGCalendar');
$fields_table_name = $mod->fields_table_name;
$event_field_values_table_name = $mod->event_field_values_table_name;
$sql = "DELETE FROM \${$event_field_values_table_name} where field_name='{$field_oldname}'";
$db->Execute($sql);
$sql = "DELETE FROM {$fields_table_name} where field_name='{$field_oldname}'";
$db->Execute($sql);
}
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:11,代码来源:action.admin_fields_update.php
示例11: _get_canonical
private function _get_canonical()
{
if (!isset($this->_meta['canonical'])) {
$tmp = $this->news_url;
if ($tmp == '') {
$aliased_title = munge_string_to_url($this->title);
$tmp = 'news/' . $this->id . '/' . $this->returnid . "/{$aliased_title}";
}
$mod = cms_utils::get_module('News');
$canonical = $mod->create_url($this->_inid, 'detail', $this->returnid, $this->params, false, false, $tmp);
$this->_meta['canonical'] = $canonical;
}
return $this->_meta['canonical'];
}
开发者ID:RTR-ITF,项目名称:usse-cms,代码行数:14,代码来源:class.news_article.php
示例12: GetBlockInput
public function GetBlockInput()
{
$AdvancedContent =& cms_utils::get_module('AdvancedContent');
if ($this->GetBlockProperty('module') == '') {
return $AdvancedContent->lang('error_insufficient_blockparams', 'module', $this->GetBlockProperty('name'));
}
if (!($module =& $AdvancedContent->GetModuleInstance($this->GetBlockProperty('module')))) {
return $AdvancedContent->lang('error_loading_module', $this->GetBlockProperty('module'), $this->GetBlockProperty('name'));
}
if (!$module->HasCapability('contentblocks')) {
return $AdvancedContent->lang('error_contentblock_support', $this->GetBlockProperty('module'), $this->GetBlockProperty('name'));
}
return $module->GetContentBlockInput($this->GetBlockProperty('id'), $this->content_obj->GetPropertyValue($this->GetBlockProperty('id')), $this->GetBlockProperty('params'), $this->GetBlockProperty('adding'));
}
开发者ID:aldrymaulana,项目名称:cmsdepdagri,代码行数:14,代码来源:class.acBlockType_module.php
示例13: load
public static function load($libname)
{
$mod = cms_utils::get_module(MOD_CGEXTENSIONS);
if ($libname == 'cg_cmsms') {
// gotta return code.
$config = cms_config::get_instance();
$tpl = $mod->CreateSmartyTemplate('jquery.cg_cmsms.tpl');
$tpl->assign('mod', $mod);
$tpl->assign('config', $config);
$code = $tpl->fetch();
$obj = new StdClass();
$obj->code = $code;
return $obj;
}
}
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:15,代码来源:class.cge_jshandler.php
示例14: get_tasks
/**
* Private method to find available tasks. This method will look in the lib/tasks directory
* for tack files, and also ask modules for tasks that they support. Modules exporting tasks
* should create and return a task object.
*
* @return void
*/
private static function get_tasks()
{
if (!is_object(self::$_tasks)) {
self::$_tasks = new ArrayObject();
}
// 1. Get task objects from files.
$gCms = cmsms();
$dir = $gCms->config['root_path'] . '/lib/tasks';
$tmp = new DirectoryIterator($dir);
$iterator = new RegexIterator($tmp, '/class\\..+task\\.php$/');
foreach ($iterator as $match) {
$tmp = explode('.', basename($match->current()));
if (is_array($tmp) && count($tmp) == 4) {
$classname = $tmp[1] . 'Task';
require_once $dir . '/' . $match->current();
$obj = new $classname();
if ($obj instanceof CmsRegularTask) {
self::$_tasks->append($obj);
}
}
}
// 2. Get task objects from modules.
$opts = $gCms->GetModuleOperations();
$modules = $opts->get_modules_with_capability('tasks');
if (!$modules) {
return;
}
foreach ($modules as $one) {
if (!is_object($one)) {
$one = cms_utils::get_module($one);
}
if (!method_exists($one, 'get_tasks')) {
continue;
}
$tasks = $one->get_tasks();
if ($tasks) {
if (!is_array($tasks)) {
$tmp = array($tasks);
$tasks = $tmp;
}
foreach ($tasks as $onetask) {
if (is_object($onetask) && $onetask instanceof CmsRegularTask) {
self::$_tasks->append($onetask);
}
}
}
}
}
开发者ID:RTR-ITF,项目名称:usse-cms,代码行数:55,代码来源:class.CmsRegularTaskHandler.php
示例15: cgsi_getimages
public static function cgsi_getimages($params, $content, &$smarty, $repeat)
{
if (!$content) {
return;
}
$mod = cms_utils::get_module('CGSmartImage');
$old_errorval = libxml_use_internal_errors(true);
$dom = new CGDomDocument();
$dom->strictErrorChecking = FALSE;
$dom->validateOnParse = FALSE;
if (function_exists('mb_convert_encoding')) {
$content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8');
}
$dom->loadHTML($content);
$imgs = $dom->GetElementsByTagName('img');
if (is_object($imgs) && $imgs->length) {
$out = array();
for ($i = 0; $i < $imgs->length; $i++) {
$node = $imgs->item($i);
$sxe = simplexml_import_dom($node);
$rec = array();
$rec['tag'] = $sxe->asXML();
foreach ($sxe->attributes() as $name => $value) {
$value = (string) $value;
if ($value == '') {
continue;
}
$rec[$name] = $value;
}
$out[] = $rec;
}
if (isset($params['assign'])) {
$smarty->assign($params['assign'], $out);
}
}
$imagesonly = cms_to_bool(get_parameter_value($params, 'imagesonly'));
$nocontent = cms_to_bool(get_parameter_value($params, 'nocontent'));
if (!$nocontent) {
if ($imagesonly) {
$content = '';
foreach ($out as $rec) {
$content .= $rec['tag'];
}
}
return $content;
}
}
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:47,代码来源:class.cgsi_extended.php
示例16: __construct
public function __construct($input)
{
$mod = cms_utils::get_module('CGSmartImage');
$this->_loc = $mod->GetPreference('croptofit_default_loc', 'c');
if (cge_array::is_hash($input)) {
if (isset($input['width'])) {
$this->_dest_w = (int) $input['width'];
$this->_dest_h = (int) $input['height'];
} else {
if (isset($input['w'])) {
$this->_dest_w = (int) $input['w'];
$this->_dest_h = (int) $input['h'];
}
}
if (isset($input['color']) && $input['color'] != '') {
$this->_color = strtolower($input['color']);
}
if (isset($input['alpha'])) {
$this->_alpha = (int) $input['alpha'];
}
} else {
if (is_array($input)) {
if (count($input) >= 2) {
$this->_dest_w = (int) trim($input[0]);
$this->_dest_h = (int) trim($input[1]);
if (count($input) >= 3) {
if ($input[2] != '') {
$this->_color = strtolower($input[2]);
}
if (count($input) >= 4) {
if ($input[3] != '') {
$this->_alpha = (int) $input[3];
}
}
}
}
}
}
$this->_dest_w = cgsi_utils::trim_to_device('width', $this->_dest_w);
$this->_dest_h = cgsi_utils::trim_to_device('height', $this->_dest_h);
$this->_alpha = max(0, min(127, $this->_alpha));
// todo: convert color name into rgb.
if ($this->_dest_h <= 0 || $this->_dest_w <= 0) {
throw new Exception('Invalid values specified for Croptofit filter constructor');
}
}
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:46,代码来源:class.CGImage_Resizetofit_Filter.php
示例17: smarty_function_anchor
function smarty_function_anchor($params, &$template)
{
$smarty = $template->smarty;
$gCms = cmsms();
$content = cms_utils::get_current_content();
if (!is_object($content)) {
return;
}
// Added by Russ for class, tabindex and title for anchor 2006/07/19
$class = "";
$title = "";
$tabindex = "";
$accesskey = "";
if (isset($params['class'])) {
$class = ' class="' . $params['class'] . '"';
}
if (isset($params['title'])) {
$title = ' title="' . $params['title'] . '"';
}
if (isset($params['tabindex'])) {
$tabindex = ' tabindex="' . $params['tabindex'] . '"';
}
if (isset($params['accesskey'])) {
$accesskey = ' accesskey="' . $params['accesskey'] . '"';
}
// End of first part added by Russ 2006/07/19
$url = $content->GetURL() . '#' . trim($params['anchor']);
$url = str_replace('&', '***', $url);
$url = str_replace('&', '&', $url);
$url = str_replace('***', '&', $url);
if (isset($params['onlyhref']) && ($params['onlyhref'] == '1' || $params['onlyhref'] == 'true')) {
// Note if you set 'onlyheref' that is what you get - no class or title or tabindex or text
$tmp = $url;
} else {
// Line replaced by Russ
// echo '<a href="'.$url.'">'.$params['text'].'</a>';
// Line replaced with - by Russ to reflect class and title for anchor 2006/07/19
$tmp = '<a href="' . $url . '"' . $class . $title . $tabindex . $accesskey . '>' . $params['text'] . '</a>';
// End of second part added by Russ 2006/07/19
}
if (isset($params['assign'])) {
$smarty->assign(trim($params['assign']), $tmp);
return;
}
echo $tmp;
}
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:46,代码来源:function.anchor.php
示例18: process_template
/**
* Process the specififed template through smarty.
* This method will attempt to find the current action module, and given that and the name of the template find the template contents.
* if the template name ends with .tpl a module file template is assumed. Otherwise, a module database template will be assumed.
* If a module cannot be determined, then a file template is assumed, using the 'file' smarty resource.
*
* @param string $tpl The name of the template to process.
*/
protected function process_template($tpl)
{
$smarty = cmsms()->GetSmarty();
$actionmodule = $smarty->get_template_vars('actionmodule');
if ($actionmodule) {
$mod = \cms_utils::get_module($actionmodule);
if (is_object($mod)) {
if (endswith($tpl, '.tpl')) {
$out = $mod->ProcessTemplate($tpl);
} else {
$out = $mod->ProcessTemplateFromDatabase($tpl);
}
}
} else {
$out = $smarty->fetch('file:' . $tpl);
}
return $out;
}
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:26,代码来源:class.formatted_report_generator.php
示例19: send_recovery_email
/**
* A function to send lost password recovery email to a specified admin user (by name)
*
* @internal
* @access private
* @param string the username
* @return results from the attempt to send a message.
*/
function send_recovery_email($username)
{
$gCms = cmsms();
$config = $gCms->GetConfig();
$userops = $gCms->GetUserOperations();
$user = $userops->LoadUserByUsername($username);
$obj = cms_utils::get_module('CMSMailer');
if ($obj == null) {
return false;
}
$obj->AddAddress($user->email, html_entity_decode($user->firstname . ' ' . $user->lastname));
$obj->SetSubject(lang('lostpwemailsubject', html_entity_decode(get_site_preference('sitename', 'CMSMS Site'))));
$url = $config['admin_url'] . '/login.php?recoverme=' . md5(md5($config['root_path'] . '--' . $user->username . md5($user->password)));
$body = lang('lostpwemail', html_entity_decode(get_site_preference('sitename', 'CMSMS Site')), $user->username, $url);
$obj->SetBody($body);
audit('', 'Core', 'Sent Lost Password Email for ' . $username);
return $obj->Send();
}
开发者ID:Alexkuva,项目名称:Beaupotager,代码行数:26,代码来源:login.php
示例20: execute
public function execute($target = '', $data = array(), $age = '')
{
$mod = cms_utils::get_module('ModuleManager');
if (!$age) {
$age = get_site_preference('browser_cache_expiry', 60);
}
if ($age) {
$age = max(1, (int) $age);
}
// build a signature
$this->_signature = md5(serialize(array($target, $data)));
$fn = $this->_getCacheFile();
if (!$fn) {
return;
}
// check for the cached file
$atime = time() - $age * 60;
$status = '';
$resutl = '';
if ($mod->GetPreference('disable_caching', 0) || !file_exists($fn) || filemtime($fn) <= $atime) {
// execute the request
$req = new cms_http_request();
if ($this->_timeout) {
$req->setTimeout($this->_timeout);
}
$req->execute($target, '', 'POST', $data);
$this->_status = $req->getStatus();
$this->_result = $req->getResult();
@unlink($fn);
if ($this->_status == 200) {
// create a cache file
$fh = fopen($fn, 'w');
fwrite($fh, serialize(array($this->_status, $this->_result)));
fclose($fh);
}
} else {
// get data from the cache.
$data = unserialize(file_get_contents($fn));
$this->_status = $data[0];
$this->_result = $data[1];
}
}
开发者ID:RTR-ITF,项目名称:usse-cms,代码行数:42,代码来源:class.modmgr_cached_request.php
注:本文中的cms_utils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论