本文整理汇总了PHP中K2HelperUtilities::getCategoryImage方法的典型用法代码示例。如果您正苦于以下问题:PHP K2HelperUtilities::getCategoryImage方法的具体用法?PHP K2HelperUtilities::getCategoryImage怎么用?PHP K2HelperUtilities::getCategoryImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类K2HelperUtilities
的用法示例。
在下文中一共展示了K2HelperUtilities::getCategoryImage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display($tpl = null)
{
$mainframe = JFactory::getApplication();
$params = K2HelperUtilities::getParams('com_k2');
$document = JFactory::getDocument();
if (K2_JVERSION == '15') {
$document->setMimeEncoding('application/json');
$document->setType('json');
}
$model = $this->getModel('itemlist');
//Set limit for model
$limit = JRequest::getInt('limit');
if ($limit > 100 || $limit == 0) {
$limit = 100;
JRequest::setVar('limit', $limit);
}
$page = JRequest::getInt('page');
if ($page <= 0) {
$limitstart = 0;
} else {
$page--;
$limitstart = $page * $limit;
}
JRequest::setVar('limitstart', $limitstart);
$view = JRequest::getWord('view');
$task = JRequest::getWord('task');
$response = new JObject();
unset($response->_errors);
// 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');
$moduleID = JRequest::getInt('moduleID');
if ($moduleID) {
$result = $model->getModuleItems($moduleID);
$items = $result->items;
$title = $result->title;
$prefix = 'cat';
} else {
//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 != '15') {
if (!in_array($category->access, $user->getAuthorisedViewLevels())) {
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'));
}
}
//Merge params
$cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params);
if ($cparams->get('inheritFrom')) {
$masterCategory = JTable::getInstance('K2Category', 'Table');
$masterCategory->load($cparams->get('inheritFrom'));
$cparams = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($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 != '15') {
$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;
//Category children
//.........这里部分代码省略.........
示例2: 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
//.........这里部分代码省略.........
示例3: 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');
$db = JFactory::getDBO();
// 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);
$category->event = new stdClass();
// State check
if (!$category->published || $category->trash) {
JError::raiseError(404, JText::_('K2_CATEGORY_NOT_FOUND'));
}
// Access check
$user = JFactory::getUser();
if (K2_JVERSION != '15') {
if (!in_array($category->access, $user->getAuthorisedViewLevels())) {
if ($user->guest) {
$uri = JFactory::getURI();
$url = 'index.php?option=com_users&view=login&return=' . base64_encode($uri->toString());
$mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'));
} else {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
return;
}
}
$languageFilter = $mainframe->getLanguageFilter();
$languageTag = JFactory::getLanguage()->getTag();
if ($languageFilter && $category->language != $languageTag && $category->language != '*') {
return;
}
} else {
if ($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->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'));
} else {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
return;
}
}
}
// Hide the add new item link if user cannot post in the specific category
if (!K2HelperPermissions::canAddItem($id)) {
unset($this->addLink);
}
// Merge params
$cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params);
// Get the meta information before merging params since we do not want them to be inherited
$category->metaDescription = $cparams->get('catMetaDesc');
$category->metaKeywords = $cparams->get('catMetaKey');
$category->metaRobots = $cparams->get('catMetaRobots');
$category->metaAuthor = $cparams->get('catMetaAuthor');
if ($cparams->get('inheritFrom')) {
$masterCategory = JTable::getInstance('K2Category', 'Table');
$masterCategory->load($cparams->get('inheritFrom'));
$cparams = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($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 != '15') {
$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');
//.........这里部分代码省略.........