本文整理汇总了PHP中Komento::verifyEventTrigger方法的典型用法代码示例。如果您正苦于以下问题:PHP Komento::verifyEventTrigger方法的具体用法?PHP Komento::verifyEventTrigger怎么用?PHP Komento::verifyEventTrigger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Komento
的用法示例。
在下文中一共展示了Komento::verifyEventTrigger方法的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 {
//.........这里部分代码省略.........