本文整理汇总了PHP中K2HelperUtilities::getParams方法的典型用法代码示例。如果您正苦于以下问题:PHP K2HelperUtilities::getParams方法的具体用法?PHP K2HelperUtilities::getParams怎么用?PHP K2HelperUtilities::getParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类K2HelperUtilities
的用法示例。
在下文中一共展示了K2HelperUtilities::getParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: report
function report($tpl = null)
{
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$row =& JTable::getInstance('K2Comment', 'Table');
$row->load(JRequest::getInt('commentID'));
if (!$row->published) {
JError::raiseError(404, JText::_('K2_NOT_FOUND'));
}
$this->assignRef('row', $row);
$user = JFactory::getUser();
$this->assignRef('user', $user);
$params =& K2HelperUtilities::getParams('com_k2');
if (!$params->get('comments') || !$params->get('commentsReporting') || $params->get('commentsReporting') == '2' && $user->guest) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
$this->assignRef('params', $params);
if ($params->get('recaptcha') && $user->guest) {
$document = JFactory::getDocument();
$document->addScript('http://api.recaptcha.net/js/recaptcha_ajax.js');
$js = '
function showRecaptcha(){
Recaptcha.create("' . $params->get('recaptcha_public_key') . '", "recaptcha", {
theme: "' . $params->get('recaptcha_theme', 'clean') . '"
});
}
$K2(window).load(function() {
showRecaptcha();
});
';
$document->addScriptDeclaration($js);
}
parent::display($tpl);
}
示例2: getAvatar
function getAvatar($userID, $email = NULL, $width = 50)
{
jimport('joomla.filesystem.folder');
jimport('joomla.application.component.model');
$mainframe =& JFactory::getApplication();
$params =& K2HelperUtilities::getParams('com_k2');
if (K2_CB && $userID != 'alias') {
$cbUser = CBuser::getInstance((int) $userID);
if (is_object($cbUser)) {
$avatar = $cbUser->getField('avatar', null, 'csv', 'none', 'profile');
return $avatar;
}
}
/*
// JomSocial Avatar integration
if(JFolder::exists(JPATH_SITE.DS.'components'.DS.'com_community') && $userID>0){
$userInfo = &CFactory::getUser($userID);
return $userInfo->getThumbAvatar();
}
*/
// Check for placeholder overrides
if (JFile::exists(JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'images' . DS . 'placeholder' . DS . 'user.png')) {
$avatarPath = 'templates/' . $mainframe->getTemplate() . '/images/placeholder/user.png';
} else {
$avatarPath = 'components/com_k2/images/placeholder/user.png';
}
// Continue with default K2 avatar determination
if ($userID == 'alias') {
$avatar = JURI::root(true) . '/' . $avatarPath;
} else {
if ($userID == 0) {
if ($params->get('gravatar') && !is_null($email)) {
$avatar = 'http://www.gravatar.com/avatar/' . md5($email) . '?s=' . $width . '&default=' . urlencode(JURI::root() . $avatarPath);
} else {
$avatar = JURI::root(true) . '/' . $avatarPath;
}
} else {
if (is_numeric($userID) && $userID > 0) {
JModel::addIncludePath(JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models');
$model =& JModel::getInstance('Item', 'K2Model');
$profile = $model->getUserProfile($userID);
$avatar = is_null($profile) ? '' : $profile->image;
if (empty($avatar)) {
if ($params->get('gravatar') && !is_null($email)) {
$avatar = 'http://www.gravatar.com/avatar/' . md5($email) . '?s=' . $width . '&default=' . urlencode(JURI::root() . $avatarPath);
} else {
$avatar = JURI::root(true) . '/' . $avatarPath;
}
} else {
$avatar = JURI::root(true) . '/media/k2/users/' . $avatar;
}
}
}
}
if (!$params->get('userImageDefault') && $avatar == JURI::root(true) . '/' . $avatarPath) {
$avatar = '';
}
return $avatar;
}
示例3: loadjQuery
public static function loadjQuery($ui = false, $mediaManager = false)
{
JLoader::register('K2HelperUtilities', JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'helpers' . DS . 'utilities.php');
$application = JFactory::getApplication();
$document = JFactory::getDocument();
$params = K2HelperUtilities::getParams('com_k2');
if ($document->getType() == 'html') {
if (K2_JVERSION == '15') {
JHtml::_('behavior.mootools');
} else {
if (K2_JVERSION == '25') {
JHtml::_('behavior.framework');
} else {
JHtml::_('behavior.framework');
if ($application->isAdmin() || $application->isSite() && $params->get('jQueryHandling')) {
JHtml::_('jquery.framework');
}
}
}
$handling = $application->isAdmin() ? $params->get('backendJQueryHandling', 'remote') : $params->get('jQueryHandling', '1.8remote');
// jQuery
if (K2_JVERSION != '30') {
if ($handling == 'remote') {
$document->addScript('//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js');
} else {
if ($handling == 'local') {
$document->addScript(JURI::root(true) . '/media/k2/assets/js/jquery-1.8.3.min.js');
} else {
if ($handling && JString::strpos($handling, 'remote') !== false) {
if ($handling == '1.9remote') {
$handling = '1remote';
}
$document->addScript('//ajax.googleapis.com/ajax/libs/jquery/' . str_replace('remote', '', $handling) . '/jquery.min.js');
} else {
if ($handling && JString::strpos($handling, 'remote') === false) {
$document->addScript(JURI::root(true) . '/media/k2/assets/js/jquery-' . $handling . '.min.js');
}
}
}
}
}
// jQuery UI
if ($application->isAdmin() || $ui) {
// No conflict loaded when $ui requested or in the backend.
// No need to reload for $mediaManager as the latter is always called with $ui
$document->addScript(JURI::root(true) . '/media/k2/assets/js/k2.noconflict.js');
if ($handling == 'local') {
$document->addScript(JURI::root(true) . '/media/k2/assets/js/jquery-ui-1.8.24.custom.min.js');
} else {
$document->addScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js');
}
}
if ($mediaManager) {
$document->addScript(JURI::root(true) . '/media/k2/assets/js/elfinder.min.js?v=2.6.7');
}
}
}
示例4: getUserRoute
public static function getUserRoute($userID)
{
if (K2_CB) {
global $_CB_framework;
return $_CB_framework->userProfileUrl((int) $userID);
}
$key = (int) $userID;
if (isset(self::$cache['user'][$key])) {
return self::$cache['user'][$key];
}
$needles = array('user' => (int) $userID);
$user = JFactory::getUser($userID);
if (K2_JVERSION != '15' && JFactory::getConfig()->get('unicodeslugs') == 1) {
$alias = JApplication::stringURLSafe($user->name);
} else {
if (JPluginHelper::isEnabled('system', 'unicodeslug') || JPluginHelper::isEnabled('system', 'jw_unicodeSlugsExtended')) {
$alias = JFilterOutput::stringURLSafe($user->name);
} else {
mb_internal_encoding("UTF-8");
mb_regex_encoding("UTF-8");
$alias = trim(mb_strtolower($user->name));
$alias = str_replace('-', ' ', $alias);
$alias = mb_ereg_replace('[[:space:]]+', ' ', $alias);
$alias = trim(str_replace(' ', '', $alias));
$alias = str_replace('.', '', $alias);
$stripthese = ',|~|!|@|%|^|(|)|<|>|:|;|{|}|[|]|&|`|„|‹|’|‘|“|â€�|•|›|«|´|»|°|«|»|…';
$strips = explode('|', $stripthese);
foreach ($strips as $strip) {
$alias = str_replace($strip, '', $alias);
}
$params = K2HelperUtilities::getParams('com_k2');
$SEFReplacements = array();
$items = explode(',', $params->get('SEFReplacements', NULL));
foreach ($items as $item) {
if (!empty($item)) {
@(list($src, $dst) = explode('|', trim($item)));
$SEFReplacements[trim($src)] = trim($dst);
}
}
foreach ($SEFReplacements as $key => $value) {
$alias = str_replace($key, $value, $alias);
}
$alias = trim($alias, '-.');
if (trim(str_replace('-', '', $alias)) == '') {
$datenow = JFactory::getDate();
$alias = K2_JVERSION == '15' ? $datenow->toFormat("%Y-%m-%d-%H-%M-%S") : $datenow->format("Y-m-d-H-i-s");
}
}
}
$link = 'index.php?option=com_k2&view=itemlist&task=user&id=' . $userID . ':' . $alias;
if ($item = K2HelperRoute::_findItem($needles)) {
$link .= '&Itemid=' . $item->id;
}
self::$cache['user'][$key] = $link;
return $link;
}
示例5: sendReport
function sendReport()
{
JRequest::checkToken() or jexit('Invalid Token');
$params = K2HelperUtilities::getParams('com_k2');
$user = JFactory::getUser();
if (!$params->get('comments') || !$params->get('commentsReporting') || ($params->get('commentsReporting') == '2' && $user->guest))
{
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
K2Model::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models');
$model = K2Model::getInstance('Comments', 'K2Model');
$model->setState('id', JRequest::getInt('id'));
$model->setState('name', JRequest::getString('name'));
$model->setState('reportReason', JRequest::getString('reportReason'));
if (!$model->report())
{
echo $model->getError();
}
else
{
echo JText::_('K2_REPORT_SUBMITTED');
}
$mainframe = JFactory::getApplication();
$mainframe->close();
}
示例6: display
function display($tpl = null)
{
$mainframe =& JFactory::getApplication();
$params =& K2HelperUtilities::getParams('com_k2');
$model =& $this->getModel('itemlist');
$limitstart = JRequest::getInt('limitstart');
$view = JRequest::getWord('view');
$task = JRequest::getWord('task');
//Add link
if (K2HelperPermissions::canAddItem()) {
$addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');
}
$this->assignRef('addLink', $addLink);
//Get data depending on task
switch ($task) {
case 'category':
//Get category
$id = JRequest::getInt('id');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$category =& JTable::getInstance('K2Category', 'Table');
$category->load($id);
// State Check
if (!$category->published || $category->trash) {
JError::raiseError(404, JText::_('K2_CATEGORY_NOT_FOUND'));
}
//Access check
$user =& JFactory::getUser();
if (K2_JVERSION == '16') {
if (!in_array($category->access, $user->authorisedLevels())) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
$languageFilter = $mainframe->getLanguageFilter();
$languageTag = JFactory::getLanguage()->getTag();
if ($languageFilter && $category->language != $languageTag && $category->language != '*') {
return;
}
} else {
if ($category->access > $user->get('aid', 0)) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
}
// Hide the add new item link if user cannot post in the specific category
if (!K2HelperPermissions::canAddItem($id)) {
unset($this->addLink);
}
//Merge params
$cparams = new JParameter($category->params);
if ($cparams->get('inheritFrom')) {
$masterCategory =& JTable::getInstance('K2Category', 'Table');
$masterCategory->load($cparams->get('inheritFrom'));
$cparams = new JParameter($masterCategory->params);
}
$params->merge($cparams);
//Category link
$category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))));
//Category image
$category->image = K2HelperUtilities::getCategoryImage($category->image, $params);
//Category plugins
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$category->text = $category->description;
if (K2_JVERSION == '16') {
$dispatcher->trigger('onContentPrepare', array('com_k2.category', &$category, &$params, $limitstart));
} else {
$dispatcher->trigger('onPrepareContent', array(&$category, &$params, $limitstart));
}
$category->description = $category->text;
//Category K2 plugins
$category->event->K2CategoryDisplay = '';
JPluginHelper::importPlugin('k2');
$results = $dispatcher->trigger('onK2CategoryDisplay', array(&$category, &$params, $limitstart));
$category->event->K2CategoryDisplay = trim(implode("\n", $results));
$category->text = $category->description;
$dispatcher->trigger('onK2PrepareContent', array(&$category, &$params, $limitstart));
$category->description = $category->text;
$this->assignRef('category', $category);
$this->assignRef('user', $user);
//Category children
$ordering = $params->get('subCatOrdering');
$children = $model->getCategoryFirstChildren($id, $ordering);
if (count($children)) {
foreach ($children as $child) {
if ($params->get('subCatTitleItemCounter')) {
$child->numOfItems = $model->countCategoryItems($child->id);
}
$child->image = K2HelperUtilities::getCategoryImage($child->image, $params);
$child->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($child->id . ':' . urlencode($child->alias))));
$subCategories[] = $child;
}
$this->assignRef('subCategories', $subCategories);
}
//Set limit
$limit = $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items') + $params->get('num_links');
//Set featured flag
JRequest::setVar('featured', $params->get('catFeaturedItems'));
//Set layout
$this->setLayout('category');
//Set title
$title = $category->name;
// Set ordering
//.........这里部分代码省略.........
示例7: display
function display($tpl = null)
{
$mainframe =& JFactory::getApplication();
$user =& JFactory::getUser();
$document =& JFactory::getDocument();
$params =& K2HelperUtilities::getParams('com_k2');
$limitstart = JRequest::getInt('limitstart', 0);
$view = JRequest::getWord('view');
$task = JRequest::getWord('task');
$db =& JFactory::getDBO();
$jnow =& JFactory::getDate();
$now = $jnow->toMySQL();
$nullDate = $db->getNullDate();
$this->setLayout('item');
// Add link
if (K2HelperPermissions::canAddItem()) {
$addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');
}
$this->assignRef('addLink', $addLink);
// Get item
$model =& $this->getModel();
$item = $model->getData();
// Does the item exists?
if (!is_object($item) || !$item->id) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
// Prepare item
$item = $model->prepareItem($item, $view, $task);
// Plugins
$item = $model->execPlugins($item, $view, $task);
// User K2 plugins
$item->event->K2UserDisplay = '';
if (isset($item->author) && is_object($item->author->profile) && isset($item->author->profile->id)) {
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('k2');
$results = $dispatcher->trigger('onK2UserDisplay', array(&$item->author->profile, &$params, $limitstart));
$item->event->K2UserDisplay = trim(implode("\n", $results));
}
// Access check
if ($this->getLayout() == 'form') {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
if (K2_JVERSION == '16') {
if (!in_array($item->access, $user->authorisedLevels()) || !in_array($item->category->access, $user->authorisedLevels())) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
} else {
if ($item->access > $user->get('aid', 0) || $item->category->access > $user->get('aid', 0)) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
}
// Published check
if (!$item->published || $item->trash) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
if ($item->publish_up != $nullDate && $item->publish_up > $now) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
if ($item->publish_down != $nullDate && $item->publish_down < $now) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
if (!$item->category->published || $item->category->trash) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
// Increase hits counter
$model->hit($item->id);
// Set default image
K2HelperUtilities::setDefaultImage($item, $view);
// Comments
$item->event->K2CommentsCounter = '';
$item->event->K2CommentsBlock = '';
if ($item->params->get('itemComments')) {
// Trigger comments events
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('k2');
$results = $dispatcher->trigger('onK2CommentsCounter', array(&$item, &$params, $limitstart));
$item->event->K2CommentsCounter = trim(implode("\n", $results));
$results = $dispatcher->trigger('onK2CommentsBlock', array(&$item, &$params, $limitstart));
$item->event->K2CommentsBlock = trim(implode("\n", $results));
// Load K2 native comments system only if there are no plugins overriding it
if (empty($item->event->K2CommentsCounter) && empty($item->event->K2CommentsBlock)) {
// Load reCAPTCHA script
if (!JRequest::getInt('print') && ($item->params->get('comments') == '1' || $item->params->get('comments') == '2' && K2HelperPermissions::canAddComment($item->catid))) {
if ($item->params->get('recaptcha') && $user->guest) {
$document->addScript('http://api.recaptcha.net/js/recaptcha_ajax.js');
$js = '
function showRecaptcha(){
Recaptcha.create("' . $item->params->get('recaptcha_public_key') . '", "recaptcha", {
theme: "' . $item->params->get('recaptcha_theme', 'clean') . '"
});
}
$K2(window).load(function() {
showRecaptcha();
});
';
$document->addScriptDeclaration($js);
}
}
// Check for inline comment moderation
if (!$user->guest && $user->id == $item->created_by && $params->get('inlineCommentsModeration')) {
//.........这里部分代码省略.........
示例8: onBeforeRender
/**
* This method is to load neccessary access
* for PageBuilder need
*
* @return void
*/
public function onBeforeRender()
{
// Check if JoomlaShine extension framework is enabled?
$framework = JTable::getInstance('Extension');
$framework->load(array('element' => 'jsnframework', 'type' => 'plugin', 'folder' => 'system'));
// Do nothing if JSN Extension framework not found.
if (!$framework->extension_id) {
return;
}
$app = JFactory::getApplication();
$tpl = $app->input->getInt('tp', 0);
if ($app->isAdmin() || $tpl) {
return;
}
// Get requested component, view and task
$option = $app->input->getCmd('option', '');
$view = $app->input->getCmd('view', '');
$layout = $app->input->getCmd('layout', '');
$user = JFactory::getUser();
if ($app->isSite() && $option == 'com_content' && $view == 'form' && $layout == 'edit' && $user->get('id') > 0) {
return;
}
$doc = JFactory::getDocument();
if (get_class($doc) != "JDocumentHTML") {
return;
}
if ($app->isSite() && $option == 'com_k2' && $view == 'item' && $app->input->getInt('id', 0)) {
if (file_exists(JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/shortcode.php')) {
if (class_exists('K2HelperUtilities')) {
include_once JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/shortcode.php';
$shortCodeRegex = JSNPagebuilderHelpersShortcode::getShortcodeRegex();
JModelLegacy::addIncludePath(JPATH_ROOT . '/components/com_k2/models');
$K2ModelItem = JModelLegacy::getInstance('k2modelitem');
$k2Item = $K2ModelItem->getData();
if (count($k2Item)) {
$metaDescItem = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $k2Item->introtext . ' ' . $k2Item->fulltext);
$metaDescItem = strip_tags($metaDescItem);
$k2params = K2HelperUtilities::getParams('com_k2');
$metaDescItem = self::removeShortCode($metaDescItem, $shortCodeRegex);
$metaDescItem = K2HelperUtilities::characterLimit($metaDescItem, $k2params->get('metaDescLimit', 150));
if ($doc->getMetaData('og:description') != null) {
$doc->setMetaData('og:description', $metaDescItem);
}
if ($doc->getDescription() != '') {
$doc->setDescription($metaDescItem);
}
}
}
}
}
// Get PageBuilder configuration.
$params = JSNConfigHelper::get('com_pagebuilder');
// Check if it's enabled or not.
$isEnabled = $params->get('enable_pagebuilder', 1);
// Do nothing if PageBuilder not enabled;
if (!$isEnabled) {
}
// Register autoloaded classes
JSN_Loader::register(JSNPB_ADMIN_ROOT . '/helpers', 'JSNPagebuilderHelpers');
JSN_Loader::register(JSNPB_ADMIN_ROOT . '/helpers/shortcode', 'JSNPBShortcode');
//JSN_Loader::register(JPATH_ROOT . '/plugins/pagebuilder/' , 'JSNPBShortcode');
//JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder/elements/' , 'JSNPBShortcode');
JSN_Loader::register(JPATH_ROOT . '/plugins/jsnpagebuilder/defaultelements/', 'JSNPBShortcode');
//load ElementAssets
self::loadElementAssets();
/*
* Move all css files of PageBuilder
* to the end of css list
*
*/
$data = $doc->getHeadData();
$styleSheetList = $data['styleSheets'];
$_tmpList = array();
if (count($styleSheetList)) {
foreach ($styleSheetList as $cssUrl => $css) {
// Check if the file belongs to PageBuilder
if (strpos($cssUrl, 'plugins/pagebuilder/') !== false || strpos($cssUrl, 'com_pagebuilder') !== false) {
$_tmpList[$cssUrl] = $css;
unset($styleSheetList[$cssUrl]);
}
}
}
$styleSheetList = array_merge($styleSheetList, $_tmpList);
$data['styleSheets'] = $styleSheetList;
$doc->setHeadData($data);
}
示例9: report
function report()
{
$id = $this->getState('id');
$name = JString::trim($this->getState('name'));
$reportReason = JString::trim($this->getState('reportReason'));
$params =& K2HelperUtilities::getParams('com_k2');
$user = JFactory::getUser();
$row = JTable::getInstance('K2Comment', 'Table');
$row->load($id);
if (!$row->published) {
$this->setError(JText::_('K2_COMMENT_NOT_FOUND'));
return false;
}
if (empty($name)) {
$this->setError(JText::_('K2_PLEASE_TYPE_YOUR_NAME'));
return false;
}
if (empty($reportReason)) {
$this->setError(JText::_('K2_PLEASE_TYPE_THE_REPORT_REASON'));
return false;
}
if (($params->get('antispam') == 'recaptcha' || $params->get('antispam') == 'both') && $user->guest) {
if (!function_exists('_recaptcha_qsencode')) {
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'lib' . DS . 'recaptchalib.php';
}
$privatekey = $params->get('recaptcha_private_key');
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$this->setError(JText::_('K2_THE_WORDS_YOU_TYPED_DID_NOT_MATCH_THE_ONES_DISPLAYED_PLEASE_TRY_AGAIN'));
return false;
}
}
$mainframe = JFactory::getApplication();
$mail = JFactory::getMailer();
$senderEmail = $mainframe->getCfg('mailfrom');
$senderName = $mainframe->getCfg('fromname');
$mail->setSender(array($senderEmail, $senderName));
$mail->setSubject(JText::_('K2_COMMENT_REPORT'));
$mail->IsHTML(true);
switch (substr(strtoupper(PHP_OS), 0, 3)) {
case 'WIN':
$mail->LE = "\r\n";
break;
case 'MAC':
case 'DAR':
$mail->LE = "\r";
default:
break;
}
$body = "\n <strong>" . JText::_('K2_NAME') . "</strong>: " . $name . " <br/>\n <strong>" . JText::_('K2_REPORT_REASON') . "</strong>: " . $reportReason . " <br/>\n <strong>" . JText::_('K2_COMMENT') . "</strong>: " . nl2br($row->commentText) . " <br/>\n ";
$mail->setBody($body);
$mail->ClearAddresses();
$mail->AddAddress($params->get('commentsReportRecipient', $mainframe->getCfg('mailfrom')));
$mail->Send();
return true;
}
示例10: media
function media()
{
K2HelperHTML::loadjQuery(true, true);
JRequest::setVar('tmpl', 'component');
$params = K2HelperUtilities::getParams('com_k2');
$document = JFactory::getDocument();
$language = JFactory::getLanguage();
$language->load('com_k2', JPATH_ADMINISTRATOR);
$user = JFactory::getUser();
if ($user->guest) {
$uri = JFactory::getURI();
if (K2_JVERSION != '15') {
$url = 'index.php?option=com_users&view=login&return=' . base64_encode($uri->toString());
} else {
$url = 'index.php?option=com_user&view=login&return=' . base64_encode($uri->toString());
}
$mainframe = JFactory::getApplication();
$mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice');
$mainframe->redirect(JRoute::_($url, false));
}
// CSS
$document->addStyleSheet(JURI::root(true) . '/media/k2/assets/css/k2.css?v=2.6.8');
// JS
K2HelperHTML::loadjQuery(true);
$document->addScript(JURI::root(true) . '/media/k2/assets/js/k2.js?v=2.6.8&sitepath=' . JURI::root(true) . '/');
$this->addViewPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views');
$view = $this->getView('media', 'html');
$view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'media' . DS . 'tmpl');
$view->setLayout('default');
$view->display();
}
示例11: display
function display($tpl = null)
{
$mainframe = JFactory::getApplication();
$user = JFactory::getUser();
$document = JFactory::getDocument();
if (K2_JVERSION == '15') {
$document->setMimeEncoding('application/json');
$document->setType('json');
}
$params = K2HelperUtilities::getParams('com_k2');
$view = JRequest::getWord('view');
$task = JRequest::getWord('task');
$db = JFactory::getDBO();
$jnow = JFactory::getDate();
$now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql();
$nullDate = $db->getNullDate();
// Get item
$model = $this->getModel();
$item = $model->getData();
// Does the item exists?
if (!is_object($item) || !$item->id) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
// Override some params because we want to show all elements in JSON
$itemParams = class_exists('JParameter') ? new JParameter($item->params) : new JRegistry($item->params);
$itemParams->set('itemIntroText', true);
$itemParams->set('itemFullText', true);
$itemParams->set('itemTags', true);
$itemParams->set('itemExtraFields', true);
$itemParams->set('itemAttachments', true);
$itemParams->set('itemRating', true);
$itemParams->set('itemAuthor', true);
$itemParams->set('itemImageGallery', true);
$itemParams->set('itemVideo', true);
$item->params = $itemParams->toString();
// Prepare item
$item = $model->prepareItem($item, $view, $task);
// Plugins
$item = $model->execPlugins($item, $view, $task);
// Access check
if (K2_JVERSION != '15') {
if (!in_array($item->access, $user->getAuthorisedViewLevels()) || !in_array($item->category->access, $user->getAuthorisedViewLevels())) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
} else {
if ($item->access > $user->get('aid', 0) || $item->category->access > $user->get('aid', 0)) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
}
// Published check
if (!$item->published || $item->trash) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
if ($item->publish_up != $nullDate && $item->publish_up > $now) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
if ($item->publish_down != $nullDate && $item->publish_down < $now) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
if (!$item->category->published || $item->category->trash) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
// Set default image
K2HelperUtilities::setDefaultImage($item, $view);
// Build the output object
$row = $model->prepareJSONItem($item);
// Output
$response = new stdClass();
// Site
$response->site = new stdClass();
$uri = JURI::getInstance();
$response->site->url = $uri->toString(array('scheme', 'host', 'port'));
$config = JFactory::getConfig();
$response->site->name = K2_JVERSION == '30' ? $config->get('sitename') : $config->getValue('config.sitename');
$response->item = $row;
$json = json_encode($response);
$callback = JRequest::getCmd('callback');
if ($callback) {
$document->setMimeEncoding('application/javascript');
echo $callback . '(' . $json . ')';
} else {
echo $json;
}
}
示例12: media
function media()
{
JRequest::setVar('tmpl', 'component');
$params =& K2HelperUtilities::getParams('com_k2');
$document =& JFactory::getDocument();
$language =& JFactory::getLanguage();
$language->load('com_k2', JPATH_ADMINISTRATOR);
$user =& JFactory::getUser();
if ($user->guest) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
// CSS
$document->addStyleSheet(JURI::root(true) . '/media/k2/assets/css/k2.css?v=2.5.7');
// JS
$jQueryHandling = $params->get('jQueryHandling', '1.7remote');
if ($jQueryHandling && strpos($jQueryHandling, 'remote') == true) {
$document->addScript('http://ajax.googleapis.com/ajax/libs/jquery/' . str_replace('remote', '', $jQueryHandling) . '/jquery.min.js');
} elseif ($jQueryHandling && strpos($jQueryHandling, 'remote') == false) {
$document->addScript(JURI::root(true) . '/media/k2/assets/js/jquery-' . $jQueryHandling . '.min.js');
}
$backendJQueryHandling = $params->get('backendJQueryHandling', 'remote');
if ($backendJQueryHandling == 'remote') {
$document->addScript('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js');
} else {
$document->addScript(JURI::root(true) . '/media/k2/assets/js/jquery-ui-1.8.16.custom.min.js');
}
$document->addScript(JURI::root(true) . '/media/k2/assets/js/k2.js?v=2.5.7');
$this->addViewPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views');
$view =& $this->getView('media', 'html');
$view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'media' . DS . 'tmpl');
$view->setLayout('default');
$view->display();
}
示例13: prepareFeedItem
function prepareFeedItem(&$item)
{
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$params = K2HelperUtilities::getParams('com_k2');
$limitstart = 0;
$view = JRequest::getCmd('view');
//Category
$category = JTable::getInstance('K2Category', 'Table');
$category->load($item->catid);
$item->category = $category;
//Read more link
$item->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . $item->alias, $item->catid . ':' . urlencode($item->category->alias))));
//Filtering
if ($params->get('introTextCleanup')) {
$filterTags = preg_split('#[,\\s]+#', trim($params->get('introTextCleanupExcludeTags')));
$filterAttrs = preg_split('#[,\\s]+#', trim($params->get('introTextCleanupTagAttr')));
$filter = new JFilterInput($filterTags, $filterAttrs, 0, 1);
$item->introtext = $filter->clean($item->introtext);
}
if ($params->get('fullTextCleanup')) {
$filterTags = preg_split('#[,\\s]+#', trim($params->get('fullTextCleanupExcludeTags')));
$filterAttrs = preg_split('#[,\\s]+#', trim($params->get('fullTextCleanupTagAttr')));
$filter = new JFilterInput($filterTags, $filterAttrs, 0, 1);
$item->fulltext = $filter->clean($item->fulltext);
}
//Description
$item->description = '';
//Item image
if ($params->get('feedItemImage') && JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_' . $params->get('feedImgSize') . '.jpg')) {
$altText = $item->image_caption ? $item->image_caption : $item->title;
$item->description .= '<div class="K2FeedImage"><img src="' . JURI::root() . 'media/k2/items/cache/' . md5('Image' . $item->id) . '_' . $params->get('feedImgSize') . '.jpg" alt="' . $altText . '" /></div>';
}
//Item Introtext
if ($params->get('feedItemIntroText')) {
//Introtext word limit
if ($params->get('feedTextWordLimit') && $item->introtext) {
$item->introtext = K2HelperUtilities::wordLimit($item->introtext, $params->get('feedTextWordLimit'));
}
$item->description .= '<div class="K2FeedIntroText">' . $item->introtext . '</div>';
}
//Item Fulltext
if ($params->get('feedItemFullText') && $item->fulltext) {
$item->description .= '<div class="K2FeedFullText">' . $item->fulltext . '</div>';
}
//Item Tags
if ($params->get('feedItemTags')) {
$tags = $this->getItemTags($item->id);
if (count($tags)) {
$item->description .= '<div class="K2FeedTags"><ul>';
foreach ($tags as $tag) {
$item->description .= '<li>' . $tag->name . '</li>';
}
$item->description .= '<ul></div>';
}
}
//Item Video
if ($params->get('feedItemVideo') && $item->video) {
if (!empty($item->video) && JString::substr($item->video, 0, 1) !== '{') {
$item->description .= '<div class="K2FeedVideo">' . $item->video . '</div>';
} else {
$params->set('vfolder', 'media/k2/videos');
$params->set('afolder', 'media/k2/audio');
if (JString::strpos($item->video, 'remote}')) {
preg_match("#}(.*?){/#s", $item->video, $matches);
if (!JString::strpos($matches[1], 'http://}')) {
$item->video = str_replace($matches[1], JURI::root() . $matches[1], $item->video);
}
}
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$item->text = $item->video;
if (K2_JVERSION == '15') {
$dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
} else {
$dispatcher->trigger('onContentPrepare', array('com_k2.' . $view, &$item, &$params, $limitstart));
}
$item->description .= '<div class="K2FeedVideo">' . $item->text . '</div>';
}
}
//Item gallery
if ($params->get('feedItemGallery') && $item->gallery) {
$params->set('galleries_rootfolder', 'media/k2/galleries');
$params->set('enabledownload', '0');
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$item->text = $item->gallery;
if (K2_JVERSION == '15') {
$dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
} else {
$dispatcher->trigger('onContentPrepare', array('com_k2.' . $view, &$item, &$params, $limitstart));
}
$item->description .= '<div class="K2FeedGallery">' . $item->text . '</div>';
}
//Item attachments
if ($params->get('feedItemAttachments')) {
$attachments = $this->getItemAttachments($item->id);
if (count($attachments)) {
$item->description .= '<div class="K2FeedAttachments"><ul>';
foreach ($attachments as $attachment) {
$item->description .= '<li><a title="' . htmlentities($attachment->titleAttribute, ENT_QUOTES, 'UTF-8') . '" href="' . $attachment->link . '">' . $attachment->title . '</a></li>';
//.........这里部分代码省略.........
示例14: display
function display($tpl = null)
{
$mainframe = JFactory::getApplication();
$user = JFactory::getUser();
$document = JFactory::getDocument();
$params = K2HelperUtilities::getParams('com_k2');
$limitstart = JRequest::getInt('limitstart', 0);
$view = JRequest::getWord('view');
$task = JRequest::getWord('task');
$db = JFactory::getDBO();
$jnow = JFactory::getDate();
$now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql();
$nullDate = $db->getNullDate();
$this->setLayout('item');
// Add link
if (K2HelperPermissions::canAddItem()) {
$addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');
}
$this->assignRef('addLink', $addLink);
// Get item
$model = $this->getModel();
$item = $model->getData();
// Does the item exists?
if (!is_object($item) || !$item->id) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
// Prepare item
$item = $model->prepareItem($item, $view, $task);
// Plugins
$item = $model->execPlugins($item, $view, $task);
// User K2 plugins
$item->event->K2UserDisplay = '';
if (isset($item->author) && is_object($item->author->profile) && isset($item->author->profile->id)) {
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('k2');
$results = $dispatcher->trigger('onK2UserDisplay', array(&$item->author->profile, &$params, $limitstart));
$item->event->K2UserDisplay = trim(implode("\n", $results));
$item->author->profile->url = htmlspecialchars($item->author->profile->url, ENT_QUOTES, 'UTF-8');
}
// Access check
if ($this->getLayout() == 'form') {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
if (K2_JVERSION != '15') {
if (!in_array($item->access, $user->getAuthorisedViewLevels()) || !in_array($item->category->access, $user->getAuthorisedViewLevels())) {
if ($user->guest) {
$uri = JFactory::getURI();
$url = 'index.php?option=com_users&view=login&return=' . base64_encode($uri->toString());
$mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice');
$mainframe->redirect(JRoute::_($url, false));
} else {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
return;
}
}
} else {
if ($item->access > $user->get('aid', 0) || $item->category->access > $user->get('aid', 0)) {
if ($user->guest) {
$uri = JFactory::getURI();
$url = 'index.php?option=com_user&view=login&return=' . base64_encode($uri->toString());
$mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice');
$mainframe->redirect(JRoute::_($url, false));
} else {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
return;
}
}
}
// Published check
if (!$item->published || $item->trash) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
if ($item->publish_up != $nullDate && $item->publish_up > $now) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
if ($item->publish_down != $nullDate && $item->publish_down < $now) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
if (!$item->category->published || $item->category->trash) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
// Increase hits counter
$model->hit($item->id);
// Set default image
K2HelperUtilities::setDefaultImage($item, $view);
// Pass the old parameter to the view in order to avoid layout changes
if ($params->get('antispam') == 'recaptcha' || $params->get('antispam') == 'both') {
$params->set('recaptcha', true);
$item->params->set('recaptcha', true);
} else {
$params->set('recaptcha', false);
$item->params->set('recaptcha', false);
}
// Comments
$item->event->K2CommentsCounter = '';
$item->event->K2CommentsBlock = '';
if ($item->params->get('itemComments')) {
// Trigger comments events
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('k2');
//.........这里部分代码省略.........
示例15: getCounter
public function getCounter($ordering = NULL, $filter = '', $byLabel = false)
{
static $sdata = null;
static $sdataLabel = null;
$user = JFactory::getUser();
$aid = $user->get('aid');
$db = JFactory::getDBO();
$params = K2HelperUtilities::getParams('com_k2');
$task = JRequest::getCmd('task');
$model = new JAK2FilterModelItemlist();
$groupcategories = $this->params->get('k2catsid', null);
if ($this->params->get('catMode', 0)) {
$groupcategories = $model->getCategoryTree($groupcategories);
}
$filter_categories = is_array($groupcategories) ? implode(',', $groupcategories) : $groupcategories;
//
$where = '';
if ($this->update_counter) {
$badchars = array('#', '>', '<', '\\');
$search = JString::trim(JString::str_ireplace($badchars, '', JRequest::getString('searchword', null)));
$where = $model->prepareSearch($search, $filter, $filter_categories);
}
if (empty($where)) {
if ($byLabel) {
if (is_null($sdataLabel)) {
//cache data for the case of search condition is empty
$query = "SELECT `num_items`, CONCAT_WS('_', `type`, `asset_id`, `labels`) AS tkey FROM #__jak2filter_taxonomy";
$db->setQuery($query);
$sdataLabel = $db->loadAssocList('tkey', 'num_items');
}
return $sdataLabel;
} else {
if (is_null($sdata)) {
//cache data for the case of search condition is empty
$query = "SELECT `num_items`, CONCAT_WS('_', `type`, `asset_id`, `option_id`) AS tkey FROM #__jak2filter_taxonomy";
$db->setQuery($query);
$sdata = $db->loadAssocList('tkey', 'num_items');
}
return $sdata;
}
} else {
$tags_id = JRequest::getVar('tags_id');
$rating = JRequest::getVar('rating', '');
$rating = explode('|', $rating);
$ratingMin = isset($rating[0]) && !empty($rating[0]) ? intval($rating[0]) : 1;
$ratingMax = isset($rating[1]) && !empty($rating[1]) ? intval($rating[1]) : 5;
$jnow = JFactory::getDate();
$now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql();
$nullDate = $db->getNullDate();
if (JRequest::getWord('format') == 'feed') {
$limit = $params->get('feedLimit');
}
$query = "SELECT i.id";
$query .= " FROM #__k2_items as i RIGHT JOIN #__k2_categories AS c ON c.id = i.catid";
if ($ordering == 'best' || !($ratingMin <= 1 && $ratingMax == 5)) {
$query .= " LEFT JOIN #__k2_rating r ON r.itemID = i.id";
}
if ($task == 'tag' || $tags_id) {
$query .= " LEFT JOIN #__k2_tags_xref AS tags_xref ON tags_xref.itemID = i.id LEFT JOIN #__k2_tags AS tags ON tags.id = tags_xref.tagID";
}
$query .= " WHERE i.published = 1 AND ";
if (K2_JVERSION != '15') {
$query .= "i.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ")" . " AND i.trash = 0" . " AND c.published = 1" . " AND c.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ")" . " AND c.trash = 0";
$mainframe = JFactory::getApplication();
$languageFilter = $mainframe->getLanguageFilter();
if ($languageFilter) {
$languageTag = JFactory::getLanguage()->getTag();
$query .= " AND c.language IN (" . $db->quote($languageTag) . "," . $db->quote('*') . ") \n\t\t\t\t\t\t\tAND i.language IN (" . $db->quote($languageTag) . "," . $db->quote('*') . ")";
}
}
if (!($task == 'user' && !$user->guest && $user->id == JRequest::getInt('id'))) {
$query .= " AND ( i.publish_up = " . $db->Quote($nullDate) . " OR i.publish_up <= " . $db->Quote($now) . " )";
$query .= " AND ( i.publish_down = " . $db->Quote($nullDate) . " OR i.publish_down >= " . $db->Quote($now) . " )";
}
$query .= $where;
//GET DYNAMIC COUNTER
$field = $byLabel ? 'labels' : 'option_id';
$query = "\n\t\t\t\tSELECT COUNT(tm.item_id) AS num_items, CONCAT_WS('_', `type`, `asset_id`, " . $db->quoteName($field) . ") AS tkey\n\t\t\t\tFROM #__jak2filter_taxonomy t\n\t\t\t\tINNER JOIN #__jak2filter_taxonomy_map tm ON tm.node_id = t.id\n\t\t\t\tWHERE tm.item_id IN (\n\t\t\t\t" . $query . "\n\t\t\t\t)\n\t\t\t\tGROUP BY tkey\n\t\t\t\t";
$db->setQuery($query);
$data = $db->loadAssocList('tkey', 'num_items');
return $data;
}
}