本文整理汇总了PHP中cms_utils类的典型用法代码示例。如果您正苦于以下问题:PHP cms_utils类的具体用法?PHP cms_utils怎么用?PHP cms_utils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了cms_utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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;
}
}
示例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']));
}
}
示例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);
}
示例6: on_success
public function on_success($time = '')
{
if (!$time) {
$time = time();
}
$mod = cms_utils::get_module('CGSmartImage');
$mod->SetPreference('clearcache_lastrun', $time);
}
示例7: GetModuleInstance
function GetModuleInstance()
{
$mod = cms_utils::get_module($this->ModuleName());
if ($mod) {
return $mod;
}
return 'ModuleName() not defined properly';
}
示例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;
}
示例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';
}
示例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);
}
示例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'];
}
示例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'));
}
示例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;
}
}
示例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);
}
}
}
}
}
示例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;
}
}