Esempio 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);
 }
Esempio 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);
 }
Esempio 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);
 }
Esempio 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);
 }
Esempio n. 5
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);
 }
Esempio n. 6
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;
	}
Esempio 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;
	}
Esempio n. 8
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);
    }
    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);
    }
Esempio n. 10
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();
 }
Esempio n. 11
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();
 }
Esempio 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);
 }
Esempio 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();
    }
Esempio 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);
 }
Esempio 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;
	}