Ejemplo n.º 1
0
 function display($tpl = null)
 {
     JHTML::_('behavior.tooltip');
     JRequest::setVar('hidemainmenu', 1);
     $model =& $this->getModel();
     $userGroup = $model->getData();
     JFilterOutput::objectHTMLSafe($userGroup);
     $this->assignRef('row', $userGroup);
     $form = new JParameter('', JPATH_COMPONENT . DS . 'models' . DS . 'userGroup.xml');
     $form->loadINI($userGroup->permissions);
     $this->assignRef('form', $form);
     $appliedCategories = $form->get('categories');
     $this->assignRef('categories', $appliedCategories);
     $lists = array();
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'categories.php';
     $categoriesModel = new K2ModelCategories();
     $categories = $categoriesModel->categoriesTree(NULL, true);
     $categories_options = @array_merge($categories_option, $categories);
     $lists['categories'] = JHTML::_('select.genericlist', $categories, 'params[categories][]', 'multiple="multiple" style="width:90%;" size="15"', 'value', 'text', $appliedCategories);
     $lists['inheritance'] = JHTML::_('select.booleanlist', 'params[inheritance]', NULL, $form->get('inheritance'));
     $this->assignRef('lists', $lists);
     JRequest::getInt('cid') ? $title = JText::_('Edit user group') : ($title = JText::_('Add user group'));
     JToolBarHelper::title(JText::_($title));
     JToolBarHelper::save();
     JToolBarHelper::apply();
     JToolBarHelper::cancel();
     parent::display($tpl);
 }
Ejemplo n.º 2
0
 function display($tpl = null)
 {
     JHTML::_('behavior.keepalive');
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'models' . DS . 'categories.php';
     $model = new K2ModelCategories();
     $categories = $model->categoriesTree(NULL, false, false);
     $options = array();
     $options[] = JHTML::_('select.optgroup', JText::_('K2MART_CREATE_NEW_K2_CATEGORY'));
     $options[] = JHTML::_('select.option', 0, JText::_('K2MART_TYPE_CATEGORY_NAME'));
     $options[] = JHTML::_('select.optgroup', JText::_('K2MART_USE_EXISTING_K2_CATEGORY'));
     foreach ($categories as $category) {
         $options[] = JHTML::_('select.option', $category->value, $category->text);
     }
     $lists['category'] = JHTML::_('select.genericlist', $options, 'catid', 'class="inputbox"', 'value', 'text', 0);
     $vmLanguages = vmConfig::get('active_languages', array());
     if (count($vmLanguages) > 1) {
         jimport('joomla.language.helper');
         $languages = JLanguageHelper::createLanguageList(NULL, constant('JPATH_SITE'), true);
         foreach ($languages as $key => &$language) {
             if (!in_array($language['value'], $vmLanguages)) {
                 unset($languages[$key]);
             }
         }
         $lists['language'] = JHTML::_('select.genericlist', $languages, 'vmlang', '', 'value', 'text', NULL, 'vmlang');
     }
     $this->assignRef('lists', $lists);
     $this->loadHelper('html');
     K2martHTMLHelper::title('K2MART_VIRTUEMART_MIGRATOR');
     K2martHTMLHelper::toolbar();
     K2martHTMLHelper::subMenu();
     parent::display($tpl);
 }
Ejemplo n.º 3
0
 function display($tpl = null)
 {
     $mainframe =& JFactory::getApplication();
     $user =& JFactory::getUser();
     $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', 'c.id', 'cmd');
     $filter_order_Dir = $mainframe->getUserStateFromRequest($option . $view . 'filter_order_Dir', 'filter_order_Dir', 'DESC', 'word');
     $filter_state = $mainframe->getUserStateFromRequest($option . $view . 'filter_state', 'filter_state', -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');
     $search = $mainframe->getUserStateFromRequest($option . $view . 'search', 'search', '', 'string');
     $search = JString::strtolower($search);
     $model =& $this->getModel();
     $comments = $model->getData();
     $this->assignRef('rows', $comments);
     $total = $model->getTotal();
     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_state_options[] = JHTML::_('select.option', -1, JText::_('-- Select State --'));
     $filter_state_options[] = JHTML::_('select.option', 1, JText::_('Published'));
     $filter_state_options[] = JHTML::_('select.option', 0, JText::_('Unpublished'));
     $lists['state'] = JHTML::_('select.genericlist', $filter_state_options, 'filter_state', 'onchange="this.form.submit();"', 'value', 'text', $filter_state);
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'categories.php';
     $categoriesModel = new K2ModelCategories();
     $categories_option[] = JHTML::_('select.option', 0, JText::_('- Select category -'));
     $categories = $categoriesModel->categoriesTree();
     $categories_options = @array_merge($categories_option, $categories);
     $lists['categories'] = JHTML::_('select.genericlist', $categories_options, 'filter_category', 'onchange="this.form.submit();"', 'value', 'text', $filter_category);
     $lists['authors'] = JHTML::_('list.users', 'filter_author', $filter_author, true, 'onchange="this.form.submit();"');
     $this->assignRef('lists', $lists);
     JToolBarHelper::title(JText::_('Comments'));
     JToolBarHelper::publishList();
     JToolBarHelper::unpublishList();
     JToolBarHelper::deleteList(JText::_('Are you sure you want to delete selected comments?'), 'remove', JText::_('Delete'));
     $toolbar =& JToolBar::getInstance('toolbar');
     $toolbar->appendButton('Link', 'delete', JText::_('Delete all unpublished'), JURI::base() . 'index.php?option=com_k2&view=comments&task=deleteUnpublished');
     JToolBarHelper::preferences('com_k2', '500', '600');
     JSubMenuHelper::addEntry(JText::_('Dashboard'), 'index.php?option=com_k2');
     JSubMenuHelper::addEntry(JText::_('Items'), 'index.php?option=com_k2&view=items');
     JSubMenuHelper::addEntry(JText::_('Categories'), 'index.php?option=com_k2&view=categories');
     JSubMenuHelper::addEntry(JText::_('Tags'), 'index.php?option=com_k2&view=tags');
     JSubMenuHelper::addEntry(JText::_('Comments'), 'index.php?option=com_k2&view=comments', true);
     if ($user->gid > 23) {
         JSubMenuHelper::addEntry(JText::_('Users'), 'index.php?option=com_k2&view=users');
         JSubMenuHelper::addEntry(JText::_('User Groups'), 'index.php?option=com_k2&view=userGroups');
         JSubMenuHelper::addEntry(JText::_('Extra Fields'), 'index.php?option=com_k2&view=extraFields');
         JSubMenuHelper::addEntry(JText::_('Extra Field Groups'), 'index.php?option=com_k2&view=extraFieldsGroups');
         JSubMenuHelper::addEntry(JText::_('Information'), 'index.php?option=com_k2&view=info');
     }
     parent::display($tpl);
 }
Ejemplo n.º 4
0
 function display($tpl = null)
 {
     JRequest::setVar('hidemainmenu', 1);
     $model =& $this->getModel();
     $category = $model->getData();
     JFilterOutput::objectHTMLSafe($category);
     if (!$category->id) {
         $category->published = 1;
     }
     $this->assignRef('row', $category);
     $wysiwyg =& JFactory::getEditor();
     $editor = $wysiwyg->display('description', $category->description, '100%', '250', '40', '5', array('pagebreak', 'readmore'));
     $this->assignRef('editor', $editor);
     $lists = array();
     $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $category->published);
     $lists['access'] = JHTML::_('list.accesslevel', $category);
     $query = 'SELECT ordering AS value, name AS text FROM #__k2_categories ORDER BY ordering';
     $lists['ordering'] = JHTML::_('list.specificordering', $category, $category->id, $query);
     $categories[] = JHTML::_('select.option', '0', JText::_('-- None --'));
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'categories.php';
     $categoriesModel = new K2ModelCategories();
     $tree = $categoriesModel->categoriesTree($category);
     $categories = array_merge($categories, $tree);
     $lists['parent'] = JHTML::_('select.genericlist', $categories, 'parent', 'class="inputbox"', 'value', 'text', $category->parent);
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'extrafields.php';
     $extraFieldsModel = new K2ModelExtraFields();
     $groups = $extraFieldsModel->getGroups();
     $group[] = JHTML::_('select.option', '0', JText::_('-- None --'), 'id', 'name');
     $group = array_merge($group, $groups);
     $lists['extraFieldsGroup'] = JHTML::_('select.genericlist', $group, 'extraFieldsGroup', 'class="inputbox" size="1" ', 'id', 'name', $category->extraFieldsGroup);
     JPluginHelper::importPlugin('k2');
     $dispatcher =& JDispatcher::getInstance();
     $K2Plugins = $dispatcher->trigger('onRenderAdminForm', array(&$category, 'category'));
     $this->assignRef('K2Plugins', $K2Plugins);
     $params =& JComponentHelper::getParams('com_k2');
     $this->assignRef('params', $params);
     $form = new JParameter('', JPATH_COMPONENT . DS . 'models' . DS . 'category.xml');
     $form->loadINI($category->params);
     $this->assignRef('form', $form);
     $categories[0] = JHTML::_('select.option', '0', JText::_('-- None --'));
     $lists['inheritFrom'] = JHTML::_('select.genericlist', $categories, 'params[inheritFrom]', 'class="inputbox"', 'value', 'text', $form->get('inheritFrom'));
     $this->assignRef('lists', $lists);
     JRequest::getInt('cid') ? $title = JText::_('Edit Category') : ($title = JText::_('Add Category'));
     JToolBarHelper::title($title, 'k2.png');
     JToolBarHelper::save();
     JToolBarHelper::custom('saveAndNew', 'save.png', 'save_f2.png', 'Save & New', false);
     JToolBarHelper::apply();
     JToolBarHelper::cancel();
     parent::display($tpl);
 }
Ejemplo n.º 5
0
 private function categories()
 {
     // Get application
     $application = JFactory::getApplication();
     // Get filter
     $filter = $this->params->get('categoryIDs');
     // Get categories model
     $model = K2Model::getInstance('Categories');
     $model->setState('site', true);
     $model->setState('limit', 0);
     $model->setState('limitstart', 0);
     // Apply filtering if enabled
     if ($filter['enabled']) {
         $categoryIds = K2ModelCategories::getCategoryFilter($filter['categories'], $filter['recursive'], true);
         if (count($categoryIds)) {
             $model->setState('id', $categoryIds);
         } else {
             $this->categories = array();
             return;
         }
     }
     $this->categories = $model->getRows();
     foreach ($this->categories as $category) {
         // Get items model
         $model = K2Model::getInstance('Items');
         $model->setState('site', true);
         $model->setState('recursive', false);
         $model->setState('limit', $this->params->get('latestItemsLimit', 10));
         $model->setState('limitstart', 0);
         $model->setState('category', $category->id);
         $category->items = $model->getRows();
     }
     $this->blocks = $this->categories;
 }
Ejemplo n.º 6
0
 function display($tpl = null)
 {
     JHTML::_('behavior.tooltip');
     JRequest::setVar('hidemainmenu', 1);
     $model =& $this->getModel();
     $userGroup = $model->getData();
     if (K2_JVERSION == '15') {
         JFilterOutput::objectHTMLSafe($userGroup);
     } else {
         JFilterOutput::objectHTMLSafe($userGroup, ENT_QUOTES, 'permissions');
     }
     $this->assignRef('row', $userGroup);
     if (K2_JVERSION == '15') {
         $form = new JParameter('', JPATH_COMPONENT . DS . 'models' . DS . 'usergroup.xml');
         $form->loadINI($userGroup->permissions);
         $appliedCategories = $form->get('categories');
         $inheritance = $form->get('inheritance');
     } else {
         jimport('joomla.form.form');
         $form = JForm::getInstance('permissions', JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'usergroup.xml');
         $values = array('params' => json_decode($userGroup->permissions));
         $form->bind($values);
         $inheritance = isset($values['params']->inheritance) ? $values['params']->inheritance : 0;
         $appliedCategories = isset($values['params']->categories) ? $values['params']->categories : '';
     }
     $this->assignRef('form', $form);
     $this->assignRef('categories', $appliedCategories);
     $lists = array();
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'categories.php';
     $categoriesModel = new K2ModelCategories();
     $categories = $categoriesModel->categoriesTree(NULL, true);
     $categories_options = @array_merge($categories_option, $categories);
     $lists['categories'] = JHTML::_('select.genericlist', $categories, 'params[categories][]', 'multiple="multiple" size="15"', 'value', 'text', $appliedCategories);
     $lists['inheritance'] = JHTML::_('select.booleanlist', 'params[inheritance]', NULL, $inheritance);
     $this->assignRef('lists', $lists);
     JRequest::getInt('cid') ? $title = JText::_('K2_EDIT_USER_GROUP') : ($title = JText::_('K2_ADD_USER_GROUP'));
     JToolBarHelper::title($title, 'k2.png');
     JToolBarHelper::save();
     JToolBarHelper::apply();
     JToolBarHelper::cancel();
     parent::display($tpl);
 }
Ejemplo n.º 7
0
 /**
  * Returns array of K2 list options
  * Used by Backend XML only
  *
  * @return array
  */
 public function getK2Options()
 {
     global $_CB_framework;
     $options = array();
     if (is_dir($_CB_framework->getCfg('absolute_path') . '/administrator/components/com_k2') && class_exists('K2Model')) {
         /** @noinspection PhpIncludeInspection */
         require_once $_CB_framework->getCfg('absolute_path') . '/administrator/components/com_k2/models/categories.php';
         /** @noinspection PhpUndefinedClassInspection */
         $categories = new K2ModelCategories();
         /** @noinspection PhpUndefinedMethodInspection */
         $options = array_merge($options, $categories->categoriesTree(null, true, true));
     }
     return $options;
 }
Ejemplo n.º 8
0
 function move()
 {
     $mainframe =& JFactory::getApplication();
     JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables');
     $cid = JRequest::getVar('cid');
     foreach ($cid as $id) {
         $row =& JTable::getInstance('K2Category', 'Table');
         $row->load($id);
         $rows[] = $row;
     }
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'categories.php';
     $categoriesModel = new K2ModelCategories();
     $categories_option[] = JHTML::_('select.option', 0, JText::_('K2_NONE_ONSELECTLISTS'));
     $categories = $categoriesModel->categoriesTree(NULL, true, false);
     $categories_options = @array_merge($categories_option, $categories);
     foreach ($categories_options as $option) {
         if (in_array($option->value, $cid)) {
             $option->disable = true;
         }
     }
     $lists['categories'] = JHTML::_('select.genericlist', $categories_options, 'category', 'class="inputbox" size="8"', 'value', 'text');
     $this->assignRef('rows', $rows);
     $this->assignRef('lists', $lists);
     JToolBarHelper::title(JText::_('K2_MOVE_CATEGORIES'), 'k2.png');
     JToolBarHelper::custom('saveMove', 'save.png', 'save_f2.png', 'K2_SAVE', false);
     JToolBarHelper::cancel();
     parent::display();
 }
Ejemplo n.º 9
0
    private function setQueryConditions(&$query)
    {
        $db = $this->getDBO();
        if ($this->getState('site')) {
            // Get current datetime
            $date = JFactory::getDate()->toSql();
            // Get authorised view levels
            $viewlevels = array_unique(JFactory::getUser()->getAuthorisedViewLevels());
            // Published items only
            $this->setState('state', 1);
            $this->setState('publish_up', $date);
            $this->setState('publish_down', $date);
            // Set state for access
            $this->setState('access', $viewlevels);
            // Language filter
            $application = JFactory::getApplication();
            if ($application->isSite() && $application->getLanguageFilter()) {
                $language = JFactory::getLanguage();
                $query->where($db->quoteName('item.language') . ' IN (' . $db->quote($language->getTag()) . ', ' . $db->quote('*') . ')');
            }
        }
        // Shortcut method for setting the categoy filter
        if ($this->getState('category.filter')) {
            $filter = (object) $this->getState('category.filter');
            if (isset($filter->enabled) && $filter->enabled) {
                $this->setState('category', $filter->categories);
                $this->setState('recursive', $filter->recursive);
            }
        }
        if ($this->getState('category')) {
            $categories = (array) $this->getState('category');
            $filter = K2ModelCategories::getCategoryFilter($categories, $this->getState('recursive'), $this->getState('site'));
            if (!count($filter)) {
                $filter[] = 1;
            }
            $this->setState('categories.applied', $filter);
            $query->where($db->quoteName('item.catid') . ' IN (' . implode(',', $filter) . ')');
        } else {
            if ($this->getState('site')) {
                $authorised = K2ModelCategories::getAuthorised();
                if (!count($authorised)) {
                    $authorised[] = 1;
                }
                $this->setState('categories.applied', $authorised);
                $query->where($db->quoteName('item.catid') . ' IN (' . implode(',', $authorised) . ')');
            }
        }
        if ($this->getState('language')) {
            $query->where($db->quoteName('item.language') . ' = ' . $db->quote($this->getState('language')));
        }
        if (is_numeric($this->getState('state'))) {
            $operator = $this->getState('state.operator') ? $this->getState('state.operator') : '=';
            $query->where($db->quoteName('item.state') . ' ' . $operator . ' ' . (int) $this->getState('state'));
        }
        if (is_numeric($this->getState('featured'))) {
            $query->where($db->quoteName('item.featured') . ' = ' . (int) $this->getState('featured'));
        }
        if ($this->getState('access')) {
            $access = $this->getState('access');
            if (is_array($access)) {
                $access = array_unique($access);
                JArrayHelper::toInteger($access);
                $query->where($db->quoteName('item.access') . ' IN (' . implode(',', $access) . ')');
            } else {
                $query->where($db->quoteName('item.access') . ' = ' . (int) $access);
            }
        }
        if ($this->getState('id')) {
            $id = $this->getState('id');
            if (is_array($id)) {
                JArrayHelper::toInteger($id);
                $query->where($db->quoteName('item.id') . ' IN (' . implode(',', $id) . ')');
            } else {
                $query->where($db->quoteName('item.id') . ' = ' . (int) $id);
            }
        }
        if ($this->getState('alias')) {
            $query->where($db->quoteName('item.alias') . ' = ' . $db->quote($this->getState('alias')));
        }
        if ($this->getState('author')) {
            $query->where($db->quoteName('item.created_by') . ' = ' . (int) $this->getState('author'));
            if ($this->getState('site')) {
                $query->where($db->quoteName('item.created_by_alias') . ' = ' . $db->quote(''));
            }
        }
        if ($tag = $this->getState('tag')) {
            if ($excludeItemId = $this->getState('tag.exclude.item')) {
                $query->where($db->quoteName('item.id') . ' != ' . (int) $excludeItemId);
            }
            // Cast to integer and generate the query string
            $tag = (array) $tag;
            JArrayHelper::toInteger($tag);
            sort($tag, SORT_NUMERIC);
            $condition = implode(',', $tag);
            // Optimize query depending on data amount. Use cache to avoid duplicate queries
            if (!isset(self::$cache[$condition]['count'])) {
                $subquery = $db->getQuery(true);
                $subquery->select('COUNT(' . $db->quoteName('itemId') . ')')->from($db->quoteName('#__k2_tags_xref'));
                $subquery->where($db->quoteName('tagId') . ' IN (' . $condition . ')');
                $db->setQuery($subquery);
                self::$cache[$condition]['count'] = (int) $db->loadResult();
            }
            $numOfTaggedItems = self::$cache[$condition]['count'];
            if ($numOfTaggedItems == 0 || $numOfTaggedItems == 1 && $this->getState('tag.exclude.item')) {
                // No results should be returned
                $query->where($db->quoteName('item.id') . ' IN(0)');
            } else {
                if ($numOfTaggedItems <= 50) {
                    if (!isset(self::$cache[$condition]['itemIds'])) {
                        $subquery = $db->getQuery(true);
                        $subquery->select($db->quoteName('itemId'))->from($db->quoteName('#__k2_tags_xref'));
                        $subquery->where($db->quoteName('tagId') . ' IN (' . $condition . ')');
                        $db->setQuery($subquery);
                        self::$cache[$condition]['itemIds'] = $db->loadColumn();
                    }
                    $query->where($db->quoteName('item.id') . ' IN (' . implode(',', self::$cache[$condition]['itemIds']) . ')');
                } else {
                    $query->innerJoin($db->quoteName('#__k2_tags_xref') . ' AS ' . $db->quoteName('xref') . ' ON ' . $db->quoteName('item.id') . ' = ' . $db->quoteName('xref.itemId'));
                    $query->where($db->quoteName('xref.tagId') . ' IN (' . $condition . ')');
                }
            }
        }
        if ($this->getState('publish_up')) {
            $query->where('(' . $db->quoteName('item.publish_up') . ' = ' . $db->Quote($db->getNullDate()) . ' OR ' . $db->quoteName('item.publish_up') . ' <= ' . $db->Quote($this->getState('publish_up')) . ')');
        }
        if ($this->getState('publish_down')) {
            $query->where('(' . $db->quoteName('item.publish_down') . ' = ' . $db->Quote($db->getNullDate()) . ' OR ' . $db->quoteName('item.publish_down') . ' >= ' . $db->Quote($this->getState('publish_down')) . ')');
        }
        if ($this->getState('search')) {
            $search = trim($this->getState('search'));
            if ($search) {
                // Site search
                if ($this->getState('site')) {
                    $mode = $this->getState('search.mode');
                    switch ($mode) {
                        case 'exact':
                            $text = $db->quote('%' . $db->escape($search, true) . '%', false);
                            $where = $db->quoteName('item.title') . ' LIKE ' . $text . ' OR ' . $db->quoteName('item.introtext') . ' LIKE ' . $text . ' OR ' . $db->quoteName('item.fulltext') . ' LIKE ' . $text . ' OR ' . $db->quoteName('item.extra_fields') . ' LIKE ' . $text . ' OR ' . $db->quoteName('item.tags') . ' LIKE ' . $text;
                            break;
                        case 'all':
                        case 'any':
                        default:
                            $words = explode(' ', $search);
                            $searchConditions = array();
                            foreach ($words as $word) {
                                $word = $db->quote('%' . $db->escape($word, true) . '%', false);
                                $wordConditions = array();
                                $wordConditions[] = $db->quoteName('item.title') . ' LIKE ' . $word;
                                $wordConditions[] = $db->quoteName('item.introtext') . ' LIKE ' . $word;
                                $wordConditions[] = $db->quoteName('item.fulltext') . ' LIKE ' . $word;
                                $wordConditions[] = $db->quoteName('item.extra_fields') . ' LIKE ' . $word;
                                $wordConditions[] = $db->quoteName('item.tags') . ' LIKE ' . $word;
                                $searchConditions[] = implode(' OR ', $wordConditions);
                            }
                            $where = '(' . implode($mode == 'all' ? ') AND (' : ') OR (', $searchConditions) . ')';
                            break;
                    }
                    $query->where('(' . $where . ')');
                } else {
                    $search = $db->escape($search, true);
                    $query->where('(' . $db->quoteName('item.title') . ' LIKE ' . $db->Quote('%' . $search . '%', false) . ' 
					OR ' . $db->quoteName('item.id') . ' = ' . (int) $search . '
					OR ' . $db->quoteName('item.introtext') . ' LIKE ' . $db->Quote('%' . $search . '%', false) . '
					OR ' . $db->quoteName('item.fulltext') . ' LIKE ' . $db->Quote('%' . $search . '%', false) . ')');
                }
            }
        }
        if ($this->getState('year') && $this->getState('month') && $this->getState('day')) {
            $startDate = JFactory::getDate($this->getState('year') . '-' . $this->getState('month') . '-' . $this->getState('day'))->toSql();
            $endDate = JFactory::getDate($this->getState('year') . '-' . $this->getState('month') . '-' . $this->getState('day') . ' 23:59:59')->toSql();
        } else {
            if ($this->getState('year') && $this->getState('month')) {
                $startDate = JFactory::getDate($this->getState('year') . '-' . $this->getState('month') . '-01')->toSql();
                $endDate = JFactory::getDate($this->getState('year') . '-' . $this->getState('month') . '-' . date('t', strtotime('last day of ' . $this->getState('year') . '-' . $this->getState('month') . '-01')) . ' 23:59:59')->toSql();
            } else {
                if ($this->getState('year')) {
                    $startDate = JFactory::getDate($this->getState('year') . '-01-01')->toSql();
                    $endDate = JFactory::getDate($this->getState('year') . '-12-31 23:59:59')->toSql();
                }
            }
        }
        if (isset($startDate)) {
            $query->where($db->quoteName('item.created') . ' >= ' . $db->quote($startDate));
        }
        if (isset($endDate)) {
            $query->where($db->quoteName('item.created') . ' <= ' . $db->quote($endDate));
        }
        if ($this->getState('media')) {
            $query->where($db->quoteName('item.media') . ' != ' . $db->quote('[]'));
            $query->where($db->quoteName('item.media') . ' != ' . $db->quote(''));
        }
        if ($this->getState('created.value')) {
            $query->where($db->quoteName('item.created') . ' ' . $this->getState('created.operator') . ' ' . $db->quote($this->getState('created.value')));
        }
        if (is_numeric($this->getState('ordering.value'))) {
            $query->where($db->quoteName('item.ordering') . ' ' . $this->getState('ordering.operator') . ' ' . (int) $this->getState('ordering.value'));
        }
        if ($excludeItemId = $this->getState('exclude')) {
            $query->where($db->quoteName('item.id') . ' != ' . (int) $excludeItemId);
        }
    }
Ejemplo n.º 10
0
    function display($tpl = null)
    {
        $mainframe =& JFactory::getApplication();
        $user =& JFactory::getUser();
        if ($user->guest) {
            JError::raiseError(403, JText::_("ALERTNOTAUTH"));
        }
        JHTML::_('behavior.mootools');
        $document =& JFactory::getDocument();
        $document->addCustomTag('
<!-- K2 by JoomlaWorks (start) -->

	<!-- Load Khepri styling -->
	<link rel="stylesheet" href="' . JURI::root() . 'administrator/templates/system/css/system.css" type="text/css" />
	<link href="' . JURI::root() . 'administrator/templates/khepri/css/template.css" rel="stylesheet" type="text/css" />
	<!--[if IE 7]>
	<link href="' . JURI::root() . 'administrator/templates/khepri/css/ie7.css" rel="stylesheet" type="text/css" />
	<![endif]-->
	<!--[if lte IE 6]>
	<link href="' . JURI::root() . 'administrator/templates/khepri/css/ie6.css" rel="stylesheet" type="text/css" />
	<![endif]-->
	<link rel="stylesheet" type="text/css" href="' . JURI::root() . 'administrator/templates/khepri/css/rounded.css" />

	<!-- Load K2 styling -->
	<link href="' . JURI::root() . 'administrator/components/com_k2/css/k2.css" rel="stylesheet" type="text/css" />

<!-- K2 by JoomlaWorks (end) -->
				');
        $model =& $this->getModel();
        $comments = $model->getUserComments($user->id);
        $total = $model->countUserComments($user->id);
        $option = JRequest::getCmd('option');
        $view = JRequest::getCmd('view');
        $limit = $mainframe->getUserStateFromRequest($option . $view . '.limit', 'limit', 10, 'int');
        $limitstart = $mainframe->getUserStateFromRequest($option . $view . '.limitstart', 'limitstart', 0, 'int');
        $filter_order = $mainframe->getUserStateFromRequest($option . $view . 'filter_order', 'filter_order', 'c.id', 'cmd');
        $filter_order_Dir = $mainframe->getUserStateFromRequest($option . $view . 'filter_order_Dir', 'filter_order_Dir', 'DESC', 'word');
        $filter_state = $mainframe->getUserStateFromRequest($option . $view . 'filter_state', 'filter_state', -1, 'int');
        $filter_category = $mainframe->getUserStateFromRequest($option . $view . 'filter_category', 'filter_category', 0, 'int');
        $search = $mainframe->getUserStateFromRequest($option . $view . 'search', 'search', '', 'string');
        $search = JString::strtolower($search);
        jimport('joomla.html.pagination');
        $pagination = new JPagination($total, $limitstart, $limit);
        $lists = array();
        $lists['search'] = $search;
        $lists['order_Dir'] = $filter_order_Dir;
        $lists['order'] = $filter_order;
        $filter_state_options[] = JHTML::_('select.option', -1, '-- ' . JText::_('Select state') . ' --');
        $filter_state_options[] = JHTML::_('select.option', 1, JText::_('Published'));
        $filter_state_options[] = JHTML::_('select.option', 0, JText::_('Unpublished'));
        $lists['state'] = JHTML::_('select.genericlist', $filter_state_options, 'filter_state', 'onchange="this.form.submit();"', 'value', 'text', $filter_state);
        require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'categories.php';
        $categoriesModel = new K2ModelCategories();
        $categories_option[] = JHTML::_('select.option', 0, '- ' . JText::_('Select category') . ' -');
        $categories = $categoriesModel->categoriesTree();
        $categories_options = @array_merge($categories_option, $categories);
        $lists['categories'] = JHTML::_('select.genericlist', $categories_options, 'filter_category', 'onchange="this.form.submit();"', 'value', 'text', $filter_category);
        $this->assignRef('lists', $lists);
        $this->assignRef('rows', $comments);
        $this->assignRef('pagination', $pagination);
        $this->setLayout('default');
        parent::display($tpl);
    }
Ejemplo n.º 11
0
    private function setQueryConditions(&$query)
    {
        $db = $this->getDBO();
        if ($itemId = $this->getState('itemId')) {
            if (is_array($itemId)) {
                $query->where($db->quoteName('comment.itemId') . ' IN (' . implode(',', $itemId) . ')');
            } else {
                $query->where($db->quoteName('comment.itemId') . ' = ' . (int) $itemId);
            }
        }
        if (is_numeric($this->getState('state'))) {
            $query->where($db->quoteName('comment.state') . ' = ' . (int) $this->getState('state'));
        }
        if ($this->getState('id')) {
            $id = $this->getState('id');
            if ($this->getState('id.operator')) {
                $operator = $this->getState('id.operator');
            } else {
                $operator = '=';
            }
            $query->where($db->quoteName('comment.id') . ' ' . $operator . ' ' . (int) $id);
        }
        if ($this->getState('search')) {
            $search = trim($this->getState('search'));
            $search = strtolower($search);
            if ($search) {
                $search = $db->escape($search, true);
                $query->where('(' . $db->quoteName('comment.text') . ' LIKE ' . $db->Quote('%' . $search . '%', false) . ' 
					OR ' . $db->quoteName('comment.name') . ' LIKE ' . $db->Quote('%' . $search . '%', false) . '
					OR ' . $db->quoteName('comment.email') . ' LIKE ' . $db->Quote('%' . $search . '%', false) . '
					OR ' . $db->quoteName('comment.ip') . ' LIKE ' . $db->Quote('%' . $search . '%', false) . '
					OR ' . $db->quoteName('comment.hostname') . ' LIKE ' . $db->Quote('%' . $search . '%', false) . ')');
            }
        }
        if ($this->getState('userId')) {
            $query->where($db->quoteName('comment.userId') . ' = ' . (int) $this->getState('userId'));
        }
        if ($category = (int) $this->getState('category')) {
            $query->where($db->quoteName('item.catid') . ' = ' . $category);
        }
        if ($this->getState('filter.items')) {
            // Items should be published
            $query->where($db->quoteName('item.state') . ' = 1');
            // Check categories access level
            $filter = K2ModelCategories::getCategoryFilter($this->getState('category'), false, true);
            $query->where($db->quoteName('item.catid') . ' IN (' . implode(',', $filter) . ')');
            // Check item access level
            $viewlevels = array_unique(JFactory::getUser()->getAuthorisedViewLevels());
            $query->where($db->quoteName('item.access') . ' IN (' . implode(',', $viewlevels) . ')');
            // Check publish up/down
            $date = JFactory::getDate()->toSql();
            $query->where('(' . $db->quoteName('item.publish_up') . ' = ' . $db->Quote($db->getNullDate()) . ' OR ' . $db->quoteName('item.publish_up') . ' <= ' . $db->Quote($date) . ')');
            $query->where('(' . $db->quoteName('item.publish_down') . ' = ' . $db->Quote($db->getNullDate()) . ' OR ' . $db->quoteName('item.publish_down') . ' >= ' . $db->Quote($date) . ')');
        }
    }
Ejemplo n.º 12
0
 function display($tpl = null)
 {
     JRequest::setVar('hidemainmenu', 1);
     $model =& $this->getModel();
     $category = $model->getData();
     if (K2_JVERSION == '15') {
         JFilterOutput::objectHTMLSafe($category);
     } else {
         JFilterOutput::objectHTMLSafe($category, ENT_QUOTES, array('params', 'plugins'));
     }
     if (!$category->id) {
         $category->published = 1;
     }
     $this->assignRef('row', $category);
     $wysiwyg =& JFactory::getEditor();
     $editor = $wysiwyg->display('description', $category->description, '100%', '250px', '', '', array('pagebreak', 'readmore'));
     $this->assignRef('editor', $editor);
     $document =& JFactory::getDocument();
     $js = "\n\t\tvar K2SitePath = '" . JURI::root(true) . "/';\n\t\tvar K2BasePath = '" . JURI::base(true) . "/';\n\t\t";
     $document->addScriptDeclaration($js);
     $lists = array();
     $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $category->published);
     $lists['access'] = JHTML::_('list.accesslevel', $category);
     $query = 'SELECT ordering AS value, name AS text FROM #__k2_categories ORDER BY ordering';
     $lists['ordering'] = JHTML::_('list.specificordering', $category, $category->id, $query);
     $categories[] = JHTML::_('select.option', '0', JText::_('K2_NONE_ONSELECTLISTS'));
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'categories.php';
     $categoriesModel = new K2ModelCategories();
     $tree = $categoriesModel->categoriesTree($category);
     $categories = array_merge($categories, $tree);
     $lists['parent'] = JHTML::_('select.genericlist', $categories, 'parent', 'class="inputbox"', 'value', 'text', $category->parent);
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'extrafields.php';
     $extraFieldsModel = new K2ModelExtraFields();
     $groups = $extraFieldsModel->getGroups();
     $group[] = JHTML::_('select.option', '0', JText::_('K2_NONE_ONSELECTLISTS'), 'id', 'name');
     $group = array_merge($group, $groups);
     $lists['extraFieldsGroup'] = JHTML::_('select.genericlist', $group, 'extraFieldsGroup', 'class="inputbox" size="1" ', 'id', 'name', $category->extraFieldsGroup);
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $languages = JHTML::_('contentlanguage.existing', true, true);
         $lists['language'] = JHTML::_('select.genericlist', $languages, 'language', '', 'value', 'text', $category->language);
     }
     JPluginHelper::importPlugin('k2');
     $dispatcher =& JDispatcher::getInstance();
     $K2Plugins = $dispatcher->trigger('onRenderAdminForm', array(&$category, 'category'));
     $this->assignRef('K2Plugins', $K2Plugins);
     $params =& JComponentHelper::getParams('com_k2');
     $this->assignRef('params', $params);
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         jimport('joomla.form.form');
         $form = JForm::getInstance('categoryForm', JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'category.xml');
         $values = array('params' => json_decode($category->params));
         $form->bind($values);
         $inheritFrom = isset($values['params']->inheritFrom) ? $values['params']->inheritFrom : 0;
     } else {
         $form = new JParameter('', JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'category.xml');
         $form->loadINI($category->params);
         $inheritFrom = $form->get('inheritFrom');
     }
     $this->assignRef('form', $form);
     $categories[0] = JHTML::_('select.option', '0', JText::_('K2_NONE_ONSELECTLISTS'));
     $lists['inheritFrom'] = JHTML::_('select.genericlist', $categories, 'params[inheritFrom]', 'class="inputbox"', 'value', 'text', $inheritFrom);
     $this->assignRef('lists', $lists);
     JRequest::getInt('cid') ? $title = JText::_('K2_EDIT_CATEGORY') : ($title = JText::_('K2_ADD_CATEGORY'));
     JToolBarHelper::title($title, 'k2.png');
     JToolBarHelper::save();
     JToolBarHelper::custom('saveAndNew', 'save.png', 'save_f2.png', 'K2_SAVE_AND_NEW', false);
     JToolBarHelper::apply();
     JToolBarHelper::cancel();
     // ACE ACL integration
     $definedConstants = get_defined_constants();
     if (!empty($definedConstants['ACEACL']) && AceaclApi::authorize('permissions', 'com_aceacl')) {
         $aceAclFlag = true;
     } else {
         $aceAclFlag = false;
     }
     $this->assignRef('aceAclFlag', $aceAclFlag);
     parent::display($tpl);
 }
Ejemplo n.º 13
0
    function edit()
    {
        $mainframe =& JFactory::getApplication();
        jimport('joomla.filesystem.file');
        jimport('joomla.html.pane');
        $db =& JFactory::getDBO();
        JHTML::_('behavior.mootools');
        $document =& JFactory::getDocument();
        $document->addScript(JURI::root() . 'administrator/components/com_k2/lib/Autocompleter.js');
        $document->addScript(JURI::root() . 'administrator/components/com_k2/lib/observer.js');
        $document->addScript(JURI::root() . 'administrator/components/com_k2/lib/simpletabs_1.3.js');
        //$document->addScript(JURI::root().'administrator/components/com_k2/js/k2.js'); // Core JS
        $document->addScript(JURI::root() . 'administrator/components/com_k2/js/k2.mootools.js');
        // Mootools based JS
        $document->addCustomTag('
        
<!-- K2 by JoomlaWorks (start) -->
		
	<!-- Load Khepri styling -->
	<link rel="stylesheet" href="' . JURI::root() . 'administrator/templates/system/css/system.css" type="text/css" />
	<link href="' . JURI::root() . 'administrator/templates/khepri/css/template.css" rel="stylesheet" type="text/css" />
	<!--[if IE 7]>
	<link href="' . JURI::root() . 'administrator/templates/khepri/css/ie7.css" rel="stylesheet" type="text/css" />
	<![endif]-->
	<!--[if lte IE 6]>
	<link href="' . JURI::root() . 'administrator/templates/khepri/css/ie6.css" rel="stylesheet" type="text/css" />
	<![endif]-->
	<link rel="stylesheet" type="text/css" href="' . JURI::root() . 'administrator/templates/khepri/css/rounded.css" />
	
	<!-- Load K2 styling -->
	<link href="' . JURI::root() . 'administrator/components/com_k2/css/k2.css" rel="stylesheet" type="text/css" />
	<!--[if IE 7]>
	<link href="' . JURI::root() . 'administrator/components/com_k2/css/k2_ie7.css" rel="stylesheet" type="text/css" />
	<![endif]-->
	<!--[if lte IE 6]>
	<link href="' . JURI::root() . 'administrator/components/com_k2/css/k2_ie6.css" rel="stylesheet" type="text/css" />
	<![endif]-->
		
<!-- K2 by JoomlaWorks (end) -->

		');
        JRequest::setVar('tmpl', 'component');
        require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'item.php';
        $model = new K2ModelItem();
        $task = JRequest::getCmd('task');
        $user =& JFactory::getUser();
        if ($task == 'edit') {
            $item = $model->getData();
            JFilterOutput::objectHTMLSafe($item, ENT_QUOTES, 'video');
            if (!K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
                JError::raiseError(403, JText::_("ALERTNOTAUTH"));
            }
            if (JTable::isCheckedOut($user->get('id'), $item->checked_out)) {
                $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The item'), $item->title);
                $mainframe->redirect('index.php?option=com_k2&view=item&id=' . $item->id . '&tmpl=component', $msg);
            }
        } elseif ($task == 'add') {
            if (!K2HelperPermissions::canAddItem()) {
                JError::raiseError(403, JText::_("ALERTNOTAUTH"));
            }
            JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables');
            $item =& JTable::getInstance('K2Item', 'Table');
            $createdate =& JFactory::getDate();
            $item->published = 1;
            $item->publish_up = $createdate->toUnix();
            $item->publish_down = JText::_('Never');
            $item->created = $createdate->toUnix();
            $item->modified = $db->getNullDate();
        }
        if ($item->id) {
            $item->checkout($user->get('id'));
        }
        $item->created = JHTML::_('date', $item->created, '%Y-%m-%d %H:%M:%S');
        $item->publish_up = JHTML::_('date', $item->publish_up, '%Y-%m-%d %H:%M:%S');
        if (JHTML::_('date', $item->publish_down, '%Y') <= 1969 || $item->publish_down == $db->getNullDate()) {
            $item->publish_down = JText::_('Never');
        } else {
            $item->publish_down = JHTML::_('date', $item->publish_down, '%Y-%m-%d %H:%M:%S');
        }
        $params =& JComponentHelper::getParams('com_k2');
        $wysiwyg =& JFactory::getEditor();
        if ($params->get("mergeEditors")) {
            if (JString::strlen($item->fulltext) > 1) {
                $textValue = $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext;
            } else {
                $textValue = $item->introtext;
            }
            $text = $wysiwyg->display('text', $textValue, '100%', '400', '40', '5', array('pagebreak'));
            $this->assignRef('text', $text);
        } else {
            $introtext = $wysiwyg->display('introtext', $item->introtext, '100%', '400', '40', '5', array('pagebreak', 'readmore'));
            $this->assignRef('introtext', $introtext);
            $fulltext = $wysiwyg->display('fulltext', $item->fulltext, '100%', '400', '40', '5', array('pagebreak', 'readmore'));
            $this->assignRef('fulltext', $fulltext);
        }
        $lists = array();
        $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $item->published);
        $lists['access'] = JHTML::_('list.accesslevel', $item);
        $query = "SELECT ordering AS value, title AS text FROM #__k2_items WHERE catid={$item->catid}";
        $lists['ordering'] = JHTML::_('list.specificordering', $item, $item->id, $query);
        require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'categories.php';
        $categoriesModel = new K2ModelCategories();
        $categories = $categoriesModel->categoriesTree();
        $lists['catid'] = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox"', 'value', 'text', $item->catid);
        $lists['checkSIG'] = $model->checkSIG();
        $lists['checkAllVideos'] = $model->checkAllVideos();
        $remoteVideo = false;
        $providerVideo = false;
        $embedVideo = false;
        $options['startOffset'] = 0;
        if (stristr($item->video, 'remote}') !== false) {
            $remoteVideo = true;
            $options['startOffset'] = 1;
        }
        $providers = $model->getVideoProviders();
        if (count($providers)) {
            foreach ($providers as $provider) {
                $providersOptions[] = JHTML::_('select.option', $provider, $provider);
                if (stristr($item->video, "{{$provider}}") !== false) {
                    $providerVideo = true;
                    $options['startOffset'] = 2;
                }
            }
        }
        if (JString::substr($item->video, 0, 1) !== '{') {
            $embedVideo = true;
            $options['startOffset'] = 3;
        }
        $lists['uploadedVideo'] = !$remoteVideo && !$providerVideo && !$embedVideo ? true : false;
        if ($lists['uploadedVideo']) {
            $options['startOffset'] = 0;
        }
        $lists['remoteVideo'] = $remoteVideo ? preg_replace('%\\{[a-z0-9-_]*\\}(.*)\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
        $lists['remoteVideoType'] = $remoteVideo ? preg_replace('%\\{([a-z0-9-_]*)\\}.*\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
        $lists['providerVideo'] = $providerVideo ? preg_replace('%\\{[a-z0-9-_]*\\}(.*)\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
        $lists['providerVideoType'] = $providerVideo ? preg_replace('%\\{([a-z0-9-_]*)\\}.*\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
        $lists['embedVideo'] = $embedVideo ? $item->video : '';
        if (count($providers)) {
            $lists['providers'] = JHTML::_('select.genericlist', $providersOptions, 'videoProvider', '', 'value', 'text', $lists['providerVideoType']);
        }
        JPluginHelper::importPlugin('content', 'jw_sigpro');
        JPluginHelper::importPlugin('content', 'jw_sig');
        JPluginHelper::importPlugin('content', 'jw_allvideos');
        $dispatcher =& JDispatcher::getInstance();
        $params->set('galleries_rootfolder', 'media/k2/galleries');
        $params->set('thb_width', '150');
        $params->set('thb_height', '120');
        $params->set('popup_engine', 'mootools_slimbox');
        $params->set('enabledownload', '0');
        $item->text = $item->gallery;
        $dispatcher->trigger('onPrepareContent', array(&$item, &$params, null));
        $item->gallery = $item->text;
        if (!$embedVideo) {
            $params->set('vfolder', 'media/k2/videos');
            $item->text = $item->video;
            $dispatcher->trigger('onPrepareContent', array(&$item, &$params, null));
            $item->video = $item->text;
        } else {
            $item->video = '<div>' . $item->video . '</div>';
        }
        if (isset($item->created_by)) {
            $author =& JUser::getInstance($item->created_by);
            $item->author = $author->name;
        }
        if (isset($item->modified_by)) {
            $moderator =& JUser::getInstance($item->modified_by);
            $item->moderator = $moderator->name;
        }
        if ($task == 'edit') {
            $item->editor = $item->author;
        } else {
            $item->editor = $user->name;
        }
        require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'categories.php';
        $categoriesModel = new K2ModelCategories();
        $categories_option[] = JHTML::_('select.option', 0, JText::_('- Select category -'));
        $categories = $categoriesModel->categoriesTree();
        if (($task == 'add' || $task == 'edit') && !$user->authorize('com_k2', 'add', 'category', 'all')) {
            for ($i = 0; $i < sizeof($categories); $i++) {
                if (!$user->authorize('com_k2', 'add', 'category', $categories[$i]->value)) {
                    $categories[$i]->disable = true;
                }
            }
        }
        $categories_options = @array_merge($categories_option, $categories);
        $lists['categories'] = JHTML::_('select.genericlist', $categories_options, 'catid', '', 'value', 'text', $item->catid);
        JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables');
        $category =& JTable::getInstance('K2Category', 'Table');
        $category->load($item->catid);
        require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'extrafield.php';
        $extraFieldModel = new K2ModelExtraField();
        if ($category->extraFieldsGroup) {
            $extraFields = $extraFieldModel->getExtraFieldsByGroup($category->extraFieldsGroup);
        } else {
            $extraFields = NULL;
        }
        for ($i = 0; $i < sizeof($extraFields); $i++) {
            $extraFields[$i]->element = $extraFieldModel->renderExtraField($extraFields[$i], $item->id);
        }
        if ($item->id) {
            $item->attachments = $model->getAttachments($item->id);
        } else {
            $item->attachments = NULL;
        }
        $tags = $model->getAvailableTags($item->id);
        $lists['tags'] = JHTML::_('select.genericlist', $tags, 'tags', 'multiple="multiple" size="10" ', 'id', 'name');
        if (isset($item->id)) {
            $item->tags = $model->getCurrentTags($item->id);
            $lists['selectedTags'] = JHTML::_('select.genericlist', $item->tags, 'selectedTags[]', 'multiple="multiple" size="10" ', 'id', 'name');
        } else {
            $lists['selectedTags'] = '<select size="10" multiple="multiple" id="selectedTags" name="selectedTags[]"></select>';
        }
        if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) {
            $item->image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg';
        }
        if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_S.jpg')) {
            $item->thumb = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_S.jpg';
        }
        $lists['metadata'] = new JParameter($item->metadata);
        JPluginHelper::importPlugin('k2');
        $dispatcher =& JDispatcher::getInstance();
        $K2PluginsItemContent = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'content'));
        $this->assignRef('K2PluginsItemContent', $K2PluginsItemContent);
        $K2PluginsItemImage = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'image'));
        $this->assignRef('K2PluginsItemImage', $K2PluginsItemImage);
        $K2PluginsItemGallery = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'gallery'));
        $this->assignRef('K2PluginsItemGallery', $K2PluginsItemGallery);
        $K2PluginsItemVideo = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'video'));
        $this->assignRef('K2PluginsItemVideo', $K2PluginsItemVideo);
        $K2PluginsItemExtraFields = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'extra-fields'));
        $this->assignRef('K2PluginsItemExtraFields', $K2PluginsItemExtraFields);
        $K2PluginsItemAttachments = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'attachments'));
        $this->assignRef('K2PluginsItemAttachments', $K2PluginsItemAttachments);
        $K2PluginsItemOther = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'other'));
        $this->assignRef('K2PluginsItemOther', $K2PluginsItemOther);
        $form = new JParameter('', JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'item.xml');
        $form->loadINI($item->params);
        $this->assignRef('form', $form);
        $this->assignRef('extraFields', $extraFields);
        $this->assignRef('options', $options);
        $this->assignRef('row', $item);
        $this->assignRef('lists', $lists);
        $this->assignRef('params', $params);
        parent::display();
    }
Ejemplo n.º 14
0
 function display($tpl = null)
 {
     $mainframe =& JFactory::getApplication();
     $db =& JFactory::getDBO();
     jimport('joomla.filesystem.file');
     jimport('joomla.html.pane');
     JHTML::_('behavior.keepalive');
     JRequest::setVar('hidemainmenu', 1);
     $document =& JFactory::getDocument();
     $document->addScript(JURI::root() . 'administrator/components/com_k2/lib/Autocompleter.js');
     $document->addScript(JURI::root() . 'administrator/components/com_k2/lib/observer.js');
     $document->addScript(JURI::root() . 'administrator/components/com_k2/lib/nicEdit.js');
     $js = "function initExtraFieldsEditor(){\n\t\t\t\$\$('.k2ExtraFieldEditor').each(function(element) {\n\t\t\t\tvar id = element.id;\n\t\t\t\tif (typeof JContentEditor != 'undefined') {\n\t\t\t\t\tif (tinyMCE.get(id)) {\n\t\t\t\t\t\ttinymce.EditorManager.remove(tinyMCE.get(id));\n\t\t\t\t\t}\n\t\t\t\t\ttinyMCE.execCommand('mceAddControl', false, id);\n\t\t\t\t} else {\n\t\t\t\t\tnew nicEditor({fullPanel: true, maxHeight: 180, iconsPath: '" . JURI::root() . "administrator/components/com_k2/images/system/nicEditorIcons.gif'}).panelInstance(element.getProperty('id'));\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tfunction syncExtraFieldsEditor(){\n\t\t\t\$\$('.k2ExtraFieldEditor').each(function(element){\n\t\t\t\teditor = nicEditors.findEditor(element.getProperty('id'));\n\t\t\t\tif(typeof editor != 'undefined'){\n\t\t\t\t\teditor.saveContent();\n\t\t\t\t}\n    \t\t});\n\t\t}\n\t\t";
     $document->addScriptDeclaration($js);
     $model =& $this->getModel();
     $item = $model->getData();
     JFilterOutput::objectHTMLSafe($item, ENT_QUOTES, 'video');
     $user =& JFactory::getUser();
     if (JTable::isCheckedOut($user->get('id'), $item->checked_out)) {
         $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The item'), $item->title);
         $mainframe->redirect('index.php?option=com_k2', $msg);
     }
     if ($item->id) {
         $item->checkout($user->get('id'));
     } else {
         $createdate =& JFactory::getDate();
         $item->published = 1;
         $item->publish_up = $createdate->toUnix();
         $item->publish_down = JText::_('Never');
         $item->created = $createdate->toUnix();
         $item->modified = $db->getNullDate();
     }
     $item->created = JHTML::_('date', $item->created, '%Y-%m-%d %H:%M:%S');
     $item->publish_up = JHTML::_('date', $item->publish_up, '%Y-%m-%d %H:%M:%S');
     if (JHTML::_('date', $item->publish_down, '%Y') <= 1969 || $item->publish_down == $db->getNullDate()) {
         $item->publish_down = JText::_('Never');
     } else {
         $item->publish_down = JHTML::_('date', $item->publish_down, '%Y-%m-%d %H:%M:%S');
     }
     $params =& JComponentHelper::getParams('com_k2');
     $wysiwyg =& JFactory::getEditor();
     if ($params->get("mergeEditors")) {
         if (JString::strlen($item->fulltext) > 1) {
             $textValue = $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext;
         } else {
             $textValue = $item->introtext;
         }
         $text = $wysiwyg->display('text', $textValue, '100%', '400', '40', '5');
         $this->assignRef('text', $text);
     } else {
         $introtext = $wysiwyg->display('introtext', $item->introtext, '100%', '400', '40', '5', array('readmore'));
         $this->assignRef('introtext', $introtext);
         $fulltext = $wysiwyg->display('fulltext', $item->fulltext, '100%', '400', '40', '5', array('readmore'));
         $this->assignRef('fulltext', $fulltext);
     }
     $lists = array();
     $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $item->published);
     $lists['access'] = JHTML::_('list.accesslevel', $item);
     $query = "SELECT ordering AS value, title AS text FROM #__k2_items WHERE catid={$item->catid}";
     $lists['ordering'] = JHTML::_('list.specificordering', $item, $item->id, $query);
     if (!$item->id) {
         $item->catid = $mainframe->getUserStateFromRequest('com_k2itemsfilter_category', 'catid', 0, 'int');
     }
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'categories.php';
     $categoriesModel = new K2ModelCategories();
     $categories = $categoriesModel->categoriesTree();
     $lists['catid'] = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox"', 'value', 'text', $item->catid);
     $lists['checkSIG'] = $model->checkSIG();
     $lists['checkAllVideos'] = $model->checkAllVideos();
     $remoteVideo = false;
     $providerVideo = false;
     $embedVideo = false;
     if (stristr($item->video, 'remote}') !== false) {
         $remoteVideo = true;
         $options['startOffset'] = 1;
     }
     $providers = $model->getVideoProviders();
     if (count($providers)) {
         foreach ($providers as $provider) {
             $providersOptions[] = JHTML::_('select.option', $provider, $provider);
             if (stristr($item->video, "{{$provider}}") !== false) {
                 $providerVideo = true;
                 $options['startOffset'] = 2;
             }
         }
     }
     if (JString::substr($item->video, 0, 1) !== '{') {
         $embedVideo = true;
         $options['startOffset'] = 3;
     }
     $lists['uploadedVideo'] = !$remoteVideo && !$providerVideo && !$embedVideo ? true : false;
     if ($lists['uploadedVideo'] || $item->video == '') {
         $options['startOffset'] = 0;
     }
     $lists['remoteVideo'] = $remoteVideo ? preg_replace('%\\{[a-z0-9-_]*\\}(.*)\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
     $lists['remoteVideoType'] = $remoteVideo ? preg_replace('%\\{([a-z0-9-_]*)\\}.*\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
     $lists['providerVideo'] = $providerVideo ? preg_replace('%\\{[a-z0-9-_]*\\}(.*)\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
     $lists['providerVideoType'] = $providerVideo ? preg_replace('%\\{([a-z0-9-_]*)\\}.*\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
     $lists['embedVideo'] = $embedVideo ? $item->video : '';
     if (isset($providersOptions)) {
         $lists['providers'] = JHTML::_('select.genericlist', $providersOptions, 'videoProvider', '', 'value', 'text', $lists['providerVideoType']);
     }
     JPluginHelper::importPlugin('content', 'jw_sigpro');
     JPluginHelper::importPlugin('content', 'jw_allvideos');
     $dispatcher =& JDispatcher::getInstance();
     $params->set('galleries_rootfolder', 'media/k2/galleries');
     $params->set('thb_width', '150');
     $params->set('thb_height', '120');
     $params->set('popup_engine', 'mootools_slimbox');
     $params->set('enabledownload', '0');
     $item->text = $item->gallery;
     $dispatcher->trigger('onPrepareContent', array(&$item, &$params, null));
     $item->gallery = $item->text;
     if (!$embedVideo) {
         $params->set('vfolder', 'media/k2/videos');
         if (JString::strpos($item->video, 'remote}')) {
             preg_match("#}(.*?){/#s", $item->video, $matches);
             if (JString::substr($matches[1], 0, 7) != 'http://') {
                 $item->video = JString::str_ireplace($matches[1], JURI::root() . $matches[1], $item->video);
             }
         }
         $item->text = $item->video;
         $dispatcher->trigger('onPrepareContent', array(&$item, &$params, null));
         $item->video = $item->text;
     } else {
         // no nothing
     }
     if (isset($item->created_by)) {
         $author =& JUser::getInstance($item->created_by);
         $item->author = $author->name;
     }
     if (isset($item->modified_by)) {
         $moderator =& JUser::getInstance($item->modified_by);
         $item->moderator = $moderator->name;
     }
     if ($item->id) {
         $active = $item->created_by;
     } else {
         $active = $user->id;
     }
     $lists['authors'] = JHTML::_('list.users', 'created_by', $active, false);
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'categories.php';
     $categoriesModel = new K2ModelCategories();
     $categories_option[] = JHTML::_('select.option', 0, JText::_('- Select category -'));
     $categories = $categoriesModel->categoriesTree(NUll, true, false);
     $categories_options = @array_merge($categories_option, $categories);
     $lists['categories'] = JHTML::_('select.genericlist', $categories_options, 'catid', '', 'value', 'text', $item->catid);
     JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables');
     $category =& JTable::getInstance('K2Category', 'Table');
     $category->load($item->catid);
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'extrafield.php';
     $extraFieldModel = new K2ModelExtraField();
     if ($item->id) {
         $extraFields = $extraFieldModel->getExtraFieldsByGroup($category->extraFieldsGroup);
     } else {
         $extraFields = NULL;
     }
     for ($i = 0; $i < sizeof($extraFields); $i++) {
         $extraFields[$i]->element = $extraFieldModel->renderExtraField($extraFields[$i], $item->id);
     }
     if ($item->id) {
         $item->attachments = $model->getAttachments($item->id);
         $rating = $model->getRating();
         if (is_null($rating)) {
             $item->ratingSum = 0;
             $item->ratingCount = 0;
         } else {
             $item->ratingSum = (int) $rating->rating_sum;
             $item->ratingCount = (int) $rating->rating_count;
         }
     } else {
         $item->attachments = NULL;
         $item->ratingSum = 0;
         $item->ratingCount = 0;
     }
     if ($user->gid < 24 && $params->get('lockTags')) {
         $params->set('taggingSystem', 0);
     }
     $tags = $model->getAvailableTags($item->id);
     $lists['tags'] = JHTML::_('select.genericlist', $tags, 'tags', 'multiple="multiple" size="10" ', 'id', 'name');
     if (isset($item->id)) {
         $item->tags = $model->getCurrentTags($item->id);
         $lists['selectedTags'] = JHTML::_('select.genericlist', $item->tags, 'selectedTags[]', 'multiple="multiple" size="10" ', 'id', 'name');
     } else {
         $lists['selectedTags'] = '<select size="10" multiple="multiple" id="selectedTags" name="selectedTags[]"></select>';
     }
     $lists['metadata'] = new JParameter($item->metadata);
     if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) {
         $item->image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg';
     }
     if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_S.jpg')) {
         $item->thumb = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_S.jpg';
     }
     JPluginHelper::importPlugin('k2');
     $dispatcher =& JDispatcher::getInstance();
     $K2PluginsItemContent = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'content'));
     $this->assignRef('K2PluginsItemContent', $K2PluginsItemContent);
     $K2PluginsItemImage = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'image'));
     $this->assignRef('K2PluginsItemImage', $K2PluginsItemImage);
     $K2PluginsItemGallery = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'gallery'));
     $this->assignRef('K2PluginsItemGallery', $K2PluginsItemGallery);
     $K2PluginsItemVideo = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'video'));
     $this->assignRef('K2PluginsItemVideo', $K2PluginsItemVideo);
     $K2PluginsItemExtraFields = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'extra-fields'));
     $this->assignRef('K2PluginsItemExtraFields', $K2PluginsItemExtraFields);
     $K2PluginsItemAttachments = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'attachments'));
     $this->assignRef('K2PluginsItemAttachments', $K2PluginsItemAttachments);
     $K2PluginsItemOther = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'other'));
     $this->assignRef('K2PluginsItemOther', $K2PluginsItemOther);
     $form = new JParameter('', JPATH_COMPONENT . DS . 'models' . DS . 'item.xml');
     $form->loadINI($item->params);
     $this->assignRef('form', $form);
     $this->assignRef('extraFields', $extraFields);
     $this->assignRef('options', $options);
     $this->assignRef('row', $item);
     $this->assignRef('lists', $lists);
     $this->assignRef('params', $params);
     $this->assignRef('user', $user);
     JRequest::getInt('cid') ? $title = JText::_('Edit Item') : ($title = JText::_('Add Item'));
     JToolBarHelper::title($title, 'k2.png');
     JToolBarHelper::save();
     JToolBarHelper::custom('saveAndNew', 'save.png', 'save_f2.png', 'Save &amp; New', false);
     JToolBarHelper::apply();
     JToolBarHelper::cancel();
     parent::display($tpl);
 }
Ejemplo n.º 15
0
	/**
	 * @return array
	 */
	public function k2Categories()
	{
		global $_CB_framework;

		$listCategories				=	array();

		if ( $this->isK2Installed() ) {
			require_once( $_CB_framework->getCfg( 'absolute_path' ) . '/administrator/components/com_k2/models/categories.php' );

			$categoryModel			=	new K2ModelCategories();

			$categories				=	$categoryModel->categoriesTree( null, true, true );

			if ( $categories ) foreach ( $categories as $category ) {
				$listCategories[]	=	moscomprofilerHTML::makeOption( (string) $category->value, $category->text );
			}
		}

		return $listCategories;
	}
Ejemplo n.º 16
0
 public function getTagCloud()
 {
     // Get database
     $db = $this->getDbo();
     // Get query
     $query = $db->getQuery(true);
     // Select tag id
     $query->select($db->quoteName('tag') . '.*');
     // counter
     $query->select('COUNT(' . $db->quoteName('tag.id') . ') AS ' . $db->quoteName('counter'));
     // From statement
     $query->from($db->quoteName('#__k2_tags', 'tag'));
     // Tags should be published
     $query->where($db->quoteName('tag.state') . ' = 1');
     // Join over the reference table
     $query->leftJoin($db->quoteName('#__k2_tags_xref', 'xref') . ' ON ' . $db->quoteName('xref.tagId') . ' = ' . $db->quoteName('tag.id'));
     // Join over the items table
     $query->leftJoin($db->quoteName('#__k2_items', 'item') . ' ON ' . $db->quoteName('item.id') . ' = ' . $db->quoteName('xref.itemId'));
     // Items should be published
     $query->where($db->quoteName('item.state') . ' = 1');
     // Handle categories
     $categories = K2ModelCategories::getCategoryFilter($this->getState('categories'), $this->getState('recursive'), true);
     // user cannot see any category return empty data
     if (empty($categories)) {
         return array();
     }
     // Apply the filter to the query
     $query->where($db->quoteName('item.catid') . ' IN (' . implode(',', $categories) . ')');
     // Check access level
     $viewlevels = array_unique(JFactory::getUser()->getAuthorisedViewLevels());
     $query->where($db->quoteName('item.access') . ' IN (' . implode(',', $viewlevels) . ')');
     // Check publish up/down
     $date = JFactory::getDate()->toSql();
     $query->where('(' . $db->quoteName('item.publish_up') . ' = ' . $db->Quote($db->getNullDate()) . ' OR ' . $db->quoteName('item.publish_up') . ' <= ' . $db->Quote($date) . ')');
     $query->where('(' . $db->quoteName('item.publish_down') . ' = ' . $db->Quote($db->getNullDate()) . ' OR ' . $db->quoteName('item.publish_down') . ' >= ' . $db->Quote($date) . ')');
     // Group by tag Id
     $query->order($db->quoteName('counter') . ' DESC');
     // Group by tag Id
     $query->group($db->quoteName('tag.id'));
     // Set query
     $db->setQuery($query, 0, (int) $this->getState('limit'));
     // Get rows
     $rows = $db->loadObjectList();
     // Return
     return $rows;
 }
    function render(&$params)
    {
        $mainframe =& JFactory::getApplication();
        // load the admin language file
        $lang =& JFactory::getLanguage();
        if ($lang->getTag() != 'en-GB') {
            // Loads English language file as fallback (for undefined stuff in other language file)
            $lang->load('plg_editors-xtd_articlesanywhere', JPATH_ADMINISTRATOR, 'en-GB');
        }
        $lang->load('plg_editors-xtd_articlesanywhere', JPATH_ADMINISTRATOR, null, 1);
        // load the content language file
        $lang->load('com_content', JPATH_ADMINISTRATOR);
        require_once JPATH_ADMINISTRATOR . '/components/com_content/helpers/content.php';
        //$k2 = JFile::exists( JPATH_ADMINISTRATOR.'/components/com_k2/admin.k2.php' );
        $k2 = 0;
        $content_type = JRequest::getCmd('content_type', $params->content_type);
        // Initialize variables
        $db =& JFactory::getDBO();
        $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
        $filter = null;
        // Get some variables from the request
        $filter_order = $mainframe->getUserStateFromRequest('articlesanywhere_filter_order', 'filter_order', 'ordering', 'cmd');
        $filter_order_Dir = $mainframe->getUserStateFromRequest('articlesanywhere_filter_order_Dir', 'filter_order_Dir', '', 'word');
        $filter_featured = $mainframe->getUserStateFromRequest('articlesanywhere_filter_featured', 'filter_featured', '', 'int');
        $filter_category = $mainframe->getUserStateFromRequest('articlesanywhere_filter_category', 'filter_category', 0, 'int');
        $filter_author = $mainframe->getUserStateFromRequest('articlesanywhere_filter_author', 'filter_author', 0, 'int');
        $filter_state = $mainframe->getUserStateFromRequest('articlesanywhere_filter_state', 'filter_state', '', 'word');
        $search = $mainframe->getUserStateFromRequest('articlesanywhere_search', 'search', '', 'string');
        $search = JString::strtolower($search);
        $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
        $limitstart = $mainframe->getUserStateFromRequest('articlesanywhere_limitstart', 'limitstart', 0, 'int');
        // In case limit has been changed, adjust limitstart accordingly
        $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
        $lists = array();
        // search filter
        $lists['search'] = $search;
        // table ordering
        if ($k2 && $content_type == 'k2') {
            if ($filter_order == 'section' || $filter_order == 'frontpage') {
                $filter_order = 'ordering';
                $filter_order_Dir = '';
            }
        } else {
            if ($filter_order == 'featured') {
                $filter_order = 'ordering';
                $filter_order_Dir = '';
            }
        }
        $lists['order_Dir'] = $filter_order_Dir;
        $lists['order'] = $filter_order;
        if ($k2 && $content_type == 'k2') {
            // load the k2 language file
            $lang->load('com_k2', JPATH_ADMINISTRATOR);
            define('JPATH_COMPONENT', JPATH_ADMINISTRATOR . '/components/com_k2');
            define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_COMPONENT);
            /* FILTERS */
            // featured filter
            $filter_featured_options[] = JHTML::_('select.option', -1, JText::_('- Select featured state -'));
            $filter_featured_options[] = JHTML::_('select.option', 1, JText::_('Featured'));
            $filter_featured_options[] = JHTML::_('select.option', 0, JText::_('Not featured'));
            $lists['featured'] = JHTML::_('select.genericlist', $filter_featured_options, 'filter_featured', 'onchange="this.form.submit();"', 'value', 'text', $filter_featured);
            // get list of categories for dropdown filter
            require_once JPATH_COMPONENT . '/models/categories.php';
            $categoriesModel = new K2ModelCategories();
            $categories_option[] = JHTML::_('select.option', 0, JText::_('- Select category -'));
            $categories = $categoriesModel->categoriesTree();
            $categories_options = @array_merge($categories_option, $categories);
            $lists['categories'] = JHTML::_('select.genericlist', $categories_options, 'filter_category', 'onchange="this.form.submit();"', 'value', 'text', $filter_category);
            // get list of Authors for dropdown filter
            $query = 'SELECT c.created_by, u.name
				FROM #__k2_items AS c
				LEFT JOIN #__users AS u ON u.id = c.created_by
				WHERE c.published <> -1
				AND c.published <> -2
				AND trash = 0
				GROUP BY u.id
				ORDER BY c.id DESC
				';
            $authors[] = JHTML::_('select.option', '0', '- ' . JText::_('Select Author') . ' -', 'created_by', 'name');
            $db->setQuery($query);
            $authors = array_merge($authors, $db->loadObjectList());
            $lists['authors'] = JHTML::_('select.genericlist', $authors, 'filter_author', 'class="inputbox" size="1" onchange="this.form.submit( );"', 'created_by', 'name', $filter_author);
            // state filter
            $filter_state_options[] = JHTML::_('select.option', -1, JText::_('- Select publishing state -'));
            $filter_state_options[] = JHTML::_('select.option', 1, JText::_('Published'));
            $filter_state_options[] = JHTML::_('select.option', 0, JText::_('Unpublished'));
            $lists['state'] = JHTML::_('select.genericlist', $filter_state_options, 'filter_state', 'onchange="this.form.submit();"', 'value', 'text', $filter_state);
            /* ITEMS */
            $where = array();
            $where[] = 'c.published != -2 AND c.trash = 0';
            if ($search) {
                if ($params->adminSearch == 'full') {
                    $where[] = 'MATCH(c.title, c.introtext, c.`fulltext`, c.extra_fields_search, c.image_caption,c.image_credits,c.video_caption,c.video_credits,c.metadesc,c.metakey) AGAINST(' . $db->quote($search) . ')';
                } else {
                    $where[] = 'MATCH( c.title ) AGAINST(' . $db->quote($search) . ')';
                }
            }
            if ($filter_state && $filter_state > -1) {
                $where[] = 'c.published = ' . (int) $filter_state;
            }
            if ($filter_featured && $filter_featured > -1) {
                $where[] = 'c.featured = ' . (int) $filter_featured;
            }
            if ($filter_category && $filter_category > 0) {
                require_once JPATH_SITE . '/components/com_k2/models/itemlist.php';
                $categories = K2ModelItemlist::getCategoryChilds($filter_category);
                $categories[] = $filter_category;
                $categories = @array_unique($categories);
                $sql = @implode(',', $categories);
                $where[] = 'c.catid IN (' . $sql . ')';
            }
            if ($filter_author && $filter_author > 0) {
                $where[] = 'c.created_by=' . (int) $filter_author;
            }
            // Build the where clause of the content record query
            $where = count($where) ? ' WHERE ' . implode(' AND ', $where) : '';
            // Get the total number of records
            $query = 'SELECT COUNT( * )
				FROM #__k2_items as c
				LEFT JOIN #__k2_categories AS cc ON cc.id = c.catid
				' . $where;
            $db->setQuery($query);
            $total = $db->loadResult();
            // Create the pagination object
            jimport('joomla.html.pagination');
            $page = new JPagination($total, $limitstart, $limit);
            if ($filter_order == 'ordering') {
                $order = ' ORDER BY category, ordering ' . $filter_order_Dir;
            } else {
                $order = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir . ', category, ordering';
            }
            $query = 'SELECT c.*, g.name AS accesslevel, cc.name AS category, v.name AS author,
				w.name as moderator, u.name AS editor
				FROM #__k2_items as c
				LEFT JOIN #__k2_categories AS cc ON cc.id = c.catid
				LEFT JOIN #__groups AS g ON g.id = c.access
				LEFT JOIN #__users AS u ON u.id = c.checked_out
				LEFT JOIN #__users AS v ON v.id = c.created_by
				LEFT JOIN #__users AS w ON w.id = c.modified_by
				' . $where . $order;
            $db->setQuery($query, $page->limitstart, $page->limit);
            $rows = $db->loadObjectList();
            // If there is a database query error, throw a HTTP 500 and exit
            if ($db->getErrorNum()) {
                JError::raiseError(500, $db->stderr());
                return false;
            }
        } else {
            $options = JHtml::_('category.options', 'com_content');
            array_unshift($options, JHtml::_('select.option', '0', '- ' . JText::_('Select Category') . ' -'));
            $lists['categories'] = JHTML::_('select.genericlist', $options, 'filter_category', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_category);
            //$lists['categories'] = JHTML::_( 'select.genericlist',  $categories, 'filter_category', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_category );
            // get list of Authors for dropdown filter
            $query = 'SELECT c.created_by, u.name
				FROM #__content AS c
				LEFT JOIN #__users AS u ON u.id = c.created_by
				WHERE c.state <> -1
				AND c.state <> -2
				GROUP BY u.id
				ORDER BY u.id DESC
				';
            $db->setQuery($query);
            $options = $db->loadObjectList();
            array_unshift($options, JHtml::_('select.option', '0', '- ' . JText::_('Select Author') . ' -', 'created_by', 'name'));
            $lists['authors'] = JHTML::_('select.genericlist', $options, 'filter_author', 'class="inputbox" size="1" onchange="this.form.submit( );"', 'created_by', 'name', $filter_author);
            // state filter
            $lists['state'] = JHTML::_('grid.state', $filter_state, 'Published', 'Unpublished', 'Archived');
            /* ITEMS */
            $where = array();
            $where[] = 'c.state != -2';
            /*
             * Add the filter specific information to the where clause
             */
            // Category filter
            if ($filter_category > 0) {
                $where[] = 'c.catid = ' . (int) $filter_category;
            }
            // Author filter
            if ($filter_author > 0) {
                $where[] = 'c.created_by = ' . (int) $filter_author;
            }
            // Content state filter
            if ($filter_state) {
                if ($filter_state == 'P') {
                    $where[] = 'c.state = 1';
                } else {
                    if ($filter_state == 'U') {
                        $where[] = 'c.state = 0';
                    } else {
                        if ($filter_state == 'A') {
                            $where[] = 'c.state = -1';
                        } else {
                            $where[] = 'c.state != -2';
                        }
                    }
                }
            }
            // Keyword filter
            if ($search) {
                $where[] = '(LOWER( c.title ) LIKE ' . $db->quote('%' . $db->getEscaped($search, true) . '%', false) . ' OR c.id = ' . (int) $search . ' )';
            }
            // Build the where clause of the content record query
            $where = count($where) ? ' WHERE ' . implode(' AND ', $where) : '';
            // Get the total number of records
            $query = 'SELECT COUNT( * )
				FROM #__content AS c
				LEFT JOIN #__categories AS cc ON cc.id = c.catid
				' . $where;
            $db->setQuery($query);
            $total = $db->loadResult();
            // Create the pagination object
            jimport('joomla.html.pagination');
            $page = new JPagination($total, $limitstart, $limit);
            if ($filter_order == 'ordering') {
                $order = ' ORDER BY category, ordering ' . $filter_order_Dir;
            } else {
                $order = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir . ', category, ordering';
            }
            // Get the articles
            $query = 'SELECT c.*, c.state as published, g.title AS accesslevel, cc.title AS category, u.name AS editor, f.content_id AS frontpage, v.name AS author
				FROM #__content AS c
				LEFT JOIN #__categories AS cc ON cc.id = c.catid
				LEFT JOIN #__viewlevels AS g ON g.id = c.access
				LEFT JOIN #__users AS u ON u.id = c.checked_out
				LEFT JOIN #__users AS v ON v.id = c.created_by
				LEFT JOIN #__content_frontpage AS f ON f.content_id = c.id
				' . $where . $order;
            $db->setQuery($query, $page->limitstart, $page->limit);
            $rows = $db->loadObjectList();
            // If there is a database query error, throw a HTTP 500 and exit
            if ($db->getErrorNum()) {
                JError::raiseError(500, $db->stderr());
                return false;
            }
        }
        $this->outputHTML($params, $rows, $client, $page, $lists, $k2);
    }
Ejemplo n.º 18
0
 function move()
 {
     $mainframe =& JFactory::getApplication();
     JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables');
     $cid = JRequest::getVar('cid');
     foreach ($cid as $id) {
         $row =& JTable::getInstance('K2Item', 'Table');
         $row->load($id);
         $rows[] = $row;
     }
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'categories.php';
     $categoriesModel = new K2ModelCategories();
     $categories = $categoriesModel->categoriesTree();
     $lists['categories'] = JHTML::_('select.genericlist', $categories, 'category', 'class="inputbox" size="8"', 'value', 'text');
     $this->assignRef('rows', $rows);
     $this->assignRef('lists', $lists);
     JToolBarHelper::title(JText::_('K2_MOVE_ITEMS'), 'k2.png');
     JToolBarHelper::custom('saveMove', 'save.png', 'save_f2.png', 'K2_SAVE', false);
     JToolBarHelper::cancel();
     parent::display();
 }
Ejemplo n.º 19
0
 public static function getSearch($params)
 {
     $application = JFactory::getApplication();
     $search = new stdClass();
     $search->action = JRoute::_(K2HelperRoute::getSearchRoute());
     $search->text = $params->get('text', JText::_('K2_SEARCH'));
     $search->width = intval($params->get('width', 20));
     $search->maxLength = $search->width > 20 ? $search->width : 20;
     $search->button = $params->get('button');
     $search->buttonText = htmlspecialchars($params->get('button_text', JText::_('K2_SEARCH')));
     $search->imageButton = $params->get('imagebutton');
     $search->buttonPosition = $params->get('button_pos', 'left');
     $search->sef = $application->getCfg('sef');
     $search->filter = '';
     $filter = $params->get('category_id');
     if ($filter && isset($filter->enabled) && $filter->enabled) {
         $model = K2Model::getInstance('Categories');
         $categories = K2ModelCategories::getCategoryFilter($filter->categories, $filter->recursive, true);
         $search->filter = implode(',', $categories);
     }
     if ($params->get('liveSearch')) {
         $document = JFactory::getDocument();
         if ($document->getType() == 'html') {
             $document->addScript(JURI::root(true) . '/media/k2app/vendor/underscore/underscore-min.js?v=3.0.0');
             $document->addScriptDeclaration('var K2Site = "' . JURI::root(true) . '";');
         }
     }
     return $search;
 }
Ejemplo n.º 20
0
 /**
  *  view display method
  * @return void
  **/
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('COM_K2IMPORT_TITLE'), 'generic.png');
     k2importToolbarHelper::upload();
     k2importToolbarHelper::export();
     k2importToolbarHelper::instructions();
     $document =& JFactory::getDocument();
     $document->addStyleSheet('components/com_k2import/css/k2import.css');
     $document->addScript('../media/system/js/modal.js');
     $document->addStyleSheet('../media/system/css/modal.css');
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         JHtml::_('behavior.framework', true);
         JHTML::_('behavior.modal');
         jimport('joomla.html.html.behavior');
     }
     //TODO shouldn't this go to the .js file?
     $js = "\n\t\twindow.addEvent('domready', function(){\n\t\t\t\t\$('browseSrv').addEvent('click', function(e){\n\t\t\te = new Event(e).stop();\n\t\t\tSqueezeBox.initialize();\n\t\t\tSqueezeBox.fromElement(this, {\n\t\t\t\thandler: 'iframe',\n\t\t\t\turl: '" . JURI::base() . "index.php?option=com_k2import&view=item&task=filebrowser&type=text&tmpl=component',\n\t\t\t\tsize: {x: 590, y: 400}\n\t\t\t});\n\t\t})\n\t\t\n\t\t\n\t\t\$('k2ResetButton').addEvent('click', function(e){\n\t\t\te.preventDefault();\n\t\t\t\$('adminForm').search.value = '';\n\t\t\t\$('adminForm').filter_trash.options[0].selected = true;\n\t\t\t\$('adminForm').filter_state.options[0].selected = true;\n\t\t\t\$('adminForm').language.options[0].selected = true;\t\t\n\t\t\t\$('adminForm').action = 'index.php';\n\t\t\t\$('adminForm').task.value = ''; \n\t\t\tthis.form.submit();\n\t\t\t});\n\t\n\t\t\$('k2SubmitButton').addEvent('click', function(e){\t\n\t\t\t\$('adminForm').action = 'index.php';\n\t\t\t\$('adminForm').task.value = ''; \n\t\t\tthis.form.submit();\n\t\t\t});\n\t\t\n\t\t\n\t\t});\n\t\t";
     $document->addScriptDeclaration($js);
     //---------------------------------------
     //the pieces starting from here is taken from K2:
     //administrator/components/com_k2/views/categories/view.html.php
     /**
      * @version		$Id: view.html.php 1112 2011-10-11 14:34:53Z lefteris.kavadas $
      * @package		K2
      * @author		JoomlaWorks http://www.joomlaworks.gr
      * @copyright	Copyright (c) 2006 - 2011 JoomlaWorks Ltd. All rights reserved.
      * @license		GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
      */
     //Artur Neumann www.individual-it.net info@individual-it.net  29.02.2012
     //changed all K2_* textes
     $mainframe =& JFactory::getApplication();
     $user =& JFactory::getUser();
     $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', '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');
     $filter_category = $mainframe->getUserStateFromRequest($option . $view . 'filter_category', 'filter_category', 0, 'int');
     $filter_state = $mainframe->getUserStateFromRequest($option . $view . 'filter_state', 'filter_state', -1, 'int');
     $language = $mainframe->getUserStateFromRequest($option . $view . 'language', 'language', '', 'string');
     $search = $mainframe->getUserStateFromRequest($option . $view . 'search', 'search', '', 'string');
     $search = JString::strtolower($search);
     //Artur Neumann www.individual-it.net info@individual-it.net  21.02.2012
     //importing the model directly
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'categories.php';
     //Artur Neumann www.individual-it.net info@individual-it.net  21.02.2012
     //$model = & $this->getModel(); doesn't work for us so we take it directly
     $model = new K2ModelCategories();
     $categories = $model->getData();
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'category.php';
     $categoryModel = new K2ModelCategory();
     $params =& JComponentHelper::getParams('com_k2');
     $this->assignRef('params', $params);
     if ($params->get('showItemsCounterAdmin')) {
         for ($i = 0; $i < sizeof($categories); $i++) {
             $categories[$i]->numOfItems = $categoryModel->countCategoryItems($categories[$i]->id);
         }
     }
     $this->assignRef('rows', $categories);
     $total = $model->getTotal();
     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_trash_options[] = JHTML::_('select.option', 0, JText::_('COM_K2IMPORT_CURRENT'));
     $filter_trash_options[] = JHTML::_('select.option', 1, JText::_('COM_K2IMPORT_TRASHED'));
     $lists['trash'] = JHTML::_('select.genericlist', $filter_trash_options, 'filter_trash', '', 'value', 'text', $filter_trash);
     $filter_state_options[] = JHTML::_('select.option', -1, JText::_('COM_K2IMPORT_SELECT_STATE'));
     $filter_state_options[] = JHTML::_('select.option', 1, JText::_('COM_K2IMPORT_PUBLISHED'));
     $filter_state_options[] = JHTML::_('select.option', 0, JText::_('COM_K2IMPORT_UNPUBLISHED'));
     $lists['state'] = JHTML::_('select.genericlist', $filter_state_options, 'filter_state', '', 'value', 'text', $filter_state);
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $languages = JHTML::_('contentlanguage.existing', true, true);
         array_unshift($languages, JHTML::_('select.option', '', JText::_('COM_K2IMPORT_SELECT_LANGUAGE')));
         $lists['language'] = JHTML::_('select.genericlist', $languages, 'language', '', 'value', 'text', $language);
     }
     $this->assignRef('lists', $lists);
     //Artur Neumann www.individual-it.net info@individual-it.net 20.02.2012
     //deleted K2 toolbar because not needed in my extension
     $this->assignRef('filter_trash', $filter_trash);
     $template = $mainframe->getTemplate();
     $this->assignRef('template', $template);
     $ordering = ($this->lists['order'] == 'c.ordering' || $this->lists['order'] == 'c.parent, c.ordering') && !$this->filter_trash;
     $this->assignRef('ordering', $ordering);
     //
     parent::display($tpl);
 }
Ejemplo n.º 21
0
	/**
	 * @param bool $raw
	 * @return array
	 */
	static public function getCategoriesList( $raw = false )
	{
		global$_CB_framework;

		static $cache					=	null;

		if ( ! isset( $cache ) ) {
			$plugin						=	cbconsultationsClass::getPlugin();
			$sectionid					=	$plugin->params->get( 'consultation_k2_section', null );

			/** @noinspection PhpIncludeInspection */
			require_once( $_CB_framework->getCfg( 'absolute_path' ) . '/administrator/components/com_k2/models/categories.php' );

			/** @noinspection PhpUndefinedClassInspection */
			$categories					=	new K2ModelCategories();

			/** @noinspection PhpUndefinedMethodInspection */
			$cache						=	$categories->categoriesTree( null, true, true);
			$remove						=	array();

			if ( $sectionid ) {
				$section				=	JTable::getInstance( 'K2Category', 'Table' );

				$section->load( (int) $sectionid );

				/** @noinspection PhpUndefinedMethodInspection */
				$children				=	$categories->categoriesTree( $section, true, true );

				if ( $children ) foreach ( $children as $child ) {
					$remove[]			=	$child->value;
				}

				$remove[]				=	$sectionid;
			}

			foreach ( $cache as $k => $row ) {
				if ( in_array( $row->value, $remove ) ) {
					unset( $cache[$k] );
				} else {
					$cache[$k]->text	=	preg_replace( '/(?:- ){0,3}/', '', $cache[$k]->text, 1 );
				}
			}

			$cache						=	array_values( $cache );
		}

		$rows							=	$cache;

		if ( $rows ) {
			if ( $raw === true ) {
				$categories				=	array();

				foreach ( $rows as $row ) {
					$categories[]		=	(int) $row->value;
				}

				$rows					=	$categories;
			}
		} else {
			$rows						=	array();
		}

		return $rows;
	}
Ejemplo n.º 22
0
 /**
  * getCategoryFilter method.
  *
  * @return array
  */
 public static function getCategoryFilter($categories = null, $recursive = false, $access = false)
 {
     $filter = K2ModelCategories::getAuthorised();
     if ($categories) {
         if (!is_array($categories)) {
             $categories = (array) $categories;
         }
         $categories = array_filter($categories);
         if (count($categories)) {
             if ($recursive) {
                 $children = array();
                 $model = K2Model::getInstance('Categories');
                 foreach ($categories as $categoryId) {
                     $key = (string) $access . '|' . (string) $categoryId;
                     if (!isset(self::$cache['trees'][$key])) {
                         $model->setState('site', $access);
                         $model->setState('root', $categoryId);
                         $rows = $model->getRows();
                         self::$cache['trees'][$key] = $rows;
                     } else {
                         $rows = self::$cache['trees'][$key];
                     }
                     foreach ($rows as $row) {
                         $children[] = $row->id;
                     }
                 }
                 $categories = array_merge($categories, $children);
                 $categories = array_unique($categories);
             }
             if ($access) {
                 $filter = array_intersect($categories, K2ModelCategories::getAuthorised());
             } else {
                 $filter = $categories;
             }
         }
     }
     return array_unique($filter);
 }