Esempio n. 1
0
 function add_css_js()
 {
     $css = "\n\t\tdiv.pane-sliders ul.adminformlist li label.hasTip {\n\t\t\tdisplay:inline-block; padding: 4px; margin: 1px 6px 0px 1px; text-align: right;\twidth:132px; font-weight: bold;\n\t\t\tbackground-color: #F6F6F6; border-bottom: 1px solid #E9E9E9; border-right: 1px solid #E9E9E9; color: #666666;\n\t\t}\n\t\tdiv.pane-sliders ul.adminformlist li ul#rules label.hasTip {\n\t\t\tdisplay:inherit; padding: inherit; margin: inherit; text-align: inherit;\twidth: inherit; font-weight: inherit;\n\t\t\tbackground-color: inherit; border-width: 0px; color: inherit;\n\t\t}\n\t\tdiv.pane-sliders ul.adminformlist li select { margin-bottom: 0px;}\n\t\tdiv.pane-sliders ul.adminformlist li fieldset  { margin: 0; padding: 0; }\n\t\t\n\t\tdiv.current ul.config-option-list li .fcsep_level3 {\n\t\t\tleft: 232px !important;\n\t\t}\n\t\t/*div.controls input, div.controls textarea {\n\t\t\tmin-width: 56%;\n\t\t}*/\n\t\tdiv.control-group div.control-label label.hasTooltip,\n\t\tdiv.current ul.config-option-list li label.hasTooltip,\n\t\tdiv.current ul.config-option-list li label.hasTip {\n\t\t\tdisplay:inline-block; padding: 4px; margin: 1px 6px 0px 1px; text-align: right;\twidth:220px; font-weight: normal; font-size: 12px;\n\t\t\tbackground-color: #F6F6F6; border-bottom: 1px solid #E9E9E9; border-right: 1px solid #E9E9E9; color: #666666;\n\t\t}\n\t\tdiv.current ul.config-option-list li ul#rules label.hasTip {\n\t\t\tdisplay:inherit; padding: inherit; margin: inherit; text-align: inherit;\twidth: inherit; font-weight: inherit;\n\t\t\tbackground-color: inherit; border-width: 0px; color: inherit;\n\t\t}\n\t\tform#item-form div.pane-sliders ul.adminformlist li label.hasTip {\n\t\t\tdisplay:inline-block; padding: 4px; margin: 1px 6px 0px 1px; text-align: right;\twidth:160px; font-weight: bold;\n\t\t\tbackground-color: #F6F6F6; border-bottom: 1px solid #E9E9E9; border-right: 1px solid #E9E9E9; color: #666666;\n\t\t}\n\t\t\n\t\t/*div.current fieldset.radio label {\n\t\t\tmin-width:10px!important; padding: 0px 16px 0px 0px!important; margin: 2px 0px 0px 1px!important;\n\t\t}\n\t\tdiv fieldset.adminform fieldset.radio label, div fieldset.panelform fieldset.radio label {\n\t\t\tmin-width:10px!important; padding: 0px 10px 0px 0px!important; margin: 4px 0px 0px 1px!important;\n\t\t}*/\n\t\t\n\t\t/*div fieldset input, div fieldset textarea, div fieldset img, div fieldset button { margin:5px 2px 2px 0px; }*/\n\t\tdiv fieldset select { margin:0px; }\n\t\t\t\t\t\n\t\tdiv.current ul.config-option-list li select { margin-bottom: 0px; font-size:12px;}\n\t\tdiv.current ul.config-option-list li fieldset  { margin: 0; padding: 0; }\n\t\t\n\t\t.tool-tip { }\n\t\t.tip-title { }\n\t\t";
     $document = JFactory::getDocument();
     $document->addStyleDeclaration($css);
     if (FLEXI_J30GE) {
         $jinput = JFactory::getApplication()->input;
     }
     $option = FLEXI_J30GE ? $jinput->get('option', '', 'string') : JRequest::getVar('option');
     $view = FLEXI_J30GE ? $jinput->get('view', '', 'string') : JRequest::getVar('view');
     $controller = FLEXI_J30GE ? $jinput->get('controller', '', 'string') : JRequest::getVar('controller');
     $component = FLEXI_J30GE ? $jinput->get('component', '', 'string') : JRequest::getVar('component');
     // NOTE: this is imported by main Frontend/Backend CSS file
     // so import these only if it is not a flexicontent view
     if ($option != 'com_flexicontent') {
         $document->addStyleSheet(JURI::root(true) . '/components/com_flexicontent/assets/css/flexi_form.css');
         // NOTE: this is imported by main Frontend/Backend CSS file
         $document->addStyleSheet(JURI::root(true) . '/components/com_flexicontent/assets/css/flexi_shared.css');
         // NOTE: this is imported by main Frontend/Backend CSS file
         // Add flexicontent specific TABBing to non-flexicontent views
         $document->addStyleSheet(JURI::root(true) . '/components/com_flexicontent/assets/css/tabber.css');
         $document->addScript(JURI::root(true) . '/components/com_flexicontent/assets/js/tabber-minimized.js');
         $document->addScriptDeclaration(' document.write(\'<style type="text/css">.fctabber{display:none;}<\\/style>\'); ');
     }
     require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.helper.php';
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadJQuery();
     // 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);
     $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VERSION);
 }
Esempio n. 2
0
 function add_css_js()
 {
     require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.helper.php';
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadJQuery();
     $document = JFactory::getDocument();
     $js = "\n\t\t\tvar sorttable_fcfield_lists = '';\n\t\t\t\n\t\t\t/* unused to be removed */\n\t\t\tfunction fcfield_add2list(list_tagid, selector){\n\t\t\t\tvar list = jQuery('#'+list_tagid);\n\t\t\t\tvar sep = list.val().trim() ? ', ' : '';\n\t\t\t\tval = list.val() +  sep + jQuery(selector).val();\n\t\t\t\tlist.val(val);\n\t\t\t}\n\t\t\t\n\t\t\tfunction fcfield_del_sortable_element(obj){\n\t\t\t\tvar element = jQuery(obj).parent();\n\t\t\t\tvar parent_element = jQuery(element.parent());\n\t\t\t\telement.remove();\n\t\t\t\tstoreordering( parent_element );\n\t\t\t}\n\t\t\t\n\t\t\tfunction fcfield_add_sortable_element(selector){\n\t\t\t\tvar selobj = jQuery(selector);\n\t\t\t\tvar tagid  = selobj.attr('id').replace('_selector','');\n\t\t\t\tvar container = 'sortable-' + tagid;\n\t\t\t\t\n\t\t\t\tvar val = selobj.val();\n\t\t\t\tif (!val) return;\n\t\t\t\tvar lbl = selobj.find('option:selected').text();\n\t\t\t\tjQuery('#'+container).append('<li id=\"field_'+val+'\" class=\"fields delfield\">'+lbl+\n\t\t\t\t'<a title=\"" . JText::_('FLEXI_REMOVE') . "\" align=\"right\" onclick=\"javascript:fcfield_del_sortable_element(this);\" class=\"deletetag\" href=\"javascript:;\"></a>'+\n\t\t\t\t'</li>');\n\t\t\t\t\n\t\t\t\tvar field_list = jQuery('#'+tagid).val();\n\t\t\t\tfield_list += field_list ? ','+val : val;\n\t\t\t\tjQuery('#'+tagid).val(field_list);\n\t\t\t\tselobj.prop('selectedIndex',0);\n\t\t\t}\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\n\t\t\tjQuery(document).ready(function() {\n\t\t\t\n\t\t\t\tjQuery( sorttable_fcfield_lists ).each(function(index, value) {\n\t\t\t\t\tstoreordering(jQuery(this));\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\tjQuery( sorttable_fcfield_lists ).sortable({\n\t\t\t\t\tconnectWith: sorttable_fcfield_lists,\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\t\n\t\t\t});\n\t\t";
     if ($js) {
         $document->addScriptDeclaration($js);
     }
 }
 /**
  * Utility function to load each JS Frameworks once
  *
  * @param 	string 		$text
  * @param 	int 		$nb
  * @return 	string
  * @since 1.5
  */
 static function loadFramework($framework, $mode = '')
 {
     // Detect already loaded framework
     static $_loaded = array();
     if (isset($_loaded[$framework])) {
         return $_loaded[$framework];
     }
     $_loaded[$framework] = false;
     // Get frameworks that are configured to be loaded manually in frontend (e.g. via the Joomla template)
     $app = JFactory::getApplication();
     static $load_frameworks = null;
     static $load_jquery = null;
     if (!isset($load_frameworks[$framework])) {
         $flexiparams = JComponentHelper::getParams('com_flexicontent');
         //$load_frameworks = $flexiparams->get('load_frameworks', array('jQuery','image-picker','masonry','select2','inputmask','prettyCheckable','fancybox'));
         //$load_frameworks = FLEXIUtilities::paramToArray($load_frameworks);
         //$load_frameworks = array_flip($load_frameworks);
         //$load_jquery = isset($load_frameworks['jQuery']) || !$app->isSite();
         if ($load_jquery === null) {
             $load_jquery = $flexiparams->get('loadfw_jquery', 1) == 1 || !$app->isSite();
         }
         $load_framework = $flexiparams->get('loadfw_' . strtolower(str_replace('-', '_', $framework)), 1);
         $load_frameworks[$framework] = $load_framework == 1 || $load_framework == 2 && !$app->isSite();
     }
     // Set loaded flag
     $_loaded[$framework] = $load_frameworks[$framework];
     // Do not progress further if it is disabled
     if (!$load_frameworks[$framework]) {
         return false;
     }
     // Load Framework
     $document = JFactory::getDocument();
     $lib_path = '/components/com_flexicontent/librairies';
     $js = "";
     $css = "";
     switch ($framework) {
         case 'jQuery':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             break;
         case 'mCSB':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             $framework_path = JURI::root(true) . $lib_path . '/mCSB';
             $document->addScript($framework_path . '/jquery.mCustomScrollbar.min.js');
             $document->addStyleSheet($framework_path . '/jquery.mCustomScrollbar.css');
             $js .= "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tjQuery('.fc_add_scroller').mCustomScrollbar({\n\t\t\t\t\t\t\ttheme:'dark-thick',\n\t\t\t\t\t\t\tadvanced:{updateOnContentResize: true}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tjQuery('.fc_add_scroller_horizontal').mCustomScrollbar({\n\t\t\t\t\t\t\ttheme:'dark-thick',\n\t\t\t\t\t\t\thorizontalScroll:true,\n\t\t\t\t\t\t\tadvanced:{updateOnContentResize: true}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t";
             break;
         case 'image-picker':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             $framework_path = JURI::root(true) . $lib_path . '/image-picker';
             $document->addScript($framework_path . '/image-picker.min.js');
             $document->addStyleSheet($framework_path . '/image-picker.css');
             break;
         case 'masonry':
             $framework_path = JURI::root(true) . $lib_path . '/masonry';
             $document->addScript($framework_path . '/masonry.pkgd.min.js');
             break;
         case 'select2':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             // Replace chosen function (if loaded)
             //JHtml::_('formbehavior.chosen', '#_some_iiidddd_');
             $js .= "\n\t\t\t\tif (typeof jQuery.fn.chosen == 'function') { \n\t\t\t\t\tjQuery.fn.chosen_fc = jQuery.fn.chosen;\n\t\t\t\t\tjQuery.fn.chosen = function(){\n\t\t\t\t\t\tvar args = arguments;\n\t\t\t\t\t\tjQuery(this).each(function() {\n\t\t\t\t\t\t\tif (jQuery(this).hasClass('use_select2_lib')) return;\n\t\t\t\t\t\t\tjQuery(this).chosen_fc(args);\n\t\t\t\t\t\t});\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\t";
             $ver = '3.5.4';
             $framework_path = JURI::root(true) . $lib_path . '/select2';
             $framework_folder = JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'librairies' . DS . 'select2';
             $document->addScriptVersion($framework_path . '/select2.min.js', $ver);
             $document->addStyleSheetVersion($framework_path . '/select2.css', $ver);
             $lang_code = flexicontent_html::getUserCurrentLang();
             if ($lang_code && $lang_code != 'en') {
                 // Try language shortcode
                 if (file_exists($framework_folder . DS . 'select2_locale_' . $lang_code . '.js')) {
                     $document->addScriptVersion($framework_path . '/select2_locale_' . $lang_code . '.js', $ver);
                 } else {
                     $country_code = flexicontent_html::getUserCurrentLang($short_tag = false);
                     if ($country_code && file_exists($framework_folder . DS . 'select2_locale_' . $country_code . '.js')) {
                         $document->addScriptVersion($framework_path . '/select2_locale_' . $country_code . '.js', $ver);
                     }
                 }
             }
             $js .= "\n\t\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\tjQuery('select.use_select2_lib').select2({\n\t\t\t\t\t\t\t/*hideSelectionFromResult: function(selectedObject) { selectedObject.removeClass('select2-result-selectable').addClass('select2-result-unselectable').addClass('select2-disabled'); return false; },*/\n\t\t\t\t\t\t\tminimumResultsForSearch: 10\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tjQuery('div.use_select2_lib').each(function() {\n\t\t\t\t\t\t\tvar el_container = jQuery(this);\n\t\t\t\t\t\t\tvar el_select = el_container.next('select');\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tvar fc_label_text = el_select.attr('data-fc_label_text');\n\t\t\t\t\t\t\tif (!fc_label_text) fc_label_text = el_select.attr('fc_label_text');\n\t\t\t\t\t\t\tif (fc_label_text) {\n\t\t\t\t\t\t\t\tvar _label = (fc_label_text.length >= 30) ? fc_label_text.substring(0, 28) + '...' : fc_label_text;\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tjQuery('<span/>', {\n\t\t\t\t\t\t\t\t\t'class': 'fc_has_inner_label fc_has_inner_label_select2',\n\t\t\t\t\t\t\t\t\t'text': _label\n\t\t\t\t\t\t\t\t}).prependTo(el_container.find('.select2-search-field'));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tvar fc_prompt_text = el_select.attr('data-fc_prompt_text');\n\t\t\t\t\t\t\tif (!fc_prompt_text) fc_prompt_text = el_select.attr('fc_prompt_text');\n\t\t\t\t\t\t\tif (fc_prompt_text) {\n\t\t\t\t\t\t\t\tvar _prompt = (fc_prompt_text.length >= 30) ? fc_prompt_text.substring(0, 28) + '...' : fc_prompt_text;\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tjQuery('<span/>', {\n\t\t\t\t\t\t\t\t\t'class': 'fc_has_inner_prompt fc_has_inner_prompt_select2',\n\t\t\t\t\t\t\t\t\t'text': _prompt\n\t\t\t\t\t\t\t\t}).prependTo(el_container.find('.select2-search-field')).hide();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tif ( ! el_select.attr('multiple') && !el_select.hasClass('fc_skip_highlight') ) {\n\t\t\t\t\t\t\t\tvar el = el_container.find('.select2-choice');\n\t\t\t\t\t\t\t\tvar val = el_select.val();\n\t\t\t\t\t\t\t\tif (val === null) {\n\t\t\t\t\t\t\t\t\t//el.addClass('fc_highlight_disabled');\n\t\t\t\t\t\t\t\t} else if (!!val && val.length) {\n\t\t\t\t\t\t\t\t\tel.addClass('fc_highlight');\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tel.removeClass('fc_highlight');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\tjQuery('select.use_select2_lib').on('select2-open', function() {\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tvar el_container = jQuery(this).parent();\n\t\t\t\t\t\t\tvar el = jQuery(this).parent().find('.select2-input');\n\t\t\t\t\t\t\tvar el_label = el.prevAll('.fc_has_inner_label');\n\t\t\t\t\t\t\tif (el_label) el_label.hide();\n\t\t\t\t\t\t\tvar el_prompt = el.prevAll('.fc_has_inner_prompt');\n\t\t\t\t\t\t\tif (el_prompt) el_prompt.show();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tif (jQuery(this).hasClass('select2_list_selected')) {\n\t\t\t\t\t\t\t\tvar els = jQuery('#select2-drop').find('.select2-selected');\n\t\t\t\t\t\t\t\tels.addClass('select2-selected-highlight').addClass('select2-disabled').removeClass('select2-selected').removeClass('select2-result-selectable');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}).on('select2-close', function() {\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tvar el_container = jQuery(this).parent();\n\t\t\t\t\t\t\tvar el = jQuery(this).parent().find('.select2-input');\n\t\t\t\t\t\t\tvar el_label = el.prevAll('.fc_has_inner_label');\n\t\t\t\t\t\t\tif (el_label) el_label.show();\n\t\t\t\t\t\t\tvar el_prompt = el.prevAll('.fc_has_inner_prompt');\n\t\t\t\t\t\t\tif (el_prompt) el_prompt.hide();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tif (jQuery(this).hasClass('select2_list_selected')) {\n\t\t\t\t\t\t\t\tvar els = jQuery('#select2-drop').find('.select2-selected-highlight');\n\t\t\t\t\t\t\t\tels.removeClass('select2-selected-highlight').removeClass('select2-disabled').addClass('select2-result-selectable');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}).on\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\t('change', function() {\n\t\t\t\t\t\t\tvar el_select = jQuery(this);\n\t\t\t\t\t\t\tif ( ! el_select.attr('multiple') && !el_select.hasClass('fc_skip_highlight') ) {\n\t\t\t\t\t\t\t\tvar el = jQuery(this).prev('div').find('.select2-choice');\n\t\t\t\t\t\t\t\tvar val = el_select.val();\n\t\t\t\t\t\t\t\tif (!!val && val.length) {\n\t\t\t\t\t\t\t\t\tel.addClass('fc_highlight');\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tel.removeClass('fc_highlight');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\tjQuery('div.use_select2_lib.select2-container-multi input').on('keydown', function() {\n\t\t\t\t\t\t\tvar el = jQuery(this);\n\t\t\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\t\t\tvar val = el.val();\n\t\t\t\t\t\t\t\tif (!!val && val.length) {\n\t\t\t\t\t\t\t\t\tvar el_prompt = el.prevAll('.fc_has_inner_prompt');\n\t\t\t\t\t\t\t\t\tif (el_prompt) el_prompt.hide();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tvar el_prompt = el.prevAll('.fc_has_inner_prompt');\n\t\t\t\t\t\t\t\t\tif (el_prompt) el_prompt.show();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}, 0);\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\tjQuery('select.use_select2_lib').on('loaded open', function() {\n\t\t\t\t\t\t\tvar ul = jQuery('#select2-drop ul.select2-results');\n\t\t\t\t\t\t\tvar needsScroll= ul.prop('scrollHeight') > ul.prop('clientHeight');\n\t\t\t\t\t\t\tif (needsScroll) ul.css('overflow-y', 'scroll');\n\t\t\t\t\t\t\telse  ul.css('overflow-y', 'auto');\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t});\n\t\t\t\t";
             break;
         case 'inputmask':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             $framework_path = JURI::root(true) . $lib_path . '/inputmask';
             $document->addScript($framework_path . '/jquery.inputmask.bundle.min.js');
             // Extra inputmask declarations definitions, e.g. ...
             $js .= "\n\t\t\t\t";
             // Attach inputmask to all input fields that have appropriate tag parameters
             $js .= "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tInputmask.extendAliases({\n\t\t\t\t\t\t\tdecimal: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tradixPoint: '.',\n\t\t\t\t\t\t\t\tgroupSeparator: ',',\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdecimal_comma: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tradixPoint: ',',\n\t\t\t\t\t\t\t\tgroupSeparator: '.',\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcurrency: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tprefix: '\$ ',\n\t\t\t\t\t\t\t\tgroupSeparator: ',',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tdigits: 2,\n\t\t\t\t\t\t\t\tdigitsOptional: false,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcurrency_euro: {\n\t\t\t\t\t\t\t\talias: 'currency',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tprefix: '\\u20ac ',\n\t\t\t\t\t\t\t\tgroupSeparator: ',',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tdigits: 2,\n\t\t\t\t\t\t\t\tdigitsOptional: false,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: false,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpercentage_zero_nolimit: {\n\t\t\t\t\t\t\t\talias: 'percentage',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tdigits: 2,\n\t\t\t\t\t\t\t\tradixPoint: '.',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tmin: 0,\n\t\t\t\t\t\t\t\tmax: '',\n\t\t\t\t\t\t\t\tsuffix: ' %',\n\t\t\t\t\t\t\t\tallowPlus: false,\n\t\t\t\t\t\t\t\tallowMinus: false,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpercentage_nolimit_nolimit: {\n\t\t\t\t\t\t\t\talias: 'percentage',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tdigits: 2,\n\t\t\t\t\t\t\t\tradixPoint: '.',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tmin: '',\n\t\t\t\t\t\t\t\tmax: '',\n\t\t\t\t\t\t\t\tsuffix: ' %',\n\t\t\t\t\t\t\t\tallowPlus: false,\n\t\t\t\t\t\t\t\tallowMinus: true,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tinteger: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tdigits: 0,\n\t\t\t\t\t\t\t\tradixPoint: '',\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tunsigned: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tdigits: 0,\n\t\t\t\t\t\t\t\tradixPoint: '',\n\t\t\t\t\t\t\t\tallowPlus: false,\n\t\t\t\t\t\t\t\tallowMinus: false,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'mobile': {\n\t\t\t\t\t\t\t\t'mask': '9999 999 999',\n\t\t\t\t\t\t\t\t'autounmask': true,\n\t\t\t\t\t\t\t\t'insertMode': true,\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tjQuery('input.has_inputmask').inputmask();\n\t\t\t\t\t\tjQuery('input.inputmask-regex').inputmask('Regex');\n\t\t\t\t\t});\n\t\t\t\t";
             break;
         case 'prettyCheckable':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             $framework_path = JURI::root(true) . $lib_path . '/prettyCheckable';
             $document->addScript($framework_path . '/dev/prettyCheckable.js');
             $document->addStyleSheet($framework_path . '/dist/prettyCheckable.css');
             $js .= "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tjQuery('input.use_prettycheckable').each(function() {\n\t\t\t\t\t\t\tvar elem = jQuery(this);\n\t\t\t\t\t\t\tvar lbl = elem.next('label');\n\t\t\t\t\t\t\tvar lbl_html = elem.next('label').html();\n\t\t\t\t\t\t\tlbl.remove();\n\t\t\t\t\t\t\telem.prettyCheckable({\n\t\t\t\t\t\t\t\tcolor: 'blue',\n\t\t\t\t\t\t\t\tlabel: lbl_html\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";
             break;
         case 'multibox':
         case 'jmultibox':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             $framework_path = JURI::root(true) . $lib_path . '/jmultibox';
             // Add JS
             $document->addScript($framework_path . '/js/jmultibox.js');
             $document->addScript($framework_path . '/js/jquery.vegas.js');
             // Add CSS
             $document->addStyleSheet($framework_path . '/styles/multibox.css');
             $document->addStyleSheet($framework_path . '/styles/jquery.vegas.css');
             if (substr($_SERVER['HTTP_USER_AGENT'], 0, 34) == "Mozilla/4.0 (compatible; MSIE 6.0;") {
                 $document->addStyleSheet($framework_path . '/styles/multibox-ie6.css');
             }
             // Attach multibox to ... this will be left to the caller so that it will create a multibox object with custom options
             //$js .= "";
             break;
         case 'fancybox':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             $document->addScript(JURI::root(true) . '/components/com_flexicontent/assets/js/jquery-easing.js');
             $framework_path = JURI::root(true) . $lib_path . '/fancybox';
             // Add mousewheel plugin (this is optional)
             $document->addScript($framework_path . '/lib/jquery.mousewheel-3.0.6.pack.js');
             // Add fancyBox CSS / JS
             $document->addStyleSheet($framework_path . '/source/jquery.fancybox.css');
             $document->addScript($framework_path . '/source/jquery.fancybox.pack.js');
             // Optionally add helpers - button, thumbnail and/or media
             $document->addStyleSheet($framework_path . '/source/helpers/jquery.fancybox-buttons.css');
             $document->addScript($framework_path . '/source/helpers/jquery.fancybox-buttons.js');
             $document->addScript($framework_path . '/source/helpers/jquery.fancybox-media.js');
             $document->addStyleSheet($framework_path . '/source/helpers/jquery.fancybox-thumbs.css');
             $document->addScript($framework_path . '/source/helpers/jquery.fancybox-thumbs.js');
             // Attach fancybox to all elements having a specific CSS class
             $js .= "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tjQuery('.fancybox').fancybox({\n\t\t\t\t\t\t\t'openEffect'\t: 'elastic',\n\t\t\t\t\t\t\t'closeEffect'\t: 'elastic',\n\t\t\t\t\t\t\t'openEasing'  : 'easeOutCubic',\n\t\t\t\t\t\t\t'closeEasing' : 'easeInCubic',\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t";
             break;
         case 'galleriffic':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             //flexicontent_html::loadFramework('fancybox');
             $framework_path = JURI::root(true) . $lib_path . '/galleriffic';
             //$document->addStyleSheet($framework_path.'/css/basic.css');  // This is too generic and should not be loaded
             $document->addStyleSheet($framework_path . '/css/galleriffic-3.css');
             $document->addScript($framework_path . '/js/jquery.galleriffic.js');
             $document->addScript($framework_path . '/js/jquery.opacityrollover.js');
             break;
         case 'elastislide':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             $framework_path = JURI::root(true) . $lib_path . '/elastislide';
             $document->addStyleSheet($framework_path . '/css/style.css');
             $document->addStyleSheet($framework_path . '/css/elastislide.css');
             $document->addScript($framework_path . '/js/jquery.tmpl.min.js');
             $document->addScript($framework_path . '/js/jquery.easing.1.3.js');
             $document->addScript($framework_path . '/js/jquery.elastislide.js');
             //$document->addScript($framework_path.'/js/gallery.js'); // replace with field specific: gallery_tmpl.js
             break;
         case 'photoswipe':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             $framework_path = JURI::root(true) . $lib_path . '/photoswipe';
             //$document->addStyleSheet($framework_path.'/lib/jquery.mobile/jquery.mobile.css');
             $document->addStyleSheet($framework_path . '/photoswipe.css');
             //$document->addScript($framework_path.'/lib/jquery.mobile/jquery.mobile.js');
             $document->addScript($framework_path . '/lib/simple-inheritance.min.js');
             //$document->addScript($framework_path.'/lib/jquery.animate-enhanced.min.js');
             $document->addScript($framework_path . '/code.photoswipe.min.js');
             $js .= "\n\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\tvar myPhotoSwipe = jQuery('.photoswipe_fccontainer a').photoSwipe(); \n\t\t\t\t});\n\t\t\t\t";
             break;
         case 'fcxSlide':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             $framework_path = JURI::root(true) . $lib_path . '/fcxSlide';
             $document->addScriptVersion($framework_path . '/class.fcxSlide.js', FLEXI_VERSION);
             $document->addStyleSheetVersion($framework_path . '/fcxSlide.css', FLEXI_VERSION);
             //$document->addScriptVersion($framework_path.'/class.fcxSlide.packed.js', FLEXI_VERSION);
             break;
         case 'imagesLoaded':
             $framework_path = JURI::root(true) . $lib_path . '/imagesLoaded';
             $document->addScript($framework_path . '/imagesloaded.pkgd.min.js');
             break;
         case 'noobSlide':
             // Make sure mootools are loaded
             FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
             $framework_path = JURI::root(true) . $lib_path . '/noobSlide';
             //$document->addScript($framework_path.'/_class.noobSlide.js');
             $document->addScript($framework_path . '/_class.noobSlide.packed.js');
             break;
         case 'zTree':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             $framework_path = JURI::root(true) . $lib_path . '/zTree';
             $document->addStyleSheet($framework_path . '/css/flexi_ztree.css');
             $document->addStyleSheet($framework_path . '/css/zTreeStyle/zTreeStyle.css');
             $document->addScript($framework_path . '/js/jquery.ztree.all-3.5.min.js');
             //$document->addScript($framework_path.'/js/jquery.ztree.core-3.5.js');
             //$document->addScript($framework_path.'/js/jquery.ztree.excheck-3.5.js');
             //$document->addScript($framework_path.'/js/jquery.ztree.exedit-3.5.js');
             break;
         case 'plupload':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             $framework_path = JURI::root(true) . $lib_path . '/plupload';
             $document->addScript($framework_path . '/js/plupload.full.min.js');
             if ($mode == 'ui') {
                 $document->addStyleSheet($framework_path . '/js/jquery.ui.plupload/css/jquery.ui.plupload.css');
                 $document->addScript($framework_path . '/js/jquery.ui.plupload/jquery.ui.plupload.min.js');
                 $document->addScript($framework_path . '/js/themeswitcher.js');
             } else {
                 $document->addStyleSheet($framework_path . '/js/jquery.plupload.queue/css/jquery.plupload.queue.css');
                 $document->addScript($framework_path . '/js/jquery.plupload.queue/jquery.plupload.queue.js');
             }
             $lang_code = flexicontent_html::getUserCurrentLang();
             if ($lang_code && $lang_code != 'en') {
                 // Try language shortcode
                 if (file_exists($framework_folder . DS . 'js' . DS . $lang_code . '.js')) {
                     $document->addScript($framework_path . '/js/' . $lang_code . '.js');
                 } else {
                     $country_code = flexicontent_html::getUserCurrentLang($short_tag = false);
                     if ($country_code && file_exists($framework_folder . DS . 'js' . DS . $country_code . '.js')) {
                         $document->addScript($framework_path . '/js/' . $country_code . '.js');
                     }
                 }
             }
             // For debugging
             //$document->addScript($framework_path.'/js/moxie.min.js');
             //$document->addScript($framework_path.'/js/plupload.dev.js');
             break;
         case 'nouislider':
             $framework_path = JURI::root(true) . $lib_path . '/nouislider';
             $document->addStyleSheet($framework_path . '/nouislider.min.css');
             $document->addScript($framework_path . '/nouislider.min.js');
             break;
         case 'flexi_tmpl_common':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             flexicontent_html::loadFramework('select2');
             // make sure select2 is loaded
             // Make sure user cookie is set
             $jcookie = $app->input->cookie;
             $fc_uid = $jcookie->get('fc_uid', null);
             $hashedUA = JFactory::getUser()->id ? JUserHelper::getShortHashedUserAgent() : 'p';
             if ($fc_uid != $hashedUA) {
                 $jcookie->set('fc_uid', $hashedUA, 0);
             }
             $js .= "\n\t\t\t\t\tvar _FC_GET = " . json_encode($_GET) . ";\n\t\t\t\t";
             $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/tmpl-common.js', FLEXI_VERSION);
             $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/jquery-easing.js', FLEXI_VERSION);
             JText::script("FLEXI_APPLYING_FILTERING", true);
             JText::script("FLEXI_TYPE_TO_LIST", true);
             JText::script("FLEXI_TYPE_TO_FILTER", true);
             JText::script("FLEXI_UPDATING_CONTENTS", true);
             break;
         case 'flexi-lib':
             if ($load_jquery) {
                 flexicontent_html::loadJQuery();
             }
             $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/flexi-lib.js', FLEXI_VERSION);
             JText::script("FLEXI_NOT_AN_IMAGE_FILE", true);
             break;
         default:
             JFactory::getApplication()->enqueueMessage(__FUNCTION__ . ' Cannot load unknown Framework: ' . $framework, 'error');
             break;
     }
     // Add custom JS & CSS code
     if ($js) {
         $document->addScriptDeclaration($js);
     }
     if ($css) {
         $document->addStyleDeclaration($css);
     }
     return $_loaded[$framework];
 }
Esempio n. 4
0
    /**
     * Creates the Fileselement view
     *
     * @since 1.0
     */
    function display($tpl = null)
    {
        // Check for request forgeries
        JRequest::checkToken('request') or jexit('Invalid Token');
        //initialise variables
        $app = JFactory::getApplication();
        $document = JFactory::getDocument();
        $option = JRequest::getCmd('option');
        $view = JRequest::getVar('view');
        $layout = JRequest::getVar('layout', 'default');
        $db = JFactory::getDBO();
        $user = JFactory::getUser();
        $cparams = JComponentHelper::getParams('com_flexicontent');
        //$authorparams = flexicontent_db::getUserConfig($user->id);
        $langs = FLEXIUtilities::getLanguages('code');
        $fieldid = JRequest::getVar('field', null, 'request', 'int');
        $client = $app->isAdmin() ? '../' : '';
        flexicontent_html::loadJQuery();
        flexicontent_html::loadFramework('select2');
        JHTML::_('behavior.tooltip');
        // Load the form validation behavior
        JHTML::_('behavior.formvalidation');
        // Get filters
        $_view = $view . $fieldid;
        $folder_mode = $app->getUserStateFromRequest($option . '.' . $_view . '.folder_mode', 'folder_mode', 0, 'int');
        // Get User's Global Permissions
        $perms = FlexicontentHelperPerm::getPerm();
        // Get model
        $model = $this->getModel();
        $count_filters = 0;
        $filter_order = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_order', 'filter_order', 'f.filename', 'cmd');
        $filter_order_Dir = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_order_Dir', 'filter_order_Dir', '', 'word');
        $filter_lang = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_lang', 'filter_lang', '', 'string');
        $filter_url = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_url', 'filter_url', '', 'word');
        $filter_secure = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_secure', 'filter_secure', '', 'word');
        $target_dir = 2;
        if (!$folder_mode) {
            $field_params = $model->getFieldParams();
            $target_dir = $field_params->get('target_dir', '');
            // Clear secure/media filter if field is not configured to use specific
            if (!strlen($target_dir) || $target_dir != 2) {
                $filter_secure = '';
            }
        }
        $filter_ext = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_ext', 'filter_ext', '', 'alnum');
        $filter_uploader = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_uploader', 'filter_uploader', '', 'int');
        $filter_item = $app->getUserStateFromRequest($option . '.' . $_view . '.item_id', 'item_id', '', 'int');
        if ($layout != 'image') {
            if ($filter_lang) {
                $count_filters++;
            }
            if ($filter_url) {
                $count_filters++;
            }
            if ($filter_secure) {
                $count_filters++;
            }
        }
        if ($filter_ext) {
            $count_filters++;
        }
        //if ($perms->CanViewAllFiles && $filter_uploader) $count_filters++;
        if ($filter_item) {
            $count_filters++;
        }
        $u_item_id = $app->getUserStateFromRequest($option . '.' . $_view . '.u_item_id', 'u_item_id', 0, 'string');
        //if ($u_item_id && (int)$u_item_id = $u_item_id) $filter_item = $u_item_id;   // DO NOT SET it prevents listing and selecting files !!
        if (!$u_item_id && $filter_item) {
            $u_item_id = $filter_item;
        }
        $autoselect = $app->getUserStateFromRequest($option . '.' . $_view . '.autoselect', 'autoselect', 0, 'int');
        $autoassign = $app->getUserStateFromRequest($option . '.' . $_view . '.autoassign', 'autoassign', 0, 'int');
        $folder_param = $app->getUserStateFromRequest($option . '.' . $_view . '.folder_param', 'folder_param', 'dir', 'string');
        $append_item = $app->getUserStateFromRequest($option . '.' . $_view . '.append_item', 'append_item', 1, 'int');
        $append_field = $app->getUserStateFromRequest($option . '.' . $_view . '.append_field', 'append_field', 1, 'int');
        $targetid = $app->getUserStateFromRequest($option . '.' . $_view . '.targetid', 'targetid', '', 'string');
        $thumb_w = $app->getUserStateFromRequest($option . '.' . $_view . '.thumb_w', 'thumb_w', 120, 'int');
        $thumb_h = $app->getUserStateFromRequest($option . '.' . $_view . '.thumb_h', 'thumb_h', 90, 'int');
        $scope = $app->getUserStateFromRequest($option . '.' . $_view . '.scope', 'scope', 1, 'int');
        $search = $app->getUserStateFromRequest($option . '.' . $_view . '.search', 'search', '', 'string');
        $search = $db->escape(trim(JString::strtolower($search)));
        $filter_uploader = $filter_uploader ? $filter_uploader : '';
        $filter_item = $filter_item ? $filter_item : '';
        $newfileid = JRequest::getInt('newfileid');
        $newfilename = base64_decode(JRequest::getVar('newfilename', ''));
        $delfilename = base64_decode(JRequest::getVar('delfilename', ''));
        // Add custom css and js to document
        if ($app->isSite()) {
            $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontent.css');
        } else {
            $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');
            }
        }
        // This is not included automatically in frontend
        JFactory::getDocument()->addScript(JURI::root(true) . '/components/com_flexicontent/assets/js/flexi-lib.js');
        // Include backend CSS template CSS file , access to backend folder may not be allowed but ...
        //$template = $app->isSite() ? (!FLEXI_J16GE ? 'khepri' : (FLEXI_J30GE ? 'hathor' : 'bluestork')) : $app->getTemplate();
        //$document->addStyleSheet(JURI::base(true).'/templates/'.$template.(FLEXI_J16GE ? '/css/template.css': '/css/general.css'));
        //a trick to avoid loosing general style in modal window
        $css = 'body, td, th { font-size: 11px; }
		a.striketext {
			text-decoration: line-through;
			color:red;
			font-style:italic;
		}
		';
        $document->addStyleDeclaration($css);
        // Create document/toolbar titles
        $doc_title = JText::_('FLEXI_FILE');
        $site_title = $document->getTitle();
        $document->setTitle($doc_title . ' - ' . $site_title);
        // ***********************
        // Get data from the model
        // ***********************
        if (!$folder_mode) {
            $rows = $this->get('Data');
            $img_folder = '';
        } else {
            $exts = $cparams->get('upload_extensions', 'bmp,csv,doc,gif,ico,jpg,jpeg,odg,odp,ods,odt,pdf,png,ppt,swf,txt,xcf,xls,zip,ics');
            $rows = $model->getFilesFromPath($u_item_id, $fieldid, $append_item, $append_field, $folder_param, $exts);
            $img_folder = $model->getFieldFolderPath($u_item_id, $fieldid, $append_item, $append_field, $folder_param);
            $img_path = str_replace('\\', '/', $img_folder . DS . $newfilename);
            $thumb = JURI::root() . 'components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $img_path . '&w=' . $thumb_w . '&h=' . $thumb_h;
        }
        $upload_path_var = 'fc_upload_path_' . $fieldid . '_' . $u_item_id;
        $app->setUserState($upload_path_var, $img_folder);
        //echo $upload_path_var . "<br>";
        //echo $app->getUserState( $upload_path_var, 'noset' );
        $pagination = $this->get('Pagination');
        //$users = $this->get('Users');
        // Get item using at least one file (-of- the currently listed files)
        /*$items_single	= $model->getItemsSingleprop( array('file','minigallery') );
        		$items_multi	= $model->getItemsMultiprop ( $field_props=array('image'=>'originalname'), $value_props=array('image'=>'filename') );
        		$items = array();
        		foreach ($items_single as $item_id => $_item) $items[$item_id] = $_item;
        		foreach ($items_multi  as $item_id => $_item) $items[$item_id] = $_item;
        		ksort($items);*/
        $fname = $model->getFieldName($fieldid);
        $files_selected = $model->getItemFiles($u_item_id);
        $formfieldname = FLEXI_J16GE ? 'custom[' . $fname . '][]' : $fname . '[]';
        //add js to document
        if ($folder_mode) {
            $js = "\n\t\t\tjQuery(document).ready(function()\n\t\t\t{\n\t\t\t\tvar delfilename = '" . $delfilename . "';\n\t\t\t\tvar remove_existing_files_from_list = 0;\n\t\t\t\tvar remove_new_files_from_list = 0;\n\t\t\t\t\n\t\t\t\t// Find and mark file usage by filename search\n\t\t\t\tvar original_objs = jQuery(window.parent.document.body).find('.fcfieldval_container_" . $fieldid . " .originalname');\n\t\t\t\tvar existing_objs = jQuery(window.parent.document.body).find('.fcfieldval_container_" . $fieldid . " .existingname');\n\t\t\t\t\n\t\t\t\tvar imgobjs = Array();\n\t\t\t\tfor(i=0,n=original_objs.length; i<n; i++)  {\n\t\t\t\t\tif (original_objs[i].value) imgobjs.push(original_objs[i].value);\n\t\t\t\t\tif (delfilename!='' && original_objs[i].value == delfilename)\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.parent.qmAssignFile" . $fieldid . "('" . $targetid . "', '', '', '1');\n\t\t\t\t\t\tremove_existing_files_from_list = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(i=0,n=existing_objs.length; i<n; i++) {\n\t\t\t\t\tif (existing_objs[i].value) imgobjs.push(existing_objs[i].value);\n\t\t\t\t\tif (delfilename!='' && existing_objs[i].value == delfilename)\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.parent.qmAssignFile" . $fieldid . "('" . $targetid . "', '', '', '1');\n\t\t\t\t\t\tremove_new_files_from_list = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif ( remove_existing_files_from_list || remove_new_files_from_list ) {\n\t\t\t\t\tmssg = '" . JText::_('FLEXI_DELETE_FILE_IN_LIST_WINDOW_MUST_CLOSE') . "';\n\t\t\t\t\tmssg = mssg + '\\n' + (remove_existing_files_from_list ? '" . JText::_('FLEXI_EXISTING_FILE_REMOVED_SAVE_RECOMMENEDED', true) . "' : '');\n\t\t\t\t\talert( mssg );\n\t\t\t\t\twindow.parent.qmAssignFile" . $fieldid . "('" . $targetid . "', '', '', '2');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfor(i=0,n=imgobjs.length; i<n; i++) {\n\t\t\t\t\tvar rows = jQuery.find('a[data-filename=\"'+ imgobjs[i] +'\"]');\n\t\t\t\t\tjQuery(rows).addClass('striketext');\n\t\t\t\t}\n\t\t\t\t" . ($autoassign && $newfilename ? "window.parent.qmAssignFile" . $fieldid . "('" . $targetid . "', '" . $newfilename . "', '" . $thumb . "');" : "") . "\n\t\t\t});\n\t\t\t";
        } else {
            $js = "\n\t\t\tfunction qffileselementadd(obj, id, file) {\n\t\t\t\tvar result = window.parent.qfSelectFile" . $fieldid . "(obj, id, file);\n\t\t\t\tif ((typeof result) != 'undefined' && result == 'cancel') return;\n\t\t\t\tobj.className = 'striketext';\n\t\t\t\tdocument.adminForm.file.value=id;\n\t\t\t}\n\t\t\tjQuery(document).ready(function()\n\t\t\t{\n\t\t\t\t// Find and mark file usage by filename search\n\t\t\t\tvar existing_objs = jQuery(window.parent.document.body).find('.fcfieldval_container_" . $fieldid . " .existingname');\n\t\t\t\tfor(i=0,n=existing_objs.length; i<n; i++) {\n\t\t\t\t\tvar rows = jQuery.find('a[data-filename=\"'+ existing_objs[i].value +'\"]');\n\t\t\t\t\tjQuery(rows).addClass('striketext');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Find and mark file usage by fileid search\n\t\t\t\tvar id_objs = jQuery(window.parent.document.body).find('.fcfieldval_container_" . $fieldid . " input.contains_fileid');\n\t\t\t\tvar imgids = Array();\n\t\t\t\tfor(i=0,n=id_objs.length; i<n; i++) {\n\t\t\t\t\tif ( id_objs[i].value) imgids.push(id_objs[i].value);\n\t\t\t\t}\n\t\t\t\tfor(i=0,n=imgids.length; i<n; i++) {\n\t\t\t\t\tvar rows = jQuery.find('a[data-fileid=\"'+ imgids[i] +'\"]');\n\t\t\t\t\tjQuery(rows).addClass('striketext');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t" . ($autoselect && $newfileid ? "qffileselementadd( document.getElementById('file" . $newfileid . "'), '" . $newfileid . "', '" . $newfilename . "');" : "") . "\n\t\t\t});\n\t\t\t";
        }
        $document->addScriptDeclaration($js);
        if ($autoselect && $newfileid) {
            $app->enqueueMessage(JText::_('FLEXI_UPLOADED_FILE_WAS_SELECTED'), 'message');
        }
        /*****************
         ** BUILD LISTS **
         *****************/
        $lists = array();
        // ** FILE UPLOAD FORM **
        // Build languages list
        //$allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed',null);
        //$allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs);
        $display_file_lang_as = $cparams->get('display_file_lang_as', 3);
        $allowed_langs = null;
        $lists['file-lang'] = flexicontent_html::buildlanguageslist('file-lang', '', '*', $display_file_lang_as, $allowed_langs, $published_only = false);
        /*************
         ** FILTERS **
         *************/
        // language filter
        $lists['language'] = ($filter_lang || 1 ? '<label class="label">' . JText::_('FLEXI_LANGUAGE') . '</label>' : '') . flexicontent_html::buildlanguageslist('filter_lang', 'class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" size="1" ', $filter_lang, '-');
        // search
        $lists['search'] = $search;
        //search filter
        $filters = array();
        $filters[] = JHTML::_('select.option', '1', JText::_('FLEXI_FILENAME'));
        $filters[] = JHTML::_('select.option', '2', JText::_('FLEXI_FILE_DISPLAY_TITLE'));
        $lists['scope'] = JHTML::_('select.genericlist', $filters, 'scope', 'size="1" class="use_select2_lib fc_skip_highlight" title="' . JText::_('FLEXI_SEARCH_TEXT_INSIDE') . '"', 'value', 'text', $scope);
        //build url/file filterlist
        $url = array();
        $url[] = JHTML::_('select.option', '', '-');
        $url[] = JHTML::_('select.option', 'F', JText::_('FLEXI_FILE'));
        $url[] = JHTML::_('select.option', 'U', JText::_('FLEXI_URL'));
        $lists['url'] = ($filter_url || 1 ? '<label class="label">' . JText::_('FLEXI_ALL_FILES') . '</label>' : '') . JHTML::_('select.genericlist', $url, 'filter_url', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_url);
        //item lists
        /*$items_list = array();
        		$items_list[] = JHTML::_('select.option', '', '- '. JText::_( 'FLEXI_FILTER_BY_ITEM' ) .' -' );
        		foreach($items as $item) {
        			$items_list[] = JHTML::_('select.option', $item->id, JText::_( $item->title ) . ' (#' . $item->id . ')' );
        		}
        		$lists['item_id'] = JHTML::_('select.genericlist', $items_list, 'item_id', 'size="1" class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_item );*/
        $lists['item_id'] = '<input type="text" name="item_id" size="1" class="inputbox" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" value="' . $filter_item . '" />';
        //build secure/media filterlist
        $secure = array();
        $secure[] = JHTML::_('select.option', '', '-');
        $secure[] = JHTML::_('select.option', 'S', JText::_('FLEXI_SECURE_DIR'));
        $secure[] = JHTML::_('select.option', 'M', JText::_('FLEXI_MEDIA_DIR'));
        $lists['secure'] = ($filter_secure || 1 ? '<label class="label">' . JText::_('FLEXI_ALL_DIRECTORIES') . '</label>' : '') . JHTML::_('select.genericlist', $secure, 'filter_secure', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_secure);
        //build ext filterlist
        $lists['ext'] = ($filter_ext || 1 ? '<label class="label">' . JText::_('FLEXI_ALL_EXT') . '</label>' : '') . flexicontent_html::buildfilesextlist('filter_ext', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', $filter_ext, '-');
        //build uploader filterlist
        $lists['uploader'] = ($filter_uploader || 1 ? '<label class="label">' . JText::_('FLEXI_ALL_UPLOADERS') . '</label>' : '') . flexicontent_html::builduploaderlist('filter_uploader', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', $filter_uploader, '-');
        // table ordering
        $lists['order_Dir'] = $filter_order_Dir;
        $lists['order'] = $filter_order;
        // removed files
        $filelist = JRequest::getString('files');
        $file = JRequest::getInt('file');
        $filelist = explode(',', $filelist);
        $files = array();
        foreach ($filelist as $fileid) {
            if ($fileid && $fileid != $file) {
                $files[] = (int) $fileid;
            }
        }
        $files = implode(',', $files);
        if (strlen($files) > 0) {
            $files .= ',';
        }
        $files .= $file;
        //assign data to template
        $this->assignRef('target_dir', $target_dir);
        $this->assignRef('count_filters', $count_filters);
        $this->assignRef('params', $cparams);
        $this->assignRef('client', $client);
        $this->assignRef('lists', $lists);
        $this->assignRef('rows', $rows);
        $this->assignRef('folder_mode', $folder_mode);
        $this->assignRef('img_folder', $img_folder);
        $this->assignRef('thumb_w', $thumb_w);
        $this->assignRef('thumb_h', $thumb_h);
        $this->assignRef('pagination', $pagination);
        $this->assignRef('files', $files);
        $this->assignRef('fieldid', $fieldid);
        $this->assignRef('u_item_id', $u_item_id);
        $this->assignRef('targetid', $targetid);
        $this->assignRef('CanFiles', $perms->CanFiles);
        $this->assignRef('CanUpload', $perms->CanUpload);
        $this->assignRef('CanViewAllFiles', $perms->CanViewAllFiles);
        $this->assignRef('files_selected', $files_selected);
        $this->assignRef('langs', $langs);
        $this->assignRef('option', $option);
        $this->assignRef('view', $view);
        parent::display($tpl);
    }
Esempio n. 5
0
    function display($tpl = null)
    {
        //initialise variables
        $mainframe = JFactory::getApplication();
        $option = JRequest::getVar('option');
        $db = JFactory::getDBO();
        $document = JFactory::getDocument();
        $user = JFactory::getUser();
        FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
        $use_jquery_sortable = true;
        //FLEXI_J16GE ? true : false;
        if ($use_jquery_sortable) {
            flexicontent_html::loadJQuery();
        } else {
            // mootools sortable
            $document->addScript(JURI::base() . 'components/com_flexicontent/assets/js/sortables.js');
        }
        $type = JRequest::getVar('type', 'items', '', 'word');
        $folder = JRequest::getVar('folder', 'default', '', 'cmd');
        if (FLEXI_FISH || FLEXI_J16GE) {
            FLEXIUtilities::loadTemplateLanguageFile($folder);
        }
        //Get data from the model
        $layout = $this->get('Data');
        $fields = $this->get('Fields');
        $fbypos = $this->get('FieldsByPositions');
        $used = $this->get('UsedFields');
        $contentTypes = $this->get('ContentTypesList');
        $fieldTypes = $this->get('FieldTypesList');
        // 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="fcfield_selectval" ';
        $content_type_select = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', '', $elementid);
        // Create FIELD TYPE SELECTOR
        $options = array();
        $options[] = JHTML::_('select.option', '', JText::_('FLEXI_ALL'));
        foreach ($fieldTypes as $fieldType) {
            $options[] = JHTML::_('select.option', $fieldType->type_name, $fieldType->field_name);
        }
        $fieldname = $elementid = 'field_type__au__';
        $attribs = ' onchange="filterFieldList(\'%s\', \'%s\', \'%s\');" class="fcfield_selectval" ';
        $field_type_select = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', '', $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[] = $use_jquery_sortable ? 'storeordering(jQuery("#sortable-' . $v . '"))' : 'results(' . $k . ',\'' . $v . '\')';
                }
            }
            $positions = implode(',', $idsort);
            $jssort = implode("; ", $jssort);
            $sortable_ids = "#" . implode(",#", $sort);
            if ($use_jquery_sortable) {
                $js = "\n\t\t\t\tjQuery(function() {\n\t\t\t\t\tmy = jQuery( \"{$sortable_ids}\" ).sortable({\n\t\t\t\t\t\tconnectWith: \"" . $sortable_ids . "\",\n\t\t\t\t\t\tupdate: function(event, ui) {\n\t\t\t\t\t\t\tif(ui.sender) {\n\t\t\t\t\t\t\t\tstoreordering(jQuery(ui.sender));\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\tstoreordering(jQuery(ui.item).parent());\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\tinitordering();\n\t\t\t\t});\n\t\t\t\tfunction storeordering(parent_element) {\n\t\t\t\t\thidden_id = '#'+jQuery.trim(parent_element.attr('id').replace('sortable-',''));\n\t\t\t\t\tfields = new Array();\n\t\t\t\t\ti = 0;\n\t\t\t\t\tparent_element.children('li').each(function(){\n\t\t\t\t\t\tfields[i++] = jQuery(this).attr('id').replace('field_', '');\n\t\t\t\t\t});\n\t\t\t\t\tjQuery(hidden_id).val(fields.join(','))\n\t\t\t\t}\n\t\t\t\t";
            } else {
                $js = "\n\t\t\t\tvar my = '';\n\t\t\t\twindow.addEvent('domready', function(){\n\t\t\t\t\tvar mySortables = new Sortables('.positions', {\n\t\t\t\t\t\tconstrain: false,\n\t\t\t\t\t\tclone: false,\n\t\t\t\t\t\trevert: true,\n\t\t\t\t\t\tonComplete: storeordering\n\t\t\t\t\t});\n\t\t\t\t\tmy = mySortables;\n\t\t\t\t\tstoreordering();\n\n\t\t\t\t\tvar slideaccess = new Fx.Slide('propvisible');\n\t\t\t\t\tvar slidenoaccess = new Fx.Slide('propnovisible');\n\t\t\t\t\tvar legend = \$\$('fieldset.tmplprop legend');\n\t\t\t\t\tslidenoaccess.hide();\n\t\t\t\t\tlegend.addEvent('click', function(ev) {\n\t\t\t\t\t\tlegend.toggleClass('open');\n\t\t\t\t\t\tslideaccess.toggle();\n\t\t\t\t\t\tslidenoaccess.toggle();\n\t\t\t\t\t});\n\n\n\t\t\t\t});\n\n\t\t\t\tfunction results(i, field) {\n\t\t\t\t\tvar res = my.serialize(i, function(element, index){\n\t\t\t\t\treturn element.getProperty('id').replace('field_','');\n\t\t\t\t}).join(',');\n\t\t\t\t\t\$(field).value = res;\n\t\t\t\t}\n\t\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);
        }
        JHTML::_('behavior.tooltip');
        JHTML::_('behavior.modal');
        //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');
            }
        }
        $permission = FlexicontentHelperPerm::getPerm();
        if (!$permission->CanTemplates) {
            $mainframe->redirect('index.php?option=com_flexicontent', JText::_('FLEXI_NO_ACCESS'));
        }
        //Create Submenu
        FLEXISubmenu('CanTemplates');
        //create the toolbar
        JToolBarHelper::title(JText::_('FLEXI_EDIT_TEMPLATE'), 'templates');
        if (FLEXI_J16GE) {
            JToolBarHelper::apply('templates.apply');
            JToolBarHelper::save('templates.save');
            JToolBarHelper::cancel('templates.cancel');
        } else {
            JToolBarHelper::apply();
            JToolBarHelper::save();
            JToolBarHelper::cancel();
        }
        //assign data to template
        $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);
    }
Esempio n. 6
0
 /**
  * Method to get the list of files for the field options.
  * Specify the target directory with a directory attribute
  * Attributes allow an exclude mask and stripping of extensions from file name.
  * Default attribute may optionally be set to null (no file) or -1 (use a default).
  *
  * @return  array  The field option objects.
  *
  * @since   1.5
  */
 protected function getInput()
 {
     // element params
     $node =& $this->element;
     $attributes = get_object_vars($node->attributes());
     $attributes = $attributes['@attributes'];
     // value
     $value = $this->value;
     $value = $value ? $value : $attributes['default'];
     // Get current extension and id being edited
     $view = JRequest::getVar('view');
     $option = JRequest::getVar('option');
     if ($option == 'com_modules' || $option == 'com_advancedmodules' || $option == 'com_falang' && JRequest::getVar('catid') == 'modules') {
         $view = 'module';
     }
     $cid = JRequest::getVar('cid', array(0), $hash = 'default', 'array');
     JArrayHelper::toInteger($cid, array(0));
     $pk = $cid[0];
     if (!$pk) {
         $pk = JRequest::getInt('id', 0);
     }
     // Initialize variables.
     //$options = array();
     // Initialize some field attributes.
     $filter = (string) @$attributes['filter'];
     $exclude = (string) @$attributes['exclude'];
     $stripExt = (string) @$attributes['stripext'];
     $hideNone = (string) @$attributes['hide_none'];
     $hideDefault = (string) @$attributes['hide_default'];
     // Get the path which contains layouts
     $directory = (string) @$attributes['directory'];
     $path = (!is_dir($directory) ? JPATH_ROOT : '') . $directory;
     // For using directory in url
     $directory = str_replace('\\', '/', $directory);
     // Prepare the grouped list
     $groups = array();
     $groups['_'] = array();
     $groups['_']['id'] = $this->id . '__';
     $groups['_']['text'] = $view == 'module' ? JText::sprintf('JOPTION_FROM_MODULE') : 'Layouts';
     $groups['_']['items'] = array();
     // Prepend some default options based on field attributes.
     if (!$hideNone) {
         $groups['_']['items'][] = JHTML::_('select.option', '-1', JText::alt('JOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)));
     }
     if (!$hideDefault) {
         $groups['_']['items'][] = JHTML::_('select.option', '', JText::alt('JOPTION_USE_DEFAULT', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)));
     }
     // Get a list of files in the search path with the given filter.
     $files = JFolder::files($path, $filter);
     $module_layouts = array();
     // Build the options list from the list of files.
     if (is_array($files)) {
         foreach ($files as $file) {
             // Check to see if the file is in the exclude mask.
             if ($exclude && preg_match(chr(1) . $exclude . chr(1), $file)) {
                 continue;
             }
             // If the extension is to be stripped, do it.
             if ($stripExt) {
                 $file = JFile::stripExt($file);
             }
             $groups['_']['items'][] = JHTML::_('select.option', $file, $file);
             $module_layouts[] = $file;
         }
     }
     // Merge any additional options in the XML definition.
     //if (FLEXI_J16GE) $options = array_merge(parent::getOptions(), $options);
     // Merge any additional options in the XML definition.
     $options = parent::getOptions();
     if (count($options) > 0) {
         $groups['extended'] = array();
         $groups['extended']['id'] = $this->id . '_extended';
         $groups['extended']['text'] = JText::sprintf('From xml options elements');
         $groups['extended']['items'] = $options;
     }
     // START custom templates
     if ($view == 'module') {
         // Get the database object and a new query object.
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         // Get the client id.
         $clientId = $this->element['client_id'];
         if (is_null($clientId) && $this->form instanceof JForm) {
             $clientId = $this->form->getValue('client_id');
         }
         $clientId = (int) $clientId;
         $client = JApplicationHelper::getClientInfo($clientId);
         // Get the module.
         $module = (string) $this->element['module'];
         if (empty($module) && $this->form instanceof JForm) {
             $module = $this->form->getValue('module');
         }
         $module = preg_replace('#\\W#', '', $module);
         // Get the template.
         $template = (string) $this->element['template'];
         $template = preg_replace('#\\W#', '', $template);
         // Get the style.
         if ($this->form instanceof JForm) {
             $template_style_id = $this->form->getValue('template_style_id');
         }
         $template_style_id = preg_replace('#\\W#', '', $template_style_id);
         // Build the query.
         $query->select('element, name')->from('#__extensions as e')->where('e.client_id = ' . (int) $clientId)->where('e.type = ' . $db->quote('template'))->where('e.enabled = 1');
         if ($template) {
             $query->where('e.element = ' . $db->quote($template));
         }
         if ($template_style_id) {
             $query->join('LEFT', '#__template_styles as s on s.template=e.element')->where('s.id=' . (int) $template_style_id);
         }
         // Set the query and load the templates.
         $db->setQuery($query);
         $templates = $db->loadObjectList('element');
         // Load language file
         $lang = JFactory::getLanguage();
         $lang->load($module . '.sys', $client->path, null, false, true) || $lang->load($module . '.sys', $client->path . '/modules/' . $module, null, false, true);
         // Loop on all templates
         if ($templates) {
             foreach ($templates as $template) {
                 // Load language file
                 $lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, true) || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, true);
                 $template_path = JPath::clean($client->path . '/templates/' . $template->element . '/html/' . $module);
                 // Add the layout options from the template path.
                 if (is_dir($template_path) && ($files = JFolder::files($template_path, '^[^_]*\\.php$'))) {
                     foreach ($files as $i => $file) {
                         // Remove layout that already exist in component ones
                         if (in_array(basename($file, '.php'), $module_layouts)) {
                             unset($files[$i]);
                         }
                     }
                     if (count($files)) {
                         // Create the group for the template
                         $groups[$template->element] = array();
                         $groups[$template->element]['id'] = $this->id . '_' . $template->element;
                         $groups[$template->element]['text'] = JText::sprintf('JOPTION_FROM_TEMPLATE', $template->name);
                         $groups[$template->element]['items'] = array();
                         foreach ($files as $file) {
                             // Add an option to the template group
                             $value = basename($file, '.php');
                             $text = $lang->hasKey($key = strtoupper('TPL_' . $template->element . '_' . $module . '_LAYOUT_' . $value)) ? JText::_($key) : $value;
                             $groups[$template->element]['items'][] = JHtml::_('select.option', $template->element . ':' . $value, $text);
                         }
                     }
                 }
             }
         }
         // END custom templates
     }
     // Element name and id
     $_name = $this->fieldname;
     $fieldname = $this->name;
     $element_id = $this->id;
     // Add tag attributes
     $attribs = '';
     if (@$attributes['multiple'] == 'multiple' || @$attributes['multiple'] == 'true') {
         $attribs .= ' multiple="multiple" ';
         $attribs .= @$attributes['size'] ? ' size="' . @$attributes['size'] . '" ' : ' size="6" ';
     } else {
         $attribs .= 'class="inputbox"';
     }
     $attribs .= ' onchange="fc_getLayout(this);"';
     // Container of parameters
     $tmpl_container = (string) @$attributes['tmpl_container'];
     // Add JS code to display parameters, either via 'file' or 'inline'
     // For modules we can not use method 'file' (external xml file), because J2.5+ does form validation on the XML file ...
     $params_source = (string) @$attributes['params_source'];
     $container_sx = FLEXI_J16GE ? '-options' : '-page';
     flexicontent_html::loadJQuery();
     if (!@$attributes['skipparams']) {
         $doc = JFactory::getDocument();
         $js = "\n\n" . ($params_source == "file" ? "\n\nfunction fc_getLayout(el)\n{\n\tvar container = jQuery('#" . $tmpl_container . $container_sx . "');\n \tvar container2 = jQuery('a[href=\"#attrib-" . $tmpl_container . "\"]');\n \t\n  // *** Hide layout container\n\t//if (container) container.parent().css('display', 'none');\n \t//if (container2) container2.parent().css('display', 'none');\n\t\n\tvar panel;\n\tvar panel_name;\n\tvar panel_header = container;\n\tif (panel_header) {\n\t\tpanel_name = '" . $tmpl_container . $container_sx . "';\n\t\tpanel = panel_header.next();\n\t}\n\t\n\tif (panel_header.length==0 && container2.length>0) {\n\t\tpanel_header = container2;\n\t\tpanel_name = 'attrib-" . $tmpl_container . "';\n\t\tpanel = jQuery('#'+panel_name);\n\t}\n\t\n\tvar layout_name = el.value;\n\tvar _loading_img = '<img src=\"components/com_flexicontent/assets/images/ajax-loader.gif\" align=\"center\">';\n\tpanel_header.html(_loading_img);\n\tpanel_header.html('<a href=\"javascript:void(0);\"><span>Layout: '+_loading_img+'</span></a>');\n\tpanel.html('');\n\tjQuery.ajax({\n\t\ttype: 'GET',\n\t\turl: 'index.php?option=com_flexicontent&task=templates.getlayoutparams&ext_view=" . $view . "&ext_option=" . $option . "&ext_id=" . $pk . "&directory=" . $directory . "&layout_name='+layout_name+'&format=raw',\n\t\tsuccess: function(str) {\n\t\t\tpanel_header.html('<a href=\"javascript:void(0);\"><span>Layout: '+layout_name+'</span></a>');\n\t\t \tpanel_header.parent().css('display', '');\n\t\t\tpanel.html(str);\n\t\t\tjQuery('.hasTooltip').tooltip({'html': true,'container': panel});\n\t\t\t//tabberAutomatic(tabberOptions, panel_name);\n\t\t\tfc_bindFormDependencies('#'+panel_name, 0, '');\n\t\t}\n\t});\n}\n\n" : "\n\nfunction fc_getLayout(el)\n{\n  // *** Hide default container\n\tvar container = \$('" . $tmpl_container . $container_sx . "');\n\tif (container) container.getParent().setStyle('display', 'none');\n\t\n\t" . (FLEXI_J30GE ? "\n \tvar container = jQuery('a[href=\"#attrib-" . $tmpl_container . "\"]');\n \tif (container) container.parent().css('display', 'none');\n \t" : "") . "\n\t\n  // *** Hide ALL containers\n  var layout_name = el.value;\n\tvar layouts = new Array('" . implode("','", $module_layouts) . "');\n\tfor (i=0; i<layouts.length; i++) {\n\t\tif (layouts[i] == layout_name) continue;\n\t\t\n\t\tvar container = \$('" . $tmpl_container . "_' + layouts[i] + '" . $container_sx . "');\n\t\tif (container) container.getParent().setStyle('display', 'none');\n\t\t\n\t\t" . (FLEXI_J30GE ? "\n  \tvar container = jQuery('a[href=\"#attrib-" . $tmpl_container . "_' + layouts[i] + '\"]');\n  \tif (container) {container.parent().css('display', 'none');}\n  \t" : "") . "\n  }\n\t\n\t// *** Show current container\n  var container = \$('" . $tmpl_container . "_' + layout_name + '" . $container_sx . "');\n  if (container) container.getParent().setStyle('display', '');\n  \n\t" . (FLEXI_J30GE ? "\n\tvar container = jQuery('a[href=\"#attrib-" . $tmpl_container . "_' + layout_name + '\"]');\n\tif (container) container.parent().css('display', '');\n \t" : "") . "\n}\n\n") . "\n\nwindow.addEvent('domready', function(){\n\tfc_getLayout(\$('jform_" . ($view == 'field' ? "attribs_" : "params_") . $_name . "'));\n});\n\n";
         $doc->addScriptDeclaration($js);
     }
     // Compute the current selected values
     $selected = array($this->value);
     // Create form element
     return JHTML::_('select.groupedlist', $groups, $fieldname, array('id' => $element_id, 'group.id' => 'id', 'list.attr' => $attribs, 'list.select' => $selected));
 }
Esempio n. 7
0
 function add_css_js()
 {
     $css = "\n\t\tdiv.pane-sliders ul.adminformlist li label.hasTip {\n\t\t\tdisplay:inline-block; padding: 4px; margin: 1px 6px 0px 1px; text-align: right;\twidth:132px; font-weight: bold;\n\t\t\tbackground-color: #F6F6F6; border-bottom: 1px solid #E9E9E9; border-right: 1px solid #E9E9E9; color: #666666;\n\t\t}\n\t\tdiv.pane-sliders ul.adminformlist li ul#rules label.hasTip {\n\t\t\tdisplay:inherit; padding: inherit; margin: inherit; text-align: inherit;\twidth: inherit; font-weight: inherit;\n\t\t\tbackground-color: inherit; border-width: 0px; color: inherit;\n\t\t}\n\t\tdiv.pane-sliders ul.adminformlist li select { margin-bottom: 0px;}\n\t\tdiv.pane-sliders ul.adminformlist li fieldset  { margin: 0; padding: 0; }\n\t\t\n\t\tdiv.current ul.config-option-list li .fcsep_level3 {\n\t\t\tleft: 232px !important;\n\t\t}\n\t\tdiv.controls input, div.controls textarea {\n\t\t\tmin-width: 56%;\n\t\t}\n\t\tdiv.control-group div.control-label label.hasTooltip,\n\t\tdiv.current ul.config-option-list li label.hasTooltip,\n\t\tdiv.current ul.config-option-list li label.hasTip {\n\t\t\tdisplay:inline-block; padding: 4px; margin: 1px 6px 0px 1px; text-align: right;\twidth:220px; font-weight: normal; font-size: 12px;\n\t\t\tbackground-color: #F6F6F6; border-bottom: 1px solid #E9E9E9; border-right: 1px solid #E9E9E9; color: #666666;\n\t\t}\n\t\tdiv.current ul.config-option-list li ul#rules label.hasTip {\n\t\t\tdisplay:inherit; padding: inherit; margin: inherit; text-align: inherit;\twidth: inherit; font-weight: inherit;\n\t\t\tbackground-color: inherit; border-width: 0px; color: inherit;\n\t\t}\n\t\tform#item-form div.pane-sliders ul.adminformlist li label.hasTip {\n\t\t\tdisplay:inline-block; padding: 4px; margin: 1px 6px 0px 1px; text-align: right;\twidth:160px; font-weight: bold;\n\t\t\tbackground-color: #F6F6F6; border-bottom: 1px solid #E9E9E9; border-right: 1px solid #E9E9E9; color: #666666;\n\t\t}\n\t\t\n\t\t/*div.current fieldset.radio label {\n\t\t\tmin-width:10px!important; padding: 0px 16px 0px 0px!important; margin: 2px 0px 0px 1px!important;\n\t\t}\n\t\tdiv fieldset.adminform fieldset.radio label, div fieldset.panelform fieldset.radio label {\n\t\t\tmin-width:10px!important; padding: 0px 10px 0px 0px!important; margin: 4px 0px 0px 1px!important;\n\t\t}*/\n\t\t\n\t\t/*div fieldset input, div fieldset textarea, div fieldset img, div fieldset button { margin:5px 2px 2px 0px; }*/\n\t\tdiv fieldset select { margin:0px; }\n\t\t\t\t\t\n\t\tdiv.current ul.config-option-list li select { margin-bottom: 0px; font-size:12px;}\n\t\tdiv.current ul.config-option-list li fieldset  { margin: 0; padding: 0; }\n\t\t\n\t\t.tool-tip { }\n\t\t.tip-title { }\n\t\t";
     $document = JFactory::getDocument();
     $document->addStyleDeclaration($css);
     // WORKAROUNDs of for 2 issues in com_config: slow chosen JS and PHP 5.3.9+ 'max_input_vars' limit
     if (FLEXI_J30GE) {
         $jinput = JFactory::getApplication()->input;
     }
     $option = FLEXI_J30GE ? $jinput->get('option', '', 'string') : JRequest::getVar('option');
     $view = FLEXI_J30GE ? $jinput->get('view', '', 'string') : JRequest::getVar('view');
     $controller = FLEXI_J30GE ? $jinput->get('controller', '', 'string') : JRequest::getVar('controller');
     $component = FLEXI_J30GE ? $jinput->get('component', '', 'string') : JRequest::getVar('component');
     // NOTE: this is imported by main Frontend/Backend CSS file
     // so import these only if it is not a flexicontent view
     if ($option != 'com_flexicontent') {
         $document->addStyleSheet(JURI::root(true) . '/components/com_flexicontent/assets/css/flexi_form.css');
         // NOTE: this is imported by main Frontend/Backend CSS file
         $document->addStyleSheet(JURI::root(true) . '/components/com_flexicontent/assets/css/flexi_shared.css');
         // NOTE: this is imported by main Frontend/Backend CSS file
         // Add flexicontent specific TABBing to non-flexicontent views
         $document->addStyleSheet(JURI::root(true) . '/components/com_flexicontent/assets/css/tabber.css');
         $document->addScript(JURI::root(true) . '/components/com_flexicontent/assets/js/tabber-minimized.js');
         $document->addScriptDeclaration(' document.write(\'<style type="text/css">.fctabber{display:none;}<\\/style>\'); ');
     }
     $js = '';
     if ($option == 'com_config' && ($view == 'component' || ($controller = 'component')) && $component == 'com_flexicontent') {
         if (FLEXI_J30GE) {
             // Make sure chosen JS file is loaded before our code
             JHtml::_('formbehavior.chosen', '#_some_iiidddd_');
             // replace chosen function
             $js .= "\n\t\t\t\t\tjQuery.fn.chosen = function(){};\n\t\t\t\t";
         }
         if (FLEXI_J16GE) {
             /*$js .= "
             			function fc_prepare_config_form(){
             				jQuery('#jform_fcdata_serialized').val( '' );
             				jQuery('#jform_fcdata_serialized').val( JSON.stringify(jQuery('#component-form').serializeArray()) );
             				jQuery('#component-form select').attr('disabled', true);
             				jQuery('#component-form textarea').attr('disabled', true);
             				jQuery('#component-form input[type=text], #component-form input[type=checkbox], #component-form input[type=radio]').attr('disabled', true);
             			}
             			jQuery(document).ready(function() {
             				jQuery('#component-form').attr('onsubmit', \"fc_prepare_config_form();\");
             			})
             		";*/
         }
     }
     if ($js) {
         $document->addScriptDeclaration($js);
     }
     if (FLEXI_J16GE) {
         require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.helper.php';
         FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
         flexicontent_html::loadJQuery();
         // Add js function to overload the joomla submitform validation
         JHTML::_('behavior.formvalidation');
         // load default validation JS to make sure it is overriden
         $document->addScript(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js');
         $document->addScript(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js');
         //if (!FLEXI_J30GE)  $document->addStyleSheet(JURI::base(true).'/components/com_flexicontent/assets/css/j25.css');
         if (FLEXI_J30GE) {
             $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css');
         }
     }
 }
Esempio n. 8
0
    /**
     * 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();
        // We do not have item parameters yet, but we need to do some work before creating the item
        // Get the COMPONENT only parameter
        $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;
        }
        // ***********************
        // 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 (CORE & CUSTOM) fields and their VERSIONED values and then
        // **************************************************************
        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;
        }
        // ***************************
        // 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;}');
        }
        // *****************
        // Load JS/CSS files
        // *****************
        // 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);
        // Fields common CSS
        $document->addStyleSheetVersion(JURI::root(true) . '/components/com_flexicontent/assets/css/flexi_form_fields.css', FLEXI_VHASH);
        // Add JS frameworks
        $has_J2S = false;
        foreach ($fields as $field) {
            $has_J2S = $has_J2S || $field->field_type == 'j2store';
            if ($has_J2S) {
                break;
            }
        }
        $_params = new JRegistry();
        $_params->set('load-ui-dialog', 1);
        $_params->set('load-ui-menu', $has_J2S ? 0 : 1);
        $_params->set('load-ui-autocomplete', $has_J2S ? 0 : 1);
        flexicontent_html::loadJQuery($add_jquery = 1, $add_jquery_ui = 1, $add_jquery_ui_css = 1, $add_remote = 1, $_params);
        //flexicontent_html::loadFramework('jQuery');
        flexicontent_html::loadFramework('select2');
        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_VHASH);
        $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VHASH);
        // Add js function for custom code used by FLEXIcontent item form
        $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/itemscreen.js', FLEXI_VHASH);
        // ******************
        // 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, '?') ? '&amp;' : '?') . 'preview=1' . $autologin;
            //$previewlink     = str_replace('&amp;', '&', $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&amp;view=template&amp;type=items&amp;tmpl=component&amp;ismodal=1&amp;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"');
            }
        }
        // *****************************************************************************
        // (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);
        }
        $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();
        $prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable');
        // Get if prettyCheckable was loaded
        // 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'] .= '&nbsp;' . 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'] .= '&nbsp;' . JText::_($option_label) . '</label>';
            }
            $i++;
        }
        // build field for notifying subscribers
        if (!$subscribers) {
            $lists['notify'] = !$isnew ? '<div class="alert alert-info fc-small fc-iblock">' . JText::_('FLEXI_NO_SUBSCRIBERS_EXIST') . '</div>' : '';
        } 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'] = '<div class="alert alert-info fc-small fc-iblock">' . JText::_('FLEXI_SUBSCRIBERS_ALREADY_NOTIFIED') . '</div>';
            } 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'] .= '&nbsp;' . $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;
        }
    }
	/**
	 * Utility function to load each JS Frameworks once
	 *
	 * @param 	string 		$text
	 * @param 	int 		$nb
	 * @return 	string
	 * @since 1.5
	 */
	static function loadFramework( $framework, $mode='' )
	{
		// Detect already loaded framework
		static $_loaded = array();
		if ( isset($_loaded[$framework]) ) return $_loaded[$framework];
		$_loaded[$framework] = false;
		
		// Get frameworks that are configured to be loaded manually in frontend (e.g. via the Joomla template)
		$app = JFactory::getApplication();
		static $load_frameworks = null;
		static $load_jquery = null;
		if ( !isset($load_frameworks[$framework]) ) {
			$flexiparams = JComponentHelper::getParams('com_flexicontent');
			//$load_frameworks = $flexiparams->get('load_frameworks', array('jQuery','image-picker','masonry','select2','inputmask','prettyCheckable','fancybox'));
			//$load_frameworks = FLEXIUtilities::paramToArray($load_frameworks);
			//$load_frameworks = array_flip($load_frameworks);
			//$load_jquery = isset($load_frameworks['jQuery']) || !$app->isSite();
			if ( $load_jquery===null ) $load_jquery = $flexiparams->get('loadfw_jquery', 1)==1  ||  !$app->isSite();
			$load_framework = $flexiparams->get( 'loadfw_'.strtolower(str_replace('-','_',$framework)), 1 );
			$load_frameworks[$framework] = $load_framework==1  ||  ($load_framework==2 && !$app->isSite());
		}
		
		// Set loaded flag
		$_loaded[$framework] = $load_frameworks[$framework];
		// Do not progress further if it is disabled
		if ( !$load_frameworks[$framework] ) return false;
		
		// Load Framework
		$document = JFactory::getDocument();
		$js = "";
		$css = "";
		switch ( $framework )
		{
			case 'jQuery':
				if ($load_jquery) flexicontent_html::loadJQuery();
				break;
			
			case 'mCSB':
				if ($load_jquery) flexicontent_html::loadJQuery();
				
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/mCSB';
				$document->addScript($framework_path.'/jquery.mCustomScrollbar.min.js');
				$document->addStyleSheet($framework_path.'/jquery.mCustomScrollbar.css');
				$js .= "
					jQuery(document).ready(function(){
					    jQuery('.fc_add_scroller').mCustomScrollbar({
					    	theme:'dark-thick',
					    	advanced:{updateOnContentResize: true}
					    });
					    jQuery('.fc_add_scroller_horizontal').mCustomScrollbar({
					    	theme:'dark-thick',
					    	horizontalScroll:true,
					    	advanced:{updateOnContentResize: true}
					    });
					});
				";
				break;
			
			case 'image-picker':
				if ($load_jquery) flexicontent_html::loadJQuery();
				
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/image-picker';
				$document->addScript($framework_path.'/image-picker.min.js');
				$document->addStyleSheet($framework_path.'/image-picker.css');
				break;
			
			case 'masonry':
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/masonry';
				$document->addScript($framework_path.'/masonry.pkgd.min.js');
				
				break;
			
			case 'select2':
				if ($load_jquery) flexicontent_html::loadJQuery();
				
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/select2';
				$framework_folder = JPATH_SITE .DS.'components'.DS.'com_flexicontent'.DS.'librairies'.DS.'select2';
				$document->addScript($framework_path.'/select2.min.js');
				$document->addStyleSheet($framework_path.'/select2.css');
				
				$user_lang = flexicontent_html::getUserCurrentLang();
				if ( $user_lang && $user_lang!='en' )
				{
					// Try language shortcode
					$framework_folder.DS.'select2_locale_'.$user_lang.'.js';
					if ( file_exists($framework_folder.DS.'select2_locale_'.$user_lang.'.js') ) {
						$document->addScript($framework_path.'/select2_locale_'.$user_lang.'.js');
					}
					// Try coutry language code
					else {
						$languages = FLEXIUtilities::getLanguages($hash='shortcode');
						$lang_code = isset($languages->$user_lang->code) ? $languages->$user_lang->code : false;
						if ( $lang_code && file_exists($framework_folder.'/select2_locale_'.$lang_code.'.js') ) {
							$document->addScript($framework_path.'/select2_locale_'.$lang_code.'.js');
						}
					}
				}
				
				$js .= "
					jQuery(document).ready(function() {
						
						"/* Attach select2 to specific to select elements having specific CSS class, show selected values as both: unselectable and disabled */."
						jQuery('select.use_select2_lib').select2({
							/*hideSelectionFromResult: function(selectedObject) { selectedObject.removeClass('select2-result-selectable').addClass('select2-result-unselectable').addClass('select2-disabled'); return false; }*/
						});
						
						jQuery('div.use_select2_lib').each(function() {
							var el_container = jQuery(this);
							var el_select = el_container.next('select');
							
							"/* MULTI-SELECT2: Initialize internal labels, placing the label so that it overlaps the text filter box */."
							var fc_label_text = el_select.attr('data-fc_label_text');
							if (!fc_label_text) fc_label_text = el_select.attr('fc_label_text');
							if (fc_label_text) {
								var _label = (fc_label_text.length >= 30) ? fc_label_text.substring(0, 28) + '...' : fc_label_text;
								
								jQuery('<span/>', {
									'class': 'fc_has_inner_label fc_has_inner_label_select2',
									'text': _label
								}).prependTo(el_container.find('.select2-search-field'));
							}
							
							"/* MULTI-SELECT2: Initialize internal prompts, placing the prompt so that it overlaps the text filter box */."
							var fc_prompt_text = el_select.attr('data-fc_prompt_text');
							if (!fc_prompt_text) fc_prompt_text = el_select.attr('fc_prompt_text');
							if (fc_prompt_text) {
								var _prompt = (fc_prompt_text.length >= 30) ? fc_prompt_text.substring(0, 28) + '...' : fc_prompt_text;
								
								jQuery('<span/>', {
									'class': 'fc_has_inner_prompt fc_has_inner_prompt_select2',
									'text': _prompt
								}).prependTo(el_container.find('.select2-search-field')).hide();
							}
							
							"/* SINGLE-SELECT2: Highlight selects with an active value */."
							if ( ! el_select.attr('multiple') ) {
								var el = el_container.find('.select2-choice');
								var val = el_select.val();
								if (val === null) {
									el.addClass('fc_highlight_disabled');
								} else if (val.length) {
									el.addClass('fc_highlight');
								} else {
									el.removeClass('fc_highlight');
								}
							}
						});
						
						"/* MULTI-SELECT2: */."
						jQuery('select.use_select2_lib').on('select2-open', function() {
							"/* Add events to handle focusing the text filter box (hide inner label) */."
							var el_container = jQuery(this).parent();
							var el = jQuery(this).parent().find('.select2-input');
							var el_label = el.prevAll('.fc_has_inner_label');
							if (el_label) el_label.hide();
							var el_prompt = el.prevAll('.fc_has_inner_prompt');
							if (el_prompt) el_prompt.show();
							
							"/* Allow listing already selected options WHEN having class 'select2_list_selected' */."
							if (jQuery(this).hasClass('select2_list_selected')) {
								var els = jQuery('#select2-drop').find('.select2-selected');
								els.addClass('select2-selected-highlight').addClass('select2-disabled').removeClass('select2-selected').removeClass('select2-result-selectable');
							}
						}).on('select2-close', function() {
							"/* Add events to handle bluring the text filter box (show inner label) */."
							var el_container = jQuery(this).parent();
							var el = jQuery(this).parent().find('.select2-input');
							var el_label = el.prevAll('.fc_has_inner_label');
							if (el_label) el_label.show();
							var el_prompt = el.prevAll('.fc_has_inner_prompt');
							if (el_prompt) el_prompt.hide();
							
							"/* Restore already selected options state */."
							if (jQuery(this).hasClass('select2_list_selected')) {
								var els = jQuery('#select2-drop').find('.select2-selected-highlight');
								els.removeClass('select2-selected-highlight').removeClass('select2-disabled').addClass('select2-result-selectable');
							}
						}).on
						
						"/* SINGLE-SELECT2: Add events to handle highlighting selected value */."
						('change', function() {
							var el_select = jQuery(this);
							if ( ! el_select.attr('multiple') ) {
								var el = jQuery(this).prev('div').find('.select2-choice');
								var val = el_select.val();
								if (val.length) {
									el.addClass('fc_highlight');
								} else {
									el.removeClass('fc_highlight');
								}
							}
						});
						
						"/* SINGLE-SELECT2: Add events to handle highlighting selected value */."
						jQuery('div.use_select2_lib.select2-container-multi input').on('keydown', function() {
							var el = jQuery(this);
							setTimeout(function() {
								if (el.val().length) {
									var el_prompt = el.prevAll('.fc_has_inner_prompt');
									if (el_prompt) el_prompt.hide();
								} else {
									var el_prompt = el.prevAll('.fc_has_inner_prompt');
									if (el_prompt) el_prompt.show();
								}
							}, 0);
						});
						
						"/* SELECT2: scrollbar wrap problem */."
						jQuery('select.use_select2_lib').on('loaded open', function() {
							var ul = jQuery('#select2-drop ul.select2-results');
							var needsScroll= ul.prop('scrollHeight') > ul.prop('clientHeight');
							if (needsScroll) ul.css('overflow-y', 'scroll');
							else  ul.css('overflow-y', 'auto');
						});
						
					});
				";
				break;
			
			case 'inputmask':
				if ($load_jquery) flexicontent_html::loadJQuery();
				
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/inputmask';
				$document->addScript($framework_path.'/jquery.inputmask.bundle.min.js');
				
				// Extra inputmask declarations definitions, e.g. ...
				/*$js .= "
					jQuery.extend(jQuery.inputmask.defaults.definitions, {
					    'f': {
					        \"validator\": \"[0-9\(\)\.\+/ ]\",
					        \"cardinality\": 1,
					        'prevalidator': null
					    }
					});
				";*/
				
				// Attach inputmask to all input fields that have appropriate tag parameters
				$js .= "
					jQuery(document).ready(function(){
					    jQuery(\":input\").inputmask();
					});
				";
				break;
			
			case 'prettyCheckable':
				if ($load_jquery) flexicontent_html::loadJQuery();
				
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/prettyCheckable';
				$document->addScript($framework_path.'/prettyCheckable.js');
				$document->addStyleSheet($framework_path.'/prettyCheckable.css');
				$js .= "
					jQuery(document).ready(function(){
						jQuery('input.use_prettycheckable').prettyCheckable();
						jQuery('div.fcradiocheckimage').each(
							function() {
								jQuery(this).find('label').append(jQuery(this).next('label').html());
								jQuery(this).next('label').remove();
							});
					});
				";
				break;
			
			case 'fancybox':
				if ($load_jquery) flexicontent_html::loadJQuery();
				
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/fancybox';
				
				// Add mousewheel plugin (this is optional)
				$document->addScript($framework_path.'/lib/jquery.mousewheel-3.0.6.pack.js');
				
				// Add fancyBox CSS / JS
				$document->addStyleSheet($framework_path.'/source/jquery.fancybox.css?v=2.1.1');
				$document->addScript($framework_path.'/source/jquery.fancybox.pack.js?v=2.1.1');
				
				// Optionally add helpers - button, thumbnail and/or media
				$document->addStyleSheet($framework_path.'/source/helpers/jquery.fancybox-buttons.css?v=1.0.4');
				$document->addScript($framework_path.'/source/helpers/jquery.fancybox-buttons.js?v=1.0.4');
				$document->addScript($framework_path.'/source/helpers/jquery.fancybox-media.js?v=1.0.4');
				$document->addStyleSheet($framework_path.'/source/helpers/jquery.fancybox-thumbs.css?v=1.0.7');
				$document->addScript($framework_path.'/source/helpers/jquery.fancybox-thumbs.js?v=1.0.7');
				
				// Attach fancybox to all elements having a specific CSS class
				$js .= "
					jQuery(document).ready(function(){
						jQuery('.fancybox').fancybox();
					});
				";
				break;
			
			case 'galleriffic':
				if ($load_jquery) flexicontent_html::loadJQuery();
				
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/galleriffic';
				$document->addStyleSheet($framework_path.'/css/basic.css');
				$document->addStyleSheet($framework_path.'/css/galleriffic-3.css');
				$document->addScript($framework_path.'/js/jquery.galleriffic.js');
				$document->addScript($framework_path.'/js/jquery.opacityrollover.js');
				
				//$view_width = 500;
				$js = "
				//document.write('<style>.noscript { display: none; }</style>');
				jQuery(document).ready(function() {
					// We only want these styles applied when javascript is enabled
					jQuery('div.navigation').css({'width' : '150px', 'float' : 'left'});
					jQuery('div.content').css({'display' : 'inline-block', 'float' : 'none'});
	
					// Initially set opacity on thumbs and add
					// additional styling for hover effect on thumbs
					var onMouseOutOpacity = 0.67;
					jQuery('#gf_thumbs ul.thumbs li').opacityrollover({
						mouseOutOpacity:   onMouseOutOpacity,
						mouseOverOpacity:  1.0,
						fadeSpeed:         'fast',
						exemptionSelector: '.selected'
					});
					
					// Initialize Advanced Galleriffic Gallery
					var gallery = jQuery('#gf_thumbs').galleriffic({
						delay:                     2500,
						numThumbs:                 4,
						preloadAhead:              10,
						enableTopPager:            true,
						enableBottomPager:         true,
						maxPagesToShow:            20,
						imageContainerSel:         '#gf_slideshow',
						controlsContainerSel:      '#gf_controls',
						captionContainerSel:       '#gf_caption',
						loadingContainerSel:       '#gf_loading',
						renderSSControls:          true,
						renderNavControls:         true,
						playLinkText:              'Play Slideshow',
						pauseLinkText:             'Pause Slideshow',
						prevLinkText:              '&lsaquo; Previous Photo',
						nextLinkText:              'Next Photo &rsaquo;',
						nextPageLinkText:          'Next &rsaquo;',
						prevPageLinkText:          '&lsaquo; Prev',
						enableHistory:             false,
						autoStart:                 false,
						syncTransitions:           true,
						defaultTransitionDuration: 900,
						onSlideChange:             function(prevIndex, nextIndex) {
							// 'this' refers to the gallery, which is an extension of jQuery('#gf_thumbs')
							this.find('ul.thumbs').children()
								.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
								.eq(nextIndex).fadeTo('fast', 1.0);
						},
						onPageTransitionOut:       function(callback) {
							this.fadeTo('fast', 0.0, callback);
						},
						onPageTransitionIn:        function() {
							this.fadeTo('fast', 1.0);
						}
					});
				});
				";
				break;
			
			case 'elastislide':
				if ($load_jquery) flexicontent_html::loadJQuery();
				
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/elastislide';
				$document->addStyleSheet($framework_path.'/css/demo.css');
				$document->addStyleSheet($framework_path.'/css/style.css');
				$document->addStyleSheet($framework_path.'/css/elastislide.css');
				
				$document->addScript($framework_path.'/js/jquery.tmpl.min.js');
				$document->addScript($framework_path.'/js/jquery.easing.1.3.js');
				$document->addScript($framework_path.'/js/jquery.elastislide.js');
				//$document->addScript($framework_path.'/js/gallery.js'); // replace with field specific: gallery_tmpl.js
				break;
			
			case 'photoswipe':
				if ($load_jquery) flexicontent_html::loadJQuery();
				
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/photoswipe';
				
				//$document->addStyleSheet($framework_path.'/lib/jquery.mobile/jquery.mobile.css');
				$document->addStyleSheet($framework_path.'/photoswipe.css');
				
				//$document->addScript($framework_path.'/lib/jquery.mobile/jquery.mobile.js');
				$document->addScript($framework_path.'/lib/simple-inheritance.min.js');
				//$document->addScript($framework_path.'/lib/jquery.animate-enhanced.min.js');
				$document->addScript($framework_path.'/code.photoswipe.min.js');
				
				$js = "
				jQuery(document).ready(function() {
					var myPhotoSwipe = jQuery('.photoswipe_fccontainer a').photoSwipe(); 
				});
				";
				break;
			
			case 'fcxSlide':
				if ($load_jquery) flexicontent_html::loadJQuery();
				
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/fcxSlide';
				$document->addScript($framework_path.'/class.fcxSlide.js');
				//$document->addScript($framework_path.'/class.fcxSlide.packed.js');
				break;
			
			case 'imagesLoaded':
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/imagesLoaded';
				$document->addScript($framework_path.'/imagesloaded.pkgd.min.js');
				break;
			
			case 'noobSlide':
				// Make sure mootools are loaded
				FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
				
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/noobSlide';
				//$document->addScript($framework_path.'/_class.noobSlide.js');
				$document->addScript($framework_path.'/_class.noobSlide.packed.js');
				break;
			
			case 'zTree':
				if ($load_jquery) flexicontent_html::loadJQuery();
				
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/zTree';
				$document->addStyleSheet($framework_path.'/css/flexi_ztree.css');
				$document->addStyleSheet($framework_path.'/css/zTreeStyle/zTreeStyle.css');
				$document->addScript($framework_path.'/js/jquery.ztree.all-3.5.min.js');
				//$document->addScript($framework_path.'/js/jquery.ztree.core-3.5.js');
				//$document->addScript($framework_path.'/js/jquery.ztree.excheck-3.5.js');
				//$document->addScript($framework_path.'/js/jquery.ztree.exedit-3.5.js');
				break;
			
			
			case 'plupload':
				if ($load_jquery) flexicontent_html::loadJQuery();
				
				$framework_path = JURI::root(true).'/components/com_flexicontent/librairies/plupload';
				$document->addScript($framework_path.'/js/plupload.full.min.js');
				
				if ($mode=='ui') {
					$document->addStyleSheet($framework_path.'/js/jquery.ui.plupload/css/jquery.ui.plupload.css');
					$document->addScript($framework_path.'/js/jquery.ui.plupload/jquery.ui.plupload.min.js');
					$document->addScript($framework_path.'/js/themeswitcher.js');
				} else {
					$document->addStyleSheet($framework_path.'/js/jquery.plupload.queue/css/jquery.plupload.queue.css');
					$document->addScript($framework_path.'/js/jquery.plupload.queue/jquery.plupload.queue.js');
				}
				// For debugging
				//$document->addScript($framework_path.'/js/moxie.min.js');
				//$document->addScript($framework_path.'/js/plupload.dev.js');
				break;
			
			case 'flexi_tmpl_common':
				if ($load_jquery) flexicontent_html::loadJQuery();
				flexicontent_html::loadFramework('select2');  // make sure select2 is loaded
				
				$js = "
					var _FC_GET = ".json_encode($_GET).";
				";
				//var _FC_POST = ".json_encode($_POST).";
				//var _FC_REQUEST = ".json_encode($_REQUEST).";
				$document->addScript( JURI::root(true).'/components/com_flexicontent/assets/js/tmpl-common.js' );
				FLEXI_J16GE ? JText::script("FLEXI_APPLYING_FILTERING", true) : fcjsJText::script("FLEXI_APPLYING_FILTERING", true);
				FLEXI_J16GE ? JText::script("FLEXI_TYPE_TO_LIST", true) : fcjsJText::script("FLEXI_TYPE_TO_LIST", true);
				FLEXI_J16GE ? JText::script("FLEXI_TYPE_TO_FILTER", true) : fcjsJText::script("FLEXI_TYPE_TO_FILTER", true);
				break;
			
			case 'flexi-lib':
				if ($load_jquery) flexicontent_html::loadJQuery();
				
				$document->addScript( JURI::root(true).'/components/com_flexicontent/assets/js/flexi-lib.js' );
				FLEXI_J16GE ? JText::script("FLEXI_NOT_AN_IMAGE_FILE", true) : fcjsJText::script("FLEXI_NOT_AN_IMAGE_FILE", true);
				break;
			
			default:
				JFactory::getApplication()->enqueueMessage(__FUNCTION__.' Cannot load unknown Framework: '.$framework, 'error');
				break;
		}
		
		// Add custom JS & CSS code
		if ($js)  $document->addScriptDeclaration($js);
		if ($css) $document->addStyleDeclaration($css);
		return $_loaded[$framework];
	}
Esempio n. 10
0
 /**
  * Creates the Filemanagerview
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     flexicontent_html::loadJQuery();
     flexicontent_html::loadFramework('select2');
     JHTML::_('behavior.tooltip');
     // Load the form validation behavior
     JHTML::_('behavior.formvalidation');
     //initialise variables
     $app = JFactory::getApplication();
     $option = JRequest::getVar('option');
     $document = JFactory::getDocument();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $params = JComponentHelper::getParams('com_flexicontent');
     //$authorparams = flexicontent_db::getUserConfig($user->id);
     $langs = FLEXIUtilities::getLanguages('code');
     //get vars
     $filter_order = $app->getUserStateFromRequest($option . '.filemanager.filter_order', 'filter_order', 'f.filename', 'cmd');
     $filter_order_Dir = $app->getUserStateFromRequest($option . '.filemanager.filter_order_Dir', 'filter_order_Dir', '', 'word');
     $filter = $app->getUserStateFromRequest($option . '.filemanager.filter', 'filter', 1, 'int');
     $filter_lang = $app->getUserStateFromRequest($option . '.filemanager.filter_lang', 'filter_lang', '', 'string');
     $filter_uploader = $app->getUserStateFromRequest($option . '.filemanager.filter_uploader', 'filter_uploader', 0, 'int');
     $filter_url = $app->getUserStateFromRequest($option . '.filemanager.filter_url', 'filter_url', '', 'word');
     $filter_secure = $app->getUserStateFromRequest($option . '.filemanager.filter_secure', 'filter_secure', '', 'word');
     $filter_ext = $app->getUserStateFromRequest($option . '.filemanager.filter_ext', 'filter_ext', '', 'alnum');
     $search = $app->getUserStateFromRequest($option . '.filemanager.search', 'search', '', 'string');
     $filter_item = $app->getUserStateFromRequest($option . '.filemanager.item_id', 'item_id', 0, 'int');
     $folder_mode = 0;
     $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 toolbar
     // **************************
     FLEXISubmenu('CanFiles');
     // Create document/toolbar titles
     $doc_title = JText::_('FLEXI_FILEMANAGER');
     $site_title = $document->getTitle();
     JToolBarHelper::title($doc_title, 'files');
     $document->setTitle($doc_title . ' - ' . $site_title);
     // Create the toolbar
     if (FLEXI_J16GE) {
         JToolBarHelper::deleteList('Are you sure?', 'filemanager.remove');
     } else {
         JToolBarHelper::deleteList();
     }
     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();
     if (!$folder_mode) {
         $rows = $this->get('Data');
     } else {
         // TODO MORE ...
     }
     $pagination = $this->get('Pagination');
     //$users = $this->get('Users');
     // Get item using at least one file (-of- the currently listed files)
     /*$items_single	= $model->getItemsSingleprop( array('file','minigallery') );
     		$items_multi	= $model->getItemsMultiprop ( $field_props=array('image'=>'originalname'), $value_props=array('image'=>'filename') );
     		$items = array();
     		foreach ($items_single as $item_id => $_item) $items[$item_id] = $_item;
     		foreach ($items_multi  as $item_id => $_item) $items[$item_id] = $_item;
     		ksort($items);*/
     $assigned_fields_labels = array('image' => 'image/gallery', 'file' => 'file', 'minigallery' => 'minigallery');
     $assigned_fields_icons = array('image' => 'picture_link', 'file' => 'page_link', 'minigallery' => 'film_link');
     /*****************
      ** BUILD LISTS **
      *****************/
     $lists = array();
     // ** FILE UPLOAD FORM **
     // Build languages list
     //$allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed',null);
     //$allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs);
     $display_file_lang_as = $params->get('display_file_lang_as', 3);
     $allowed_langs = null;
     if (FLEXI_FISH || FLEXI_J16GE) {
         $lists['file-lang'] = flexicontent_html::buildlanguageslist('file-lang', '', '*', $display_file_lang_as, $allowed_langs, $published_only = false);
     } else {
         $lists['file-lang'] = flexicontent_html::getSiteDefaultLang() . '<input type="hidden" name="file-lang" value="' . flexicontent_html::getSiteDefaultLang() . '" />';
     }
     /*************
      ** FILTERS **
      *************/
     // language filter
     $lists['language'] = flexicontent_html::buildlanguageslist('filter_lang', 'class="use_select2_lib" onchange="submitform();" size="1" ', $filter_lang, 2);
     // search
     $lists['search'] = $search;
     //search filter
     $filters = array();
     $filters[] = JHTML::_('select.option', '1', JText::_('FLEXI_FILENAME'));
     $filters[] = JHTML::_('select.option', '2', JText::_('FLEXI_FILE_TITLE'));
     $lists['filter'] = JHTML::_('select.genericlist', $filters, 'filter', 'size="1" class="use_select2_lib"', 'value', 'text', $filter);
     //build url/file filterlist
     $url = array();
     $url[] = JHTML::_('select.option', '', '- ' . JText::_('FLEXI_ALL_FILES') . ' -');
     $url[] = JHTML::_('select.option', 'F', JText::_('FLEXI_FILE'));
     $url[] = JHTML::_('select.option', 'U', JText::_('FLEXI_URL'));
     $lists['url'] = JHTML::_('select.genericlist', $url, 'filter_url', 'class="use_select2_lib" size="1" onchange="submitform( );"', 'value', 'text', $filter_url);
     //item lists
     /*$items_list = array();
     		$items_list[] = JHTML::_('select.option', '', '- '. JText::_( 'FLEXI_FILTER_BY_ITEM' ) .' -' );
     		foreach($items as $item) {
     			$items_list[] = JHTML::_('select.option', $item->id, JText::_( $item->title ) . ' (#' . $item->id . ')' );
     		}
     		$lists['item_id'] = JHTML::_('select.genericlist', $items_list, 'item_id', 'size="1" class="use_select2_lib" onchange="submitform( );"', 'value', 'text', $filter_item );*/
     $lists['item_id'] = '<input type="text" name="item_id" size="1" class="inputbox" onchange="submitform( );" value="' . $filter_item . '" />';
     //build secure/media filterlist
     $secure = array();
     $secure[] = JHTML::_('select.option', '', '- ' . JText::_('FLEXI_ALL_DIRECTORIES') . ' -');
     $secure[] = JHTML::_('select.option', 'S', JText::_('FLEXI_SECURE_DIR'));
     $secure[] = JHTML::_('select.option', 'M', JText::_('FLEXI_MEDIA_DIR'));
     $lists['secure'] = JHTML::_('select.genericlist', $secure, 'filter_secure', 'class="use_select2_lib" size="1" onchange="submitform( );"', 'value', 'text', $filter_secure);
     //build ext filterlist
     $lists['ext'] = flexicontent_html::buildfilesextlist('filter_ext', 'class="use_select2_lib" size="1" onchange="submitform( );"', $filter_ext);
     //build uploader filterlist
     $lists['uploader'] = flexicontent_html::builduploaderlist('filter_uploader', 'class="use_select2_lib" size="1" onchange="submitform( );"', $filter_uploader);
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     // uploadstuff
     if ($params->get('enable_flash', 1) && !FLEXI_J30GE) {
         JHTML::_('behavior.uploader', 'file-upload', array('onAllComplete' => 'function(){ window.location.reload(); }'));
     }
     jimport('joomla.client.helper');
     $ftp = !JClientHelper::hasCredentials('ftp');
     //assign data to template
     $this->assignRef('params', $params);
     $this->assign('require_ftp', $ftp);
     //Load pane behavior
     if (!FLEXI_J16GE) {
         jimport('joomla.html.pane');
         $pane = JPane::getInstance('Tabs');
         $this->assignRef('pane', $pane);
     }
     $this->assignRef('lists', $lists);
     $this->assignRef('rows', $rows);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('CanFiles', $perms->CanFiles);
     $this->assignRef('CanUpload', $perms->CanUpload);
     $this->assignRef('CanViewAllFiles', $perms->CanViewAllFiles);
     $this->assignRef('assigned_fields_labels', $assigned_fields_labels);
     $this->assignRef('assigned_fields_icons', $assigned_fields_icons);
     $this->assignRef('langs', $langs);
     parent::display($tpl);
 }
Esempio n. 11
0
 function indexer($tpl)
 {
     $document = JFactory::getDocument();
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadJQuery();
     parent::display($tpl);
 }
Esempio n. 12
0
 /**
  * Creates the Filemanager view
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     //initialise variables
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $option = JRequest::getCmd('option');
     $view = JRequest::getVar('view');
     $layout = JRequest::getVar('layout', 'default');
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $cparams = JComponentHelper::getParams('com_flexicontent');
     //$authorparams = flexicontent_db::getUserConfig($user->id);
     $langs = FLEXIUtilities::getLanguages('code');
     flexicontent_html::loadJQuery();
     flexicontent_html::loadFramework('select2');
     JHTML::_('behavior.tooltip');
     // Load the form validation behavior
     JHTML::_('behavior.formvalidation');
     // Get filters
     $count_filters = 0;
     $_view = $view;
     $filter_order = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_order', 'filter_order', 'f.filename', 'cmd');
     $filter_order_Dir = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_order_Dir', 'filter_order_Dir', '', 'word');
     $filter_lang = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_lang', 'filter_lang', '', 'string');
     $filter_url = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_url', 'filter_url', '', 'word');
     $filter_secure = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_secure', 'filter_secure', '', 'word');
     $filter_ext = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_ext', 'filter_ext', '', 'alnum');
     $filter_uploader = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_uploader', 'filter_uploader', '', 'int');
     $filter_item = $app->getUserStateFromRequest($option . '.' . $_view . '.item_id', 'item_id', '', 'int');
     if ($layout != 'image') {
         if ($filter_lang) {
             $count_filters++;
         }
         if ($filter_url) {
             $count_filters++;
         }
         if ($filter_secure) {
             $count_filters++;
         }
     }
     if ($filter_ext) {
         $count_filters++;
     }
     if ($filter_uploader) {
         $count_filters++;
     }
     if ($filter_item) {
         $count_filters++;
     }
     $scope = $app->getUserStateFromRequest($option . '.' . $_view . '.scope', 'scope', 1, 'int');
     $search = $app->getUserStateFromRequest($option . '.' . $_view . '.search', 'search', '', 'string');
     $search = $db->escape(trim(JString::strtolower($search)));
     $filter_uploader = $filter_uploader ? $filter_uploader : '';
     $filter_item = $filter_item ? $filter_item : '';
     // **************************
     // Add css and js to document
     // **************************
     if ($app->isSite()) {
         $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontent.css');
     } else {
         $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('CanFiles');
     // Create document/toolbar titles
     $doc_title = JText::_('FLEXI_FILEMANAGER');
     $site_title = $document->getTitle();
     JToolBarHelper::title($doc_title, 'files');
     $document->setTitle($doc_title . ' - ' . $site_title);
     // Create the toolbar
     JToolBarHelper::deleteList('Are you sure?', 'filemanager.remove');
     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 = "jQuery(document).ready(function(){";
     $toolbar = JToolBar::getInstance('toolbar');
     $btn_task = '';
     $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent&view=filemanager&layout=indexer&tmpl=component&indexer=fileman_default';
     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-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: 500, y: 240}, onClose: function() {}}');\n\t\t\t";
         JToolBarHelper::custom($btn_task, 'basicindex.png', 'basicindex_f2.png', 'Index file statistics', false);
         JHtml::_('behavior.modal', '#toolbar-basicindex a.toolbar, #toolbar-basicindex button');
     } else {
         $toolbar->appendButton('Popup', 'basicindex', 'Index file statistics', str_replace('&', '&amp;', $popup_load_url), 500, 240);
     }
     $js .= "});";
     $document->addScriptDeclaration($js);
     // ***********************
     // Get data from the model
     // ***********************
     $folder_mode = 0;
     $model = $this->getModel();
     if (!$folder_mode) {
         $rows = $this->get('Data');
     } else {
         // TODO MORE ...
     }
     $pagination = $this->get('Pagination');
     //$users = $this->get('Users');
     // Get item using at least one file (-of- the currently listed files)
     /*$items_single	= $model->getItemsSingleprop( array('file','minigallery') );
     		$items_multi	= $model->getItemsMultiprop ( $field_props=array('image'=>'originalname'), $value_props=array('image'=>'filename') );
     		$items = array();
     		foreach ($items_single as $item_id => $_item) $items[$item_id] = $_item;
     		foreach ($items_multi  as $item_id => $_item) $items[$item_id] = $_item;
     		ksort($items);*/
     $assigned_fields_labels = array('image' => 'image/gallery', 'file' => 'file', 'minigallery' => 'minigallery');
     $assigned_fields_icons = array('image' => 'picture_link', 'file' => 'page_link', 'minigallery' => 'film_link');
     /*****************
      ** BUILD LISTS **
      *****************/
     $lists = array();
     // ** FILE UPLOAD FORM **
     // Build languages list
     //$allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed',null);
     //$allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs);
     $display_file_lang_as = $cparams->get('display_file_lang_as', 3);
     $allowed_langs = null;
     $lists['file-lang'] = flexicontent_html::buildlanguageslist('file-lang', '', '*', $display_file_lang_as, $allowed_langs, $published_only = false);
     /*************
      ** FILTERS **
      *************/
     // language filter
     $lists['language'] = ($filter_lang || 1 ? '<label class="label">' . JText::_('FLEXI_LANGUAGE') . '</label>' : '') . flexicontent_html::buildlanguageslist('filter_lang', 'class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" size="1" ', $filter_lang, '-');
     // search
     $lists['search'] = $search;
     //search filter
     $filters = array();
     $filters[] = JHTML::_('select.option', '1', JText::_('FLEXI_FILENAME'));
     $filters[] = JHTML::_('select.option', '2', JText::_('FLEXI_FILE_DISPLAY_TITLE'));
     $lists['scope'] = JHTML::_('select.genericlist', $filters, 'scope', 'size="1" class="use_select2_lib fc_skip_highlight" title="' . JText::_('FLEXI_SEARCH_TEXT_INSIDE') . '"', 'value', 'text', $scope);
     //build url/file filterlist
     $url = array();
     $url[] = JHTML::_('select.option', '', '-');
     $url[] = JHTML::_('select.option', 'F', JText::_('FLEXI_FILE'));
     $url[] = JHTML::_('select.option', 'U', JText::_('FLEXI_URL'));
     $lists['url'] = ($filter_url || 1 ? '<label class="label">' . JText::_('FLEXI_ALL_FILES') . '</label>' : '') . JHTML::_('select.genericlist', $url, 'filter_url', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_url);
     //item lists
     /*$items_list = array();
     		$items_list[] = JHTML::_('select.option', '', '- '. JText::_( 'FLEXI_FILTER_BY_ITEM' ) .' -' );
     		foreach($items as $item) {
     			$items_list[] = JHTML::_('select.option', $item->id, JText::_( $item->title ) . ' (#' . $item->id . ')' );
     		}
     		$lists['item_id'] = JHTML::_('select.genericlist', $items_list, 'item_id', 'size="1" class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_item );*/
     $lists['item_id'] = '<input type="text" name="item_id" size="1" class="inputbox" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" value="' . $filter_item . '" />';
     //build secure/media filterlist
     $secure = array();
     $secure[] = JHTML::_('select.option', '', '-');
     $secure[] = JHTML::_('select.option', 'S', JText::_('FLEXI_SECURE_DIR'));
     $secure[] = JHTML::_('select.option', 'M', JText::_('FLEXI_MEDIA_DIR'));
     $lists['secure'] = ($filter_secure || 1 ? '<label class="label">' . JText::_('FLEXI_ALL_DIRECTORIES') . '</label>' : '') . JHTML::_('select.genericlist', $secure, 'filter_secure', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_secure);
     //build ext filterlist
     $lists['ext'] = ($filter_ext || 1 ? '<label class="label">' . JText::_('FLEXI_ALL_EXT') . '</label>' : '') . flexicontent_html::buildfilesextlist('filter_ext', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', $filter_ext, '-');
     //build uploader filterlist
     $lists['uploader'] = ($filter_uploader || 1 ? '<label class="label">' . JText::_('FLEXI_ALL_UPLOADERS') . '</label>' : '') . flexicontent_html::builduploaderlist('filter_uploader', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', $filter_uploader, '-');
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     // uploadstuff
     if ($cparams->get('enable_flash', 1) && !FLEXI_J30GE) {
         JHTML::_('behavior.uploader', 'file-upload', array('onAllComplete' => 'function(){ window.location.reload(); }'));
     }
     jimport('joomla.client.helper');
     $ftp = !JClientHelper::hasCredentials('ftp');
     //assign data to template
     $this->assignRef('count_filters', $count_filters);
     $this->assignRef('params', $cparams);
     $this->assign('require_ftp', $ftp);
     $this->assignRef('lists', $lists);
     $this->assignRef('rows', $rows);
     $this->assignRef('folder_mode', $folder_mode);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('CanFiles', $perms->CanFiles);
     $this->assignRef('CanUpload', $perms->CanUpload);
     $this->assignRef('CanViewAllFiles', $perms->CanViewAllFiles);
     $this->assignRef('assigned_fields_labels', $assigned_fields_labels);
     $this->assignRef('assigned_fields_icons', $assigned_fields_icons);
     $this->assignRef('langs', $langs);
     $this->assignRef('option', $option);
     $this->assignRef('view', $view);
     $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null;
     parent::display($tpl);
 }
Esempio n. 13
0
 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('&', '&amp;', $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('&', '&amp;', $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);
     }
 }
Esempio n. 14
0
    /**
     * Creates the Filemanagerview
     *
     * @since 1.0
     */
    function display($tpl = null)
    {
        // Check for request forgeries
        JRequest::checkToken('request') or jexit('Invalid Token');
        flexicontent_html::loadJQuery();
        flexicontent_html::loadFramework('select2');
        JHTML::_('behavior.tooltip');
        // Load the form validation behavior
        JHTML::_('behavior.formvalidation');
        //initialise variables
        $app = JFactory::getApplication();
        $option = JRequest::getVar('option');
        $document = JFactory::getDocument();
        $db = JFactory::getDBO();
        $user = JFactory::getUser();
        $params = JComponentHelper::getParams('com_flexicontent');
        //$authorparams = flexicontent_db::getUserConfig($user->id);
        $langs = FLEXIUtilities::getLanguages('code');
        $fieldid = JRequest::getVar('field', null, 'request', 'int');
        $client = $app->isAdmin() ? '../' : '';
        //get vars
        $filter_order = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.filter_order', 'filter_order', 'f.filename', 'cmd');
        $filter_order_Dir = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.filter_order_Dir', 'filter_order_Dir', '', 'word');
        $filter = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.filter', 'filter', 1, 'int');
        $filter_lang = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.filter_lang', 'filter_lang', '', 'string');
        $filter_uploader = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.filter_uploader', 'filter_uploader', 0, 'int');
        $filter_url = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.filter_url', 'filter_url', '', 'word');
        $filter_secure = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.filter_secure', 'filter_secure', '', 'word');
        $filter_ext = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.filter_ext', 'filter_ext', '', 'alnum');
        $search = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.search', 'search', '', 'string');
        $filter_item = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.item_id', 'item_id', '', 'int');
        $u_item_id = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.u_item_id', 'u_item_id', 0, 'string');
        $autoselect = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.autoselect', 'autoselect', 0, 'int');
        $autoassign = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.autoassign', 'autoassign', 0, 'int');
        $folder_mode = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.folder_mode', 'folder_mode', 0, 'int');
        $folder_param = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.folder_param', 'folder_param', 'dir', 'string');
        $append_item = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.append_item', 'append_item', 1, 'int');
        $append_field = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.append_field', 'append_field', 1, 'int');
        $targetid = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.targetid', 'targetid', '', 'string');
        $thumb_w = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.thumb_w', 'thumb_w', 120, 'int');
        $thumb_h = $app->getUserStateFromRequest($option . '.fileselement' . $fieldid . '.thumb_h', 'thumb_h', 90, 'int');
        $search = FLEXI_J16GE ? $db->escape(trim(JString::strtolower($search))) : $db->getEscaped(trim(JString::strtolower($search)));
        $newfileid = JRequest::getInt('newfileid');
        $newfilename = base64_decode(JRequest::getVar('newfilename', ''));
        $delfilename = base64_decode(JRequest::getVar('delfilename', ''));
        //add css and submenu to document
        if ($app->isSite()) {
            $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontent.css');
            $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexi_shared.css');
            // NOTE: this is imported by main Frontend CSS file
        } else {
            $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->addStyleSheet(JURI::root() . 'administrator/templates/system/css/system.css');
        // include backend CSS template CSS file , access to backend folder may not be allowed but ...
        if ($app->isSite()) {
            $template = !FLEXI_J16GE ? 'khepri' : (FLEXI_J30GE ? 'hathor' : 'bluestork');
            $document->addStyleSheet(JURI::root() . 'administrator/templates/' . $template . (FLEXI_J16GE ? '/css/template.css' : '/css/general.css'));
        }
        //a trick to avoid loosing general style in modal window
        $css = 'body, td, th { font-size: 11px; }
		a.striketext {
			text-decoration: line-through;
			color:red;
			font-style:italic;
		}
		';
        $document->addStyleDeclaration($css);
        // Get User's Global Permissions
        $perms = FlexicontentHelperPerm::getPerm();
        // ***********************
        // Get data from the model
        // ***********************
        $model = $this->getModel();
        if (!$folder_mode) {
            $rows = $this->get('Data');
            $img_folder = '';
        } else {
            $rows = $model->getFilesFromPath($u_item_id, $fieldid, $append_item, $append_field, $folder_param);
            $img_folder = $model->getFieldFolderPath($u_item_id, $fieldid, $append_item, $append_field, $folder_param);
            $img_path = str_replace('\\', '/', $img_folder . DS . $newfilename);
            $thumb = JURI::root() . 'components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $img_path . '&w=' . $thumb_w . '&h=' . $thumb_h;
        }
        $upload_path_var = 'fc_upload_path_' . $fieldid . '_' . $u_item_id;
        $app->setUserState($upload_path_var, $img_folder);
        //echo $upload_path_var . "<br>";
        //echo $app->getUserState( $upload_path_var, 'noset' );
        $pagination = $this->get('Pagination');
        //$users = $this->get('Users');
        // Get item using at least one file (-of- the currently listed files)
        /*$items_single	= $model->getItemsSingleprop( array('file','minigallery') );
        		$items_multi	= $model->getItemsMultiprop ( $field_props=array('image'=>'originalname'), $value_props=array('image'=>'filename') );
        		$items = array();
        		foreach ($items_single as $item_id => $_item) $items[$item_id] = $_item;
        		foreach ($items_multi  as $item_id => $_item) $items[$item_id] = $_item;
        		ksort($items);*/
        $fname = $model->getFieldName($fieldid);
        $files_selected = $model->getItemFiles($u_item_id);
        $formfieldname = FLEXI_J16GE ? 'custom[' . $fname . '][]' : $fname . '[]';
        //add js to document
        if ($folder_mode) {
            $js = "\n\t\t\t\n\t\t\twindow.addEvent('domready', function() {\n\n\t\t    function closest (obj, el) {\n\t\t        var find = obj.getElement(el);\n\t\t        var self = obj;\n\t\t        \n\t\t        while (self && !find) {\n\t\t            self = self.getParent();\n\t\t            find = self ? self.getElement(el) : null;\n\t\t        }\n\t\t        return find;\n\t\t    }\n\n\t\t\t\tvar delfilename = '" . $delfilename . "';\n\t\t\t\tvar remove_existing_files_from_list = 0;\n\t\t\t\tvar remove_new_files_from_list = 0;\n\t\t\t\toriginal_objs = \$(window.parent.document.body).getElement('#container_fcfield_" . $fieldid . "').getElements('.originalname');\n\t\t\t\texisting_objs = \$(window.parent.document.body).getElement('#container_fcfield_" . $fieldid . "').getElements('.existingname');\n\t\t\t\t\n\t\t\t\tvar imgobjs = Array();\n\t\t\t\tfor(i=0,n=original_objs.length; i<n; i++)  {\n\t\t\t\t\tif (original_objs[i].value) imgobjs.push(original_objs[i].value);\n\t\t\t\t\tif ( delfilename!='' && original_objs[i].value == delfilename)\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.parent.deleteField" . $fieldid . "( original_objs[i].getParent() );\n\t\t\t\t\t\tremove_existing_files_from_list = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(i=0,n=existing_objs.length; i<n; i++) {\n\t\t\t\t\tif ( existing_objs[i].value) imgobjs.push(existing_objs[i].value);\n\t\t\t\t\tif ( delfilename!='' && existing_objs[i].value == delfilename)\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.parent.deleteField" . $fieldid . "(\n\t\t\t\t\t\t\t(MooTools.version>='1.2.4')  ?  existing_objs[i].getParent('.img_value_props')  :  closest (existing_objs[i] , '.img_value_props')\n\t\t\t\t\t\t);\n\t\t\t\t\t\tremove_new_files_from_list = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif ( remove_existing_files_from_list || remove_new_files_from_list ) {\n\t\t\t\t\tmssg = '" . JText::_('FLEXI_DELETE_FILE_IN_LIST_WINDOW_MUST_CLOSE') . "';\n\t\t\t\t\tmssg = mssg + '\\n' + (remove_existing_files_from_list ? '" . JText::_('FLEXI_EXISTING_FILE_REMOVED_SAVE_RECOMMENEDED', true) . "' : '');\n\t\t\t\t\talert( mssg );\n\t\t\t\t\t(MooTools.version>='1.2.4') ?  window.parent.SqueezeBox.close()  :  window.parent.document.getElementById('sbox-window').close();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfor(i=0,n=imgobjs.length; i<n; i++) {\n\t\t\t\t\tvar rows = \$(document.body).getElements('a[rel='+ imgobjs[i] +']');\n\t\t\t\t\trows.addClass('striketext');\n\t\t\t\t\t\n\t\t\t\t\t//if( (typeof rows) != 'undefined' && rows != null) {\n\t\t\t\t\t\t//alert(rows[0]);\n\t\t\t\t\t\t//row.className = 'striketext';\n\t\t\t\t\t//}\n\t\t\t\t}\n\t\t\t\t" . ($autoassign && $newfilename ? "window.parent.qmAssignFile" . $fieldid . "('" . $targetid . "', '" . $newfilename . "', '" . $thumb . "');" : "") . "\n\t\t\t});\n\t\t\t";
        } else {
            $js = "\n\t\t\tfunction qffileselementadd(obj, id, file) {\n\t\t\t\tvar result = window.parent.qfSelectFile" . $fieldid . "(id, file);\n\t\t\t\tif ((typeof result) != 'undefined' && result == 'cancel') return;\n\t\t\t\tobj.className = 'striketext';\n\t\t\t\tdocument.adminForm.file.value=id;\n\t\t\t}\n\t\t\twindow.addEvent('domready', function() {\n\t\t\t\tfileobjs = window.parent.document.getElementsByName('{$formfieldname}');\n\t\t\t\tfor(i=0,n=fileobjs.length; i<n; i++) {\n\t\t\t\t\trow = document.getElementById('file'+fileobjs[i].value);\n\t\t\t\t\tif( (typeof row) != 'undefined' && row != null) {\n\t\t\t\t\t\trow.className = 'striketext';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t" . ($autoselect && $newfileid ? "qffileselementadd( document.getElementById('file" . $newfileid . "'), '" . $newfileid . "', '" . $newfilename . "');" : "") . "\n\t\t\t});\n\t\t\t";
        }
        $document->addScriptDeclaration($js);
        if ($autoselect && $newfileid) {
            $app->enqueueMessage(JText::_('FLEXI_UPLOADED_FILE_WAS_SELECTED'), 'message');
        }
        /*****************
         ** BUILD LISTS **
         *****************/
        $lists = array();
        // ** FILE UPLOAD FORM **
        // Build languages list
        //$allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed',null);
        //$allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs);
        $display_file_lang_as = $params->get('display_file_lang_as', 3);
        $allowed_langs = null;
        if (FLEXI_FISH || FLEXI_J16GE) {
            $lists['file-lang'] = flexicontent_html::buildlanguageslist('file-lang', '', '*', $display_file_lang_as, $allowed_langs, $published_only = false);
        } else {
            $lists['file-lang'] = flexicontent_html::getSiteDefaultLang() . '<input type="hidden" name="file-lang" value="' . flexicontent_html::getSiteDefaultLang() . '" />';
        }
        /*************
         ** FILTERS **
         *************/
        // language filter
        $lists['language'] = flexicontent_html::buildlanguageslist('filter_lang', 'class="use_select2_lib" onchange="submitform();" size="1" ', $filter_lang, 2);
        // search
        $lists['search'] = $search;
        //search filter
        $filters = array();
        $filters[] = JHTML::_('select.option', '1', JText::_('FLEXI_FILENAME'));
        $filters[] = JHTML::_('select.option', '2', JText::_('FLEXI_FILE_TITLE'));
        $lists['filter'] = JHTML::_('select.genericlist', $filters, 'filter', 'size="1" class="use_select2_lib"', 'value', 'text', $filter);
        //build url/file filterlist
        $url = array();
        $url[] = JHTML::_('select.option', '', '- ' . JText::_('FLEXI_ALL_FILES') . ' -');
        $url[] = JHTML::_('select.option', 'F', JText::_('FLEXI_FILE'));
        $url[] = JHTML::_('select.option', 'U', JText::_('FLEXI_URL'));
        $lists['url'] = JHTML::_('select.genericlist', $url, 'filter_url', 'class="use_select2_lib" size="1" onchange="submitform( );"', 'value', 'text', $filter_url);
        //item lists
        /*$items_list = array();
        		$items_list[] = JHTML::_('select.option', '', '- '. JText::_( 'FLEXI_FILTER_BY_ITEM' ) .' -' );
        		foreach($items as $item) {
        			$items_list[] = JHTML::_('select.option', $item->id, JText::_( $item->title ) . ' (#' . $item->id . ')' );
        		}
        		$lists['item_id'] = JHTML::_('select.genericlist', $items_list, 'item_id', 'size="1" class="use_select2_lib" onchange="submitform( );"', 'value', 'text', $filter_item );*/
        $lists['item_id'] = '<input type="text" name="item_id" size="1" class="inputbox" onchange="submitform( );" value="' . $filter_item . '" />';
        //build secure/media filterlist
        $secure = array();
        $secure[] = JHTML::_('select.option', '', '- ' . JText::_('FLEXI_ALL_DIRECTORIES') . ' -');
        $secure[] = JHTML::_('select.option', 'S', JText::_('FLEXI_SECURE_DIR'));
        $secure[] = JHTML::_('select.option', 'M', JText::_('FLEXI_MEDIA_DIR'));
        $lists['secure'] = JHTML::_('select.genericlist', $secure, 'filter_secure', 'class="use_select2_lib" size="1" onchange="submitform( );"', 'value', 'text', $filter_secure);
        //build ext filterlist
        $lists['ext'] = flexicontent_html::buildfilesextlist('filter_ext', 'class="use_select2_lib" size="1" onchange="submitform( );"', $filter_ext);
        //build uploader filterlist
        $lists['uploader'] = flexicontent_html::builduploaderlist('filter_uploader', 'class="use_select2_lib" size="1" onchange="submitform( );"', $filter_uploader);
        // table ordering
        $lists['order_Dir'] = $filter_order_Dir;
        $lists['order'] = $filter_order;
        // removed files
        $filelist = JRequest::getString('files');
        $file = JRequest::getInt('file');
        $filelist = explode(',', $filelist);
        $files = array();
        foreach ($filelist as $fileid) {
            if ($fileid && $fileid != $file) {
                $files[] = (int) $fileid;
            }
        }
        $files = implode(',', $files);
        if (strlen($files) > 0) {
            $files .= ',';
        }
        $files .= $file;
        //assign data to template
        $this->assignRef('params', $params);
        $this->assignRef('client', $client);
        //Load pane behavior
        if (!FLEXI_J16GE) {
            jimport('joomla.html.pane');
            $pane = JPane::getInstance('Tabs');
            $this->assignRef('pane', $pane);
        }
        $this->assignRef('lists', $lists);
        $this->assignRef('rows', $rows);
        $this->assignRef('folder_mode', $folder_mode);
        $this->assignRef('img_folder', $img_folder);
        $this->assignRef('thumb_w', $thumb_w);
        $this->assignRef('thumb_h', $thumb_h);
        $this->assignRef('pagination', $pagination);
        $this->assignRef('files', $files);
        $this->assignRef('fieldid', $fieldid);
        $this->assignRef('u_item_id', $u_item_id);
        $this->assignRef('targetid', $targetid);
        $this->assignRef('CanFiles', $perms->CanFiles);
        $this->assignRef('CanUpload', $perms->CanUpload);
        $this->assignRef('CanViewAllFiles', $perms->CanViewAllFiles);
        $this->assignRef('files_selected', $files_selected);
        $this->assignRef('langs', $langs);
        parent::display($tpl);
    }
Esempio n. 15
0
    /**
     * Creates the item submit form
     *
     * @since 1.0
     */
    function _displayForm($tpl)
    {
        jimport('joomla.html.parameter');
        // ... we use some strings from administrator part
        // load english language file for 'com_content' component then override with current language file
        JFactory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR, 'en-GB', true);
        JFactory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR, null, true);
        // load english language file for 'com_flexicontent' component then override with current language file
        JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, 'en-GB', true);
        JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, null, true);
        // ********************************
        // Initialize variables, flags, etc
        // ********************************
        $app = JFactory::getApplication();
        $dispatcher = JDispatcher::getInstance();
        $document = JFactory::getDocument();
        $session = JFactory::getSession();
        $user = JFactory::getUser();
        $db = JFactory::getDBO();
        $uri = JFactory::getURI();
        $nullDate = $db->getNullDate();
        $menu = $app->getMenu()->getActive();
        // We do not have item parameters yet, but we need to do some work before creating the item
        // Get the COMPONENT only parameter
        $params = new JRegistry();
        $cparams = JComponentHelper::getParams('com_flexicontent');
        $params->merge($cparams);
        // Merge the active menu parameters
        if ($menu) {
            $params->merge($menu->params);
        }
        // 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;
        }
        // *********************************************************
        // Get item data and create item form (that loads item data)
        // *********************************************************
        if ($print_logging_info) {
            $start_microtime = microtime(true);
        }
        $model = $this->getModel();
        // Indicate to model that current view IS item form
        $model->isForm = true;
        // ** WE NEED TO get OR decide the Content Type, before we call the getItem
        // ** We rely on typeid Request variable to decide type for new items so make sure this is set,
        // ZERO means allow user to select type, but if user is only allowed a single type, then autoselect it!
        // Try type from session
        $jdata = $app->getUserState('com_flexicontent.edit.item.data');
        //print_r($jdata);
        if (!empty($jdata['type_id'])) {
            JRequest::setVar('typeid', (int) $jdata['type_id']);
            // This also forces zero if value not set
        } else {
            if ($menu && isset($menu->query['typeid'])) {
                JRequest::setVar('typeid', (int) $menu->query['typeid']);
                // This also forces zero if value not set
            }
        }
        $new_typeid = JRequest::getVar('typeid', 0, '', 'int');
        // Verify type is allowed to the user
        if (!$new_typeid) {
            $types = $model->getTypeslist($type_ids_arr = false, $check_perms = true, $_published = true);
            if ($types && count($types) == 1) {
                $new_typeid = $types[0]->id;
            }
            JRequest::setVar('typeid', $new_typeid);
            $canCreateType = true;
        }
        // FORCE model to load versioned data (URL specified version or latest version (last saved))
        $version = JRequest::getVar('version', 0, 'request', 'int');
        // Load specific item version (non-zero), 0 version: is unversioned data, -1 version: is latest version (=default for edit form)
        // Indicate to model to merge menu parameters if menu matches
        $model->mergeMenuParams = true;
        // Get the item, loading item data and doing parameters merging
        $item = $model->getItem(null, $check_view_access = false, $no_cache = true, $force_version = $version != 0 ? $version : -1);
        // -1 version means latest
        // Replace component/menu 'params' with the merged component/category/type/item/menu ETC ... parameters
        $params =& $item->parameters;
        if ($print_logging_info) {
            $fc_run_times['get_item_data'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
        }
        // **************************************************************
        // Get (CORE & CUSTOM) fields and their VERSIONED values and then
        // **************************************************************
        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;
        }
        // Load permissions (used by form template)
        $perms = $this->_getItemPerms($item);
        // Create submit configuration (for new items) into the session, this is needed before creating the item form
        $submitConf = $this->_createSubmitConf($item, $perms);
        // Most core field are created via calling methods of the form (J2.5)
        $form = $this->get('Form');
        // is new item and ownership Flags
        $isnew = !$item->id;
        $isOwner = $item->created_by == $user->get('id');
        // *****************
        // Type related data
        // *****************
        // Get available types and the currently selected/requested type
        $types = $model->getTypeslist();
        $typesselected = $model->getTypesselected();
        // Get type parameters, these are needed besides the 'merged' item parameters, e.g. to get Type's default layout
        $tparams = $this->get('Typeparams');
        $tparams = new JRegistry($tparams);
        // *****************
        // Load JS/CSS files
        // *****************
        $has_J2S = false;
        foreach ($fields as $field) {
            $has_J2S = $has_J2S || $field->field_type == 'j2store';
            if ($has_J2S) {
                break;
            }
        }
        $_params = new JRegistry();
        $_params->set('load-ui-dialog', 1);
        $_params->set('load-ui-menu', $has_J2S ? 0 : 1);
        $_params->set('load-ui-autocomplete', $has_J2S ? 0 : 1);
        //FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
        flexicontent_html::loadJQuery($add_jquery = 1, $add_jquery_ui = 1, $add_jquery_ui_css = 1, $add_remote = 1, $_params);
        //flexicontent_html::loadFramework('jQuery');
        flexicontent_html::loadFramework('select2');
        flexicontent_html::loadFramework('prettyCheckable');
        flexicontent_html::loadFramework('flexi-lib');
        // Load custom behaviours: form validation, popup tooltips
        JHTML::_('behavior.formvalidation');
        // load default validation JS to make sure it is overriden
        FLEXI_J30GE ? JHtml::_('bootstrap.tooltip') : JHTML::_('behavior.tooltip');
        //JHTML::_('script', 'joomla.javascript.js', 'includes/js/');
        // Add css files to the document <head> section (also load CSS joomla template override)
        $document->addStyleSheetVersion($this->baseurl . '/components/com_flexicontent/assets/css/flexicontent.css', FLEXI_VHASH);
        //$document->addCustomTag('<!--[if IE]><style type="text/css">.floattext {zoom:1;}</style><![endif]-->');
        if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) {
            $document->addStyleSheetVersion($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css', FLEXI_VHASH);
        }
        // Fields common CSS
        $document->addStyleSheetVersion($this->baseurl . '/components/com_flexicontent/assets/css/flexi_form_fields.css', FLEXI_VHASH);
        // Load backend / frontend shared and Joomla version specific CSS (different for frontend / backend)
        FLEXI_J30GE ? $document->addStyleSheetVersion($this->baseurl . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VHASH) : $document->addStyleSheetVersion($this->baseurl . '/components/com_flexicontent/assets/css/j25.css', FLEXI_VHASH);
        // Add js function to overload the joomla submitform
        $document->addScriptVersion($this->baseurl . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VHASH);
        $document->addScriptVersion($this->baseurl . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VHASH);
        // Add js function for custom code used by FLEXIcontent item form
        $document->addScriptVersion($this->baseurl . '/components/com_flexicontent/assets/js/itemscreen.js', FLEXI_VHASH);
        // *********************************************************************************************************
        // Get language stuff, and also load Template-Specific language file to override or add new language strings
        // *********************************************************************************************************
        if ($enable_translation_groups) {
            $langAssocs = $params->get('uselang_fe') == 1 ? $this->get('LangAssocs') : false;
        }
        $langs = FLEXIUtilities::getLanguages('code');
        FLEXIUtilities::loadTemplateLanguageFile($params->get('ilayout', 'default'));
        // *************************************
        // Create captcha field via custom logic
        // *************************************
        // create and set (into HTTP request) a unique item id for plugins that needed it
        if ($item->id) {
            $unique_tmp_itemid = $item->id;
        } 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);
        // Component / Menu Item parameters
        $allowunauthorize = $params->get('allowunauthorize', 0);
        // allow unauthorised user to submit new content
        $unauthorized_page = $params->get('unauthorized_page', '');
        // page URL for unauthorized users (via global configuration)
        $notauth_itemid = $params->get('notauthurl', '');
        // menu itemid (to redirect) when user is not authorized to create content
        // Create captcha field or messages
        // Maybe some code can be removed by using Joomla's built-in form element (in XML file), instead of calling the captcha plugin ourselves
        $use_captcha = $params->get('use_captcha', 1);
        // 1 for guests, 2 for any user
        $captcha_formop = $params->get('captcha_formop', 0);
        // 0 for submit, 1 for submit/edit (aka always)
        $display_captcha = $use_captcha >= 2 || $use_captcha == 1 && $user->guest;
        $display_captcha = $display_captcha && ($isnew || $captcha_formop);
        // Trigger the configured captcha plugin
        if ($display_captcha) {
            // Get configured captcha plugin
            $c_plugin = $params->get('captcha', $app->getCfg('captcha'));
            // TODO add param to override default
            if ($c_plugin) {
                $c_name = 'captcha_response_field';
                $c_id = $c_plugin == 'recaptcha' ? 'dynamic_recaptcha_1' : 'fc_dynamic_captcha';
                $c_class = ' required';
                $c_namespace = 'fc_item_form';
                // Try to load the configured captcha plugin, (check if disabled or uninstalled), Joomla will enqueue an error message if needed
                $captcha_obj = JCaptcha::getInstance($c_plugin, array('namespace' => $c_namespace));
                if ($captcha_obj) {
                    $captcha_field = $captcha_obj->display($c_name, $c_id, $c_class);
                    $label_class = 'flexi_label';
                    $label_class .= FLEXI_J30GE ? ' hasTooltip' : ' hasTip';
                    $label_tooltip = flexicontent_html::getToolTip(null, 'FLEXI_CAPTCHA_ENTER_CODE_DESC', 1, 1);
                    $captcha_field = '
						<label id="' . $c_name . '-lbl" for="' . $c_name . '" class="' . $label_class . '" title="' . $label_tooltip . '" >
						' . JText::_('FLEXI_CAPTCHA_ENTER_CODE') . '
						</label>
						<div id="container_fcfield_' . $c_plugin . '" class="container_fcfield container_fcfield_name_' . $c_plugin . '">
							<div class="fcfieldval_container valuebox fcfieldval_container_' . $c_plugin . '">
							' . $captcha_field . '
							</div>
						</div>';
                }
            }
        }
        // *******************************
        // CHECK EDIT / CREATE PERMISSIONS
        // *******************************
        // User Group / Author parameters
        $authorparams = flexicontent_db::getUserConfig($user->id);
        $max_auth_limit = intval($authorparams->get('max_auth_limit', 0));
        // maximum number of content items the user can create
        $hasTmpEdit = false;
        $hasCoupon = false;
        // Check session
        if ($session->has('rendered_uneditable', 'flexicontent')) {
            $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent');
            $hasTmpEdit = !empty($rendered_uneditable[$model->get('id')]);
            $hasCoupon = !empty($rendered_uneditable[$model->get('id')]) && $rendered_uneditable[$model->get('id')] == 2;
            // editable via coupon
        }
        if (!$isnew) {
            // EDIT action
            // Finally check if item is currently being checked-out (currently being edited)
            if ($model->isCheckedOut($user->get('id'))) {
                $msg = JText::sprintf('FLEXI_DESCBEINGEDITTED', $model->get('title'));
                $app->redirect(JRoute::_('index.php?view=' . FLEXI_ITEMVIEW . '&cid=' . $model->get('catid') . '&id=' . $model->get('id'), false), $msg);
            }
            //Checkout the item
            $model->checkout();
            // Get edit access, this includes privileges edit and edit-own and the temporary EDIT flag ('rendered_uneditable')
            $canEdit = $model->getItemAccess()->get('access-edit');
            // If no edit privilege, check if edit COUPON was provided
            if (!$canEdit) {
                $edittok = JRequest::getCmd('edittok', false);
                if ($edittok) {
                    $query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_edit_coupons"';
                    $db->setQuery($query);
                    $tbl_exists = (bool) count($db->loadObjectList());
                    if ($tbl_exists) {
                        $query = 'SELECT * FROM #__flexicontent_edit_coupons ' . ' WHERE token = ' . $db->Quote($edittok) . ' AND id = ' . $model->get('id');
                        $db->setQuery($query);
                        $tokdata = $db->loadObject();
                        if ($tokdata) {
                            $hasCoupon = true;
                            $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent');
                            $rendered_uneditable[$model->get('id')] = 2;
                            // 2: indicates, that has edit via EDIT Coupon
                            $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent');
                            $canEdit = 1;
                        } else {
                            JError::raiseNotice(403, JText::_('EDIT_TOKEN_IS_INVALID') . ' : ' . $edittok);
                        }
                    }
                }
            }
            // Edit check finished, throw error if needed
            if (!$canEdit) {
                if ($user->guest) {
                    $uri = JFactory::getURI();
                    $return = $uri->toString();
                    $fcreturn = serialize(array('id' => @$this->_item->id, 'cid' => $cid));
                    // a special url parameter, used by some SEF code
                    $com_users = FLEXI_J16GE ? 'com_users' : 'com_user';
                    $url = $params->get('login_page', 'index.php?option=' . $com_users . '&view=login');
                    $return = strtr(base64_encode($return), '+/=', '-_,');
                    $url .= '&return=' . $return;
                    //$url .= '&return='.urlencode(base64_encode($return));
                    $url .= '&fcreturn=' . base64_encode($fcreturn);
                    JError::raiseWarning(403, JText::sprintf("FLEXI_LOGIN_TO_ACCESS", $url));
                    $app->redirect($url);
                } else {
                    if ($unauthorized_page) {
                        //  unauthorized page via global configuration
                        JError::raiseNotice(403, JText::_('FLEXI_ALERTNOTAUTH_TASK'));
                        $app->redirect($unauthorized_page);
                    } else {
                        // user isn't authorize to edit this content
                        $msg = JText::_('FLEXI_ALERTNOTAUTH_TASK');
                        if (FLEXI_J16GE) {
                            throw new Exception($msg, 403);
                        } else {
                            JError::raiseError(403, $msg);
                        }
                    }
                }
            }
        } else {
            // CREATE action
            // Get create access, this includes check of creating in at least one category, and type's "create items"
            $canAdd = $model->getItemAccess()->get('access-create');
            $overrideCategoryACL = $params->get("overridecatperms", 1) && ($params->get("cid") || $params->get("maincatid"));
            $canAssignToCategory = $canAdd || $overrideCategoryACL;
            // can create in any category -OR- category ACL override is enabled
            // Check if Content Type can be created by current user
            if (empty($canCreateType)) {
                if ($new_typeid) {
                    // not needed, already done be model when type_id is set, check and remove
                    $canCreateType = $model->canCreateType(array($new_typeid));
                    // Can create given Content Type
                } else {
                    // needed not done be model yet
                    $canCreateType = $model->canCreateType();
                    // Can create at least one Content Type
                }
            }
            // Not authorized if can not assign item to category or can not create type
            $not_authorised = !$canAssignToCategory || !$canCreateType;
            // Allow item submission by unauthorized users, ... even guests ...
            if ($allowunauthorize == 2) {
                $allowunauthorize = !$user->guest;
            }
            if ($not_authorised && !$allowunauthorize) {
                $msg = '';
                if (!$canCreateType) {
                    $type_name = isset($types[$new_typeid]) ? '"' . JText::_($types[$new_typeid]->name) . '"' : JText::_('FLEXI_ANY');
                    $msg .= ($msg ? '<br/>' : '') . JText::sprintf('FLEXI_NO_ACCESS_CREATE_CONTENT_OF_TYPE', $type_name);
                }
                if (!$canAssignToCategory) {
                    $msg .= ($msg ? '<br/>' : '') . JText::_('FLEXI_ALERTNOTAUTH_CREATE_IN_ANY_CAT');
                }
            } else {
                if ($max_auth_limit) {
                    $db->setQuery('SELECT COUNT(id) FROM #__content WHERE created_by = ' . $user->id);
                    $authored_count = $db->loadResult();
                    $content_is_limited = $authored_count >= $max_auth_limit;
                    $msg = $content_is_limited ? JText::sprintf('FLEXI_ALERTNOTAUTH_CREATE_MORE', $max_auth_limit) : '';
                }
            }
            if ($not_authorised && !$allowunauthorize || @$content_is_limited) {
                // User isn't authorize to add ANY content
                if ($notauth_menu = $app->getMenu()->getItem($notauth_itemid)) {
                    // a. custom unauthorized submission page via menu item
                    $internal_link_vars = @$notauth_menu->component ? '&Itemid=' . $notauth_itemid . '&option=' . $notauth_menu->component : '';
                    $notauthurl = JRoute::_($notauth_menu->link . $internal_link_vars, false);
                    JError::raiseNotice(403, $msg);
                    $app->redirect($notauthurl);
                } else {
                    if ($unauthorized_page) {
                        // b. General unauthorized page via global configuration
                        JError::raiseNotice(403, $msg);
                        $app->redirect($unauthorized_page);
                    } else {
                        // c. Finally fallback to raising a 403 Exception/Error that will redirect to site's default 403 unauthorized page
                        if (FLEXI_J16GE) {
                            throw new Exception($msg, 403);
                        } else {
                            JError::raiseError(403, $msg);
                        }
                    }
                }
            }
        }
        // *****************************************************************************
        // (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);
        }
        $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;
        }
        // Tags used by the item
        $usedtagsids = $this->get('UsedtagsIds');
        // NOTE: This will normally return the already set versioned value of tags ($item->tags)
        $usedtagsdata = $model->getUsedtagsData($usedtagsids);
        // Get the edit lists
        $lists = $this->_buildEditLists($perms, $params, $authorparams);
        // Get number of subscribers
        $subscribers = $this->get('SubscribersCount');
        // Get menu overridden categories/main category fields
        $menuCats = $this->_getMenuCats($item, $perms);
        // Create placement configuration for CORE properties
        $placementConf = $this->_createPlacementConf($item, $fields);
        // Item language related vars
        $languages = FLEXIUtilities::getLanguages();
        $itemlang = new stdClass();
        $itemlang->shortcode = substr($item->language, 0, 2);
        $itemlang->name = $languages->{$item->language}->name;
        $itemlang->image = '<img src="' . @$languages->{$item->language}->imgsrc . '" alt="' . $languages->{$item->language}->name . '" />';
        //Load the JEditor object
        $editor = JFactory::getEditor();
        // **********************************************************
        // Calculate a (browser window) page title and a page heading
        // **********************************************************
        // This was done inside model, because we have set the merge parameters flag
        // ************************************************************
        // Create the document title, by from page title and other data
        // ************************************************************
        // Use the page heading as document title, (already calculated above via 'appropriate' logic ...)
        $doc_title = $params->get('page_title');
        // Check and prepend or append site name
        // Add Site Name to page title
        if ($app->getCfg('sitename_pagetitles', 0) == 1) {
            $doc_title = $app->getCfg('sitename') . " - " . $doc_title;
        } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
            $doc_title = $doc_title . " - " . $app->getCfg('sitename');
        }
        // Finally, set document title
        $document->setTitle($doc_title);
        // Add title to pathway
        $pathway = $app->getPathWay();
        $pathway->addItem($doc_title, '');
        // Get pageclass suffix
        $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
        // Ensure the row data is safe html
        // @TODO: check if this is really required as it conflicts with the escape function in the tmpl
        //JFilterOutput::objectHTMLSafe( $item );
        $this->assign('action', $uri->toString());
        $this->assignRef('item', $item);
        $this->assignRef('form', $form);
        // most core field are created via calling methods of the form (J2.5)
        if ($enable_translation_groups) {
            $this->assignRef('lang_assocs', $langAssocs);
        }
        $this->assignRef('langs', $langs);
        $this->assignRef('params', $params);
        $this->assignRef('lists', $lists);
        $this->assignRef('subscribers', $subscribers);
        $this->assignRef('editor', $editor);
        $this->assignRef('user', $user);
        $this->assignRef('usedtagsdata', $usedtagsdata);
        $this->assignRef('fields', $fields);
        $this->assignRef('tparams', $tparams);
        $this->assignRef('perms', $perms);
        $this->assignRef('document', $document);
        $this->assignRef('nullDate', $nullDate);
        $this->assignRef('menuCats', $menuCats);
        $this->assignRef('submitConf', $submitConf);
        $this->assignRef('placementConf', $placementConf);
        $this->assignRef('itemlang', $itemlang);
        $this->assignRef('pageclass_sfx', $pageclass_sfx);
        $this->assign('captcha_errmsg', @$captcha_errmsg);
        $this->assign('captcha_field', @$captcha_field);
        // ****************************************************************
        // SET INTO THE FORM, parameter values for various parameter groups
        // ****************************************************************
        if (JHTML::_('date', $item->publish_down, 'Y') <= 1969 || $item->publish_down == $nullDate) {
            $item->publish_down = '';
            //JText::_( 'FLEXI_NEVER' );
        }
        // ****************************
        // 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();
        }
        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) {
            if (FLEXI_J16GE) {
                $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);
                    }
                }
            } else {
                $tmpl->params->loadINI($item->attribs);
            }
        }
        $this->assignRef('tmpls', $tmpls);
        // 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;
        }
    }
JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, 'en-GB', true);
JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, null, true);
// Load language overrides, just before executing the component (DONE manually for J1.5)
$overrideDir = JPATH_ADMINISTRATOR . DS . 'languages' . DS . 'overrides' . DS;
if (!FLEXI_J16GE) {
    JFactory::getLanguage()->load('override', $overrideDir, 'en-GB', true);
    JFactory::getLanguage()->load('override', $overrideDir, null, true);
}
// ********************************
// Load common js libs / frameworks
// ********************************
if (JRequest::getWord('format') != 'raw') {
    // Load mootools
    FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
    // Load jquery Framework
    flexicontent_html::loadJQuery();
    // Load J2.5 (non-bootstrap tooltips) tooltips, we still need regardless of using J3.x, since some code may still use them
    JHTML::_('behavior.tooltip');
    // J3.0+ tooltips (bootstrap based)
    if (FLEXI_J30GE) {
        JHtml::_('bootstrap.tooltip');
    }
    // Add flexi-lib JS
    JFactory::getDocument()->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/flexi-lib.js', FLEXI_VERSION);
    // Frontend/backend script
    JFactory::getDocument()->addScriptVersion(JURI::base(true) . '/components/com_flexicontent/assets/js/flexi-lib.js', FLEXI_VERSION);
    // Backend only script
}
// ***********************************
// PREPARE Calling the controller task
// ***********************************
Esempio n. 17
0
 function add_css_js()
 {
     $css = "\n\t\tdiv table td.paramlist_value {\n\t\t\tpadding-left:8px;\n\t\t}\n\t\tdiv .paramlist_value label {\n\t\t\tmin-width:10px!important; padding: 0px 10px 0px 0px!important; margin: 4px 0px 0px 1px!important;\n\t\t}\n\t\tdiv .paramlist_value input, div .paramlist_value textarea, div .paramlist_value img, div .paramlist_value button { margin:5px 0px 2px 0px; }\n\t\tdiv .paramlist_value select { margin:0px; }\n\t\tfieldset.radio  { margin: 0; padding: 0; }\n\t\t\n\t\t.tool-tip { }\n\t\t.tip-title { }\n\t\t";
     $document = JFactory::getDocument();
     $document->addStyleDeclaration($css);
     $document->addStyleSheet(JURI::root() . 'components/com_flexicontent/assets/css/flexi_form.css');
     // WORKAROUNDs of for 2 issues in com_config: slow chosen JS and PHP 5.3.9+ 'max_input_vars' limit
     if (FLEXI_J30GE) {
         $jinput = JFactory::getApplication()->input;
     }
     $option = FLEXI_J30GE ? $jinput->get('option', '', 'string') : JRequest::getVar('option');
     $view = FLEXI_J30GE ? $jinput->get('view', '', 'string') : JRequest::getVar('view');
     $controller = FLEXI_J30GE ? $jinput->get('controller', '', 'string') : JRequest::getVar('controller');
     $component = FLEXI_J30GE ? $jinput->get('component', '', 'string') : JRequest::getVar('component');
     //if ($option=='com_config' || $option=='com_menus' || $option=='com_modules') {
     $document->addStyleSheet(JURI::root() . 'components/com_flexicontent/assets/css/flexi_shared.css');
     //}
     $js = '';
     if ($option == 'com_config' && ($view == 'component' || ($controller = 'component')) && $component == 'com_flexicontent') {
         $document->addStyleSheet(JURI::root() . 'components/com_flexicontent/assets/css/tabber.css');
         $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/tabber-minimized.js');
         $document->addScriptDeclaration(' document.write(\'<style type="text/css">.fctabber{display:none;}<\\/style>\'); ');
         if (FLEXI_J30GE) {
             // Make sure chosen JS file is loaded before our code
             JHtml::_('formbehavior.chosen', '#_some_iiidddd_');
             // replace chosen function
             $js .= "\n\t\t\t\t\tjQuery.fn.chosen = function(){};\n\t\t\t\t";
         }
         if (FLEXI_J16GE) {
             /*$js .= "
             			function fc_prepare_config_form(){
             				jQuery('#jform_fcdata_serialized').val( '' );
             				jQuery('#jform_fcdata_serialized').val( JSON.stringify(jQuery('#component-form').serializeArray()) );
             				jQuery('#component-form select').attr('disabled', true);
             				jQuery('#component-form textarea').attr('disabled', true);
             				jQuery('#component-form input[type=text], #component-form input[type=checkbox], #component-form input[type=radio]').attr('disabled', true);
             			}
             			jQuery(document).ready(function() {
             				jQuery('#component-form').attr('onsubmit', \"fc_prepare_config_form();\");
             			})
             		";*/
         }
     }
     if ($js) {
         $document->addScriptDeclaration($js);
     }
     if (FLEXI_J16GE) {
         require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.helper.php';
         FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
         flexicontent_html::loadJQuery();
         $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/admin.js');
         $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/validate.js');
         //if (!FLEXI_J30GE)  $document->addStyleSheet(JURI::base().'components/com_flexicontent/assets/css/j25.css');
         if (FLEXI_J30GE) {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css');
         }
     }
 }
Esempio n. 18
0
    /**
     * Method to select new state for many items
     * 
     * @since 1.5
     */
    function selectsearchflag()
    {
        $user = JFactory::getUser();
        $document = JFactory::getDocument();
        $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);
        // Load jquery Framework
        flexicontent_html::loadJQuery();
        JHtml::_('bootstrap.framework');
        JHtml::_('bootstrap.tooltip');
        $btn_class = 'hasTooltip btn btn-small';
        $state['issearch'] = array('name' => 'FLEXI_TOGGLE_TEXT_SEARCHABLE', 'desc' => 'FLEXI_FIELD_CONTENT_LIST_TEXT_SEARCHABLE_DESC', 'icon' => 'search', 'btn_class' => 'btn-success', 'clear' => true);
        $state['isfilter'] = array('name' => 'FLEXI_TOGGLE_FILTERABLE', 'desc' => 'FLEXI_FIELD_CONTENT_LIST_FILTERABLE_DESC', 'icon' => 'filter', 'btn_class' => 'btn-success', 'clear' => true);
        $state['isadvsearch'] = array('name' => 'FLEXI_TOGGLE_ADV_TEXT_SEARCHABLE', 'desc' => 'FLEXI_FIELD_ADVANCED_TEXT_SEARCHABLE_DESC', 'icon' => 'search', 'btn_class' => 'btn-info', 'clear' => true);
        $state['isadvfilter'] = array('name' => 'FLEXI_TOGGLE_ADV_FILTERABLE', 'desc' => 'FLEXI_FIELD_ADVANCED_FILTERABLE_DESC', 'icon' => 'filter', 'btn_class' => 'btn-info', 'clear' => true);
        ?>
<div id="flexicontent" class="flexicontent" style="padding-top:5%;"><?php 
        foreach ($state as $shortname => $statedata) {
            $css = "width:216px; margin:0px 24px 12px 0px; text-align: left;";
            $link = JURI::base(true) . "/index.php?option=com_flexicontent&task=fields.toggleprop&propname=" . $shortname . "&" . (FLEXI_J30GE ? JSession::getFormToken() : JUtility::getToken()) . "=1";
            $icon = $statedata['icon'];
            if ($shortname == 'issearch') {
                echo '<br/><span class="label">' . JText::_('FLEXI_TOGGLE') . '</span> ' . JText::_('Content Lists') . '<br/>';
            } else {
                if ($shortname == 'isadvsearch') {
                    echo '<br/><span class="label">' . JText::_('FLEXI_TOGGLE') . '</span> ' . JText::_('Search View') . '<br/>';
                }
            }
            ?>
			<span style="<?php 
            echo $css;
            ?>
" class="<?php 
            echo $btn_class . ' ' . $statedata['btn_class'];
            ?>
" title="<?php 
            echo JText::_($statedata['desc']);
            ?>
" data-placement="right"
				onclick="window.parent.document.adminForm.propname.value='<?php 
            echo $shortname;
            ?>
'; window.parent.document.adminForm.boxchecked.value==0  ?  alert('<?php 
            echo JText::_('FLEXI_NO_ITEMS_SELECTED');
            ?>
')  :  window.parent.Joomla.submitbutton('fields.toggleprop')"
			>
				<span class="icon-<?php 
            echo $icon;
            ?>
"></span><?php 
            echo JText::_($statedata['name']);
            ?>
			</span>
			<?php 
            if (isset($statedata['clear'])) {
                echo '<div class="fcclear"></div>';
            }
        }
        ?>
</div><?php 
        return;
    }
Esempio n. 19
0
    function display($tpl = null)
    {
        // ********************
        // Initialise variables
        // ********************
        $app = JFactory::getApplication();
        $jinput = $app->input;
        $layout = $jinput->get('layout', '', 'cmd');
        $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();
        //$authorparams = flexicontent_db::getUserConfig($user->id);
        $langs = FLEXIUtilities::getLanguages('code');
        flexicontent_html::loadJQuery();
        flexicontent_html::loadFramework('select2');
        //JHTML::_('behavior.tooltip');
        // Load the form validation behavior
        JHTML::_('behavior.formvalidation');
        // Get user's global permissions
        $perms = FlexicontentHelperPerm::getPerm();
        // Get folder mode
        $_view = $view;
        $folder_mode = 0;
        // ***********
        // Get filters
        // ***********
        $count_filters = 0;
        // Order and order direction
        $filter_order = $model->getState('filter_order');
        $filter_order_Dir = $model->getState('filter_order_Dir');
        $filter_lang = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_lang', 'filter_lang', '', 'string');
        $filter_url = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_url', 'filter_url', '', 'word');
        $filter_secure = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_secure', 'filter_secure', '', 'word');
        $filter_ext = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_ext', 'filter_ext', '', 'alnum');
        $filter_uploader = $app->getUserStateFromRequest($option . '.' . $_view . '.filter_uploader', 'filter_uploader', '', 'int');
        $filter_item = $app->getUserStateFromRequest($option . '.' . $_view . '.item_id', 'item_id', '', 'int');
        if ($layout != 'image') {
            if ($filter_lang) {
                $count_filters++;
            }
            if ($filter_url) {
                $count_filters++;
            }
            if ($filter_secure) {
                $count_filters++;
            }
        }
        if ($filter_ext) {
            $count_filters++;
        }
        if ($filter_uploader) {
            $count_filters++;
        }
        if ($filter_item) {
            $count_filters++;
        }
        // Text search
        $scope = $model->getState('scope');
        $search = $model->getState('search');
        $search = $db->escape(trim(JString::strtolower($search)));
        $filter_uploader = $filter_uploader ? $filter_uploader : '';
        $filter_item = $filter_item ? $filter_item : '';
        // **************************
        // Add css and js to document
        // **************************
        if ($app->isSite()) {
            $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontent.css', FLEXI_VHASH);
        } else {
            $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(){";
        // ************************
        // Create Submenu & Toolbar
        // ************************
        // Create Submenu (and also check access to current view)
        FLEXISubmenu('CanFiles');
        // Create document/toolbar titles
        $doc_title = JText::_('FLEXI_FILEMANAGER');
        $site_title = $document->getTitle();
        JToolBarHelper::title($doc_title, 'files');
        $document->setTitle($doc_title . ' - ' . $site_title);
        // Create the toolbar
        $this->setToolbar();
        // ***********************
        // Get data from the model
        // ***********************
        if (!$folder_mode) {
            $rows = $this->get('Data');
        } else {
            // TODO MORE ...
        }
        $pagination = $this->get('Pagination');
        //$users = $this->get('Users');
        // Get item using at least one file (-of- the currently listed files)
        /*$items_single	= $model->getItemsSingleprop( array('file','minigallery') );
        		$items_multi	= $model->getItemsMultiprop ( $field_props=array('image'=>'originalname'), $value_props=array('image'=>'filename') );
        		$items = array();
        		foreach ($items_single as $item_id => $_item) $items[$item_id] = $_item;
        		foreach ($items_multi  as $item_id => $_item) $items[$item_id] = $_item;
        		ksort($items);*/
        $assigned_fields_labels = array('image' => 'image/gallery', 'file' => 'file', 'minigallery' => 'minigallery');
        $assigned_fields_icons = array('image' => 'picture_link', 'file' => 'page_link', 'minigallery' => 'film_link');
        /*****************
         ** BUILD LISTS **
         *****************/
        $lists = array();
        // ** FILE UPLOAD FORM **
        // Build languages list
        //$allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed',null);
        //$allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs);
        $display_file_lang_as = $cparams->get('display_file_lang_as', 3);
        $allowed_langs = null;
        $lists['file-lang'] = flexicontent_html::buildlanguageslist('file-lang', '', '*', $display_file_lang_as, $allowed_langs, $published_only = false);
        /*************
         ** FILTERS **
         *************/
        // language filter
        $lists['language'] = ($filter_lang || 1 ? '<label class="label">' . JText::_('FLEXI_LANGUAGE') . '</label>' : '') . flexicontent_html::buildlanguageslist('filter_lang', 'class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" size="1" ', $filter_lang, '-');
        // search
        $lists['search'] = $search;
        //search filter
        $filters = array();
        $filters[] = JHTML::_('select.option', '0', '- ' . JText::_('FLEXI_ALL') . ' -');
        $filters[] = JHTML::_('select.option', '1', JText::_('FLEXI_FILENAME'));
        $filters[] = JHTML::_('select.option', '2', JText::_('FLEXI_FILE_DISPLAY_TITLE'));
        $filters[] = JHTML::_('select.option', '3', JText::_('FLEXI_DESCRIPTION'));
        $lists['scope'] = '
			<span class="hasTooltip" style="display:inline-block; padding:0; margin:0;" title="' . JText::_('FLEXI_SEARCH_TEXT_INSIDE') . '"><i class="icon-info"></i></span>
			' . JHTML::_('select.genericlist', $filters, 'scope', 'size="1" class="use_select2_lib fc_skip_highlight" onchange="jQuery(\'#search\').attr(\'placeholder\', jQuery(this).find(\'option:selected\').text());" ', 'value', 'text', $scope);
        //build url/file filterlist
        $url = array();
        $url[] = JHTML::_('select.option', '', '-');
        $url[] = JHTML::_('select.option', 'F', JText::_('FLEXI_FILE'));
        $url[] = JHTML::_('select.option', 'U', JText::_('FLEXI_URL'));
        $lists['url'] = ($filter_url || 1 ? '<label class="label">' . JText::_('FLEXI_ALL_FILES') . '</label>' : '') . JHTML::_('select.genericlist', $url, 'filter_url', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_url);
        //item lists
        /*$items_list = array();
        		$items_list[] = JHTML::_('select.option', '', '- '. JText::_( 'FLEXI_FILTER_BY_ITEM' ) .' -' );
        		foreach($items as $item) {
        			$items_list[] = JHTML::_('select.option', $item->id, JText::_( $item->title ) . ' (#' . $item->id . ')' );
        		}
        		$lists['item_id'] = JHTML::_('select.genericlist', $items_list, 'item_id', 'size="1" class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_item );*/
        $lists['item_id'] = '<input type="text" name="item_id" size="1" class="inputbox" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" value="' . $filter_item . '" />';
        //build secure/media filterlist
        $secure = array();
        $secure[] = JHTML::_('select.option', '', '-');
        $secure[] = JHTML::_('select.option', 'S', JText::_('FLEXI_SECURE_DIR'));
        $secure[] = JHTML::_('select.option', 'M', JText::_('FLEXI_MEDIA_DIR'));
        $lists['secure'] = ($filter_secure || 1 ? '<label class="label">' . JText::_('FLEXI_ALL_DIRECTORIES') . '</label>' : '') . JHTML::_('select.genericlist', $secure, 'filter_secure', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_secure);
        //build ext filterlist
        $lists['ext'] = ($filter_ext || 1 ? '<label class="label">' . JText::_('FLEXI_ALL_EXT') . '</label>' : '') . flexicontent_html::buildfilesextlist('filter_ext', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', $filter_ext, '-');
        //build uploader filterlist
        $lists['uploader'] = ($filter_uploader || 1 ? '<label class="label">' . JText::_('FLEXI_ALL_UPLOADERS') . '</label>' : '') . flexicontent_html::builduploaderlist('filter_uploader', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', $filter_uploader, '-');
        // table ordering
        $lists['order_Dir'] = $filter_order_Dir;
        $lists['order'] = $filter_order;
        // uploadstuff
        if ($cparams->get('enable_flash', 1) && !FLEXI_J30GE) {
            JHTML::_('behavior.uploader', 'file-upload', array('onAllComplete' => 'function(){ window.location.reload(); }'));
        }
        jimport('joomla.client.helper');
        $ftp = !JClientHelper::hasCredentials('ftp');
        //assign data to template
        $this->assignRef('count_filters', $count_filters);
        $this->assignRef('params', $cparams);
        $this->assign('require_ftp', $ftp);
        $this->assignRef('lists', $lists);
        $this->assignRef('rows', $rows);
        $this->assignRef('folder_mode', $folder_mode);
        $this->assignRef('pagination', $pagination);
        $this->assignRef('CanFiles', $perms->CanFiles);
        $this->assignRef('CanUpload', $perms->CanUpload);
        $this->assignRef('CanViewAllFiles', $perms->CanViewAllFiles);
        $this->assignRef('assigned_fields_labels', $assigned_fields_labels);
        $this->assignRef('assigned_fields_icons', $assigned_fields_icons);
        $this->assignRef('langs', $langs);
        $this->assignRef('option', $option);
        $this->assignRef('view', $view);
        $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null;
        parent::display($tpl);
    }