本文整理汇总了PHP中Komento::_方法的典型用法代码示例。如果您正苦于以下问题:PHP Komento::_方法的具体用法?PHP Komento::_怎么用?PHP Komento::_使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Komento
的用法示例。
在下文中一共展示了Komento::_方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doSave
private function doSave()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$mainframe = JFactory::getApplication();
if (!JRequest::getMethod() == 'POST') {
$mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_STORE_INVALID_REQUEST', 'error'));
return false;
}
// Unset unecessary post data.
$post = JRequest::get('POST');
unset($post['task']);
unset($post['option']);
unset($post['c']);
$token = Komento::_('getToken');
unset($post[$token]);
// check the target component
if (!$post['target_component']) {
$mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_MISSING_TARGET_COMPONENT'));
return false;
}
// rememeber user's choice
// $mainframe->setUserState('com_komento.acl.component', $post['target_component']);
// Save post data
$model = Komento::getModel('Acl', true);
if (!$model->save($post)) {
$mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_STORE_ERROR', 'error'));
return false;
}
$mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_STORE_SUCCESS', 'message'));
// Clear the component's cache
$cache = JFactory::getCache('com_komento');
$cache->clean();
return true;
}
示例2: __construct
public function __construct()
{
$konfig = Komento::getKonfig();
$config = Komento::getConfig();
// @legacy: If environment is set to production, change to static.
$environment = $konfig->get('komento_environment');
if ($environment=='production') {
$environment='static';
}
$this->fullName = 'Komento';
$this->shortName = 'kmt';
$this->environment = $environment;
$this->mode = $konfig->get('komento_mode');
$this->version = (string) Komento::getHelper( 'Version' )->getLocalVersion();
$this->baseUrl = Komento::getHelper( 'Document' )->getBaseUrl();
$this->token = Komento::_( 'getToken' );
$newConfig = clone $config->toObject();
$newKonfig = clone $konfig->toObject();
unset( $newConfig->antispam_recaptcha_private_key );
unset( $newConfig->antispam_recaptcha_public_key );
unset( $newConfig->antispam_akismet_key );
unset( $newConfig->layout_phpbb_path );
unset( $newConfig->layout_phpbb_url );
unset( $newKonfig->layout_phpbb_path );
unset( $newKonfig->layout_phpbb_url );
$this->options = array(
"responsive" => (bool) $config->get('enable_responsive'),
"jversion" => Komento::joomlaVersion(),
"spinner" => JURI::root() . 'media/com_komento/images/loader.gif',
"view" => JRequest::getString( 'view', '' ),
"guest" => Komento::getProfile()->guest ? 1 : 0,
"config" => $newConfig,
"konfig" => $newKonfig,
"acl" => Komento::getACL(),
"element" => new stdClass()
);
parent::__construct();
}
示例3: 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 {
//.........这里部分代码省略.........
示例4: display
public function display($cacheable = false, $urlparams = false)
{
JFactory::getApplication()->enqueueMessage('You are using Komento free version. <a href="http://stackideas.com/komento/plans.html" target="_blank">Upgrade to Komento Pro</a> to enjoy our priority support and more. <a href="http://stackideas.com/komento/plans.html" target="_blank" style="padding: 5px 10px; background-color: #C02828; color: #FFFFFF;">Upgrade now!</a>', 'notice');
// free version text (for reference only)
// JFactory::getApplication()->enqueueMessage( 'You are using Komento free version. <a href="http://stackideas.com/komento/plans.html" target="_blank">Upgrade to Komento Pro</a> to enjoy our priority support and more. <a href="http://stackideas.com/komento/plans.html" target="_blank" style="padding: 5px 10px; background-color: #C02828; color: #FFFFFF;">Upgrade now!</a>', 'notice' );
$document = JFactory::getDocument();
// Set the layout
$viewType = $document->getType();
$viewName = JRequest::getCmd('view', $this->getName());
$viewLayout = JRequest::getCmd('layout', 'default');
$view = $this->getView($viewName, $viewType, '');
$view->setLayout($viewLayout);
$format = JRequest::getCmd('format', 'html');
// Test if the call is for Ajax
if (!empty($format) && $format == 'ajax') {
// Ajax calls.
if (!JRequest::checkToken('GET')) {
$ejax = new Ejax();
$ejax->script('alert("' . JText::_('Not allowed here') . '");');
$ejax->send();
}
// Process Ajax call
$data = JRequest::get('POST');
$arguments = array();
foreach ($data as $key => $value) {
if (JString::substr($key, 0, 5) == 'value') {
if (is_array($value)) {
$arrVal = array();
foreach ($value as $val) {
$item =& $val;
$item = stripslashes($item);
$item = rawurldecode($item);
$arrVal[] = $item;
}
$arguments[] = $arrVal;
} else {
$val = stripslashes($value);
$val = rawurldecode($val);
$arguments[] = $val;
}
}
}
// if(!method_exists( $view , $viewLayout ) )
// {
// $ejax = new Ejax();
// $ejax->script( 'alert("' . JText::sprintf( 'Method %1$s does not exists in this context' , $viewLayout ) . '");');
// $ejax->send();
// return;
// }
// Execute method
call_user_func_array(array($view, $viewLayout), $arguments);
} else {
// Non ajax calls.
if ($viewLayout != 'default') {
if ($cacheable) {
$cache = JFactory::getCache('com_komento', 'view');
$cache->get($view, $viewLayout);
} else {
if (!method_exists($view, $viewLayout)) {
$view->display();
} else {
// @todo: Display error about unknown layout.
$view->{$viewLayout}();
}
}
} else {
$view->display();
}
// Add necessary buttons to the site.
if (method_exists($view, 'registerToolbar')) {
$view->registerToolbar();
}
// Override submenu if needed
if (method_exists($view, 'registerSubmenu') && $view->registerSubmenu() != '') {
$this->loadSubmenu($view->getName(), $view->registerSubmenu());
}
// @task: Append hidden token into the page.
echo '<span id="komento-token" style="display:none;"><input type="hidden" name="' . Komento::_('getToken') . '" value="1" /></span>';
}
}
示例5: push
/**
* Push the email notification to MailQ
* @param string $type type of notification
* @param string $recipient recipient (subscribers,admins,author,me)
* @param array $options various options
*
* @return nothing
*/
public function push( $type, $recipients, $options = array() )
{
if( !empty( $options['commentId'] ) )
{
$comment = Komento::getComment( $options['commentId'] );
$options['comment'] = $comment;
$options['component'] = $comment->component;
$options['cid'] = $comment->cid;
$options['comment'] = Komento::getHelper( 'comment' )->process( $options['comment'] );
unset( $options['commentId'] );
}
if( !isset( $options['component'] ) || !isset( $options['cid'] ) )
{
return;
}
if( $type == 'new' && $options['comment']->parent_id )
{
$type = 'reply';
}
$recipients = explode(',', $recipients);
$rows = array();
$skipMe = true;
// process requested recipients first
foreach ($recipients as $recipient)
{
$recipient = 'get' . ucfirst( strtolower( trim($recipient) ) );
if( !method_exists($this, $recipient) )
{
continue;
}
if( $recipient == 'getMe' )
{
$skipMe = false;
}
$result = $this->$recipient( $type, $options );
// stacking up all the emails and details
$rows = $rows + $result;
}
// process usergroups notification based on notification type
$rows = $rows + $this->getUsergroups( $type );
if( $type == 'report' )
{
$admins = $this->getAdmins();
foreach( $admins as $admin )
{
if( isset($rows[$options['comment']->email]) && $options['comment']->email === $admin->email )
{
$skipMe = false;
}
}
}
if( empty($rows) )
{
return;
}
// Do not send to the commentor/actor
if( $skipMe && isset($rows[$options['comment']->email]) )
{
unset( $rows[$options['comment']->email] );
}
$lang = JFactory::getLanguage();
// Load English first as fallback
$konfig = Komento::getKonfig();
if( $konfig->get( 'enable_language_fallback' ) )
{
$lang->load( 'com_komento', JPATH_ROOT, 'en-GB', true );
}
// Load site's selected language
$lang->load( 'com_komento', JPATH_ROOT, $lang->getDefault(), true );
// Load user's preferred language file
$lang->load( 'com_komento', JPATH_ROOT, null, true );
//.........这里部分代码省略.........
示例6: defined
* @license GNU/GPL, see LICENSE.php
*
* Komento is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Restricted access'); ?>
<?php Komento::trigger( 'onBeforeKomentoBar', array( 'component' => $component, 'cid' => $cid, 'commentCount', &$commentCount ) ); ?>
<?php $readmore = false;
if( $component == 'com_content' )
{
if( $system->config->get( 'layout_frontpage_readmore_use_joomla' ) == 0 && ( ( $system->config->get( 'layout_frontpage_readmore' ) == 2 ) || ( $system->config->get( 'layout_frontpage_readmore' ) == 1 && Komento::_('JParameter::get', $article->params, 'show_readmore') && $article->readmore ) ) )
{
$readmore = true;
}
}
else
{
if( $system->config->get( 'layout_frontpage_readmore' ) != 0 )
{
$readmore = true;
}
}
if( $readmore || $system->config->get( 'layout_frontpage_comment') || $system->config->get( 'layout_frontpage_hits') ) { ?>
<div class="kmt-readon">
<?php if( $readmore ) { ?>
<span class="kmt-readmore aligned-<?php echo $system->config->get( 'layout_frontpage_alignment' ); ?>">
示例7: doSave
private function doSave()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$result = array();
$mainframe = JFactory::getApplication();
if (!JRequest::getMethod() == 'POST') {
// $mainframe->enqueueMessage( JText::_('COM_KOMENTO_SETTINGS_STORE_INVALID_REQUEST' ), 'error' );
$result['message'] = JText::_('COM_KOMENTO_SETTINGS_STORE_INVALID_REQUEST');
$result['type'] = 'error';
return $result;
}
// Unset unecessary post data.
$post = JRequest::get('POST');
unset($post['active']);
unset($post['activechild']);
unset($post['task']);
unset($post['option']);
unset($post['c']);
$token = Komento::_('getToken');
unset($post[$token]);
// check the target component
if (!$post['component']) {
// $mainframe->enqueueMessage( JText::_('COM_KOMENTO_SETTINGS_MISSING_TARGET_COMPONENT'), 'error' );
$result['message'] = JText::_('COM_KOMENTO_SETTINGS_MISSING_TARGET_COMPONENT');
$result['type'] = 'error';
return $result;
}
// custom field that requires processing before save should all goes here
if (array_key_exists('email_regex', $post)) {
$post['email_regex'] = array(urlencode($post['email_regex']));
}
if (array_key_exists('website_regex', $post)) {
$post['website_regex'] = array(urlencode($post['website_regex']));
}
if (array_key_exists('smileycode', $post)) {
foreach ($post['smileycode'] as $index => $smileycode) {
if (empty($smileycode)) {
unset($post['smileycode'][$index]);
}
}
}
if (array_key_exists('smileypath', $post)) {
foreach ($post['smileypath'] as $index => $smileypath) {
if (empty($smileypath)) {
unset($post['smileypath'][$index]);
}
}
}
// Overwrite the value by using getVar to preserve the html tag
$post['tnc'] = JRequest::getVar('tnc', '', 'post', 'string', JREQUEST_ALLOWRAW);
// Fix multiple select
$multiples = array('allowed_categories', 'requires_moderation', 'show_tnc', 'notification_to_usergroup_comment', 'notification_to_usergroup_reply', 'notification_to_usergroup_pending', 'notification_to_usergroup_reported', 'notification_es_to_usergroup_comment', 'notification_es_to_usergroup_reply', 'notification_es_to_usergroup_like', 'smileypath', 'smileycode');
foreach ($multiples as $multiple) {
if (!array_key_exists($multiple, $post)) {
$post[$multiple] = array();
}
}
// Save post data
$model = Komento::getModel('system', true);
if (!$model->save($post)) {
$result['message'] = JText::_('COM_KOMENTO_SETTINGS_STORE_ERROR');
$result['type'] = 'error';
return $result;
}
// Post save actions
$result['message'] = JText::_('COM_KOMENTO_SETTINGS_STORE_SUCCESS');
$result['type'] = 'message';
// Clear the component's cache
$cache = JFactory::getCache();
$cache->clean();
return $result;
}
示例8: debug
/**
* START OF STRING RETURN FUNCTIONS
*/
public function debug()
{
$prefix = Komento::_("JFactory::getConfig", "dbprefix");
$query = $this->buildSql();
return str_ireplace( '#__' , $prefix , $query );
}