function display($tpl = null) { //initialise variables $app = JFactory::getApplication(); $document = JFactory::getDocument(); $cparams = JComponentHelper::getParams('com_flexicontent'); $user = JFactory::getUser(); //add css 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'); } } //add js function to overload the joomla submitform FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); JHTML::_('behavior.tooltip'); flexicontent_html::loadFramework('jQuery'); flexicontent_html::loadFramework('select2'); $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/admin.js'); $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/validate.js'); //Load pane behavior jimport('joomla.html.pane'); //Import File system jimport('joomla.filesystem.file'); //Get data from the model $model = $this->getModel(); $row = $this->get('Field'); if (FLEXI_J16GE) { $form = $this->get('Form'); } $types = $this->get('Typeslist'); $typesselected = $this->get('Typesselected'); //create the toolbar if ($row->id) { JToolBarHelper::title(JText::_('FLEXI_EDIT_FIELD'), 'fieldedit'); } else { JToolBarHelper::title(JText::_('FLEXI_ADD_FIELD'), 'fieldadd'); } $ctrl = FLEXI_J16GE ? 'fields.' : ''; JToolBarHelper::apply($ctrl . 'apply'); JToolBarHelper::save($ctrl . 'save'); JToolBarHelper::custom($ctrl . 'saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false); JToolBarHelper::cancel($ctrl . 'cancel'); // Import Joomla plugin that implements the type of current flexi field JPluginHelper::importPlugin('flexicontent_fields', $row->iscore ? 'core' : $row->field_type); // load plugin's english language file then override with current language file $extension_name = 'plg_flexicontent_fields_' . ($row->iscore ? 'core' : $row->field_type); JFactory::getLanguage()->load($extension_name, JPATH_ADMINISTRATOR, 'en-GB', true); JFactory::getLanguage()->load($extension_name, JPATH_ADMINISTRATOR, null, true); //check which properties are supported by current field $ft_support = FlexicontentFields::getPropertySupport($row->field_type, $row->iscore); $supportsearch = $ft_support->supportsearch; $supportadvsearch = $ft_support->supportadvsearch; $supportfilter = $ft_support->supportfilter; $supportadvfilter = $ft_support->supportadvfilter; $supportuntranslatable = $ft_support->supportuntranslatable; $supportvalueseditable = $ft_support->supportvalueseditable; $supportformhidden = $ft_support->supportformhidden; $supportedithelp = $ft_support->supportedithelp; //build selectlists, (for J1.6+ most of these are defined via XML file and custom form field classes) $lists = array(); //build field_type list if (!$row->field_type) { $row->field_type = 'text'; } if ($row->iscore == 1) { $class = 'disabled="disabled"'; } else { $class = ''; $_field_id = '#' . (FLEXI_J16GE ? 'jform_' : '') . 'field_type'; $_row_id = FLEXI_J16GE ? $form->getValue("id") : $row->id; $_ctrl_task = FLEXI_J16GE ? 'task=fields.getfieldspecificproperties' : 'controller=fields&task=getfieldspecificproperties'; $document->addScriptDeclaration("\n\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\tjQuery('" . $_field_id . "').on('change', function() {\n\t\t\t\t\t\tjQuery('#fieldspecificproperties').html('<p class=\"centerimg\"><img src=\"components/com_flexicontent/assets/images/ajax-loader.gif\" align=\"center\"></p>');\n\t\t\t\t\t\tjQuery.ajax({\n\t\t\t\t\t\t\ttype: \"GET\",\n\t\t\t\t\t\t\turl: 'index.php?option=com_flexicontent&" . $_ctrl_task . "&cid=" . $_row_id . "&field_type='+this.value+'&format=raw',\n\t\t\t\t\t\t\tsuccess: function(str) {\n\t\t\t\t\t\t\t\tjQuery('#fieldspecificproperties').html(str);\n\t\t\t\t\t\t\t\tvar JTooltips = new Tips(jQuery('#fieldspecificproperties .hasTip'), { maxTitleChars: 50, fixed: false});\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tjQuery('#field_typename').html(jQuery('" . $_field_id . "').val());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t"); } //build field select list $lists['field_type'] = flexicontent_html::buildfieldtypeslist('field_type', $class, $row->field_type, $group = true); //build type select list $attribs = 'class="use_select2_lib" multiple="multiple" size="6"'; $attribs .= $row->iscore ? ' disabled="disabled"' : ''; $types_fieldname = FLEXI_J16GE ? 'jform[tid][]' : 'tid[]'; $lists['tid'] = flexicontent_html::buildtypesselect($types, $types_fieldname, $typesselected, false, $attribs); // ************************************************************************** // Create fields for J1.5 (J2.5+ uses JForm XML file for most of form fields) // ************************************************************************** if (!FLEXI_J16GE) { //build formhidden selector $formhidden[] = JHTML::_('select.option', 0, JText::_('FLEXI_NO')); $formhidden[] = JHTML::_('select.option', 1, JText::_('FLEXI_FRONTEND')); $formhidden[] = JHTML::_('select.option', 2, JText::_('FLEXI_BACKEND')); $formhidden[] = JHTML::_('select.option', 3, JText::_('FLEXI_BOTH')); $formhidden_fieldname = FLEXI_J16GE ? 'jform[formhidden]' : 'formhidden'; $lists['formhidden'] = JHTML::_('select.radiolist', $formhidden, $formhidden_fieldname, '', 'value', 'text', $row->formhidden); if (FLEXI_ACCESS) { $valueseditable[] = JHTML::_('select.option', 0, JText::_('FLEXI_ANY_EDITOR')); $valueseditable[] = JHTML::_('select.option', 1, JText::_('FLEXI_USE_ACL_PERMISSION')); $valueseditable_fieldname = FLEXI_J16GE ? 'jform[valueseditable]' : 'valueseditable'; $lists['valueseditable'] = JHTML::_('select.radiolist', $valueseditable, $valueseditable_fieldname, '', 'value', 'text', $row->valueseditable); } $edithelp[] = JHTML::_('select.option', 0, JText::_('FLEXI_EDIT_HELP_NONE')); $edithelp[] = JHTML::_('select.option', 1, JText::_('FLEXI_EDIT_HELP_LABEL_TOOLTIP')); $edithelp[] = JHTML::_('select.option', 2, JText::_('FLEXI_EDIT_HELP_LABEL_TOOLTIP_WICON')); $edithelp[] = JHTML::_('select.option', 3, JText::_('FLEXI_EDIT_HELP_INLINE')); $edithelp_fieldname = FLEXI_J16GE ? 'jform[edithelp]' : 'edithelp'; $lists['edithelp'] = JHTML::_('select.radiolist', $edithelp, $edithelp_fieldname, '', 'value', 'text', $row->edithelp); // build the html select list for ordering $query = 'SELECT ordering AS value, label AS text' . ' FROM #__flexicontent_fields' . ' WHERE published >= 0' . ' ORDER BY ordering'; $row->ordering = @$row->ordering; $lists['ordering'] = $row->id ? JHTML::_('list.specificordering', $row, $row->id, $query) : JHTML::_('list.specificordering', $row, '', $query); //build access level list if (FLEXI_ACCESS) { $lang = JFactory::getLanguage(); $lang->_strings['FLEXIACCESS_PADD'] = 'Edit-Value'; $lists['access'] = FAccess::TabGmaccess($row, 'field', 1, 1, 0, 1, 0, 1, 0, 1, 1); } else { $lists['access'] = JHTML::_('list.accesslevel', $row); } } if (!FLEXI_J16GE) { // Create the parameter 's form object parsing the file XML $pluginpath = JPATH_PLUGINS . DS . 'flexicontent_fields' . DS . $row->field_type . '.xml'; if (JFile::exists($pluginpath)) { $form = new JParameter('', $pluginpath); } else { $form = new JParameter('', JPATH_PLUGINS . DS . 'flexicontent_fields' . DS . 'core.xml'); } // Special and Core Groups $form->loadINI($row->attribs); } // fail if checked out not by 'me' if ($row->id) { if ($model->isCheckedOut($user->get('id'))) { JError::raiseWarning('SOME_ERROR_CODE', $row->name . ' ' . JText::_('FLEXI_EDITED_BY_ANOTHER_ADMIN')); $app->redirect('index.php?option=com_flexicontent&view=fields'); } } //clean data JFilterOutput::objectHTMLSafe($row, ENT_QUOTES); // assign permissions for J2.5 if (FLEXI_J16GE) { $permission = FlexicontentHelperPerm::getPerm(); $this->assignRef('permission', $permission); } //assign data to template $this->assignRef('document', $document); $this->assignRef('row', $row); $this->assignRef('lists', $lists); $this->assignRef('form', $form); $this->assignRef('typesselected', $typesselected); $this->assignRef('supportsearch', $supportsearch); $this->assignRef('supportadvsearch', $supportadvsearch); $this->assignRef('supportfilter', $supportfilter); $this->assignRef('supportadvfilter', $supportadvfilter); $this->assignRef('supportuntranslatable', $supportuntranslatable); $this->assignRef('supportvalueseditable', $supportvalueseditable); $this->assignRef('supportformhidden', $supportformhidden); $this->assignRef('supportedithelp', $supportedithelp); parent::display($tpl); }
function display($tpl = null) { // Initialise variables $app = JFactory::getApplication(); $option = JRequest::getVar('option'); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $user = JFactory::getUser(); $use_jquery_sortable = true; $type = JRequest::getVar('type', 'items', '', 'word'); $folder = JRequest::getVar('folder', 'default', '', 'cmd'); $ismodal = JRequest::getVar('ismodal', 'default', '', 'int'); FLEXIUtilities::loadTemplateLanguageFile($folder); //Get data from the model $layout = $this->get('Data'); $conf = $this->get('LayoutConf'); $fields = $this->get('Fields'); $fbypos = $this->get('FieldsByPositions'); $used = $this->get('UsedFields'); $contentTypes = $this->get('TypesList'); //$fieldTypes = $this->get( 'FieldTypesList' ); $fieldTypes = flexicontent_db::getFieldTypes($_grouped = true, $_usage = false, $_published = false); // Field types with content type ASSIGNMENT COUNTING // Create CONTENT TYPE SELECTOR foreach ($fields as $field) { $field->type_ids = !empty($field->reltypes) ? explode(",", $field->reltypes) : array(); } $options = array(); $options[] = JHTML::_('select.option', '', JText::_('FLEXI_ALL')); foreach ($contentTypes as $contentType) { $options[] = JHTML::_('select.option', $contentType->id, JText::_($contentType->name)); } $fieldname = $elementid = 'content_type__au__'; $attribs = ' onchange="filterFieldList(\'%s\', \'%s\', \'%s\');" class="use_select2_lib" '; $content_type_select = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', '', $elementid); // Create FIELD TYPE SELECTOR $ALL = mb_strtoupper(JText::_('FLEXI_ALL'), 'UTF-8') . ' : '; $fftypes = array(); $fftypes[] = array('value' => '', 'text' => JText::_('FLEXI_ALL')); //$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->friendly); } $fftypes[] = ''; } $fieldname = $elementid = 'field_type__au__'; $attribs = ' class="use_select2_lib" onchange="filterFieldList(\'%s\', \'%s\', \'%s\');"'; $field_type_select = flexicontent_html::buildfieldtypeslist($fftypes, $fieldname, '', $_grouped ? 1 : 0, $attribs, $elementid); if (isset($layout->positions)) { $sort = array(); $jssort = array(); $idsort = array(); $sort[0] = 'sortablecorefields'; $sort[1] = 'sortableuserfields'; $i = 2; $count = -1; foreach ($layout->positions as $pos) { $count++; if (isset($layout->attributes[$count]) && isset($layout->attributes[$count]['readonly'])) { continue; } $sort[$i] = 'sortable-' . $pos; $idsort[$i] = $pos; $i++; } foreach ($idsort as $k => $v) { if ($k > 1) { $jssort[] = 'storeordering(jQuery("#sortable-' . $v . '"))'; } } $positions = implode(',', $idsort); $jssort = implode("; ", $jssort); $sortable_ids = "#" . implode(",#", $sort); $js = "\n\t\t\tjQuery(function() {\n\t\t\t\tmy = jQuery( \"{$sortable_ids}\" ).sortable({\n\t\t\t\t\tconnectWith: \"" . $sortable_ids . "\",\n\t\t\t\t\tupdate: function(event, ui) {\n\t\t\t\t\t\tif(ui.sender) {\n\t\t\t\t\t\t\tstoreordering(jQuery(ui.sender));\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tstoreordering(jQuery(ui.item).parent());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tinitordering();\n\t\t\t});\n\t\t\tfunction storeordering(parent_element) {\n\t\t\t\thidden_id = '#'+jQuery.trim(parent_element.attr('id').replace('sortable-',''));\n\t\t\t\tfields = new Array();\n\t\t\t\ti = 0;\n\t\t\t\tparent_element.children('li').each(function(){\n\t\t\t\t\tfields[i++] = jQuery(this).attr('id').replace('field_', '');\n\t\t\t\t});\n\t\t\t\tjQuery(hidden_id).val(fields.join(','))\n\t\t\t}\n\t\t\t"; $js .= ' var fieldListFilters = new Array( "content_type", "field_type" ); function filterFieldList (containerID, method, group) { var needed_classes = ""; for (i=0; i<fieldListFilters.length; i++) { filter_name = fieldListFilters[i]; var filter_val = jQuery("#" + filter_name + "_" + group).val(); if (filter_val) { needed_classes += "."+filter_name+"_"+filter_val; } } if (needed_classes) { (method=="hide") ? jQuery("#"+containerID).find("li").show().filter(":not("+needed_classes+")").hide() : jQuery("#"+containerID).find("li").css({"color":"red"}).filter(":not("+needed_classes+")").css({"color":"black"}); } else { (method=="hide") ? jQuery("#"+containerID).find("li").show() : jQuery("#"+containerID).find("li").css({"color":"black"}); } } '; $document->addScriptDeclaration($js); } // ************************** // Add css and js to document // ************************** flexicontent_html::loadFramework('select2'); JHTML::_('behavior.tooltip'); JHTML::_('behavior.modal'); $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(); 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 the toolbar $bar = JToolBar::getInstance('toolbar'); JToolBarHelper::title(JText::_('FLEXI_EDIT_TEMPLATE'), 'templates'); if (!$ismodal) { JToolBarHelper::apply('templates.apply'); JToolBarHelper::save('templates.save'); JToolBarHelper::cancel('templates.cancel'); } else { JToolBarHelper::apply('templates.apply_modal'); echo $bar->render(); } // ********************************************************************************** // Get Templates and apply Template Parameters values into the form fields structures // ********************************************************************************** if (FLEXI_J16GE) { $jform = new JForm('com_flexicontent.template.category', array('control' => 'jform', 'load_data' => true)); $jform->load($layout->params); $layout->params = $jform; // ... values applied at the template form file } else { $layout->params->loadINI($row->params); } //print_r($layout); //assign data to template //print_r($conf); $this->assignRef('conf', $conf); $this->assignRef('layout', $layout); $this->assignRef('fields', $fields); $this->assignRef('user', $user); $this->assignRef('type', $type); $this->assignRef('folder', $folder); $this->assignRef('jssort', $jssort); $this->assignRef('positions', $positions); $this->assignRef('used', $used); $this->assignRef('fbypos', $fbypos); $this->assignRef('use_jquery_sortable', $use_jquery_sortable); $this->assignRef('content_type_select', $content_type_select); $this->assignRef('field_type_select', $field_type_select); parent::display($tpl); }
function display($tpl = null) { //initialise variables $app = JFactory::getApplication(); $option = JRequest::getVar('option'); $document = JFactory::getDocument(); $cparams = JComponentHelper::getParams('com_flexicontent'); $user = JFactory::getUser(); //add css to document $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); // 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_VHASH); $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VHASH); //Load pane behavior jimport('joomla.html.pane'); //Import File system jimport('joomla.filesystem.file'); //Get data from the model $model = $this->getModel(); $row = $this->get('Field'); $form = $this->get('Form'); $types = $this->get('Typeslist'); $typesselected = $this->get('Typesselected'); //create the toolbar if ($row->id) { JToolBarHelper::title(JText::_('FLEXI_EDIT_FIELD'), 'fieldedit'); } else { JToolBarHelper::title(JText::_('FLEXI_ADD_FIELD'), 'fieldadd'); } $ctrl = FLEXI_J16GE ? 'fields.' : ''; JToolBarHelper::apply($ctrl . 'apply'); JToolBarHelper::save($ctrl . 'save'); JToolBarHelper::custom($ctrl . 'saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false); JToolBarHelper::cancel($ctrl . 'cancel'); // Import Joomla plugin that implements the type of current flexi field $extfolder = 'flexicontent_fields'; $extname = $row->iscore ? 'core' : $row->field_type; JPluginHelper::importPlugin('flexicontent_fields', $row->iscore ? 'core' : $row->field_type); // Create class name of the plugin and then create a plugin instance $classname = 'plg' . ucfirst($extfolder) . $extname; // Check max allowed version if (property_exists($classname, 'prior_to_version')) { // Set a system message with warning of failed PHP limits $prior_to_version = $app->getUserStateFromRequest($option . '.flexicontent.prior_to_version_' . $row->field_type, 'prior_to_version_' . $row->field_type, 0, 'int'); $app->setUserState($option . '.flexicontent.prior_to_version_' . $row->field_type, $prior_to_version + 1); if ($prior_to_version < 2) { $close_btn = FLEXI_J30GE ? '<a class="close" data-dismiss="alert">×</a>' : '<a class="fc-close" onclick="this.parentNode.parentNode.removeChild(this.parentNode);">×</a>'; $manifest_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'manifest.xml'; $com_xml = JApplicationHelper::parseXMLInstallFile($manifest_path); $ver_exceeded = version_compare(str_replace(' ', '.', $com_xml['version']), str_replace(' ', '.', $classname::$prior_to_version), '>='); if ($ver_exceeded) { echo ' <span class="fc-note fc-mssg-inline"> ' . $close_btn . ' Warning: installed version of Field: \'<b>' . $extname . '</b>\' was given to be free for FLEXIcontent versions prior to: v' . $classname::$prior_to_version . ' <br/> It may or may not work properly in later versions </span>'; } else { echo ' <span class="fc-info fc-mssg-inline"> ' . $close_btn . ' Note: installed version of Field: \'<b>' . $extname . '</b>\' is given free for FLEXIcontent versions prior to: v' . $classname::$prior_to_version . ', nevertheless it will continue to function after FLEXIcontent is upgraded. </span>'; } } } // load plugin's english language file then override with current language file $extension_name = 'plg_flexicontent_fields_' . ($row->iscore ? 'core' : $row->field_type); JFactory::getLanguage()->load($extension_name, JPATH_ADMINISTRATOR, 'en-GB', true); JFactory::getLanguage()->load($extension_name, JPATH_ADMINISTRATOR, null, true); //check which properties are supported by current field $ft_support = FlexicontentFields::getPropertySupport($row->field_type, $row->iscore); $supportsearch = $ft_support->supportsearch; $supportadvsearch = $ft_support->supportadvsearch; $supportfilter = $ft_support->supportfilter; $supportadvfilter = $ft_support->supportadvfilter; $supportuntranslatable = $ft_support->supportuntranslatable; $supportvalueseditable = $ft_support->supportvalueseditable; $supportformhidden = $ft_support->supportformhidden; $supportedithelp = $ft_support->supportedithelp; //build selectlists, (for J1.6+ most of these are defined via XML file and custom form field classes) $lists = array(); //build field_type list if (!$row->field_type) { $row->field_type = 'text'; } $_attribs = ' class="use_select2_lib fc_skip_highlight" '; if ($row->iscore == 1) { $_attribs .= ' disabled="disabled" '; } else { $_field_id = 'jform_field_type'; $_row_id = $form->getValue("id"); $_ctrl_task = 'task=fields.getfieldspecificproperties'; $document->addScriptDeclaration("\n\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\tjQuery('#" . $_field_id . "').on('change', function() {\n\t\t\t\t\t\tjQuery('#fieldspecificproperties').html('<p class=\"centerimg\"><img src=\"components/com_flexicontent/assets/images/ajax-loader.gif\" align=\"center\"></p>');\n\t\t\t\t\t\tjQuery.ajax({\n\t\t\t\t\t\t\ttype: \"GET\",\n\t\t\t\t\t\t\turl: 'index.php?option=com_flexicontent&" . $_ctrl_task . "&cid=" . $_row_id . "&field_type='+this.value+'&format=raw',\n\t\t\t\t\t\t\tsuccess: function(str) {\n\t\t\t\t\t\t\t\tjQuery('#fieldspecificproperties').html(str);\n\t\t\t\t\t\t\t\t" . (FLEXI_J30GE ? "\n\t\t\t\t\t\t\t\t\tjQuery('.hasTooltip').tooltip({'html': true,'container': jQuery('#fieldspecificproperties')});\n\t\t\t\t\t\t\t\t" : "\n\t\t\t\t\t\t\t\tvar tipped_elements = jQuery('#fieldspecificproperties .hasTip');\n\t\t\t\t\t\t\t\ttipped_elements.each(function() {\n\t\t\t\t\t\t\t\t\tvar title = this.get('title');\n\t\t\t\t\t\t\t\t\tif (title) {\n\t\t\t\t\t\t\t\t\t\tvar parts = title.split('::', 2);\n\t\t\t\t\t\t\t\t\t\tthis.store('tip:title', parts[0]);\n\t\t\t\t\t\t\t\t\t\tthis.store('tip:text', parts[1]);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tvar ajax_JTooltips = new Tips(\$('fieldspecificproperties').getElements('.hasTip'), { maxTitleChars: 50, fixed: false});\n\t\t\t\t\t\t\t\t") . "\n\t\t\t\t\t\t\t\ttabberAutomatic(tabberOptions, 'fieldspecificproperties');\n\t\t\t\t\t\t\t\tfc_bindFormDependencies('#fieldspecificproperties', 0, '');\n\t\t\t\t\t\t\t\tjQuery('#field_typename').html(jQuery('#" . $_field_id . "').val());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t"); } //build field select list $fieldtypes = flexicontent_db::getFieldTypes($_grouped = true, $_usage = false, $_published = true); $fftypes = array(); 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->friendly); } $fftypes[] = ''; } $lists['field_type'] = flexicontent_html::buildfieldtypeslist($fftypes, 'jform[field_type]', $row->field_type, $_grouped ? 1 : 0, $_attribs); //build type select list $attribs = 'class="use_select2_lib" multiple="multiple" size="6"'; $attribs .= $row->iscore ? ' disabled="disabled"' : ''; $types_fieldname = FLEXI_J16GE ? 'jform[tid][]' : 'tid[]'; $lists['tid'] = flexicontent_html::buildtypesselect($types, $types_fieldname, $typesselected, false, $attribs); // ************************************************************************** // Create fields for J1.5 (J2.5+ uses JForm XML file for most of form fields) // ************************************************************************** if (!FLEXI_J16GE) { //build formhidden selector $formhidden[] = JHTML::_('select.option', 0, JText::_('FLEXI_NO')); $formhidden[] = JHTML::_('select.option', 1, JText::_('FLEXI_FRONTEND')); $formhidden[] = JHTML::_('select.option', 2, JText::_('FLEXI_BACKEND')); $formhidden[] = JHTML::_('select.option', 3, JText::_('FLEXI_BOTH')); $formhidden_fieldname = FLEXI_J16GE ? 'jform[formhidden]' : 'formhidden'; $lists['formhidden'] = JHTML::_('select.radiolist', $formhidden, $formhidden_fieldname, '', 'value', 'text', $row->formhidden); if (FLEXI_ACCESS) { $valueseditable[] = JHTML::_('select.option', 0, JText::_('FLEXI_ANY_EDITOR')); $valueseditable[] = JHTML::_('select.option', 1, JText::_('FLEXI_USE_ACL_PERMISSION')); $valueseditable_fieldname = FLEXI_J16GE ? 'jform[valueseditable]' : 'valueseditable'; $lists['valueseditable'] = JHTML::_('select.radiolist', $valueseditable, $valueseditable_fieldname, '', 'value', 'text', $row->valueseditable); } $edithelp[] = JHTML::_('select.option', 0, JText::_('FLEXI_EDIT_HELP_NONE')); $edithelp[] = JHTML::_('select.option', 1, JText::_('FLEXI_EDIT_HELP_LABEL_TOOLTIP')); $edithelp[] = JHTML::_('select.option', 2, JText::_('FLEXI_EDIT_HELP_LABEL_TOOLTIP_WICON')); $edithelp[] = JHTML::_('select.option', 3, JText::_('FLEXI_EDIT_HELP_INLINE')); $edithelp_fieldname = FLEXI_J16GE ? 'jform[edithelp]' : 'edithelp'; $lists['edithelp'] = JHTML::_('select.radiolist', $edithelp, $edithelp_fieldname, '', 'value', 'text', $row->edithelp); // build the html select list for ordering $query = 'SELECT ordering AS value, label AS text' . ' FROM #__flexicontent_fields' . ' WHERE published >= 0' . ' ORDER BY ordering'; $row->ordering = @$row->ordering; $lists['ordering'] = $row->id ? JHTML::_('list.specificordering', $row, $row->id, $query) : JHTML::_('list.specificordering', $row, '', $query); //build access level list if (FLEXI_ACCESS) { $lang = JFactory::getLanguage(); $lang->_strings['FLEXIACCESS_PADD'] = 'Edit-Value'; $lists['access'] = FAccess::TabGmaccess($row, 'field', 1, 1, 0, 1, 0, 1, 0, 1, 1); } else { $lists['access'] = JHTML::_('list.accesslevel', $row); } } if (!FLEXI_J16GE) { // Create the parameter 's form object parsing the file XML $pluginpath = JPATH_PLUGINS . DS . 'flexicontent_fields' . DS . $row->field_type . '.xml'; if (JFile::exists($pluginpath)) { $form = new JParameter('', $pluginpath); } else { $form = new JParameter('', JPATH_PLUGINS . DS . 'flexicontent_fields' . DS . 'core.xml'); } // Special and Core Groups $form->loadINI($row->attribs); } // fail if checked out not by 'me' if ($row->id) { if ($model->isCheckedOut($user->get('id'))) { JError::raiseWarning('SOME_ERROR_CODE', $row->name . ' ' . JText::_('FLEXI_EDITED_BY_ANOTHER_ADMIN')); $app->redirect('index.php?option=com_flexicontent&view=fields'); } } //clean data JFilterOutput::objectHTMLSafe($row, ENT_QUOTES); // assign permissions for J2.5 $permission = FlexicontentHelperPerm::getPerm(); $this->assignRef('permission', $permission); //assign data to template $this->assignRef('document', $document); $this->assignRef('row', $row); $this->assignRef('lists', $lists); $this->assignRef('form', $form); $this->assignRef('typesselected', $typesselected); $this->assignRef('supportsearch', $supportsearch); $this->assignRef('supportadvsearch', $supportadvsearch); $this->assignRef('supportfilter', $supportfilter); $this->assignRef('supportadvfilter', $supportadvfilter); $this->assignRef('supportuntranslatable', $supportuntranslatable); $this->assignRef('supportvalueseditable', $supportvalueseditable); $this->assignRef('supportformhidden', $supportformhidden); $this->assignRef('supportedithelp', $supportedithelp); 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); }