当前位置: 首页>>代码示例>>PHP>>正文


PHP CampTemplate::singleton方法代码示例

本文整理汇总了PHP中CampTemplate::singleton方法的典型用法代码示例。如果您正苦于以下问题:PHP CampTemplate::singleton方法的具体用法?PHP CampTemplate::singleton怎么用?PHP CampTemplate::singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CampTemplate的用法示例。


在下文中一共展示了CampTemplate::singleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smarty_function_render

/**
 * Campsite render function plugin
 *
 * Type:     function
 * Name:     render
 * Purpose:  template rendering
 *
 * @param array
 *     $p_params
 * @param object
 *     $p_smarty The Smarty object
 *
 * @return
 *     rendered content
 */
function smarty_function_render($p_params, &$p_smarty)
{
    if (empty($p_params['file'])) {
        return null;
    }
    $smarty = CampTemplate::singleton();
    $cache_lifetimeBak = $smarty->cache_lifetime;
    $campsiteVectorBak = $smarty->campsiteVector;
    if (SystemPref::Get('TemplateCacheHandler')) {
        $campsiteVector = $smarty->campsiteVector;
        foreach ($campsiteVector as $key => $value) {
            if (isset($p_params[$key])) {
                if (empty($p_params[$key]) || strtolower($p_params[$key]) == 'off') {
                    $campsiteVector[$key] = null;
                }
                if (is_int($p_params[$key])) {
                    $campsiteVector[$key] = $p_params[$key];
                }
            }
        }
        if (isset($p_params['params'])) {
            $campsiteVector['params'] = $p_params['params'];
        }
        $smarty->campsiteVector = $campsiteVector;
        if (empty($p_params['cache'])) {
            $template = new Template(CampSite::GetURIInstance()->getThemePath() . $p_params['file']);
            $smarty->cache_lifetime = (int) $template->getCacheLifetime();
        } else {
            $smarty->cache_lifetime = (int) $p_params['cache'];
        }
    }
    $smarty->display($p_params['file']);
    $smarty->cache_lifetime = $cache_lifetimeBak;
    $smarty->campsiteVector = $campsiteVectorBak;
}
开发者ID:nidzix,项目名称:Newscoop,代码行数:50,代码来源:function.render.php

示例2: __construct

 public function __construct(ThemesService $themesService)
 {
     $this->smarty = \CampTemplate::singleton();
     $this->smarty->assign('gimme', $this->smarty->context());
     $this->themesService = $themesService;
     $this->preconfigureSmarty();
 }
开发者ID:alvsgithub,项目名称:Newscoop,代码行数:7,代码来源:TemplatesService.php

示例3: smarty_block_search_form

/**
 * Campsite search_form block plugin
 *
 * Type:     block
 * Name:     search_form
 * Purpose:  Provides a...
 *
 * @param string $p_params
 *
 * @param string $p_content
 *
 * @param string $p_smarty
 *
 *
 * @return string $html
 */
function smarty_block_search_form($p_params, $p_content, &$p_smarty)
{
    if (!isset($p_content)) {
        return '';
    }

    require_once $p_smarty->_get_plugin_filepath('shared','escape_special_chars');

    // gets the context variable
    $campsite = $p_smarty->get_template_vars('gimme');

    $url = $campsite->url;
    $url->uri_parameter = "";
    $template = null;
    if (isset($p_params['template'])) {
        $template = new MetaTemplate($p_params['template']);
        if (!$template->defined()) {
            CampTemplate::singleton()->trigger_error('invalid template "' . $p_params['template']
            . '" specified in the search form');
            return false;
        }
    } elseif (is_numeric($url->get_parameter('tpl'))) {
        $template = $campsite->default_template;
    }
    if (!isset($p_params['submit_button'])) {
        $p_params['submit_button'] = 'Submit';
    }
    if (!isset($p_params['html_code']) || empty($p_params['html_code'])) {
        $p_params['html_code'] = '';
    }
    if (!isset($p_params['button_html_code']) || empty($p_params['button_html_code'])) {
        $p_params['button_html_code'] = '';
    }

    $searchListIdPrefix = $campsite->list_id_prefix('SearchResultsList');
    if (isset($template)) {
        $url->uri_parameter = "template " . str_replace(' ', "\\ ", $template->name);
    }
    $html = "<form name=\"search_articles\" action=\"" . $url->uri_path . "\" method=\"post\" "
    .$p_params['html_code'].">\n";
    if (isset($template)) {
        $html .= "<input type=\"hidden\" name=\"tpl\" value=\"" . $template->identifier . "\" />\n";
    }
    foreach ($campsite->url->form_parameters as $param) {
        if (strncasecmp($param[name], $searchListIdPrefix, strlen($searchListIdPrefix)) == 0) {
            continue;
        }
        if ($param['name'] == 'tpl') {
            continue;
        }
        $html .= '<input type="hidden" name="'.$param['name']
        .'" value="'.htmlentities($param['value'])."\" />\n";
    }
    $html .= $p_content;
    $html .= "<input type=\"submit\" name=\"f_search_articles\" value=\""
    .smarty_function_escape_special_chars($p_params['submit_button'])
    ."\" ".$p_params['button_html_code']." />\n</form>\n";

    return $html;
} // fn smarty_block_search_form
开发者ID:nistormihai,项目名称:Newscoop,代码行数:76,代码来源:block.search_form.php

示例4: smarty_function_set_topic

/**
 * Campsite set_topic function plugin
 *
 * Type:     function
 * Name:     set_topic
 * Purpose:
 *
 * @param array
 *     $p_params[name] The Name of the topic to be set
 *     $p_params[identifier] The Identifier of the topic to be set
 * @param object
 *     $p_smarty The Smarty object
 */
function smarty_function_set_topic($p_params, &$p_smarty)
{
    // gets the context variable
    $campsite = $p_smarty->getTemplateVars('gimme');
    if (isset($p_params['identifier'])) {
        $attrName = 'identifier';
        $attrValue = $p_params['identifier'];
        $topicId = intval($p_params['identifier']);
    } elseif (isset($p_params['name'])) {
        $attrName = 'name';
        $attrValue = $p_params['name'];
        $topicService = \Zend_Registry::get('container')->getService('newscoop_newscoop.topic_service');
        $topic = $topicService->getTopicByFullName($p_params['name']);
        if (!is_null($topic) && $topic) {
            $topicId = $topic->getId();
        } else {
            $campsite->topic->trigger_invalid_value_error($attrName, $attrValue, $p_smarty);
            return false;
        }
    } else {
        $property = array_shift(array_keys($p_params));
        CampTemplate::singleton()->trigger_error("invalid parameter '{$property}' in set_topic");
        return false;
    }
    if ($campsite->topic->defined && $campsite->topic->identifier == $topicId) {
        return;
    }
    $topicObj = new MetaTopic($topicId);
    if ($topicObj->defined) {
        $campsite->topic = $topicObj;
    } else {
        $campsite->topic->trigger_invalid_value_error($attrName, $attrValue, $p_smarty);
    }
}
开发者ID:alvsgithub,项目名称:Newscoop,代码行数:47,代码来源:function.set_topic.php

示例5: convertParameters

 protected function convertParameters($firstResult, $parameters)
 {
     $this->criteria->orderBy = array();
     // run default simple parameters converting
     parent::convertParameters($firstResult, $parameters);
     // apply attributes as a filters
     if (array_key_exists('attributes', $parameters)) {
         $this->criteria->attributes = $this->parseConstraintsString($parameters['attributes']);
     }
     // convert your special parameters into criteria properties.
     if (array_key_exists('search', $parameters)) {
         $this->criteria->query = $parameters['search'];
     } elseif (array_key_exists('filter', $parameters)) {
         $filter = $parameters['filter'];
         $this->criteria->groups = !empty($parameters['editor_groups']) ? array_map('intval', explode(',', $parameters['editor_groups'])) : array();
         switch ($filter) {
             case 'active':
                 $this->criteria->orderBy = array('points' => 'desc');
                 $this->criteria->excludeGroups = true;
                 break;
             case 'editors':
                 $this->criteria->excludeGroups = false;
                 break;
             default:
                 $this->criteria->groups = array();
                 // example: filter="a-c"
                 if (preg_match('/([a-z])-([a-z])/', $filter, $matches)) {
                     $this->criteria->nameRange = range($matches[1], $matches[2]);
                 } else {
                     \CampTemplate::singleton()->trigger_error("invalid parameter {$filter} in filter");
                 }
                 break;
         }
     }
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:35,代码来源:UsersList.php

示例6: ProcessParameters

 /**
  * Processes the input parameters passed in an array; drops the invalid
  * parameters and parameters with invalid values. Returns an array of
  * valid parameters.
  *
  * @param array $p_parameters
  * @return array
  */
 protected function ProcessParameters(array $p_parameters)
 {
     $parameters = array();
     foreach ($p_parameters as $parameter => $value) {
         $parameter = strtolower($parameter);
         switch ($parameter) {
             case 'length':
             case 'columns':
             case 'name':
                 if ($parameter == 'length' || $parameter == 'columns') {
                     $intValue = (int) $value;
                     if ("{$intValue}" != $value || $intValue < 0) {
                         CampTemplate::singleton()->trigger_error("invalid value {$value} of parameter {$parameter} in statement list_article_locations");
                     }
                     $parameters[$parameter] = (int) $value;
                 } else {
                     $parameters[$parameter] = $value;
                 }
                 break;
             default:
                 CampTemplate::singleton()->trigger_error("invalid parameter {$parameter} in list_article_locations", $p_smarty);
         }
     }
     $operator = new Operator('is', 'integer');
     $context = CampTemplate::singleton()->context();
     if (!$context->article->defined) {
         CampTemplate::singleton()->trigger_error("undefined environment attribute 'Article' in statement list_article_locations");
         return array();
     }
     $this->m_constraints[] = new ComparisonOperation('article', $operator, $context->article->number);
     return $parameters;
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:40,代码来源:ArticleLocationsList.php

示例7: smarty_function_set_publication

/**
 * Campsite set_publication function plugin
 *
 * Type:     function
 * Name:     set_publication
 * Purpose:
 *
 * @param array
 *     $p_params[name] The Name of the publication to be set
 *     $p_params[identifier] The Identifier of the publication to be set
 * @param object
 *     $p_smarty The Smarty object
 */
function smarty_function_set_publication($p_params, &$p_smarty)
{
    // gets the context variable
    $campsite = $p_smarty->getTemplateVars('gimme');
    if (isset($p_params['identifier'])) {
        $attrName = 'identifier';
        $attrValue = $p_params['identifier'];
        $publicationId = intval($p_params['identifier']);
    } elseif (isset($p_params['name'])) {
        $attrName = 'name';
        $attrValue = $p_params['name'];
        $publications = Publication::GetPublications($p_params['name']);
        if (!empty($publications)) {
            $publicationId = $publications[0]->getPublicationId();
        } else {
            $campsite->publication->trigger_invalid_value_error($attrName, $attrValue, $p_smarty);
            return false;
        }
    } else {
        $property = array_shift(array_keys($p_params));
        CampTemplate::singleton()->trigger_error("invalid parameter '{$property}' in set_publication");
        return false;
    }
    if ($campsite->publication->defined && $campsite->publication->identifier == $publicationId) {
        return;
    }
    $publicationObj = new MetaPublication($publicationId);
    if ($publicationObj->defined) {
        $campsite->publication = $publicationObj;
    } else {
        $campsite->publication->trigger_invalid_value_error($attrName, $attrValue, $p_smarty);
    }
}
开发者ID:nidzix,项目名称:Newscoop,代码行数:46,代码来源:function.set_publication.php

示例8: __construct

 public function __construct($publicationId, $userId)
 {
     $this->subscriptions = $this->getSubscriptions(\CampTemplate::singleton()->context()->publication->identifier, \CampTemplate::singleton()->context()->user->identifier);
     if (count($this->subscriptions) == 0) {
         $this->subscriptions = array();
     }
 }
开发者ID:riverans,项目名称:plugin-NewscoopPaywallBundle,代码行数:7,代码来源:MetaSubscriptions.php

示例9: getRightOperand

 /**
  * Returns the right operand
  *
  * @return mix
  */
 public function getRightOperand()
 {
     // some values have to be computed
     switch (strtolower($this->m_rightOperand)) {
         case 'now()':
             $this->m_rightOperand = strftime('%Y-%m-%d %H:%M:%S');
             break;
         case 'curdate()':
             $this->m_rightOperand = strftime('%Y-%m-%d');
             break;
         case 'curtime()':
             $this->m_rightOperand = strftime('%H:%M:%S');
             break;
         case 'current()':
             // this value indicates that the left operand have to compared with the value from current context
             // e.g. language_number is current()
             $Context = CampTemplate::singleton()->context();
             $object = strtolower($this->m_leftOperand);
             switch ($object) {
                 case 'language':
                 case 'publication':
                 case 'issue':
                 case 'section':
                 case 'article':
                     $this->m_rightOperand = $Context->{$object}->number;
                     break;
                 case 'publication':
                     $this->m_rightOperand = $Context->{$object}->identifier;
                     break;
             }
             break;
     }
     return $this->m_rightOperand;
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:39,代码来源:ComparisonOperation.php

示例10: smarty_function_set_language

/**
 * Campsite set_language function plugin
 *
 * Type:     function
 * Name:     set_language
 * Purpose:
 *
 * @param array
 *     $p_params The English name of the language to be set
 * @param object
 *     $p_smarty The Smarty object
 */
function smarty_function_set_language($p_params, &$p_smarty)
{
    // gets the context variable
    $campsite = $p_smarty->get_template_vars('gimme');

    if (isset($p_params['name'])) {
    	$languageName = $p_params['name'];
    } else {
    	$property = array_shift(array_keys($p_params));
        CampTemplate::singleton()->trigger_error("invalid parameter '$property' in set_language");
    	return false;
    }

    if ($campsite->language->defined
            && $campsite->language->english_name == $languageName) {
        return;
    }

    $languages = Language::GetLanguages(null, null, $languageName);
    if (empty($languages)) {
    	$campsite->language->trigger_invalid_value_error('name', $languageName, $p_smarty);
    	return false;
    }
    $campsite->language = new MetaLanguage($languages[0]->getLanguageId());
} // fn smarty_function_set_language
开发者ID:nistormihai,项目名称:Newscoop,代码行数:37,代码来源:function.set_language.php

示例11: smarty_function_set_issue

/**
 * Campsite set_issue function plugin
 *
 * Type:     function
 * Name:     set_issue
 * Purpose:
 *
 * @param array
 *     $p_params The number of the issue to be set
 * @param object
 *     $p_smarty The Smarty object
 */
function smarty_function_set_issue($p_params, &$p_smarty)
{
    // gets the context variable
    $campsite = $p_smarty->get_template_vars('gimme');

    if (isset($p_params['number'])) {
    	$issueNumber = intval($p_params['number']);
    } else {
    	$property = array_shift(array_keys($p_params));
        CampTemplate::singleton()->trigger_error("invalid parameter '$property' in set_issue");
    	return false;
    }

    if ($campsite->issue->defined
            && $campsite->issue->number == $issueNumber) {
        return;
    }

    $issueObj = new MetaIssue($campsite->publication->identifier,
                              $campsite->language->number, $issueNumber);
    if ($issueObj->defined) {
        $campsite->issue = $issueObj;
    } else {
    	$campsite->issue->trigger_invalid_value_error('number', $p_params['number'], $p_smarty);
    }
} // fn smarty_function_set_issue
开发者ID:nistormihai,项目名称:Newscoop,代码行数:38,代码来源:function.set_issue.php

示例12: smarty_function_set_section

/**
 * Campsite set_section function plugin
 *
 * Type:     function
 * Name:     set_section
 * Purpose:
 *
 * @param array
 *     $p_params[name] The Name of the section to be set
 *     $p_params[number] The Number of the section to be set
 * @param object
 *     $p_smarty The Smarty object
 */
function smarty_function_set_section($p_params, &$p_smarty)
{
    // gets the context variable
    $campsite = $p_smarty->getTemplateVars('gimme');
    if (isset($p_params['number'])) {
        $attrName = 'number';
        $attrValue = $p_params['number'];
        $sectionNumber = intval($p_params['number']);
    } elseif (isset($p_params['name'])) {
        $sections = Section::GetSections($campsite->publication->identifier, $campsite->issue->number, $campsite->language->number, null, $p_params['name']);
        if (isset($sections[0])) {
            $attrName = 'name';
            $attrValue = $p_params['name'];
            $sectionNumber = intval($sections[0]->getSectionNumber());
        } else {
            $campsite->section->trigger_invalid_value_error($attrName, $attrValue, $p_smarty);
            return false;
        }
    } else {
        $property = array_shift(array_keys($p_params));
        CampTemplate::singleton()->trigger_error("invalid parameter '{$property}' in set_section");
        return false;
    }
    if ($campsite->section->defined && $campsite->section->number == $sectionNumber) {
        return;
    }
    $sectionObj = new MetaSection($campsite->publication->identifier, $campsite->issue->number, $campsite->language->number, $sectionNumber);
    if ($sectionObj->defined) {
        $campsite->section = $sectionObj;
    }
}
开发者ID:sourcefabric,项目名称:newscoop,代码行数:44,代码来源:function.set_section.php

示例13: indexAction

 public function indexAction()
 {
     if ($this->_getParam('language')) {
         $gimme = CampTemplate::singleton()->context();
         $gimme->language = MetaLanguage::createFromCode($this->_getParam('language'));
     }
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:7,代码来源:SearchController.php

示例14: smarty_block_user_form

/**
 * Campsite user_form block plugin
 *
 * Type:     block
 * Name:     user_form
 * Purpose:  Provides a...
 *
 * @param string
 *     $p_params
 * @param string
 *     $p_smarty
 * @param string
 *     $p_content
 *
 * @return
 *
 */
function smarty_block_user_form($p_params, $p_content, &$p_smarty, &$p_repeat)
{
    $p_smarty->smarty->loadPlugin('smarty_function_get_resource_id');
    $resourceId = smarty_function_get_resource_id($p_params, $p_smarty);
    if (!isset($p_content)) {
        return null;
    }
    $p_smarty->smarty->loadPlugin('smarty_shared_escape_special_chars');
    $campsite = $p_smarty->getTemplateVars('gimme');
    $url = $campsite->url;
    $url->uri_parameter = "";
    $template = null;
    if (isset($p_params['template'])) {
        $template = new MetaTemplate($resourceId);
        if (!$template->defined()) {
            CampTemplate::singleton()->trigger_error('invalid template "' . $p_params['template'] . '" specified in the user form');
            return false;
        }
    } elseif (is_numeric($url->get_parameter('tpl'))) {
        $template = $campsite->default_template;
    }
    if (!isset($p_params['submit_button'])) {
        require_once $GLOBALS['g_campsiteDir'] . '/admin-files/localizer/Localizer.php';
        if (!isGS('Submit')) {
            camp_load_translation_strings("globals", $campsite->language->code);
        }
        $p_params['submit_button'] = getGS('Submit');
    }
    if (!isset($p_params['html_code']) || empty($p_params['html_code'])) {
        $p_params['html_code'] = '';
    }
    if (!isset($p_params['button_html_code']) || empty($p_params['button_html_code'])) {
        $p_params['button_html_code'] = '';
    }
    if (isset($template)) {
        $url->uri_parameter = "template " . str_replace(' ', "\\ ", $template->name);
    }
    if ($campsite->user->defined && $campsite->user->subscription->defined) {
        $subsType = $campsite->user->subscription->type == 'T' ? 'trial' : 'paid';
    } else {
        $subsType = null;
    }
    $html = "<form name=\"edit_user\" action=\"" . $url->uri_path . "\" method=\"post\" " . $p_params['html_code'] . ">\n";
    if (!is_null($subsType)) {
        $html .= "<input type=\"hidden\" name=\"f_substype\" value=\"" . $subsType . "\" />\n";
    }
    if (isset($template)) {
        $html .= "<input type=\"hidden\" name=\"tpl\" value=\"" . $template->identifier . "\" />\n";
    }
    foreach ($campsite->url->form_parameters as $param) {
        if ($param['name'] == 'tpl') {
            continue;
        }
        $html .= '<input type="hidden" name="' . $param['name'] . '" value="' . htmlentities($param['value']) . "\" />\n";
    }
    $html .= $p_content;
    $html .= "<input type=\"submit\" name=\"f_edit_user\" value=\"" . smarty_function_escape_special_chars($p_params['submit_button']) . "\" " . $p_params['button_html_code'] . " />\n</form>\n";
    return $html;
}
开发者ID:nidzix,项目名称:Newscoop,代码行数:76,代码来源:block.user_form.php

示例15: getWeekDayName

 public function getWeekDayName()
 {
     $language = new Language(CampTemplate::singleton()->context()->language->number);
     if (!$language->exists()) {
         return null;
     }
     return $language->getProperty('WDay' . (int) $this->getWeekDay());
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:8,代码来源:MetaDate.php


注:本文中的CampTemplate::singleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。