當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Komento::verifyContext方法代碼示例

本文整理匯總了PHP中Komento::verifyContext方法的典型用法代碼示例。如果您正苦於以下問題:PHP Komento::verifyContext方法的具體用法?PHP Komento::verifyContext怎麽用?PHP Komento::verifyContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Komento的用法示例。


在下文中一共展示了Komento::verifyContext方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: commentify

 /**
  * This is the heart of Komento that does magic
  *
  * @param	$component	string
  * @param	$article	object
  * @param	$options	array
  * @return null
  */
 public static function commentify($component, &$article, $options = array())
 {
     $eventTrigger = null;
     $context = null;
     $params = array();
     $page = 0;
     if (array_key_exists('trigger', $options)) {
         $eventTrigger = $options['trigger'];
     }
     if (array_key_exists('context', $options)) {
         $context = $options['context'];
     }
     if (array_key_exists('params', $options)) {
         $params = $options['params'];
     }
     if (array_key_exists('page', $options)) {
         $page = $options['page'];
     }
     // TODO: Allow string/int: see line 662
     // Sometimes people pass in $article as an array, we convert it to object
     if (is_array($article)) {
         $article = (object) $article;
     }
     // Check if there is a valid component
     if (empty($component)) {
         return false;
     }
     // @task: prepare data and checking on plugin level
     $application = Komento::loadApplication($component);
     // We verify context and trigger first before going into onBeforeLoad because onBeforeLoad already expects the article to be what Komento want to integrate
     // @task: verify if context is correct
     if (!Komento::verifyContext($context, $application->getContext())) {
         return false;
     }
     // @task: verify if event trigger is correct
     if (!Komento::verifyEventTrigger($eventTrigger, $application->getEventTrigger())) {
         return false;
     }
     // @trigger: onBeforeLoad
     // we do this checking before load because in some cases,
     // article is not an object and the article id might be missing.
     if (!$application->onBeforeLoad($eventTrigger, $context, $article, $params, $page, $options)) {
         return false;
     }
     // @task: set the component
     self::setCurrentComponent($component);
     // @task: get all the configuration
     $config = self::getConfig($component);
     $konfig = Komento::getKonfig();
     // @task: check if enabled
     if (!$config->get('enable_komento')) {
         return false;
     }
     // @task: disable Komento in tmpl=component mode such as print mode
     if ($config->get('disable_komento_on_tmpl_component') && JRequest::getString('tmpl', '') === 'component') {
         return false;
     }
     // We accept $article as an int
     // For $article as a string, onBeforeLoad should already prepare the $article object properly
     if (is_string($article) || is_int($article)) {
         $cid = $article;
     } else {
         // @task: set cid based on application mapping keys because some component might have custom keys (not necessarily always $article-id)
         $cid = $article->{$application->_map['id']};
     }
     // Don't proceed if $cid is empty
     if (empty($cid)) {
         return false;
     }
     // @task: process in-content parameters
     self::processParameter($article, $options);
     // terminate if it's disabled
     if ($options['disable']) {
         if (!$application->onParameterDisabled($eventTrigger, $context, $article, $params, $page, $options)) {
             return false;
         }
     }
     // @task: loading article infomation with defined get methods
     if (!$application->load($cid)) {
         return false;
     }
     // If enabled flag exists, bypass category check
     if (array_key_exists('enable', $options) && !$options['enable']) {
         // @task: category access check
         $categories = $config->get('allowed_categories');
         // no categories mode
         switch ($config->get('allowed_categories_mode')) {
             // selected categories
             case 1:
                 if (empty($categories)) {
                     return false;
                 } else {
//.........這裏部分代碼省略.........
開發者ID:BetterBetterBetter,項目名稱:B3App,代碼行數:101,代碼來源:helper.php


注:本文中的Komento::verifyContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。