function display($tpl = null) { //initialise variables $app = JFactory::getApplication(); $option = JRequest::getVar('option'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $cparams = JComponentHelper::getParams('com_flexicontent'); $print_logging_info = $cparams->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } JHTML::_('behavior.tooltip'); //get vars $filter_order = $app->getUserStateFromRequest($option . '.tags.filter_order', 'filter_order', 't.name', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest($option . '.tags.filter_order_Dir', 'filter_order_Dir', '', 'word'); $filter_state = $app->getUserStateFromRequest($option . '.tags.filter_state', 'filter_state', '*', 'word'); $filter_assigned = $app->getUserStateFromRequest($option . '.tags.filter_assigned', 'filter_assigned', '*', 'word'); $search = $app->getUserStateFromRequest($option . '.tags.search', 'search', '', 'string'); $search = FLEXI_J16GE ? $db->escape(trim(JString::strtolower($search))) : $db->getEscaped(trim(JString::strtolower($search))); //add css and submenu to document $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css'); if (FLEXI_J30GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css'); } else { if (FLEXI_J16GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css'); } else { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css'); } } // Get User's Global Permissions $perms = FlexicontentHelperPerm::getPerm(); // Create Submenu (and also check access to current view) FLEXISubmenu('CanTags'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_TAGS'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'tags'); $document->setTitle($doc_title . ' - ' . $site_title); // Create the toolbar $js = "window.addEvent('domready', function(){"; $contrl = FLEXI_J16GE ? "tags." : ""; $toolbar = JToolBar::getInstance('toolbar'); if ($perms->CanConfig) { $btn_task = ''; $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent&view=tags&layout=import&tmpl=component'; if (FLEXI_J30GE || !FLEXI_J16GE) { // Layout of Popup button broken in J3.1, add in J1.5 it generates duplicate HTML tag id (... just for validation), so add manually $js .= "\n\t\t\t\t\tjQuery('#toolbar-import a.toolbar, #toolbar-import button')\n\t\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 430, y: 500}, onClose: function() {}}');\n\t\t\t\t"; JToolBarHelper::custom($btn_task, 'import.png', 'import_f2.png', 'FLEXI_IMPORT', false); JHtml::_('behavior.modal', '#toolbar-import a.toolbar, #toolbar-import button'); } else { $toolbar->appendButton('Popup', 'import', JText::_('FLEXI_IMPORT'), str_replace('&', '&', $popup_load_url), 430, 500); } JToolBarHelper::divider(); JToolBarHelper::spacer(); } JToolBarHelper::publishList($contrl . 'publish'); JToolBarHelper::unpublishList($contrl . 'unpublish'); JToolBarHelper::addNew($contrl . 'add'); JToolBarHelper::editList($contrl . 'edit'); //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove'); // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag) $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE')); $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM'); $btn_task = $contrl . 'remove'; $extra_js = ""; flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); if ($perms->CanConfig) { JToolBarHelper::divider(); JToolBarHelper::spacer(); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } $js .= "});"; $document->addScriptDeclaration($js); //Get data from the model if ($print_logging_info) { $start_microtime = microtime(true); } $rows = $this->get('Data'); if ($print_logging_info) { @($fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } // Get assigned items $model = $this->getModel(); $rowids = array(); foreach ($rows as $row) { $rowids[] = $row->id; } if ($print_logging_info) { $start_microtime = microtime(true); } $rowtotals = $model->getAssignedItems($rowids); if ($print_logging_info) { @($fc_run_times['execute_sec_queries'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } foreach ($rows as $row) { $row->nrassigned = isset($rowtotals[$row->id]) ? $rowtotals[$row->id]->nrassigned : 0; } $pagination = $this->get('Pagination'); $lists = array(); //build arphaned/assigned filter $assigned = array(); $assigned[] = JHTML::_('select.option', '', '- ' . JText::_('FLEXI_ALL_TAGS') . ' -'); $assigned[] = JHTML::_('select.option', 'O', JText::_('FLEXI_ORPHANED')); $assigned[] = JHTML::_('select.option', 'A', JText::_('FLEXI_ASSIGNED')); $lists['assigned'] = JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="inputbox" size="1" onchange="submitform( );"', 'value', 'text', $filter_assigned); //publish unpublished filter $lists['state'] = JHTML::_('grid.state', $filter_state); // search filter $lists['search'] = $search; // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; //assign data to template $this->assignRef('lists', $lists); $this->assignRef('rows', $rows); $this->assignRef('pagination', $pagination); parent::display($tpl); }
/** * Creates the Entrypage * * @since 1.0 */ function display($tpl = null) { //initialise variables $app = JFactory::getApplication(); $option = JRequest::getVar('option'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $cparams = JComponentHelper::getParams('com_flexicontent'); $print_logging_info = $cparams->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } JHTML::_('behavior.tooltip'); //get vars $filter_order = $app->getUserStateFromRequest($option . '.types.filter_order', 'filter_order', 't.name', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest($option . '.types.filter_order_Dir', 'filter_order_Dir', '', 'word'); $filter_state = $app->getUserStateFromRequest($option . '.types.filter_state', 'filter_state', '*', 'word'); $search = $app->getUserStateFromRequest($option . '.types.search', 'search', '', 'string'); $search = FLEXI_J16GE ? $db->escape(trim(JString::strtolower($search))) : $db->getEscaped(trim(JString::strtolower($search))); //add css and submenu to document $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css'); if (FLEXI_J30GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css'); } else { if (FLEXI_J16GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css'); } else { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css'); } } // Get User's Global Permissions $perms = FlexicontentHelperPerm::getPerm(); // Create Submenu (and also check access to current view) FLEXISubmenu('CanTypes'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_TYPES'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'types'); $document->setTitle($doc_title . ' - ' . $site_title); // Create the toolbar $contrl = FLEXI_J16GE ? "types." : ""; JToolBarHelper::custom($contrl . 'copy', 'copy.png', 'copy_f2.png', 'FLEXI_COPY'); JToolBarHelper::divider(); JToolBarHelper::spacer(); JToolBarHelper::publishList($contrl . 'publish'); JToolBarHelper::unpublishList($contrl . 'unpublish'); JToolBarHelper::addNew($contrl . 'add'); JToolBarHelper::editList($contrl . 'edit'); //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove'); // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag) $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE')); $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM'); $btn_task = $contrl . 'remove'; $extra_js = ""; flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); if ($perms->CanConfig) { JToolBarHelper::divider(); JToolBarHelper::spacer(); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } // Get data from the model if ($print_logging_info) { $start_microtime = microtime(true); } if (FLEXI_J16GE) { $rows = $this->get('Items'); } else { $rows = $this->get('Data'); } if ($print_logging_info) { @($fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } // Create type's parameters foreach ($rows as $type) { $type->config = FLEXI_J16GE ? new JRegistry($type->config) : new JParameter($type->config); } // Create pagination object $pagination = $this->get('Pagination'); $lists = array(); //publish unpublished filter $lists['state'] = JHTML::_('grid.state', $filter_state); // search filter $lists['search'] = $search; // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; //assign data to template $this->assignRef('lists', $lists); $this->assignRef('rows', $rows); $this->assignRef('pagination', $pagination); parent::display($tpl); }
function display($tpl = null) { //initialise variables global $globalcats; $app = JFactory::getApplication(); $option = JRequest::getVar('option'); $view = JRequest::getVar('view'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $cparams = JComponentHelper::getParams('com_flexicontent'); $print_logging_info = $cparams->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } JHTML::_('behavior.tooltip'); //get vars $order_property = !FLEXI_J16GE ? 'c.ordering' : 'c.lft'; $filter_order = $app->getUserStateFromRequest($option . '.' . $view . '.filter_order', 'filter_order', $order_property, 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest($option . '.' . $view . '.filter_order_Dir', 'filter_order_Dir', '', 'word'); $filter_state = $app->getUserStateFromRequest($option . '.' . $view . '.filter_state', 'filter_state', '', 'string'); $filter_cats = $app->getUserStateFromRequest($option . '.' . $view . '.filter_cats', 'filter_cats', '', 'int'); $filter_level = $app->getUserStateFromRequest($option . '.' . $view . '.filter_level', 'filter_level', '', 'string'); $filter_access = $app->getUserStateFromRequest($option . '.' . $view . '.filter_access', 'filter_access', '', 'string'); if (FLEXI_J16GE) { $filter_language = $app->getUserStateFromRequest($option . '.' . $view . '.filter_language', 'filter_language', '', 'string'); } $search = $app->getUserStateFromRequest($option . '.' . $view . '.search', 'search', '', 'string'); $search = FLEXI_J16GE ? $db->escape(trim(JString::strtolower($search))) : $db->getEscaped(trim(JString::strtolower($search))); // Prepare the document: add css files, etc $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css'); if (FLEXI_J30GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css'); } else { if (FLEXI_J16GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css'); } else { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css'); } } // Get User's Global Permissions $perms = FlexicontentHelperPerm::getPerm(); // Create Submenu (and also check access to current view) FLEXISubmenu('CanCats'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_CATEGORIES'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'fc_categories'); $document->setTitle($doc_title . ' - ' . $site_title); // ****************** // Create the toolbar // ****************** $js = "window.addEvent('domready', function(){"; $contrl = FLEXI_J16GE ? "categories." : ""; $contrl_singular = FLEXI_J16GE ? "category." : ""; $toolbar = JToolBar::getInstance('toolbar'); // Copy Parameters $btn_task = ''; $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent&view=categories&layout=params&tmpl=component'; if (FLEXI_J30GE || !FLEXI_J16GE) { // Layout of Popup button broken in J3.1, add in J1.5 it generates duplicate HTML tag id (... just for validation), so add manually $js .= "\n\t\t\t\tjQuery('#toolbar-params a.toolbar, #toolbar-params button')\n\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 600, y: 440}, onClose: function() {}}');\n\t\t\t"; JToolBarHelper::custom($btn_task, 'params.png', 'params_f2.png', 'FLEXI_COPY_PARAMS', false); JHtml::_('behavior.modal', '#toolbar-params a.toolbar, #toolbar-params button'); } else { $toolbar->appendButton('Popup', 'params', JText::_('FLEXI_COPY_PARAMS'), str_replace('&', '&', $popup_load_url), 600, 440); } //if (FLEXI_J16GE) // $toolbar->appendButton('Popup', 'move', JText::_('FLEXI_COPY_MOVE'), JURI::base().'index.php?option=com_flexicontent&view=categories&layout=batch&tmpl=component', 800, 440); JToolBarHelper::divider(); $add_divider = false; if (!FLEXI_J16GE || $user->authorise('core.create', 'com_flexicontent')) { $cancreate_cat = true; } else { $usercats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true, $check_published = true, $specific_catids = false, $find_first = true); $cancreate_cat = count($usercats) > 0; } if ($cancreate_cat) { JToolBarHelper::addNew($contrl_singular . 'add'); $add_divider = true; } if (!FLEXI_J16GE || ($user->authorise('core.edit', 'com_flexicontent') || $user->authorise('core.edit.own', 'com_flexicontent'))) { JToolBarHelper::editList($contrl_singular . 'edit'); $add_divider = true; } if (FLEXI_J16GE && $user->authorise('core.admin', 'checkin')) { JToolBarHelper::checkin($contrl . 'checkin'); $add_divider = true; } if ($add_divider) { JToolBarHelper::divider(); } $add_divider = false; if (!FLEXI_J16GE || ($user->authorise('core.edit.state', 'com_flexicontent') || $user->authorise('core.edit.state.own', 'com_flexicontent'))) { JToolBarHelper::publishList($contrl . 'publish'); JToolBarHelper::unpublishList($contrl . 'unpublish'); JToolBarHelper::divider(); if (FLEXI_J16GE) { JToolBarHelper::archiveList($contrl . 'archive'); } } $add_divider = false; if (!FLEXI_J16GE || $filter_state == -2 && $user->authorise('core.delete', 'com_flexicontent')) { //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove'); // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag) $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE')); $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM'); $btn_task = $contrl . 'remove'; $extra_js = ""; flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); $add_divider = true; } elseif ($user->authorise('core.edit.state', 'com_flexicontent')) { JToolBarHelper::trash($contrl . 'trash'); $add_divider = true; } if ($add_divider) { JToolBarHelper::divider(); } if ($perms->CanConfig) { //JToolBarHelper::custom($contrl.'rebuild', 'refresh.png', 'refresh_f2.png', 'JTOOLBAR_REBUILD', false); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } $js .= "});"; $document->addScriptDeclaration($js); //Get data from the model if ($print_logging_info) { $start_microtime = microtime(true); } if (FLEXI_J16GE) { $rows = $this->get('Items'); } else { $rows = $this->get('Data'); } if ($print_logging_info) { @($fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } // Get assigned items $model = $this->getModel(); $rowids = array(); foreach ($rows as $row) { $rowids[] = $row->id; } if ($print_logging_info) { $start_microtime = microtime(true); } $rowtotals = $model->getAssignedItems($rowids); if ($print_logging_info) { @($fc_run_times['execute_sec_queries'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } foreach ($rows as $row) { $row->nrassigned = isset($rowtotals[$row->id]) ? $rowtotals[$row->id]->nrassigned : 0; } // Parse configuration for every category foreach ($rows as $cat) { $cat->config = FLEXI_J16GE ? new JRegistry($cat->config) : new JParameter($cat->config); } if (FLEXI_J16GE) { $this->state = $this->get('State'); // Preprocess the list of items to find ordering divisions. foreach ($rows as &$item) { $this->ordering[$item->parent_id][] = $item->id; } } $pagination = $this->get('Pagination'); $categories =& $globalcats; $lists['copyid'] = flexicontent_cats::buildcatselect($categories, 'copycid', '', 2, 'class="inputbox"', false, true, $actions_allowed = array('core.edit')); $lists['destid'] = flexicontent_cats::buildcatselect($categories, 'destcid[]', '', false, 'class="inputbox" size="15" multiple="true"', false, true, $actions_allowed = array('core.edit')); // ******************* // Create Form Filters // ******************* // filter by a category (it's subtree will be displayed) $categories = $globalcats; $lists['cats'] = flexicontent_cats::buildcatselect($categories, 'filter_cats', $filter_cats, 2, 'class="inputbox" size="1" onchange="this.form.submit();"', $check_published = true, $check_perms = false); // filter depth level $options = array(); $options[] = JHtml::_('select.option', '', JText::_('FLEXI_SELECT_MAX_DEPTH')); for ($i = 1; $i <= 10; $i++) { $options[] = JHtml::_('select.option', $i, $i); } $fieldname = $elementid = 'filter_level'; $attribs = ' size="1" class="inputbox" onchange="this.form.submit();" '; $lists['level'] = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_level, $elementid, $translate = true); // filter publication state if (FLEXI_J16GE) { $options = JHtml::_('jgrid.publishedOptions'); array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_SELECT_PUBLISHED'))); $fieldname = $elementid = 'filter_state'; $attribs = ' size="1" class="inputbox" onchange="Joomla.submitform()" '; $lists['state'] = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_state, $elementid, $translate = true); } else { $lists['state'] = JHTML::_('grid.state', $filter_state); } if (FLEXI_J16GE) { // filter access level $options = JHtml::_('access.assetgroups'); array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_SELECT_ACCESS'))); $fieldname = $elementid = 'filter_access'; $attribs = ' size="1" class="inputbox" onchange="Joomla.submitform()" '; $lists['access'] = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_access, $elementid, $translate = true); // filter language $lists['language'] = flexicontent_html::buildlanguageslist('filter_language', 'size="1" class="inputbox" onchange="submitform();"', $filter_language, 2); } else { // filter access level $options = array(); $options[] = JHtml::_('select.option', '', JText::_('FLEXI_SELECT_ACCESS_LEVEL')); $options[] = JHtml::_('select.option', '0', JText::_('Public')); $options[] = JHtml::_('select.option', '1', JText::_('Registered')); $options[] = JHtml::_('select.option', '2', JText::_('SPECIAL')); $fieldname = $elementid = 'filter_access'; $attribs = ' size="1" class="inputbox" onchange="this.form.submit()" '; $lists['access'] = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_access, $elementid, $translate = true); } // filter search word $lists['search'] = $search; // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; $ordering = $lists['order'] == $order_property ? $order_property : ''; //assign data to template $this->assignRef('lists', $lists); $this->assignRef('rows', $rows); $this->assignRef('perms', $perms); if (FLEXI_J16GE) { $this->assignRef('orderingx', $ordering); } else { $this->assignRef('ordering', $ordering); } $this->assignRef('pagination', $pagination); $this->assignRef('user', $user); parent::display($tpl); }
function display($tpl = null) { // ******************** // Initialise variables // ******************** $app = JFactory::getApplication(); $jinput = $app->input; $option = $jinput->get('option', '', 'cmd'); $view = $jinput->get('view', '', 'cmd'); $cparams = JComponentHelper::getParams('com_flexicontent'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); // Get model $model = $this->getModel(); $print_logging_info = $cparams->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } // *********** // Get filters // *********** $count_filters = 0; // various filters $filter_fieldtype = $model->getState('filter_fieldtype'); $filter_assigned = $model->getState('filter_assigned'); $filter_type = $model->getState('filter_type'); $filter_state = $model->getState('filter_state'); $filter_access = $model->getState('filter_access'); if ($filter_assigned) { $count_filters++; } if ($filter_fieldtype) { $count_filters++; } if ($filter_state) { $count_filters++; } if ($filter_access) { $count_filters++; } if ($filter_type) { $count_filters++; } // ordering filters $filter_order = $model->getState('filter_order'); $filter_order_Dir = $model->getState('filter_order_Dir'); // text search $search = $model->getState('search'); $search = $db->escape(trim(JString::strtolower($search))); // **************************** // Important usability messages // **************************** if ($cparams->get('show_usability_messages', 1)) { $notice_content_type_order = $app->getUserStateFromRequest($option . '.' . $view . '.notice_content_type_order', 'notice_content_type_order', 0, 'int'); if (!$notice_content_type_order) { $app->setUserState($option . '.' . $view . '.notice_content_type_order', 1); $app->enqueueMessage(JText::_('FLEXI_DEFINE_FIELD_ORDER_FILTER_BY_TYPE'), 'message'); $app->enqueueMessage(JText::_('FLEXI_DEFINE_FIELD_ORDER_FILTER_WITHOUT_TYPE'), 'message'); $app->enqueueMessage(JText::_('FLEXI_USABILITY_MESSAGES_TURN_OFF'), 'message'); } } // ************************** // Add css and js to document // ************************** flexicontent_html::loadFramework('select2'); //JHTML::_('behavior.tooltip'); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VHASH); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VHASH); $js = "jQuery(document).ready(function(){"; // ***************************** // Get user's global permissions // ***************************** $perms = FlexicontentHelperPerm::getPerm(); // ************************ // Create Submenu & Toolbar // ************************ // Create Submenu (and also check access to current view) FLEXISubmenu('CanFields'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_FIELDS'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'fields'); $document->setTitle($doc_title . ' - ' . $site_title); if ($perms->CanEditField) { $ctrl_task = '&task=fields.selectsearchflag'; $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent' . $ctrl_task . '&tmpl=component'; $btn_name = 'basicindex'; $btn_task = ''; $full_js = ';'; $extra_js = ''; flexicontent_html::addToolBarButton(JText::_('FLEXI_TOGGLE_SEARCH_FLAG'), $btn_name, $full_js, $msg_alert = JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm = '', $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = false, $btn_class = ""); $js .= "\n\t\t\t\tjQuery('#toolbar-basicindex a.toolbar, #toolbar-basicindex button')\n\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 800, y: 340}, onClose: function() {}}');\n\t\t\t"; } $contrl = "fields."; if ($perms->CanCopyFields) { JToolBarHelper::custom($contrl . 'copy', 'copy.png', 'copy_f2.png', 'FLEXI_COPY'); JToolBarHelper::custom($contrl . 'copy_wvalues', 'copy_wvalues.png', 'copy_f2.png', 'FLEXI_COPY_WITH_VALUES'); JToolBarHelper::divider(); } JToolBarHelper::publishList($contrl . 'publish'); JToolBarHelper::unpublishList($contrl . 'unpublish'); if ($perms->CanAddField) { JToolBarHelper::addNew($contrl . 'add'); } if ($perms->CanEditField) { JToolBarHelper::editList($contrl . 'edit'); } if ($perms->CanDeleteField) { //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove'); // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag) $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE')); $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM'); $btn_task = $contrl . 'remove'; $extra_js = ""; flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); } JToolbarHelper::checkin($contrl . 'checkin'); /* JToolBarHelper::divider(); JToolBarHelper::spacer(); $btn_name = 'basicindex'; $btn_task = 'fields.toggleprop'; $extra_js = "document.getElementById('adminForm').elements['propname'].value='issearch';"; flexicontent_html::addToolBarButton( 'FLEXI_TOGGLE_TEXT_SEARCHABLE', $btn_name, $full_js='', $msg_alert=JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm='', $btn_task, $extra_js, $btn_list=true, $btn_menu=true, $btn_confirm=false, $btn_class="btn-info"); $btn_name = 'basicfilter'; $btn_task = 'fields.toggleprop'; $extra_js = "document.getElementById('adminForm').elements['propname'].value='isfilter';"; flexicontent_html::addToolBarButton( 'FLEXI_TOGGLE_FILTERABLE', $btn_name, $full_js='', $msg_alert=JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm='', $btn_task, $extra_js, $btn_list=true, $btn_menu=true, $btn_confirm=false, $btn_class="btn-info"); $btn_name = 'advindex'; $btn_task = 'fields.toggleprop'; $extra_js = "document.getElementById('adminForm').elements['propname'].value='isadvsearch';"; flexicontent_html::addToolBarButton( 'FLEXI_TOGGLE_ADV_TEXT_SEARCHABLE', $btn_name, $full_js='', $msg_alert=JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm='', $btn_task, $extra_js, $btn_list=true, $btn_menu=true, $btn_confirm=false, $btn_class="btn-info"); $btn_name = 'advfilter'; $btn_task = 'fields.toggleprop'; $extra_js = "document.getElementById('adminForm').elements['propname'].value='isadvfilter';"; flexicontent_html::addToolBarButton( 'FLEXI_TOGGLE_ADV_FILTERABLE', $btn_name, $full_js='', $msg_alert=JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm='', $btn_task, $extra_js, $btn_list=true, $btn_menu=true, $btn_confirm=false, $btn_class="btn-info"); */ $appsman_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'appsman'; if (file_exists($appsman_path)) { $btn_icon = 'icon-download'; $btn_name = 'download'; $btn_task = 'appsman.exportxml'; $extra_js = " var f=document.getElementById('adminForm'); f.elements['view'].value='appsman'; jQuery('<input>').attr({type: 'hidden', name: 'table', value: 'flexicontent_fields'}).appendTo(jQuery(f));"; flexicontent_html::addToolBarButton('Export now', $btn_name, $full_js = '', $msg_alert = '', $msg_confirm = 'Export now as XML', $btn_task, $extra_js, $btn_list = false, $btn_menu = true, $btn_confirm = true, $btn_class = "btn-warning", $btn_icon); $btn_icon = 'icon-box-add'; $btn_name = 'box-add'; $btn_task = 'appsman.addtoexport'; $extra_js = " var f=document.getElementById('adminForm'); f.elements['view'].value='appsman'; jQuery('<input>').attr({type: 'hidden', name: 'table', value: 'flexicontent_fields'}).appendTo(jQuery(f));"; flexicontent_html::addToolBarButton('Add to export', $btn_name, $full_js = '', $msg_alert = '', $msg_confirm = 'Add to export list', $btn_task, $extra_js, $btn_list = false, $btn_menu = true, $btn_confirm = true, $btn_class = "btn-warning", $btn_icon); } /*$btn_icon = 'icon-download'; $btn_name = 'download'; $btn_task = 'fields.exportsql'; $extra_js = ""; flexicontent_html::addToolBarButton( 'Export SQL', $btn_name, $full_js='', $msg_alert='', $msg_confirm='Field\'s configuration will be exported as SQL', $btn_task, $extra_js, $btn_list=false, $btn_menu=true, $btn_confirm=true, $btn_class="btn-warning", $btn_icon); $btn_icon = 'icon-download'; $btn_name = 'download'; $btn_task = 'fields.exportcsv'; $extra_js = ""; flexicontent_html::addToolBarButton( 'Export CSV', $btn_name, $full_js='', $msg_alert='', $msg_confirm='Field\'s configuration will be exported as CSV', $btn_task, $extra_js, $btn_list=false, $btn_menu=true, $btn_confirm=true, $btn_class="btn-warning", $btn_icon);*/ if ($perms->CanConfig) { JToolBarHelper::divider(); JToolBarHelper::spacer(); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } $js .= "});"; $document->addScriptDeclaration($js); // Get data from the model if ($print_logging_info) { $start_microtime = microtime(true); } $rows = $this->get('Items'); $allrows = $this->get('AllItems'); if ($print_logging_info) { @($fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } $pagination = $this->get('Pagination'); // Pagination $types = $this->get('Typeslist'); // Content types $fieldTypes = flexicontent_db::getFieldTypes($_grouped = true, $_usage = true, $_published = false); // Field types with content type ASSIGNMENT COUNTING $lists = array(); // build item-type filter $lists['filter_type'] = ($filter_type || 1 ? '<label class="label">' . JText::_('FLEXI_TYPE') . '</label>' : '') . flexicontent_html::buildtypesselect($types, 'filter_type', $filter_type, '-', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'filter_type'); // build orphaned/assigned filter $assigned = array(); $assigned[] = JHTML::_('select.option', '', '-'); $assigned[] = JHTML::_('select.option', 'O', JText::_('FLEXI_ORPHANED')); $assigned[] = JHTML::_('select.option', 'A', JText::_('FLEXI_ASSIGNED')); $lists['assigned'] = ($filter_assigned || 1 ? '<label class="label">' . JText::_('FLEXI_ASSIGNED') . '</label>' : '') . JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_assigned); // build field-type filter $ALL = mb_strtoupper(JText::_('FLEXI_ALL'), 'UTF-8') . ' : '; $fftypes = array(); $fftypes[] = array('value' => '', 'text' => '-'); $fftypes[] = array('value' => 'BV', 'text' => $ALL . JText::_('FLEXI_BACKEND_FIELDS')); $fftypes[] = array('value' => 'C', 'text' => $ALL . JText::_('FLEXI_CORE_FIELDS')); $fftypes[] = array('value' => 'NC', 'text' => $ALL . JText::_('FLEXI_NON_CORE_FIELDS')); foreach ($fieldTypes as $field_group => $ft_types) { $fftypes[] = $field_group; foreach ($ft_types as $field_type => $ftdata) { $fftypes[] = array('value' => $ftdata->field_type, 'text' => '-' . $ftdata->assigned . '- ' . $ftdata->friendly); } $fftypes[] = ''; } $lists['fftype'] = ($filter_fieldtype || 1 ? '<label class="label">' . JText::_('FLEXI_FIELD_TYPE') . '</label>' : '') . flexicontent_html::buildfieldtypeslist($fftypes, 'filter_fieldtype', $filter_fieldtype, $_grouped ? 1 : 0, 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"'); // build publication state filter $states = array(); $states[] = JHTML::_('select.option', '', '-'); $states[] = JHTML::_('select.option', 'P', JText::_('FLEXI_PUBLISHED')); $states[] = JHTML::_('select.option', 'U', JText::_('FLEXI_UNPUBLISHED')); //$states[] = JHTML::_('select.option', '-2', JText::_( 'FLEXI_TRASHED' ) ); $lists['state'] = ($filter_state || 1 ? '<label class="label">' . JText::_('FLEXI_STATE') . '</label>' : '') . JHTML::_('select.genericlist', $states, 'filter_state', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_state); //JHTML::_('grid.state', $filter_state ); // build access level filter $options = JHtml::_('access.assetgroups'); array_unshift($options, JHtml::_('select.option', '', '-')); $fieldname = $elementid = 'filter_access'; $attribs = 'class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"'; $lists['access'] = ($filter_access || 1 ? '<label class="label">' . JText::_('FLEXI_ACCESS') . '</label>' : '') . JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_access, $elementid, $translate = true); // text search filter $lists['search'] = $search; // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; if ($filter_type == '' || $filter_type == 0) { $ordering = $lists['order'] == 't.ordering'; } else { $ordering = $lists['order'] == 'typeordering'; } //assign data to template $this->assignRef('count_filters', $count_filters); $this->assignRef('permission', $perms); $this->assignRef('filter_type', $filter_type); $this->assignRef('lists', $lists); $this->assignRef('rows', $rows); $this->assignRef('allrows', $allrows); $this->assignRef('types', $types); $this->assignRef('ordering', $ordering); $this->assignRef('pagination', $pagination); $this->assignRef('option', $option); $this->assignRef('view', $view); $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null; parent::display($tpl); }
/** * Creates the Entrypage * * @since 1.0 */ function display($tpl = null) { //initialise variables $app = JFactory::getApplication(); $cparams = JComponentHelper::getParams('com_flexicontent'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $option = JRequest::getVar('option'); FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); flexicontent_html::loadFramework('jQuery'); flexicontent_html::loadFramework('select2'); JHTML::_('behavior.tooltip'); //get vars $filter_assigned = $app->getUserStateFromRequest($option . '.fields.filter_assigned', 'filter_assigned', '', 'word'); $filter_fieldtype = $app->getUserStateFromRequest($option . '.fields.filter_fieldtype', 'filter_fieldtype', '', 'word'); $filter_state = $app->getUserStateFromRequest($option . '.fields.filter_state', 'filter_state', '', 'word'); $filter_type = $app->getUserStateFromRequest($option . '.fields.filter_type', 'filter_type', '', 'int'); $filter_order = $app->getUserStateFromRequest($option . '.fields.filter_order', 'filter_order', 't.ordering', 'cmd'); if ($filter_type && $filter_order == 't.ordering') { $filter_order = $app->setUserState($option . '.fields.filter_order', 'typeordering'); } else { if (!$filter_type && $filter_order == 'typeordering') { $filter_order = $app->setUserState($option . '.fields.filter_order', 't.ordering'); } } $filter_order_Dir = $app->getUserStateFromRequest($option . '.fields.filter_order_Dir', 'filter_order_Dir', 'ASC', 'word'); $search = $app->getUserStateFromRequest($option . '.fields.search', 'search', '', 'string'); $search = FLEXI_J16GE ? $db->escape(trim(JString::strtolower($search))) : $db->getEscaped(trim(JString::strtolower($search))); if ($cparams->get('show_usability_messages', 1)) { $notice_content_type_order = $app->getUserStateFromRequest($option . '.fields.notice_content_type_order', 'notice_content_type_order', 0, 'int'); if (!$notice_content_type_order) { $app->setUserState($option . '.fields.notice_content_type_order', 1); $app->enqueueMessage(JText::_('FLEXI_DEFINE_FIELD_ORDER_FILTER_BY_TYPE'), 'notice'); $app->enqueueMessage(JText::_('FLEXI_DEFINE_FIELD_ORDER_FILTER_WITHOUT_TYPE'), 'notice'); $app->enqueueMessage(JText::_('FLEXI_USABILITY_MESSAGES_TURN_OFF'), 'message'); } } //add css and submenu to document $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css'); if (FLEXI_J30GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css'); } else { if (FLEXI_J16GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css'); } else { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css'); } } $document->addScript(JURI::base() . 'components/com_flexicontent/assets/js/flexi-lib.js'); // Get User's Global Permissions $perms = FlexicontentHelperPerm::getPerm(); // Create Submenu and check access FLEXISubmenu('CanFields'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_FIELDS'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'fields'); $document->setTitle($doc_title . ' - ' . $site_title); // Create the toolbar $contrl = FLEXI_J16GE ? "fields." : ""; if ($perms->CanCopyFields) { JToolBarHelper::custom($contrl . 'copy', 'copy.png', 'copy_f2.png', 'FLEXI_COPY'); JToolBarHelper::custom($contrl . 'copy_wvalues', 'copy_wvalues.png', 'copy_f2.png', 'FLEXI_COPY_WITH_VALUES'); JToolBarHelper::divider(); } JToolBarHelper::publishList($contrl . 'publish'); JToolBarHelper::unpublishList($contrl . 'unpublish'); if ($perms->CanAddField) { JToolBarHelper::addNew($contrl . 'add'); } if ($perms->CanEditField) { JToolBarHelper::editList($contrl . 'edit'); } if ($perms->CanDeleteField) { //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove'); // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag) $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE')); $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM'); $btn_task = $contrl . 'remove'; $extra_js = ""; flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); } JToolBarHelper::divider(); JToolBarHelper::spacer(); $toggle_icon = 'basicindex'; $btn_task = FLEXI_J16GE ? 'fields.toggleprop' : 'toggleprop'; $extra_js = "document.getElementById('adminForm').elements['propname'].value='issearch';"; flexicontent_html::addToolBarButton('FLEXI_TOGGLE_TEXT_SEARCHABLE', $toggle_icon, $full_js = '', $msg_alert = JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm = '', $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = false); $toggle_icon = 'basicfilter'; $btn_task = FLEXI_J16GE ? 'fields.toggleprop' : 'toggleprop'; $extra_js = "document.getElementById('adminForm').elements['propname'].value='isfilter';"; flexicontent_html::addToolBarButton('FLEXI_TOGGLE_FILTERABLE', $toggle_icon, $full_js = '', $msg_alert = JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm = '', $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = false); $toggle_icon = 'advindex'; $btn_task = FLEXI_J16GE ? 'fields.toggleprop' : 'toggleprop'; $extra_js = "document.getElementById('adminForm').elements['propname'].value='isadvsearch';"; flexicontent_html::addToolBarButton('FLEXI_TOGGLE_ADV_TEXT_SEARCHABLE', $toggle_icon, $full_js = '', $msg_alert = JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm = '', $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = false); $toggle_icon = 'advfilter'; $btn_task = FLEXI_J16GE ? 'fields.toggleprop' : 'toggleprop'; $extra_js = "document.getElementById('adminForm').elements['propname'].value='isadvfilter';"; flexicontent_html::addToolBarButton('FLEXI_TOGGLE_ADV_FILTERABLE', $toggle_icon, $full_js = '', $msg_alert = JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm = '', $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = false); if ($perms->CanConfig) { JToolBarHelper::divider(); JToolBarHelper::spacer(); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } //Get data from the model $model = $this->getModel(); $rows = $this->get(FLEXI_J16GE ? 'Items' : 'Data'); $pagination = $this->get('Pagination'); $types = $this->get('Typeslist'); $fieldtypes = $model->getFieldtypes($fields_in_groups = true); $lists = array(); //build backend visible filter $ALL = mb_strtoupper(JText::_('FLEXI_ALL'), 'UTF-8') . ' : '; $fftype = array(); $fftype[] = JHTML::_('select.option', '', '- ' . JText::_('FLEXI_ALL_FIELDS_TYPE') . ' -'); $fftype[] = JHTML::_('select.option', 'BV', $ALL . JText::_('FLEXI_BACKEND_FIELDS')); $fftype[] = JHTML::_('select.option', 'C', $ALL . JText::_('FLEXI_CORE_FIELDS')); $fftype[] = JHTML::_('select.option', 'NC', $ALL . JText::_('FLEXI_NON_CORE_FIELDS')); foreach ($fieldtypes as $field_group => $ft_types) { $fftype[] = JHTML::_('select.optgroup', $field_group); foreach ($ft_types as $field_type => $ftdata) { $field_friendlyname = str_ireplace("FLEXIcontent - ", "", $ftdata->field_friendlyname); $fftype[] = JHTML::_('select.option', $field_type, '-' . $ftdata->assigned . '- ' . $field_friendlyname); } $fftype[] = JHTML::_('select.optgroup', ''); } $lists['fftype'] = JHTML::_('select.genericlist', $fftype, 'filter_fieldtype', 'class="use_select2_lib" size="1" onchange="submitform( );"', 'value', 'text', $filter_fieldtype); if (!FLEXI_J16GE) { $lists['fftype'] = str_replace('<optgroup label="">', '</optgroup>', $lists['fftype']); } //build orphaned/assigned filter $assigned = array(); $assigned[] = JHTML::_('select.option', '', '- ' . JText::_('FLEXI_ALL_FIELDS') . ' -'); $assigned[] = JHTML::_('select.option', 'O', JText::_('FLEXI_ORPHANED')); $assigned[] = JHTML::_('select.option', 'A', JText::_('FLEXI_ASSIGNED')); $lists['assigned'] = JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="use_select2_lib" size="1" onchange="submitform( );"', 'value', 'text', $filter_assigned); //build type select list $lists['filter_type'] = flexicontent_html::buildtypesselect($types, 'filter_type', $filter_type, true, 'class="use_select2_lib" size="1" onchange="submitform( );"', 'filter_type'); //publish unpublished filter $states = array(); $states[] = JHTML::_('select.option', '', JText::_('FLEXI_SELECT_STATE')); $states[] = JHTML::_('select.option', 'P', JText::_('FLEXI_PUBLISHED')); $states[] = JHTML::_('select.option', 'U', JText::_('FLEXI_UNPUBLISHED')); //$lists['state'] = JHTML::_('grid.state', $filter_state ); $lists['state'] = JHTML::_('select.genericlist', $states, 'filter_state', 'class="use_select2_lib" size="1" onchange="submitform( );"', 'value', 'text', $filter_state); // search filter $lists['search'] = $search; // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // filter ordering if ($filter_type == '' || $filter_type == 0) { $ordering = $lists['order'] == 't.ordering'; } else { $ordering = $lists['order'] == 'typeordering'; } //assign data to template $this->assignRef('permission', $perms); $this->assignRef('filter_type', $filter_type); $this->assignRef('lists', $lists); $this->assignRef('rows', $rows); $this->assignRef('ordering', $ordering); $this->assignRef('pagination', $pagination); parent::display($tpl); }
/** * Creates the item page * * @since 1.0 */ function display($tpl = null) { // ******************************** // Initialize variables, flags, etc // ******************************** global $globalcats; $categories = $globalcats; $app = JFactory::getApplication(); $dispatcher = JDispatcher::getInstance(); $document = JFactory::getDocument(); $config = JFactory::getConfig(); $session = JFactory::getSession(); $user = JFactory::getUser(); $db = JFactory::getDBO(); $option = JRequest::getVar('option'); $nullDate = $db->getNullDate(); // Get the COMPONENT only parameters // Get component parameters $params = new JRegistry(); $cparams = JComponentHelper::getParams('com_flexicontent'); $params->merge($cparams); $params = clone JComponentHelper::getParams('com_flexicontent'); // Some flags $enable_translation_groups = flexicontent_db::useAssociations(); //$params->get("enable_translation_groups"); $print_logging_info = $params->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } // ***************** // Load JS/CSS files // ***************** // Add css to document $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VERSION); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VERSION); // Fields common CSS $document->addStyleSheetVersion(JURI::root(true) . '/components/com_flexicontent/assets/css/flexi_form_fields.css', FLEXI_VERSION); // Add JS frameworks flexicontent_html::loadFramework('select2'); $prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable'); flexicontent_html::loadFramework('flexi-lib'); // Add js function to overload the joomla submitform validation JHTML::_('behavior.formvalidation'); // load default validation JS to make sure it is overriden $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VERSION); $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VERSION); // Add js function for custom code used by FLEXIcontent item form $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/itemscreen.js', FLEXI_VERSION); // *********************** // Get data from the model // *********************** if ($print_logging_info) { $start_microtime = microtime(true); } $model = $this->getModel(); $item = $model->getItem(); $form = $this->get('Form'); if ($print_logging_info) { $fc_run_times['get_item_data'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } // *************************** // Get Associated Translations // *************************** if ($enable_translation_groups) { $langAssocs = $this->get('LangAssocs'); } $langs = FLEXIUtilities::getLanguages('code'); // Get item id and new flag $cid = $model->getId(); $isnew = !$cid; // Create and set a unique item id for plugins that needed it if ($cid) { $unique_tmp_itemid = $cid; } else { $unique_tmp_itemid = $app->getUserState('com_flexicontent.edit.item.unique_tmp_itemid'); $unique_tmp_itemid = $unique_tmp_itemid ? $unique_tmp_itemid : date('_Y_m_d_h_i_s_', time()) . uniqid(true); } //print_r($unique_tmp_itemid); JRequest::setVar('unique_tmp_itemid', $unique_tmp_itemid); // Get number of subscribers $subscribers = $model->getSubscribersCount(); // ****************** // Version Panel data // ****************** // Get / calculate some version related variables $versioncount = $model->getVersionCount(); $versionsperpage = $params->get('versionsperpage', 10); $pagecount = (int) ceil($versioncount / $versionsperpage); // Data need by version panel: (a) current version page, (b) currently active version $current_page = 1; $k = 1; $allversions = $model->getVersionList(); foreach ($allversions as $v) { if ($k > 1 && ($k - 1) % $versionsperpage == 0) { $current_page++; } if ($v->nr == $item->version) { break; } $k++; } // Finally fetch the version data for versions in current page $versions = $model->getVersionList(($current_page - 1) * $versionsperpage, $versionsperpage); // Create display of average rating $ratings = $model->getRatingDisplay(); // ***************** // Type related data // ***************** // Get available types and the currently selected/requested type $types = $model->getTypeslist(); $typesselected = $model->getTypesselected(); // Get and merge type parameters $tparams = $this->get('Typeparams'); $tparams = new JRegistry($tparams); $params->merge($tparams); // Apply type configuration if it type is set // Get user allowed permissions on the item ... to be used by the form rendering // Also hide parameters panel if user can not edit parameters $perms = $this->_getItemPerms($item); if (!$perms['canparams']) { $document->addStyleDeclaration('#details-options {display:none;}'); } // ****************** // Create the toolbar // ****************** $toolbar = JToolBar::getInstance('toolbar'); $tip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; // SET toolbar title if ($cid) { JToolBarHelper::title(JText::_('FLEXI_EDIT_ITEM'), 'itemedit'); // Editing existing item } else { JToolBarHelper::title(JText::_('FLEXI_NEW_ITEM'), 'itemadd'); // Creating new item } // ************** // Common Buttons // ************** // Applying new item type is a special case that has not loaded custom fieds yet JToolBarHelper::apply($item->type_id ? 'items.apply' : 'items.apply_type', !$isnew ? 'FLEXI_APPLY' : ($typesselected->id ? 'FLEXI_ADD' : 'FLEXI_APPLY_TYPE'), false); /*if (!$isnew || $item->version) flexicontent_html::addToolBarButton( 'FLEXI_FAST_APPLY', $btn_name='apply_ajax', $full_js="Joomla.submitbutton('items.apply_ajax')", $msg_alert='', $msg_confirm='', $btn_task='items.apply_ajax', $extra_js='', $btn_list=false, $btn_menu=true, $btn_confirm=false, $btn_class="".$tip_class, $btn_icon="icon-loop", 'data-placement="bottom" title="Fast saving, without reloading the form. <br/><br/>Note: new files will not be uploaded, <br/>- in such a case please use \'Apply\'"');*/ if (!$isnew || $item->version) { JToolBarHelper::save('items.save'); } if (!$isnew || $item->version) { JToolBarHelper::custom('items.saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false); } JToolBarHelper::cancel('items.cancel'); // *********************** // Add a preview button(s) // *********************** //$_sh404sef = JPluginHelper::isEnabled('system', 'sh404sef') && $config->get('sef'); $_sh404sef = defined('SH404SEF_IS_RUNNING') && $config->get('sef'); if ($cid) { // Domain URL and autologin vars $server = JURI::getInstance()->toString(array('scheme', 'host', 'port')); $autologin = ''; //$params->get('autoflogin', 1) ? '&fcu='.$user->username . '&fcp='.$user->password : ''; // Check if we are in the backend, in the back end we need to set the application to the site app instead // we do not remove 'isAdmin' check so that we can copy later without change, e.g. to a plugin $isAdmin = JFactory::getApplication()->isAdmin(); if ($isAdmin && !$_sh404sef) { JFactory::$application = JApplication::getInstance('site'); } // Create the URL $item_url = FlexicontentHelperRoute::getItemRoute($item->id . ':' . $item->alias, $categories[$item->catid]->slug) . ($item->language != '*' ? '&lang=' . substr($item->language, 0, 2) : ''); $item_url = $_sh404sef ? Sh404sefHelperGeneral::getSefFromNonSef($item_url, $fullyQualified = true, $xhtml = false, $ssl = null) : JRoute::_($item_url); // Check if we are in the backend again // In backend we need to remove administrator from URL as it is added even though we've set the application to the site app if ($isAdmin && !$_sh404sef) { $admin_folder = str_replace(JURI::root(true), '', JURI::base(true)); $item_url = str_replace($admin_folder . '/', '/', $item_url); // Restore application JFactory::$application = JApplication::getInstance('administrator'); } $previewlink = $item_url . (strstr($item_url, '?') ? '&' : '?') . 'preview=1' . $autologin; //$previewlink = str_replace('&', '&', $previewlink); //$previewlink = JRoute::_(JURI::root() . FlexicontentHelperRoute::getItemRoute($item->id.':'.$item->alias, $categories[$item->catid]->slug)) .$autologin; // PREVIEW for latest version if (!$params->get('use_versioning', 1) || $item->version == $item->current_version && $item->version == $item->last_version) { $toolbar->appendButton('Custom', '<button class="preview btn btn-small btn-info spaced-btn" onClick="window.open(\'' . $previewlink . '\');"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('Preview') . '</button>', 'preview'); } else { // Add a preview button for (currently) LOADED version of the item $previewlink_loaded_ver = $previewlink . '&version=' . $item->version; $toolbar->appendButton('Custom', '<button class="preview btn btn-small" onClick="window.open(\'' . $previewlink_loaded_ver . '\');" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('FLEXI_PREVIEW_FORM_LOADED_VERSION') . ' [' . $item->version . ']</button>', 'preview'); // Add a preview button for currently ACTIVE version of the item $previewlink_active_ver = $previewlink . '&version=' . $item->current_version; $toolbar->appendButton('Custom', '<button class="preview btn btn-small" onClick="window.open(\'' . $previewlink_active_ver . '\');" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('FLEXI_PREVIEW_FRONTEND_ACTIVE_VERSION') . ' [' . $item->current_version . ']</button>', 'preview'); // Add a preview button for currently LATEST version of the item $previewlink_last_ver = $previewlink; //'&version='.$item->last_version; $toolbar->appendButton('Custom', '<button class="preview btn btn-small" onClick="window.open(\'' . $previewlink_last_ver . '\');" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('FLEXI_PREVIEW_LATEST_SAVED_VERSION') . ' [' . $item->last_version . ']</button>', 'preview'); } JToolBarHelper::spacer(); JToolBarHelper::divider(); JToolBarHelper::spacer(); } // ************************ // Add modal layout editing // ************************ if ($perms['cantemplates']) { JToolBarHelper::divider(); if (!$isnew || $item->version) { flexicontent_html::addToolBarButton('FLEXI_EDIT_LAYOUT', $btn_name = 'apply_ajax', $full_js = "var url = jQuery(this).attr('data-href'); fc_showDialog(url, 'fc_modal_popup_container'); return false;", $msg_alert = '', $msg_confirm = '', $btn_task = 'items.apply_ajax', $extra_js = '', $btn_list = false, $btn_menu = true, $btn_confirm = false, $btn_class = "btn-info" . $tip_class, $btn_icon = "icon-pencil", 'data-placement="bottom" data-href="index.php?option=com_flexicontent&view=template&type=items&tmpl=component&ismodal=1&folder=' . $item->itemparams->get('ilayout', $tparams->get('ilayout', 'default')) . '" title="Edit the display layout of this item. <br/><br/>Note: this layout maybe assigned to content types or other items, thus changing it will effect them too"'); } } // Check if saving an item that translates an original content in site's default language $site_default = substr(flexicontent_html::getSiteDefaultLang(), 0, 2); $is_content_default_lang = $site_default == substr($item->language, 0, 2); // ***************************************************************************** // Get (CORE & CUSTOM) fields and their VERSIONED values and then // (a) Apply Content Type Customization to CORE fields (label, description, etc) // (b) Create the edit html of the CUSTOM fields by triggering 'onDisplayField' // ***************************************************************************** if ($print_logging_info) { $start_microtime = microtime(true); } $fields = $this->get('Extrafields'); $item->fields =& $fields; if ($print_logging_info) { $fc_run_times['get_field_vals'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } if ($print_logging_info) { $start_microtime = microtime(true); } $jcustom = $app->getUserState('com_flexicontent.edit.item.custom'); //print_r($jcustom); foreach ($fields as $field) { // a. Apply CONTENT TYPE customizations to CORE FIELDS, e.g a type specific label & description // NOTE: the field parameters are already created so there is not need to call this for CUSTOM fields, which do not have CONTENT TYPE customizations if ($field->iscore) { FlexicontentFields::loadFieldConfig($field, $item); } // b. Create field 's editing HTML (the form field) // NOTE: this is DONE only for CUSTOM fields, since form field html is created by the form for all CORE fields, EXCEPTION is the 'text' field (see bellow) if (!$field->iscore) { if (isset($jcustom[$field->name])) { $field->value = array(); foreach ($jcustom[$field->name] as $i => $_val) { $field->value[$i] = $_val; } } $is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id); if ($is_editable) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayField', array(&$field, &$item)); if ($field->untranslatable) { $field->html = (!isset($field->html) ? '<div class="fc-mssg-inline fc-warning" style="margin:0 4px 6px 4px; max-width: unset;">' . JText::_('FLEXI_PLEASE_PUBLISH_THIS_PLUGIN') . '</div><div class="clear"></div>' : '') . '<div class="alert alert-info fc-small fc-iblock" style="margin:0 4px 6px 4px; max-width: unset;">' . JText::_('FLEXI_FIELD_VALUE_IS_NON_TRANSLATABLE') . '</div>' . "\n" . (isset($field->html) ? '<div class="clear"></div>' . $field->html : ''); } } else { if ($field->valueseditable == 1) { $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>'; } else { if ($field->valueseditable == 2) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item)); $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>' . "\n" . $field->display; } else { if ($field->valueseditable == 3) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item)); $field->html = $field->display; } else { if ($field->valueseditable == 4) { $field->html = ''; $field->formhidden = 4; } } } } } } // c. Create main text field, via calling the display function of the textarea field (will also check for tabs) if ($field->field_type == 'maintext') { if (isset($item->item_translations)) { $shortcode = substr($item->language, 0, 2); foreach ($item->item_translations as $lang_id => $t) { if ($shortcode == $t->shortcode) { continue; } $field->name = array('jfdata', $t->shortcode, 'text'); $field->value[0] = html_entity_decode($t->fields->text->value, ENT_QUOTES, 'UTF-8'); FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item)); $t->fields->text->tab_labels = $field->tab_labels; $t->fields->text->html = $field->html; unset($field->tab_labels); unset($field->html); } } $field->name = 'text'; // NOTE: We use the text created by the model and not the text retrieved by the CORE plugin code, which maybe overwritten with JoomFish/Falang data $field->value[0] = $item->text; // do not decode special characters this was handled during saving ! // Render the field's (form) HTML FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item)); } } if ($print_logging_info) { $fc_run_times['render_field_html'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } // ************************* // Get tags used by the item // ************************* $usedtagsIds = $this->get('UsedtagsIds'); // NOTE: This will normally return the already set versioned value of tags ($item->tags) $usedtags = $model->getUsedtagsData($usedtagsIds); // ******************************* // Get categories used by the item // ******************************* if ($isnew) { // Case for preselected main category for new items $maincat = $item->catid ? $item->catid : JRequest::getInt('maincat', 0); if (!$maincat) { $maincat = $app->getUserStateFromRequest($option . '.items.filter_cats', 'filter_cats', '', 'int'); } if ($maincat) { $selectedcats = array($maincat); $item->catid = $maincat; } else { $selectedcats = array(); } if ($tparams->get('cid_default')) { $selectedcats = $tparams->get('cid_default'); } if ($tparams->get('catid_default')) { $item->catid = $tparams->get('catid_default'); } } else { // NOTE: This will normally return the already set versioned value of categories ($item->categories) $selectedcats = $this->get('Catsselected'); } //$selectedcats = $isnew ? array() : $fields['categories']->value; //echo "<br/>row->tags: "; print_r($item->tags); //echo "<br/>usedtagsIds: "; print_r($usedtagsIds); //echo "<br/>usedtags (data): "; print_r($usedtags); //echo "<br/>row->categories: "; print_r($item->categories); //echo "<br/>selectedcats: "; print_r($selectedcats); // ********************************************************************************************* // Build select lists for the form field. Only few of them are used in J1.6+, since we will use: // (a) form XML file to declare them and then (b) getInput() method form field to create them // ********************************************************************************************* // First clean form data, we do this after creating the description field which may contain HTML JFilterOutput::objectHTMLSafe($item, ENT_QUOTES); $lists = array(); // build state list $non_publishers_stategrp = $perms['isSuperAdmin'] || $item->state == -3 || $item->state == -4; $special_privelege_stategrp = $item->state == 2 || $perms['canarchive'] || ($item->state == -2 || $perms['candelete']); $state = array(); // Using <select> groups if ($non_publishers_stategrp || $special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_PUBLISHERS_WORKFLOW_STATES')); } $state[] = JHTML::_('select.option', 1, JText::_('FLEXI_PUBLISHED')); $state[] = JHTML::_('select.option', 0, JText::_('FLEXI_UNPUBLISHED')); $state[] = JHTML::_('select.option', -5, JText::_('FLEXI_IN_PROGRESS')); // States reserved for workflow if ($non_publishers_stategrp) { $state[] = JHTML::_('select.optgroup', ''); $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_NON_PUBLISHERS_WORKFLOW_STATES')); } if ($item->state == -3 || $perms['isSuperAdmin']) { $state[] = JHTML::_('select.option', -3, JText::_('FLEXI_PENDING')); } if ($item->state == -4 || $perms['isSuperAdmin']) { $state[] = JHTML::_('select.option', -4, JText::_('FLEXI_TO_WRITE')); } // Special access states if ($special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', ''); $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_SPECIAL_ACTION_STATES')); } if ($item->state == 2 || $perms['canarchive']) { $state[] = JHTML::_('select.option', 2, JText::_('FLEXI_ARCHIVED')); } if ($item->state == -2 || $perms['candelete']) { $state[] = JHTML::_('select.option', -2, JText::_('FLEXI_TRASHED')); } // Close last <select> group if ($non_publishers_stategrp || $special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', ''); } $fieldname = 'jform[state]'; $elementid = 'jform_state'; $class = 'use_select2_lib'; $attribs = 'class="' . $class . '"'; $lists['state'] = JHTML::_('select.genericlist', $state, $fieldname, $attribs, 'value', 'text', $item->state, $elementid); if (!FLEXI_J16GE) { $lists['state'] = str_replace('<optgroup label="">', '</optgroup>', $lists['state']); } // *** BOF: J2.5 SPECIFIC SELECT LISTS if (FLEXI_J16GE) { // build featured flag $fieldname = 'jform[featured]'; $elementid = 'jform_featured'; /* $options = array(); $options[] = JHTML::_('select.option', 0, JText::_( 'FLEXI_NO' ) ); $options[] = JHTML::_('select.option', 1, JText::_( 'FLEXI_YES' ) ); $attribs = FLEXI_J16GE ? ' style ="float:none!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['featured'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', $item->featured, $elementid); */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $i = 1; $options = array(0 => JText::_('FLEXI_NO'), 1 => JText::_('FLEXI_YES')); $lists['featured'] = ''; foreach ($options as $option_id => $option_label) { $checked = $option_id == $item->featured ? ' checked="checked"' : ''; $elementid_no = $elementid . '_' . $i; if (!$prettycheckable_added) { $lists['featured'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['featured'] .= ' <input type="radio" id="' . $elementid_no . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />'; if (!$prettycheckable_added) { $lists['featured'] .= ' ' . JText::_($option_label) . '</label>'; } $i++; } } // *** EOF: J1.5 SPECIFIC SELECT LISTS // build version approval list $fieldname = 'jform[vstate]'; $elementid = 'jform_vstate'; /* $options = array(); $options[] = JHTML::_('select.option', 1, JText::_( 'FLEXI_NO' ) ); $options[] = JHTML::_('select.option', 2, JText::_( 'FLEXI_YES' ) ); $attribs = FLEXI_J16GE ? ' style ="float:left!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['vstate'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', 2, $elementid); */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $i = 1; $options = array(1 => JText::_('FLEXI_NO'), 2 => JText::_('FLEXI_YES')); $lists['vstate'] = ''; foreach ($options as $option_id => $option_label) { $checked = $option_id == 2 ? ' checked="checked"' : ''; $elementid_no = $elementid . '_' . $i; if (!$prettycheckable_added) { $lists['vstate'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['vstate'] .= ' <input type="radio" id="' . $elementid_no . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />'; if (!$prettycheckable_added) { $lists['vstate'] .= ' ' . JText::_($option_label) . '</label>'; } $i++; } // build field for notifying subscribers if (!$subscribers) { $lists['notify'] = !$isnew ? JText::_('FLEXI_NO_SUBSCRIBERS_EXIST') : ''; } else { // b. Check if notification emails to subscribers , were already sent during current session $subscribers_notified = $session->get('subscribers_notified', array(), 'flexicontent'); if (!empty($subscribers_notified[$item->id])) { $lists['notify'] = JText::_('FLEXI_SUBSCRIBERS_ALREADY_NOTIFIED'); } else { // build favs notify field $fieldname = 'jform[notify]'; $elementid = 'jform_notify'; /* $attribs = FLEXI_J16GE ? ' style ="float:none!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['notify'] = '<input type="checkbox" name="jform[notify]" id="jform_notify" '.$attribs.' /> '. $lbltxt; */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $lbltxt = $subscribers . ' ' . JText::_($subscribers > 1 ? 'FLEXI_SUBSCRIBERS' : 'FLEXI_SUBSCRIBER'); if (!$prettycheckable_added) { $lists['notify'] .= '<label class="fccheckradio_lbl" for="' . $elementid . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . $lbltxt . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['notify'] = ' <input type="checkbox" id="' . $elementid . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="1" ' . $extra_params . ' checked="checked" />'; if (!$prettycheckable_added) { $lists['notify'] .= ' ' . $lbltxt . '</label>'; } } } // Retrieve author configuration $authorparams = flexicontent_db::getUserConfig($user->id); // Get author's maximum allowed categories per item and set js limitation $max_cat_assign = intval($authorparams->get('max_cat_assign', 0)); $document->addScriptDeclaration(' max_cat_assign_fc = ' . $max_cat_assign . '; existing_cats_fc = ["' . implode('","', $selectedcats) . '"]; '); JText::script('FLEXI_TOO_MANY_ITEM_CATEGORIES', true); // Creating categorories tree for item assignment, we use the 'create' privelege $actions_allowed = array('core.create'); // Featured categories form field $featured_cats_parent = $params->get('featured_cats_parent', 0); $featured_cats = array(); $enable_featured_cid_selector = $perms['multicat'] && $perms['canchange_featcat']; if ($featured_cats_parent) { $featured_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $featured_cats_parent, $depth_limit = 0); $disabled_cats = $params->get('featured_cats_parent_disable', 1) ? array($featured_cats_parent) : array(); $featured_sel = array(); foreach ($selectedcats as $item_cat) { if (isset($featured_tree[$item_cat])) { $featured_sel[] = $item_cat; } } $class = "use_select2_lib select2_list_selected"; $attribs = 'class="' . $class . '" multiple="multiple" size="8"'; $attribs .= $enable_featured_cid_selector ? '' : ' disabled="disabled"'; $fieldname = 'jform[featured_cid][]'; $lists['featured_cid'] = ($enable_featured_cid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($featured_tree, $fieldname, $featured_sel, 3, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options = array(), $disabled_cats); } else { // Do not display, if not configured or not allowed to the user $lists['featured_cid'] = false; } // Multi-category form field, for user allowed to use multiple categories $lists['cid'] = ''; $enable_cid_selector = $perms['multicat'] && $perms['canchange_seccat']; if (1) { if ($tparams->get('cid_allowed_parent')) { $cid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $tparams->get('cid_allowed_parent'), $depth_limit = 0); $disabled_cats = $tparams->get('cid_allowed_parent_disable', 1) ? array($tparams->get('cid_allowed_parent')) : array(); } else { $cid_tree =& $categories; $disabled_cats = array(); } // Get author's maximum allowed categories per item and set js limitation $max_cat_assign = !$authorparams ? 0 : intval($authorparams->get('max_cat_assign', 0)); $document->addScriptDeclaration(' max_cat_assign_fc = ' . $max_cat_assign . '; existing_cats_fc = ["' . implode('","', $selectedcats) . '"]; '); $class = "mcat use_select2_lib select2_list_selected"; $class .= $max_cat_assign ? " validate-fccats" : " validate"; $attribs = 'class="' . $class . '" multiple="multiple" size="20"'; $attribs .= $enable_cid_selector ? '' : ' disabled="disabled"'; $fieldname = 'jform[cid][]'; $skip_subtrees = $featured_cats_parent ? array($featured_cats_parent) : array(); $lists['cid'] = ($enable_cid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($cid_tree, $fieldname, $selectedcats, false, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees, $disable_subtrees = array(), $custom_options = array(), $disabled_cats); } else { if (count($selectedcats) > 1) { foreach ($selectedcats as $catid) { $cat_titles[$catid] = $globalcats[$catid]->title; } $lists['cid'] .= implode(', ', $cat_titles); } else { $lists['cid'] = false; } } // Main category form field $class = 'scat use_select2_lib'; if ($perms['multicat']) { $class .= ' validate-catid'; } else { $class .= ' required'; } $attribs = 'class="' . $class . '"'; $fieldname = 'jform[catid]'; $enable_catid_selector = $isnew && !$tparams->get('catid_default') || !$isnew && empty($item->catid) || $perms['canchange_cat']; if ($tparams->get('catid_allowed_parent')) { $catid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $tparams->get('catid_allowed_parent'), $depth_limit = 0); $disabled_cats = $tparams->get('catid_allowed_parent_disable', 1) ? array($tparams->get('catid_allowed_parent')) : array(); } else { $catid_tree =& $categories; $disabled_cats = array(); } $lists['catid'] = false; if (!empty($catid_tree)) { $disabled = $enable_catid_selector ? '' : ' disabled="disabled"'; $attribs .= $disabled; $lists['catid'] = ($enable_catid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($catid_tree, $fieldname, $item->catid, 2, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options = array(), $disabled_cats); } else { if (!$isnew && $item->catid) { $lists['catid'] = $globalcats[$item->catid]->title; } } //buid types selectlist $class = 'required use_select2_lib'; $attribs = 'class="' . $class . '"'; $fieldname = 'jform[type_id]'; $elementid = 'jform_type_id'; $lists['type'] = flexicontent_html::buildtypesselect($types, $fieldname, $typesselected->id, 1, $attribs, $elementid, $check_perms = true); //build languages list $allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed', null); $allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs); if (!$isnew && $allowed_langs) { $allowed_langs[] = $item->language; } // We will not use the default getInput() function of J1.6+ since we want to create a radio selection field with flags // we could also create a new class and override getInput() method but maybe this is an overkill, we may do it in the future $lists['languages'] = flexicontent_html::buildlanguageslist('jform[language]', 'class="use_select2_lib"', $item->language, 2, $allowed_langs); // Label for current item state: published, unpublished, archived etc switch ($item->state) { case 0: $published = JText::_('FLEXI_UNPUBLISHED'); break; case 1: $published = JText::_('FLEXI_PUBLISHED'); break; case -1: $published = JText::_('FLEXI_ARCHIVED'); break; case -3: $published = JText::_('FLEXI_PENDING'); break; case -5: $published = JText::_('FLEXI_IN_PROGRESS'); break; case -4: default: $published = JText::_('FLEXI_TO_WRITE'); break; } // ************************************************************** // Handle Item Parameters Creation and Load their values for J1.5 // In J1.6+ we declare them in the item form XML file // ************************************************************** if (JHTML::_('date', $item->publish_down, 'Y') <= 1969 || $item->publish_down == $db->getNullDate() || empty($item->publish_down)) { $form->setValue('publish_down', null, ''); // Setting to text will break form date element } // **************************** // Handle Template related work // **************************** // (a) Get the templates structures used to create form fields for template parameters $themes = flexicontent_tmpl::getTemplates(); $tmpls_all = $themes->items; // (b) Get Content Type allowed templates $allowed_tmpls = $tparams->get('allowed_ilayouts'); $type_default_layout = $tparams->get('ilayout', 'default'); if (empty($allowed_tmpls)) { $allowed_tmpls = array(); } else { if (!is_array($allowed_tmpls)) { $allowed_tmpls = explode("|", $allowed_tmpls); } } // (c) Add default layout, unless all templates allowed (=array is empty) if (count($allowed_tmpls) && !in_array($type_default_layout, $allowed_tmpls)) { $allowed_tmpls[] = $type_default_layout; } // (d) Create array of template data according to the allowed templates for current content type if (count($allowed_tmpls)) { foreach ($tmpls_all as $tmpl) { if (in_array($tmpl->name, $allowed_tmpls)) { $tmpls[] = $tmpl; } } } else { $tmpls = $tmpls_all; } // (e) Apply Template Parameters values into the form fields structures foreach ($tmpls as $tmpl) { $jform = new JForm('com_flexicontent.template.item', array('control' => 'jform', 'load_data' => true)); $jform->load($tmpl->params); $tmpl->params = $jform; foreach ($tmpl->params->getGroup('attribs') as $field) { $fieldname = $field->__get('fieldname'); $value = $item->itemparams->get($fieldname); if (strlen($value)) { $tmpl->params->setValue($fieldname, 'attribs', $value); } } } // ****************************** // Assign data to VIEW's template // ****************************** $this->assignRef('document', $document); $this->assignRef('lists', $lists); $this->assignRef('row', $item); if (FLEXI_J16GE) { $this->assignRef('form', $form); } else { $this->assignRef('editor', $editor); $this->assignRef('pane', $pane); $this->assignRef('formparams', $formparams); } if ($enable_translation_groups) { $this->assignRef('lang_assocs', $langAssocs); } if (FLEXI_FISH || FLEXI_J16GE) { $this->assignRef('langs', $langs); } $this->assignRef('typesselected', $typesselected); $this->assignRef('published', $published); $this->assignRef('nullDate', $nullDate); $this->assignRef('subscribers', $subscribers); $this->assignRef('fields', $fields); $this->assignRef('versions', $versions); $this->assignRef('ratings', $ratings); $this->assignRef('pagecount', $pagecount); $this->assignRef('params', $params); $this->assignRef('tparams', $tparams); $this->assignRef('tmpls', $tmpls); $this->assignRef('usedtags', $usedtags); $this->assignRef('perms', $perms); $this->assignRef('current_page', $current_page); // Clear custom form data from session $app->setUserState($form->option . '.edit.' . $form->context . '.custom', false); $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', false); $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', false); if ($print_logging_info) { $start_microtime = microtime(true); } parent::display($tpl); if ($print_logging_info) { $fc_run_times['form_rendering'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { $canDo = UsersHelper::getActions(); if ($canDo->get('core.create')) { JToolBarHelper::addNew('group.add'); } if ($canDo->get('core.edit')) { JToolBarHelper::editList('group.edit'); JToolBarHelper::divider(); } if ($canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'groups.delete'); JToolBarHelper::divider(); } $appsman_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'appsman'; if (file_exists($appsman_path)) { $btn_icon = 'icon-download'; $btn_name = 'download'; $btn_task = 'appsman.exportxml'; $extra_js = " var f=document.getElementById('adminForm'); f.elements['view'].value='appsman'; jQuery('<input>').attr({type: 'hidden', name: 'table', value: 'usergroups'}).appendTo(jQuery(f));"; flexicontent_html::addToolBarButton('Export now', $btn_name, $full_js = '', $msg_alert = '', $msg_confirm = 'Export now as XML', $btn_task, $extra_js, $btn_list = false, $btn_menu = true, $btn_confirm = true, $btn_class = "btn-warning", $btn_icon); $btn_icon = 'icon-box-add'; $btn_name = 'box-add'; $btn_task = 'appsman.addtoexport'; $extra_js = " var f=document.getElementById('adminForm'); f.elements['view'].value='appsman'; jQuery('<input>').attr({type: 'hidden', name: 'table', value: 'usergroups'}).appendTo(jQuery(f));"; flexicontent_html::addToolBarButton('Add to export', $btn_name, $full_js = '', $msg_alert = '', $msg_confirm = 'Add to export list', $btn_task, $extra_js, $btn_list = false, $btn_menu = true, $btn_confirm = true, $btn_class = "btn-warning", $btn_icon); } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_users'); JToolBarHelper::divider(); } JToolBarHelper::help('JHELP_USERS_GROUPS'); }
/** * Method to configure the toolbar for this view. * * @access public * @return void */ function setToolbar() { $perms = FlexicontentHelperPerm::getPerm(); $contrl = "users."; JToolBarHelper::custom('logout', 'cancel.png', 'cancel_f2.png', 'Logout'); JToolBarHelper::addNew($contrl . 'add'); JToolBarHelper::editList($contrl . 'edit'); //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove'); // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag) $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE')); $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM'); $btn_task = $contrl . 'remove'; $extra_js = ""; flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); JToolBarHelper::divider(); JToolBarHelper::spacer(); JToolBarHelper::help('JHELP_USERS_USER_MANAGER'); if ($perms->CanConfig) { JToolBarHelper::divider(); JToolBarHelper::spacer(); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } }
function display($tpl = null) { // *********** // Batch tasks // *********** $app = JFactory::getApplication(); $jinput = $app->input; $task = $jinput->get('task', '', 'cmd'); $cid = $jinput->get('cid', array(), 'array'); if ($task == 'copy') { $behaviour = $jinput->get('copy_behaviour', 'copy/move', 'string'); $this->setLayout('copy'); $this->_displayCopyMove($tpl, $cid, $behaviour); return; } // ******************** // Initialise variables // ******************** global $globalcats; $option = $jinput->get('option', '', 'cmd'); $view = $jinput->get('view', '', 'cmd'); $cparams = JComponentHelper::getParams('com_flexicontent'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $session = JFactory::getSession(); $bind_limit = $jinput->get('bind_limit', 1000, 'int'); // Some flags $enable_translation_groups = flexicontent_db::useAssociations(); //$cparams->get("enable_translation_groups"); $print_logging_info = $cparams->get('print_logging_info'); // Get model $model = $this->getModel(); // *********** // Get filters // *********** $count_filters = 0; // File id filtering $fileid_to_itemids = $session->get('fileid_to_itemids', array(), 'flexicontent'); $filter_fileid = $model->getState('filter_fileid'); if ($filter_fileid) { $count_filters++; } // Order type, order, order direction $filter_order_type = $model->getState('filter_order_type'); $filter_order = $model->getState('filter_order'); $filter_order_Dir = $model->getState('filter_order_Dir'); // Category filtering $filter_cats = $model->getState('filter_cats'); $filter_subcats = $model->getState('filter_subcats'); $filter_catsinstate = $model->getState('filter_catsinstate'); if ($filter_cats) { $count_filters++; } if ($filter_subcats != 1) { $count_filters++; } if ($filter_catsinstate != 1) { $count_filters++; } // Other filters $filter_tag = $model->getState('filter_tag'); $filter_lang = $model->getState('filter_lang'); $filter_type = $model->getState('filter_type'); $filter_author = $model->getState('filter_author'); $filter_state = $model->getState('filter_state'); $filter_access = $model->getState('filter_access'); // Support for using 'ALL', 'ORPHAN' fake states, by clearing other values if (is_array($filter_state) && in_array('ALL', $filter_state)) { $filter_state = array('ALL'); } if (is_array($filter_state) && in_array('ORPHAN', $filter_state)) { $filter_state = array('ORPHAN'); } // Count active filters if ($filter_tag) { $count_filters++; } if ($filter_lang) { $count_filters++; } if ($filter_type) { $count_filters++; } if ($filter_author) { $count_filters++; } if ($filter_state) { $count_filters++; } if ($filter_access) { $count_filters++; } // Date filters $date = $model->getState('date'); $startdate = $model->getState('startdate'); $enddate = $model->getState('enddate'); $startdate = $db->escape(trim(JString::strtolower($startdate))); $enddate = $db->escape(trim(JString::strtolower($enddate))); if ($startdate) { $count_filters++; } if ($enddate) { $count_filters++; } // Item ID filter $filter_id = $model->getState('filter_id'); if ($filter_id) { $count_filters++; } // Text search $scope = $model->getState('scope'); $search = $model->getState('search'); $search = $db->escape(trim(JString::strtolower($search))); // ************************** // Add css and js to document // ************************** flexicontent_html::loadFramework('select2'); JHTML::_('behavior.calendar'); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VERSION); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VERSION); $js = "jQuery(document).ready(function(){"; if ($filter_cats) { $js .= "jQuery('.col_cats').each(function(){ jQuery(this).addClass('yellow'); });"; } if ($filter_type) { $js .= "jQuery('.col_type').each(function(){ jQuery(this).addClass('yellow'); });"; } if ($filter_author) { $js .= "jQuery('.col_authors').each(function(){ jQuery(this).addClass('yellow'); });"; } if ($filter_state) { $js .= "jQuery('.col_state').each(function(){ jQuery(this).addClass('yellow'); });"; } if ($filter_lang) { $js .= "jQuery('.col_lang').each(function(){ jQuery(this).addClass('yellow'); });"; } if ($filter_access) { $js .= "jQuery('.col_access').each(function(){ jQuery(this).addClass('yellow'); });"; } if ($filter_tag) { $js .= "jQuery('.col_tag').each(function(){ jQuery(this).addClass('yellow'); });"; } if ($filter_id) { $js .= "jQuery('.col_id').each(function(){ jQuery(this).addClass('yellow'); });"; } if ($startdate || $enddate) { if ($date == 1) { $js .= "jQuery('.col_created').each(function(){ jQuery(this).addClass('yellow'); });"; } else { if ($date == 2) { $js .= "jQuery('.col_revised').each(function(){ jQuery(this).addClass('yellow'); });"; } } } if (strlen($search)) { $js .= "jQuery('.col_title').each(function(){ jQuery(this).addClass('yellow'); });"; } // ***************************** // Get user's global permissions // ***************************** $perms = FlexicontentHelperPerm::getPerm(); $CanEdit = $perms->CanEdit; $CanPublish = $perms->CanPublish; $CanDelete = $perms->CanDelete; $CanEditOwn = $perms->CanEditOwn; $CanPublishOwn = $perms->CanPublishOwn; $CanDeleteOwn = $perms->CanDeleteOwn; $hasEdit = $CanEdit || $CanEditOwn; $hasPublish = $CanPublish || $CanPublishOwn; $hasDelete = $CanDelete || $CanDeleteOwn; $CanCats = $perms->CanCats; $CanAccLvl = $perms->CanAccLvl; $CanOrder = $perms->CanOrder; $CanCopy = $perms->CanCopy; $CanArchives = $perms->CanArchives; // Check if user can create in at least one published category require_once "components/com_flexicontent/models/item.php"; $itemmodel = new FlexicontentModelItem(); $CanAdd = $itemmodel->getItemAccess()->get('access-create'); // ***************************** // Get user's global permissions // ***************************** $perms = FlexicontentHelperPerm::getPerm(); // ************************ // Create Submenu & Toolbar // ************************ // Create Submenu (and also check access to current view) FLEXISubmenu('notvariable'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_ITEMS'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'items'); $document->setTitle($doc_title . ' - ' . $site_title); $toolbar = JToolBar::getInstance('toolbar'); // Implementation of multiple-item state selector $add_divider = false; if ($hasPublish) { $btn_task = ''; $ctrl_task = '&task=items.selectstate'; $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent' . $ctrl_task . '&format=raw'; if (FLEXI_J30GE || !FLEXI_J16GE) { // Layout of Popup button broken in J3.1, add in J1.5 it generates duplicate HTML tag id (... just for validation), so add manually $js .= "\n\t\t\t\t\tjQuery('#toolbar-publish a.toolbar, #toolbar-publish button')\n\t\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 800, y: 240}, onClose: function() {}}');\n\t\t\t\t"; //JToolBarHelper::publishList( $btn_task ); JToolBarHelper::custom($btn_task, 'publish.png', 'publish_f2.png', 'FLEXI_CHANGE_STATE', false); JHtml::_('behavior.modal', '#toolbar-publish a.toolbar, #toolbar-publish button'); } else { $toolbar->appendButton('Popup', 'publish', JText::_('FLEXI_CHANGE_STATE'), str_replace('&', '&', $popup_load_url), 800, 240); } $add_divider = true; } if ($hasDelete) { if ($filter_state && in_array('T', $filter_state)) { //$btn_msg = JText::_('FLEXI_ARE_YOU_SURE'); //$btn_task = 'items.remove'; //JToolBarHelper::deleteList($btn_msg, $btn_task); $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE')); $msg_confirm = JText::_('FLEXI_ARE_YOU_SURE'); $btn_task = 'items.remove'; $extra_js = ""; flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true, $btn_class = "btn-warning"); } else { $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_TRASH')); $msg_confirm = JText::_('FLEXI_TRASH_CONFIRM') . ' ' . JText::_('FLEXI_NOTES') . ': ' . JText::_('FLEXI_DELETE_PERMANENTLY'); $btn_task = 'items.changestate'; $extra_js = "document.adminForm.newstate.value='T';"; flexicontent_html::addToolBarButton('FLEXI_TRASH', 'trash', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true, $btn_class = ""); } $add_divider = true; } if ($CanArchives && (!$filter_state || !in_array('A', $filter_state))) { $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_ARCHIVE')); $msg_confirm = JText::_('FLEXI_ARCHIVE_CONFIRM'); $btn_task = 'items.changestate'; $extra_js = "document.adminForm.newstate.value='A';"; flexicontent_html::addToolBarButton('FLEXI_ARCHIVE', 'archive', $full_js = '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); $add_divider = true; } if ($CanArchives && $filter_state && in_array('A', $filter_state) || $hasDelete && $filter_state && in_array('T', $filter_state)) { $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_RESTORE')); $msg_confirm = JText::_('FLEXI_RESTORE_CONFIRM'); $btn_task = 'items.changestate'; $extra_js = "document.adminForm.newstate.value='P';"; flexicontent_html::addToolBarButton('FLEXI_RESTORE', 'restore', $full_js = '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); } if ($add_divider) { JToolBarHelper::divider(); } $add_divider = false; if ($CanAdd) { $btn_task = ''; $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent&view=types&format=raw'; if (FLEXI_J30GE || !FLEXI_J16GE) { // Layout of Popup button broken in J3.1, add in J1.5 it generates duplicate HTML tag id (... just for validation), so add manually $js .= "\n\t\t\t\t\tjQuery('#toolbar-new a.toolbar, #toolbar-new button')\n\t\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 800, y: 240}, onClose: function() {}}');\n\t\t\t\t"; //JToolBarHelper::addNew( $btn_task ); JToolBarHelper::custom($btn_task, 'new.png', 'new_f2.png', 'FLEXI_NEW', false); JHtml::_('behavior.modal', '#toolbar-new a.toolbar, #toolbar-new button'); } else { $toolbar->appendButton('Popup', 'new', JText::_('FLEXI_NEW'), str_replace('&', '&', $popup_load_url), 800, 240); } $add_divider = true; } if ($hasEdit) { $btn_task = 'items.edit'; JToolBarHelper::editList($btn_task); $add_divider = true; } if ($add_divider) { JToolBarHelper::divider(); } $add_divider = false; if ($CanAdd && $CanCopy) { $btn_task = 'items.copy'; JToolBarHelper::custom($btn_task, 'copy.png', 'copy_f2.png', 'FLEXI_BATCH'); if ($enable_translation_groups) { JToolBarHelper::custom('translate', 'translate', 'translate', 'FLEXI_TRANSLATE'); } $add_divider = true; } $btn_task = 'items.checkin'; JToolbarHelper::checkin($btn_task); if ($add_divider) { JToolBarHelper::divider(); JToolBarHelper::spacer(); } if ($perms->CanConfig) { $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } $js .= "});"; $document->addScriptDeclaration($js); // *********************** // Get data from the model // *********************** $badcatitems = (int) $model->getUnboundedItems($limit = 10000000, $count_only = true, $checkNoExtData = false, $checkInvalidCat = true); $unassociated = (int) $model->getUnboundedItems($limit = 10000000, $count_only = true, $checkNoExtData = true, $checkInvalidCat = false); $rows = $this->get('Data'); $pagination = $this->get('Pagination'); $types = $this->get('Typeslist'); $authors = $this->get('Authorslist'); // these depend on data rows and must be called after getting data $extraCols = $this->get('ExtraCols'); $customFilts = $this->get('CustomFilts'); foreach ($customFilts as $filter) { if (count($filter->value)) { $count_filters++; } } $itemCats = $this->get('ItemCats'); $itemTags = $this->get('ItemTags'); if ($enable_translation_groups) { $langAssocs = $this->get('LangAssocs'); } $langs = FLEXIUtilities::getLanguages('code'); $categories = $globalcats ? $globalcats : array(); $limit = $pagination->limit; $inline_ss_max = 500; $drag_reorder_max = 150; if ($limit > $drag_reorder_max) { $cparams->set('draggable_reordering', 0); } // ****************************************** // Add usability notices if these are enabled // ****************************************** if ($cparams->get('show_usability_messages', 1) && !$unassociated && !$badcatitems) { $notice_iss_disabled = $app->getUserStateFromRequest($option . '.items.notice_iss_disabled', 'notice_iss_disabled', 0, 'int'); if (!$notice_iss_disabled && $limit > $inline_ss_max) { $app->setUserState($option . '.items.notice_iss_disabled', 1); $app->enqueueMessage(JText::sprintf('FLEXI_INLINE_ITEM_STATE_SELECTOR_DISABLED', $inline_ss_max), 'notice'); $show_turn_off_notice = 1; } $notice_drag_reorder_disabled = $app->getUserStateFromRequest($option . '.items.notice_drag_reorder_disabled', 'notice_drag_reorder_disabled', 0, 'int'); if (!$notice_drag_reorder_disabled && $limit > $drag_reorder_max) { $app->setUserState($option . '.items.notice_drag_reorder_disabled', 1); $app->enqueueMessage(JText::sprintf('FLEXI_DRAG_REORDER_DISABLED', $drag_reorder_max), 'notice'); $show_turn_off_notice = 1; } $notice_add_custom_columns = $app->getUserStateFromRequest($option . '.items.notice_add_custom_columns', 'notice_add_custom_columns', 0, 'int'); if (!$notice_add_custom_columns) { $app->setUserState($option . '.items.notice_add_custom_columns', 1); $app->enqueueMessage(JText::_('FLEXI_YOU_MAY_CONFIGURE_CUSTOM_COLUMNS_GLOBAL_AND_PER_TYPE'), 'message'); $show_turn_off_notice = 1; } if (!empty($show_turn_off_notice)) { $app->enqueueMessage(JText::_('FLEXI_USABILITY_MESSAGES_TURN_OFF'), 'message'); } } // ******************* // Create Filters HTML // ******************* // filter publication state $states = array(); //$states[] = JHTML::_('select.option', '', '-'/*JText::_( 'FLEXI_SELECT_STATE' )*/ ); $states[] = JHTML::_('select.optgroup', JText::_('FLEXI_SINGLE_STATUS')); $states[] = JHTML::_('select.option', 'P', JText::_('FLEXI_PUBLISHED')); $states[] = JHTML::_('select.option', 'U', JText::_('FLEXI_UNPUBLISHED')); $states[] = JHTML::_('select.option', 'PE', JText::_('FLEXI_PENDING')); $states[] = JHTML::_('select.option', 'OQ', JText::_('FLEXI_TO_WRITE')); $states[] = JHTML::_('select.option', 'IP', JText::_('FLEXI_IN_PROGRESS')); $states[] = JHTML::_('select.option', 'RV', JText::_('FLEXI_REVISED_VER')); $states[] = JHTML::_('select.option', 'A', JText::_('FLEXI_ARCHIVED')); $states[] = JHTML::_('select.option', 'T', JText::_('FLEXI_TRASHED')); $states[] = JHTML::_('select.optgroup', ''); $states[] = JHTML::_('select.optgroup', JText::_('FLEXI_STATUS_GROUPS')); $states[] = JHTML::_('select.option', 'ALL', JText::_('FLEXI_GRP_ALL') . ' ' . JText::_('FLEXI_STATE_S')); $states[] = JHTML::_('select.option', 'ALL_P', JText::_('FLEXI_GRP_PUBLISHED') . ' ' . JText::_('FLEXI_STATE_S')); $states[] = JHTML::_('select.option', 'ALL_U', JText::_('FLEXI_GRP_UNPUBLISHED') . ' ' . JText::_('FLEXI_STATE_S')); $states[] = JHTML::_('select.option', 'ORPHAN', JText::_('FLEXI_GRP_ORPHAN')); $states[] = JHTML::_('select.optgroup', ''); $lists['filter_state'] = ($filter_state || 1 ? '<label class="label">' . JText::_('FLEXI_STATE') . '</label>' : '') . JHTML::_('select.genericlist', $states, 'filter_state[]', 'class="use_select2_lib fcfilter_be" multiple="multiple" size="3" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_state); //JHTML::_('grid.state', $filter_state ); // build filter state group if ($hasDelete || $CanArchives) { //$stategroups[''] = JText::_( 'FLEXI_GRP_NORMAL' ) .' '. JText::_( 'FLEXI_STATE_S' ); //$stategroups['published'] = JText::_( 'FLEXI_GRP_PUBLISHED' ) .' '. JText::_( 'FLEXI_STATE_S' ); //$stategroups['unpublished'] = JText::_( 'FLEXI_GRP_UNPUBLISHED' ) .' '. JText::_( 'FLEXI_STATE_S' ); /*if ($hasDelete) $stategroups['trashed'] = JText::_( 'FLEXI_GRP_TRASHED' );*/ /*if ($CanArchives) $stategroups['archived'] = JText::_( 'FLEXI_GRP_ARCHIVED' );*/ //$stategroups['orphan'] = JText::_( 'FLEXI_GRP_ORPHAN' ); //$stategroups['all'] = JText::_( 'FLEXI_GRP_ALL' ); /*$_stategroups = array(); foreach ($stategroups as $i => $v) { $_stategroups[] = JHTML::_('select.option', $i, $v); } $lists['filter_stategrp'] = JHTML::_('select.radiolist', $_stategroups, 'filter_stategrp', 'size="1" class="inputbox" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_stategrp );*/ /*$lists['filter_stategrp'] = ''; foreach ($stategroups as $i => $v) { $checked = $filter_stategrp == $i ? ' checked="checked" ' : ''; $lists['filter_stategrp'] .= '<input type="radio" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" class="inputbox" '.$checked.' value="'.$i.'" id="filter_stategrp'.$i.'" name="filter_stategrp" />'; $lists['filter_stategrp'] .= '<label class="" id="filter_stategrp'.$i.'-lbl" for="filter_stategrp'.$i.'">'.$v.'</label>'; }*/ } // build the include subcats boolean list // build the include non-published cats boolean list if ($filter_order_type && $filter_cats && ($filter_order == 'i.ordering' || $filter_order == 'catsordering')) { $ordering_tip = '<img src="components/com_flexicontent/assets/images/comment.png" class="hasTooltip" title="' . JText::_('FLEXI_SUBCATEGORIES_NOT_INCLUDED_DURING_CATORDER_DESC', true) . '" />'; $lists['filter_subcats'] = ' <span class="fc-mssg-inline fc-note"> ' . JText::_('FLEXI_SUBCATEGORIES_NOT_INCLUDED_DURING_CATORDER') . ' ' . $ordering_tip . ' </span>'; } else { //$lists['filter_subcats'] = JHTML::_('select.booleanlist', 'filter_subcats', 'class="inputbox" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', $filter_subcats ); $subcats = array(); $subcats[] = JHTML::_('select.option', 0, JText::_('FLEXI_NO')); $subcats[] = JHTML::_('select.option', 1, JText::_('FLEXI_YES')); $lists['filter_subcats'] = JHTML::_('select.genericlist', $subcats, 'filter_subcats', 'size="1" class="use_select2_lib ' . ($filter_subcats != 1 ? '' : ' fc_skip_highlight') . '" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_subcats, 'filter_subcats'); } $lists['filter_subcats'] = ($filter_subcats || 1 ? '<label class="label">' . JText::_('FLEXI_SUBCATEGORIES') . '</label>' : '') . $lists['filter_subcats']; // build the include non-published cats boolean list $catsinstate[1] = JText::_('FLEXI_PUBLISHED'); $catsinstate[0] = JText::_('FLEXI_UNPUBLISHED'); $catsinstate[99] = JText::_('FLEXI_ANY'); $catsinstate[2] = JText::_('FLEXI_ARCHIVED_STATE'); $catsinstate[-2] = JText::_('FLEXI_TRASHED_STATE'); $_catsinstate = array(); foreach ($catsinstate as $i => $v) { $_catsinstate[] = JHTML::_('select.option', $i, $v); } $lists['filter_catsinstate'] = ($filter_catsinstate || 1 ? '<label class="label">' . JText::_('FLEXI_LIST_ITEMS_IN_CATS') . '</label>' : '') . JHTML::_('select.genericlist', $_catsinstate, 'filter_catsinstate', 'size="1" class="use_select2_lib' . ($filter_catsinstate != 1 ? '' : ' fc_skip_highlight') . '" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_catsinstate, 'filter_catsinstate'); //$lists['filter_catsinstate'] = JHTML::_('select.radiolist', $_catsinstate, 'filter_catsinstate', 'size="1" class="inputbox" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_catsinstate ); /*$lists['filter_catsinstate'] = ''; foreach ($catsinstate as $i => $v) { $checked = $filter_catsinstate == $i ? ' checked="checked" ' : ''; $lists['filter_catsinstate'] .= '<input type="radio" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" class="inputbox" '.$checked.' value="'.$i.'" id="filter_catsinstate'.$i.'" name="filter_catsinstate" />'; $lists['filter_catsinstate'] .= '<label class="" id="filter_catsinstate'.$i.'-lbl" for="filter_catsinstate'.$i.'">'.$v.'</label>'; }*/ // build the order type boolean list $order_types = array(); $order_types[] = JHTML::_('select.option', '0', 'FLEXI_ORDER_JOOMLA'); $order_types[] = JHTML::_('select.option', '1', 'FLEXI_ORDER_FLEXICONTENT'); //$lists['filter_order_type'] = JHTML::_('select.radiolist', $order_types, 'filter_order_type', 'size="1" class="inputbox" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_order_type ); $lists['filter_order_type'] = JHTML::_('select.genericlist', $order_types, 'filter_order_type', 'size="1" class="use_select2_lib fc_skip_highlight" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_order_type, 'filter_order_type', $translate = true); // build the categories select list for filter $lists['filter_cats'] = ($filter_cats || 1 ? '<label class="label">' . JText::_('FLEXI_CATEGORY') . '</label>' : '') . flexicontent_cats::buildcatselect($categories, 'filter_cats', $filter_cats, '-', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', $check_published = false, $check_perms = false); //build type select list $lists['filter_type'] = ($filter_type || 1 ? '<label class="label">' . JText::_('FLEXI_TYPE') . '</label>' : '') . flexicontent_html::buildtypesselect($types, 'filter_type[]', $filter_type, 0, 'class="use_select2_lib fcfilter_be" multiple="multiple" size="3" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'filter_type'); //build authors select list $lists['filter_author'] = ($filter_author || 1 ? '<label class="label">' . JText::_('FLEXI_AUTHOR') . '</label>' : '') . flexicontent_html::buildauthorsselect($authors, 'filter_author[]', $filter_author, 0, 'class="use_select2_lib fcfilter_be" multiple="multiple" size="3" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"'); if ($badcatitems) { $lists['default_cat'] = flexicontent_cats::buildcatselect($categories, 'default_cat', '', 2, 'class="use_select2_lib"', false, false); } //search filter $scopes = array(); $scopes[1] = JText::_('FLEXI_TITLE'); $scopes[2] = JText::_('FLEXI_INTROTEXT'); $scopes[4] = JText::_('FLEXI_INDEXED_CONTENT'); $_scopes = array(); foreach ($scopes as $i => $v) { $_scopes[] = JHTML::_('select.option', $i, $v); } //$lists['scope'] = JHTML::_('select.radiolist', $_scopes, 'scope', 'size="1" class="inputbox"', 'value', 'text', $scope ); $lists['scope'] = JHTML::_('select.genericlist', $_scopes, 'scope', 'size="1" class="use_select2_lib fc_skip_highlight" onchange="jQuery(\'#search\').attr(\'placeholder\', jQuery(this).find(\'option:selected\').text());" title="' . JText::_('FLEXI_SEARCH_TEXT_INSIDE') . '"', 'value', 'text', $scope, 'scope'); /*$lists['scope'] = ''; foreach ($scopes as $i => $v) { $checked = $scope == $i ? ' checked="checked" ' : ''; $lists['scope'] .= '<input type="radio" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" class="inputbox" '.$checked.' value="'.$i.'" id="scope'.$i.'" name="scope" />'; $lists['scope'] .= '<label class="" id="scope'.$i.'-lbl" for="scope'.$i.'">'.$v.'</label>'; }*/ // build item dates option list $dates[1] = JText::_('FLEXI_CREATED'); $dates[2] = JText::_('FLEXI_REVISED'); $_dates = array(); foreach ($dates as $i => $v) { $_dates[] = JHTML::_('select.option', $i, $v); } //$lists['date'] = JHTML::_('select.radiolist', $_dates, 'date', 'size="1" class="inputbox"', 'value', 'text', $date ); $lists['date'] = '<label class="label">' . JText::_('FLEXI_DATE') . '</label>' . JHTML::_('select.genericlist', $_dates, 'date', 'size="1" class="use_select2_lib fc_skip_highlight"', 'value', 'text', $date, 'date'); /*$lists['date'] = ''; foreach ($dates as $i => $v) { $checked = $date == $i ? ' checked="checked" ' : ''; $lists['date'] .= '<input type="radio" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" class="inputbox" '.$checked.' value="'.$i.'" id="date'.$i.'" name="date" />'; $lists['date'] .= '<label class="" id="date'.$i.'-lbl" for="date'.$i.'">'.$v.'</label>'; }*/ $lists['startdate'] = JHTML::_('calendar', $startdate, 'startdate', 'startdate', '%Y-%m-%d', array('class' => 'inputbox', 'size' => '8', 'maxlength' => '19', 'style' => 'width:auto', 'placeholder' => JText::_('FLEXI_FROM'))); $lists['enddate'] = JHTML::_('calendar', $enddate, 'enddate', 'enddate', '%Y-%m-%d', array('class' => 'inputbox', 'size' => '8', 'maxlength' => '19', 'style' => 'width:auto', 'placeholder' => JText::_('FLEXI_TO'))); // search filter $bind_limits = array(); $bind_limits[] = JHTML::_('select.option', 250, '250 ' . JText::_('FLEXI_ITEMS')); $bind_limits[] = JHTML::_('select.option', 500, '500 ' . JText::_('FLEXI_ITEMS')); $bind_limits[] = JHTML::_('select.option', 750, '750 ' . JText::_('FLEXI_ITEMS')); $bind_limits[] = JHTML::_('select.option', 1000, '1000 ' . JText::_('FLEXI_ITEMS')); $bind_limits[] = JHTML::_('select.option', 1500, '1500 ' . JText::_('FLEXI_ITEMS')); $bind_limits[] = JHTML::_('select.option', 2000, '2000 ' . JText::_('FLEXI_ITEMS')); $lists['bind_limits'] = JHTML::_('select.genericlist', $bind_limits, 'bind_limit', 'size="1" class="use_select2_lib"', 'value', 'text', $bind_limit, 'bind_limit'); // search filter $lists['search'] = $search; // search id $lists['filter_id'] = $filter_id; // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // filter ordering if (!$filter_order_type) { $ordering = $lists['order'] == 'i.ordering'; } else { $ordering = $lists['order'] == 'catsordering'; } //build tags filter $lists['filter_tag'] = ($filter_tag || 1 ? '<label class="label">' . JText::_('FLEXI_TAG') . '</label>' : '') . flexicontent_html::buildtagsselect('filter_tag[]', 'class="use_select2_lib fcfilter_be" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" multiple="multiple" size="3" ', $filter_tag, 0); //build languages filter $lists['filter_lang'] = ($filter_lang || 1 ? '<label class="label">' . JText::_('FLEXI_LANGUAGE') . '</label>' : '') . flexicontent_html::buildlanguageslist('filter_lang[]', 'class="use_select2_lib fcfilter_be" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" multiple="multiple" size="3" ', $filter_lang, 1); // build access level filter $access_levels = JHtml::_('access.assetgroups'); /*if ( $cparams->get('iman_viewable_items', 1) ) // only viewable items is enabled, skip the non available levels to avoid user confusion { $_aid_arr = array_flip(JAccess::getAuthorisedViewLevels($user->id)); $_levels = array(); foreach($access_levels as $i => $level) { if ( isset($_aid_arr[$level->value]) ) $_levels[] = $level; //else $access_levels[$i]->disable = 1; } $access_levels = $_levels; }*/ // Above code is maybe problematic (e.g. in multi-sites), need to test more //array_unshift($access_levels, JHtml::_('select.option', '', '-'/*'JOPTION_SELECT_ACCESS'*/) ); $fieldname = 'filter_access[]'; // make multivalue $elementid = 'filter_access'; $attribs = 'class="use_select2_lib fcfilter_be" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" multiple="multiple"'; $lists['filter_access'] = ($filter_access || 1 ? '<label class="label">' . JText::_('FLEXI_ACCESS') . '</label>' : '') . JHTML::_('select.genericlist', $access_levels, $fieldname, $attribs, 'value', 'text', $filter_access, $elementid, $translate = true); // filter by item usage a specific file if ($fileid_to_itemids && count($fileid_to_itemids)) { $files_data = $model->getFileData(array_keys($fileid_to_itemids)); $file_options = array(); $file_options[] = JHTML::_('select.option', '', '-'); foreach ($files_data as $_file) { $file_options[] = JHTML::_('select.option', $_file->id, $_file->altname); } flexicontent_html::loadFramework('select2'); $lists['filter_fileid'] = ($filter_fileid || 1 ? '<label class="label">' . JText::_('FLEXI_ITEMS_USING') . ' ' . JText::_('FLEXI_FILE') . '</label>' : '') . JHTML::_('select.genericlist', $file_options, 'filter_fileid', 'size="1" class="use_select2_lib' . ($filter_fileid ? '' : ' fc_skip_highlight') . '" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_fileid); } //assign data to template $this->assignRef('CanTemplates', $perms->CanTemplates); $this->assignRef('count_filters', $count_filters); //$this->assignRef('filter_stategrp', $filter_stategrp); $this->assignRef('filter_catsinstate', $filter_catsinstate); $this->assignRef('db', $db); $this->assignRef('lists', $lists); $this->assignRef('rows', $rows); $this->assignRef('itemCats', $itemCats); $this->assignRef('itemTags', $itemTags); $this->assignRef('extra_fields', $extraCols); $this->assignRef('custom_filts', $customFilts); if ($enable_translation_groups) { $this->assignRef('lang_assocs', $langAssocs); } $this->assignRef('langs', $langs); $this->assignRef('cid', $cid); $this->assignRef('pagination', $pagination); $this->assignRef('ordering', $ordering); $this->assignRef('CanOrder', $CanOrder); $this->assignRef('CanCats', $CanCats); $this->assignRef('CanAccLvl', $CanAccLvl); $this->assignRef('unassociated', $unassociated); $this->assignRef('badcatitems', $badcatitems); // filters $this->assignRef('filter_id', $filter_id); $this->assignRef('filter_state', $filter_state); $this->assignRef('filter_author', $filter_author); $this->assignRef('filter_type', $filter_type); $this->assignRef('filter_cats', $filter_cats); $this->assignRef('filter_subcats', $filter_subcats); $this->assignRef('filter_catsinstate', $filter_catsinstate); $this->assignRef('filter_order_type', $filter_order_type); $this->assignRef('filter_order', $filter_order); $this->assignRef('filter_lang', $filter_lang); $this->assignRef('filter_access', $filter_access); $this->assignRef('filter_tag', $filter_tag); $this->assignRef('filter_fileid', $filter_fileid); $this->assignRef('inline_ss_max', $inline_ss_max); $this->assignRef('scope', $scope); $this->assignRef('search', $search); $this->assignRef('date', $date); $this->assignRef('startdate', $startdate); $this->assignRef('enddate', $enddate); $this->assignRef('option', $option); $this->assignRef('view', $view); $print_logging_info = $cparams->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; $start_microtime = microtime(true); } $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null; parent::display($tpl); if ($print_logging_info) { @($fc_run_times['template_render'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } }
function display($tpl = null) { // ******************** // Initialise variables // ******************** $app = JFactory::getApplication(); $jinput = $app->input; $option = $jinput->get('option', '', 'cmd'); $view = $jinput->get('view', '', 'cmd'); $cparams = JComponentHelper::getParams('com_flexicontent'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); // ************************** // Add css and js to document // ************************** flexicontent_html::loadFramework('select2'); //JHTML::_('behavior.tooltip'); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VHASH); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VHASH); // ***************************** // Get user's global permissions // ***************************** $perms = FlexicontentHelperPerm::getPerm(); if (!$perms->CanTemplates) { $app->redirect('index.php?option=com_flexicontent', JText::_('FLEXI_NO_ACCESS')); } // ************************ // Create Submenu & Toolbar // ************************ // Create Submenu (and also check access to current view) FLEXISubmenu('CanTemplates'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_TEMPLATES'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'templates'); $document->setTitle($doc_title . ' - ' . $site_title); // Create the toolbar $appsman_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'appsman'; if (file_exists($appsman_path)) { $btn_icon = 'icon-download'; $btn_name = 'download'; $btn_task = 'appsman.exportxml'; $extra_js = " var f=document.getElementById('adminForm'); f.elements['view'].value='appsman'; jQuery('<input>').attr({type: 'hidden', name: 'table', value: 'flexicontent_templates'}).appendTo(jQuery(f));"; flexicontent_html::addToolBarButton('Export now', $btn_name, $full_js = '', $msg_alert = '', $msg_confirm = 'Export now as XML', $btn_task, $extra_js, $btn_list = false, $btn_menu = true, $btn_confirm = true, $btn_class = "btn-warning", $btn_icon); $btn_icon = 'icon-box-add'; $btn_name = 'box-add'; $btn_task = 'appsman.addtoexport'; $extra_js = " var f=document.getElementById('adminForm'); f.elements['view'].value='appsman'; jQuery('<input>').attr({type: 'hidden', name: 'table', value: 'flexicontent_templates'}).appendTo(jQuery(f));"; flexicontent_html::addToolBarButton('Add to export', $btn_name, $full_js = '', $msg_alert = '', $msg_confirm = 'Add to export list', $btn_task, $extra_js, $btn_list = false, $btn_menu = true, $btn_confirm = true, $btn_class = "btn-warning", $btn_icon); } //JToolBarHelper::Back(); if ($perms->CanConfig) { //JToolBarHelper::divider(); JToolBarHelper::spacer(); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } $tmpldirectory = JPATH_COMPONENT_SITE . DS . 'templates' . DS; $source = JRequest::getString('source', ''); $dest = $source ? flexicontent_upload::sanitizedir($tmpldirectory, $source) : ''; //Get data from the model $rows = $this->get('Data'); // Get layout data /*$tmpl = flexicontent_tmpl::getTemplates(); foreach($rows as $row) { $row->item_layout = @ $tmpl->items->{$row->name}; $row->category_layout = @ $tmpl->category->{$row->name}; }*/ //assign data to template $this->assignRef('rows', $rows); $this->assignRef('user', $user); $this->assignRef('tmpldirectory', $tmpldirectory); $this->assignRef('source', $source); $this->assignRef('dest', $dest); $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null; parent::display($tpl); }
function display($tpl = null) { // ******************** // Initialise variables // ******************** $app = JFactory::getApplication(); $jinput = $app->input; $option = $jinput->get('option', '', 'cmd'); $view = $jinput->get('view', '', 'cmd'); $cparams = JComponentHelper::getParams('com_flexicontent'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); // Get model $model = $this->getModel(); $print_logging_info = $cparams->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } // *********** // Get filters // *********** $count_filters = 0; // various filters $filter_state = $app->getUserStateFromRequest($option . '.' . $view . '.filter_state', 'filter_state', '', 'word'); $filter_access = $app->getUserStateFromRequest($option . '.' . $view . '.filter_access', 'filter_access', '', 'string'); if ($filter_state) { $count_filters++; } if ($filter_access) { $count_filters++; } // ordering filters $filter_order = $app->getUserStateFromRequest($option . '.' . $view . '.filter_order', 'filter_order', 't.name', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest($option . '.' . $view . '.filter_order_Dir', 'filter_order_Dir', '', 'word'); // text search $search = $app->getUserStateFromRequest($option . '.' . $view . '.search', 'search', '', 'string'); $search = $db->escape(trim(JString::strtolower($search))); // **************************** // Important usability messages // **************************** if ($cparams->get('show_usability_messages', 1)) { } // ************************** // Add css and js to document // ************************** flexicontent_html::loadFramework('select2'); JHTML::_('behavior.tooltip'); $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css'); if (FLEXI_J30GE) { $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css'); } else { if (FLEXI_J16GE) { $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/j25.css'); } } // ***************************** // Get user's global permissions // ***************************** $perms = FlexicontentHelperPerm::getPerm(); // ************************ // Create Submenu & Toolbar // ************************ // Create Submenu (and also check access to current view) FLEXISubmenu('CanTypes'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_TYPES'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'types'); $document->setTitle($doc_title . ' - ' . $site_title); $contrl = "types."; JToolBarHelper::custom($contrl . 'copy', 'copy.png', 'copy_f2.png', 'FLEXI_COPY'); JToolBarHelper::divider(); JToolBarHelper::spacer(); JToolBarHelper::publishList($contrl . 'publish'); JToolBarHelper::unpublishList($contrl . 'unpublish'); JToolBarHelper::addNew($contrl . 'add'); JToolBarHelper::editList($contrl . 'edit'); //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove'); // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag) $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE')); $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM'); $btn_task = $contrl . 'remove'; $extra_js = ""; flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); $appsman_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'appsman'; if (file_exists($appsman_path)) { $btn_icon = 'icon-download'; $btn_name = 'download'; $btn_task = 'appsman.exportxml'; $extra_js = " var f=document.getElementById('adminForm'); f.elements['view'].value='appsman'; jQuery('<input>').attr({type: 'hidden', name: 'table', value: 'flexicontent_types'}).appendTo(jQuery(f));"; flexicontent_html::addToolBarButton('Export now', $btn_name, $full_js = '', $msg_alert = '', $msg_confirm = 'Export now as XML', $btn_task, $extra_js, $btn_list = false, $btn_menu = true, $btn_confirm = true, $btn_class = "btn-warning", $btn_icon); $btn_icon = 'icon-box-add'; $btn_name = 'box-add'; $btn_task = 'appsman.addtoexport'; $extra_js = " var f=document.getElementById('adminForm'); f.elements['view'].value='appsman'; jQuery('<input>').attr({type: 'hidden', name: 'table', value: 'flexicontent_types'}).appendTo(jQuery(f));"; flexicontent_html::addToolBarButton('Add to export', $btn_name, $full_js = '', $msg_alert = '', $msg_confirm = 'Add to export list', $btn_task, $extra_js, $btn_list = false, $btn_menu = true, $btn_confirm = true, $btn_class = "btn-warning", $btn_icon); } if ($perms->CanConfig) { JToolBarHelper::divider(); JToolBarHelper::spacer(); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } // Get data from the model if ($print_logging_info) { $start_microtime = microtime(true); } $rows = $this->get('Items'); if ($print_logging_info) { @($fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } $pagination = $this->get('Pagination'); // Pagination // Create type's parameters foreach ($rows as $type) { $type->config = FLEXI_J16GE ? new JRegistry($type->config) : new JParameter($type->config); } $lists = array(); // build publication state filter $states = array(); $states[] = JHTML::_('select.option', '', '-'); $states[] = JHTML::_('select.option', 'P', JText::_('FLEXI_PUBLISHED')); $states[] = JHTML::_('select.option', 'U', JText::_('FLEXI_UNPUBLISHED')); //$states[] = JHTML::_('select.option', '-2', JText::_( 'FLEXI_TRASHED' ) ); $lists['state'] = ($filter_state || 1 ? '<label class="label">' . JText::_('FLEXI_STATE') . '</label>' : '') . JHTML::_('select.genericlist', $states, 'filter_state', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_state); //JHTML::_('grid.state', $filter_state ); // build access level filter $options = JHtml::_('access.assetgroups'); array_unshift($options, JHtml::_('select.option', '', '-')); $fieldname = $elementid = 'filter_access'; $attribs = 'class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"'; $lists['access'] = ($filter_access || 1 ? '<label class="label">' . JText::_('FLEXI_ACCESS') . '</label>' : '') . JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_access, $elementid, $translate = true); // text search filter $lists['search'] = $search; // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; //assign data to template $this->assignRef('CanTemplates', $perms->CanTemplates); $this->assignRef('count_filters', $count_filters); $this->assignRef('lists', $lists); $this->assignRef('rows', $rows); $this->assignRef('pagination', $pagination); $this->assignRef('option', $option); $this->assignRef('view', $view); $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null; parent::display($tpl); }
function display($tpl = null) { global $globalcats; $app = JFactory::getApplication(); $user = JFactory::getUser(); $document = JFactory::getDocument(); JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR, 'en-GB', true); JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR, null, true); // *********************************************************** // Get category data, and check if item is already checked out // *********************************************************** // Get data from the model $model = $this->getModel(); if (FLEXI_J16GE) { $row = $this->get('Item'); $form = $this->get('Form'); } else { $row = $this->get('Category'); } $catparams = new JRegistry($row->params); $cid = $row->id; $isnew = !$cid; // Check category is checked out by different editor / administrator if (!$isnew && $model->isCheckedOut($user->get('id'))) { JError::raiseWarning('SOME_ERROR_CODE', $row->title . ' ' . JText::_('FLEXI_EDITED_BY_ANOTHER_ADMIN')); $app->redirect('index.php?option=com_flexicontent&view=categories'); } // *************************************************************************** // Currently access checking for category add/edit form , it is done here, for // most other views we force going though the controller and checking it there // *************************************************************************** // ********************************************************************************************* // Global Permssions checking (needed because this view can be called without a controller task) // ********************************************************************************************* // Get global permissions $perms = FlexicontentHelperPerm::getPerm(); // handles super admins correctly // Check no access to categories management (Global permission) if (!$perms->CanCats) { $app->redirect('index.php?option=com_flexicontent', JText::_('FLEXI_NO_ACCESS')); } // Check no privilege to create new categories (Global permission) if ($isnew && !$perms->CanAddCats) { JError::raiseWarning(403, JText::_('FLEXI_NO_ACCESS_CREATE')); $app->redirect('index.php?option=com_flexicontent'); } // ************************************************************************************ // Record Permssions (needed because this view can be called without a controller task) // ************************************************************************************ // Get edit privilege for current category if (!$isnew) { if (FLEXI_J16GE) { $isOwner = $row->get('created_by') == $user->id; $rights = FlexicontentHelperPerm::checkAllItemAccess($user->id, 'category', $cid); $canedit_cat = in_array('edit', $rights) || in_array('edit.own', $rights) && $isOwner; } else { if (FLEXI_ACCESS) { $rights = FAccess::checkAllItemAccess('com_content', 'users', $user->gmid, 0, $row->id); $canedit_cat = $user->gid < 25 ? in_array('edit', $rights) || in_array('editown', $rights) : 1; } else { $canedit_cat = true; } } } // Get if we can create inside at least one (com_content) category if ($user->authorise('core.create', 'com_flexicontent')) { $cancreate_cat = true; } else { $usercats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true, $check_published = true, $specific_catids = false, $find_first = true); $cancreate_cat = count($usercats) > 0; } // Creating new category: Check if user can create inside any existing category if ($isnew && !$cancreate_cat) { $acc_msg = JText::_('FLEXI_NO_ACCESS_CREATE') . "<br/>" . (FLEXI_J16GE ? JText::_('FLEXI_CANNOT_ADD_CATEGORY_REASON') : ""); JError::raiseWarning(403, $acc_msg); $app->redirect('index.php?option=com_flexicontent&view=categories'); } // Editing existing category: Check if user can edit existing (current) category if (!$isnew && !$canedit_cat) { $acc_msg = JText::_('FLEXI_NO_ACCESS_EDIT') . "<br/>" . JText::_('FLEXI_CANNOT_EDIT_CATEGORY_REASON'); JError::raiseWarning(403, $acc_msg); $app->redirect('index.php?option=com_flexicontent&view=categories'); } // ************************************************** // Include needed files and add needed js / css files // ************************************************** // Add css to document $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VERSION); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VERSION); // Add JS frameworks flexicontent_html::loadFramework('select2'); // Add js function to overload the joomla submitform validation JHTML::_('behavior.formvalidation'); // load default validation JS to make sure it is overriden $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VERSION); $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VERSION); //Load pane behavior jimport('joomla.html.pane'); // ******************** // Initialise variables // ******************** $editor_name = $user->getParam('editor', $app->getCfg('editor')); $editor = JFactory::getEditor($editor_name); $cparams = JComponentHelper::getParams('com_flexicontent'); $categories = $globalcats; $bar = JToolBar::getInstance('toolbar'); $tip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; // ****************** // Create the toolbar // ****************** // Create Toolbar title and add the preview button if (!$isnew) { JToolBarHelper::title(JText::_('FLEXI_EDIT_CATEGORY'), 'fc_categoryedit'); } else { JToolBarHelper::title(JText::_('FLEXI_NEW_CATEGORY'), 'fc_categoryadd'); } // Add apply and save buttons JToolBarHelper::apply('category.apply', 'FLEXI_APPLY'); /*if ( !$isnew ) flexicontent_html::addToolBarButton( 'FLEXI_FAST_APPLY', $btn_name='apply_ajax', $full_js="Joomla.submitbutton('category.apply_ajax')", $msg_alert='', $msg_confirm='', $btn_task='category.apply_ajax', $extra_js='', $btn_list=false, $btn_menu=true, $btn_confirm=false, $btn_class="", $btn_icon="icon-loop");*/ JToolBarHelper::save('category.save'); // Add a save and new button, if user can create inside at least one (com_content) category if ($cancreate_cat) { JToolBarHelper::save2new('category.save2new'); } // Add a save as copy button, if editing an existing category (J2.5 only) if (!$isnew && $cancreate_cat) { JToolBarHelper::save2copy('category.save2copy'); } // Add a cancel or close button if ($isnew) { JToolBarHelper::cancel('category.cancel'); } else { JToolBarHelper::cancel('category.cancel', 'JTOOLBAR_CLOSE'); } // ****************** // Add preview button // ****************** if (!$isnew) { JToolBarHelper::divider(); $autologin = ''; //$cparams->get('autoflogin', 1) ? '&fcu='.$user->username . '&fcp='.$user->password : ''; $previewlink = JRoute::_(JURI::root() . FlexicontentHelperRoute::getCategoryRoute($categories[$cid]->slug)) . $autologin; // Add a preview button $bar->appendButton('Custom', '<a class="preview btn btn-small btn-info spaced-btn" href="' . $previewlink . '" target="_blank" ><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('Preview') . '</a>', 'preview'); } // ************************ // Add modal layout editing // ************************ if (!$isnew && $perms->CanTemplates) { $inheritcid_comp = $cparams->get('inheritcid', -1); $inheritcid = $catparams->get('inheritcid', ''); $inherit_parent = $inheritcid === '-1' || $inheritcid === '' && $inheritcid_comp; if (!$inherit_parent || $row->parent_id === '1') { $row_clayout = $catparams->get('clayout', $cparams->get('clayout', 'blog')); } else { $row_clayout = $catparams->get('clayout', ''); if (!$row_clayout) { $_ancestors = $this->getModel()->getParentParams($row->id); // This is ordered by level ASC $row_clayout = $cparams->get('clayout', 'blog'); $cats_params = array(); foreach ($_ancestors as $_cid => $_cat) { $cats_params = new JRegistry($_cat->params); $row_clayout = $cats_params->get('clayout', '') ? $cats_params->get('clayout', '') : $row_clayout; } } } flexicontent_html::addToolBarButton('FLEXI_EDIT_LAYOUT', $btn_name = 'apply_ajax', $full_js = "var url = jQuery(this).attr('data-href'); fc_showDialog(url, 'fc_modal_popup_container'); return false;", $msg_alert = '', $msg_confirm = '', $btn_task = 'items.apply_ajax', $extra_js = '', $btn_list = false, $btn_menu = true, $btn_confirm = false, $btn_class = "btn-info" . $tip_class, $btn_icon = "icon-pencil", 'data-placement="bottom" data-href="index.php?option=com_flexicontent&view=template&type=category&tmpl=component&ismodal=1&folder=' . $row_clayout . '" title="Edit the display layout of this category. <br/><br/>Note: this layout maybe assigned to other categories, thus changing it will effect them too"'); } // ******************************************* // Prepare data to pass to the form's template // ******************************************* if (!FLEXI_J16GE) { //clean data JFilterOutput::objectHTMLSafe($row, ENT_QUOTES, 'description'); // Create the form $form = new JParameter($row->params, JPATH_COMPONENT . DS . 'models' . DS . 'category.xml'); //$form->loadINI($row->attribs); //echo "<pre>"; print_r($form->_xml['templates']->_children[0]); echo "<pre>"; print_r($form->_xml['templates']->param[0]); exit; foreach ($form->_xml['templates']->_children as $i => $child) { if (isset($child->_attributes['enableparam']) && !$cparams->get($child->_attributes['enableparam'])) { unset($form->_xml['templates']->_children[$i]); unset($form->_xml['templates']->param[$i]); } } foreach ($form->_xml['special']->_children as $i => $child) { if (isset($child->_attributes['enableparam']) && !$cparams->get($child->_attributes['enableparam'])) { unset($form->_xml['special']->_children[$i]); unset($form->_xml['special']->param[$i]); } } } // ********************************************************************************** // Get Templates and apply Template Parameters values into the form fields structures // ********************************************************************************** $themes = flexicontent_tmpl::getTemplates(); $tmpls = $themes->category; foreach ($tmpls as $tmpl) { $jform = new JForm('com_flexicontent.template.category', array('control' => 'jform', 'load_data' => true)); $jform->load($tmpl->params); $tmpl->params = $jform; // ... values applied at the template form file } //build selectlists $Lists = array(); if (!FLEXI_J16GE) { $javascript = "onchange=\"javascript:if (document.forms[0].image.options[selectedIndex].value!='') {document.imagelib.src='../images/stories/' + document.forms[0].image.options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\""; $Lists['imagelist'] = JHTML::_('list.images', 'image', $row->image, $javascript, '/images/stories/'); $Lists['access'] = JHTML::_('list.accesslevel', $row); // build granular access list if (FLEXI_ACCESS) { $Lists['access'] = FAccess::TabGmaccess($row, 'category', 1, 1, 1, 1, 1, 1, 1, 1, 1); } } $check_published = false; $check_perms = true; $actions_allowed = array('core.create'); $fieldname = FLEXI_J16GE ? 'jform[parent_id]' : 'parent_id'; $Lists['parent_id'] = flexicontent_cats::buildcatselect($categories, $fieldname, $row->parent_id, $top = 1, 'class="use_select2_lib"', $check_published, $check_perms, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array($row->id)); $check_published = false; $check_perms = true; $actions_allowed = array('core.edit', 'core.edit.own'); $fieldname = FLEXI_J16GE ? 'jform[copycid]' : 'copycid'; $Lists['copycid'] = flexicontent_cats::buildcatselect($categories, $fieldname, '', $top = 2, 'class="use_select2_lib"', $check_published, $check_perms, $actions_allowed, $require_all = false); $custom_options[''] = 'FLEXI_USE_GLOBAL'; $custom_options['0'] = 'FLEXI_COMPONENT_ONLY'; $custom_options['-1'] = 'FLEXI_PARENT_CAT_MULTI_LEVEL'; $check_published = false; $check_perms = true; $actions_allowed = array('core.edit', 'core.edit.own'); $fieldname = FLEXI_J16GE ? 'jform[special][inheritcid]' : 'params[inheritcid]'; $Lists['inheritcid'] = flexicontent_cats::buildcatselect($categories, $fieldname, $catparams->get('inheritcid', ''), $top = false, 'class="use_select2_lib"', $check_published, $check_perms, $actions_allowed, $require_all = false, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options); // ************************ // Assign variables to view // ************************ $this->assignRef('document', $document); $this->assignRef('Lists', $Lists); $this->assignRef('row', $row); $this->assignRef('form', $form); $this->assignRef('perms', $perms); $this->assignRef('editor', $editor); $this->assignRef('tmpls', $tmpls); $this->assignRef('cparams', $cparams); parent::display($tpl); }
/** * Display the view */ public function display($tpl = null) { $app = JFactory::getApplication(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $option = JRequest::getCmd('option'); $user = JFactory::getUser(); $acl = JFactory::getACL(); $cparams = JComponentHelper::getParams('com_flexicontent'); $print_logging_info = $cparams->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } JHTML::_('behavior.tooltip'); //get vars $filter_order = $app->getUserStateFromRequest("{$option}.authors.filter_order", 'filter_order', 'a.name', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest("{$option}.authors.filter_order_Dir", 'filter_order_Dir', '', 'word'); $filter_itemscount = $app->getUserStateFromRequest("{$option}.authors.filter_itemscount", 'filter_itemscount', '', 'int'); $filter_usergrp = $app->getUserStateFromRequest("{$option}.authors.filter_usergrp", 'filter_usergrp', '', 'string'); $filter_logged = $app->getUserStateFromRequest("{$option}.authors.filter_logged", 'filter_logged', '', 'int'); $date = $app->getUserStateFromRequest("{$option}.authors.date", 'date', 1, 'int'); $startdate = $app->getUserStateFromRequest("{$option}.authors.startdate", 'startdate', '', 'cmd'); $enddate = $app->getUserStateFromRequest("{$option}.authors.enddate", 'enddate', '', 'cmd'); if ($startdate == JText::_('FLEXI_FROM')) { $startdate = $app->setUserState("{$option}.authors.startdate", ''); } if ($enddate == JText::_('FLEXI_TO')) { $enddate = $app->setUserState("{$option}.authors.enddate", ''); } $filter_id = $app->getUserStateFromRequest("{$option}.authors.filter_id", 'filter_id', '', 'int'); $search = $app->getUserStateFromRequest("{$option}.authors.search", 'search', '', 'string'); if (strpos($search, '"') !== false) { $search = str_replace(array('=', '<'), '', $search); } $search = JString::strtolower($search); if ($cparams->get('show_usability_messages', 1)) { $notice_author_with_items_only = $app->getUserStateFromRequest($option . '.users.notice_author_with_items_only', 'notice_author_with_items_only', 0, 'int'); if (!$notice_author_with_items_only) { $app->setUserState($option . '.users.notice_author_with_items_only', 1); $app->enqueueMessage(JText::_('FLEXI_BY_DEFAULT_ONLY_AUTHORS_WITH_ITEMS_SHOWN'), 'notice'); $app->enqueueMessage(JText::_('FLEXI_USABILITY_MESSAGES_TURN_OFF'), 'message'); } } //add css and submenu to document $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css'); if (FLEXI_J30GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css'); } else { if (FLEXI_J16GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css'); } else { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css'); } } $js = "window.addEvent('domready', function(){"; if ($filter_usergrp) { $js .= "\$\$('.col_usergrp').each(function(el){ el.addClass('yellow'); });"; } if ($filter_logged) { $js .= "\$\$('.col_logged').each(function(el){ el.addClass('yellow'); });"; } if ($filter_id) { $js .= "\$\$('.col_id').each(function(el){ el.addClass('yellow'); });"; } if ($startdate || $enddate) { if ($date == 1) { $js .= "\$\$('.col_registered').each(function(el){ el.addClass('yellow'); });"; } else { if ($date == 2) { $js .= "\$\$('.col_visited').each(function(el){ el.addClass('yellow'); });"; } } } if ($filter_itemscount) { $js .= "\$\$('.col_itemscount').each(function(el){ el.addClass('yellow'); });"; } else { $js .= "\$\$('.col_itemscount').each(function(el){ el.removeClass('yellow'); });"; } if ($search) { $js .= "\$\$('.col_title').each(function(el){ el.addClass('yellow'); });"; } else { $js .= "\$\$('.col_title').each(function(el){ el.removeClass('yellow'); });"; } $js .= "});"; $document->addScriptDeclaration($js); // Get User's Global Permissions $perms = FlexicontentHelperPerm::getPerm(); // Create Submenu (and also check access to current view) FLEXISubmenu('CanAuthors'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_AUTHORS'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'authors'); $document->setTitle($doc_title . ' - ' . $site_title); // Create the toolbar $contrl = FLEXI_J16GE ? "users." : ""; JToolBarHelper::custom('logout', 'cancel.png', 'cancel_f2.png', 'Logout'); //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove'); // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag) $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE')); $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM'); $btn_task = $contrl . 'remove'; $extra_js = ""; flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); JToolBarHelper::addNew($contrl . 'add'); JToolBarHelper::editList($contrl . 'edit'); JToolBarHelper::divider(); JToolBarHelper::spacer(); if (!FLEXI_J16GE) { JToolBarHelper::help('screen.users'); } else { JToolBarHelper::help('JHELP_USERS_USER_MANAGER'); } if ($perms->CanConfig) { JToolBarHelper::divider(); JToolBarHelper::spacer(); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int'); $limitstart = $app->getUserStateFromRequest($option . '.limitstart', 'limitstart', 0, 'int'); $where = array(); $having = array(); $extra_joins = array(); if (isset($search) && $search != '') { $searchEscaped = FLEXI_J16GE ? $db->escape($search, true) : $db->getEscaped($search, true); $searchEscaped = $db->Quote('%' . $searchEscaped . '%', false); $where[] = 'a.username LIKE ' . $searchEscaped . ' OR a.email LIKE ' . $searchEscaped . ' OR a.name LIKE ' . $searchEscaped; } // visited date filtering if ($date == 1) { if ($startdate && !$enddate) { // from only $where[] = ' a.registerDate >= ' . $db->Quote($startdate); } if (!$startdate && $enddate) { // to only $where[] = ' a.registerDate <= ' . $db->Quote($enddate); } if ($startdate && $enddate) { // date range $where[] = '( a.registerDate >= ' . $db->Quote($startdate) . ' AND a.registerDate <= ' . $db->Quote($enddate) . ' )'; } } if ($date == 2) { if ($startdate && !$enddate) { // from only $where[] = ' a.lastvisitDate >= ' . $db->Quote($startdate); } if (!$startdate && $enddate) { // to only $where[] = ' a.lastvisitDate <= ' . $db->Quote($enddate); } if ($startdate && $enddate) { // date range $where[] = '( a.lastvisitDate >= ' . $db->Quote($startdate) . ' AND a.lastvisitDate <= ' . $db->Quote($enddate) . ' )'; } } if ($filter_id) { $where[] = 'a.id = ' . $filter_id; } if ($filter_usergrp) { if (!FLEXI_J16GE) { if ($filter_usergrp == 'Public Frontend') { $where[] = ' a.usertype = \'Registered\' OR a.usertype = \'Author\' OR a.usertype = \'Editor\' OR a.usertype = \'Publisher\' '; } else { if ($filter_usergrp == 'Public Backend') { $where[] = 'a.usertype = \'Manager\' OR a.usertype = \'Administrator\' OR a.usertype = \'Super Administrator\' '; } else { $where[] = 'a.usertype = LOWER( ' . $db->Quote($filter_usergrp) . ' ) '; } } } else { // Added as right join, see query bellow $extra_joins[] = ' RIGHT JOIN #__user_usergroup_map AS ug ON ug.user_id = a.id AND ug.group_id=' . $filter_usergrp; } } if ($filter_logged == 1) { $where[] = 's.userid IS NOT NULL'; } else { if ($filter_logged == 2) { $where[] = 's.userid IS NULL'; } } if (!$filter_itemscount) { $having[] = ' itemscount > 0 '; } else { if ($filter_itemscount == 1) { $having[] = ' itemscount = 0 '; } } // exclude any child group id's for this user, this applicable only in J1.5, and not for J16/J1.7/J2.5+ if (!FLEXI_J16GE) { $pgids = $acl->get_group_children($user->get('gid'), 'ARO', 'RECURSE'); if (is_array($pgids) && count($pgids) > 0) { JArrayHelper::toInteger($pgids); $where[] = 'a.gid NOT IN (' . implode(',', $pgids) . ')'; } } // ensure filter_order has a valid value. $allowed_order_cols = array('a.name', 'itemscount', 'a.username', 'loggedin', 'a.block', 'groupname', 'a.email', 'a.lastvisitDate', 'a.lastvisitDate', 'a.id'); if (!in_array($filter_order, $allowed_order_cols)) { $filter_order = 'a.name'; } if (!in_array(strtoupper($filter_order_Dir), array('ASC', 'DESC'))) { $filter_order_Dir = ''; } $orderby = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir; $where = count($where) ? ' WHERE (' . implode(') AND (', $where) . ')' : ''; $having = count($having) ? ' HAVING (' . implode(') AND (', $having) . ')' : ''; $extra_joins = count($extra_joins) ? implode(' ', $extra_joins) : ''; // Do main query to get the authors $query = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT a.*, s.userid IS NOT NULL AS loggedin' . ', (SELECT COUNT(*) FROM #__content AS i WHERE i.created_by = a.id) AS itemscount ' . (!FLEXI_J16GE ? ', g.name AS groupname' : '') . ' FROM #__users AS a' . (!FLEXI_J16GE ? ' INNER JOIN #__core_acl_aro AS aro ON aro.value = a.id' : '') . (!FLEXI_J16GE ? ' INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.id' : '') . (!FLEXI_J16GE ? ' INNER JOIN #__core_acl_aro_groups AS g ON g.id = gm.group_id' : '') . ' LEFT JOIN #__flexicontent_authors_ext AS ue ON a.id = ue.user_id' . ' LEFT JOIN #__session AS s ON s.userid = a.id' . $extra_joins . $where . $having . $orderby; $db->setQuery($query, $limitstart, $limit); if ($print_logging_info) { $start_microtime = microtime(true); } $rows = $db->loadObjectList(); if ($print_logging_info) { @($fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } if ($db->getErrorMsg()) { echo $db->getErrorMsg(); } // Get total and create pagination controls $db->setQuery("SELECT FOUND_ROWS()"); $total = $db->loadResult(); if (!$total) { echo $db->getErrorMsg(); } // Create pagination jimport('joomla.html.pagination'); $pagination = new JPagination($total, $limitstart, $limit); // DB Query (J2.5 only) to get -mulitple- user group ids for all authors, // this is needed because user-To-usergoup mapping are stored in separate table if (FLEXI_J16GE) { $user_ids = array(); foreach ($rows as $row) { $row->usergroups = array(); $user_ids[] = $row->id; } $query = 'SELECT user_id, group_id FROM #__user_usergroup_map ' . (count($user_ids) ? 'WHERE user_id IN (' . implode(',', $user_ids) . ')' : ''); $db->setQuery($query); $ugdata_arr = $db->loadObjectList(); foreach ($ugdata_arr as $ugdata) { $usergroups[$ugdata->user_id][] = $ugdata->group_id; } foreach ($rows as $row) { $row->usergroups = $usergroups[$row->id]; } } // get list of Groups for dropdown filter if (FLEXI_J16GE) { $query = 'SELECT *, id AS value, title AS text FROM #__usergroups'; } else { $query = 'SELECT *, name AS value, name AS text FROM #__core_acl_aro_groups WHERE name != "ROOT" AND name != "USERS"'; } $db->setQuery($query); $usergroups = $db->loadObjectList('id'); $types[] = JHTML::_('select.option', '', '- ' . JText::_('Select Group') . ' -'); foreach ($usergroups as $ugrp) { $types[] = JHTML::_('select.option', $ugrp->value, JText::_($ugrp->text)); } $itemscount_options[] = JHTML::_('select.option', '', '- ' . JText::_('One or more') . ' -'); $itemscount_options[] = JHTML::_('select.option', 1, JText::_('None')); $itemscount_options[] = JHTML::_('select.option', 2, JText::_('Any number')); $lists['filter_itemscount'] = JHTML::_('select.genericlist', $itemscount_options, 'filter_itemscount', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "{$filter_itemscount}"); $lists['filter_usergrp'] = JHTML::_('select.genericlist', $types, 'filter_usergrp', 'class="inputbox" style="width:auto;" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "{$filter_usergrp}"); // get list of Log Status for dropdown filter $logged[] = JHTML::_('select.option', '', '- ' . JText::_('Select Log Status') . ' -'); $logged[] = JHTML::_('select.option', 1, JText::_('Logged In')); $logged[] = JHTML::_('select.option', 2, JText::_('Logged Out')); $lists['filter_logged'] = JHTML::_('select.genericlist', $logged, 'filter_logged', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "{$filter_logged}"); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // build dates option list $dates = array(); $dates[] = JHTML::_('select.option', '1', JText::_('Registered')); $dates[] = JHTML::_('select.option', '2', JText::_('Last Visit')); $lists['date'] = JHTML::_('select.radiolist', $dates, 'date', 'size="1" class="inputbox"', 'value', 'text', $date); $lists['startdate'] = JHTML::_('calendar', $startdate, 'startdate', 'startdate', '%Y-%m-%d', array('class' => 'inputbox', 'size' => '11', 'maxlength' => '20')); $lists['enddate'] = JHTML::_('calendar', $enddate, 'enddate', 'enddate', '%Y-%m-%d', array('class' => 'inputbox', 'size' => '11', 'maxlength' => '20')); // search filter $lists['search'] = $search; // search id $lists['filter_id'] = $filter_id; $this->assignRef('lists', $lists); $this->assignRef('items', $rows); $this->assignRef('usergroups', $usergroups); $this->assignRef('pagination', $pagination); // filters $this->assignRef('filter_id', $filter_id); $this->assignRef('filter_itemscount', $filter_itemscount); $this->assignRef('filter_usergrp', $filter_usergrp); $this->assignRef('filter_logged', $filter_logged); $this->assignRef('search', $search); $this->assignRef('filter_id', $filter_id); $this->assignRef('date', $date); $this->assignRef('startdate', $startdate); $this->assignRef('enddate', $enddate); parent::display($tpl); }
function display($tpl = null) { // ******************** // Initialise variables // ******************** global $globalcats; $app = JFactory::getApplication(); $cparams = JComponentHelper::getParams('com_flexicontent'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $option = JRequest::getCmd('option'); $view = JRequest::getVar('view'); $order_property = 'c.lft'; // Get model $model = $this->getModel(); $print_logging_info = $cparams->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } // *********** // Get filters // *********** $count_filters = 0; // various filters $filter_state = $model->getState('filter_state'); $filter_cats = $model->getState('filter_cats'); $filter_level = $model->getState('filter_level'); $filter_access = $model->getState('filter_access'); $filter_language = $model->getState('filter_language'); if ($filter_state) { $count_filters++; } if ($filter_cats) { $count_filters++; } if ($filter_level) { $count_filters++; } if ($filter_access) { $count_filters++; } if ($filter_language) { $count_filters++; } // Item ID filter $filter_id = $model->getState('filter_id'); if ($filter_id) { $count_filters++; } // text search $search = $model->getState('search'); $search = $db->escape(trim(JString::strtolower($search))); // ordering $filter_order = $model->getState('filter_order'); $filter_order_Dir = $model->getState('filter_order_Dir'); // ************************** // Add css and js to document // ************************** flexicontent_html::loadFramework('select2'); //JHTML::_('behavior.tooltip'); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VHASH); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VHASH); // ***************************** // Get user's global permissions // ***************************** $perms = FlexicontentHelperPerm::getPerm(); // ************************ // Create Submenu & Toolbar // ************************ // Create Submenu (and also check access to current view) FLEXISubmenu('CanCats'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_CATEGORIES'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'fc_categories'); $document->setTitle($doc_title . ' - ' . $site_title); $js = "jQuery(document).ready(function(){"; $contrl = "categories."; $contrl_singular = "category."; $toolbar = JToolBar::getInstance('toolbar'); // Copy Parameters $btn_task = ''; $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent&view=categories&layout=params&tmpl=component'; if (FLEXI_J30GE || !FLEXI_J16GE) { // Layout of Popup button broken in J3.1, add in J1.5 it generates duplicate HTML tag id (... just for validation), so add manually $js .= "\n\t\t\t\tjQuery('#toolbar-params a.toolbar, #toolbar-params button')\n\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 600, y: 440}, onClose: function() {}}');\n\t\t\t"; JToolBarHelper::custom($btn_task, 'params.png', 'params_f2.png', 'FLEXI_COPY_PARAMS', false); JHtml::_('behavior.modal', '#toolbar-params a.toolbar, #toolbar-params button'); } else { $toolbar->appendButton('Popup', 'params', JText::_('FLEXI_COPY_PARAMS'), str_replace('&', '&', $popup_load_url), 600, 440); } //$toolbar->appendButton('Popup', 'move', JText::_('FLEXI_BATCH'), JURI::base().'index.php?option=com_flexicontent&view=categories&layout=batch&tmpl=component', 800, 440); JToolBarHelper::divider(); $add_divider = false; if ($user->authorise('core.create', 'com_flexicontent')) { $cancreate_cat = true; } else { $usercats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true, $check_published = true, $specific_catids = false, $find_first = true); $cancreate_cat = count($usercats) > 0; } if ($cancreate_cat) { JToolBarHelper::addNew($contrl_singular . 'add'); $add_divider = true; } if ($user->authorise('core.edit', 'com_flexicontent') || $user->authorise('core.edit.own', 'com_flexicontent')) { JToolBarHelper::editList($contrl_singular . 'edit'); $add_divider = true; } $add_divider = false; if ($user->authorise('core.edit.state', 'com_flexicontent') || $user->authorise('core.edit.state.own', 'com_flexicontent')) { JToolBarHelper::publishList($contrl . 'publish'); JToolBarHelper::unpublishList($contrl . 'unpublish'); JToolBarHelper::divider(); JToolBarHelper::archiveList($contrl . 'archive'); } $add_divider = false; if ($filter_state == -2 && $user->authorise('core.delete', 'com_flexicontent')) { //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove'); // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag) $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE')); $msg_confirm = JText::_('FLEXI_ARE_YOU_SURE'); $btn_task = $contrl . 'remove'; $extra_js = ""; flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); $add_divider = true; } elseif ($user->authorise('core.edit.state', 'com_flexicontent')) { JToolBarHelper::trash($contrl . 'trash'); $add_divider = true; } if ($add_divider) { JToolBarHelper::divider(); } // Checkin JToolBarHelper::checkin($contrl . 'checkin'); $appsman_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'appsman'; if (file_exists($appsman_path)) { $btn_icon = 'icon-download'; $btn_name = 'download'; $btn_task = 'appsman.exportxml'; $extra_js = " var f=document.getElementById('adminForm'); f.elements['view'].value='appsman'; jQuery('<input>').attr({type: 'hidden', name: 'table', value: 'categories'}).appendTo(jQuery(f));"; flexicontent_html::addToolBarButton('Export now', $btn_name, $full_js = '', $msg_alert = '', $msg_confirm = 'Export now as XML', $btn_task, $extra_js, $btn_list = false, $btn_menu = true, $btn_confirm = true, $btn_class = "btn-warning", $btn_icon); $btn_icon = 'icon-box-add'; $btn_name = 'box-add'; $btn_task = 'appsman.addtoexport'; $extra_js = " var f=document.getElementById('adminForm'); f.elements['view'].value='appsman'; jQuery('<input>').attr({type: 'hidden', name: 'table', value: 'categories'}).appendTo(jQuery(f));"; flexicontent_html::addToolBarButton('Add to export', $btn_name, $full_js = '', $msg_alert = '', $msg_confirm = 'Add to export list', $btn_task, $extra_js, $btn_list = false, $btn_menu = true, $btn_confirm = true, $btn_class = "btn-warning", $btn_icon); } if ($perms->CanConfig) { //JToolBarHelper::custom($contrl.'rebuild', 'refresh.png', 'refresh_f2.png', 'JTOOLBAR_REBUILD', false); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } $js .= "});"; $document->addScriptDeclaration($js); // Get data from the model if ($print_logging_info) { $start_microtime = microtime(true); } $rows = $this->get('Items'); if ($print_logging_info) { @($fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } // Get assigned items $rowids = array(); foreach ($rows as $row) { $rowids[] = $row->id; } if ($print_logging_info) { $start_microtime = microtime(true); } //$rowtotals = $model->getAssignedItems($rowids); $byStateTotals = $model->countItemsByState($rowids); if ($print_logging_info) { @($fc_run_times['execute_sec_queries'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } foreach ($rows as $row) { //$row->nrassigned = isset($rowtotals[$row->id]) ? $rowtotals[$row->id]->nrassigned : 0; $row->byStateTotals = isset($byStateTotals[$row->id]) ? $byStateTotals[$row->id] : array(); } // Parse configuration for every category foreach ($rows as $cat) { $cat->config = new JRegistry($cat->config); } $this->state = $this->get('State'); // Preprocess the list of items to find ordering divisions. foreach ($rows as &$item) { $this->ordering[$item->parent_id][] = $item->id; } unset($item); // unset the variable reference to avoid trouble if variable is reused, thus overwritting last pointed variable $pagination = $this->get('Pagination'); $categories =& $globalcats; $lists['copyid'] = flexicontent_cats::buildcatselect($categories, 'copycid', '', 2, 'class="use_select2_lib"', false, true, $actions_allowed = array('core.edit')); $lists['destid'] = flexicontent_cats::buildcatselect($categories, 'destcid[]', '', false, 'class="use_select2_lib" size="10" multiple="true"', false, true, $actions_allowed = array('core.edit')); // ******************* // Create Form Filters // ******************* // filter by a category (it's subtree will be displayed) $categories = $globalcats; $lists['cats'] = ($filter_cats || 1 ? '<label class="label">' . JText::_('FLEXI_CATEGORY') . '</label>' : '') . flexicontent_cats::buildcatselect($categories, 'filter_cats', $filter_cats, '-', 'class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', $check_published = true, $check_perms = false); // filter depth level $options = array(); $options[] = JHtml::_('select.option', '', '-'); for ($i = 1; $i <= 10; $i++) { $options[] = JHtml::_('select.option', $i, $i); } $fieldname = $elementid = 'filter_level'; $attribs = 'class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"'; $lists['level'] = ($filter_level || 1 ? '<label class="label">' . JText::_('FLEXI_MAX_DEPTH') . '</label>' : '') . JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_level, $elementid, $translate = true); // filter publication state $options = JHtml::_('jgrid.publishedOptions'); array_unshift($options, JHtml::_('select.option', '', '-')); $fieldname = $elementid = 'filter_state'; $attribs = 'class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"'; $lists['state'] = ($filter_state || 1 ? '<label class="label">' . JText::_('FLEXI_STATE') . '</label>' : '') . JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_state, $elementid, $translate = true); // filter access level $options = JHtml::_('access.assetgroups'); array_unshift($options, JHtml::_('select.option', '', '-')); $fieldname = $elementid = 'filter_access'; $attribs = 'class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"'; $lists['access'] = ($filter_access || 1 ? '<label class="label">' . JText::_('FLEXI_ACCESS') . '</label>' : '') . JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_access, $elementid, $translate = true); // filter language $lists['language'] = ($filter_language || 1 ? '<label class="label">' . JText::_('FLEXI_LANGUAGE') . '</label>' : '') . flexicontent_html::buildlanguageslist('filter_language', 'class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', $filter_language, '-'); // filter search word $lists['search'] = $search; // search id $lists['filter_id'] = $filter_id; // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; $orderingx = $lists['order'] == $order_property && strtolower($lists['order_Dir']) == 'asc' ? $order_property : ''; //assign data to template $this->assignRef('CanTemplates', $perms->CanTemplates); $this->assignRef('count_filters', $count_filters); $this->assignRef('lists', $lists); $this->assignRef('rows', $rows); $this->assignRef('perms', $perms); $this->assignRef('orderingx', $orderingx); $this->assignRef('pagination', $pagination); $this->assignRef('user', $user); $this->assignRef('option', $option); $this->assignRef('view', $view); $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null; parent::display($tpl); }
function display($tpl = null) { global $globalcats; $app = JFactory::getApplication(); $cparams = JComponentHelper::getParams('com_flexicontent'); //initialise variables $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $option = JRequest::getCmd('option'); $task = JRequest::getVar('task', ''); $cid = JRequest::getVar('cid', array()); $bind_limit = JRequest::getInt('bind_limit', 1000); $session = JFactory::getSession(); $fileid_to_itemids = $session->get('fileid_to_itemids', array(), 'flexicontent'); $filter_fileid = JRequest::getInt('filter_fileid', 0); // Some flags $enable_translation_groups = $cparams->get("enable_translation_groups") && (FLEXI_J16GE || FLEXI_FISH); $print_logging_info = $cparams->get('print_logging_info'); FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); if ($task == 'copy') { $this->setLayout('copy'); $this->_displayCopyMove($tpl, $cid); return; } flexicontent_html::loadJQuery(); flexicontent_html::loadFramework('select2'); JHTML::_('behavior.tooltip'); JHTML::_('behavior.calendar'); // Get filters $count_filters = 0; $filter_cats = $app->getUserStateFromRequest($option . '.items.filter_cats', 'filter_cats', '', 'int'); $filter_subcats = $app->getUserStateFromRequest($option . '.items.filter_subcats', 'filter_subcats', 1, 'int'); $filter_catsinstate = $app->getUserStateFromRequest($option . '.items.filter_catsinstate', 'filter_catsinstate', 1, 'int'); if ($filter_cats) { $count_filters++; } $filter_order_type = $app->getUserStateFromRequest($option . '.items.filter_order_type', 'filter_order_type', 1, 'int'); $filter_order = $app->getUserStateFromRequest($option . '.items.filter_order', 'filter_order', '', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest($option . '.items.filter_order_Dir', 'filter_order_Dir', '', 'word'); $filter_type = $app->getUserStateFromRequest($option . '.items.filter_type', 'filter_type', 0, 'int'); $filter_authors = $app->getUserStateFromRequest($option . '.items.filter_authors', 'filter_authors', 0, 'int'); $filter_state = $app->getUserStateFromRequest($option . '.items.filter_state', 'filter_state', '', 'word'); if ($filter_type) { $count_filters++; } if ($filter_authors) { $count_filters++; } if ($filter_state) { $count_filters++; } $filter_stategrp = $app->getUserStateFromRequest($option . '.items.filter_stategrp', 'filter_stategrp', '', 'word'); if (FLEXI_FISH || FLEXI_J16GE) { $filter_lang = $app->getUserStateFromRequest($option . '.items.filter_lang', 'filter_lang', '', 'string'); if ($filter_lang) { $count_filters++; } } $scope = $app->getUserStateFromRequest($option . '.items.scope', 'scope', 1, 'int'); $date = $app->getUserStateFromRequest($option . '.items.date', 'date', 1, 'int'); $startdate = $app->getUserStateFromRequest($option . '.items.startdate', 'startdate', '', 'cmd'); if ($startdate == JText::_('FLEXI_FROM')) { $startdate = $app->setUserState($option . '.items.startdate', ''); } if ($startdate) { $count_filters++; } $enddate = $app->getUserStateFromRequest($option . '.items.enddate', 'enddate', '', 'cmd'); if ($enddate == JText::_('FLEXI_TO')) { $enddate = $app->setUserState($option . '.items.enddate', ''); } if ($enddate) { $count_filters++; } $filter_id = $app->getUserStateFromRequest($option . '.items.filter_id', 'filter_id', '', 'int'); if ($filter_id) { $count_filters++; } $search = $app->getUserStateFromRequest($option . '.items.search', 'search', '', 'string'); $search = FLEXI_J16GE ? $db->escape(trim(JString::strtolower($search))) : $db->getEscaped(trim(JString::strtolower($search))); if ($search) { $count_filters++; } // Add custom css and js to document $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css'); if (FLEXI_J30GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css'); } else { if (FLEXI_J16GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css'); } else { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css'); } } $document->addScript(JURI::base() . 'components/com_flexicontent/assets/js/stateselector.js'); $document->addScript(JURI::base() . 'components/com_flexicontent/assets/js/flexi-lib.js'); $js = "window.addEvent('domready', function(){"; if ($filter_cats) { $js .= "\$\$('.col_cats').each(function(el){ el.addClass('yellow'); });"; } if ($filter_type) { $js .= "\$\$('.col_type').each(function(el){ el.addClass('yellow'); });"; } if ($filter_authors) { $js .= "\$\$('.col_authors').each(function(el){ el.addClass('yellow'); });"; } if ($filter_state) { $js .= "\$\$('.col_state').each(function(el){ el.addClass('yellow'); });"; } if (FLEXI_FISH || FLEXI_J16GE) { if ($filter_lang) { $js .= "\$\$('.col_lang').each(function(el){ el.addClass('yellow'); });"; } } if ($filter_id) { $js .= "\$\$('.col_id').each(function(el){ el.addClass('yellow'); });"; } if ($startdate || $enddate) { if ($date == 1) { $js .= "\$\$('.col_created').each(function(el){ el.addClass('yellow'); });"; } else { if ($date == 2) { $js .= "\$\$('.col_revised').each(function(el){ el.addClass('yellow'); });"; } } } if ($search) { $js .= "\$\$('.col_title').each(function(el){ el.addClass('yellow'); });"; } else { $js .= "\$\$('.col_title').each(function(el){ el.removeClass('yellow'); });"; } // Check if user can create in at least one published category require_once "components/com_flexicontent/models/item.php"; $itemmodel = new FlexicontentModelItem(); $CanAdd = !FLEXI_J16GE ? $itemmodel->canAdd() : $itemmodel->getItemAccess()->get('access-create'); // Performance consideration: ... CHECK ONLY global permissions, and not individual categories $perms = FlexicontentHelperPerm::getPerm(); $CanEdit = $perms->CanEdit; $CanPublish = $perms->CanPublish; $CanDelete = $perms->CanDelete; $CanEditOwn = $perms->CanEditOwn; $CanPublishOwn = $perms->CanPublishOwn; $CanDeleteOwn = $perms->CanDeleteOwn; $CanCats = $perms->CanCats; $CanAccLvl = $perms->CanAccLvl; $CanOrder = $perms->CanOrder; $CanCopy = $perms->CanCopy; $CanArchives = $perms->CanArchives; // Create Submenu (and also check access to current view) FLEXISubmenu('notvariable'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_ITEMS'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'items'); $document->setTitle($doc_title . ' - ' . $site_title); // Create the toolbar $toolbar = JToolBar::getInstance('toolbar'); $add_divider = false; if ($filter_stategrp != '') { $btn_task = FLEXI_J16GE ? 'items.display' : 'display'; $extra_js = "document.getElementById('filter_stategrp').checked=true;"; flexicontent_html::addToolBarButton('FLEXI_DISPLAY_NORMAL', 'preview', $full_js = '', $msg_alert = '', $msg_confirm = '', $btn_task, $extra_js, $btn_list = false, $btn_menu = true, $btn_confirm = false); $add_divider = true; } /*if ( ($CanDelete || $CanDeleteOwn) && $filter_stategrp != 'trashed' ) { $btn_task = FLEXI_J16GE ? 'items.display' : 'display'; $extra_js = "document.getElementById('filter_stategrptrashed').checked=true;"; flexicontent_html::addToolBarButton( 'FLEXI_DISPLAY_TRASH', 'preview', $full_js='', $msg_alert='', $msg_confirm='', $btn_task, $extra_js, $btn_list=false, $btn_menu=true, $btn_confirm=false); $add_divider = true; } if ($CanArchives && $filter_stategrp != 'archived') { $btn_task = FLEXI_J16GE ? 'items.display' : 'display'; $extra_js = "document.getElementById('filter_stategrparchived').checked=true;"; flexicontent_html::addToolBarButton( 'FLEXI_DISPLAY_ARCHIVE', 'preview', $full_js='', $msg_alert='', $msg_confirm='', $btn_task, $extra_js, $btn_list=false, $btn_menu=true, $btn_confirm=false); $add_divider = true; } if ($add_divider) { JToolBarHelper::divider(); }*/ // Implementation of multiple-item state selector $add_divider = false; if ($CanPublish || $CanPublishOwn) { $btn_task = ''; $ctrl_task = FLEXI_J16GE ? '&task=items.selectstate' : '&controller=items&task=selectstate'; $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent' . $ctrl_task . '&format=raw'; if (FLEXI_J30GE || !FLEXI_J16GE) { // Layout of Popup button broken in J3.1, add in J1.5 it generates duplicate HTML tag id (... just for validation), so add manually $js .= "\n\t\t\t\t\tjQuery('#toolbar-publish a.toolbar, #toolbar-publish button')\n\t\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 800, y: 240}, onClose: function() {}}');\n\t\t\t\t"; //JToolBarHelper::publishList( $btn_task ); JToolBarHelper::custom($btn_task, 'publish.png', 'publish_f2.png', 'FLEXI_CHANGE_STATE', false); JHtml::_('behavior.modal', '#toolbar-publish a.toolbar, #toolbar-publish button'); } else { $toolbar->appendButton('Popup', 'publish', JText::_('FLEXI_CHANGE_STATE'), str_replace('&', '&', $popup_load_url), 800, 240); } $add_divider = true; } if ($CanDelete || $CanDeleteOwn) { if ($filter_stategrp == 'trashed') { $btn_msg = 'FLEXI_ARE_YOU_SURE'; $btn_task = FLEXI_J16GE ? 'items.remove' : 'remove'; JToolBarHelper::deleteList($btn_msg, $btn_task); } else { $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_TRASH')); $msg_confirm = JText::_('FLEXI_TRASH_CONFIRM'); $btn_task = FLEXI_J16GE ? 'items.changestate' : 'changestate'; $extra_js = "document.adminForm.newstate.value='T';"; flexicontent_html::addToolBarButton('FLEXI_TRASH', 'trash', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); } $add_divider = true; } if ($CanArchives && $filter_stategrp != 'archived') { $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_ARCHIVE')); $msg_confirm = JText::_('FLEXI_ARCHIVE_CONFIRM'); $btn_task = FLEXI_J16GE ? 'items.changestate' : 'changestate'; $extra_js = "document.adminForm.newstate.value='A';"; flexicontent_html::addToolBarButton('FLEXI_ARCHIVE', 'archive', $full_js = '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); $add_divider = true; } if ($CanArchives && $filter_stategrp == 'archived' || ($CanDelete || $CanDeleteOwn) && $filter_stategrp == 'trashed') { $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_RESTORE')); $msg_confirm = JText::_('FLEXI_RESTORE_CONFIRM'); $btn_task = FLEXI_J16GE ? 'items.changestate' : 'changestate'; $extra_js = "document.adminForm.newstate.value='P';"; flexicontent_html::addToolBarButton('FLEXI_RESTORE', 'restore', $full_js = '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); } if ($add_divider) { JToolBarHelper::divider(); } $add_divider = false; if ($CanAdd) { $btn_task = ''; $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent&view=types&format=raw'; if (FLEXI_J30GE || !FLEXI_J16GE) { // Layout of Popup button broken in J3.1, add in J1.5 it generates duplicate HTML tag id (... just for validation), so add manually $js .= "\n\t\t\t\t\tjQuery('#toolbar-new a.toolbar, #toolbar-new button')\n\t\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 800, y: 240}, onClose: function() {}}');\n\t\t\t\t"; //JToolBarHelper::addNew( $btn_task ); JToolBarHelper::custom($btn_task, 'new.png', 'new_f2.png', 'FLEXI_NEW', false); JHtml::_('behavior.modal', '#toolbar-new a.toolbar, #toolbar-new button'); } else { $toolbar->appendButton('Popup', 'new', JText::_('FLEXI_NEW'), str_replace('&', '&', $popup_load_url), 800, 240); } $add_divider = true; } if ($CanEdit || $CanEditOwn) { $btn_task = FLEXI_J16GE ? 'items.edit' : 'edit'; JToolBarHelper::editList($btn_task); $add_divider = true; } if ($add_divider) { JToolBarHelper::divider(); } $add_divider = false; if ($CanAdd && $CanCopy) { $btn_task = FLEXI_J16GE ? 'items.copy' : 'copy'; JToolBarHelper::custom($btn_task, 'copy.png', 'copy_f2.png', 'FLEXI_COPY_MOVE'); if ($enable_translation_groups) { JToolBarHelper::custom('translate', 'translate', 'translate', 'FLEXI_TRANSLATE'); } $add_divider = true; } if ($add_divider) { JToolBarHelper::divider(); JToolBarHelper::spacer(); } if ($perms->CanConfig) { $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } $js .= "});"; $document->addScriptDeclaration($js); // *********************** // Get data from the model // *********************** $model = $this->getModel(); $badcatitems = (int) $model->getUnboundedItems($limit = 10000000, $count_only = true, $checkNoExtData = false, $checkInvalidCat = true); $unassociated = (int) $model->getUnboundedItems($limit = 10000000, $count_only = true, $checkNoExtData = true, $checkInvalidCat = false); $rows = $this->get('Data'); $pagination = $this->get('Pagination'); $types = $this->get('Typeslist'); $authors = $this->get('Authorslist'); // these depend on data rows and must be called after getting data $extraCols = $this->get('ExtraCols'); $itemCats = $this->get('ItemCats'); if ($enable_translation_groups) { $langAssocs = $this->get('LangAssocs'); } if (FLEXI_FISH || FLEXI_J16GE) { $langs = FLEXIUtilities::getLanguages('code'); } $categories = $globalcats ? $globalcats : array(); $limit = $pagination->limit; $inline_ss_max = 30; $drag_reorder_max = 100; if ($limit > $drag_reorder_max) { $cparams->set('draggable_reordering', 0); } // ****************************************** // Add usability notices if these are enabled // ****************************************** if ($cparams->get('show_usability_messages', 1) && !$unassociated && !$badcatitems) { $notice_iss_disabled = $app->getUserStateFromRequest($option . '.items.notice_iss_disabled', 'notice_iss_disabled', 0, 'int'); if (!$notice_iss_disabled && $limit > $inline_ss_max) { $app->setUserState($option . '.items.notice_iss_disabled', 1); $app->enqueueMessage(JText::sprintf('FLEXI_INLINE_ITEM_STATE_SELECTOR_DISABLED', $inline_ss_max), 'notice'); $show_turn_off_notice = 1; } $notice_drag_reorder_disabled = $app->getUserStateFromRequest($option . '.items.notice_drag_reorder_disabled', 'notice_drag_reorder_disabled', 0, 'int'); if (!$notice_drag_reorder_disabled && $limit > $drag_reorder_max) { $app->setUserState($option . '.items.notice_drag_reorder_disabled', 1); $app->enqueueMessage(JText::sprintf('FLEXI_DRAG_REORDER_DISABLED', $drag_reorder_max), 'notice'); $show_turn_off_notice = 1; } $notice_add_custom_columns = $app->getUserStateFromRequest($option . '.items.notice_add_custom_columns', 'notice_add_custom_columns', 0, 'int'); if (!$notice_add_custom_columns) { $app->setUserState($option . '.items.notice_add_custom_columns', 1); $app->enqueueMessage(JText::_('FLEXI_YOU_MAY_CONFIGURE_CUSTOM_COLUMNS_GLOBAL_AND_PER_TYPE'), 'message'); $show_turn_off_notice = 1; } if (!empty($show_turn_off_notice)) { $app->enqueueMessage(JText::_('FLEXI_USABILITY_MESSAGES_TURN_OFF'), 'notice'); } } // ******************* // Create Filters HTML // ******************* $state[] = JHTML::_('select.option', '', JText::_('FLEXI_SELECT_STATE')); $state[] = JHTML::_('select.option', 'P', JText::_('FLEXI_PUBLISHED')); $state[] = JHTML::_('select.option', 'U', JText::_('FLEXI_UNPUBLISHED')); $state[] = JHTML::_('select.option', 'PE', JText::_('FLEXI_PENDING')); $state[] = JHTML::_('select.option', 'OQ', JText::_('FLEXI_TO_WRITE')); $state[] = JHTML::_('select.option', 'IP', JText::_('FLEXI_IN_PROGRESS')); $state[] = JHTML::_('select.option', 'RV', JText::_('FLEXI_REVISED_VER')); $lists['filter_state'] = JHTML::_('select.genericlist', $state, 'filter_state', 'class="use_select2_lib" size="1" onchange="submitform( );"', 'value', 'text', $filter_state); // build filter state group if ($CanDelete || $CanDeleteOwn || $CanArchives) { $stategroups[''] = JText::_('FLEXI_GRP_NORMAL') . ' ' . JText::_('FLEXI_STATE_S'); $stategroups['published'] = JText::_('FLEXI_GRP_PUBLISHED') . ' ' . JText::_('FLEXI_STATE_S'); $stategroups['unpublished'] = JText::_('FLEXI_GRP_UNPUBLISHED') . ' ' . JText::_('FLEXI_STATE_S'); if ($CanDelete || $CanDeleteOwn) { $stategroups['trashed'] = JText::_('FLEXI_GRP_TRASHED'); } if ($CanArchives) { $stategroups['archived'] = JText::_('FLEXI_GRP_ARCHIVED'); } $stategroups['orphan'] = JText::_('FLEXI_GRP_ORPHAN'); $stategroups['all'] = JText::_('FLEXI_GRP_ALL'); /*$_stategroups = array(); foreach ($stategroups as $i => $v) { $_stategroups[] = JHTML::_('select.option', $i, $v); } $lists['filter_stategrp'] = JHTML::_('select.radiolist', $_stategroups, 'filter_stategrp', 'size="1" class="inputbox" onchange="submitform();"', 'value', 'text', $filter_stategrp );*/ $lists['filter_stategrp'] = ''; foreach ($stategroups as $i => $v) { $checked = $filter_stategrp == $i ? ' checked="checked" ' : ''; $lists['filter_stategrp'] .= '<input type="radio" onchange="submitform();" class="inputbox" ' . $checked . ' value="' . $i . '" id="filter_stategrp' . $i . '" name="filter_stategrp" />'; $lists['filter_stategrp'] .= '<label class="" id="filter_stategrp' . $i . '-lbl" for="filter_stategrp' . $i . '">' . $v . '</label>'; } } // build the include subcats boolean list // build the include non-published cats boolean list if ($filter_order_type && $filter_cats && ($filter_order == 'i.ordering' || $filter_order == 'catsordering')) { $ordering_tip = '<img src="components/com_flexicontent/assets/images/comment.png" class="hasTip" title="' . JText::_('FLEXI_REASON', true) . '::' . JText::_('<u>Items may belong to both</u>: <br/> (a) currently filtered category <br/>(b) to any of its subcategories, <br/> -- Thus item may get listed in a subcategory instead of the currently filtered category, to avoid this sub-categories are not included.', true) . '" />'; $lists['filter_subcats'] = '<span class="fc-mssg-inline fc-note">' . JText::_('Sub-categories not included during specific category ordering: ') . $ordering_tip . '</span>'; } else { $lists['filter_subcats'] = JHTML::_('select.booleanlist', 'filter_subcats', 'class="inputbox" onchange="submitform();"', $filter_subcats); } // build the include non-published cats boolean list $catsinstate[1] = JText::_('FLEXI_PUBLISHED'); $catsinstate[0] = JText::_('FLEXI_UNPUBLISHED'); $catsinstate[99] = JText::_('FLEXI_ANY'); if (FLEXI_J16GE) { $catsinstate[2] = JText::_('FLEXI_ARCHIVED_STATE'); $catsinstate[-2] = JText::_('FLEXI_TRASHED_STATE'); } /*$_catsinstate = array(); foreach ($catsinstate as $i => $v) { $_catsinstate[] = JHTML::_('select.option', $i, $v); } $lists['filter_catsinstate'] = JHTML::_('select.radiolist', $_catsinstate, 'filter_catsinstate', 'size="1" class="inputbox" onchange="submitform();"', 'value', 'text', $filter_catsinstate );*/ $lists['filter_catsinstate'] = ''; foreach ($catsinstate as $i => $v) { $checked = $filter_catsinstate == $i ? ' checked="checked" ' : ''; $lists['filter_catsinstate'] .= '<input type="radio" onchange="submitform();" class="inputbox" ' . $checked . ' value="' . $i . '" id="filter_catsinstate' . $i . '" name="filter_catsinstate" />'; $lists['filter_catsinstate'] .= '<label class="" id="filter_catsinstate' . $i . '-lbl" for="filter_catsinstate' . $i . '">' . $v . '</label>'; } // build the order type boolean list $order_types = array(); $order_types[] = JHTML::_('select.option', '0', JText::_('FLEXI_ORDER_JOOMLA') . '<br/>'); $order_types[] = JHTML::_('select.option', '1', JText::_('FLEXI_ORDER_FLEXICONTENT')); $lists['filter_order_type'] = JHTML::_('select.radiolist', $order_types, 'filter_order_type', 'size="1" class="inputbox" onchange="submitform();"', 'value', 'text', $filter_order_type); // build the categories select list for filter $lists['filter_cats'] = flexicontent_cats::buildcatselect($categories, 'filter_cats', $filter_cats, 2, 'class="use_select2_lib" size="1" onchange="submitform( );"', $check_published = false, $check_perms = false); //build type select list $lists['filter_type'] = flexicontent_html::buildtypesselect($types, 'filter_type', $filter_type, true, 'class="use_select2_lib" size="1" onchange="submitform( );"', 'filter_type'); //build authors select list $lists['filter_authors'] = flexicontent_html::buildauthorsselect($authors, 'filter_authors', $filter_authors, true, 'class="use_select2_lib" size="1" onchange="submitform( );"'); if ($badcatitems) { $lists['default_cat'] = flexicontent_cats::buildcatselect($categories, 'default_cat', '', 2, 'class="use_select2_lib"', false, false); } //search filter $scopes = array(); $scopes[1] = JText::_('FLEXI_TITLE'); $scopes[2] = JText::_('FLEXI_INTROTEXT'); $scopes[4] = JText::_('FLEXI_INDEXED_CONTENT'); /*$_scopes = array(); foreach ($scopes as $i => $v) { $_scopes[] = JHTML::_('select.option', $i, $v); } $lists['scope'] = JHTML::_('select.radiolist', $_scopes, 'scope', 'size="1" class="inputbox"', 'value', 'text', $scope );*/ $lists['scope'] = ''; foreach ($scopes as $i => $v) { $checked = $scope == $i ? ' checked="checked" ' : ''; $lists['scope'] .= '<input type="radio" onchange="submitform();" class="inputbox" ' . $checked . ' value="' . $i . '" id="scope' . $i . '" name="scope" />'; $lists['scope'] .= '<label class="" id="scope' . $i . '-lbl" for="scope' . $i . '">' . $v . '</label>'; } // build item dates option list $dates[1] = JText::_('FLEXI_CREATED'); $dates[2] = JText::_('FLEXI_REVISED'); /*$_dates = array(); foreach ($dates as $i => $v) { $_dates[] = JHTML::_('select.option', $i, $v); } $lists['date'] = JHTML::_('select.radiolist', $_dates, 'date', 'size="1" class="inputbox"', 'value', 'text', $date );*/ $lists['date'] = ''; foreach ($dates as $i => $v) { $checked = $date == $i ? ' checked="checked" ' : ''; $lists['date'] .= '<input type="radio" onchange="submitform();" class="inputbox" ' . $checked . ' value="' . $i . '" id="date' . $i . '" name="date" />'; $lists['date'] .= '<label class="" id="date' . $i . '-lbl" for="date' . $i . '">' . $v . '</label>'; } $lists['startdate'] = JHTML::_('calendar', $startdate, 'startdate', 'startdate', '%Y-%m-%d', array('class' => 'inputbox', 'size' => '11', 'maxlength' => '20')); $lists['enddate'] = JHTML::_('calendar', $enddate, 'enddate', 'enddate', '%Y-%m-%d', array('class' => 'inputbox', 'size' => '11', 'maxlength' => '20')); // search filter $bind_limits = array(); $bind_limits[] = JHTML::_('select.option', 250, '250 ' . JText::_('FLEXI_ITEMS')); $bind_limits[] = JHTML::_('select.option', 500, '500 ' . JText::_('FLEXI_ITEMS')); $bind_limits[] = JHTML::_('select.option', 750, '750 ' . JText::_('FLEXI_ITEMS')); $bind_limits[] = JHTML::_('select.option', 1000, '1000 ' . JText::_('FLEXI_ITEMS')); $bind_limits[] = JHTML::_('select.option', 1500, '1500 ' . JText::_('FLEXI_ITEMS')); $bind_limits[] = JHTML::_('select.option', 2000, '2000 ' . JText::_('FLEXI_ITEMS')); $lists['bind_limits'] = JHTML::_('select.genericlist', $bind_limits, 'bind_limit', 'size="1" class="use_select2_lib"', 'value', 'text', $bind_limit, 'bind_limit'); // search filter $lists['search'] = $search; // search id $lists['filter_id'] = $filter_id; // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // filter ordering if (!$filter_order_type) { $ordering = $lists['order'] == 'i.ordering'; } else { $ordering = $lists['order'] == 'catsordering'; } if (FLEXI_FISH || FLEXI_J16GE) { //build languages filter $lists['filter_lang'] = flexicontent_html::buildlanguageslist('filter_lang', 'class="use_select2_lib" onchange="submitform();" size="1" ', $filter_lang, 2); } // filter by item usage a specific file if ($fileid_to_itemids && count($fileid_to_itemids)) { $files_data = $model->getFileData(array_keys($fileid_to_itemids)); $file_options = array(); $file_options[] = JHTML::_('select.option', '', ' -- ' . JText::_('FLEXI_SELECT') . ' ' . JText::_('FLEXI_FILE') . ' -- '); foreach ($files_data as $_file) { $file_options[] = JHTML::_('select.option', $_file->id, $_file->altname); } flexicontent_html::loadFramework('select2'); $lists['filter_fileid'] = JHTML::_('select.genericlist', $file_options, 'filter_fileid', 'size="1" class="use_select2_lib" onchange="submitform();"', 'value', 'text', $filter_fileid); } //assign data to template $this->assignRef('count_filters', $count_filters); $this->assignRef('filter_stategrp', $filter_stategrp); $this->assignRef('filter_catsinstate', $filter_catsinstate); $this->assignRef('db', $db); $this->assignRef('lists', $lists); $this->assignRef('rows', $rows); $this->assignRef('itemCats', $itemCats); $this->assignRef('extra_fields', $extraCols); if ($enable_translation_groups) { $this->assignRef('lang_assocs', $langAssocs); } if (FLEXI_FISH || FLEXI_J16GE) { $this->assignRef('langs', $langs); } $this->assignRef('cid', $cid); $this->assignRef('pagination', $pagination); $this->assignRef('ordering', $ordering); $this->assignRef('CanOrder', $CanOrder); $this->assignRef('CanCats', $CanCats); $this->assignRef('CanAccLvl', $CanAccLvl); $this->assignRef('unassociated', $unassociated); $this->assignRef('badcatitems', $badcatitems); // filters $this->assignRef('filter_id', $filter_id); $this->assignRef('filter_state', $filter_state); $this->assignRef('filter_authors', $filter_authors); $this->assignRef('filter_type', $filter_type); $this->assignRef('filter_cats', $filter_cats); $this->assignRef('filter_subcats', $filter_subcats); $this->assignRef('filter_catsinstate', $filter_catsinstate); $this->assignRef('filter_order_type', $filter_order_type); $this->assignRef('filter_order', $filter_order); $this->assignRef('filter_lang', $filter_lang); $this->assignRef('filter_fileid', $filter_fileid); $this->assignRef('inline_ss_max', $inline_ss_max); $this->assignRef('scope', $scope); $this->assignRef('search', $search); $this->assignRef('date', $date); $this->assignRef('startdate', $startdate); $this->assignRef('enddate', $enddate); $print_logging_info = $cparams->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; $start_microtime = microtime(true); } parent::display($tpl); if ($print_logging_info) { @($fc_run_times['template_render'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } }
function display($tpl = null) { //initialise variables $app = JFactory::getApplication(); $cparams = JComponentHelper::getParams('com_flexicontent'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $option = JRequest::getCmd('option'); $view = JRequest::getVar('view'); // Get model $model = $this->getModel(); $print_logging_info = $cparams->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } // *********** // Get filters // *********** $count_filters = 0; // Order and order direction $filter_order = $model->getState('filter_order'); $filter_order_Dir = $model->getState('filter_order_Dir'); // Get filter vars $filter_state = $model->getState('filter_state'); $filter_assigned = $model->getState('filter_assigned'); if ($filter_state) { $count_filters++; } if ($filter_assigned) { $count_filters++; } // Text search $search = $model->getState('search'); $search = $db->escape(trim(JString::strtolower($search))); // **************************** // Important usability messages // **************************** if ($cparams->get('show_usability_messages', 1)) { } // ************************** // Add css and js to document // ************************** flexicontent_html::loadFramework('select2'); //JHTML::_('behavior.tooltip'); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VHASH); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VHASH); // ***************************** // Get user's global permissions // ***************************** $perms = FlexicontentHelperPerm::getPerm(); // ************************ // Create Submenu & Toolbar // ************************ // Create Submenu (and also check access to current view) FLEXISubmenu('CanTags'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_TAGS'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'tags'); $document->setTitle($doc_title . ' - ' . $site_title); // Create the toolbar $js = "jQuery(document).ready(function(){"; $contrl = FLEXI_J16GE ? "tags." : ""; $toolbar = JToolBar::getInstance('toolbar'); if ($perms->CanConfig) { $btn_task = ''; $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent&view=tags&layout=import&tmpl=component'; if (FLEXI_J30GE || !FLEXI_J16GE) { // Layout of Popup button broken in J3.1, add in J1.5 it generates duplicate HTML tag id (... just for validation), so add manually $js .= "\n\t\t\t\t\tjQuery('#toolbar-import a.toolbar, #toolbar-import button')\n\t\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 430, y: 500}, onClose: function() {}}');\n\t\t\t\t"; JToolBarHelper::custom($btn_task, 'import.png', 'import_f2.png', 'FLEXI_IMPORT', false); JHtml::_('behavior.modal', '#toolbar-import a.toolbar, #toolbar-import button'); } else { $toolbar->appendButton('Popup', 'import', JText::_('FLEXI_IMPORT'), str_replace('&', '&', $popup_load_url), 430, 500); } JToolBarHelper::divider(); JToolBarHelper::spacer(); } JToolBarHelper::publishList($contrl . 'publish'); JToolBarHelper::unpublishList($contrl . 'unpublish'); if ($perms->CanCreateTags) { JToolBarHelper::addNew($contrl . 'add'); } JToolBarHelper::editList($contrl . 'edit'); //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove'); // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag) $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE')); $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM'); $btn_task = $contrl . 'remove'; $extra_js = ""; flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true); // Checkin JToolbarHelper::checkin($contrl . 'checkin'); if ($perms->CanConfig) { JToolBarHelper::divider(); JToolBarHelper::spacer(); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } $js .= "});"; $document->addScriptDeclaration($js); // Get data from the model if ($print_logging_info) { $start_microtime = microtime(true); } $model = $this->getModel(); $rows = $this->get('Data'); if ($print_logging_info) { @($fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } // Get assigned items (via separate query), (if not already retrieved) // ... when we order by assigned then this is already done via main DB query if ($filter_order != 'nrassigned') { $rowids = array(); foreach ($rows as $row) { $rowids[] = $row->id; } if ($print_logging_info) { $start_microtime = microtime(true); } $rowtotals = $model->getAssignedItems($rowids); if ($print_logging_info) { @($fc_run_times['execute_sec_queries'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } foreach ($rows as $row) { $row->nrassigned = isset($rowtotals[$row->id]) ? $rowtotals[$row->id]->nrassigned : 0; } } // Create pagination object $pagination = $this->get('Pagination'); $lists = array(); // build orphaned/assigned filter $assigned = array(); $assigned[] = JHTML::_('select.option', '', '-'); $assigned[] = JHTML::_('select.option', 'O', JText::_('FLEXI_ORPHANED')); $assigned[] = JHTML::_('select.option', 'A', JText::_('FLEXI_ASSIGNED')); $lists['assigned'] = ($filter_assigned || 1 ? '<label class="label">' . JText::_('FLEXI_ASSIGNED') . '</label>' : '') . JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_assigned); // build publication state filter $states = array(); $states[] = JHTML::_('select.option', '', '-'); $states[] = JHTML::_('select.option', 'P', JText::_('FLEXI_PUBLISHED')); $states[] = JHTML::_('select.option', 'U', JText::_('FLEXI_UNPUBLISHED')); //$states[] = JHTML::_('select.option', '-2', JText::_( 'FLEXI_TRASHED' ) ); $lists['state'] = ($filter_state || 1 ? '<label class="label">' . JText::_('FLEXI_STATE') . '</label>' : '') . JHTML::_('select.genericlist', $states, 'filter_state', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_state); //JHTML::_('grid.state', $filter_state ); // text search filter $lists['search'] = $search; // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; //assign data to template $this->assignRef('count_filters', $count_filters); $this->assignRef('lists', $lists); $this->assignRef('rows', $rows); $this->assignRef('pagination', $pagination); $this->assignRef('option', $option); $this->assignRef('view', $view); $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null; parent::display($tpl); }