本文整理汇总了PHP中K2Model::addIncludePath方法的典型用法代码示例。如果您正苦于以下问题:PHP K2Model::addIncludePath方法的具体用法?PHP K2Model::addIncludePath怎么用?PHP K2Model::addIncludePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类K2Model
的用法示例。
在下文中一共展示了K2Model::addIncludePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAfterInitialise
public function onAfterInitialise()
{
// Get application
$application = JFactory::getApplication();
// Get user
$user = JFactory::getUser();
// Load Joomla! classes
jimport('joomla.filesystem.file');
// Load the K2 classes
require_once JPATH_ADMINISTRATOR . '/components/com_k2/classes/plugin.php';
require_once JPATH_ADMINISTRATOR . '/components/com_k2/tables/table.php';
require_once JPATH_ADMINISTRATOR . '/components/com_k2/models/model.php';
require_once JPATH_ADMINISTRATOR . '/components/com_k2/resources/attachments.php';
require_once JPATH_ADMINISTRATOR . '/components/com_k2/resources/categories.php';
require_once JPATH_ADMINISTRATOR . '/components/com_k2/resources/comments.php';
require_once JPATH_ADMINISTRATOR . '/components/com_k2/resources/extrafields.php';
require_once JPATH_ADMINISTRATOR . '/components/com_k2/resources/extrafieldsgroups.php';
require_once JPATH_ADMINISTRATOR . '/components/com_k2/resources/items.php';
require_once JPATH_ADMINISTRATOR . '/components/com_k2/resources/tags.php';
require_once JPATH_ADMINISTRATOR . '/components/com_k2/resources/users.php';
K2Model::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/models');
// Load K2 language
$language = JFactory::getLanguage();
$language->load('com_k2', JPATH_ADMINISTRATOR);
// Use K2 to make Joomla! Varnish-friendly. For more checkout: https://snipt.net/fevangelou/the-perfect-varnish-configuration-for-joomla-websites/
if (!$user->guest) {
$application->setHeader('X-Logged-In', 'True', true);
} else {
$application->setHeader('X-Logged-In', 'False', true);
}
}
示例2: getInput
protected function getInput()
{
$document = JFactory::getDocument();
$document->addScriptDeclaration('var K2BasePath = "' . JURI::root(true) . '";');
$document->addScript(JURI::root(true) . '/plugins/josetta_ext/k2item/fields/k2extrafields.js');
K2Model::addIncludePath(JPATH_SITE . '/components/com_k2/models');
JLoader::register('K2HelperUtilities', JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'helpers' . DS . 'utilities.php');
$model = K2Model::getInstance('Item', 'K2Model');
$extraFields = $model->getItemExtraFields($this->value);
$html = '<div id="extraFieldsContainer">';
if (count($extraFields)) {
$html .= '<table class="admintable" id="extraFields">';
foreach ($extraFields as $extraField) {
$html .= '<tr>
<td align="right" class="key">' . $extraField->name . '</td>
<td>' . $extraField->element . '</td>
</tr>';
}
$html .= '</table>';
} else {
$html .= '<span class="k2Note"> ' . JText::_('K2_PLEASE_SELECT_A_CATEGORY_FIRST_TO_RETRIEVE_ITS_RELATED_EXTRA_FIELDS') . ' </span>';
}
$html .= '</div>';
return $html;
}
示例3: onJosettaLoadItem
public function onJosettaLoadItem($context, $id = '')
{
if (!empty($context) && $context != $this->_context || empty($id)) {
return null;
}
$item = parent::onJosettaLoadItem($context, $id);
// Merge introtext and fulltext
$item->articletext = trim($item->fulltext) != '' ? $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext : $item->introtext;
// Get tags
K2Model::addIncludePath(JPATH_SITE . '/components/com_k2/models');
JLoader::register('K2HelperUtilities', JPATH_SITE . '/components/com_k2/helpers/utilities.php');
$model = K2Model::getInstance('Item', 'K2Model');
$tags = $model->getItemTags($item->id);
$tmp = array();
foreach ($tags as $tag) {
$tmp[] = $tag->name;
}
$item->tags = implode(', ', $tmp);
// Get extra fields
$extraFields = $model->getItemExtraFields($item->extra_fields);
$html = '';
if (count($extraFields)) {
$html .= '<ul>';
foreach ($extraFields as $key => $extraField) {
$html .= '<li class="type' . ucfirst($extraField->type) . ' group' . $extraField->group . '">
<span class="itemExtraFieldsLabel">' . $extraField->name . ':</span>
<span class="itemExtraFieldsValue">' . $extraField->value . '</span>
</li>';
}
$html .= '</ul>';
}
$item->extra_fields = $html;
// Return the item
return $item;
}
示例4: getAvatar
public static 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) {
K2Model::addIncludePath(JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models');
$model = K2Model::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;
}
示例5: getInstance
/**
* Gets an item instance.
*
* @param integer $id The id of the item to get.
*
* @return K2Attachment The attachment object.
*/
public static function getInstance($id)
{
if (empty(self::$instances[$id])) {
K2Model::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/models');
$model = K2Model::getInstance('Attachments', 'K2Model');
$model->setState('id', $id);
$item = $model->getRow();
self::$instances[$id] = $item;
}
return self::$instances[$id];
}
示例6: getFields
public function getFields()
{
$fields = array();
if ($this->id) {
K2Model::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/models');
$model = K2Model::getInstance('ExtraFields', 'K2Model');
$model->setState('group', $this->id);
$model->setState('sorting', 'ordering');
$fields = $model->getRows();
}
return $fields;
}
示例7: _findItem
public static function _findItem($catid)
{
$component = JComponentHelper::getComponent('com_jak2filter');
$application = JFactory::getApplication();
$menus = $application->getMenu('site', array());
if (K2_JVERSION != '15') {
$items = $menus->getItems('component_id', $component->id);
} else {
$items = $menus->getItems('componentid', $component->id);
}
$match = null;
if (count($items)) {
foreach ($items as $item) {
if ($catid) {
if (@$item->query['view'] == 'itemlist' && @$item->query['category_id'] == $catid) {
$match = $item;
break;
}
} else {
if (@$item->query['view'] == 'itemlist' && !isset($item->query['category_id'])) {
$match = $item;
break;
}
}
}
}
if (is_null($match)) {
// Try to detect any parent category menu item....
if (is_null(self::$tree)) {
include_once JPATH_ADMINISTRATOR . '/components/com_k2/models/model.php';
K2Model::addIncludePath(JPATH_SITE . '/components/com_k2/models');
$model = K2Model::getInstance('Itemlist', 'K2Model');
self::$model = $model;
self::$tree = $model->getCategoriesTree();
}
$parents = self::$model->getTreePath(self::$tree, $catid);
if (is_array($parents)) {
foreach ($parents as $categoryID) {
if ($categoryID != $catid) {
$match = JAK2FilterHelperRoute::_findItem($categoryID);
if (!is_null($match)) {
break;
}
}
}
}
if (is_null($match) && !is_null(self::$anyK2Link)) {
$match = self::$anyK2Link;
}
}
return $match;
}
示例8: getGroups
public static function getGroups($scope = 'item')
{
if (!isset(self::$groups[$scope])) {
K2Model::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/models');
$model = K2Model::getInstance('ExtraFieldsGroups', 'K2Model');
$model->setState('scope', $scope);
$model->setState('sorting', 'name');
$rows = $model->getRows();
self::$groups[$scope] = array();
foreach ($rows as $row) {
self::$groups[$scope][$row->id] = $row;
}
}
return self::$groups[$scope];
}
示例9: getInstance
/**
* Gets an item instance.
*
* @param integer $id The id of the item to get.
*
* @return K2Category The category object.
*/
public static function getInstance($id)
{
if (empty(self::$instances[$id])) {
K2Model::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/models');
$model = K2Model::getInstance('Categories', 'K2Model');
if (is_numeric($id)) {
$model->setState('id', $id);
} else {
$model->setState('alias', $id);
}
$item = $model->getRow();
self::$instances[$id] = $item;
self::$instances[$item->alias] = $item;
}
return self::$instances[$id];
}
示例10: getRelatedItems
function getRelatedItems($itemID, $tags, $params)
{
// var_dump($tags);
$mainframe = JFactory::getApplication();
$limit = $params->get('itemRelatedLimit', 10);
$itemID = (int) $itemID;
foreach ($tags as $tag) {
$tagIDs[] = $tag->id;
}
JArrayHelper::toInteger($tagIDs);
$sql = implode(',', $tagIDs);
$user = JFactory::getUser();
$aid = (int) $user->get('aid');
$db = JFactory::getDBO();
$jnow = JFactory::getDate();
$now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql();
$nullDate = $db->getNullDate();
$query = "SELECT DISTINCT itemID FROM #__k2_tags_xref WHERE tagID IN ({$sql}) AND itemID!={$itemID}";
$db->setQuery($query);
$itemsIDs = K2_JVERSION == '30' ? $db->loadColumn() : $db->loadResultArray();
if (!count($itemsIDs)) {
return array();
}
$sql = implode(',', $itemsIDs);
$query = "SELECT i.*, c.alias as categoryalias FROM #__k2_items as i \n\t\t\t\tLEFT JOIN #__k2_categories c ON c.id = i.catid \n\t\t\t\tWHERE i.published = 1 \n\t\t\t\tAND ( i.publish_up = " . $db->Quote($nullDate) . " OR i.publish_up <= " . $db->Quote($now) . " ) \n\t\t\t\tAND ( i.publish_down = " . $db->Quote($nullDate) . " OR i.publish_down >= " . $db->Quote($now) . " ) ";
if (K2_JVERSION != '15') {
$query .= " AND i.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ") ";
if ($mainframe->getLanguageFilter()) {
$query .= " AND i.language IN(" . $db->Quote(JFactory::getLanguage()->getTag()) . ", " . $db->Quote('*') . ")";
}
} else {
$query .= " AND i.access <= {$aid} ";
}
$query .= " AND i.trash = 0 \n\t\t\t\tAND c.published = 1 ";
if (K2_JVERSION != '15') {
$query .= " AND c.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ") ";
if ($mainframe->getLanguageFilter()) {
$query .= " AND c.language IN(" . $db->Quote(JFactory::getLanguage()->getTag()) . ", " . $db->Quote('*') . ")";
}
} else {
$query .= " AND c.access <= {$aid} ";
}
$query .= " AND c.trash = 0 \n\t\t\t\tAND (i.id) IN ({$sql}) \n\t\t\t\tORDER BY i.created DESC";
$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();
K2Model::addIncludePath(JPATH_COMPONENT . DS . 'models');
$model = K2Model::getInstance('Item', 'K2Model');
for ($key = 0; $key < sizeof($rows); $key++) {
if (!$params->get('itemRelatedMedia')) {
$rows[$key]->video = null;
}
if (!$params->get('itemRelatedImageGallery')) {
$rows[$key]->gallery = null;
}
$rows[$key] = $model->prepareItem($rows[$key], 'relatedByTag', '');
$rows[$key] = $model->execPlugins($rows[$key], 'relatedByTag', '');
K2HelperUtilities::setDefaultImage($rows[$key], 'relatedByTag', $params);
}
return $rows;
}
示例11: getTotal
function getTotal()
{
$mainframe = JFactory::getApplication();
$params = JComponentHelper::getParams('com_k2');
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDBO();
$filter_trash = $mainframe->getUserStateFromRequest($option . $view . 'filter_trash', 'filter_trash', 0, 'int');
$filter_featured = $mainframe->getUserStateFromRequest($option . $view . 'filter_featured', 'filter_featured', -1, 'int');
$filter_category = $mainframe->getUserStateFromRequest($option . $view . 'filter_category', 'filter_category', 0, 'int');
$filter_author = $mainframe->getUserStateFromRequest($option . $view . 'filter_author', 'filter_author', 0, 'int');
$filter_state = $mainframe->getUserStateFromRequest($option . $view . 'filter_state', 'filter_state', -1, 'int');
$search = $mainframe->getUserStateFromRequest($option . $view . 'search', 'search', '', 'string');
$search = JString::strtolower($search);
$tag = $mainframe->getUserStateFromRequest($option . $view . 'tag', 'tag', 0, 'int');
$language = $mainframe->getUserStateFromRequest($option . $view . 'language', 'language', '', 'string');
$query = "SELECT COUNT(*) FROM #__k2_items AS i ";
if ($params->get('showTagFilter') && $tag) {
$query .= " LEFT JOIN #__k2_tags_xref AS tags_xref ON tags_xref.itemID = i.id";
}
$query .= " WHERE trash={$filter_trash} ";
if ($search) {
$escaped = K2_JVERSION == '15' ? $db->getEscaped($search, true) : $db->escape($search, true);
$quoted = $db->Quote('%' . $escaped . '%', false);
if ($params->get('adminSearch') == 'full') {
$query .= " AND ( LOWER(i.title) LIKE " . $quoted . " OR LOWER(i.introtext) LIKE " . $quoted . " OR LOWER(i.`fulltext`) LIKE " . $quoted . " OR LOWER(i.extra_fields_search) LIKE " . $quoted . " OR LOWER(i.image_caption) LIKE " . $quoted . " OR LOWER(i.image_credits) LIKE " . $quoted . " OR LOWER(i.video_caption) LIKE " . $quoted . " OR LOWER(i.video_credits) LIKE " . $quoted . " OR LOWER(i.metadesc) LIKE " . $quoted . " OR LOWER(i.metakey) LIKE " . $quoted . ") ";
} else {
$query .= " AND LOWER(i.title) LIKE " . $quoted;
}
}
if ($filter_state > -1) {
$query .= " AND published={$filter_state}";
}
if ($filter_featured > -1) {
$query .= " AND featured={$filter_featured}";
}
if ($filter_category > 0) {
if ($params->get('showChildCatItems')) {
K2Model::addIncludePath(JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models');
$itemListModel = K2Model::getInstance('Itemlist', 'K2Model');
$categories = $itemListModel->getCategoryTree($filter_category);
$sql = @implode(',', $categories);
$query .= " AND catid IN ({$sql})";
} else {
$query .= " AND catid={$filter_category}";
}
}
if ($filter_author > 0) {
$query .= " AND created_by={$filter_author}";
}
if ($params->get('showTagFilter') && $tag) {
$query .= " AND tags_xref.tagID = {$tag}";
}
if ($language) {
$query .= " AND (language = " . $db->Quote($language) . " OR language = '*')";
}
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('k2');
$dispatcher->trigger('onK2BeforeSetQuery', array(&$query));
$db->setQuery($query);
$result = $db->loadResult();
return $result;
}
示例12: reportSpammer
function reportSpammer()
{
$mainframe = JFactory::getApplication();
$user = JFactory::getUser();
$format = JRequest::getVar('format');
$errors = array();
if (K2_JVERSION != '15')
{
if (!$user->authorise('core.admin', 'com_k2'))
{
$format == 'raw' ? die(JText::_('K2_ALERTNOTAUTH')) : JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
}
else
{
if ($user->gid < 25)
{
$format == 'raw' ? die(JText::_('K2_ALERTNOTAUTH')) : JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
}
K2Model::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'models');
$model = K2Model::getInstance('User', 'K2Model');
$model->setState('id', JRequest::getInt('id'));
$model->reportSpammer();
if ($format == 'raw')
{
$response = '';
$messages = $mainframe->getMessageQueue();
foreach ($messages as $message)
{
$response .= $message['message']."\n";
}
die($response);
}
$this->setRedirect('index.php?option=com_k2&view=comments&tmpl=component');
}
示例13: display
function display($tpl = null)
{
$mainframe = JFactory::getApplication();
$document = JFactory::getDocument();
$db = JFactory::getDBO();
$params = JComponentHelper::getParams('com_k2');
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
$limitstart = $mainframe->getUserStateFromRequest($option . $view . '.limitstart', 'limitstart', 0, 'int');
$filter_order = $mainframe->getUserStateFromRequest($option . $view . 'filter_order', 'filter_order', 'juser.name', 'cmd');
$filter_order_Dir = $mainframe->getUserStateFromRequest($option . $view . 'filter_order_Dir', 'filter_order_Dir', '', 'word');
$filter_status = $mainframe->getUserStateFromRequest($option . $view . 'filter_status', 'filter_status', -1, 'int');
$filter_group = $mainframe->getUserStateFromRequest($option . $view . 'filter_group', 'filter_group', '', 'string');
$filter_group_k2 = $mainframe->getUserStateFromRequest($option . $view . 'filter_group_k2', 'filter_group_k2', '', 'string');
$search = $mainframe->getUserStateFromRequest($option . $view . 'search', 'search', '', 'string');
$search = JString::strtolower($search);
K2Model::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models');
$model = K2Model::getInstance('Users', 'K2Model');
$total = $model->getTotal();
if ($limitstart > $total - $limit) {
$limitstart = max(0, (int) (ceil($total / $limit) - 1) * $limit);
JRequest::setVar('limitstart', $limitstart);
}
$users = $model->getData();
$task = JRequest::getCmd('task');
for ($i = 0; $i < sizeof($users); $i++) {
$users[$i]->loggedin = $model->checkLogin($users[$i]->id);
$users[$i]->profileID = $model->hasProfile($users[$i]->id);
if ($users[$i]->profileID) {
$db->setQuery("SELECT ip FROM #__k2_users WHERE id = " . $users[$i]->profileID);
$users[$i]->ip = $db->loadResult();
} else {
$users[$i]->ip = '';
}
if ($users[$i]->lastvisitDate == "0000-00-00 00:00:00") {
$users[$i]->lvisit = false;
} else {
$users[$i]->lvisit = $users[$i]->lastvisitDate;
}
$users[$i]->link = JRoute::_('index.php?option=com_k2&view=user&cid=' . $users[$i]->id);
if (K2_JVERSION == '15') {
$users[$i]->published = $users[$i]->loggedin;
$users[$i]->loggedInStatus = strip_tags(JHTML::_('grid.published', $users[$i], $i), '<img>');
$users[$i]->blockStatus = '';
if ($users[$i]->block) {
$users[$i]->blockStatus .= '<a title="' . JText::_('K2_ENABLE') . '" onclick="return listItemTask(\'cb' . $i . ',\'enable\')" href="#"><img alt="' . JText::_('K2_ENABLED') . '" src="images/publish_x.png"></a>';
} else {
$users[$i]->blockStatus .= '<a title="' . JText::_('K2_DISABLE') . '" onclick="return listItemTask(\'cb' . $i . ',\'disable\')" href="#"><img alt="' . JText::_('K2_DISABLED') . '" src="images/tick.png"></a>';
}
if ($task == 'element') {
$users[$i]->blockStatus = strip_tags($users[$i]->blockStatus, '<img>');
}
} else {
$states = array(1 => array('', 'K2_LOGGED_IN', 'K2_LOGGED_IN', 'K2_LOGGED_IN', false, 'publish', 'publish'), 0 => array('', 'K2_NOT_LOGGED_IN', 'K2_NOT_LOGGED_IN', 'K2_NOT_LOGGED_IN', false, 'unpublish', 'unpublish'));
$users[$i]->loggedInStatus = JHtml::_('jgrid.state', $states, $users[$i]->loggedin, $i, '', false);
$states = array(0 => array('disable', 'K2_ENABLED', 'K2_DISABLE', 'K2_ENABLED', false, 'publish', 'publish'), 1 => array('enable', 'K2_DISABLED', 'K2_ENABLE', 'K2_DISABLED', false, 'unpublish', 'unpublish'));
$users[$i]->blockStatus = JHtml::_('jgrid.state', $states, $users[$i]->block, $i, '', $task != 'element');
}
}
$this->assignRef('rows', $users);
jimport('joomla.html.pagination');
$pageNav = new JPagination($total, $limitstart, $limit);
$this->assignRef('page', $pageNav);
$lists = array();
$lists['search'] = $search;
$lists['order_Dir'] = $filter_order_Dir;
$lists['order'] = $filter_order;
$filter_status_options[] = JHTML::_('select.option', -1, JText::_('K2_SELECT_STATE'));
$filter_status_options[] = JHTML::_('select.option', 0, JText::_('K2_ENABLED'));
$filter_status_options[] = JHTML::_('select.option', 1, JText::_('K2_BLOCKED'));
$lists['status'] = JHTML::_('select.genericlist', $filter_status_options, 'filter_status', '', 'value', 'text', $filter_status);
$userGroups = $model->getUserGroups();
$groups[] = JHTML::_('select.option', '0', JText::_('K2_SELECT_JOOMLA_GROUP'));
foreach ($userGroups as $userGroup) {
$groups[] = JHTML::_('select.option', $userGroup->value, $userGroup->text);
}
$lists['filter_group'] = JHTML::_('select.genericlist', $groups, 'filter_group', '', 'value', 'text', $filter_group);
$K2userGroups = $model->getUserGroups('k2');
$K2groups[] = JHTML::_('select.option', '0', JText::_('K2_SELECT_K2_GROUP'));
foreach ($K2userGroups as $K2userGroup) {
$K2groups[] = JHTML::_('select.option', $K2userGroup->id, $K2userGroup->name);
}
$lists['filter_group_k2'] = JHTML::_('select.genericlist', $K2groups, 'filter_group_k2', '', 'value', 'text', $filter_group_k2);
$this->assignRef('lists', $lists);
if (K2_JVERSION != '15') {
$dateFormat = JText::_('K2_J16_DATE_FORMAT');
} else {
$dateFormat = JText::_('K2_DATE_FORMAT');
}
$this->assignRef('dateFormat', $dateFormat);
$template = $mainframe->getTemplate();
$this->assignRef('template', $template);
if ($mainframe->isAdmin()) {
JToolBarHelper::title(JText::_('K2_USERS'), 'k2.png');
JToolBarHelper::custom('move', 'move.png', 'move_f2.png', 'K2_MOVE', true);
JToolBarHelper::deleteList('K2_WARNING_YOU_ARE_ABOUT_TO_DELETE_THE_SELECTED_USERS_PERMANENTLY_FROM_THE_SYSTEM', 'delete', 'K2_DELETE');
JToolBarHelper::publishList('enable', 'K2_ENABLE');
JToolBarHelper::unpublishList('disable', 'K2_DISABLE');
JToolBarHelper::editList();
//.........这里部分代码省略.........
示例14: defined
<?php
/**
* @version 3.0.0
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2014 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once JPATH_SITE . '/components/com_k2/helpers/route.php';
require_once JPATH_SITE . '/components/com_k2/helpers/utilities.php';
require_once JPATH_ADMINISTRATOR . '/components/com_k2/models/model.php';
K2Model::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/models');
class ModK2ToolsHelper
{
public static function getArchive($params)
{
$model = K2Model::getInstance('Items');
$model->setState('site', true);
$filter = $params->get('archiveCategory');
$model->setState('category.filter', $filter);
$model->setState('sorting', 'created.reverse');
$rows = $model->getArchive();
$months = array(JText::_('K2_JANUARY'), JText::_('K2_FEBRUARY'), JText::_('K2_MARCH'), JText::_('K2_APRIL'), JText::_('K2_MAY'), JText::_('K2_JUNE'), JText::_('K2_JULY'), JText::_('K2_AUGUST'), JText::_('K2_SEPTEMBER'), JText::_('K2_OCTOBER'), JText::_('K2_NOVEMBER'), JText::_('K2_DECEMBER'));
$archives = array();
$root = isset($filter->categories[0]) ? $filter->categories[0] : 0;
foreach ($rows as $row) {
$row->numOfItems = '';
if ($params->get('archiveItemsCounter')) {
示例15: getData
function getData()
{
$mainframe = JFactory::getApplication();
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDBO();
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
$limitstart = $mainframe->getUserStateFromRequest($option . $view . '.limitstart', 'limitstart', 0, 'int');
$search = $mainframe->getUserStateFromRequest($option . $view . 'search', 'search', '', 'string');
$search = JString::strtolower($search);
$filter_order = $mainframe->getUserStateFromRequest($option . $view . 'filter_order', 'filter_order', 'c.ordering', 'cmd');
$filter_order_Dir = $mainframe->getUserStateFromRequest($option . $view . 'filter_order_Dir', 'filter_order_Dir', '', 'word');
$filter_trash = $mainframe->getUserStateFromRequest($option . $view . 'filter_trash', 'filter_trash', 0, 'int');
$language = $mainframe->getUserStateFromRequest($option . $view . 'language', 'language', '', 'string');
$filter_category = $mainframe->getUserStateFromRequest($option . $view . 'filter_category', 'filter_category', 0, 'int');
// Publish categories only
$filter_state = $mainframe->getUserStateFromRequest($option . $view . 'filter_state', 'filter_state', 1, 'int');
$query = "SELECT c.*, g.name AS groupname, exfg.name as extra_fields_group FROM #__k2_categories as c LEFT JOIN #__groups AS g ON g.id = c.access LEFT JOIN #__k2_extra_fields_groups AS exfg ON exfg.id = c.extraFieldsGroup WHERE c.id>0";
if (!$filter_trash) {
$query .= " AND c.trash=0";
}
if ($search) {
$escaped = K2_JVERSION == '15' ? $db->getEscaped($search, true) : $db->escape($search, true);
$query .= " AND LOWER( c.name ) LIKE " . $db->Quote('%' . $escaped . '%', false);
}
if ($filter_state > -1) {
$query .= " AND c.published={$filter_state}";
}
if ($language) {
$query .= " AND (c.language = " . $db->Quote($language) . " OR c.language = '*')";
}
if ($filter_category) {
K2Model::addIncludePath(JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models');
$ItemlistModel = K2Model::getInstance('Itemlist', 'K2Model');
$tree = $ItemlistModel->getCategoryTree($filter_category);
$query .= " AND c.id IN (" . implode(',', $tree) . ")";
}
$query .= " ORDER BY {$filter_order} {$filter_order_Dir}";
if (K2_JVERSION != '15') {
$query = JString::str_ireplace('#__groups', '#__viewlevels', $query);
$query = JString::str_ireplace('g.name AS groupname', 'g.title AS groupname', $query);
}
$db->setQuery($query);
$rows = $db->loadObjectList();
if (K2_JVERSION != '15') {
foreach ($rows as $row) {
$row->parent_id = $row->parent;
$row->title = $row->name;
}
}
$categories = array();
if ($search) {
foreach ($rows as $row) {
$row->treename = $row->name;
$categories[] = $row;
}
} else {
if ($filter_category) {
$db->setQuery('SELECT parent FROM #__k2_categories WHERE id = ' . $filter_category);
$root = $db->loadResult();
} else {
$root = 0;
}
$categories = $this->indentRows($rows, $root);
}
if (isset($categories)) {
$total = count($categories);
} else {
$total = 0;
}
jimport('joomla.html.pagination');
$pageNav = new JPagination($total, $limitstart, $limit);
$categories = @array_slice($categories, $pageNav->limitstart, $pageNav->limit);
foreach ($categories as $category) {
$category->parameters = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params);
if ($category->parameters->get('inheritFrom')) {
$db->setQuery("SELECT name FROM #__k2_categories WHERE id = " . (int) $category->parameters->get('inheritFrom'));
$category->inheritFrom = $db->loadResult();
} else {
$category->inheritFrom = '';
}
}
return $categories;
}