Esempio n. 1
0
	function onDisplayField(&$field, &$item)
	{
		// execute the code only if the field type match the plugin type
		if ( !in_array($field->field_type, self::$field_types) ) return;
		
		$field->label = JText::_($field->label);
		
		// some parameter shortcuts
		$sql_mode				= $field->parameters->get( 'sql_mode', 0 ) ;
		$field_elements	= $field->parameters->get( 'field_elements' ) ;
		$default_value	= $field->parameters->get( 'default_value', '' ) ;
		
		$firstoptiontext = $field->parameters->get( 'firstoptiontext', 'FLEXI_SELECT' ) ;
		$usefirstoption  = $field->parameters->get( 'usefirstoption', 1 ) ;
		
		$required = $field->parameters->get( 'required', 0 ) ;
		$required = $required ? ' required' : '';
		
		// initialise property
		if (!$field->value && $default_value!=='') {
			$field->value = array();
			$field->value[0] = $default_value;
		} else if (!$field->value) {
			$field->value = array();
			$field->value[0] = '';
		}
		
		$fieldname = FLEXI_J16GE ? 'custom['.$field->name.']' : $field->name;
		$elementid = FLEXI_J16GE ? 'custom_'.$field->name : $field->name;
		
		// Get indexed element values
		$elements = FlexicontentFields::indexedField_getElements($field, $item, self::$extra_props);
		if ( !$elements ) {
			if ($sql_mode)
				$field->html = JText::_('FLEXI_FIELD_INVALID_QUERY');
			else
				$field->html = JText::_('FLEXI_FIELD_INVALID_ELEMENTS');
			return;
		}
		
		static $select2_added = false;
	  if ( !$select2_added )
	  {
			$select2_added = true;
			flexicontent_html::loadFramework('select2');
		}
		
		$classes  = ' use_select2_lib ';
		$classes .= $required;
		$attribs = ' class="'.$classes.'"';
		
		// Create field's HTML display for item form
		// Display as drop-down select
		$options = array();
		if ($usefirstoption) $options[] = JHTML::_('select.option', '', JText::_($firstoptiontext));
		foreach ($elements as $element) {
			$options[] = JHTML::_('select.option', $element->value, JText::_($element->text));
		}
		$field->html	= JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $field->value, $elementid);
	}
Esempio n. 2
0
 function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $option = JRequest::getVar('option');
     //initialise variables
     $db = JFactory::getDBO();
     $document = JFactory::getDocument();
     $template = $mainframe->getTemplate();
     $dispatcher = JDispatcher::getInstance();
     $rev = JRequest::getInt('version', '', 'request');
     $codemode = JRequest::getInt('codemode', 0);
     $cparams = JComponentHelper::getParams('com_flexicontent');
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadFramework('jQuery');
     JHTML::_('behavior.tooltip');
     JHTML::_('behavior.modal');
     //a trick to avoid loosing general style in modal window
     $css = 'body, td, th { font-size: 11px; } .novalue { color: gray; font-style: italic; }';
     $document->addStyleDeclaration($css);
     //Get data from the model
     $model = $this->getModel();
     $row = $this->get('Item');
     $fields = $this->get('Extrafields');
     $versions = $this->get('VersionList');
     $tparams = $this->get('Typeparams');
     // Create the type parameters
     $tparams = FLEXI_J16GE ? new JRegistry($tparams) : new JParameter($tparams);
     // Add html to field object trought plugins
     foreach ($fields as $field) {
         if ($field->value) {
             //$results = $dispatcher->trigger('onDisplayFieldValue', array( &$field, $row ));
             $fieldname = $field->iscore ? 'core' : $field->field_type;
             FLEXIUtilities::call_FC_Field_Func($fieldname, 'onDisplayFieldValue', array(&$field, $row));
         } else {
             $field->display = '<span class="novalue">' . JText::_('FLEXI_NO_VALUE') . '</span>';
         }
         if ($field->version) {
             //$results = $dispatcher->trigger('onDisplayFieldValue', array( &$field, $row, $field->version, 'displayversion' ));
             $fieldname = $field->iscore ? 'core' : $field->field_type;
             FLEXIUtilities::call_FC_Field_Func($fieldname, 'onDisplayFieldValue', array(&$field, $row, $field->version, 'displayversion'));
         } else {
             $field->displayversion = '<span class="novalue">' . JText::_('FLEXI_NO_VALUE') . '</span>';
         }
     }
     //assign data to template
     $this->assignRef('document', $document);
     $this->assignRef('row', $row);
     $this->assignRef('fields', $fields);
     $this->assignRef('versions', $versions);
     $this->assignRef('rev', $rev);
     $this->assignRef('tparams', $tparams);
     $this->assignRef('cparams', $cparams);
     $this->assignRef('codemode', $codemode);
     parent::display($tpl);
 }
Esempio n. 3
0
 function display($tpl = null)
 {
     //initialise variables
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     //$authorparams = flexicontent_db::getUserConfig($user->id);
     //add css/js to document
     flexicontent_html::loadFramework('select2');
     $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');
         }
     }
     //create the toolbar
     JToolBarHelper::title(JText::_('FLEXI_EDIT_FILE'), 'fileedit');
     JToolBarHelper::apply('filemanager.apply');
     JToolBarHelper::save('filemanager.save');
     JToolBarHelper::cancel('filemanager.cancel');
     //Get data from the model
     $model = $this->getModel();
     $form = $this->get('Form');
     $row = $this->get('File');
     // fail if checked out not by 'me'
     if ($row->id) {
         if ($model->isCheckedOut($user->get('id'))) {
             JError::raiseWarning('SOME_ERROR_CODE', $row->name . ' ' . JText::_('FLEXI_EDITED_BY_ANOTHER_ADMIN'));
             $app->redirect('index.php?option=com_flexicontent&view=filemanager');
         }
     }
     //build access level list
     $lists['access'] = JHTML::_('access.assetgrouplist', 'access', $row->access, $config = array('class' => 'use_select2_lib'));
     // Build languages list
     //$allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed',null);
     //$allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs);
     $allowed_langs = null;
     $lists['language'] = flexicontent_html::buildlanguageslist('language', ' class="use_select2_lib" ', $row->language, 2, $allowed_langs, $published_only = false);
     //clean data
     JFilterOutput::objectHTMLSafe($row, ENT_QUOTES);
     //assign data to template
     $this->assignRef('form', $form);
     $this->assignRef('row', $row);
     $this->assignRef('lists', $lists);
     $this->assignRef('document', $document);
     parent::display($tpl);
 }
Esempio n. 4
0
 $custom4 = $params->get('custom4');
 $custom5 = $params->get('custom5');
 // Create Item List Data
 $list_arr = modFlexicontentHelper::getList($params);
 // Get comments for the items (if enabled), NOTE !! TODO: modify templates and XML file so that this used
 $comments_arr = modFlexicontentHelper::getComments($params, $list_arr);
 $mod_fc_run_times['category_data_retrieval'] = $modfc_jprof->getmicrotime();
 // Get Category List Data
 $catdata_arr = modFlexicontentHelper::getCategoryData($params);
 $catdata_arr = $catdata_arr ? $catdata_arr : array(false);
 $mod_fc_run_times['category_data_retrieval'] = $modfc_jprof->getmicrotime() - $mod_fc_run_times['category_data_retrieval'];
 $mod_fc_run_times['rendering_template'] = $modfc_jprof->getmicrotime();
 // Load needed JS libs & CSS styles
 FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
 flexicontent_html::loadFramework('jQuery');
 flexicontent_html::loadFramework('flexi_tmpl_common');
 // Add tooltips
 if ($add_tooltips) {
     JHTML::_('behavior.tooltip');
 }
 // Add css
 if ($add_ccs && $layout) {
     if ($caching && !FLEXI_J16GE) {
         // Work around for caching bug in J1.5
         if (file_exists(dirname(__FILE__) . DS . 'tmpl' . DS . $layout . DS . $layout . '.css')) {
             // active layout css
             echo '<link rel="stylesheet" href="' . JURI::base(true) . '/modules/mod_flexicontent/tmpl/' . $layout . '/' . $layout . '.css">';
         }
         echo '<link rel="stylesheet" href="' . JURI::base(true) . '/modules/mod_flexicontent/tmpl_common/module.css">';
         echo '<link rel="stylesheet" href="' . JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontent.css">';
         //allow css override
Esempio n. 5
0
 function buildSelectList($field)
 {
     $db = JFactory::getDBO();
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $document = JFactory::getDocument();
     // Get configuration parameters
     $required = $field->parameters->get('required', 0);
     $required = $required ? ' required' : '';
     $autoupload = $field->parameters->get('autoupload', 1);
     $existing_imgs = $field->parameters->get('existing_imgs', 1);
     $imagepickerlimit = $field->parameters->get('imagepickerlimit', 200);
     $all_media = $field->parameters->get('list_all_media_files', 0);
     $unique_thumb_method = $field->parameters->get('unique_thumb_method', 0);
     $limit_by_uploader = $field->parameters->get('limit_by_uploader', 0);
     // USED ONLY WHEN all_media is ENABLED
     $dir = $field->parameters->get('dir');
     $dir_url = str_replace('\\', '/', $dir);
     $image_folder = JURI::root(true) . '/' . $dir_url;
     // Retrieve available (and appropriate) images from the DB
     if ($all_media) {
         $query = 'SELECT filename' . ' FROM #__flexicontent_files' . ' WHERE secure=1 AND ext IN ("jpg","gif","png","jpeg") ' . ($limit_by_uploader ? " AND uploaded_by = " . $user->id : "");
     } else {
         $query = 'SELECT value' . ' FROM #__flexicontent_fields_item_relations' . ' WHERE field_id = ' . (int) $field->id;
     }
     $db->setQuery($query);
     $values = FLEXI_J16GE ? $db->loadColumn() : $db->loadResultArray();
     // Create original filenames array skipping any empty records,
     // NOTE: if all_media is ON the we already retrieved filenames above
     if ($all_media) {
         $filenames =& $values;
     } else {
         $filenames = array();
         foreach ($values as $value) {
             if (empty($value)) {
                 continue;
             }
             $value = @unserialize($value);
             if (!isset($value['originalname'])) {
                 continue;
             }
             $filenames[] = $value['originalname'];
         }
     }
     // Eliminate duplicate records in the array
     sort($filenames);
     $filenames = array_unique($filenames);
     // Eliminate records that have no original files
     $securepath = JPath::clean(COM_FLEXICONTENT_FILEPATH . DS);
     $existing_files = array();
     foreach ($filenames as $filename) {
         $filepath = $securepath . $filename;
         if (file_exists($filepath)) {
             $existing_files[] = $filename;
         }
     }
     $filenames = $existing_files;
     $images_count = count($filenames);
     // Create attributes of the drop down field for selecting existing images
     $onchange = ' onchange="';
     $onchange .= " qmAssignFile" . $field->id . "(this.id, '', fc_db_img_path+'/s_'+this.value);";
     $onchange .= ' "';
     $classes = ' existingname no_value_selected ';
     $js = "";
     // Add Image Picker script on the document.ready event
     static $imagepicker_added = false;
     $use_imgpicker = $existing_imgs == 1 && $images_count <= $imagepickerlimit;
     if ($use_imgpicker) {
         $classes .= ' image-picker masonry show-labels show-html ';
         if (!$imagepicker_added) {
             $imagepicker_added = true;
             flexicontent_html::loadFramework('image-picker');
             $js .= "\n\t\t\t\t\tfunction fcimgfld_toggle_image_picker(obj) {\n\t\t\t\t\t\tvar has_imagepicker = jQuery(obj).parent().find('ul.image_picker_selector').length != 0;\n\t\t\t\t\t\tif (has_imagepicker) jQuery(obj).parent().find('ul.image_picker_selector').remove();\n\t\t\t\t\t\telse                 jQuery(obj).parent().find('select.image-picker').imagepicker({ hide_select:false, show_label:true })\n\t\t\t\t\t}\n\t\t\t\t\t";
         }
     }
     // Add Select2 script on the document.ready event
     static $select2_added = false;
     $classes .= ' use_select2_lib ';
     if (!$select2_added) {
         $select2_added = true;
         flexicontent_html::loadFramework('select2');
     }
     // Add custom Javascript Code
     if ($js) {
         $document->addScriptDeclaration($js);
     }
     $attribs = $onchange . " " . ' class="' . $classes . '"';
     // Populate the select field options
     $options = array();
     $options[] = $use_imgpicker ? '<option value="">' . JText::_('FLEXI_FIELD_PLEASE_SELECT') . '</option>' : JHTML::_('select.option', '', JText::_('FLEXI_FIELD_PLEASE_SELECT'));
     foreach ($filenames as $filename) {
         $options[] = $use_imgpicker ? '<option data-img-src="' . $image_folder . '/s_' . $filename . '" value="' . $filename . '">' . $filename . '</option>' : JHTML::_('select.option', $filename, $filename);
     }
     // Finally create the select field and return it
     $formfldname = '__FORMFLDNAME__';
     $formfldid = '__FORMFLDID__';
     $list = $use_imgpicker ? '<select ' . $attribs . ' name="' . $formfldname . '" id="' . $formfldid . '">' . implode("\n", $options) . '</select>' : JHTML::_('select.genericlist', $options, $formfldname, $attribs, 'value', 'text', '', $formfldid);
     if ($use_imgpicker) {
         $btn_name = JText::_('FLEXI_TOGGLE_ALL_THUMBS') . " (" . $images_count . ")";
         $list = '<input class="fcfield-button" type="button" value="' . $btn_name . '" onclick="fcimgfld_toggle_image_picker(this);" /> ' . $list;
     }
     return $list;
 }
    function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
    {
        if (!in_array($field->field_type, self::$field_types)) {
            return;
        }
        $field->label = JText::_($field->label);
        $values = $values ? $values : $field->value;
        // Load file data
        if (!$values) {
            $files_data = array();
            $values = array();
        } else {
            $files_data = $this->getFileData($values, $published = true);
            //if ($field->id==NNN) { echo "<pre>"; print_r($files_data); exit; }
            $values = array();
            foreach ($files_data as $file_id => $file_data) {
                $values[] = $file_id;
            }
        }
        $app = JFactory::getApplication();
        $document = JFactory::getDocument();
        $flexiparams = JComponentHelper::getParams('com_flexicontent');
        $mediapath = $flexiparams->get('media_path', 'components/com_flexicontent/medias');
        $usepopup = $field->parameters->get('usepopup', 1);
        $popuptype = $field->parameters->get('popuptype', 4);
        // some parameter shortcuts
        $thumbposition = $field->parameters->get('thumbposition', 3);
        $w_l = $field->parameters->get('w_l', 450);
        $h_l = $field->parameters->get('h_l', 300);
        $w_s = $field->parameters->get('w_s', 100);
        $h_s = $field->parameters->get('h_s', 66);
        switch ($thumbposition) {
            case 1:
                // top
                $marginpos = 'top';
                $marginval = $h_s;
                break;
            case 2:
                // left
                $marginpos = 'left';
                $marginval = $w_s;
                break;
            case 4:
                // right
                $marginpos = 'right';
                $marginval = $w_s;
                break;
            case 3:
            default:
                // bottom
                $marginpos = 'bottom';
                $marginval = $h_s;
                break;
        }
        $scroll_thumbnails = $field->parameters->get('scroll_thumbnails', 1);
        switch ($thumbposition) {
            case 1:
                // top
            // top
            case 3:
            default:
                // bottom
                $rows = ceil(count($values) * ($w_s + 8) / $w_l);
                // thumbnail rows
                $series = $scroll_thumbnails ? 1 : $rows;
                $series_size = ($h_s + 8) * $series;
                break;
            case 2:
                // left
            // left
            case 4:
                // right
                $cols = ceil(count($values) * ($h_s + 8) / $h_l);
                // thumbnail columns
                $series = $scroll_thumbnails ? 1 : $cols;
                $series_size = ($w_s + 8) * $series;
                break;
        }
        static $item_field_arr = null;
        static $js_and_css_added = false;
        $slideshowtype = $field->parameters->get('slideshowtype', 'Flash');
        // default is normal slideshow
        $slideshowClass = 'Slideshow';
        if (empty($values)) {
            return;
        }
        if (!$js_and_css_added) {
            $document->addStyleSheet(JURI::root(true) . '/plugins/flexicontent_fields/minigallery/css/minigallery.css');
            FLEXI_J16GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
            $document->addScript(JURI::root(true) . '/plugins/flexicontent_fields/minigallery/js/slideshow.js');
            if ($slideshowtype != 'slideshow') {
                $document->addScript(JURI::root(true) . '/plugins/flexicontent_fields/minigallery/js/slideshow.' . strtolower($slideshowtype) . '.js');
                $slideshowClass .= '.' . $slideshowtype;
            }
            // this allows you to override the default css files
            $csspath = JPATH_ROOT . '/templates/' . $app->getTemplate() . '/css/minigallery.css';
            if (file_exists($csspath)) {
                $document->addStyleSheet(JURI::root(true) . '/templates/' . $app->getTemplate() . '/css/minigallery.css');
            }
            if ($usepopup && $popuptype == 4) {
                flexicontent_html::loadFramework('fancybox');
            }
        }
        $js_and_css_added = true;
        $htmltag_id = "slideshowContainer_" . $field->name . "_" . $item->id;
        $slidethumb = "slideshowThumbnail_" . $field->name . "_" . $item->id;
        $transition = $field->parameters->get('transition', 'back');
        $t_dir = $field->parameters->get('t_dir', 'in');
        $thumbnails = $field->parameters->get('thumbnails', '1');
        $thumbnails = $thumbnails ? 'true' : 'false';
        $controller = $field->parameters->get('controller', '1');
        $controller = $controller ? 'true' : 'false';
        $otheroptions = $field->parameters->get('otheroptions', '');
        if (!isset($item_field_arr[$item->id][$field->id])) {
            $item_field_arr[$item->id][$field->id] = 1;
            $css = "\n\t\t\t#{$htmltag_id} {\n\t\t\t\twidth: " . $w_l . "px;\n\t\t\t\theight: " . $h_l . "px;\n\t\t\t\tmargin-" . $marginpos . ": " . ($marginval + 8) * $series . "px;\n\t\t\t}\n\t\t\t\t";
            if ($thumbposition == 2 || $thumbposition == 4) {
                $css .= "div .slideshow-thumbnails { " . $marginpos . ": -" . ($series_size + 4) . "px; height: 100%; width: " . ($series_size + 4) . "px; top:0px; }";
                $css .= "div .slideshow-thumbnails ul { width: " . $series_size . "px; }";
                $css .= "div .slideshow-thumbnails ul li {  }";
            } else {
                if ($thumbposition == 1 || $thumbposition == 3) {
                    $css .= "div .slideshow-thumbnails { " . $marginpos . ": -" . ($series_size + 4) . "px; height: " . $series_size . "px; }";
                    if ($series > 1) {
                        $css .= "div .slideshow-thumbnails ul { width:100%!important; }";
                    }
                    $css .= "div .slideshow-thumbnails ul li { float: left!important;}";
                } else {
                    // inside TODO
                    $css .= "div .slideshow-thumbnails { " . $marginpos . ": -" . ($marginval + 8) . "px; height: " . ($h_s + 8) . "px; top:0px; z-index:100; }";
                    $css .= "div .slideshow-thumbnails ul { width: 100%!important;}";
                    $css .= "div .slideshow-thumbnails ul li { float: left!important;}";
                }
            }
            $document->addStyleDeclaration($css);
            $otheroptions = $otheroptions ? ',' . $otheroptions : '';
            $js = "\n\t\t  \twindow.addEvent('domready',function(){\n\t\t\t\tvar options = {\n\t\t\t\t\tdelay: " . $field->parameters->get('delay', 4000) . ",\n\t\t\t\t\thu:'{$mediapath}/',\n\t\t\t\t\ttransition:'{$transition}:{$t_dir}',\n\t\t\t\t\tduration: " . $field->parameters->get('duration', 1000) . ",\n\t\t\t\t\twidth: {$w_l},\n\t\t\t\t\theight: {$h_l},\n\t\t\t\t\tthumbnails: {$thumbnails},\n\t\t\t\t\tcontroller: {$controller}\n\t\t\t\t\t{$otheroptions}\n\t\t\t\t}\n\t\t\t\tshow = new {$slideshowClass}('{$htmltag_id}', null, options);\n\t\t\t});\n\t\t\t";
            $document->addScriptDeclaration($js);
        }
        $pimages = array();
        $display = array();
        $thumbs = array();
        $usecaptions = (int) $field->parameters->get('usecaptions', 1);
        $captions = '';
        if ($usecaptions === 2) {
            $captions = htmlspecialchars($field->parameters->get('customcaptions', 'This is a caption'), ENT_COMPAT, 'UTF-8');
        }
        $group_str = 'data-fancybox-group="fcitem_' . $item->id . '_fcfield_' . $field->id . '"';
        $n = 0;
        foreach ($files_data as $file_id => $file_data) {
            if ($file_data) {
                $img_path = substr($file_data->filename, 0, 7) != 'http://' || substr($file_data->filename, 0, 8) != 'https://' ? JURI::root(true) . '/' . $mediapath . '/' . $file_data->filename : $file_data->filename;
                $srcs = JURI::root() . 'components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $img_path . '&amp;w=' . $w_s . '&amp;h=' . $h_s . '&amp;zc=1';
                $srcb = JURI::root() . 'components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $img_path . '&amp;w=' . $w_l . '&amp;h=' . $h_l . '&amp;zc=1';
                $ext = pathinfo($img_path, PATHINFO_EXTENSION);
                if (in_array($ext, array('png', 'ico', 'gif'))) {
                    $srcs .= '&amp;f=' . $ext;
                    $srcb .= '&amp;f=' . $ext;
                }
                if ($usecaptions === 1) {
                    $captions = htmlspecialchars($file_data->altname, ENT_COMPAT, 'UTF-8');
                }
                if ($usepopup && $popuptype == 4) {
                    $pimages[] = '<img src="' . $img_path . '" id="' . $htmltag_id . '_' . $n . '_popup_img" class="fc_image_thumb fancybox" ' . $group_str . ' alt="' . $captions . '" title="' . $captions . '" >';
                }
                $tag_params = $usepopup && $popuptype == 4 ? ' onclick="jQuery(\'#\' + jQuery(this).find(\'img\').last().attr(\'id\') + \'_popup_img\').trigger(\'click\'); return false;" ' : '';
                $display[] = '
					<a ' . $tag_params . ' href="javascript:;" >
						<img src="' . $srcb . '" id="' . $htmltag_id . '_' . $n . '" alt="' . $captions . '" style="border:0" itemprop="image" />
					</a>';
                $thumbs[] = '
					<li><a href="#' . $htmltag_id . '_' . $n . '"><img src="' . $srcs . '" style="border:0" itemprop="image" alt="' . $captions . '"/></a></li>';
                $n++;
            }
        }
        $field->{$prop} = '
		<div id="' . $htmltag_id . '" class="slideshow">
			<div class="slideshow-images">
				' . implode("\n", $display) . '
			</div>
			<div class="slideshow-thumbnails">
				<ul>
				' . implode("\n", $thumbs) . '
				</ul>
			</div>
		</div>
		<div class="clr"></div>
		<div class="clear"></div>
		<div id="' . $htmltag_id . '_popup_images" style="display:none;">
			' . implode("\n", $pimages) . '
		</div>';
    }
Esempio n. 7
0
    function onDisplayField(&$field, &$item)
    {
        if (!in_array($field->field_type, self::$field_types)) {
            return;
        }
        $field->label = JText::_($field->label);
        $use_ingroup = $field->parameters->get('use_ingroup', 0);
        $ajax = !empty($field->isAjax);
        if ($use_ingroup) {
            $field->formhidden = 3;
        }
        if ($use_ingroup && empty($field->ingroup) && !$ajax) {
            return;
        }
        // initialize framework objects and other variables
        $document = JFactory::getDocument();
        // some parameter shortcuts
        $sql_mode = $field->parameters->get('sql_mode', 0);
        $field_elements = $field->parameters->get('field_elements');
        $cascade_after = (int) $field->parameters->get('cascade_after', 0);
        // ****************
        // Number of values
        // ****************
        $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
        $max_values = $use_ingroup ? 0 : (int) $field->parameters->get('max_values', 0);
        $required = $field->parameters->get('required', 0);
        $required = $required ? ' required' : '';
        $add_position = (int) $field->parameters->get('add_position', 3);
        // **************
        // Value handling
        // **************
        // Default value
        $value_usage = $field->parameters->get('default_value_use', 0);
        $default_value = $item->version == 0 || $value_usage > 0 ? trim($field->parameters->get('default_value', '')) : '';
        // *************************
        // Input field configuration
        // *************************
        // DISPLAY using prettyCheckable JS
        $use_jslib = $field->parameters->get('use_jslib', 2);
        $use_prettycheckable = $use_jslib == 2;
        static $prettycheckable_added = null;
        if ($use_prettycheckable && $prettycheckable_added === null) {
            $prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable');
        }
        // Display text label, use checkbox/radio image field for more
        $form_vals_display = $field->parameters->get('form_vals_display', 1);
        // this field includes image but it can be more convenient/compact not to be display image in item form
        // when field is displayed as drop-down select (item edit form only)
        $firstoptiontext = $field->parameters->get('firstoptiontext', 'FLEXI_SELECT');
        $usefirstoption = $field->parameters->get('usefirstoption', 1);
        // Prefix - Suffix - Separator (item FORM) parameters, for the checkbox/radio elements
        $pretext = $field->parameters->get('pretext_form', '');
        $posttext = $field->parameters->get('posttext_form', '');
        $separator = $field->parameters->get('separator', 0);
        $opentag = $field->parameters->get('opentag_form', '');
        $closetag = $field->parameters->get('closetag_form', '');
        switch ($separator) {
            case 0:
                $separator = '&nbsp;';
                break;
            case 1:
                $separator = '<br />';
                break;
            case 2:
                $separator = '&nbsp;|&nbsp;';
                break;
            case 3:
                $separator = ',&nbsp;';
                break;
            case 4:
                $separator = $closetag . $opentag;
                break;
            default:
                $separator = '&nbsp;';
                break;
        }
        // Initialise property with default value
        if (!$field->value) {
            $field->value = array($default_value);
        }
        // CSS classes of value container
        $value_classes = 'fcfieldval_container valuebox fcfieldval_container_' . $field->id;
        // Field name and HTML TAG id
        $valueholder_nm = 'custom[_fcfield_valueholder_][' . $field->name . ']';
        $valueholder_id = 'custom__fcfield_valueholder__' . $field->name;
        $fieldname = 'custom[' . $field->name . ']';
        $elementid = 'custom_' . $field->name;
        $js = "";
        $css = "";
        // *********************************************************************************************
        // Handle adding the needed JS code to CASCADE (listen to) changes of the dependent master field
        // *********************************************************************************************
        if ($cascade_after && !$ajax) {
            $byIds = FlexicontentFields::indexFieldsByIds($item->fields);
            if (isset($byIds[$cascade_after])) {
                $cascade_prompt = $field->parameters->get('cascade_prompt', '');
                $cascade_prompt = $cascade_prompt ? JText::_($cascade_prompt) : JText::_('FLEXI_PLEASE_SELECT') . ': ' . $byIds[$cascade_after]->label;
                $srcELid = 'custom_' . $byIds[$cascade_after]->name;
                $trgELid = $elementid;
                // Get values of cascade (on) source field
                $field->valgrps = $byIds[$cascade_after]->value ? $byIds[$cascade_after]->value : array();
                foreach ($field->valgrps as &$vg) {
                    if (is_array($vg)) {
                    } else {
                        if (@unserialize($vg) !== false || $vg === 'b:0;') {
                            $vg = unserialize($vg);
                        } else {
                            $vg = array($vg);
                        }
                    }
                }
                unset($vg);
            } else {
                $cascade_after = 0;
                echo 'Error in field ' . $field->label . ' [' . $field->id . ']' . ' cannot cascaded after field no: ' . $cascade_after . ', field was not found <br/>';
            }
        } else {
            if ($cascade_after && $ajax) {
                $field->valgrps = isset($field->valgrps) ? $field->valgrps : array();
                $field->valgrps = is_array($field->valgrps) ? $field->valgrps : preg_split("/\\s*,\\s*/u", trim($field->valgrps));
            }
        }
        // ***********************
        // Handle multiple records
        // ***********************
        if ($multiple && !$ajax) {
            // Add the drag and drop sorting feature
            if (!$use_ingroup) {
                $js .= "\n\t\t\tjQuery(document).ready(function(){\n\t\t\t\tjQuery('#sortables_" . $field->id . "').sortable({\n\t\t\t\t\thandle: '.fcfield-drag-handle',\n\t\t\t\t\tcontainment: 'parent',\n\t\t\t\t\ttolerance: 'pointer'\n\t\t\t\t});\n\t\t\t});\n\t\t\t";
            }
            if ($max_values) {
                JText::script("FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED", true);
            }
            $js .= "\n\t\t\tvar uniqueRowNum" . $field->id . "\t= " . count($field->value) . ";  // Unique row number incremented only\n\t\t\tvar rowCount" . $field->id . "\t= " . count($field->value) . ";      // Counts existing rows to be able to limit a max number of values\n\t\t\tvar maxValues" . $field->id . " = " . $max_values . ";\n\t\t\t\n\t\t\tfunction addField" . $field->id . "(el, groupval_box, fieldval_box, params)\n\t\t\t{\n\t\t\t\tvar insert_before   = (typeof params!== 'undefined' && typeof params.insert_before   !== 'undefined') ? params.insert_before   : 0;\n\t\t\t\tvar remove_previous = (typeof params!== 'undefined' && typeof params.remove_previous !== 'undefined') ? params.remove_previous : 0;\n\t\t\t\tvar scroll_visible  = (typeof params!== 'undefined' && typeof params.scroll_visible  !== 'undefined') ? params.scroll_visible  : 1;\n\t\t\t\tvar animate_visible = (typeof params!== 'undefined' && typeof params.animate_visible !== 'undefined') ? params.animate_visible : 1;\n\t\t\t\t\n\t\t\t\tif((rowCount" . $field->id . " >= maxValues" . $field->id . ") && (maxValues" . $field->id . " != 0)) {\n\t\t\t\t\talert(Joomla.JText._('FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED') + maxValues" . $field->id . ");\n\t\t\t\t\treturn 'cancel';\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Find last container of fields and clone it to create a new container of fields\n\t\t\t\tvar lastField = fieldval_box ? fieldval_box : jQuery(el).prev().children().last();\n\t\t\t\tvar newField  = lastField.clone();\n\t\t\t\t\n\t\t\t\t// Remove HTML added by prettyCheckable JS, from the dupicate new INPUT SET\n\t\t\t\tvar prettyContainers = newField.find('.prettyradio, .prettycheckbox');\n\t\t\t\tprettyContainers.find('input, label').each(function() {\n\t\t\t\t\tvar el = jQuery(this);\n\t\t\t\t\tel.insertAfter(el.parent());\n\t\t\t\t});\n\t\t\t\tprettyContainers.remove();\n\t\t\t\t\n\t\t\t\t// Update value holder\n\t\t\t\tnewField.find('.fcfield_value_holder')\n\t\t\t\t\t.attr('id', '" . $valueholder_id . "_'+uniqueRowNum" . $field->id . ")\n\t\t\t\t\t.attr('name', '" . $valueholder_nm . "['+uniqueRowNum" . $field->id . "+']');\n\t\t\t\t\n\t\t\t\t// Update INPUT SET container id\n\t\t\t\tnewField.find('.fc_input_set').attr('id', '" . $elementid . "_'+uniqueRowNum" . $field->id . ");\n\t\t\t\tvar js_class = '" . ($use_prettycheckable && $prettycheckable_added ? ' use_prettycheckable' : '') . "';\n\t\t\t\t\n\t\t\t\t// Update the new INPUT SET\n\t\t\t\tvar theSet = newField.find('input:radio, input:checkbox');\n\t\t\t\t//if(window.console) window.console.log('theSet.length: ' + theSet.length);\n\t\t\t\tvar nr = 0;\n\t\t\t\ttheSet.each(function() {\n\t\t\t\t\tvar elem = jQuery(this);\n\t\t\t\t\telem.attr('name', '" . $fieldname . "['+uniqueRowNum" . $field->id . "+']" . (self::$valueIsArr ? '[]' : '') . "');\n\t\t\t\t\telem.attr('id', '" . $elementid . "_'+uniqueRowNum" . $field->id . "+'_'+nr);\n\t\t\t\t\telem.attr('class', '" . $elementid . "_'+uniqueRowNum" . $field->id . " + js_class);\n\t\t\t\t\telem.removeAttr('checked');\n\t\t\t\t\t" . ($use_prettycheckable && $prettycheckable_added ? "elem.attr('data-element-grpid', '" . $elementid . "_'+uniqueRowNum" . $field->id . ");" : "elem.attr('data-element-grpid', '" . $elementid . "_'+uniqueRowNum" . $field->id . ");") . "\n\t\t\t\t\t" . ($use_prettycheckable && $prettycheckable_added ? "elem.prev('label').attr('for', '" . $elementid . "_'+uniqueRowNum" . $field->id . "+'_'+nr);" : "elem.next('label').attr('for', '" . $elementid . "_'+uniqueRowNum" . $field->id . "+'_'+nr);") . "\n\t\t\t\t\tnr++;\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\t// Reapply prettyCheckable JS \n\t\t\t\tnewField.find('.use_prettycheckable').each(function() {\n\t\t\t\t\tvar elem = jQuery(this);\n\t\t\t\t\tvar lbl = elem.prev('label');\n\t\t\t\t\tvar lbl_html = lbl.html();\n\t\t\t\t\tlbl.remove();\n\t\t\t\t\telem.prettyCheckable({ label: lbl_html });\n\t\t\t\t});\n\t\t\t\t";
            // Add new field to DOM
            $js .= "\n\t\t\t\tlastField ?\n\t\t\t\t\t(insert_before ? newField.insertBefore( lastField ) : newField.insertAfter( lastField ) ) :\n\t\t\t\t\tnewField.appendTo( jQuery('#sortables_" . $field->id . "') ) ;\n\t\t\t\tif (remove_previous) lastField.remove();\n\t\t\t\t";
            // Listen to the changes of cascade-after field
            if ($cascade_after) {
                $js .= "\n\t\t\t\tfc_cascade_field_funcs['" . $srcELid . "_'+uniqueRowNum" . $field->id . "] = function(rowNo){\n\t\t\t\t\treturn function () {\n\t\t\t\t\t\tfcCascadedField(" . $field->id . ", '" . $item->id . "', '" . $field->field_type . "', 'select#" . $srcELid . "_'+rowNo+', input." . $srcELid . "_'+rowNo, '" . $trgELid . "_'+rowNo, '" . $cascade_prompt . "', " . self::$promptEnabled . ", rowNo);\n\t\t\t\t\t}\n\t\t\t\t}(uniqueRowNum" . $field->id . ");\n\t\t\t\tfc_cascade_field_funcs['" . $srcELid . "_'+uniqueRowNum" . $field->id . "]();\n\t\t\t\t";
            }
            // Add new element to sortable objects (if field not in group)
            if (!$use_ingroup) {
                $js .= "\n\t\t\t\t//jQuery('#sortables_" . $field->id . "').sortable('refresh');  // Refresh was done appendTo ?\n\t\t\t\t";
            }
            // Show new field, increment counters
            $js .= "\n\t\t\t\t//newField.fadeOut({ duration: 400, easing: 'swing' }).fadeIn({ duration: 200, easing: 'swing' });\n\t\t\t\tif (scroll_visible) fc_scrollIntoView(newField, 1);\n\t\t\t\tif (animate_visible) newField.css({opacity: 0.1}).animate({ opacity: 1 }, 800);\n\t\t\t\t\n\t\t\t\t// Enable tooltips on new element\n\t\t\t\tnewField.find('.hasTooltip').tooltip({'html': true,'container': newField});\n\t\t\t\t\n\t\t\t\trowCount" . $field->id . "++;       // incremented / decremented\n\t\t\t\tuniqueRowNum" . $field->id . "++;   // incremented only\n\t\t\t}\n\n\t\t\tfunction deleteField" . $field->id . "(el, groupval_box, fieldval_box)\n\t\t\t{\n\t\t\t\t// Find field value container\n\t\t\t\tvar row = fieldval_box ? fieldval_box : jQuery(el).closest('li');\n\t\t\t\t\n\t\t\t\t// Add empty container if last element, instantly removing the given field value container\n\t\t\t\tif(rowCount" . $field->id . " == 1)\n\t\t\t\t\taddField" . $field->id . "(null, groupval_box, row, {remove_previous: 1, scroll_visible: 0, animate_visible: 0});\n\t\t\t\t\n\t\t\t\t// Remove if not last one, if it is last one, we issued a replace (copy,empty new,delete old) above\n\t\t\t\tif(rowCount" . $field->id . " > 1) {\n\t\t\t\t\t// Destroy the remove/add/etc buttons, so that they are not reclicked, while we do the hide effect (before DOM removal of field value)\n\t\t\t\t\trow.find('.fcfield-delvalue').remove();\n\t\t\t\t\trow.find('.fcfield-insertvalue').remove();\n\t\t\t\t\trow.find('.fcfield-drag-handle').remove();\n\t\t\t\t\t// Do hide effect then remove from DOM\n\t\t\t\t\trow.slideUp(400, function(){ jQuery(this).remove(); });\n\t\t\t\t\trowCount" . $field->id . "--;\n\t\t\t\t}\n\t\t\t}\n\t\t\t";
            $css .= '';
            $remove_button = '<span class="fcfield-delvalue' . (JComponentHelper::getParams('com_flexicontent')->get('form_font_icons', 1) ? ' fcfont-icon' : '') . '" title="' . JText::_('FLEXI_REMOVE_VALUE') . '" onclick="deleteField' . $field->id . '(this);"></span>';
            $move2 = '<span class="fcfield-drag-handle' . (JComponentHelper::getParams('com_flexicontent')->get('form_font_icons', 1) ? ' fcfont-icon' : '') . '" title="' . JText::_('FLEXI_CLICK_TO_DRAG') . '"></span>';
            $add_here = '';
            $add_here .= $add_position == 2 || $add_position == 3 ? '<span class="fcfield-insertvalue fc_before' . (JComponentHelper::getParams('com_flexicontent')->get('form_font_icons', 1) ? ' fcfont-icon' : '') . '" onclick="addField' . $field->id . '(null, jQuery(this).closest(\'ul\'), jQuery(this).closest(\'li\'), {insert_before: 1});" title="' . JText::_('FLEXI_ADD_BEFORE') . '"></span> ' : '';
            $add_here .= $add_position == 1 || $add_position == 3 ? '<span class="fcfield-insertvalue fc_after' . (JComponentHelper::getParams('com_flexicontent')->get('form_font_icons', 1) ? ' fcfont-icon' : '') . '"  onclick="addField' . $field->id . '(null, jQuery(this).closest(\'ul\'), jQuery(this).closest(\'li\'), {insert_before: 0});" title="' . JText::_('FLEXI_ADD_AFTER') . '"></span> ' : '';
        } else {
            $remove_button = '';
            $move2 = '';
            $add_here = '';
            $js .= '';
            $css .= '';
        }
        // Added field's custom CSS / JS
        if (!$ajax && $js) {
            $document->addScriptDeclaration($js);
        }
        if (!$ajax && $css) {
            $document->addStyleDeclaration($css);
        }
        // **************************
        // Get indexed element values
        // **************************
        // If cascading we will get it inside the value loop for every value, thus supporting field grouping properly
        $elements = !$cascade_after ? $this->getLimitedProps($field, $item) : array();
        if (!is_array($elements)) {
            $field->html = $elements;
            return;
        }
        // *****************************************
        // Create field's HTML display for item form
        // *****************************************
        // Alternative form field display as drop-down select to save space
        if ($field->parameters->get('display_as_select', 0)) {
            $options = array();
            if ($usefirstoption) {
                $options[] = JHTML::_('select.option', '', JText::_($firstoptiontext));
            }
            foreach ($elements as $element) {
                $options[] = JHTML::_('select.option', $element->value, $element->text);
            }
            $field->html = JHTML::_('select.genericlist', $options, $fieldname, 'class="' . $required . '"', 'value', 'text', $field->value, $elementid);
            return;
        }
        // Create the attributes of the form field
        $fftype = 'radio';
        $display_as_radioset = 1;
        if ($display_as_radioset) {
            $classes = $use_prettycheckable && $prettycheckable_added ? ' use_prettycheckable ' : '';
            $classes .= $required;
            $onchange = '';
            // Extra properties
            $attribs = '';
            if ($required) {
                $classes .= ' validate-radio ';
            }
            // if required then set appropriate validate-* CSS class (*=handler name)
            if ($onchange) {
                $attribs .= ' onchange="' . $onchange . '" ';
            }
        }
        $label_class = 'fccheckradio_lbl' . (FLEXI_J30GE ? ' hasTooltip' : ' hasTip');
        $label_style = 'vertical-align: unset!important;';
        // Handle case of FORM fields that each value is an array of values
        // (e.g. selectmultiple, checkbox), and that multi-value input is also enabled
        $is_array_already = is_array($field->value) ? is_array(reset($field->value)) : false;
        $values = self::$valueIsArr && !$multiple && !$is_array_already ? array($field->value) : $field->value;
        // *****************************************
        // Create field's HTML display for item form
        // *****************************************
        $field->html = array();
        $n = $ajax ? $field->valindex : 0;
        $per_val_js = '';
        foreach ($values as $value) {
            // Compatibility for serialized values
            if (self::$valueIsArr) {
                if (is_array($value)) {
                } else {
                    if (@unserialize($value) !== false || $value === 'b:0;') {
                        $value = unserialize($value);
                    }
                }
            }
            // Make sure value is an array
            if (!is_array($value)) {
                $value = strlen($value) ? array($value) : array();
            }
            // Skip empty if not in field group, and at least one value was added
            if (!count($value) && !$use_ingroup && $n) {
                continue;
            }
            // Get options according to cascading, this is here so that it works with field grouping too
            if ($cascade_after) {
                $elements = $this->getLimitedProps($field, $item, !$ajax ? $cascade_prompt : null, $ajax, $n);
            }
            if (1) {
                $fieldname_n = $fieldname . '[' . $n . ']' . (self::$valueIsArr ? '[]' : '');
                $elementid_n = $elementid . '_' . $n;
                // Create form field options
                $i = 0;
                $options = array();
                foreach ($elements as $element) {
                    if (!empty($element->isprompt)) {
                        $options[] = '<span style="float: left;" class="' . $element->isprompt . '">' . $element->text . '</span>';
                        continue;
                    }
                    $checked = in_array($element->value, $value) ? ' checked="checked"' : '';
                    $elementid_no = $elementid_n . '_' . $i;
                    //echo " &nbsp; &nbsp; $elementid_n , $elementid_no , $fieldname_n  , &nbsp; value: {$element->value} <br/>\n";
                    $input_attribs = $use_prettycheckable && $prettycheckable_added ? ' data-customClass="fcradiocheckimage"' : '';
                    $input_attribs .= ' class="' . @$classes . ' ' . $elementid_n . '" ';
                    $input_fld = ' <input type="' . $fftype . '" id="' . $elementid_no . '" data-element-grpid="' . $elementid_n . '" name="' . $fieldname_n . '" ' . $attribs . $input_attribs . ' value="' . $element->value . '" ' . $checked . ' />';
                    $options[] = '' . $pretext . ($use_prettycheckable && $prettycheckable_added ? $input_fld : '') . '<label for="' . $elementid_no . '" class="' . $label_class . '" style="' . $label_style . '" title="' . $element->label_tip . '">' . (!$use_prettycheckable || !$prettycheckable_added ? $input_fld : '') . ($form_vals_display != 1 ? $element->text : '') . ($form_vals_display == 2 ? ' <br/>' : '') . ($form_vals_display > 0 ? $element->image_html : '') . '</label>' . $posttext;
                    $i++;
                }
                // Apply (item form) separator and open/close tags to create the radio field
                $form_field = $opentag . implode($separator, $options) . $closetag;
            }
            if (!$ajax) {
                $field->html[] = '
					' . '<div id="' . $elementid_n . '" class="fc_input_set">' . $form_field . '</div>
					' . ($cascade_after ? '<span class="field_cascade_loading"></span>' : '') . '
					' . ($use_ingroup ? '<input type="hidden" class="fcfield_value_holder" name="' . $valueholder_nm . '[' . $n . ']" id="' . $valueholder_id . '_' . $n . '" value="-">' : '') . '
					' . ($use_ingroup ? '' : $move2) . '
					' . ($use_ingroup ? '' : $remove_button) . '
					' . ($use_ingroup || !$add_position ? '' : $add_here) . '
					';
                // Listen to the changes of cascade-after field
                if ($cascade_after && !$ajax) {
                    $per_val_js .= "\n\t\t\t\t\tfc_cascade_field_funcs['" . $srcELid . '_' . $n . "'] = function(){\n\t\t\t\t\t\tfcCascadedField(" . $field->id . ", '" . $item->id . "', '" . $field->field_type . "', 'select#" . $srcELid . '_' . $n . ", input." . $srcELid . '_' . $n . "', '" . $trgELid . '_' . $n . "', '" . $cascade_prompt . "', " . self::$promptEnabled . ", " . $n . ");\n\t\t\t\t\t}\n\t\t\t\t\tfc_cascade_field_funcs['" . $srcELid . '_' . $n . "']();\n\t\t\t\t";
                }
            } else {
                $field->html = $form_field;
            }
            $n++;
            if (!$multiple) {
                break;
            }
            // multiple values disabled, break out of the loop, not adding further values even if the exist
        }
        if ($per_val_js) {
            $document->addScriptDeclaration('
				jQuery(document).ready(function(){
					' . $per_val_js . '
				});
			');
        }
        if ($ajax) {
            return;
            // Done
        } else {
            if ($use_ingroup) {
                // do not convert the array to string if field is in a group
            } else {
                if ($multiple) {
                    // handle multiple records
                    $field->html = !count($field->html) ? '' : '<li class="' . $value_classes . '">' . implode('</li><li class="' . $value_classes . '">', $field->html) . '</li>';
                    $field->html = '<ul class="fcfield-sortables" id="sortables_' . $field->id . '">' . $field->html . '</ul>';
                    if (!$add_position) {
                        $field->html .= '<span class="fcfield-addvalue ' . (JComponentHelper::getParams('com_flexicontent')->get('form_font_icons', 1) ? ' fcfont-icon' : '') . '" onclick="addField' . $field->id . '(this);" title="' . JText::_('FLEXI_ADD_TO_BOTTOM') . '">' . JText::_('FLEXI_ADD_VALUE') . '</span>';
                    }
                } else {
                    // handle single values
                    $field->html = '<div class="fcfieldval_container valuebox fcfieldval_container_' . $field->id . '">' . $field->html[0] . '</div>';
                }
            }
        }
    }
Esempio n. 8
0
    function display($tpl = null)
    {
        //initialise variables
        $app = JFactory::getApplication();
        $option = JRequest::getVar('option');
        $document = JFactory::getDocument();
        $cparams = JComponentHelper::getParams('com_flexicontent');
        $user = JFactory::getUser();
        //add css to document
        $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VHASH);
        $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VHASH);
        // Add JS frameworks
        flexicontent_html::loadFramework('select2');
        // Add js function to overload the joomla submitform validation
        JHTML::_('behavior.formvalidation');
        // load default validation JS to make sure it is overriden
        $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VHASH);
        $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VHASH);
        //Load pane behavior
        jimport('joomla.html.pane');
        //Import File system
        jimport('joomla.filesystem.file');
        //Get data from the model
        $model = $this->getModel();
        $row = $this->get('Field');
        $form = $this->get('Form');
        $types = $this->get('Typeslist');
        $typesselected = $this->get('Typesselected');
        //create the toolbar
        if ($row->id) {
            JToolBarHelper::title(JText::_('FLEXI_EDIT_FIELD'), 'fieldedit');
        } else {
            JToolBarHelper::title(JText::_('FLEXI_ADD_FIELD'), 'fieldadd');
        }
        $ctrl = FLEXI_J16GE ? 'fields.' : '';
        JToolBarHelper::apply($ctrl . 'apply');
        JToolBarHelper::save($ctrl . 'save');
        JToolBarHelper::custom($ctrl . 'saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false);
        JToolBarHelper::cancel($ctrl . 'cancel');
        // Import Joomla plugin that implements the type of current flexi field
        $extfolder = 'flexicontent_fields';
        $extname = $row->iscore ? 'core' : $row->field_type;
        JPluginHelper::importPlugin('flexicontent_fields', $row->iscore ? 'core' : $row->field_type);
        // Create class name of the plugin and then create a plugin instance
        $classname = 'plg' . ucfirst($extfolder) . $extname;
        // Check max allowed version
        if (property_exists($classname, 'prior_to_version')) {
            // Set a system message with warning of failed PHP limits
            $prior_to_version = $app->getUserStateFromRequest($option . '.flexicontent.prior_to_version_' . $row->field_type, 'prior_to_version_' . $row->field_type, 0, 'int');
            $app->setUserState($option . '.flexicontent.prior_to_version_' . $row->field_type, $prior_to_version + 1);
            if ($prior_to_version < 2) {
                $close_btn = FLEXI_J30GE ? '<a class="close" data-dismiss="alert">&#215;</a>' : '<a class="fc-close" onclick="this.parentNode.parentNode.removeChild(this.parentNode);">&#215;</a>';
                $manifest_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'manifest.xml';
                $com_xml = JApplicationHelper::parseXMLInstallFile($manifest_path);
                $ver_exceeded = version_compare(str_replace(' ', '.', $com_xml['version']), str_replace(' ', '.', $classname::$prior_to_version), '>=');
                if ($ver_exceeded) {
                    echo '
					<span class="fc-note fc-mssg-inline">
						' . $close_btn . '
						Warning: installed version of Field: \'<b>' . $extname . '</b>\' was given to be free for FLEXIcontent versions prior to: v' . $classname::$prior_to_version . ' <br/> It may or may not work properly in later versions
					</span>';
                } else {
                    echo '
					<span class="fc-info fc-mssg-inline">
						' . $close_btn . '
						Note: installed version of Field: \'<b>' . $extname . '</b>\' is given free for FLEXIcontent versions prior to: v' . $classname::$prior_to_version . ', &nbsp; &nbsp; nevertheless it will continue to function after FLEXIcontent is upgraded.
					</span>';
                }
            }
        }
        // load plugin's english language file then override with current language file
        $extension_name = 'plg_flexicontent_fields_' . ($row->iscore ? 'core' : $row->field_type);
        JFactory::getLanguage()->load($extension_name, JPATH_ADMINISTRATOR, 'en-GB', true);
        JFactory::getLanguage()->load($extension_name, JPATH_ADMINISTRATOR, null, true);
        //check which properties are supported by current field
        $ft_support = FlexicontentFields::getPropertySupport($row->field_type, $row->iscore);
        $supportsearch = $ft_support->supportsearch;
        $supportadvsearch = $ft_support->supportadvsearch;
        $supportfilter = $ft_support->supportfilter;
        $supportadvfilter = $ft_support->supportadvfilter;
        $supportuntranslatable = $ft_support->supportuntranslatable;
        $supportvalueseditable = $ft_support->supportvalueseditable;
        $supportformhidden = $ft_support->supportformhidden;
        $supportedithelp = $ft_support->supportedithelp;
        //build selectlists, (for J1.6+ most of these are defined via XML file and custom form field classes)
        $lists = array();
        //build field_type list
        if (!$row->field_type) {
            $row->field_type = 'text';
        }
        $_attribs = ' class="use_select2_lib fc_skip_highlight" ';
        if ($row->iscore == 1) {
            $_attribs .= ' disabled="disabled" ';
        } else {
            $_field_id = 'jform_field_type';
            $_row_id = $form->getValue("id");
            $_ctrl_task = 'task=fields.getfieldspecificproperties';
            $document->addScriptDeclaration("\n\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\tjQuery('#" . $_field_id . "').on('change', function() {\n\t\t\t\t\t\tjQuery('#fieldspecificproperties').html('<p class=\"centerimg\"><img src=\"components/com_flexicontent/assets/images/ajax-loader.gif\" align=\"center\"></p>');\n\t\t\t\t\t\tjQuery.ajax({\n\t\t\t\t\t\t\ttype: \"GET\",\n\t\t\t\t\t\t\turl: 'index.php?option=com_flexicontent&" . $_ctrl_task . "&cid=" . $_row_id . "&field_type='+this.value+'&format=raw',\n\t\t\t\t\t\t\tsuccess: function(str) {\n\t\t\t\t\t\t\t\tjQuery('#fieldspecificproperties').html(str);\n\t\t\t\t\t\t\t\t" . (FLEXI_J30GE ? "\n\t\t\t\t\t\t\t\t\tjQuery('.hasTooltip').tooltip({'html': true,'container': jQuery('#fieldspecificproperties')});\n\t\t\t\t\t\t\t\t" : "\n\t\t\t\t\t\t\t\tvar tipped_elements = jQuery('#fieldspecificproperties .hasTip');\n\t\t\t\t\t\t\t\ttipped_elements.each(function() {\n\t\t\t\t\t\t\t\t\tvar title = this.get('title');\n\t\t\t\t\t\t\t\t\tif (title) {\n\t\t\t\t\t\t\t\t\t\tvar parts = title.split('::', 2);\n\t\t\t\t\t\t\t\t\t\tthis.store('tip:title', parts[0]);\n\t\t\t\t\t\t\t\t\t\tthis.store('tip:text', parts[1]);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tvar ajax_JTooltips = new Tips(\$('fieldspecificproperties').getElements('.hasTip'), { maxTitleChars: 50, fixed: false});\n\t\t\t\t\t\t\t\t") . "\n\t\t\t\t\t\t\t\ttabberAutomatic(tabberOptions, 'fieldspecificproperties');\n\t\t\t\t\t\t\t\tfc_bindFormDependencies('#fieldspecificproperties', 0, '');\n\t\t\t\t\t\t\t\tjQuery('#field_typename').html(jQuery('#" . $_field_id . "').val());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t");
        }
        //build field select list
        $fieldtypes = flexicontent_db::getFieldTypes($_grouped = true, $_usage = false, $_published = true);
        $fftypes = array();
        foreach ($fieldtypes as $field_group => $ft_types) {
            $fftypes[] = $field_group;
            foreach ($ft_types as $field_type => $ftdata) {
                $fftypes[] = array('value' => $ftdata->field_type, 'text' => $ftdata->friendly);
            }
            $fftypes[] = '';
        }
        $lists['field_type'] = flexicontent_html::buildfieldtypeslist($fftypes, 'jform[field_type]', $row->field_type, $_grouped ? 1 : 0, $_attribs);
        //build type select list
        $attribs = 'class="use_select2_lib" multiple="multiple" size="6"';
        $attribs .= $row->iscore ? ' disabled="disabled"' : '';
        $types_fieldname = FLEXI_J16GE ? 'jform[tid][]' : 'tid[]';
        $lists['tid'] = flexicontent_html::buildtypesselect($types, $types_fieldname, $typesselected, false, $attribs);
        // **************************************************************************
        // Create fields for J1.5 (J2.5+ uses JForm XML file for most of form fields)
        // **************************************************************************
        if (!FLEXI_J16GE) {
            //build formhidden selector
            $formhidden[] = JHTML::_('select.option', 0, JText::_('FLEXI_NO'));
            $formhidden[] = JHTML::_('select.option', 1, JText::_('FLEXI_FRONTEND'));
            $formhidden[] = JHTML::_('select.option', 2, JText::_('FLEXI_BACKEND'));
            $formhidden[] = JHTML::_('select.option', 3, JText::_('FLEXI_BOTH'));
            $formhidden_fieldname = FLEXI_J16GE ? 'jform[formhidden]' : 'formhidden';
            $lists['formhidden'] = JHTML::_('select.radiolist', $formhidden, $formhidden_fieldname, '', 'value', 'text', $row->formhidden);
            if (FLEXI_ACCESS) {
                $valueseditable[] = JHTML::_('select.option', 0, JText::_('FLEXI_ANY_EDITOR'));
                $valueseditable[] = JHTML::_('select.option', 1, JText::_('FLEXI_USE_ACL_PERMISSION'));
                $valueseditable_fieldname = FLEXI_J16GE ? 'jform[valueseditable]' : 'valueseditable';
                $lists['valueseditable'] = JHTML::_('select.radiolist', $valueseditable, $valueseditable_fieldname, '', 'value', 'text', $row->valueseditable);
            }
            $edithelp[] = JHTML::_('select.option', 0, JText::_('FLEXI_EDIT_HELP_NONE'));
            $edithelp[] = JHTML::_('select.option', 1, JText::_('FLEXI_EDIT_HELP_LABEL_TOOLTIP'));
            $edithelp[] = JHTML::_('select.option', 2, JText::_('FLEXI_EDIT_HELP_LABEL_TOOLTIP_WICON'));
            $edithelp[] = JHTML::_('select.option', 3, JText::_('FLEXI_EDIT_HELP_INLINE'));
            $edithelp_fieldname = FLEXI_J16GE ? 'jform[edithelp]' : 'edithelp';
            $lists['edithelp'] = JHTML::_('select.radiolist', $edithelp, $edithelp_fieldname, '', 'value', 'text', $row->edithelp);
            // build the html select list for ordering
            $query = 'SELECT ordering AS value, label AS text' . ' FROM #__flexicontent_fields' . ' WHERE published >= 0' . ' ORDER BY ordering';
            $row->ordering = @$row->ordering;
            $lists['ordering'] = $row->id ? JHTML::_('list.specificordering', $row, $row->id, $query) : JHTML::_('list.specificordering', $row, '', $query);
            //build access level list
            if (FLEXI_ACCESS) {
                $lang = JFactory::getLanguage();
                $lang->_strings['FLEXIACCESS_PADD'] = 'Edit-Value';
                $lists['access'] = FAccess::TabGmaccess($row, 'field', 1, 1, 0, 1, 0, 1, 0, 1, 1);
            } else {
                $lists['access'] = JHTML::_('list.accesslevel', $row);
            }
        }
        if (!FLEXI_J16GE) {
            // Create the parameter 's form object parsing the file XML
            $pluginpath = JPATH_PLUGINS . DS . 'flexicontent_fields' . DS . $row->field_type . '.xml';
            if (JFile::exists($pluginpath)) {
                $form = new JParameter('', $pluginpath);
            } else {
                $form = new JParameter('', JPATH_PLUGINS . DS . 'flexicontent_fields' . DS . 'core.xml');
            }
            // Special and Core Groups
            $form->loadINI($row->attribs);
        }
        // fail if checked out not by 'me'
        if ($row->id) {
            if ($model->isCheckedOut($user->get('id'))) {
                JError::raiseWarning('SOME_ERROR_CODE', $row->name . ' ' . JText::_('FLEXI_EDITED_BY_ANOTHER_ADMIN'));
                $app->redirect('index.php?option=com_flexicontent&view=fields');
            }
        }
        //clean data
        JFilterOutput::objectHTMLSafe($row, ENT_QUOTES);
        // assign permissions for J2.5
        $permission = FlexicontentHelperPerm::getPerm();
        $this->assignRef('permission', $permission);
        //assign data to template
        $this->assignRef('document', $document);
        $this->assignRef('row', $row);
        $this->assignRef('lists', $lists);
        $this->assignRef('form', $form);
        $this->assignRef('typesselected', $typesselected);
        $this->assignRef('supportsearch', $supportsearch);
        $this->assignRef('supportadvsearch', $supportadvsearch);
        $this->assignRef('supportfilter', $supportfilter);
        $this->assignRef('supportadvfilter', $supportadvfilter);
        $this->assignRef('supportuntranslatable', $supportuntranslatable);
        $this->assignRef('supportvalueseditable', $supportvalueseditable);
        $this->assignRef('supportformhidden', $supportformhidden);
        $this->assignRef('supportedithelp', $supportedithelp);
        parent::display($tpl);
    }
Esempio n. 9
0
 /**
  * Creates the Entrypage
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     //initialise variables
     $app = JFactory::getApplication();
     $cparams = JComponentHelper::getParams('com_flexicontent');
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     $document = JFactory::getDocument();
     $option = JRequest::getVar('option');
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadFramework('jQuery');
     flexicontent_html::loadFramework('select2');
     JHTML::_('behavior.tooltip');
     //get vars
     $filter_assigned = $app->getUserStateFromRequest($option . '.fields.filter_assigned', 'filter_assigned', '', 'word');
     $filter_fieldtype = $app->getUserStateFromRequest($option . '.fields.filter_fieldtype', 'filter_fieldtype', '', 'word');
     $filter_state = $app->getUserStateFromRequest($option . '.fields.filter_state', 'filter_state', '', 'word');
     $filter_type = $app->getUserStateFromRequest($option . '.fields.filter_type', 'filter_type', '', 'int');
     $filter_order = $app->getUserStateFromRequest($option . '.fields.filter_order', 'filter_order', 't.ordering', 'cmd');
     if ($filter_type && $filter_order == 't.ordering') {
         $filter_order = $app->setUserState($option . '.fields.filter_order', 'typeordering');
     } else {
         if (!$filter_type && $filter_order == 'typeordering') {
             $filter_order = $app->setUserState($option . '.fields.filter_order', 't.ordering');
         }
     }
     $filter_order_Dir = $app->getUserStateFromRequest($option . '.fields.filter_order_Dir', 'filter_order_Dir', 'ASC', 'word');
     $search = $app->getUserStateFromRequest($option . '.fields.search', 'search', '', 'string');
     $search = FLEXI_J16GE ? $db->escape(trim(JString::strtolower($search))) : $db->getEscaped(trim(JString::strtolower($search)));
     if ($cparams->get('show_usability_messages', 1)) {
         $notice_content_type_order = $app->getUserStateFromRequest($option . '.fields.notice_content_type_order', 'notice_content_type_order', 0, 'int');
         if (!$notice_content_type_order) {
             $app->setUserState($option . '.fields.notice_content_type_order', 1);
             $app->enqueueMessage(JText::_('FLEXI_DEFINE_FIELD_ORDER_FILTER_BY_TYPE'), 'notice');
             $app->enqueueMessage(JText::_('FLEXI_DEFINE_FIELD_ORDER_FILTER_WITHOUT_TYPE'), 'notice');
             $app->enqueueMessage(JText::_('FLEXI_USABILITY_MESSAGES_TURN_OFF'), 'message');
         }
     }
     //add css and submenu to document
     $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css');
     if (FLEXI_J30GE) {
         $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css');
     } else {
         if (FLEXI_J16GE) {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css');
         } else {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css');
         }
     }
     $document->addScript(JURI::base() . 'components/com_flexicontent/assets/js/flexi-lib.js');
     // Get User's Global Permissions
     $perms = FlexicontentHelperPerm::getPerm();
     // Create Submenu and check access
     FLEXISubmenu('CanFields');
     // Create document/toolbar titles
     $doc_title = JText::_('FLEXI_FIELDS');
     $site_title = $document->getTitle();
     JToolBarHelper::title($doc_title, 'fields');
     $document->setTitle($doc_title . ' - ' . $site_title);
     // Create the toolbar
     $contrl = FLEXI_J16GE ? "fields." : "";
     if ($perms->CanCopyFields) {
         JToolBarHelper::custom($contrl . 'copy', 'copy.png', 'copy_f2.png', 'FLEXI_COPY');
         JToolBarHelper::custom($contrl . 'copy_wvalues', 'copy_wvalues.png', 'copy_f2.png', 'FLEXI_COPY_WITH_VALUES');
         JToolBarHelper::divider();
     }
     JToolBarHelper::publishList($contrl . 'publish');
     JToolBarHelper::unpublishList($contrl . 'unpublish');
     if ($perms->CanAddField) {
         JToolBarHelper::addNew($contrl . 'add');
     }
     if ($perms->CanEditField) {
         JToolBarHelper::editList($contrl . 'edit');
     }
     if ($perms->CanDeleteField) {
         //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove');
         // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag)
         $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE'));
         $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM');
         $btn_task = $contrl . 'remove';
         $extra_js = "";
         flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true);
     }
     JToolBarHelper::divider();
     JToolBarHelper::spacer();
     $toggle_icon = 'basicindex';
     $btn_task = FLEXI_J16GE ? 'fields.toggleprop' : 'toggleprop';
     $extra_js = "document.getElementById('adminForm').elements['propname'].value='issearch';";
     flexicontent_html::addToolBarButton('FLEXI_TOGGLE_TEXT_SEARCHABLE', $toggle_icon, $full_js = '', $msg_alert = JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm = '', $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = false);
     $toggle_icon = 'basicfilter';
     $btn_task = FLEXI_J16GE ? 'fields.toggleprop' : 'toggleprop';
     $extra_js = "document.getElementById('adminForm').elements['propname'].value='isfilter';";
     flexicontent_html::addToolBarButton('FLEXI_TOGGLE_FILTERABLE', $toggle_icon, $full_js = '', $msg_alert = JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm = '', $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = false);
     $toggle_icon = 'advindex';
     $btn_task = FLEXI_J16GE ? 'fields.toggleprop' : 'toggleprop';
     $extra_js = "document.getElementById('adminForm').elements['propname'].value='isadvsearch';";
     flexicontent_html::addToolBarButton('FLEXI_TOGGLE_ADV_TEXT_SEARCHABLE', $toggle_icon, $full_js = '', $msg_alert = JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm = '', $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = false);
     $toggle_icon = 'advfilter';
     $btn_task = FLEXI_J16GE ? 'fields.toggleprop' : 'toggleprop';
     $extra_js = "document.getElementById('adminForm').elements['propname'].value='isadvfilter';";
     flexicontent_html::addToolBarButton('FLEXI_TOGGLE_ADV_FILTERABLE', $toggle_icon, $full_js = '', $msg_alert = JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm = '', $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = false);
     if ($perms->CanConfig) {
         JToolBarHelper::divider();
         JToolBarHelper::spacer();
         $session = JFactory::getSession();
         $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent');
         $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940;
         $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent');
         $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550;
         JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration');
     }
     //Get data from the model
     $model = $this->getModel();
     $rows = $this->get(FLEXI_J16GE ? 'Items' : 'Data');
     $pagination = $this->get('Pagination');
     $types = $this->get('Typeslist');
     $fieldtypes = $model->getFieldtypes($fields_in_groups = true);
     $lists = array();
     //build backend visible filter
     $ALL = mb_strtoupper(JText::_('FLEXI_ALL'), 'UTF-8') . ' : ';
     $fftype = array();
     $fftype[] = JHTML::_('select.option', '', '- ' . JText::_('FLEXI_ALL_FIELDS_TYPE') . ' -');
     $fftype[] = JHTML::_('select.option', 'BV', $ALL . JText::_('FLEXI_BACKEND_FIELDS'));
     $fftype[] = JHTML::_('select.option', 'C', $ALL . JText::_('FLEXI_CORE_FIELDS'));
     $fftype[] = JHTML::_('select.option', 'NC', $ALL . JText::_('FLEXI_NON_CORE_FIELDS'));
     foreach ($fieldtypes as $field_group => $ft_types) {
         $fftype[] = JHTML::_('select.optgroup', $field_group);
         foreach ($ft_types as $field_type => $ftdata) {
             $field_friendlyname = str_ireplace("FLEXIcontent - ", "", $ftdata->field_friendlyname);
             $fftype[] = JHTML::_('select.option', $field_type, '-' . $ftdata->assigned . '- ' . $field_friendlyname);
         }
         $fftype[] = JHTML::_('select.optgroup', '');
     }
     $lists['fftype'] = JHTML::_('select.genericlist', $fftype, 'filter_fieldtype', 'class="use_select2_lib" size="1" onchange="submitform( );"', 'value', 'text', $filter_fieldtype);
     if (!FLEXI_J16GE) {
         $lists['fftype'] = str_replace('<optgroup label="">', '</optgroup>', $lists['fftype']);
     }
     //build orphaned/assigned filter
     $assigned = array();
     $assigned[] = JHTML::_('select.option', '', '- ' . JText::_('FLEXI_ALL_FIELDS') . ' -');
     $assigned[] = JHTML::_('select.option', 'O', JText::_('FLEXI_ORPHANED'));
     $assigned[] = JHTML::_('select.option', 'A', JText::_('FLEXI_ASSIGNED'));
     $lists['assigned'] = JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="use_select2_lib" size="1" onchange="submitform( );"', 'value', 'text', $filter_assigned);
     //build type select list
     $lists['filter_type'] = flexicontent_html::buildtypesselect($types, 'filter_type', $filter_type, true, 'class="use_select2_lib" size="1" onchange="submitform( );"', 'filter_type');
     //publish unpublished filter
     $states = array();
     $states[] = JHTML::_('select.option', '', JText::_('FLEXI_SELECT_STATE'));
     $states[] = JHTML::_('select.option', 'P', JText::_('FLEXI_PUBLISHED'));
     $states[] = JHTML::_('select.option', 'U', JText::_('FLEXI_UNPUBLISHED'));
     //$lists['state']	= JHTML::_('grid.state', $filter_state );
     $lists['state'] = JHTML::_('select.genericlist', $states, 'filter_state', 'class="use_select2_lib" size="1" onchange="submitform( );"', 'value', 'text', $filter_state);
     // search filter
     $lists['search'] = $search;
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     // filter ordering
     if ($filter_type == '' || $filter_type == 0) {
         $ordering = $lists['order'] == 't.ordering';
     } else {
         $ordering = $lists['order'] == 'typeordering';
     }
     //assign data to template
     $this->assignRef('permission', $perms);
     $this->assignRef('filter_type', $filter_type);
     $this->assignRef('lists', $lists);
     $this->assignRef('rows', $rows);
     $this->assignRef('ordering', $ordering);
     $this->assignRef('pagination', $pagination);
     parent::display($tpl);
 }
Esempio n. 10
0
 /**
  * Creates the page's display
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     //initialize variables
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $uri = JFactory::getURI();
     $view = JRequest::getCmd('view');
     // Get view's Model
     $model = $this->getModel();
     // Get parameters via model
     $params = $model->getParams();
     // Get various data from the model
     $items = $this->get('Data');
     $total = $this->get('Total');
     // Make sure field values were retrieved e.g. we need 'item->categories' for template classes
     $items = FlexicontentFields::getFields($items, $view, $params);
     // Calculate CSS classes needed to add special styling markups to the items
     flexicontent_html::calculateItemMarkups($items, $params);
     // ********************************
     // Load needed JS libs & CSS styles
     // ********************************
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadFramework('jQuery');
     flexicontent_html::loadFramework('flexi_tmpl_common');
     // Add css files to the document <head> section (also load CSS joomla template override)
     if (!$params->get('disablecss', '')) {
         $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);
     }
     // **********************************************************
     // Calculate a (browser window) page title and a page heading
     // **********************************************************
     // Verify menu item points to current FLEXIcontent object
     if ($menu) {
         $view_ok = 'favourites' == @$menu->query['view'];
         $menu_matches = $view_ok;
         //$menu_params = FLEXI_J16GE ? $menu->params : new JParameter($menu->params);  // Get active menu item parameters
     } else {
         $menu_matches = false;
     }
     // MENU ITEM matched, use its page heading (but use menu title if the former is not set)
     if ($menu_matches) {
         $default_heading = FLEXI_J16GE ? $menu->title : $menu->name;
         // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->def('page_heading', $params->get('page_title', $default_heading));
         $params->def('page_title', $params->get('page_heading', $default_heading));
         $params->def('show_page_heading', $params->get('show_page_title', 0));
         $params->def('show_page_title', $params->get('show_page_heading', 0));
     } else {
         // Clear some menu parameters
         //$params->set('pageclass_sfx',	'');  // CSS class SUFFIX is behavior, so do not clear it ?
         // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ...
         // meta_params->get('page_title') is meant for <title> but let's use as ... default page heading
         $default_heading = JText::_('FLEXI_YOUR_FAVOURED_ITEMS');
         // Decide to show page heading (=J1.5 page title), this is always yes
         $show_default_heading = 1;
         // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->set('page_title', $default_heading);
         $params->set('page_heading', $default_heading);
         $params->set('show_page_heading', $show_default_heading);
         $params->set('show_page_title', $show_default_heading);
     }
     // Prevent showing the page heading if ... currently no reason
     if (0) {
         $params->set('show_page_heading', 0);
         $params->set('show_page_title', 0);
     }
     // ************************************************************
     // 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 to page title
     if ($doc_title != $app->getCfg('sitename')) {
         if ($app->getCfg('sitename_pagetitles', 0) == 1) {
             $doc_title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $doc_title);
         } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
             $doc_title = JText::sprintf('JPAGETITLE', $doc_title, $app->getCfg('sitename'));
         }
     }
     // Finally, set document title
     $document->setTitle($doc_title);
     // ************************
     // Set document's META tags
     // ************************
     // Workaround for Joomla not setting the default value for 'robots', so component must do it
     $app_params = $app->getParams();
     if ($_mp = $app_params->get('robots')) {
         $document->setMetadata('robots', $_mp);
     }
     // Overwrite with menu META data if menu matched
     if ($menu_matches) {
         if ($_mp = $menu->params->get('menu-meta_description')) {
             $document->setDescription($_mp);
         }
         if ($_mp = $menu->params->get('menu-meta_keywords')) {
             $document->setMetadata('keywords', $_mp);
         }
         if ($_mp = $menu->params->get('robots')) {
             $document->setMetadata('robots', $_mp);
         }
         if ($_mp = $menu->params->get('secure')) {
             $document->setMetadata('secure', $_mp);
         }
     }
     // Disable features, that are not supported by the view
     $params->set('use_filters', 0);
     $params->set('show_alpha', 0);
     $params->set('clayout_switcher', 0);
     //ordering
     $filter_order = JRequest::getCmd('filter_order', 'i.title');
     $filter_order_Dir = JRequest::getCmd('filter_order_Dir', 'ASC');
     $filter = JRequest::getString('filter');
     $lists = array();
     $lists['filter_order'] = $filter_order;
     $lists['filter_order_Dir'] = $filter_order_Dir;
     $lists['filter'] = $filter;
     // Create the pagination object
     $pageNav = $this->get('pagination');
     // URL-encode filter values
     foreach ($_GET as $i => $v) {
         if (substr($i, 0, 6) === "filter") {
             $_revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')');
             $v = str_replace('&', '__amp__', $v);
             $v = strtr(rawurlencode($v), $_revert);
             $pageNav->setAdditionalUrlParam($i, $v);
         }
     }
     // Create links, etc
     $link = JRoute::_(FlexicontentHelperRoute::getFavsRoute(0, $menu_matches ? $menu->id : 0));
     //$print_link  = JRoute::_('index.php?view=favourites&pop=1&tmpl=component');
     $curr_url = str_replace('&', '&amp;', $_SERVER['REQUEST_URI']);
     $print_link = $curr_url . (strstr($curr_url, '?') ? '&amp;' : '?') . 'pop=1&amp;tmpl=component&amp;print=1';
     $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->assignRef('action', $link);
     // $uri->toString()
     $this->assignRef('print_link', $print_link);
     $this->assignRef('items', $items);
     $this->assignRef('lists', $lists);
     $this->assignRef('params', $params);
     $this->assignRef('pageNav', $pageNav);
     $this->assignRef('pageclass_sfx', $pageclass_sfx);
     $print_logging_info = $params->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. 11
0
	function onDisplayField(&$field, &$item)
	{
		// execute the code only if the field type match the plugin type
		if ( !in_array($field->field_type, self::$field_types) ) return;
		
		$field->label = JText::_($field->label);
		
		// some parameter shortcuts
		$sql_mode				= $field->parameters->get( 'sql_mode', 0 ) ;
		$field_elements	= $field->parameters->get( 'field_elements' ) ;
		$default_values	= $field->parameters->get( 'default_values', '' ) ;
		
		// Prefix - Suffix - Separator parameters, replacing other field values if found
		$pretext			= $field->parameters->get( 'pretext_form', '' ) ;
		$posttext			= $field->parameters->get( 'posttext_form', '' ) ;
		$separator		= $field->parameters->get( 'separator', 0 ) ;
		$opentag			= $field->parameters->get( 'opentag_form', '' ) ;
		$closetag			= $field->parameters->get( 'closetag_form', '' ) ;
		
		$required = $field->parameters->get( 'required', 0 ) ;
		//$required = $required ? ' required validate-checkbox' : '';
		$max_values		= $field->parameters->get( 'max_values', 0 ) ;
		$min_values		= $field->parameters->get( 'min_values', 0 ) ;
		$exact_values	= $field->parameters->get( 'exact_values', 0 ) ;
		if ($required && !$min_values) $min_values = 1;
		if ($exact_values) $max_values = $min_values = $exact_values;
		$js_popup_err	= $field->parameters->get( 'js_popup_err', 0 ) ;
		
		switch($separator)
		{
			case 0:
			$separator = '&nbsp;';
			break;

			case 1:
			$separator = '<br />';
			break;

			case 2:
			$separator = '&nbsp;|&nbsp;';
			break;

			case 3:
			$separator = ',&nbsp;';
			break;

			case 4:
			$separator = $closetag . $opentag;
			break;

			default:
			$separator = '&nbsp;';
			break;
		}

		// initialise property
		if (!$field->value && $default_values!=='') {
			$field->value = explode(",", $default_values);
		} else if (!$field->value) {
			$field->value = array();
			$field->value[0] = '';
		}
		
		$fieldname = FLEXI_J16GE ? 'custom['.$field->name.'][]' : $field->name.'[]';
		$elementid = FLEXI_J16GE ? 'custom_'.$field->name : $field->name;
		
		// Get indexed element values
		$elements = FlexicontentFields::indexedField_getElements($field, $item, self::$extra_props);
		if ( !$elements ) {
			if ($sql_mode)
				$field->html = JText::_('FLEXI_FIELD_INVALID_QUERY');
			else
				$field->html = JText::_('FLEXI_FIELD_INVALID_ELEMENTS');
			return;
		}
		
		static $prettycheckable_added = null;
	  if ( $prettycheckable_added === null )
	  {
			$prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable');
		}
		
		$attribs  = '';
		$classes  = ($prettycheckable_added ? ' use_prettycheckable ' : '');
		//$classes .= $required;
		if ($exact_values)  {
			$attribs .= ' exact_values="'.$exact_values.'" ';
		} else {
			if ($max_values)    $attribs .= ' max_values="'.$max_values.'" ';
			if ($min_values)    $attribs .= ' min_values="'.$min_values.'" ';
		}
		if ($js_popup_err)  $attribs .= ' js_popup_err="'.$js_popup_err.'" ';
		if ($max_values || $min_values || $exact_values)  $classes .= ' validate-cboxlimitations ';
		if ($classes)  $attribs .= ' class="'.$classes.'" ';
		
		// Create field's HTML display for item form
		// Display as checkboxes
		$i = 0;
		$options = array();
		foreach ($elements as $element) {
			$checked  = in_array($element->value, $field->value)  ?  ' checked="checked"'  :  '';
			$elementid_no = $elementid.'_'.$i;
			$extra_params = $prettycheckable_added ? ' data-label="'.JText::_($element->text).'" data-labelPosition="right" data-customClass="fcradiocheck"' : '';
			$options[] = ''
				.(!$prettycheckable_added ? '<label class="fccheckradio_lbl">' : '')
				.' <input type="checkbox" id="'.$elementid_no.'" element_group_id="'.$elementid.'" name="'.$fieldname.'" '.$attribs.' value="'.$element->value.'" '.$checked.$extra_params.' />'
				.(!$prettycheckable_added ? '&nbsp;'.JText::_($element->text).'</label>' : '')
				;
			$i++;
		}
		
		// Apply values separator
		$field->html = implode($separator, $options);
		
		// Apply field 's opening / closing texts
		if ($field->html)
			$field->html = $opentag . $field->html . $closetag;
		
		// Add message box about allowed # values
		if ($exact_values) {
			$field->html = '<div class="fc_mini_note_box">'.JText::sprintf('FLEXI_FIELD_NUM_VALUES_EXACTLY', $exact_values) .'</div><div class="clear"></div>'. $field->html;
		} else if ($max_values || $min_values > 1) {
			$field->html = '<div class="fc_mini_note_box">'.JText::sprintf('FLEXI_FIELD_NUM_VALUES_BETWEEN', $min_values, $max_values) .'</div><div class="clear"></div>'. $field->html;
		}
	}
Esempio n. 12
0
 /**
  * Creates the page's display
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     //initialize variables
     $option = JRequest::getVar('option');
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $db = JFactory::getDBO();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $uri = JFactory::getURI();
     $pathway = $app->getPathway();
     // Get view's Model
     $model = $this->getModel();
     $error = '';
     $rows = null;
     $total = 0;
     $form_id = $form_name = "searchForm";
     // Get parameters via model
     $params = $model->getParams();
     // Get various data from the model
     $areas = $this->get('areas');
     $state = $this->get('state');
     $searchword = $state->get('keyword');
     $searchphrase = $state->get('match');
     $searchordering = $state->get('ordering');
     // ***********************************************************
     // some parameter shortcuts common with advanced search plugin
     // ***********************************************************
     $canseltypes = $params->get('canseltypes', 1);
     $txtmode = $params->get('txtmode', 0);
     // 0: BASIC Index, 1: ADVANCED Index without search fields user selection, 2: ADVANCED Index with search fields user selection
     // Get if text searching according to specific (single) content type
     $show_txtfields = $params->get('show_txtfields', 1);
     //0:hide, 1:according to content, 2:use custom configuration
     $show_txtfields = $txtmode ? 0 : $show_txtfields;
     // disable this flag if using BASIC index for text search
     // Get if filtering according to specific (single) content type
     $show_filters = $params->get('show_filters', 1);
     //0:hide, 1:according to content, 2:use custom configuration
     // Force single type selection and showing the content type selector
     $type_based_search = $show_filters == 1 || $show_txtfields == 1;
     $canseltypes = $type_based_search ? 1 : $canseltypes;
     // ********************************
     // Load needed JS libs & CSS styles
     // ********************************
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadFramework('jQuery');
     flexicontent_html::loadFramework('flexi_tmpl_common');
     // Add css files to the document <head> section (also load CSS joomla template override)
     if (!$params->get('disablecss', '')) {
         $document->addStyleSheetVersion($this->baseurl . '/components/com_flexicontent/assets/css/flexicontent.css', FLEXI_VERSION);
         $document->addStyleSheetVersion($this->baseurl . '/components/com_flexicontent/assets/css/flexi_filters.css', FLEXI_VERSION);
         //$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_VERSION);
     }
     // **********************************************************
     // Calculate a (browser window) page title and a page heading
     // **********************************************************
     // Verify menu item points to current FLEXIcontent object
     if ($menu) {
         $view_ok = 'search' == @$menu->query['view'];
         $menu_matches = $view_ok;
         //$menu_params = FLEXI_J16GE ? $menu->params : new JParameter($menu->params);  // Get active menu item parameters
     } else {
         $menu_matches = false;
     }
     // MENU ITEM matched, use its page heading (but use menu title if the former is not set)
     if ($menu_matches) {
         $default_heading = FLEXI_J16GE ? $menu->title : $menu->name;
         // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->def('page_heading', $params->get('page_title', $default_heading));
         $params->def('page_title', $params->get('page_heading', $default_heading));
         $params->def('show_page_heading', $params->get('show_page_title', 0));
         $params->def('show_page_title', $params->get('show_page_heading', 0));
     } else {
         // Clear some menu parameters
         //$params->set('pageclass_sfx',	'');  // CSS class SUFFIX is behavior, so do not clear it ?
         // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ...
         // meta_params->get('page_title') is meant for <title> but let's use as ... default page heading
         $default_heading = JText::_('FLEXI_SEARCH');
         // Decide to show page heading (=J1.5 page title), this default to no
         $show_default_heading = 0;
         // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->set('page_title', $default_heading);
         $params->set('page_heading', $default_heading);
         $params->set('show_page_heading', $show_default_heading);
         $params->set('show_page_title', $show_default_heading);
     }
     // Prevent showing the page heading if ... currently no reason
     if (0) {
         $params->set('show_page_heading', 0);
         $params->set('show_page_title', 0);
     }
     // ************************************************************
     // 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 to page title
     if ($doc_title != $app->getCfg('sitename')) {
         if ($app->getCfg('sitename_pagetitles', 0) == 1) {
             $doc_title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $doc_title);
         } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
             $doc_title = JText::sprintf('JPAGETITLE', $doc_title, $app->getCfg('sitename'));
         }
     }
     // Finally, set document title
     $document->setTitle($doc_title);
     // ************************
     // Set document's META tags
     // ************************
     // Workaround for Joomla not setting the default value for 'robots', so component must do it
     $app_params = $app->getParams();
     if ($_mp = $app_params->get('robots')) {
         $document->setMetadata('robots', $_mp);
     }
     // Overwrite with menu META data if menu matched
     if ($menu_matches) {
         if ($_mp = $menu->params->get('menu-meta_description')) {
             $document->setDescription($_mp);
         }
         if ($_mp = $menu->params->get('menu-meta_keywords')) {
             $document->setMetadata('keywords', $_mp);
         }
         if ($_mp = $menu->params->get('robots')) {
             $document->setMetadata('robots', $_mp);
         }
         if ($_mp = $menu->params->get('secure')) {
             $document->setMetadata('secure', $_mp);
         }
     }
     // ********************************************************************
     // Get Content Types allowed for user selection in the Search Form
     // Also retrieve their configuration, plus the currently selected types
     // ********************************************************************
     // Get them from configuration
     $contenttypes = $params->get('contenttypes', array());
     // Sanitize them
     $contenttypes = !is_array($contenttypes) ? array($contenttypes) : $contenttypes;
     $contenttypes = array_unique(array_map('intval', $contenttypes));
     // Make sure these are integers since we will be using them UNQUOTED
     // Force hidden content type selection if only 1 content type was initially configured
     $canseltypes = count($contenttypes) == 1 ? 0 : $canseltypes;
     // Type data and configuration (parameters), if no content types specified then all will be retrieved
     $typeData = flexicontent_db::getTypeData(implode(",", $contenttypes));
     $contenttypes = array();
     foreach ($typeData as $tdata) {
         $contenttypes[] = $tdata->id;
     }
     // Get Content Types to use either those currently selected in the Search Form, or those hard-configured in the search menu item
     if ($canseltypes) {
         $form_contenttypes = JRequest::getVar('contenttypes', array());
         // Sanitize them
         $form_contenttypes = !is_array($form_contenttypes) ? array($form_contenttypes) : $form_contenttypes;
         $form_contenttypes = array_unique(array_map('intval', $form_contenttypes));
         // Make sure these are integers since we will be using them UNQUOTED
         $_contenttypes = array_intersect($contenttypes, $form_contenttypes);
         if (!empty($_contenttypes)) {
             $contenttypes = $_contenttypes;
         }
         // catch empty case: no content types were given or not-allowed content types were passed
     }
     // Check for zero content type (can occur during sanitizing content ids to integers)
     if (!empty($contenttypes)) {
         foreach ($contenttypes as $i => $v) {
             if (!strlen($contenttypes[$i])) {
                 unset($contenttypes[$i]);
             }
         }
     }
     // Type based seach, get a single content type (first one, if more than 1 were given ...)
     if ($type_based_search && !empty($contenttypes)) {
         $single_contenttype = reset($contenttypes);
         $contenttypes = array($single_contenttype);
     } else {
         $single_contenttype = false;
     }
     // *************************************
     // Text Search Fields of the search form
     // *************************************
     if (!$txtmode) {
         $txtflds = array();
         $fields_text = array();
     } else {
         $txtflds = '';
         if ($show_txtfields) {
             if ($show_txtfields == 1) {
                 $txtflds = $single_contenttype ? $typeData[$single_contenttype]->params->get('searchable', '') : '';
             } else {
                 $txtflds = $params->get('txtflds', '');
             }
         }
         // Sanitize them
         $txtflds = preg_replace("/[\"'\\\\]/u", "", $txtflds);
         $txtflds = array_unique(preg_split("/\\s*,\\s*/u", $txtflds));
         if (!strlen($txtflds[0])) {
             unset($txtflds[0]);
         }
         // Create a comma list of them
         $txtflds_list = count($txtflds) ? "'" . implode("','", $txtflds) . "'" : '';
         // Retrieve field properties/parameters, verifying the support to be used as Text Search Fields
         // This will return all supported fields if field limiting list is empty
         $fields_text = FlexicontentFields::getSearchFields($key = 'id', $indexer = 'advanced', $txtflds_list, $contenttypes, $load_params = true, 0, 'search');
         if (empty($fields_text)) {
             // all entries of field limiting list were invalid , get ALL
             if (!empty($contenttypes)) {
                 $fields_text = FlexicontentFields::getSearchFields($key = 'id', $indexer = 'advanced', null, $contenttypes, $load_params = true, 0, 'search');
             } else {
                 $fields_text = array();
             }
         }
     }
     // ********************************
     // Filter Fields of the search form
     // ********************************
     // Get them from type configuration or from search menu item
     $filtflds = '';
     if ($show_filters) {
         if ($show_filters == 1) {
             $filtflds = $single_contenttype ? $typeData[$single_contenttype]->params->get('filters', '') : '';
         } else {
             $filtflds = $params->get('filtflds', '');
         }
     }
     // Sanitize them
     $filtflds = preg_replace("/[\"'\\\\]/u", "", $filtflds);
     $filtflds = array_unique(preg_split("/\\s*,\\s*/u", $filtflds));
     if (!strlen($filtflds[0])) {
         unset($filtflds[0]);
     }
     // Create a comma list of them
     $filtflds_list = count($filtflds) ? "'" . implode("','", $filtflds) . "'" : '';
     // Retrieve field properties/parameters, verifying the support to be used as Filter Fields
     // This will return all supported fields if field limiting list is empty
     if (count($filtflds)) {
         $filters_tmp = FlexicontentFields::getSearchFields($key = 'name', $indexer = 'advanced', $filtflds_list, $contenttypes, $load_params = true, 0, 'filter');
         // Use custom order
         $filters = array();
         if ($canseltypes && $show_filters) {
             foreach ($filtflds as $field_name) {
                 if (empty($filters_tmp[$field_name])) {
                     continue;
                 }
                 $filter_id = $filters_tmp[$field_name]->id;
                 $filters[$filter_id] = $filters_tmp[$field_name];
             }
         } else {
             foreach ($filters_tmp as $filter) {
                 $filters[$filter->id] = $filter;
                 // index by filter_id in this case too (for consistency, although we do not use the array index ?)
             }
         }
         unset($filters_tmp);
     }
     // If configured filters were not found/invalid for the current content type(s)
     // then retrieve all fields marked as filterable for the give content type(s) this is useful to list per content type filters automatically, even when not set or misconfigured
     if (empty($filters)) {
         if (!empty($contenttypes)) {
             $filters = FlexicontentFields::getSearchFields($key = 'id', $indexer = 'advanced', null, $contenttypes, $load_params = true, 0, 'filter');
         } else {
             $filters = array();
         }
     }
     // ****************************************
     // Create Form Elements (the 'lists' array)
     // ****************************************
     $lists = array();
     // *** Selector of Content Types
     if ($canseltypes) {
         $types = array();
         if ($show_filters) {
             $types[] = JHTML::_('select.option', '', JText::_('FLEXI_PLEASE_SELECT'));
         }
         foreach ($typeData as $type) {
             $types[] = JHTML::_('select.option', $type->id, JText::_($type->name));
         }
         $multiple_param = $show_filters ? ' onchange="adminFormPrepare(this.form); this.form.submit();" ' : ' multiple="multiple" ';
         $attribs = $multiple_param . ' size="5" class="fc_field_filter use_select2_lib fc_label_internal fc_prompt_internal"';
         $attribs .= ' data-fc_label_text="' . flexicontent_html::escapeJsText(JText::_('FLEXI_CLICK_TO_LIST'), 's') . '"';
         $attribs .= ' data-fc_prompt_text="' . flexicontent_html::escapeJsText(JText::_('FLEXI_TYPE_TO_FILTER'), 's') . '"';
         $lists['contenttypes'] = JHTML::_('select.genericlist', $types, 'contenttypes[]', $attribs, 'value', 'text', empty($form_contenttypes) ? '' : $form_contenttypes, 'contenttypes');
         /*
         $checked = !count($form_contenttypes) || !strlen($form_contenttypes[0]);
         $checked_attr = $checked ? 'checked="checked"' : '';
         $checked_class = $checked ? 'fc_highlight' : '';
         
         $lists['contenttypes']  = '<ul class="fc_field_filter fc_checkradio_group">';
         $lists['contenttypes'] .= ' <li class="fc_checkradio_option fc_checkradio_special">';
         $lists['contenttypes'] .= '  <input href="javascript:;" onclick="fc_toggleClass(this, \'fc_highlight\', 1);" ';
         $lists['contenttypes'] .= '    id="_contenttypes_0" type="checkbox" name="contenttypes[0]" ';
         $lists['contenttypes'] .= '    value="" '.$checked_attr.' class="fc_checkradio" />';
         $lists['contenttypes'] .= '  <label class="'.$checked_class.'" for="_contenttypes_0">';
         $lists['contenttypes'] .= '   -'.JText::_('FLEXI_ALL').'-';
         $lists['contenttypes'] .= '  </label>';
         $lists['contenttypes'] .= ' </li>';
         foreach($typeData as $type) {
         	$checked = in_array($type->value, $form_contenttypes);
         	$checked_attr = $checked ? 'checked=checked' : '';
         	$checked_class = $checked ? ' fc_highlight' : '';
         	$lists['contenttypes'] .= ' <li class="fc_checkradio_option">';
         	$lists['contenttypes'] .= '  <input href="javascript:;" onclick="fc_toggleClass(this, \'fc_highlight\');" ';
         	$lists['contenttypes'] .= '    id="_contenttypes_'.$type->value.'" type="checkbox" name="contenttypes[]" ';
         	$lists['contenttypes'] .= '    value="'.$type->value.'" '.$checked_attr.' class="fc_checkradio" />';
         	$lists['contenttypes'] .= '  <label class="'.$checked_class.'" for="_contenttypes_'.$type->value.'">';
         	$lists['contenttypes'] .= '   '.JText::_($type->text);
         	$lists['contenttypes'] .= '  </label>';
         	$lists['contenttypes'] .= ' </li>';
         }
         $lists['contenttypes'] .= '</ul>';
         */
     }
     // *** Selector of Fields for text searching
     if ($txtmode == 2 && count($fields_text)) {
         // Get selected text fields in the Search Form
         $form_txtflds = JRequest::getVar('txtflds', array());
         if (!$form_txtflds || empty($form_txtflds)) {
             $form_txtflds = array();
             //array('__FC_ALL__'); //array_keys($fields_text);
         }
         $attribs = ' multiple="multiple" size="5" class="fc_field_filter use_select2_lib fc_label_internal fc_prompt_internal"';
         $attribs .= ' data-fc_label_text="' . flexicontent_html::escapeJsText(JText::_('FLEXI_CLICK_TO_LIST'), 's') . '"';
         $attribs .= ' data-fc_prompt_text="' . flexicontent_html::escapeJsText(JText::_('FLEXI_TYPE_TO_FILTER'), 's') . '"';
         $lists['txtflds'] = JHTML::_('select.genericlist', $fields_text, 'txtflds[]', $attribs, 'name', 'label', $form_txtflds, 'txtflds');
         /*
         $checked = !count($form_txtflds) || !strlen($form_txtflds[0]);
         $checked_attr = $checked ? 'checked="checked"' : '';
         $checked_class = $checked ? 'fc_highlight' : '';
         
         $lists['txtflds']  = '<ul class="fc_field_filter fc_checkradio_group">';
         $lists['txtflds'] .= ' <li class="fc_checkradio_option fc_checkradio_special">';
         $lists['txtflds'] .= '  <input href="javascript:;" onclick="fc_toggleClass(this, \'fc_highlight\', 1);" ';
         $lists['txtflds'] .= '    id="_txtflds_0" type="checkbox" name="txtflds[0]" value="" ';
         $lists['txtflds'] .= '    value="" '.$checked_attr.' class="fc_checkradio" />';
         $lists['txtflds'] .= '  <label class="'.$checked_class.'" for="_txtflds_0">';
         $lists['txtflds'] .= '   -'.JText::_('FLEXI_ALL').'-';
         $lists['txtflds'] .= '  </label>';
         $lists['txtflds'] .= ' </li>';
         foreach($fields_text as $field) {
         	$checked = in_array($field->name, $form_txtflds);
         	$checked_attr = $checked ? 'checked=checked' : '';
         	$checked_class = $checked ? ' fc_highlight' : '';
         	$lists['txtflds'] .= ' <li class="fc_checkradio_option">';
         	$lists['txtflds'] .= '  <input href="javascript:;" onclick="fc_toggleClass(this, \'fc_highlight\');" ';
         	$lists['txtflds'] .= '    id="_txtflds_'.$field->id.'" type="checkbox" name="txtflds[]" ';
         	$lists['txtflds'] .= '    value="'.$field->name.'" '.$checked_attr.' class="fc_checkradio" />';
         	$lists['txtflds'] .= '  <label class="class=""'.$checked_class.'" for="_txtflds_'.$field->id.'">';
         	$lists['txtflds'] .= '   '.JText::_($field->label);
         	$lists['txtflds'] .= '  </label>';
         	$lists['txtflds'] .= ' </li>';
         }
         $lists['txtflds'] .= '</ul>';
         */
     }
     // *** Selector of FLEXIcontent Results Ordering
     if ($orderby_override = $params->get('orderby_override', 1)) {
         $lists['orderby'] = flexicontent_html::ordery_selector($params, $form_id, $autosubmit = 0);
     }
     // *** Selector of Pagination Limit
     if ($limit_override = $params->get('limit_override', 1)) {
         $lists['limit'] = flexicontent_html::limit_selector($params, $form_id, $autosubmit = 0);
     }
     // *** Selector of non-FLEXIcontent Results Ordering
     if ($show_searchordering = $params->get('show_searchordering', 1)) {
         // built select lists
         $orders = array();
         $orders[] = JHTML::_('select.option', 'newest', JText::_('FLEXI_ADV_NEWEST_FIRST'));
         $orders[] = JHTML::_('select.option', 'oldest', JText::_('FLEXI_ADV_OLDEST_FIRST'));
         $orders[] = JHTML::_('select.option', 'popular', JText::_('FLEXI_ADV_MOST_POP'));
         $orders[] = JHTML::_('select.option', 'alpha', JText::_('FLEXI_ADV_ALPHA'));
         $orders[] = JHTML::_('select.option', 'category', JText::_('FLEXI_ADV_SEARCH_SEC_CAT'));
         $lists['ordering'] = JHTML::_('select.genericlist', $orders, 'o', 'class="fc_field_filter use_select2_lib"', 'value', 'text', $searchordering, 'ordering');
     }
     // *** Selector for usage of Search Text
     if ($show_searchphrase = $params->get('show_searchphrase', 1)) {
         $searchphrase_names = array('natural' => 'FLEXI_NATURAL_PHRASE', 'natural_expanded' => 'FLEXI_NATURAL_PHRASE_GUESS_RELEVANT', 'all' => 'FLEXI_ALL_WORDS', 'any' => 'FLEXI_ANY_WORDS', 'exact' => 'FLEXI_EXACT_PHRASE');
         $phrases = array();
         foreach ($searchphrase_names as $searchphrase_value => $searchphrase_name) {
             $_obj = new stdClass();
             $_obj->value = $searchphrase_value;
             $_obj->text = $searchphrase_name;
             $phrases[] = $_obj;
         }
         $lists['searchphrase'] = JHTML::_('select.genericlist', $phrases, 'p', 'class="fc_field_filter use_select2_lib"', 'value', 'text', $searchphrase, 'searchphrase', $_translate = true);
         /*$lists['searchphrase']  = '<ul class="fc_field_filter fc_checkradio_group">';
         		foreach ($searchphrase_names as $searchphrase_value => $searchphrase_name) {
         			$lists['searchphrase'] .= ' <li class="fc_checkradio_option fc_checkradio_special">';
         			$checked = $searchphrase_value == $searchphrase;
         			$checked_attr = $checked ? 'checked=checked' : '';
         			$checked_class = $checked ? 'fc_highlight' : '';
         			$lists['searchphrase'] .= '  <input href="javascript:;" onclick="fc_toggleClassGrp(this.parentNode, \'fc_highlight\');" id="searchphrase_'.$searchphrase_value.'" type="radio" name="p" value="'.$searchphrase_value.'" '.$checked_attr.' />';
         			$lists['searchphrase'] .= '  <label class="'.$checked_class.'" style="display:inline-block; white-space:nowrap;" for="searchphrase_'.$searchphrase_value.'">';
         			$lists['searchphrase'] .=     JText::_($searchphrase_name);
         			$lists['searchphrase'] .= '  </label>';
         			$lists['searchphrase'] .= ' </li>';
         		}
         		$lists['searchphrase']  .= '</ul>';*/
     }
     // *** Selector for filter combination
     /*if($show_filtersop = $params->get('show_filtersop', 1)) {
     			$default_filtersop = $params->get('default_filtersop', 'all');
     			$filtersop = JRequest::getVar('filtersop', $default_filtersop);
     			$filtersop_arr		= array();
     			$filtersop_arr[] = JHTML::_('select.option',  'all', JText::_( 'FLEXI_SEARCH_ALL' ) );
     			$filtersop_arr[] = JHTML::_('select.option',  'any', JText::_( 'FLEXI_SEARCH_ANY' ) );
     			$lists['filtersop']= JHTML::_('select.radiolist',  $filtersop_arr, 'filtersop', '', 'value', 'text', $filtersop );
     		}*/
     // *** Selector of Search Areas
     // If showing this is disabled, then FLEXIcontent (advanced) search model will not use all search areas,
     // but instead it will use just 'flexicontent' search area, that is the search area of FLEXIcontent (advanced) search plugin
     if ($params->get('show_searchareas', 0)) {
         // Get Content Types currently selected in the Search Form
         $form_areas = JRequest::getVar('areas', array());
         //if ( empty($form_areas) || !count($form_areas) )  $form_areas = array('flexicontent');
         $checked = empty($form_areas) || !count($form_areas);
         $checked_attr = $checked ? 'checked="checked"' : '';
         $checked_class = $checked ? 'fc_highlight' : '';
         // Create array of area options
         $options = array();
         foreach ($areas['search'] as $area => $label) {
             $_area = new stdClass();
             $_area->text = $label;
             $_area->value = $area;
             $options[] = $_area;
         }
         $attribs = ' multiple="multiple" size="5" class="fc_field_filter use_select2_lib fc_label_internal fc_prompt_internal"';
         $attribs .= ' data-fc_label_text="' . flexicontent_html::escapeJsText(JText::_('FLEXI_CLICK_TO_LIST'), 's') . '"';
         $attribs .= ' data-fc_prompt_text="' . flexicontent_html::escapeJsText(JText::_('FLEXI_TYPE_TO_FILTER'), 's') . '"';
         $lists['areas'] = JHTML::_('select.genericlist', $options, 'areas[]', $attribs, 'value', 'text', $form_areas, 'areas', $do_jtext = true);
         /*
         $lists['areas']  = '<ul class="fc_field_filter fc_checkradio_group">';
         $lists['areas'] .= ' <li class="fc_checkradio_option fc_checkradio_special">';
         $lists['areas'] .= '  <input href="javascript:;" onclick="fc_toggleClass(this, \'fc_highlight\', 1);" ';
         $lists['areas'] .= '    id="area_0" type="checkbox" name="area[0]" ';
         $lists['areas'] .= '    value="" '.$checked_attr.' class="fc_checkradio" />';
         $lists['areas'] .= '  <label class="'.$checked_class.'" for="_txtflds_0">';
         $lists['areas'] .= '   -'.JText::_('FLEXI_CONTENT_ONLY').'-';
         $lists['areas'] .= '  </label>';
         $lists['areas'] .= ' </li>';
         foreach($areas['search'] as $area_name => $area_label) {
         	$checked = in_array($area_name, $form_areas);
         	$checked_attr = $checked ? 'checked=checked' : '';
         	$checked_class = $checked ? ' fc_highlight' : '';
         	$lists['areas'] .= ' <li class="fc_checkradio_option">';
         	$lists['areas'] .= '  <input href="javascript:;" onclick="fc_toggleClass(this, \'fc_highlight\');" ';
         	$lists['areas'] .= '    id="area_'.$area_name.'" type="checkbox" name="areas[]" ';
         	$lists['areas'] .= '    value="'.$area_name.'" '.$checked_attr.' class="fc_checkradio" />';
         	$lists['areas'] .= '  <label class="'.$checked_class.'" for="area_'.$area_name.'">';
         	$lists['areas'] .= '  '.JText::_($area_label);
         	$lists['areas'] .= '  </label>';
         	$lists['areas'] .= ' </li>';
         }
         $lists['areas'] .= '</ul>';
         */
     }
     // log the search
     FLEXIadvsearchHelper::logSearch($searchword);
     //limit searchword
     $min_word_len = $app->getUserState($option . '.min_word_len', 0);
     $min = $min_word_len ? $min_word_len : $params->get('minchars', 3);
     $max = $params->get('maxchars', 200);
     if (FLEXIadvsearchHelper::limitSearchWord($searchword, $min, $max)) {
         $error = JText::sprintf('FLEXI_SEARCH_MESSAGE', $min, $max);
     }
     // sanitise searchword
     if (FLEXIadvsearchHelper::santiseSearchWord($searchword, $state->get('match'), $min)) {
         $error = JText::_('IGNOREKEYWORD');
     }
     if (!$searchword && count(JRequest::get('post'))) {
         //$error = JText::_( 'Enter a search keyword' );
     }
     // put the filtered results back into the model
     // for next release, the checks should be done in the model perhaps...
     $state->set('keyword', $searchword);
     $filter_word_like_any = $params->get('filter_word_like_any', 0);
     if (!$error) {
         require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'route.php';
         $results = $this->get('data');
         $total = $this->get('total');
         $pageNav = $this->get('pagination');
         // URL-encode filter values
         foreach ($_GET as $i => $v) {
             if (substr($i, 0, 6) === "filter") {
                 $_revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')');
                 $v = str_replace('&', '__amp__', $v);
                 $v = strtr(rawurlencode($v), $_revert);
                 $pageNav->setAdditionalUrlParam($i, $v);
             }
         }
         if ($state->get('match') == 'exact') {
             $searchwords = array($searchword);
             //$needle = $searchword;
         } else {
             $searchwords = preg_split("/\\s+/u", $searchword);
             //print_r($searchwords);
         }
         // Create regular expressions, for highlighting the matched words
         $w_regexp_highlight = array();
         foreach ($searchwords as $n => $_word) {
             $w_regexp_highlight[$_word] = mb_strlen($_word, 'utf-8') <= 2 || $n + 1 < count($searchwords) ? '#\\b(' . preg_quote($_word, '#') . ')\\b#iu' : '#\\b(' . preg_quote($_word, '#') . ')#iu';
         }
         for ($i = 0; $i < count($results); $i++) {
             $result =& $results[$i];
             if (strlen($searchwords[0])) {
                 $parts = FLEXIadvsearchHelper::prepareSearchContent($result->text, $params->get('text_chars', 200), $searchwords);
                 //if( count($parts)>1 ) { echo "<pre>"; print_r($parts); exit;}
                 foreach ($parts as $word_found => $part) {
                     if (!$word_found) {
                         continue;
                     }
                     $searchRegex = $w_regexp_highlight[$word_found];
                     $parts[$word_found] = preg_replace($searchRegex, '_fc_highlight_start_\\0_fc_highlight_end_', $part);
                 }
                 $result->text = implode($parts, " <br/> ");
                 $replace_count_total = 0;
                 // This is for LIKE %word% search for languages without spaces
                 if ($filter_word_like_any) {
                     if (strlen($word_found) <= 2) {
                         continue;
                     }
                     // Do not highlight too small words, since we do not consider spaces
                     foreach ($searchwords as $_word) {
                         $searchRegex = '#(' . preg_quote($_word, '#') . '[^\\s]*)#iu';
                         $result->text = preg_replace($searchRegex, '_fc_highlight_start_\\0_fc_highlight_end_', $result->text, 1, $replace_count);
                         if ($replace_count) {
                             $replace_count_total++;
                         }
                     }
                 }
                 $result->text = str_replace('_fc_highlight_start_', '<span class="highlight">', $result->text);
                 $result->text = str_replace('_fc_highlight_end_', '</span>', $result->text);
                 // Add some message about matches
                 /*if ( $state->get('match')=='any' ) {
                 			$text_search_header = "<u><b>".JText::sprintf('Text Search matched at least %d %% (%d out of %d words)', $replace_count_total/count($searchwords) * 100, $replace_count_total, count($searchwords)).": </b></u><br/>";
                 		} else if ( $state->get('match')=='all' ) {
                 			$text_search_header = "<u><b>".JText::sprintf('Text Search (all %d words required)', count($searchwords)).": </b></u><br/>";
                 		} else if ( $state->get('match')=='exact' ) {
                 			$text_search_header = "<u><b>".JText::_('Text Search (exact phrase)').": </b></u><br/>";
                 		} else if ( $state->get('match')=='natural_expanded' ) {
                 			$text_search_header = "<u><b>".JText::_('Text Search (phrase, guessing related)').": </b></u><br/>";
                 		} else if ( $state->get('match')=='natural' ) {
                 			$text_search_header = "<u><b>".JText::_('Text Search (phrase)').": </b></u><br/>";
                 		}
                 		$result->text = $text_search_header . $result->text;*/
             } else {
                 $parts = FLEXIadvsearchHelper::prepareSearchContent($result->text, $params->get('text_chars', 200), array());
                 $result->text = implode($parts, " <br/> ");
             }
             /*if ( !empty($result->fields_text) ) {
             			$result->text .= "<br/><u><b>".JText::_('Attribute filters matched')." : </b></u>";
             			$result->fields_text = str_replace('[span=highlight]', '<span class="highlight">', $result->fields_text);
             			$result->fields_text = str_replace('[/span]', '</span>', $result->fields_text);
             			$result->fields_text = str_replace('[br /]', '<br />', $result->fields_text);
             			$result->text .= $result->fields_text;
             		}*/
             $result->text = str_replace('[[[', '<', $result->text);
             $result->text = str_replace(']]]', '>', $result->text);
             $result->created = $result->created ? JHTML::Date($result->created) : '';
             $result->count = $i + 1;
         }
     }
     $this->result = JText::sprintf('FLEXI_TOTALRESULTSFOUND', $total);
     // ******************************************************************
     // Create HTML of filters (-AFTER- getData of model have been called)
     // ******************************************************************
     foreach ($filters as $filter) {
         $filter->parameters->set('display_label_filter_s', 0);
         $filter->value = JRequest::getVar('filter_' . $filter->id, false);
         //$fieldsearch = $app->getUserStateFromRequest( 'flexicontent.search.'.'filter_'.$filter->id, 'filter_'.$filter->id, array(), 'array' );
         //echo "Field name: ".$filter->name; echo ":: ". 'filter_'.$filter->id ." :: value: "; print_r($filter->value); echo "<br/>\n";
         $field_filename = $filter->iscore ? 'core' : $filter->field_type;
         FLEXIUtilities::call_FC_Field_Func($field_filename, 'onAdvSearchDisplayFilter', array(&$filter, $filter->value, $form_id));
     }
     //echo "<pre>"; print_r($_GET); exit;
     // Create links
     $link = JRoute::_(FlexicontentHelperRoute::getSearchRoute(0, $menu_matches ? $menu->id : 0));
     //$print_link = JRoute::_('index.php?view=search&pop=1&tmpl=component&print=1');
     $curr_url = str_replace('&', '&amp;', $_SERVER['REQUEST_URI']);
     $print_link = $curr_url . (strstr($curr_url, '?') ? '&amp;' : '?') . 'pop=1&amp;tmpl=component&amp;print=1';
     $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->assignRef('action', $link);
     // $uri->toString()
     $this->assignRef('print_link', $print_link);
     $this->assignRef('contenttypes', $contenttypes);
     $this->assignRef('filters', $filters);
     $this->assignRef('results', $results);
     $this->assignRef('lists', $lists);
     $this->assignRef('params', $params);
     $this->assignRef('pageNav', $pageNav);
     $this->assignRef('pageclass_sfx', $pageclass_sfx);
     $this->assignRef('typeData', $typeData);
     $this->assign('ordering', $state->get('ordering'));
     $this->assign('searchword', $searchword);
     $this->assign('searchphrase', $state->get('match'));
     $this->assign('searchareas', $areas);
     $this->assign('total', $total);
     $this->assign('error', $error);
     $this->assignRef('document', $document);
     $this->assign('form_id', $form_id);
     $this->assign('form_name', $form_name);
     $print_logging_info = $params->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. 13
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();
        // Get the COMPONENT only parameters
        // Get component parameters
        $params = new JRegistry();
        $cparams = JComponentHelper::getParams('com_flexicontent');
        $params->merge($cparams);
        $params = clone JComponentHelper::getParams('com_flexicontent');
        // Some flags
        $enable_translation_groups = flexicontent_db::useAssociations();
        //$params->get("enable_translation_groups");
        $print_logging_info = $params->get('print_logging_info');
        if ($print_logging_info) {
            global $fc_run_times;
        }
        // *****************
        // Load JS/CSS files
        // *****************
        // Add css to document
        $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VERSION);
        $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VERSION);
        // Fields common CSS
        $document->addStyleSheetVersion(JURI::root(true) . '/components/com_flexicontent/assets/css/flexi_form_fields.css', FLEXI_VERSION);
        // Add JS frameworks
        flexicontent_html::loadFramework('select2');
        $prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable');
        flexicontent_html::loadFramework('flexi-lib');
        // Add js function to overload the joomla submitform validation
        JHTML::_('behavior.formvalidation');
        // load default validation JS to make sure it is overriden
        $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VERSION);
        $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VERSION);
        // Add js function for custom code used by FLEXIcontent item form
        $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/itemscreen.js', FLEXI_VERSION);
        // ***********************
        // Get data from the model
        // ***********************
        if ($print_logging_info) {
            $start_microtime = microtime(true);
        }
        $model = $this->getModel();
        $item = $model->getItem();
        $form = $this->get('Form');
        if ($print_logging_info) {
            $fc_run_times['get_item_data'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
        }
        // ***************************
        // Get Associated Translations
        // ***************************
        if ($enable_translation_groups) {
            $langAssocs = $this->get('LangAssocs');
        }
        $langs = FLEXIUtilities::getLanguages('code');
        // Get item id and new flag
        $cid = $model->getId();
        $isnew = !$cid;
        // Create and set a unique item id for plugins that needed it
        if ($cid) {
            $unique_tmp_itemid = $cid;
        } else {
            $unique_tmp_itemid = $app->getUserState('com_flexicontent.edit.item.unique_tmp_itemid');
            $unique_tmp_itemid = $unique_tmp_itemid ? $unique_tmp_itemid : date('_Y_m_d_h_i_s_', time()) . uniqid(true);
        }
        //print_r($unique_tmp_itemid);
        JRequest::setVar('unique_tmp_itemid', $unique_tmp_itemid);
        // Get number of subscribers
        $subscribers = $model->getSubscribersCount();
        // ******************
        // Version Panel data
        // ******************
        // Get / calculate some version related variables
        $versioncount = $model->getVersionCount();
        $versionsperpage = $params->get('versionsperpage', 10);
        $pagecount = (int) ceil($versioncount / $versionsperpage);
        // Data need by version panel: (a) current version page, (b) currently active version
        $current_page = 1;
        $k = 1;
        $allversions = $model->getVersionList();
        foreach ($allversions as $v) {
            if ($k > 1 && ($k - 1) % $versionsperpage == 0) {
                $current_page++;
            }
            if ($v->nr == $item->version) {
                break;
            }
            $k++;
        }
        // Finally fetch the version data for versions in current page
        $versions = $model->getVersionList(($current_page - 1) * $versionsperpage, $versionsperpage);
        // Create display of average rating
        $ratings = $model->getRatingDisplay();
        // *****************
        // Type related data
        // *****************
        // Get available types and the currently selected/requested type
        $types = $model->getTypeslist();
        $typesselected = $model->getTypesselected();
        // Get and merge type parameters
        $tparams = $this->get('Typeparams');
        $tparams = new JRegistry($tparams);
        $params->merge($tparams);
        // Apply type configuration if it type is set
        // Get user allowed permissions on the item ... to be used by the form rendering
        // Also hide parameters panel if user can not edit parameters
        $perms = $this->_getItemPerms($item);
        if (!$perms['canparams']) {
            $document->addStyleDeclaration('#details-options {display:none;}');
        }
        // ******************
        // Create the toolbar
        // ******************
        $toolbar = JToolBar::getInstance('toolbar');
        $tip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip';
        // SET toolbar title
        if ($cid) {
            JToolBarHelper::title(JText::_('FLEXI_EDIT_ITEM'), 'itemedit');
            // Editing existing item
        } else {
            JToolBarHelper::title(JText::_('FLEXI_NEW_ITEM'), 'itemadd');
            // Creating new item
        }
        // **************
        // Common Buttons
        // **************
        // Applying new item type is a special case that has not loaded custom fieds yet
        JToolBarHelper::apply($item->type_id ? 'items.apply' : 'items.apply_type', !$isnew ? 'FLEXI_APPLY' : ($typesselected->id ? 'FLEXI_ADD' : 'FLEXI_APPLY_TYPE'), false);
        /*if (!$isnew || $item->version) flexicontent_html::addToolBarButton(
        		'FLEXI_FAST_APPLY', $btn_name='apply_ajax', $full_js="Joomla.submitbutton('items.apply_ajax')", $msg_alert='', $msg_confirm='',
        		$btn_task='items.apply_ajax', $extra_js='', $btn_list=false, $btn_menu=true, $btn_confirm=false, $btn_class="".$tip_class, $btn_icon="icon-loop",
        		'data-placement="bottom" title="Fast saving, without reloading the form. <br/><br/>Note: new files will not be uploaded, <br/>- in such a case please use \'Apply\'"');*/
        if (!$isnew || $item->version) {
            JToolBarHelper::save('items.save');
        }
        if (!$isnew || $item->version) {
            JToolBarHelper::custom('items.saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false);
        }
        JToolBarHelper::cancel('items.cancel');
        // ***********************
        // Add a preview button(s)
        // ***********************
        //$_sh404sef = JPluginHelper::isEnabled('system', 'sh404sef') && $config->get('sef');
        $_sh404sef = defined('SH404SEF_IS_RUNNING') && $config->get('sef');
        if ($cid) {
            // Domain URL and autologin vars
            $server = JURI::getInstance()->toString(array('scheme', 'host', 'port'));
            $autologin = '';
            //$params->get('autoflogin', 1) ? '&fcu='.$user->username . '&fcp='.$user->password : '';
            // Check if we are in the backend, in the back end we need to set the application to the site app instead
            // we do not remove 'isAdmin' check so that we can copy later without change, e.g. to a plugin
            $isAdmin = JFactory::getApplication()->isAdmin();
            if ($isAdmin && !$_sh404sef) {
                JFactory::$application = JApplication::getInstance('site');
            }
            // Create the URL
            $item_url = FlexicontentHelperRoute::getItemRoute($item->id . ':' . $item->alias, $categories[$item->catid]->slug) . ($item->language != '*' ? '&lang=' . substr($item->language, 0, 2) : '');
            $item_url = $_sh404sef ? Sh404sefHelperGeneral::getSefFromNonSef($item_url, $fullyQualified = true, $xhtml = false, $ssl = null) : JRoute::_($item_url);
            // Check if we are in the backend again
            // In backend we need to remove administrator from URL as it is added even though we've set the application to the site app
            if ($isAdmin && !$_sh404sef) {
                $admin_folder = str_replace(JURI::root(true), '', JURI::base(true));
                $item_url = str_replace($admin_folder . '/', '/', $item_url);
                // Restore application
                JFactory::$application = JApplication::getInstance('administrator');
            }
            $previewlink = $item_url . (strstr($item_url, '?') ? '&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"');
            }
        }
        // Check if saving an item that translates an original content in site's default language
        $site_default = substr(flexicontent_html::getSiteDefaultLang(), 0, 2);
        $is_content_default_lang = $site_default == substr($item->language, 0, 2);
        // *****************************************************************************
        // Get (CORE & CUSTOM) fields and their VERSIONED values and then
        // (a) Apply Content Type Customization to CORE fields (label, description, etc)
        // (b) Create the edit html of the CUSTOM fields by triggering 'onDisplayField'
        // *****************************************************************************
        if ($print_logging_info) {
            $start_microtime = microtime(true);
        }
        $fields = $this->get('Extrafields');
        $item->fields =& $fields;
        if ($print_logging_info) {
            $fc_run_times['get_field_vals'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
        }
        if ($print_logging_info) {
            $start_microtime = microtime(true);
        }
        $jcustom = $app->getUserState('com_flexicontent.edit.item.custom');
        //print_r($jcustom);
        foreach ($fields as $field) {
            // a. Apply CONTENT TYPE customizations to CORE FIELDS, e.g a type specific label & description
            // NOTE: the field parameters are already created so there is not need to call this for CUSTOM fields, which do not have CONTENT TYPE customizations
            if ($field->iscore) {
                FlexicontentFields::loadFieldConfig($field, $item);
            }
            // b. Create field 's editing HTML (the form field)
            // NOTE: this is DONE only for CUSTOM fields, since form field html is created by the form for all CORE fields, EXCEPTION is the 'text' field (see bellow)
            if (!$field->iscore) {
                if (isset($jcustom[$field->name])) {
                    $field->value = array();
                    foreach ($jcustom[$field->name] as $i => $_val) {
                        $field->value[$i] = $_val;
                    }
                }
                $is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id);
                if ($is_editable) {
                    FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayField', array(&$field, &$item));
                    if ($field->untranslatable) {
                        $field->html = (!isset($field->html) ? '<div class="fc-mssg-inline fc-warning" style="margin:0 4px 6px 4px; max-width: unset;">' . JText::_('FLEXI_PLEASE_PUBLISH_THIS_PLUGIN') . '</div><div class="clear"></div>' : '') . '<div class="alert alert-info fc-small fc-iblock" style="margin:0 4px 6px 4px; max-width: unset;">' . JText::_('FLEXI_FIELD_VALUE_IS_NON_TRANSLATABLE') . '</div>' . "\n" . (isset($field->html) ? '<div class="clear"></div>' . $field->html : '');
                    }
                } else {
                    if ($field->valueseditable == 1) {
                        $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>';
                    } else {
                        if ($field->valueseditable == 2) {
                            FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item));
                            $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>' . "\n" . $field->display;
                        } else {
                            if ($field->valueseditable == 3) {
                                FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item));
                                $field->html = $field->display;
                            } else {
                                if ($field->valueseditable == 4) {
                                    $field->html = '';
                                    $field->formhidden = 4;
                                }
                            }
                        }
                    }
                }
            }
            // c. Create main text field, via calling the display function of the textarea field (will also check for tabs)
            if ($field->field_type == 'maintext') {
                if (isset($item->item_translations)) {
                    $shortcode = substr($item->language, 0, 2);
                    foreach ($item->item_translations as $lang_id => $t) {
                        if ($shortcode == $t->shortcode) {
                            continue;
                        }
                        $field->name = array('jfdata', $t->shortcode, 'text');
                        $field->value[0] = html_entity_decode($t->fields->text->value, ENT_QUOTES, 'UTF-8');
                        FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item));
                        $t->fields->text->tab_labels = $field->tab_labels;
                        $t->fields->text->html = $field->html;
                        unset($field->tab_labels);
                        unset($field->html);
                    }
                }
                $field->name = 'text';
                // NOTE: We use the text created by the model and not the text retrieved by the CORE plugin code, which maybe overwritten with JoomFish/Falang data
                $field->value[0] = $item->text;
                // do not decode special characters this was handled during saving !
                // Render the field's (form) HTML
                FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item));
            }
        }
        if ($print_logging_info) {
            $fc_run_times['render_field_html'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
        }
        // *************************
        // Get tags used by the item
        // *************************
        $usedtagsIds = $this->get('UsedtagsIds');
        // NOTE: This will normally return the already set versioned value of tags ($item->tags)
        $usedtags = $model->getUsedtagsData($usedtagsIds);
        // *******************************
        // Get categories used by the item
        // *******************************
        if ($isnew) {
            // Case for preselected main category for new items
            $maincat = $item->catid ? $item->catid : JRequest::getInt('maincat', 0);
            if (!$maincat) {
                $maincat = $app->getUserStateFromRequest($option . '.items.filter_cats', 'filter_cats', '', 'int');
            }
            if ($maincat) {
                $selectedcats = array($maincat);
                $item->catid = $maincat;
            } else {
                $selectedcats = array();
            }
            if ($tparams->get('cid_default')) {
                $selectedcats = $tparams->get('cid_default');
            }
            if ($tparams->get('catid_default')) {
                $item->catid = $tparams->get('catid_default');
            }
        } else {
            // NOTE: This will normally return the already set versioned value of categories ($item->categories)
            $selectedcats = $this->get('Catsselected');
        }
        //$selectedcats 	= $isnew ? array() : $fields['categories']->value;
        //echo "<br/>row->tags: "; print_r($item->tags);
        //echo "<br/>usedtagsIds: "; print_r($usedtagsIds);
        //echo "<br/>usedtags (data): "; print_r($usedtags);
        //echo "<br/>row->categories: "; print_r($item->categories);
        //echo "<br/>selectedcats: "; print_r($selectedcats);
        // *********************************************************************************************
        // Build select lists for the form field. Only few of them are used in J1.6+, since we will use:
        // (a) form XML file to declare them and then (b) getInput() method form field to create them
        // *********************************************************************************************
        // First clean form data, we do this after creating the description field which may contain HTML
        JFilterOutput::objectHTMLSafe($item, ENT_QUOTES);
        $lists = array();
        // build state list
        $non_publishers_stategrp = $perms['isSuperAdmin'] || $item->state == -3 || $item->state == -4;
        $special_privelege_stategrp = $item->state == 2 || $perms['canarchive'] || ($item->state == -2 || $perms['candelete']);
        $state = array();
        // Using <select> groups
        if ($non_publishers_stategrp || $special_privelege_stategrp) {
            $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_PUBLISHERS_WORKFLOW_STATES'));
        }
        $state[] = JHTML::_('select.option', 1, JText::_('FLEXI_PUBLISHED'));
        $state[] = JHTML::_('select.option', 0, JText::_('FLEXI_UNPUBLISHED'));
        $state[] = JHTML::_('select.option', -5, JText::_('FLEXI_IN_PROGRESS'));
        // States reserved for workflow
        if ($non_publishers_stategrp) {
            $state[] = JHTML::_('select.optgroup', '');
            $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_NON_PUBLISHERS_WORKFLOW_STATES'));
        }
        if ($item->state == -3 || $perms['isSuperAdmin']) {
            $state[] = JHTML::_('select.option', -3, JText::_('FLEXI_PENDING'));
        }
        if ($item->state == -4 || $perms['isSuperAdmin']) {
            $state[] = JHTML::_('select.option', -4, JText::_('FLEXI_TO_WRITE'));
        }
        // Special access states
        if ($special_privelege_stategrp) {
            $state[] = JHTML::_('select.optgroup', '');
            $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_SPECIAL_ACTION_STATES'));
        }
        if ($item->state == 2 || $perms['canarchive']) {
            $state[] = JHTML::_('select.option', 2, JText::_('FLEXI_ARCHIVED'));
        }
        if ($item->state == -2 || $perms['candelete']) {
            $state[] = JHTML::_('select.option', -2, JText::_('FLEXI_TRASHED'));
        }
        // Close last <select> group
        if ($non_publishers_stategrp || $special_privelege_stategrp) {
            $state[] = JHTML::_('select.optgroup', '');
        }
        $fieldname = 'jform[state]';
        $elementid = 'jform_state';
        $class = 'use_select2_lib';
        $attribs = 'class="' . $class . '"';
        $lists['state'] = JHTML::_('select.genericlist', $state, $fieldname, $attribs, 'value', 'text', $item->state, $elementid);
        if (!FLEXI_J16GE) {
            $lists['state'] = str_replace('<optgroup label="">', '</optgroup>', $lists['state']);
        }
        // *** BOF: J2.5 SPECIFIC SELECT LISTS
        if (FLEXI_J16GE) {
            // build featured flag
            $fieldname = 'jform[featured]';
            $elementid = 'jform_featured';
            /*
            $options = array();
            $options[] = JHTML::_('select.option',  0, JText::_( 'FLEXI_NO' ) );
            $options[] = JHTML::_('select.option',  1, JText::_( 'FLEXI_YES' ) );
            $attribs = FLEXI_J16GE ? ' style ="float:none!important;" '  :  '';   // this is not right for J1.5' style ="float:left!important;" ';
            $lists['featured'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', $item->featured, $elementid);
            */
            $classes = !$prettycheckable_added ? '' : ' use_prettycheckable ';
            $attribs = ' class="' . $classes . '" ';
            $i = 1;
            $options = array(0 => JText::_('FLEXI_NO'), 1 => JText::_('FLEXI_YES'));
            $lists['featured'] = '';
            foreach ($options as $option_id => $option_label) {
                $checked = $option_id == $item->featured ? ' checked="checked"' : '';
                $elementid_no = $elementid . '_' . $i;
                if (!$prettycheckable_added) {
                    $lists['featured'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">';
                }
                $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"';
                $lists['featured'] .= ' <input type="radio" id="' . $elementid_no . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />';
                if (!$prettycheckable_added) {
                    $lists['featured'] .= '&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 ? JText::_('FLEXI_NO_SUBSCRIBERS_EXIST') : '';
        } else {
            // b. Check if notification emails to subscribers , were already sent during current session
            $subscribers_notified = $session->get('subscribers_notified', array(), 'flexicontent');
            if (!empty($subscribers_notified[$item->id])) {
                $lists['notify'] = JText::_('FLEXI_SUBSCRIBERS_ALREADY_NOTIFIED');
            } else {
                // build favs notify field
                $fieldname = 'jform[notify]';
                $elementid = 'jform_notify';
                /*
                $attribs = FLEXI_J16GE ? ' style ="float:none!important;" '  :  '';   // this is not right for J1.5' style ="float:left!important;" ';
                $lists['notify'] = '<input type="checkbox" name="jform[notify]" id="jform_notify" '.$attribs.' /> '. $lbltxt;
                */
                $classes = !$prettycheckable_added ? '' : ' use_prettycheckable ';
                $attribs = ' class="' . $classes . '" ';
                $lbltxt = $subscribers . ' ' . JText::_($subscribers > 1 ? 'FLEXI_SUBSCRIBERS' : 'FLEXI_SUBSCRIBER');
                if (!$prettycheckable_added) {
                    $lists['notify'] .= '<label class="fccheckradio_lbl" for="' . $elementid . '">';
                }
                $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . $lbltxt . '" data-labelPosition="right" data-customClass="fcradiocheck"';
                $lists['notify'] = ' <input type="checkbox" id="' . $elementid . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="1" ' . $extra_params . ' checked="checked" />';
                if (!$prettycheckable_added) {
                    $lists['notify'] .= '&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;
        }
    }
 /**
  * Creates the favourite icons
  *
  * @param array $params
  * @since 1.0
  */
 static function favicon($field, $favoured, $item, $type = 'item')
 {
     $user = JFactory::getUser();
     $item_id = $item->id;
     // avoid using $field, we also support favoured categories
     $item_title = $item->title;
     static $js_and_css_added = false;
     static $tooltip_class, $addremove_tip, $img_fav_add, $img_fav_delete;
     if (!$js_and_css_added) {
         $document = JFactory::getDocument();
         $cparams = JComponentHelper::getParams('com_flexicontent');
         $tooltip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip';
         $text = $user->id ? 'FLEXI_ADDREMOVE_FAVOURITE' : 'FLEXI_FAVOURE';
         $overlib = $user->id ? 'FLEXI_ADDREMOVE_FAVOURITE_TIP' : 'FLEXI_FAVOURE_LOGIN_TIP';
         $addremove_tip = flexicontent_html::getToolTip($text, $overlib, 1, 1);
         // Make sure mootools are loaded before our js
         //FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
         // Load tooltips JS
         if ($cparams->get('add_tooltips', 1)) {
             FLEXI_J30GE ? JHtml::_('bootstrap.tooltip') : JHTML::_('behavior.tooltip');
         }
         flexicontent_html::loadFramework('jQuery');
         flexicontent_html::loadFramework('flexi_tmpl_common');
         $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/fcfav.js', FLEXI_VERSION);
         JText::script('FLEXI_YOUR_BROWSER_DOES_NOT_SUPPORT_AJAX', true);
         JText::script('FLEXI_LOADING', true);
         JText::script('FLEXI_ADDED_TO_YOUR_FAVOURITES', true);
         JText::script('FLEXI_YOU_NEED_TO_LOGIN', true);
         JText::script('FLEXI_REMOVED_FROM_YOUR_FAVOURITES', true);
         JText::script('FLEXI_USERS', true);
         //5
         JText::script('FLEXI_FAVOURE', true);
         JText::script('FLEXI_REMOVE_FAVOURITE', true);
         //7
         JText::script('FLEXI_FAVS_YOU_HAVE_SUBSCRIBED', true);
         JText::script('FLEXI_FAVS_CLICK_TO_SUBSCRIBE', true);
         JText::script('FLEXI_TOTAL', true);
         $js = "\n\t\t\t\tvar fcfav_rfolder = '" . JURI::root(true) . "';\n\t\t\t";
         $document->addScriptDeclaration($js);
         $js_and_css_added = true;
     }
     $output = "";
     if ($user->id && $favoured) {
         $alt_text = JText::_('FLEXI_REMOVE_FAVOURITE');
         if (!$img_fav_delete) {
             $img_fav_delete = JHTML::image('components/com_flexicontent/assets/images/' . 'heart_delete.png', $alt_text, NULL);
         }
         $onclick = "javascript:FCFav(" . $item_id . ", '" . $type . "')";
         $link = "javascript:void(null)";
         $output .= '<span class="fcfav_delete">' . ' <a id="favlink_' . $type . '_' . $item_id . '" href="' . $link . '" onclick="' . $onclick . '" class="btn fcfav-reponse' . $tooltip_class . '" title="' . $addremove_tip . '">' . $img_fav_delete . '</a>' . ' <span class="fav_item_id" style="display:none;">' . $item_id . '</span>' . ' <span class="fav_item_title" style="display:none;">' . $item_title . '</span>' . '</span>';
     } elseif ($user->id) {
         $alt_text = JText::_('FLEXI_FAVOURE');
         if (!$img_fav_add) {
             $img_fav_add = JHTML::image('components/com_flexicontent/assets/images/' . 'heart_add.png', $alt_text, NULL);
         }
         $onclick = "javascript:FCFav(" . $item_id . ", '" . $type . "')";
         $link = "javascript:void(null)";
         $output .= '<span class="fcfav_add">' . ' <a id="favlink_' . $type . '_' . $item_id . '" href="' . $link . '" onclick="' . $onclick . '" class="btn fcfav-reponse' . $tooltip_class . '" title="' . $addremove_tip . '">' . $img_fav_add . '</a>' . ' <span class="fav_item_id" style="display:none;">' . $item_id . '</span>' . ' <span class="fav_item_title" style="display:none;">' . $item_title . '</span>' . '</span>';
     } else {
         $attribs = 'class="btn ' . $tooltip_class . '" title="' . $addremove_tip . '" onclick="alert(\'' . JText::_('FLEXI_FAVOURE_LOGIN_TIP') . '\')"';
         $image = JHTML::image('components/com_flexicontent/assets/images/' . 'heart_login.png', JText::_('FLEXI_FAVOURE'), $attribs);
         $output = $image;
     }
     return $output;
 }
Esempio n. 15
0
 function display($tpl = null)
 {
     //initialise variables
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $cparams = JComponentHelper::getParams('com_flexicontent');
     $user = JFactory::getUser();
     //add css to document
     $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VHASH);
     $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VHASH);
     // Add JS frameworks
     flexicontent_html::loadFramework('select2');
     // Add js function to overload the joomla submitform validation
     JHTML::_('behavior.formvalidation');
     // load default validation JS to make sure it is overriden
     $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VHASH);
     $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VHASH);
     //Load pane behavior
     jimport('joomla.html.pane');
     //Get data from the model
     $model = $this->getModel();
     $row = $this->get(FLEXI_J16GE ? 'Item' : 'Type');
     $form = $this->get('Form');
     $themes = flexicontent_tmpl::getTemplates();
     $tmpls = $themes->items;
     //create the toolbar
     if ($row->id) {
         JToolBarHelper::title(JText::_('FLEXI_EDIT_TYPE'), 'typeedit');
     } else {
         JToolBarHelper::title(JText::_('FLEXI_ADD_TYPE'), 'typeadd');
     }
     $ctrl = FLEXI_J16GE ? 'types.' : '';
     JToolBarHelper::apply($ctrl . 'apply');
     JToolBarHelper::save($ctrl . 'save');
     JToolBarHelper::custom($ctrl . 'saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false);
     JToolBarHelper::cancel($ctrl . 'cancel');
     // fail if checked out not by 'me'
     if ($row->id) {
         if ($model->isCheckedOut($user->get('id'))) {
             JError::raiseWarning('SOME_ERROR_CODE', $row->name . ' ' . JText::_('FLEXI_EDITED_BY_ANOTHER_ADMIN'));
             $app->redirect('index.php?option=com_flexicontent&view=types');
         }
     }
     if (FLEXI_ACCESS) {
         $itemscreatable[] = JHTML::_('select.option', 0, JText::_('FLEXI_ANY_AUTHOR'));
         $itemscreatable[] = JHTML::_('select.option', 1, JText::_('FLEXI_USE_ACL_TO_HIDE'));
         $itemscreatable[] = JHTML::_('select.option', 2, JText::_('FLEXI_USE_ACL_TO_DISABLE'));
         $itemscreatable_fieldname = FLEXI_J16GE ? 'jform[itemscreatable]' : 'itemscreatable';
         $lists['itemscreatable'] = JHTML::_('select.genericlist', $itemscreatable, $itemscreatable_fieldname, '', 'value', 'text', $row->itemscreatable);
     }
     //build access level list
     if (!FLEXI_J16GE) {
         if (FLEXI_ACCESS) {
             $lang = JFactory::getLanguage();
             $lang->_strings['FLEXIACCESS_PADD'] = 'Create Items';
             $lists['access'] = FAccess::TabGmaccess($row, 'type', 1, 1, 0, 0, 0, 0, 0, 0, 0);
         } else {
             $lists['access'] = JHTML::_('list.accesslevel', $row);
         }
     }
     if (!FLEXI_J16GE) {
         //clean data
         JFilterOutput::objectHTMLSafe($row, ENT_QUOTES);
         //create the parameter form
         $form = new JParameter($row->attribs, JPATH_COMPONENT . DS . 'models' . DS . 'type.xml');
         //$form->loadINI($row->attribs);
         //echo "<pre>"; print_r($form->_xml['themes']->_children[0]);  echo "<pre>"; print_r($form->_xml['themes']->param[0]); exit;
         foreach ($form->_xml['themes']->_children as $i => $child) {
             if (isset($child->_attributes['enableparam']) && !$cparams->get($child->_attributes['enableparam'])) {
                 unset($form->_xml['themes']->_children[$i]);
                 unset($form->_xml['themes']->param[$i]);
             }
         }
     }
     // 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;
             // ... values applied at the template form file
         } else {
             $tmpl->params->loadINI($row->attribs);
         }
     }
     //assign data to template
     // assign permissions for J2.5
     if (FLEXI_J16GE) {
         $permission = FlexicontentHelperPerm::getPerm();
         $this->assignRef('permission', $permission);
     }
     $this->assignRef('document', $document);
     $this->assignRef('row', $row);
     $this->assignRef('form', $form);
     $this->assignRef('tmpls', $tmpls);
     if (!FLEXI_J16GE) {
         $pane = JPane::getInstance('sliders');
         $this->assignRef('pane', $pane);
         $this->assignRef('lists', $lists);
     }
     parent::display($tpl);
 }
Esempio n. 16
0
 function display($tpl = null)
 {
     //initialise variables
     $app = JFactory::getApplication();
     $cparams = JComponentHelper::getParams('com_flexicontent');
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     $document = JFactory::getDocument();
     $option = JRequest::getCmd('option');
     $view = JRequest::getVar('view');
     $print_logging_info = $cparams->get('print_logging_info');
     if ($print_logging_info) {
         global $fc_run_times;
     }
     flexicontent_html::loadFramework('select2');
     JHTML::_('behavior.tooltip');
     // Get filters
     $count_filters = 0;
     // Get filter vars
     $filter_order = $app->getUserStateFromRequest($option . '.' . $view . '.filter_order', 'filter_order', 't.name', 'cmd');
     $filter_order_Dir = $app->getUserStateFromRequest($option . '.' . $view . '.filter_order_Dir', 'filter_order_Dir', '', 'word');
     $filter_state = $app->getUserStateFromRequest($option . '.' . $view . '.filter_state', 'filter_state', '', 'word');
     $filter_assigned = $app->getUserStateFromRequest($option . '.' . $view . '.filter_assigned', 'filter_assigned', '', 'word');
     if ($filter_state) {
         $count_filters++;
     }
     if ($filter_assigned) {
         $count_filters++;
     }
     $search = $app->getUserStateFromRequest($option . '.' . $view . '.search', 'search', '', 'string');
     $search = FLEXI_J16GE ? $db->escape(trim(JString::strtolower($search))) : $db->getEscaped(trim(JString::strtolower($search)));
     // **************************
     // Add css and js to document
     // **************************
     $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('CanTags');
     // Create document/toolbar titles
     $doc_title = JText::_('FLEXI_TAGS');
     $site_title = $document->getTitle();
     JToolBarHelper::title($doc_title, 'tags');
     $document->setTitle($doc_title . ' - ' . $site_title);
     // Create the toolbar
     $js = "jQuery(document).ready(function(){";
     $contrl = FLEXI_J16GE ? "tags." : "";
     $toolbar = JToolBar::getInstance('toolbar');
     if ($perms->CanConfig) {
         $btn_task = '';
         $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent&view=tags&layout=import&tmpl=component';
         if (FLEXI_J30GE || !FLEXI_J16GE) {
             // Layout of Popup button broken in J3.1, add in J1.5 it generates duplicate HTML tag id (... just for validation), so add manually
             $js .= "\n\t\t\t\t\tjQuery('#toolbar-import a.toolbar, #toolbar-import button')\n\t\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 430, y: 500}, onClose: function() {}}');\n\t\t\t\t";
             JToolBarHelper::custom($btn_task, 'import.png', 'import_f2.png', 'FLEXI_IMPORT', false);
             JHtml::_('behavior.modal', '#toolbar-import a.toolbar, #toolbar-import button');
         } else {
             $toolbar->appendButton('Popup', 'import', JText::_('FLEXI_IMPORT'), str_replace('&', '&amp;', $popup_load_url), 430, 500);
         }
         JToolBarHelper::divider();
         JToolBarHelper::spacer();
     }
     JToolBarHelper::publishList($contrl . 'publish');
     JToolBarHelper::unpublishList($contrl . 'unpublish');
     JToolBarHelper::addNew($contrl . 'add');
     JToolBarHelper::editList($contrl . 'edit');
     //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove');
     // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag)
     $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE'));
     $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM');
     $btn_task = $contrl . 'remove';
     $extra_js = "";
     flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true);
     if ($perms->CanConfig) {
         JToolBarHelper::divider();
         JToolBarHelper::spacer();
         $session = JFactory::getSession();
         $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent');
         $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940;
         $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent');
         $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550;
         JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration');
     }
     $js .= "});";
     $document->addScriptDeclaration($js);
     // Get data from the model
     if ($print_logging_info) {
         $start_microtime = microtime(true);
     }
     $model = $this->getModel();
     $rows = $this->get('Data');
     if ($print_logging_info) {
         @($fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
     }
     // Get assigned items (via separate query),  (if not already retrieved)
     // ... when we order by assigned then this is already done via main DB query
     if ($filter_order != 'nrassigned') {
         $rowids = array();
         foreach ($rows as $row) {
             $rowids[] = $row->id;
         }
         if ($print_logging_info) {
             $start_microtime = microtime(true);
         }
         $rowtotals = $model->getAssignedItems($rowids);
         if ($print_logging_info) {
             @($fc_run_times['execute_sec_queries'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
         }
         foreach ($rows as $row) {
             $row->nrassigned = isset($rowtotals[$row->id]) ? $rowtotals[$row->id]->nrassigned : 0;
         }
     }
     // Create pagination object
     $pagination = $this->get('Pagination');
     $lists = array();
     // build orphaned/assigned filter
     $assigned = array();
     $assigned[] = JHTML::_('select.option', '', '-');
     $assigned[] = JHTML::_('select.option', 'O', JText::_('FLEXI_ORPHANED'));
     $assigned[] = JHTML::_('select.option', 'A', JText::_('FLEXI_ASSIGNED'));
     $lists['assigned'] = ($filter_assigned || 1 ? '<label class="label">' . JText::_('FLEXI_ASSIGNED') . '</label>' : '') . JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_assigned);
     // build publication state filter
     $states = array();
     $states[] = JHTML::_('select.option', '', '-');
     $states[] = JHTML::_('select.option', 'P', JText::_('FLEXI_PUBLISHED'));
     $states[] = JHTML::_('select.option', 'U', JText::_('FLEXI_UNPUBLISHED'));
     //$states[] = JHTML::_('select.option',  '-2', JText::_( 'FLEXI_TRASHED' ) );
     $lists['state'] = ($filter_state || 1 ? '<label class="label">' . JText::_('FLEXI_STATE') . '</label>' : '') . JHTML::_('select.genericlist', $states, 'filter_state', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_state);
     //JHTML::_('grid.state', $filter_state );
     // text search filter
     $lists['search'] = $search;
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     //assign data to template
     $this->assignRef('count_filters', $count_filters);
     $this->assignRef('lists', $lists);
     $this->assignRef('rows', $rows);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('option', $option);
     $this->assignRef('view', $view);
     $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null;
     parent::display($tpl);
 }
Esempio n. 17
0
    function onDisplayField(&$field, &$item)
    {
        if (!in_array($field->field_type, self::$field_types)) {
            return;
        }
        $field->label = JText::_($field->label);
        $use_ingroup = $field->parameters->get('use_ingroup', 0);
        $ajax = !empty($field->isAjax);
        if ($use_ingroup) {
            $field->formhidden = 3;
        }
        if ($use_ingroup && empty($field->ingroup) && !$ajax) {
            return;
        }
        // initialize framework objects and other variables
        $document = JFactory::getDocument();
        // some parameter shortcuts
        $sql_mode = $field->parameters->get('sql_mode', 0);
        $field_elements = $field->parameters->get('field_elements');
        $cascade_after = (int) $field->parameters->get('cascade_after', 0);
        // ****************
        // Number of values
        // ****************
        $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
        $max_values = $use_ingroup ? 0 : (int) $field->parameters->get('max_values', 0);
        $required = $field->parameters->get('required', 0);
        $required = $required ? ' required' : '';
        $add_position = (int) $field->parameters->get('add_position', 3);
        // **************
        // Value handling
        // **************
        // Default value
        $value_usage = $field->parameters->get('default_value_use', 0);
        $default_value = $item->version == 0 || $value_usage > 0 ? trim($field->parameters->get('default_value', '')) : '';
        // *************************
        // Input field configuration
        // *************************
        // DISPLAY using select2 JS
        $use_jslib = $field->parameters->get('use_jslib', 1);
        $use_select2 = $use_jslib == 1;
        static $select2_added = null;
        if ($use_select2 && $select2_added === null) {
            $select2_added = flexicontent_html::loadFramework('select2');
        }
        // Parameters for DISPLAY with / without using select2 JS
        // ... none such parameters
        // Custom HTML placed before / after form field
        $opentag = $field->parameters->get('opentag_form', '');
        $closetag = $field->parameters->get('closetag_form', '');
        // Initialise property with default value
        if (!$field->value) {
            $field->value = array($default_value);
        }
        // CSS classes of value container
        $value_classes = 'fcfieldval_container valuebox fcfieldval_container_' . $field->id;
        // Field name and HTML TAG id
        $valueholder_nm = 'custom[_fcfield_valueholder_][' . $field->name . ']';
        $valueholder_id = 'custom__fcfield_valueholder__' . $field->name;
        $fieldname = 'custom[' . $field->name . ']';
        $elementid = 'custom_' . $field->name;
        $js = "";
        $css = "";
        // *********************************************************************************************
        // Handle adding the needed JS code to CASCADE (listen to) changes of the dependent master field
        // *********************************************************************************************
        if ($cascade_after && !$ajax) {
            $byIds = FlexicontentFields::indexFieldsByIds($item->fields);
            if (isset($byIds[$cascade_after])) {
                $cascade_prompt = $field->parameters->get('cascade_prompt', '');
                $cascade_prompt = $cascade_prompt ? JText::_($cascade_prompt) : JText::_('FLEXI_PLEASE_SELECT') . ': ' . $byIds[$cascade_after]->label;
                $srcELid = 'custom_' . $byIds[$cascade_after]->name;
                $trgELid = $elementid;
                // Get values of cascade (on) source field
                $field->valgrps = $byIds[$cascade_after]->value ? $byIds[$cascade_after]->value : array();
                foreach ($field->valgrps as &$vg) {
                    if (is_array($vg)) {
                    } else {
                        if (@unserialize($vg) !== false || $vg === 'b:0;') {
                            $vg = unserialize($vg);
                        } else {
                            $vg = array($vg);
                        }
                    }
                }
                unset($vg);
            } else {
                $cascade_after = 0;
                echo 'Error in field ' . $field->label . ' [' . $field->id . ']' . ' cannot cascaded after field no: ' . $cascade_after . ', field was not found <br/>';
            }
        } else {
            if ($cascade_after && $ajax) {
                $field->valgrps = isset($field->valgrps) ? $field->valgrps : array();
                $field->valgrps = is_array($field->valgrps) ? $field->valgrps : preg_split("/\\s*,\\s*/u", trim($field->valgrps));
            }
        }
        // ***********************
        // Handle multiple records
        // ***********************
        if ($multiple && !$ajax) {
            // Add the drag and drop sorting feature
            if (!$use_ingroup) {
                $js .= "\n\t\t\tjQuery(document).ready(function(){\n\t\t\t\tjQuery('#sortables_" . $field->id . "').sortable({\n\t\t\t\t\thandle: '.fcfield-drag-handle',\n\t\t\t\t\tcontainment: 'parent',\n\t\t\t\t\ttolerance: 'pointer'\n\t\t\t\t});\n\t\t\t});\n\t\t\t";
            }
            if ($max_values) {
                JText::script("FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED", true);
            }
            $js .= "\n\t\t\tvar uniqueRowNum" . $field->id . "\t= " . count($field->value) . ";  // Unique row number incremented only\n\t\t\tvar rowCount" . $field->id . "\t= " . count($field->value) . ";      // Counts existing rows to be able to limit a max number of values\n\t\t\tvar maxValues" . $field->id . " = " . $max_values . ";\n\t\t\t\n\t\t\tfunction addField" . $field->id . "(el, groupval_box, fieldval_box, params)\n\t\t\t{\n\t\t\t\tvar insert_before   = (typeof params!== 'undefined' && typeof params.insert_before   !== 'undefined') ? params.insert_before   : 0;\n\t\t\t\tvar remove_previous = (typeof params!== 'undefined' && typeof params.remove_previous !== 'undefined') ? params.remove_previous : 0;\n\t\t\t\tvar scroll_visible  = (typeof params!== 'undefined' && typeof params.scroll_visible  !== 'undefined') ? params.scroll_visible  : 1;\n\t\t\t\tvar animate_visible = (typeof params!== 'undefined' && typeof params.animate_visible !== 'undefined') ? params.animate_visible : 1;\n\t\t\t\t\n\t\t\t\tif((rowCount" . $field->id . " >= maxValues" . $field->id . ") && (maxValues" . $field->id . " != 0)) {\n\t\t\t\t\talert(Joomla.JText._('FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED') + maxValues" . $field->id . ");\n\t\t\t\t\treturn 'cancel';\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Find last container of fields and clone it to create a new container of fields\n\t\t\t\tvar lastField = fieldval_box ? fieldval_box : jQuery(el).prev().children().last();\n\t\t\t\tvar newField  = lastField.clone();\n\t\t\t\t\n\t\t\t\t// Update value holder\n\t\t\t\tnewField.find('.fcfield_value_holder')\n\t\t\t\t\t.attr('id', '" . $valueholder_id . "_'+uniqueRowNum" . $field->id . ")\n\t\t\t\t\t.attr('name', '" . $valueholder_nm . "['+uniqueRowNum" . $field->id . "+']');\n\t\t\t\t\n\t\t\t\t// Update the new select field\n\t\t\t\tvar elem= newField.find('select.fcfield_textselval').first();\n\t\t\t\telem.val('');\n\t\t\t\telem.attr('name', '" . $fieldname . "['+uniqueRowNum" . $field->id . "+']" . (self::$valueIsArr ? '[]' : '') . "');\n\t\t\t\telem.attr('id', '" . $elementid . "_'+uniqueRowNum" . $field->id . ");\n\t\t\t\telem.attr('data-uniqueRowNum', uniqueRowNum" . $field->id . ");\n\t\t\t\t\n\t\t\t\t// Re-init any select2 elements\n\t\t\t\tvar has_select2 = newField.find('div.select2-container').length != 0;\n\t\t\t\tif (has_select2) {\n\t\t\t\t\tnewField.find('div.select2-container').remove();\n\t\t\t\t\tnewField.find('select.use_select2_lib').select2('destroy').show().select2();\n\t\t\t\t}\n\t\t\t\t";
            // Add new field to DOM
            $js .= "\n\t\t\t\tlastField ?\n\t\t\t\t\t(insert_before ? newField.insertBefore( lastField ) : newField.insertAfter( lastField ) ) :\n\t\t\t\t\tnewField.appendTo( jQuery('#sortables_" . $field->id . "') ) ;\n\t\t\t\tif (remove_previous) lastField.remove();\n\t\t\t\t";
            // Listen to the changes of cascade-after field
            if ($cascade_after) {
                $js .= "\n\t\t\t\tfc_cascade_field_funcs['" . $srcELid . "_'+uniqueRowNum" . $field->id . "] = function(rowNo){\n\t\t\t\t\treturn function () {\n\t\t\t\t\t\tfcCascadedField(" . $field->id . ", '" . $item->id . "', '" . $field->field_type . "', 'select#" . $srcELid . "_'+rowNo+', input." . $srcELid . "_'+rowNo, '" . $trgELid . "_'+rowNo, '" . $cascade_prompt . "', " . self::$promptEnabled . ", rowNo);\n\t\t\t\t\t}\n\t\t\t\t}(uniqueRowNum" . $field->id . ");\n\t\t\t\tfc_cascade_field_funcs['" . $srcELid . "_'+uniqueRowNum" . $field->id . "]();\n\t\t\t\t";
            }
            // Add new element to sortable objects (if field not in group)
            if (!$use_ingroup) {
                $js .= "\n\t\t\t\t//jQuery('#sortables_" . $field->id . "').sortable('refresh');  // Refresh was done appendTo ?\n\t\t\t\t";
            }
            // Show new field, increment counters
            $js .= "\n\t\t\t\t//newField.fadeOut({ duration: 400, easing: 'swing' }).fadeIn({ duration: 200, easing: 'swing' });\n\t\t\t\tif (scroll_visible) fc_scrollIntoView(newField, 1);\n\t\t\t\tif (animate_visible) newField.css({opacity: 0.1}).animate({ opacity: 1 }, 800);\n\t\t\t\t\n\t\t\t\t// Enable tooltips on new element\n\t\t\t\tnewField.find('.hasTooltip').tooltip({'html': true,'container': newField});\n\t\t\t\t\n\t\t\t\trowCount" . $field->id . "++;       // incremented / decremented\n\t\t\t\tuniqueRowNum" . $field->id . "++;   // incremented only\n\t\t\t}\n\n\t\t\tfunction deleteField" . $field->id . "(el, groupval_box, fieldval_box)\n\t\t\t{\n\t\t\t\t// Find field value container\n\t\t\t\tvar row = fieldval_box ? fieldval_box : jQuery(el).closest('li');\n\t\t\t\t\n\t\t\t\t// Add empty container if last element, instantly removing the given field value container\n\t\t\t\tif(rowCount" . $field->id . " == 1)\n\t\t\t\t\taddField" . $field->id . "(null, groupval_box, row, {remove_previous: 1, scroll_visible: 0, animate_visible: 0});\n\t\t\t\t\n\t\t\t\t// Remove if not last one, if it is last one, we issued a replace (copy,empty new,delete old) above\n\t\t\t\tif(rowCount" . $field->id . " > 1) {\n\t\t\t\t\t// Destroy the remove/add/etc buttons, so that they are not reclicked, while we do the hide effect (before DOM removal of field value)\n\t\t\t\t\trow.find('.fcfield-delvalue').remove();\n\t\t\t\t\trow.find('.fcfield-insertvalue').remove();\n\t\t\t\t\trow.find('.fcfield-drag-handle').remove();\n\t\t\t\t\t// Do hide effect then remove from DOM\n\t\t\t\t\trow.slideUp(400, function(){ jQuery(this).remove(); });\n\t\t\t\t\trowCount" . $field->id . "--;\n\t\t\t\t}\n\t\t\t}\n\t\t\t";
            $css .= '';
            $remove_button = '<span class="fcfield-delvalue' . (JComponentHelper::getParams('com_flexicontent')->get('form_font_icons', 1) ? ' fcfont-icon' : '') . '" title="' . JText::_('FLEXI_REMOVE_VALUE') . '" onclick="deleteField' . $field->id . '(this);"></span>';
            $move2 = '<span class="fcfield-drag-handle' . (JComponentHelper::getParams('com_flexicontent')->get('form_font_icons', 1) ? ' fcfont-icon' : '') . '" title="' . JText::_('FLEXI_CLICK_TO_DRAG') . '"></span>';
            $add_here = '';
            $add_here .= $add_position == 2 || $add_position == 3 ? '<span class="fcfield-insertvalue fc_before' . (JComponentHelper::getParams('com_flexicontent')->get('form_font_icons', 1) ? ' fcfont-icon' : '') . '" onclick="addField' . $field->id . '(null, jQuery(this).closest(\'ul\'), jQuery(this).closest(\'li\'), {insert_before: 1});" title="' . JText::_('FLEXI_ADD_BEFORE') . '"></span> ' : '';
            $add_here .= $add_position == 1 || $add_position == 3 ? '<span class="fcfield-insertvalue fc_after' . (JComponentHelper::getParams('com_flexicontent')->get('form_font_icons', 1) ? ' fcfont-icon' : '') . '"  onclick="addField' . $field->id . '(null, jQuery(this).closest(\'ul\'), jQuery(this).closest(\'li\'), {insert_before: 0});" title="' . JText::_('FLEXI_ADD_AFTER') . '"></span> ' : '';
        } else {
            $remove_button = '';
            $move2 = '';
            $add_here = '';
            $js .= '';
            $css .= '';
        }
        // Added field's custom CSS / JS
        if (!$ajax && $js) {
            $document->addScriptDeclaration($js);
        }
        if (!$ajax && $css) {
            $document->addStyleDeclaration($css);
        }
        // **************************
        // Get indexed element values
        // **************************
        // If cascading we will get it inside the value loop for every value, thus supporting field grouping properly
        $elements = !$cascade_after ? $this->getLimitedProps($field, $item) : array();
        if (!is_array($elements)) {
            $field->html = $elements;
            return;
        }
        // *****************************************
        // Create field's HTML display for item form
        // *****************************************
        // Create form field options
        $options = array();
        foreach ($elements as $element) {
            $options[] = JHTML::_('select.option', $element->value, $element->text);
        }
        // Create the attributes of the form field
        $display_as_select = 1;
        if ($display_as_select) {
            $classes = 'fcfield_textselval' . ($use_jslib && $select2_added ? ' use_select2_lib' : '');
            $classes .= $required;
            $onchange = '';
            // Extra properties
            $attribs = '';
            if ($classes) {
                $attribs .= ' class="' . $classes . '" ';
            }
            if ($onchange) {
                $attribs .= ' onchange="' . $onchange . '" ';
            }
        }
        // Handle case of FORM fields that each value is an array of values
        // (e.g. selectmultiple, checkbox), and that multi-value input is also enabled
        $is_array_already = is_array($field->value) ? is_array(reset($field->value)) : false;
        $values = self::$valueIsArr && !$multiple && !$is_array_already ? array($field->value) : $field->value;
        // *****************************************
        // Create field's HTML display for item form
        // *****************************************
        $field->html = array();
        $n = $ajax ? $field->valindex : 0;
        $per_val_js = '';
        foreach ($values as $value) {
            // Compatibility for serialized values
            if (self::$valueIsArr) {
                if (is_array($value)) {
                } else {
                    if (@unserialize($value) !== false || $value === 'b:0;') {
                        $value = unserialize($value);
                    }
                }
            }
            // Make sure value is an array
            if (!is_array($value)) {
                $value = strlen($value) ? array($value) : array();
            }
            // Skip empty if not in field group, and at least one value was added
            if (!count($value) && !$use_ingroup && $n) {
                continue;
            }
            // Get options according to cascading, this is here so that it works with field grouping too
            if ($cascade_after) {
                $elements = $this->getLimitedProps($field, $item, !$ajax ? $cascade_prompt : null, $ajax, $n);
                $options =& $elements;
            }
            if (!$ajax) {
                $fieldname_n = $fieldname . '[' . $n . ']' . (self::$valueIsArr ? '[]' : '');
                $elementid_n = $elementid . '_' . $n;
                $form_field = $opentag . JHTML::_('select.genericlist', $options, $fieldname_n, $attribs . ' data-uniqueRowNum="' . $n . '"', 'value', 'text', $value, $elementid_n) . $closetag;
                $field->html[] = '
					' . $form_field . '
					' . ($cascade_after ? '<span class="field_cascade_loading"></span>' : '') . '
					' . ($use_ingroup ? '<input type="hidden" class="fcfield_value_holder" name="' . $valueholder_nm . '[' . $n . ']" id="' . $valueholder_id . '_' . $n . '" value="-">' : '') . '
					' . ($use_ingroup ? '' : $move2) . '
					' . ($use_ingroup ? '' : $remove_button) . '
					' . ($use_ingroup || !$add_position ? '' : $add_here) . '
					';
                // Listen to the changes of cascade-after field
                if ($cascade_after && !$ajax) {
                    $per_val_js .= "\n\t\t\t\t\tfc_cascade_field_funcs['" . $srcELid . '_' . $n . "'] = function(){\n\t\t\t\t\t\tfcCascadedField(" . $field->id . ", '" . $item->id . "', '" . $field->field_type . "', 'select#" . $srcELid . '_' . $n . ", input." . $srcELid . '_' . $n . "', '" . $trgELid . '_' . $n . "', '" . $cascade_prompt . "', " . self::$promptEnabled . ", " . $n . ");\n\t\t\t\t\t}\n\t\t\t\t\tfc_cascade_field_funcs['" . $srcELid . '_' . $n . "']();\n\t\t\t\t";
                }
            } else {
                $field->html = JHTML::_('select.options', $options, 'value', 'text', $value, $translate = false);
            }
            $n++;
            if (!$multiple) {
                break;
            }
            // multiple values disabled, break out of the loop, not adding further values even if the exist
        }
        if ($per_val_js) {
            $document->addScriptDeclaration('
				jQuery(document).ready(function(){
					' . $per_val_js . '
				});
			');
        }
        if ($ajax) {
            return;
            // Done
        } else {
            if ($use_ingroup) {
                // do not convert the array to string if field is in a group
            } else {
                if ($multiple) {
                    // handle multiple records
                    $field->html = !count($field->html) ? '' : '<li class="' . $value_classes . '">' . implode('</li><li class="' . $value_classes . '">', $field->html) . '</li>';
                    $field->html = '<ul class="fcfield-sortables" id="sortables_' . $field->id . '">' . $field->html . '</ul>';
                    if (!$add_position) {
                        $field->html .= '<span class="fcfield-addvalue ' . (JComponentHelper::getParams('com_flexicontent')->get('form_font_icons', 1) ? ' fcfont-icon' : '') . '" onclick="addField' . $field->id . '(this);" title="' . JText::_('FLEXI_ADD_TO_BOTTOM') . '">' . JText::_('FLEXI_ADD_VALUE') . '</span>';
                    }
                } else {
                    // handle single values
                    $field->html = '<div class="fcfieldval_container valuebox fcfieldval_container_' . $field->id . '">' . $field->html[0] . '</div>';
                }
            }
        }
    }
    /**
     * Creates the HTML of various form fields used in the item edit form
     *
     * @since 1.0
     */
    function _buildEditLists(&$perms, &$params, &$authorparams)
    {
        $db = JFactory::getDBO();
        $user = JFactory::getUser();
        // get current user
        $item = $this->get('Item');
        // get the item from the model
        $document = JFactory::getDocument();
        $session = JFactory::getSession();
        global $globalcats;
        $categories = $globalcats;
        // get the categories tree
        $types = $this->get('Typeslist');
        $typesselected = $this->get('Typesselected');
        $subscribers = $this->get('SubscribersCount');
        $isnew = !$item->id;
        // *******************************
        // 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) {
                $selectedcats = array($maincat);
                $item->catid = $maincat;
            } else {
                $selectedcats = array();
            }
            if ($params->get('cid_default')) {
                $selectedcats = $params->get('cid_default');
            }
            if ($params->get('catid_default')) {
                $item->catid = $params->get('catid_default');
            }
        } else {
            // NOTE: This will normally return the already set versioned value of categories ($item->categories)
            $selectedcats = $this->get('Catsselected');
        }
        // *********************************************************************************************
        // 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);
        flexicontent_html::loadFramework('select2');
        $prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable');
        $lists = array();
        // build state list
        $non_publishers_stategrp = $perms['isSuperAdmin'] || $item->state == -3 || $item->state == -4;
        $special_privelege_stategrp = $item->state == 2 || $perms['canarchive'] || ($item->state == -2 || $perms['candelete']);
        $state = array();
        // Using <select> groups
        if ($non_publishers_stategrp || $special_privelege_stategrp) {
            $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_PUBLISHERS_WORKFLOW_STATES'));
        }
        $state[] = JHTML::_('select.option', 1, JText::_('FLEXI_PUBLISHED'));
        $state[] = JHTML::_('select.option', 0, JText::_('FLEXI_UNPUBLISHED'));
        $state[] = JHTML::_('select.option', -5, JText::_('FLEXI_IN_PROGRESS'));
        // States reserved for workflow
        if ($non_publishers_stategrp) {
            $state[] = JHTML::_('select.optgroup', '');
            $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_NON_PUBLISHERS_WORKFLOW_STATES'));
        }
        if ($item->state == -3 || $perms['isSuperAdmin']) {
            $state[] = JHTML::_('select.option', -3, JText::_('FLEXI_PENDING'));
        }
        if ($item->state == -4 || $perms['isSuperAdmin']) {
            $state[] = JHTML::_('select.option', -4, JText::_('FLEXI_TO_WRITE'));
        }
        // Special access states
        if ($special_privelege_stategrp) {
            $state[] = JHTML::_('select.optgroup', '');
            $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_SPECIAL_ACTION_STATES'));
        }
        if ($item->state == 2 || $perms['canarchive']) {
            $state[] = JHTML::_('select.option', 2, JText::_('FLEXI_ARCHIVED'));
        }
        if ($item->state == -2 || $perms['candelete']) {
            $state[] = JHTML::_('select.option', -2, JText::_('FLEXI_TRASHED'));
        }
        // Close last <select> group
        if ($non_publishers_stategrp || $special_privelege_stategrp) {
            $state[] = JHTML::_('select.optgroup', '');
        }
        $class = 'use_select2_lib';
        $attribs = 'class="' . $class . '"';
        $lists['state'] = JHTML::_('select.genericlist', $state, 'jform[state]', $attribs, 'value', 'text', $item->state, 'jform_state');
        if (!FLEXI_J16GE) {
            $lists['state'] = str_replace('<optgroup label="">', '</optgroup>', $lists['state']);
        }
        // *** BOF: J2.5 SPECIFIC SELECT LISTS
        if (FLEXI_J16GE) {
        }
        // *** 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 ? JText::_('FLEXI_NO_SUBSCRIBERS_EXIST') : '';
        } else {
            // b. Check if notification emails to subscribers , were already sent during current session
            $subscribers_notified = $session->get('subscribers_notified', array(), 'flexicontent');
            if (!empty($subscribers_notified[$item->id])) {
                $lists['notify'] = JText::_('FLEXI_SUBSCRIBERS_ALREADY_NOTIFIED');
            } else {
                // build favs notify field
                $fieldname = 'jform[notify]';
                $elementid = 'jform_notify';
                /*
                $attribs = FLEXI_J16GE ? ' style ="float:none!important;" '  :  '';   // this is not right for J1.5' style ="float:left!important;" ';
                $lists['notify'] = '<input type="checkbox" name="jform[notify]" id="jform_notify" '.$attribs.' /> '. $lbltxt;
                */
                $classes = !$prettycheckable_added ? '' : ' use_prettycheckable ';
                $attribs = ' class="' . $classes . '" ';
                $lbltxt = $subscribers . ' ' . JText::_($subscribers > 1 ? 'FLEXI_SUBSCRIBERS' : 'FLEXI_SUBSCRIBER');
                if (!$prettycheckable_added) {
                    $lists['notify'] .= '<label class="fccheckradio_lbl" for="' . $elementid . '">';
                }
                $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . $lbltxt . '" data-labelPosition="right" data-customClass="fcradiocheck"';
                $lists['notify'] = ' <input type="checkbox" id="' . $elementid . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="1" ' . $extra_params . ' checked="checked" />';
                if (!$prettycheckable_added) {
                    $lists['notify'] .= '&nbsp;' . $lbltxt . '</label>';
                }
            }
        }
        // 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) . '"];
			max_cat_overlimit_msg_fc = "' . JText::_('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 ($params->get('cid_allowed_parent')) {
                $cid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $params->get('cid_allowed_parent'), $depth_limit = 0);
                $disabled_cats = $params->get('cid_allowed_parent_disable', 1) ? array($params->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) . '"];
				max_cat_overlimit_msg_fc = "' . JText::_('FLEXI_TOO_MANY_ITEM_CATEGORIES', true) . '";
			');
            $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 && !$params->get('catid_default') || !$isnew && empty($item->catid) || $perms['canchange_cat'];
        if ($params->get('catid_allowed_parent')) {
            $catid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $params->get('catid_allowed_parent'), $depth_limit = 0);
            $disabled_cats = $params->get('catid_allowed_parent_disable', 1) ? array($params->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, $empty_errmsg = JText::_('FLEXI_FORM_NO_MAIN_CAT_ALLOWED'));
        } 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 version approval list
        if ($params->get('allowdisablingcomments_fe')) {
            // Set to zero if disabled or to "" (aka use default) for any other value.  THIS WILL FORCE comment field use default Global/Category/Content Type setting or disable it,
            // thus a per item commenting system cannot be selected. This is OK because it makes sense to have a different commenting system per CONTENT TYPE by not per Content Item
            $isdisabled = !$params->get('comments') && strlen($params->get('comments'));
            $fieldvalue = $isdisabled ? 0 : "";
            $fieldname = 'jform[attribs][comments]';
            $elementid = 'jform_attribs_comments';
            /*
            $options = array();
            $options[] = JHTML::_('select.option', "",  JText::_( 'FLEXI_DEFAULT_BEHAVIOR' ) );
            $options[] = JHTML::_('select.option', 0, JText::_( 'FLEXI_DISABLE' ) );
            $attribs = FLEXI_J16GE ? ' style ="float:none!important;" ' : '';
            $lists['disable_comments'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', $fieldvalue, $elementid);
            */
            $classes = !$prettycheckable_added ? '' : ' use_prettycheckable ';
            $attribs = ' class="' . $classes . '" ';
            $i = 1;
            $options = array("" => JText::_('FLEXI_DEFAULT_BEHAVIOR'), 0 => JText::_('FLEXI_DISABLE'));
            $lists['disable_comments'] = '';
            foreach ($options as $option_id => $option_label) {
                $checked = $option_id === $fieldvalue ? ' checked="checked"' : '';
                $elementid_no = $elementid . '_' . $i;
                if (!$prettycheckable_added) {
                    $lists['disable_comments'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">';
                }
                $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"';
                $lists['disable_comments'] .= ' <input type="radio" id="' . $elementid_no . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />';
                if (!$prettycheckable_added) {
                    $lists['disable_comments'] .= '&nbsp;' . JText::_($option_label) . '</label>';
                }
                $i++;
            }
        }
        // find user's allowed languages
        $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;
        }
        // find globaly or per content type disabled languages
        $disable_langs = $params->get('disable_languages_fe', array());
        // Build languages list
        if (FLEXI_J16GE || FLEXI_FISH) {
            $item_lang = $item->language;
            // Model has already set default language according to parameters
            $langdisplay = $params->get('langdisplay_fe', 2);
            $langconf = array();
            $langconf['flags'] = $params->get('langdisplay_flags_fe', 1);
            $langconf['texts'] = $params->get('langdisplay_texts_fe', 1);
            $field_attribs = $langdisplay == 2 ? 'class="use_select2_lib"' : '';
            $lists['languages'] = flexicontent_html::buildlanguageslist('jform[language]', $field_attribs, $item->language, $langdisplay, $allowed_langs, $published_only = 1, $disable_langs, $add_all = true, $langconf);
        }
        return $lists;
    }
Esempio n. 19
0
    function display($tpl = null)
    {
        // Initialise variables
        $app = JFactory::getApplication();
        $option = JRequest::getVar('option');
        $db = JFactory::getDBO();
        $document = JFactory::getDocument();
        $user = JFactory::getUser();
        $use_jquery_sortable = true;
        $type = JRequest::getVar('type', 'items', '', 'word');
        $folder = JRequest::getVar('folder', 'default', '', 'cmd');
        $ismodal = JRequest::getVar('ismodal', 'default', '', 'int');
        FLEXIUtilities::loadTemplateLanguageFile($folder);
        //Get data from the model
        $layout = $this->get('Data');
        $conf = $this->get('LayoutConf');
        $fields = $this->get('Fields');
        $fbypos = $this->get('FieldsByPositions');
        $used = $this->get('UsedFields');
        $contentTypes = $this->get('TypesList');
        //$fieldTypes = $this->get( 'FieldTypesList' );
        $fieldTypes = flexicontent_db::getFieldTypes($_grouped = true, $_usage = false, $_published = false);
        // Field types with content type ASSIGNMENT COUNTING
        // Create CONTENT TYPE SELECTOR
        foreach ($fields as $field) {
            $field->type_ids = !empty($field->reltypes) ? explode(",", $field->reltypes) : array();
        }
        $options = array();
        $options[] = JHTML::_('select.option', '', JText::_('FLEXI_ALL'));
        foreach ($contentTypes as $contentType) {
            $options[] = JHTML::_('select.option', $contentType->id, JText::_($contentType->name));
        }
        $fieldname = $elementid = 'content_type__au__';
        $attribs = ' onchange="filterFieldList(\'%s\', \'%s\', \'%s\');" class="use_select2_lib" ';
        $content_type_select = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', '', $elementid);
        // Create FIELD TYPE SELECTOR
        $ALL = mb_strtoupper(JText::_('FLEXI_ALL'), 'UTF-8') . ' : ';
        $fftypes = array();
        $fftypes[] = array('value' => '', 'text' => JText::_('FLEXI_ALL'));
        //$fftypes[] = array('value'=>'BV', 'text'=>$ALL . JText::_( 'FLEXI_BACKEND_FIELDS' ) );
        //$fftypes[] = array('value'=>'C',  'text'=>$ALL . JText::_( 'FLEXI_CORE_FIELDS' ) );
        //$fftypes[] = array('value'=>'NC', 'text'=>$ALL . JText::_( 'FLEXI_NON_CORE_FIELDS' ));
        foreach ($fieldTypes as $field_group => $ft_types) {
            $fftypes[] = $field_group;
            foreach ($ft_types as $field_type => $ftdata) {
                $fftypes[] = array('value' => $ftdata->field_type, 'text' => $ftdata->friendly);
            }
            $fftypes[] = '';
        }
        $fieldname = $elementid = 'field_type__au__';
        $attribs = ' class="use_select2_lib" onchange="filterFieldList(\'%s\', \'%s\', \'%s\');"';
        $field_type_select = flexicontent_html::buildfieldtypeslist($fftypes, $fieldname, '', $_grouped ? 1 : 0, $attribs, $elementid);
        if (isset($layout->positions)) {
            $sort = array();
            $jssort = array();
            $idsort = array();
            $sort[0] = 'sortablecorefields';
            $sort[1] = 'sortableuserfields';
            $i = 2;
            $count = -1;
            foreach ($layout->positions as $pos) {
                $count++;
                if (isset($layout->attributes[$count]) && isset($layout->attributes[$count]['readonly'])) {
                    continue;
                }
                $sort[$i] = 'sortable-' . $pos;
                $idsort[$i] = $pos;
                $i++;
            }
            foreach ($idsort as $k => $v) {
                if ($k > 1) {
                    $jssort[] = 'storeordering(jQuery("#sortable-' . $v . '"))';
                }
            }
            $positions = implode(',', $idsort);
            $jssort = implode("; ", $jssort);
            $sortable_ids = "#" . implode(",#", $sort);
            $js = "\n\t\t\tjQuery(function() {\n\t\t\t\tmy = jQuery( \"{$sortable_ids}\" ).sortable({\n\t\t\t\t\tconnectWith: \"" . $sortable_ids . "\",\n\t\t\t\t\tupdate: function(event, ui) {\n\t\t\t\t\t\tif(ui.sender) {\n\t\t\t\t\t\t\tstoreordering(jQuery(ui.sender));\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tstoreordering(jQuery(ui.item).parent());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tinitordering();\n\t\t\t});\n\t\t\tfunction storeordering(parent_element) {\n\t\t\t\thidden_id = '#'+jQuery.trim(parent_element.attr('id').replace('sortable-',''));\n\t\t\t\tfields = new Array();\n\t\t\t\ti = 0;\n\t\t\t\tparent_element.children('li').each(function(){\n\t\t\t\t\tfields[i++] = jQuery(this).attr('id').replace('field_', '');\n\t\t\t\t});\n\t\t\t\tjQuery(hidden_id).val(fields.join(','))\n\t\t\t}\n\t\t\t";
            $js .= '
			var fieldListFilters = new Array( "content_type", "field_type" );
			function filterFieldList (containerID, method, group)
			{
				var needed_classes = "";
				for (i=0; i<fieldListFilters.length; i++)
				{
					filter_name = fieldListFilters[i];
					
					var filter_val = jQuery("#" + filter_name + "_" + group).val();
					if (filter_val) {
						needed_classes += "."+filter_name+"_"+filter_val;
					}
				}
				
				if (needed_classes) {
					(method=="hide") ?
						jQuery("#"+containerID).find("li").show().filter(":not("+needed_classes+")").hide() :
						jQuery("#"+containerID).find("li").css({"color":"red"}).filter(":not("+needed_classes+")").css({"color":"black"});
				} else {
					(method=="hide") ?
						jQuery("#"+containerID).find("li").show() :
						jQuery("#"+containerID).find("li").css({"color":"black"});
				}
			}
			
			';
            $document->addScriptDeclaration($js);
        }
        // **************************
        // Add css and js to document
        // **************************
        flexicontent_html::loadFramework('select2');
        JHTML::_('behavior.tooltip');
        JHTML::_('behavior.modal');
        $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css');
        if (FLEXI_J30GE) {
            $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css');
        } else {
            if (FLEXI_J16GE) {
                $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/j25.css');
            }
        }
        // *****************************
        // Get user's global permissions
        // *****************************
        $perms = FlexicontentHelperPerm::getPerm();
        if (!$perms->CanTemplates) {
            $app->redirect('index.php?option=com_flexicontent', JText::_('FLEXI_NO_ACCESS'));
        }
        // ************************
        // Create Submenu & Toolbar
        // ************************
        // Create Submenu (and also check access to current view)
        FLEXISubmenu('CanTemplates');
        //create the toolbar
        $bar = JToolBar::getInstance('toolbar');
        JToolBarHelper::title(JText::_('FLEXI_EDIT_TEMPLATE'), 'templates');
        if (!$ismodal) {
            JToolBarHelper::apply('templates.apply');
            JToolBarHelper::save('templates.save');
            JToolBarHelper::cancel('templates.cancel');
        } else {
            JToolBarHelper::apply('templates.apply_modal');
            echo $bar->render();
        }
        // **********************************************************************************
        // Get Templates and apply Template Parameters values into the form fields structures
        // **********************************************************************************
        if (FLEXI_J16GE) {
            $jform = new JForm('com_flexicontent.template.category', array('control' => 'jform', 'load_data' => true));
            $jform->load($layout->params);
            $layout->params = $jform;
            // ... values applied at the template form file
        } else {
            $layout->params->loadINI($row->params);
        }
        //print_r($layout);
        //assign data to template
        //print_r($conf);
        $this->assignRef('conf', $conf);
        $this->assignRef('layout', $layout);
        $this->assignRef('fields', $fields);
        $this->assignRef('user', $user);
        $this->assignRef('type', $type);
        $this->assignRef('folder', $folder);
        $this->assignRef('jssort', $jssort);
        $this->assignRef('positions', $positions);
        $this->assignRef('used', $used);
        $this->assignRef('fbypos', $fbypos);
        $this->assignRef('use_jquery_sortable', $use_jquery_sortable);
        $this->assignRef('content_type_select', $content_type_select);
        $this->assignRef('field_type_select', $field_type_select);
        parent::display($tpl);
    }
Esempio n. 20
0
    function display($tpl = null)
    {
        // ***********
        // Batch tasks
        // ***********
        $app = JFactory::getApplication();
        $jinput = $app->input;
        $layout = $jinput->get('layout', '', 'cmd');
        if ($layout == 'indexer') {
            $this->indexer($tpl);
            return;
        }
        // ********************
        // Initialise variables
        // ********************
        $option = $jinput->get('option', '', 'cmd');
        $view = $jinput->get('view', '', 'cmd');
        $cparams = JComponentHelper::getParams('com_flexicontent');
        $user = JFactory::getUser();
        $db = JFactory::getDBO();
        $document = JFactory::getDocument();
        // Get model
        $model = $this->getModel();
        $print_logging_info = $cparams->get('print_logging_info');
        if ($print_logging_info) {
            global $fc_run_times;
        }
        // ***********
        // Get filters
        // ***********
        $count_filters = 0;
        // Get filter vars
        $filter_order = $model->getState('filter_order');
        $filter_order_Dir = $model->getState('filter_order_Dir');
        $filter_indextype = $model->getState('filter_indextype');
        $isADV = $filter_indextype == 'advanced';
        $filter_fieldtype = $model->getState('filter_fieldtype');
        $filter_itemtype = $model->getState('filter_itemtype');
        $filter_itemstate = $model->getState('filter_itemstate');
        if ($filter_fieldtype) {
            $count_filters++;
        }
        if ($filter_itemtype) {
            $count_filters++;
        }
        if ($filter_itemstate) {
            $count_filters++;
        }
        $search = $model->getState('search');
        $search = $db->escape(trim(JString::strtolower($search)));
        $search_itemtitle = $model->getState('search_itemtitle');
        $search_itemid = $model->getState('search_itemid');
        $search_itemid = !empty($search_itemid) ? (int) $search_itemid : '';
        if ($search_itemtitle) {
            $count_filters++;
        }
        if ($search_itemid) {
            $count_filters++;
        }
        $filter_indextype = $model->getState('filter_indextype');
        $f_active['filter_fieldtype'] = (bool) $filter_fieldtype;
        $f_active['filter_itemtype'] = (bool) $filter_itemtype;
        $f_active['filter_itemstate'] = (bool) $filter_itemstate;
        $f_active['search'] = strlen($search);
        $f_active['search_itemtitle'] = strlen($search_itemtitle);
        $f_active['search_itemid'] = (bool) $search_itemid;
        // **************************
        // Add css and js to document
        // **************************
        flexicontent_html::loadFramework('select2');
        JHTML::_('behavior.tooltip');
        $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css');
        if (FLEXI_J30GE) {
            $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css');
        } else {
            if (FLEXI_J16GE) {
                $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/j25.css');
            }
        }
        // *****************************
        // Get user's global permissions
        // *****************************
        $perms = FlexicontentHelperPerm::getPerm();
        // ************************
        // Create Submenu & Toolbar
        // ************************
        // Create Submenu (and also check access to current view)
        FLEXISubmenu('CanIndex');
        // Create document/toolbar titles
        $doc_title = JText::_('FLEXI_SEARCH_INDEX');
        $site_title = $document->getTitle();
        JToolBarHelper::title($doc_title, FLEXI_J16GE ? 'searchtext.png' : 'searchindex');
        $document->setTitle($doc_title . ' - ' . $site_title);
        // Create the toolbar
        $this->setToolbar();
        $types = $this->get('Typeslist');
        $fieldtypes = flexicontent_db::getFieldTypes($_grouped = false, $_usage = true, $_published = false);
        // Build select lists
        $lists = array();
        //build backend visible filter
        if ($isADV) {
            $fftypes = array();
            $fftypes[] = JHTML::_('select.option', '', '-');
            $fftypes[] = JHTML::_('select.option', 'C', JText::_('FLEXI_CORE_FIELDS'));
            $fftypes[] = JHTML::_('select.option', 'NC', JText::_('FLEXI_NON_CORE_FIELDS'));
            foreach ($fieldtypes as $field_type => $ftdata) {
                $fftypes[] = JHTML::_('select.option', $field_type, '-' . $ftdata->assigned . '- ' . $field_type);
            }
            $lists['filter_fieldtype'] = ($filter_fieldtype || 1 ? '<label class="label">' . JText::_('FLEXI_FIELD_TYPE') . '</label>' : '') . JHTML::_('select.genericlist', $fftypes, 'filter_fieldtype', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_fieldtype);
        }
        //build type select list
        $lists['filter_itemtype'] = ($filter_itemtype || 1 ? '<label class="label">' . JText::_('FLEXI_TYPE') . '</label>' : '') . flexicontent_html::buildtypesselect($types, 'filter_itemtype', $filter_itemtype, '-', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'filter_itemtype');
        //publish unpublished filter
        $ffstates = array();
        $ffstates[] = JHTML::_('select.option', '', '-');
        $ffstates[] = JHTML::_('select.option', 'P', JText::_('FLEXI_PUBLISHED'));
        $ffstates[] = JHTML::_('select.option', 'U', JText::_('FLEXI_UNPUBLISHED'));
        $lists['filter_itemstate'] = ($filter_itemstate || 1 ? '<label class="label">' . JText::_('FLEXI_STATE') . '</label>' : '') . JHTML::_('select.genericlist', $ffstates, 'filter_itemstate', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_itemstate);
        // build filter index type record listing
        $itn['basic'] = JText::_('FLEXI_INDEX_BASIC');
        $itn['advanced'] = JText::_('FLEXI_INDEX_ADVANCED');
        $indextypes = array();
        //foreach ($itn as $i => $v) $indextypes[] = JHTML::_('select.option', $i, $v);
        //$lists['filter_indextype'] = JHTML::_('select.radiolist', $indextypes, 'filter_indextype', 'size="1" class="inputbox" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_indextype );
        $lists['filter_indextype'] = '';
        foreach ($itn as $i => $v) {
            $checked = $filter_indextype == $i ? ' checked="checked" ' : '';
            $lists['filter_indextype'] .= '<input type="radio" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" class="inputbox" size="1" ' . $checked . ' value="' . $i . '" id="filter_indextype' . $i . '" name="filter_indextype" />';
            $lists['filter_indextype'] .= '<label class="" id="filter_indextype' . $i . '-lbl" for="filter_indextype' . $i . '">' . $v . '</label>';
        }
        // table ordering
        $lists['order_Dir'] = $filter_order_Dir;
        $lists['order'] = $filter_order;
        // search index & item title  filter
        $lists['search'] = $search;
        $lists['search_itemtitle'] = $search_itemtitle;
        $lists['search_itemid'] = $search_itemid;
        $rows = $this->get('Data');
        // MUST BE BEFORE getCount and getPagination because it also calculates total rows
        $total = $this->get('Count');
        $pagination = $this->get('Pagination');
        $limitstart = $this->get('LimitStart');
        $js = "jQuery(document).ready(function(){";
        if ($filter_fieldtype) {
            $js .= "jQuery('.col_fieldtype').each(function(){ jQuery(this).addClass('yellow'); });";
        }
        if ($search) {
            $js .= "jQuery('.col_search').each(function(){ jQuery(this).addClass('yellow'); });";
        }
        $js .= "});";
        $document->addScriptDeclaration($js);
        $query = "SHOW VARIABLES LIKE '%ft_min_word_len%'";
        $db->setQuery($query);
        $_dbvariable = $db->loadObject();
        $ft_min_word_len = (int) @$_dbvariable->Value;
        $notice_ft_min_word_len = $app->getUserStateFromRequest($option . '.fields.notice_ft_min_word_len', 'notice_ft_min_word_len', 0, 'int');
        //if ( $cparams->get('show_usability_messages', 1) )     // Important usability messages
        //{
        $old_add_search_prefix = $app->getUserState('add_search_prefix', null);
        $add_search_prefix = $cparams->get('add_search_prefix', 0);
        $app->setUserState('add_search_prefix', $add_search_prefix);
        if ($old_add_search_prefix !== null && $old_add_search_prefix != $add_search_prefix) {
            $app->enqueueMessage('Parameter: "Searching small/common words" has changed, please recreate (just once) the search indexes, otherwise text search will not work', 'warning');
        }
        if (!$cparams->get('add_search_prefix', 0)) {
            if ($ft_min_word_len > 1 && $notice_ft_min_word_len < 10) {
                $app->setUserState($option . '.fields.notice_ft_min_word_len', $notice_ft_min_word_len + 1);
                $app->enqueueMessage("NOTE : Database limits minimum search word length (ft_min_word_len) to " . $ft_min_word_len, 'message');
                $app->enqueueMessage('Please enable: "Searching small/common words":
					<a class="btn" href="index.php?option=com_config&view=component&component=com_flexicontent&path=&"><span class="icon-options"></span>Configuration</a>
					and then click to re-INDEX both search indexes', 'notice');
                //$app->enqueueMessage(JText::_('FLEXI_USABILITY_MESSAGES_TURN_OFF'), 'message');
            }
        }
        //}
        $this->assignRef('count_filters', $count_filters);
        $this->assignRef('lists', $lists);
        $this->assignRef('pagination', $pagination);
        $this->assignRef('rows', $rows);
        $this->assignRef('total', $total);
        $this->assignRef('limitstart', $limitstart);
        $this->assignRef('f_active', $f_active);
        $this->assignRef('option', $option);
        $this->assignRef('view', $view);
        $this->assignRef('isADV', $isADV);
        $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null;
        parent::display($tpl);
    }
Esempio n. 21
0
 function display($tpl = null)
 {
     //initialise variables
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $cparams = JComponentHelper::getParams('com_flexicontent');
     $user = JFactory::getUser();
     //add css to document
     $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css');
     if (FLEXI_J30GE) {
         $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css');
     } else {
         if (FLEXI_J16GE) {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css');
         } else {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css');
         }
     }
     //add js function to overload the joomla submitform
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     JHTML::_('behavior.tooltip');
     flexicontent_html::loadFramework('jQuery');
     flexicontent_html::loadFramework('select2');
     $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/admin.js');
     $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/validate.js');
     //Load pane behavior
     jimport('joomla.html.pane');
     //Import File system
     jimport('joomla.filesystem.file');
     //Get data from the model
     $model = $this->getModel();
     $row = $this->get('Field');
     if (FLEXI_J16GE) {
         $form = $this->get('Form');
     }
     $types = $this->get('Typeslist');
     $typesselected = $this->get('Typesselected');
     //create the toolbar
     if ($row->id) {
         JToolBarHelper::title(JText::_('FLEXI_EDIT_FIELD'), 'fieldedit');
     } else {
         JToolBarHelper::title(JText::_('FLEXI_ADD_FIELD'), 'fieldadd');
     }
     $ctrl = FLEXI_J16GE ? 'fields.' : '';
     JToolBarHelper::apply($ctrl . 'apply');
     JToolBarHelper::save($ctrl . 'save');
     JToolBarHelper::custom($ctrl . 'saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false);
     JToolBarHelper::cancel($ctrl . 'cancel');
     // Import Joomla plugin that implements the type of current flexi field
     JPluginHelper::importPlugin('flexicontent_fields', $row->iscore ? 'core' : $row->field_type);
     // load plugin's english language file then override with current language file
     $extension_name = 'plg_flexicontent_fields_' . ($row->iscore ? 'core' : $row->field_type);
     JFactory::getLanguage()->load($extension_name, JPATH_ADMINISTRATOR, 'en-GB', true);
     JFactory::getLanguage()->load($extension_name, JPATH_ADMINISTRATOR, null, true);
     //check which properties are supported by current field
     $ft_support = FlexicontentFields::getPropertySupport($row->field_type, $row->iscore);
     $supportsearch = $ft_support->supportsearch;
     $supportadvsearch = $ft_support->supportadvsearch;
     $supportfilter = $ft_support->supportfilter;
     $supportadvfilter = $ft_support->supportadvfilter;
     $supportuntranslatable = $ft_support->supportuntranslatable;
     $supportvalueseditable = $ft_support->supportvalueseditable;
     $supportformhidden = $ft_support->supportformhidden;
     $supportedithelp = $ft_support->supportedithelp;
     //build selectlists, (for J1.6+ most of these are defined via XML file and custom form field classes)
     $lists = array();
     //build field_type list
     if (!$row->field_type) {
         $row->field_type = 'text';
     }
     if ($row->iscore == 1) {
         $class = 'disabled="disabled"';
     } else {
         $class = '';
         $_field_id = '#' . (FLEXI_J16GE ? 'jform_' : '') . 'field_type';
         $_row_id = FLEXI_J16GE ? $form->getValue("id") : $row->id;
         $_ctrl_task = FLEXI_J16GE ? 'task=fields.getfieldspecificproperties' : 'controller=fields&task=getfieldspecificproperties';
         $document->addScriptDeclaration("\n\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\tjQuery('" . $_field_id . "').on('change', function() {\n\t\t\t\t\t\tjQuery('#fieldspecificproperties').html('<p class=\"centerimg\"><img src=\"components/com_flexicontent/assets/images/ajax-loader.gif\" align=\"center\"></p>');\n\t\t\t\t\t\tjQuery.ajax({\n\t\t\t\t\t\t\ttype: \"GET\",\n\t\t\t\t\t\t\turl: 'index.php?option=com_flexicontent&" . $_ctrl_task . "&cid=" . $_row_id . "&field_type='+this.value+'&format=raw',\n\t\t\t\t\t\t\tsuccess: function(str) {\n\t\t\t\t\t\t\t\tjQuery('#fieldspecificproperties').html(str);\n\t\t\t\t\t\t\t\tvar JTooltips = new Tips(jQuery('#fieldspecificproperties .hasTip'), { maxTitleChars: 50, fixed: false});\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tjQuery('#field_typename').html(jQuery('" . $_field_id . "').val());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t");
     }
     //build field select list
     $lists['field_type'] = flexicontent_html::buildfieldtypeslist('field_type', $class, $row->field_type, $group = true);
     //build type select list
     $attribs = 'class="use_select2_lib" multiple="multiple" size="6"';
     $attribs .= $row->iscore ? ' disabled="disabled"' : '';
     $types_fieldname = FLEXI_J16GE ? 'jform[tid][]' : 'tid[]';
     $lists['tid'] = flexicontent_html::buildtypesselect($types, $types_fieldname, $typesselected, false, $attribs);
     // **************************************************************************
     // Create fields for J1.5 (J2.5+ uses JForm XML file for most of form fields)
     // **************************************************************************
     if (!FLEXI_J16GE) {
         //build formhidden selector
         $formhidden[] = JHTML::_('select.option', 0, JText::_('FLEXI_NO'));
         $formhidden[] = JHTML::_('select.option', 1, JText::_('FLEXI_FRONTEND'));
         $formhidden[] = JHTML::_('select.option', 2, JText::_('FLEXI_BACKEND'));
         $formhidden[] = JHTML::_('select.option', 3, JText::_('FLEXI_BOTH'));
         $formhidden_fieldname = FLEXI_J16GE ? 'jform[formhidden]' : 'formhidden';
         $lists['formhidden'] = JHTML::_('select.radiolist', $formhidden, $formhidden_fieldname, '', 'value', 'text', $row->formhidden);
         if (FLEXI_ACCESS) {
             $valueseditable[] = JHTML::_('select.option', 0, JText::_('FLEXI_ANY_EDITOR'));
             $valueseditable[] = JHTML::_('select.option', 1, JText::_('FLEXI_USE_ACL_PERMISSION'));
             $valueseditable_fieldname = FLEXI_J16GE ? 'jform[valueseditable]' : 'valueseditable';
             $lists['valueseditable'] = JHTML::_('select.radiolist', $valueseditable, $valueseditable_fieldname, '', 'value', 'text', $row->valueseditable);
         }
         $edithelp[] = JHTML::_('select.option', 0, JText::_('FLEXI_EDIT_HELP_NONE'));
         $edithelp[] = JHTML::_('select.option', 1, JText::_('FLEXI_EDIT_HELP_LABEL_TOOLTIP'));
         $edithelp[] = JHTML::_('select.option', 2, JText::_('FLEXI_EDIT_HELP_LABEL_TOOLTIP_WICON'));
         $edithelp[] = JHTML::_('select.option', 3, JText::_('FLEXI_EDIT_HELP_INLINE'));
         $edithelp_fieldname = FLEXI_J16GE ? 'jform[edithelp]' : 'edithelp';
         $lists['edithelp'] = JHTML::_('select.radiolist', $edithelp, $edithelp_fieldname, '', 'value', 'text', $row->edithelp);
         // build the html select list for ordering
         $query = 'SELECT ordering AS value, label AS text' . ' FROM #__flexicontent_fields' . ' WHERE published >= 0' . ' ORDER BY ordering';
         $row->ordering = @$row->ordering;
         $lists['ordering'] = $row->id ? JHTML::_('list.specificordering', $row, $row->id, $query) : JHTML::_('list.specificordering', $row, '', $query);
         //build access level list
         if (FLEXI_ACCESS) {
             $lang = JFactory::getLanguage();
             $lang->_strings['FLEXIACCESS_PADD'] = 'Edit-Value';
             $lists['access'] = FAccess::TabGmaccess($row, 'field', 1, 1, 0, 1, 0, 1, 0, 1, 1);
         } else {
             $lists['access'] = JHTML::_('list.accesslevel', $row);
         }
     }
     if (!FLEXI_J16GE) {
         // Create the parameter 's form object parsing the file XML
         $pluginpath = JPATH_PLUGINS . DS . 'flexicontent_fields' . DS . $row->field_type . '.xml';
         if (JFile::exists($pluginpath)) {
             $form = new JParameter('', $pluginpath);
         } else {
             $form = new JParameter('', JPATH_PLUGINS . DS . 'flexicontent_fields' . DS . 'core.xml');
         }
         // Special and Core Groups
         $form->loadINI($row->attribs);
     }
     // fail if checked out not by 'me'
     if ($row->id) {
         if ($model->isCheckedOut($user->get('id'))) {
             JError::raiseWarning('SOME_ERROR_CODE', $row->name . ' ' . JText::_('FLEXI_EDITED_BY_ANOTHER_ADMIN'));
             $app->redirect('index.php?option=com_flexicontent&view=fields');
         }
     }
     //clean data
     JFilterOutput::objectHTMLSafe($row, ENT_QUOTES);
     // assign permissions for J2.5
     if (FLEXI_J16GE) {
         $permission = FlexicontentHelperPerm::getPerm();
         $this->assignRef('permission', $permission);
     }
     //assign data to template
     $this->assignRef('document', $document);
     $this->assignRef('row', $row);
     $this->assignRef('lists', $lists);
     $this->assignRef('form', $form);
     $this->assignRef('typesselected', $typesselected);
     $this->assignRef('supportsearch', $supportsearch);
     $this->assignRef('supportadvsearch', $supportadvsearch);
     $this->assignRef('supportfilter', $supportfilter);
     $this->assignRef('supportadvfilter', $supportadvfilter);
     $this->assignRef('supportuntranslatable', $supportuntranslatable);
     $this->assignRef('supportvalueseditable', $supportvalueseditable);
     $this->assignRef('supportformhidden', $supportformhidden);
     $this->assignRef('supportedithelp', $supportedithelp);
     parent::display($tpl);
 }
Esempio n. 22
0
 function onDisplayFilter(&$filter, $value = '', $formName = 'adminForm', $isSearchView = 0)
 {
     if ($filter->iscore != 1) {
         return;
     }
     // performance check
     $db = JFactory::getDBO();
     $formfieldname = 'filter_' . $filter->id;
     $_s = $isSearchView ? '_s' : '';
     $display_filter_as = $filter->parameters->get('display_filter_as' . $_s, 0);
     // Filter Type of Display
     $faceted_filter = $filter->parameters->get('faceted_filter' . $_s, 0);
     // Filter Type of Display
     $disable_keyboardinput = $filter->parameters->get('disable_keyboardinput', 0);
     $filter_as_range = in_array($display_filter_as, array(2, 3, 8));
     // Create first prompt option of drop-down select
     $label_filter = $filter->parameters->get('display_label_filter' . $_s, 2);
     $first_option_txt = $label_filter == 2 ? $filter->label : JText::_('FLEXI_ALL');
     // Prepend Field's Label to filter HTML
     //$filter->html = $label_filter==1 ? $filter->label.': ' : '';
     $filter->html = '';
     switch ($filter->field_type) {
         case 'title':
             $_inner_lb = $label_filter == 2 ? $filter->label : JText::_('FLEXI_TYPE_TO_LIST');
             $_inner_lb = flexicontent_html::escapeJsText($_inner_lb, 's');
             $attribs_str = ' class="fc_field_filter fc_label_internal" data-fc_label_text="' . $_inner_lb . '"';
             $filter_ffname = 'filter_' . $filter->id;
             $filter_ffid = $formName . '_' . $filter->id . '_val';
             $filter->html .= '<input id="' . $filter_ffid . '" name="' . $filter_ffname . '" ' . $attribs_str . ' type="text" size="20" value="' . $value . '" />';
             break;
         case 'createdby':
             // Authors
             // WARNING: we can not use column alias in from, join, where, group by, can use in having (some DB e.g. mysql) and in order-by
             // partial SQL clauses
             $filter->filter_valuesselect = ' i.created_by AS value, CASE WHEN usr.name IS NULL THEN CONCAT(\'' . JText::_('FLEXI_NOT_ASSIGNED') . ' ID:\', i.created_by) ELSE usr.name END AS text';
             $filter->filter_valuesjoin = ' JOIN #__users AS usr ON usr.id = i.created_by';
             $filter->filter_valueswhere = ' AND i.created_by <> 0';
             // full SQL clauses
             $filter->filter_groupby = ' GROUP BY i.created_by ';
             $filter->filter_having = null;
             // this indicates to use default, space is use empty
             $filter->filter_orderby = ' ORDER by text';
             // default will order by value and not by label
             FlexicontentFields::createFilter($filter, $value, $formName);
             break;
         case 'modifiedby':
             // Modifiers
             // WARNING: we can not use column alias in from, join, where, group by, can use in having (some DB e.g. mysql) and in order-by
             // partial SQL clauses
             $filter->filter_valuesselect = ' i.modified_by AS value, CASE WHEN usr.name IS NULL THEN CONCAT(\'' . JText::_('FLEXI_NOT_ASSIGNED') . ' ID:\', i.modified_by) ELSE usr.name END AS text';
             $filter->filter_valuesjoin = ' JOIN #__users AS usr ON usr.id = i.modified_by';
             $filter->filter_valueswhere = ' AND i.modified_by <> 0';
             // full SQL clauses
             $filter->filter_groupby = ' GROUP BY i.modified_by ';
             $filter->filter_having = null;
             // this indicates to use default, space is use empty
             $filter->filter_orderby = ' ORDER by text';
             // default will order by value and not by label
             FlexicontentFields::createFilter($filter, $value, $formName);
             break;
         case 'type':
             // Document Type
             // WARNING: we can not use column alias in from, join, where, group by, can use in having (some DB e.g. mysql) and in order-by
             // partial SQL clauses
             $filter->filter_valuesselect = ' ict.id AS value, ict.name AS text';
             $filter->filter_valuesjoin = '' . ' JOIN #__flexicontent_items_ext AS iext ON iext.item_id = i.id' . ' JOIN #__flexicontent_types AS ict ON iext.type_id = ict.id';
             $filter->filter_valueswhere = ' ';
             // ... a space, (indicates not needed and prevents using default)
             // full SQL clauses
             $filter->filter_groupby = ' GROUP BY ict.id';
             $filter->filter_having = null;
             // this indicates to use default, space is use empty
             $filter->filter_orderby = ' ORDER by text';
             // default will order by value and not by label
             FlexicontentFields::createFilter($filter, $value, $formName);
             break;
         case 'state':
             $options = array();
             $options[] = JHTML::_('select.option', '', '- ' . $first_option_txt . ' -');
             $options[] = JHTML::_('select.option', 'P', JText::_('FLEXI_PUBLISHED'));
             $options[] = JHTML::_('select.option', 'U', JText::_('FLEXI_UNPUBLISHED'));
             $options[] = JHTML::_('select.option', 'PE', JText::_('FLEXI_PENDING'));
             $options[] = JHTML::_('select.option', 'OQ', JText::_('FLEXI_TO_WRITE'));
             $options[] = JHTML::_('select.option', 'IP', JText::_('FLEXI_IN_PROGRESS'));
             $options[] = JHTML::_('select.option', 'A', JText::_('FLEXI_ARCHIVED'));
             //$options[] = JHTML::_('select.option',  'T', JText::_( 'FLEXI_TRASHED' ) );
             break;
         case 'categories':
             // Initialize options
             $options = array();
             // MULTI-select does not has an internal label a drop-down list option
             if ($display_filter_as != 6) {
                 $first_option_txt = $label_filter == 2 ? $filter->label : JText::_('FLEXI_ANY');
                 $options[] = JHTML::_('select.option', '', '- ' . $first_option_txt . ' -');
             }
             // Get categories
             global $globalcats;
             $rootcatid = $filter->parameters->get('rootcatid', '');
             $option = JRequest::getVar('option', '');
             $view = JRequest::getVar('view', '');
             $cid = JFactory::getApplication()->isSite() ? JRequest::getInt('cid', '') : 0;
             $cids = JRequest::getVar('cids', array(), $hash = 'default', 'array');
             JArrayHelper::toInteger($cids, array());
             $cats = array();
             if ($option == 'com_flexicontent' && $view == 'category' && count($cids)) {
                 // Current view is category view limit to descendants
             } else {
                 if ($option == 'com_flexicontent' && $view == 'category' && $cid) {
                     // Current view is category view limit to descendants
                     $cids = array($cid);
                     //$options[] = JHTML::_('select.option', $globalcats[$cid]->id, $globalcats[$cid]->treename);
                     //$cats = $globalcats[$cid]->childrenarray;
                 } else {
                     if ($rootcatid) {
                         // If configured ... limit to subcategory tree of a specified category
                         $cids = array($rootcatid);
                         //$options[] = JHTML::_('select.option', $globalcats[$rootcatid]->id, $globalcats[$rootcatid]->treename);
                         //$cats = $globalcats[$rootcatid]->childrenarray;
                     }
                 }
             }
             if (count($cids)) {
                 foreach ($cids as $_cid) {
                     if (!isset($globalcats[$_cid])) {
                         continue;
                     }
                     if (count($cids) > 1) {
                         $cat_obj = new stdClass();
                         $cat_obj->id = $globalcats[$_cid]->id;
                         $cat_obj->treename = $globalcats[$_cid]->title;
                         // $globalcats[$_cid]->treename;
                         $cat_obj->totalitems = $globalcats[$_cid]->totalitems;
                         $cats[] = $cat_obj;
                     }
                     if (empty($globalcats[$_cid]->childrenarray)) {
                         continue;
                     }
                     foreach ($globalcats[$_cid]->childrenarray as $child) {
                         $_child = clone $child;
                         $_child->treename = '&nbsp; ' . str_replace('<sup>|_</sup>&nbsp;', '', str_replace('&nbsp;.&nbsp;', '', $_child->treename));
                         $cats[] = $_child;
                     }
                 }
             } else {
                 $cats = $globalcats;
                 // All categories by default
             }
             if (!empty($cats)) {
                 foreach ($cats as $k => $list) {
                     $options[] = JHTML::_('select.option', $list->id, $list->treename . ($faceted_filter ? '&nbsp; (<' . $list->totalitems . ')' : ''));
                 }
             }
             $extra_classes = ' select2_list_selected';
             break;
         case 'tags':
             // WARNING: we can not use column alias in from, join, where, group by, can use in having (some DB e.g. mysql) and in order-by
             // partial SQL clauses
             $filter->filter_valuesselect = ' tags.id AS value, tags.name AS text';
             if (!$faceted_filter) {
                 $filter->filter_valuesfrom = ' FROM #__flexicontent_tags AS tags ';
             } else {
                 $filter->filter_valuesjoin = ' JOIN #__flexicontent_tags_item_relations AS tagsrel ON tagsrel.itemid = i.id ' . ' JOIN #__flexicontent_tags AS tags ON tags.id =  tagsrel.tid ';
             }
             $filter->filter_valueswhere = ' ';
             // ... a space, (indicates not needed and prevents using default)
             // full SQL clauses
             $filter->filter_groupby = ' GROUP BY tags.id ';
             $filter->filter_having = null;
             // this indicates to use default, space is use empty
             $filter->filter_orderby = ' ORDER by text';
             // default will order by value and not by label
             FlexicontentFields::createFilter($filter, $value, $formName);
             break;
         case 'created':
             // creation dates
         // creation dates
         case 'modified':
             // modification dates
             $date_filter_group = $filter->parameters->get('date_filter_group', 'month');
             if ($date_filter_group == 'year') {
                 $date_valformat = '%Y';
             } else {
                 if ($date_filter_group == 'month') {
                     $date_valformat = '%Y-%m';
                 } else {
                     $date_valformat = '%Y-%m-%d';
                 }
             }
             // Display date 'label' can be different than the (aggregated) date value
             $date_filter_label_format = $filter->parameters->get('date_filter_label_format', '');
             $date_txtformat = $date_filter_label_format ? $date_filter_label_format : $date_valformat;
             // If empty then same as value
             if ($disable_keyboardinput) {
                 $filter_ffid = $formName . '_' . $filter->id . '_val';
                 $document = JFactory::getDocument();
                 switch ($display_filter_as) {
                     case 1:
                         $document->addScriptDeclaration("\n\t\t\t\t\t\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\t\t\t\t\t\tjQuery('#" . $filter_ffid . "').on('keydown keypress keyup', false);\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t");
                         break;
                     case 3:
                         $document->addScriptDeclaration("\n\t\t\t\t\t\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\t\t\t\t\t\tjQuery('#" . $filter_ffid . "1').on('keydown keypress keyup', false);\n\t\t\t\t\t\t\t\t\t\t\tjQuery('#" . $filter_ffid . "2').on('keydown keypress keyup', false);\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t");
                         break;
                 }
             }
             $filter_as_range = in_array($display_filter_as, array(2, 3, 8));
             // We don't want null date if using a range
             $nullDate_quoted = $db->Quote($db->getNullDate());
             $valuecol = sprintf(' CASE WHEN i.%s=' . $nullDate_quoted . ' THEN ' . $nullDate_quoted . ' ELSE DATE_FORMAT(i.%s, "%s") END ', $filter->field_type, $filter->field_type, $date_valformat);
             $textcol = sprintf(' CASE WHEN i.%s=' . $nullDate_quoted . ' THEN "' . JText::_('FLEXI_NEVER') . '" ELSE DATE_FORMAT(i.%s, "%s") END ', $filter->field_type, $filter->field_type, $date_txtformat);
             // WARNING: we can not use column alias in from, join, where, group by, can use in having (some DB e.g. mysql) and in order-by
             // partial SQL clauses
             $filter->filter_valuesselect = ' ' . $valuecol . ' AS value, ' . $textcol . ' AS text';
             $filter->filter_valuesjoin = ' ';
             // ... a space, (indicates not needed and prevents using default)
             $filter->filter_valueswhere = $filter_as_range ? ' AND i.' . $filter->field_type . '<>' . $nullDate_quoted : ' ';
             // ... a space, (indicates not needed and prevents using default)
             // full SQL clauses
             $filter->filter_groupby = ' GROUP BY ' . $valuecol;
             $filter->filter_having = null;
             // this indicates to use default, space is use empty
             $filter->filter_orderby = ' ORDER BY ' . $valuecol;
             FlexicontentFields::createFilter($filter, $value, $formName);
             break;
         default:
             $filter->html .= 'Field type: ' . $filter->field_type . ' can not be used as search filter';
             break;
     }
     // a. If field filter has defined a custom SQL query to create filter (drop-down select) options, execute it and then create the options
     if (!empty($query)) {
         $db->setQuery($query);
         $lists = $db->loadObjectList();
         $options = array();
         $options[] = JHTML::_('select.option', '', '- ' . $first_option_txt . ' -');
         foreach ($lists as $list) {
             $options[] = JHTML::_('select.option', $list->value, $list->text . ($count_column ? ' (' . $list->found . ')' : ''));
         }
     }
     // b. If field filter has defined drop-down select options the create the drop-down select form field
     if (!empty($options)) {
         // Make use of select2 lib
         flexicontent_html::loadFramework('select2');
         $classes = " use_select2_lib" . @$extra_classes;
         $extra_param = '';
         // MULTI-select: special label and prompts
         if ($display_filter_as == 6) {
             $classes .= ' fc_label_internal fc_prompt_internal';
             // Add field's LABEL internally or click to select PROMPT (via js)
             $_inner_lb = $label_filter == 2 ? $filter->label : JText::_('FLEXI_CLICK_TO_LIST');
             // Add type to filter PROMPT (via js)
             $extra_param = ' data-fc_label_text="' . flexicontent_html::escapeJsText($_inner_lb, 's') . '"';
             $extra_param .= ' data-fc_prompt_text="' . flexicontent_html::escapeJsText(JText::_('FLEXI_TYPE_TO_FILTER'), 's') . '"';
         }
         // Create HTML tag attributes
         $attribs_str = ' class="fc_field_filter' . $classes . '" ' . $extra_param;
         $attribs_str .= $display_filter_as == 6 ? ' multiple="multiple" size="20" ' : '';
         //$attribs_str .= ($display_filter_as==0 || $display_filter_as==6) ? ' onchange="document.getElementById(\''.$formName.'\').submit();"' : '';
         // Filter name and id
         $filter_ffname = 'filter_' . $filter->id;
         $filter_ffid = $formName . '_' . $filter->id . '_val';
         // Create filter
         $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname . '[]', $attribs_str, 'value', 'text', $value, $filter_ffid);
     }
     // Special CASE 'categories' filter, replace some tags in filter HTML ...
     if ($filter->field_type == 'categories') {
         $filter->html = str_replace('&lt;sup&gt;|_&lt;/sup&gt;', '\'-', $filter->html);
     }
 }
Esempio n. 23
0
 function display($tpl = null)
 {
     global $globalcats;
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $document = JFactory::getDocument();
     if (FLEXI_J16GE) {
         JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR, 'en-GB', true);
         JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR, null, true);
     }
     // ***********************************************************
     // Get category data, and check if item is already checked out
     // ***********************************************************
     // Get data from the model
     $model = $this->getModel();
     if (FLEXI_J16GE) {
         $row = $this->get('Item');
         $form = $this->get('Form');
     } else {
         $row = $this->get('Category');
     }
     $catparams = FLEXI_J16GE ? new JRegistry($row->params) : new JParameter($row->params);
     $cid = $row->id;
     $isnew = !$cid;
     // Check category is checked out by different editor / administrator
     if (!$isnew && $model->isCheckedOut($user->get('id'))) {
         JError::raiseWarning('SOME_ERROR_CODE', $row->title . ' ' . JText::_('FLEXI_EDITED_BY_ANOTHER_ADMIN'));
         $app->redirect('index.php?option=com_flexicontent&view=categories');
     }
     // ***************************************************************************
     // Currently access checking for category add/edit form , it is done here, for
     // most other views we force going though the controller and checking it there
     // ***************************************************************************
     // *********************************************************************************************
     // Global Permssions checking (needed because this view can be called without a controller task)
     // *********************************************************************************************
     // Get global permissions
     $perms = FlexicontentHelperPerm::getPerm();
     // handles super admins correctly
     // Check no access to categories management (Global permission)
     if (!$perms->CanCats) {
         $app->redirect('index.php?option=com_flexicontent', JText::_('FLEXI_NO_ACCESS'));
     }
     // Check no privilege to create new categories (Global permission)
     if ($isnew && !$perms->CanAddCats) {
         JError::raiseWarning(403, JText::_('FLEXI_NO_ACCESS_CREATE'));
         $app->redirect('index.php?option=com_flexicontent');
     }
     // ************************************************************************************
     // Record Permssions (needed because this view can be called without a controller task)
     // ************************************************************************************
     // Get edit privilege for current category
     if (!$isnew) {
         if (FLEXI_J16GE) {
             $isOwner = $row->get('created_by') == $user->id;
             $rights = FlexicontentHelperPerm::checkAllItemAccess($user->id, 'category', $cid);
             $canedit_cat = in_array('edit', $rights) || in_array('edit.own', $rights) && $isOwner;
         } else {
             if (FLEXI_ACCESS) {
                 $rights = FAccess::checkAllItemAccess('com_content', 'users', $user->gmid, 0, $row->id);
                 $canedit_cat = $user->gid < 25 ? in_array('edit', $rights) || in_array('editown', $rights) : 1;
             } else {
                 $canedit_cat = true;
             }
         }
     }
     // Get if we can create inside at least one (com_content) category
     if (!FLEXI_J16GE || $user->authorise('core.create', 'com_flexicontent')) {
         $cancreate_cat = true;
     } else {
         $usercats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true, $check_published = true, $specific_catids = false, $find_first = true);
         $cancreate_cat = count($usercats) > 0;
     }
     // Creating new category: Check if user can create inside any existing category
     if ($isnew && !$cancreate_cat) {
         $acc_msg = JText::_('FLEXI_NO_ACCESS_CREATE') . "<br/>" . (FLEXI_J16GE ? JText::_('FLEXI_CANNOT_ADD_CATEGORY_REASON') : "");
         JError::raiseWarning(403, $acc_msg);
         $app->redirect('index.php?option=com_flexicontent&view=categories');
     }
     // Editing existing category: Check if user can edit existing (current) category
     if (!$isnew && !$canedit_cat) {
         $acc_msg = JText::_('FLEXI_NO_ACCESS_EDIT') . "<br/>" . JText::_('FLEXI_CANNOT_EDIT_CATEGORY_REASON');
         JError::raiseWarning(403, $acc_msg);
         $app->redirect('index.php?option=com_flexicontent&view=categories');
     }
     // **************************************************
     // Include needed files and add needed js / css files
     // **************************************************
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadFramework('jQuery');
     flexicontent_html::loadFramework('select2');
     // Load pane behavior
     jimport('joomla.html.pane');
     // Load tooltips
     JHTML::_('behavior.tooltip');
     // Add css to document
     $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css');
     if (FLEXI_J30GE) {
         $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css');
     } else {
         if (FLEXI_J16GE) {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css');
         } else {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css');
         }
     }
     // Add js function to overload the joomla submitform
     $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/admin.js');
     $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/validate.js');
     // ********************
     // Initialise variables
     // ********************
     $editor_name = $user->getParam('editor', $app->getCfg('editor'));
     $editor = JFactory::getEditor($editor_name);
     $cparams = JComponentHelper::getParams('com_flexicontent');
     $bar = JToolBar::getInstance('toolbar');
     if (!FLEXI_J16GE) {
         $pane = JPane::getInstance('sliders');
         $tpane = JPane::getInstance('tabs', array('startOffset' => 0, 'allowAllClose' => true, 'opacityTransition' => true, 'duration' => 600));
     }
     $categories = $globalcats;
     // ******************
     // Create the toolbar
     // ******************
     // Create Toolbar title and add the preview button
     if (!$isnew) {
         JToolBarHelper::title(JText::_('FLEXI_EDIT_CATEGORY'), 'fc_categoryedit');
         $autologin = $cparams->get('autoflogin', 1) ? '&fcu=' . $user->username . '&fcp=' . $user->password : '';
         $previewlink = JRoute::_(JURI::root() . FlexicontentHelperRoute::getCategoryRoute($categories[$cid]->slug)) . $autologin;
         // Add a preview button
         $bar->appendButton('Custom', '<a class="preview btn btn-small" href="' . $previewlink . '" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-32-preview"></span>' . JText::_('Preview') . '</a>', 'preview');
     } else {
         JToolBarHelper::title(JText::_('FLEXI_NEW_CATEGORY'), 'fc_categoryadd');
     }
     // Add apply and save buttons
     if (FLEXI_J16GE) {
         JToolBarHelper::apply('category.apply');
         JToolBarHelper::save('category.save');
     } else {
         JToolBarHelper::apply();
         JToolBarHelper::save();
     }
     // Add a save and new button, if user can create inside at least one (com_content) category
     if ($cancreate_cat) {
         if (FLEXI_J16GE) {
             JToolBarHelper::save2new('category.save2new');
         } else {
             JToolBarHelper::custom('saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false);
         }
     }
     // Add a save as copy button, if editing an existing category (J2.5 only)
     if (FLEXI_J16GE && !$isnew && $cancreate_cat) {
         JToolBarHelper::save2copy('category.save2copy');
     }
     // Add a cancel or close button
     if ($isnew) {
         if (FLEXI_J16GE) {
             JToolBarHelper::cancel('category.cancel');
         } else {
             JToolBarHelper::cancel();
         }
     } else {
         if (FLEXI_J16GE) {
             JToolBarHelper::cancel('category.cancel', 'JTOOLBAR_CLOSE');
         } else {
             JToolBarHelper::custom('cancel', 'cancel.png', 'cancel.png', 'CLOSE', false);
         }
     }
     // *******************************************
     // Prepare data to pass to the form's template
     // *******************************************
     if (!FLEXI_J16GE) {
         //clean data
         JFilterOutput::objectHTMLSafe($row, ENT_QUOTES, 'description');
         // Create the form
         $form = new JParameter($row->params, JPATH_COMPONENT . DS . 'models' . DS . 'category.xml');
         //$form->loadINI($row->attribs);
         //echo "<pre>"; print_r($form->_xml['templates']->_children[0]);  echo "<pre>"; print_r($form->_xml['templates']->param[0]); exit;
         foreach ($form->_xml['templates']->_children as $i => $child) {
             if (isset($child->_attributes['enableparam']) && !$cparams->get($child->_attributes['enableparam'])) {
                 unset($form->_xml['templates']->_children[$i]);
                 unset($form->_xml['templates']->param[$i]);
             }
         }
         foreach ($form->_xml['special']->_children as $i => $child) {
             if (isset($child->_attributes['enableparam']) && !$cparams->get($child->_attributes['enableparam'])) {
                 unset($form->_xml['special']->_children[$i]);
                 unset($form->_xml['special']->param[$i]);
             }
         }
     }
     // **********************************************************************************
     // Get Templates and apply Template Parameters values into the form fields structures
     // **********************************************************************************
     $themes = flexicontent_tmpl::getTemplates();
     $tmpls = $themes->category;
     foreach ($tmpls as $tmpl) {
         if (FLEXI_J16GE) {
             $jform = new JForm('com_flexicontent.template.category', array('control' => 'jform', 'load_data' => true));
             $jform->load($tmpl->params);
             $tmpl->params = $jform;
             // ... values applied at the template form file
         } else {
             $tmpl->params->loadINI($row->params);
         }
     }
     //build selectlists
     $Lists = array();
     if (!FLEXI_J16GE) {
         $javascript = "onchange=\"javascript:if (document.forms[0].image.options[selectedIndex].value!='') {document.imagelib.src='../images/stories/' + document.forms[0].image.options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\"";
         $Lists['imagelist'] = JHTML::_('list.images', 'image', $row->image, $javascript, '/images/stories/');
         $Lists['access'] = JHTML::_('list.accesslevel', $row);
         // build granular access list
         if (FLEXI_ACCESS) {
             $Lists['access'] = FAccess::TabGmaccess($row, 'category', 1, 1, 1, 1, 1, 1, 1, 1, 1);
         }
     }
     $check_published = false;
     $check_perms = true;
     $actions_allowed = array('core.create');
     $fieldname = FLEXI_J16GE ? 'jform[parent_id]' : 'parent_id';
     $Lists['parent_id'] = flexicontent_cats::buildcatselect($categories, $fieldname, $row->parent_id, $top = 1, 'class="use_select2_lib"', $check_published, $check_perms, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array($row->id));
     $check_published = false;
     $check_perms = true;
     $actions_allowed = array('core.edit', 'core.edit.own');
     $fieldname = FLEXI_J16GE ? 'jform[copycid]' : 'copycid';
     $Lists['copycid'] = flexicontent_cats::buildcatselect($categories, $fieldname, '', $top = 2, 'class="use_select2_lib"', $check_published, $check_perms, $actions_allowed, $require_all = false);
     $custom_options[''] = 'FLEXI_USE_GLOBAL';
     $custom_options['0'] = 'FLEXI_COMPONENT_ONLY';
     $custom_options['-1'] = 'FLEXI_PARENT_CAT_MULTI_LEVEL';
     $check_published = false;
     $check_perms = true;
     $actions_allowed = array('core.edit', 'core.edit.own');
     $fieldname = FLEXI_J16GE ? 'jform[special][inheritcid]' : 'params[inheritcid]';
     $Lists['inheritcid'] = flexicontent_cats::buildcatselect($categories, $fieldname, $catparams->get('inheritcid', ''), $top = false, 'class="use_select2_lib"', $check_published, $check_perms, $actions_allowed, $require_all = false, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options);
     // ************************
     // Assign variables to view
     // ************************
     $this->assignRef('document', $document);
     $this->assignRef('Lists', $Lists);
     $this->assignRef('row', $row);
     $this->assignRef('form', $form);
     $this->assignRef('perms', $perms);
     $this->assignRef('editor', $editor);
     $this->assignRef('tmpls', $tmpls);
     $this->assignRef('cparams', $cparams);
     if (!FLEXI_J16GE) {
         $this->assignRef('pane', $pane);
         $this->assignRef('tpane', $tpane);
     }
     parent::display($tpl);
 }
Esempio n. 24
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. 25
0
 /**
  * Creates the page's display
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     //initialize variables
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $uri = JFactory::getURI();
     $view = JRequest::getCmd('view');
     // Get view's Model
     $model = $this->getModel();
     // Get tag and set tag parameters as VIEW's parameters (tag parameters are merged with component/page(=menu item) and optionally with tag cloud parameters)
     $tag = $model->getTag();
     if (empty($tag)) {
         // Raise a 404 error, if tag doesn't exist or access isn't permitted, maybe move this into model ??
         $tid = JRequest::getInt('id', 0);
         $msg = JText::sprintf($tid ? 'Tag id was not set (is 0)' : 'Tag #%d not found', $tid);
         if (FLEXI_J16GE) {
             throw new Exception($msg, 404);
         } else {
             JError::raiseError(404, $msg);
         }
     }
     // Get parameters via model
     $params = $model->getParams();
     // Get various data from the model
     $items = $this->get('Data');
     $total = $this->get('Total');
     // Make sure field values were retrieved e.g. we need 'item->categories' for template classes
     $items = FlexicontentFields::getFields($items, $view, $params);
     // Calculate CSS classes needed to add special styling markups to the items
     flexicontent_html::calculateItemMarkups($items, $params);
     // ********************************
     // Load needed JS libs & CSS styles
     // ********************************
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadFramework('jQuery');
     flexicontent_html::loadFramework('flexi_tmpl_common');
     //add css file
     if (!$params->get('disablecss', '')) {
         $document->addStyleSheet($this->baseurl . '/components/com_flexicontent/assets/css/flexicontent.css');
         $document->addCustomTag('<!--[if IE]><style type="text/css">.floattext {zoom:1;}</style><![endif]-->');
     }
     //allow css override
     if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) {
         $document->addStyleSheet($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css');
     }
     // **********************************************************
     // Calculate a (browser window) page title and a page heading
     // **********************************************************
     // Verify menu item points to current FLEXIcontent object
     if ($menu) {
         $view_ok = 'tags' == @$menu->query['view'];
         $tid_ok = $tag->id == (int) @$menu->query['id'];
         $menu_matches = $view_ok && $tid_ok;
         //$menu_params = FLEXI_J16GE ? $menu->params : new JParameter($menu->params);  // Get active menu item parameters
     } else {
         $menu_matches = false;
     }
     // MENU ITEM matched, use its page heading (but use menu title if the former is not set)
     if ($menu_matches) {
         $default_heading = FLEXI_J16GE ? $menu->title : $menu->name;
         // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->def('page_heading', $params->get('page_title', $default_heading));
         $params->def('page_title', $params->get('page_heading', $default_heading));
         $params->def('show_page_heading', $params->get('show_page_title', 0));
         $params->def('show_page_title', $params->get('show_page_heading', 0));
     } else {
         // Clear some menu parameters
         //$params->set('pageclass_sfx',	'');  // CSS class SUFFIX is behavior, so do not clear it ?
         // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ...
         // meta_params->get('page_title') is meant for <title> but let's use as ... default page heading
         $default_heading = JText::_('FLEXI_ITEMS_WITH_TAG') . ": " . $tag->name;
         // Decide to show page heading (=J1.5 page title), this is always yes
         $show_default_heading = 1;
         // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->set('page_title', $default_heading);
         $params->set('page_heading', $default_heading);
         $params->set('show_page_heading', $show_default_heading);
         $params->set('show_page_title', $show_default_heading);
     }
     // Prevent showing the page heading if ... currently no reason
     if (0) {
         $params->set('show_page_heading', 0);
         $params->set('show_page_title', 0);
     }
     // ************************************************************
     // 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
     if (FLEXI_J16GE) {
         // Not available in J1.5
         // 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);
     // ************************
     // Set document's META tags
     // ************************
     // Workaround for Joomla not setting the default value for 'robots', so component must do it
     $app_params = $app->getParams();
     if ($_mp = $app_params->get('robots')) {
         $document->setMetadata('robots', $_mp);
     }
     // Overwrite with menu META data if menu matched
     if (FLEXI_J16GE) {
         if ($menu_matches) {
             if ($_mp = $menu->params->get('menu-meta_description')) {
                 $document->setDescription($_mp);
             }
             if ($_mp = $menu->params->get('menu-meta_keywords')) {
                 $document->setMetadata('keywords', $_mp);
             }
             if ($_mp = $menu->params->get('robots')) {
                 $document->setMetadata('robots', $_mp);
             }
             if ($_mp = $menu->params->get('secure')) {
                 $document->setMetadata('secure', $_mp);
             }
         }
     }
     // ************************************
     // Add rel canonical html head link tag (TODO: improve multi-page handing)
     // ************************************
     $base = $uri->getScheme() . '://' . $uri->getHost();
     $start = JRequest::getVar('start', '');
     $start = $start ? "&start=" . $start : "";
     $ucanonical = $base . JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->id) . $start);
     if ($params->get('add_canonical')) {
         $head_obj = $document->addHeadLink($ucanonical, 'canonical', 'rel', '');
         $defaultCanonical = flexicontent_html::getDefaultCanonical();
         if (FLEXI_J30GE && $defaultCanonical != $ucanonical) {
             unset($head_obj->_links[$defaultCanonical]);
         }
     }
     //ordering
     $filter_order = JRequest::getCmd('filter_order', 'i.title');
     $filter_order_Dir = JRequest::getCmd('filter_order_Dir', 'ASC');
     $filter = JRequest::getString('filter');
     $lists = array();
     $lists['filter_order'] = $filter_order;
     $lists['filter_order_Dir'] = $filter_order_Dir;
     $lists['filter'] = $filter;
     // Create the pagination object
     $pageNav = $this->get('pagination');
     // Create links, etc
     $link = JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->slug), false);
     //$print_link = JRoute::_('index.php?view=tags&id='.$tag->slug.'&pop=1&tmpl=component');
     $curr_url = $_SERVER['REQUEST_URI'];
     $print_link = $curr_url . (strstr($curr_url, '?') ? '&amp;' : '?') . 'pop=1&amp;tmpl=component&amp;print=1';
     $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->assignRef('action', $link);
     // $uri->toString()
     $this->assignRef('print_link', $print_link);
     $this->assignRef('tag', $tag);
     $this->assignRef('items', $items);
     $this->assignRef('lists', $lists);
     $this->assignRef('params', $params);
     $this->assignRef('pageNav', $pageNav);
     $this->assignRef('pageclass_sfx', $pageclass_sfx);
     $print_logging_info = $params->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. 26
0
 function display($tpl = null)
 {
     // ********************
     // Initialise variables
     // ********************
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $option = $jinput->get('option', '', 'cmd');
     $view = $jinput->get('view', '', 'cmd');
     $cparams = JComponentHelper::getParams('com_flexicontent');
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     $document = JFactory::getDocument();
     // Get model
     $model = $this->getModel();
     $print_logging_info = $cparams->get('print_logging_info');
     if ($print_logging_info) {
         global $fc_run_times;
     }
     // ***********
     // Get filters
     // ***********
     $count_filters = 0;
     // various filters
     $filter_fieldtype = $model->getState('filter_fieldtype');
     $filter_assigned = $model->getState('filter_assigned');
     $filter_type = $model->getState('filter_type');
     $filter_state = $model->getState('filter_state');
     $filter_access = $model->getState('filter_access');
     if ($filter_assigned) {
         $count_filters++;
     }
     if ($filter_fieldtype) {
         $count_filters++;
     }
     if ($filter_state) {
         $count_filters++;
     }
     if ($filter_access) {
         $count_filters++;
     }
     if ($filter_type) {
         $count_filters++;
     }
     // ordering filters
     $filter_order = $model->getState('filter_order');
     $filter_order_Dir = $model->getState('filter_order_Dir');
     // text search
     $search = $model->getState('search');
     $search = $db->escape(trim(JString::strtolower($search)));
     // ****************************
     // Important usability messages
     // ****************************
     if ($cparams->get('show_usability_messages', 1)) {
         $notice_content_type_order = $app->getUserStateFromRequest($option . '.' . $view . '.notice_content_type_order', 'notice_content_type_order', 0, 'int');
         if (!$notice_content_type_order) {
             $app->setUserState($option . '.' . $view . '.notice_content_type_order', 1);
             $app->enqueueMessage(JText::_('FLEXI_DEFINE_FIELD_ORDER_FILTER_BY_TYPE'), 'message');
             $app->enqueueMessage(JText::_('FLEXI_DEFINE_FIELD_ORDER_FILTER_WITHOUT_TYPE'), 'message');
             $app->enqueueMessage(JText::_('FLEXI_USABILITY_MESSAGES_TURN_OFF'), 'message');
         }
     }
     // **************************
     // Add css and js to document
     // **************************
     flexicontent_html::loadFramework('select2');
     //JHTML::_('behavior.tooltip');
     $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VHASH);
     $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VHASH);
     $js = "jQuery(document).ready(function(){";
     // *****************************
     // Get user's global permissions
     // *****************************
     $perms = FlexicontentHelperPerm::getPerm();
     // ************************
     // Create Submenu & Toolbar
     // ************************
     // Create Submenu (and also check access to current view)
     FLEXISubmenu('CanFields');
     // Create document/toolbar titles
     $doc_title = JText::_('FLEXI_FIELDS');
     $site_title = $document->getTitle();
     JToolBarHelper::title($doc_title, 'fields');
     $document->setTitle($doc_title . ' - ' . $site_title);
     if ($perms->CanEditField) {
         $ctrl_task = '&task=fields.selectsearchflag';
         $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent' . $ctrl_task . '&tmpl=component';
         $btn_name = 'basicindex';
         $btn_task = '';
         $full_js = ';';
         $extra_js = '';
         flexicontent_html::addToolBarButton(JText::_('FLEXI_TOGGLE_SEARCH_FLAG'), $btn_name, $full_js, $msg_alert = JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm = '', $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = false, $btn_class = "");
         $js .= "\n\t\t\t\tjQuery('#toolbar-basicindex a.toolbar, #toolbar-basicindex button')\n\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 800, y: 340}, onClose: function() {}}');\n\t\t\t";
     }
     $contrl = "fields.";
     if ($perms->CanCopyFields) {
         JToolBarHelper::custom($contrl . 'copy', 'copy.png', 'copy_f2.png', 'FLEXI_COPY');
         JToolBarHelper::custom($contrl . 'copy_wvalues', 'copy_wvalues.png', 'copy_f2.png', 'FLEXI_COPY_WITH_VALUES');
         JToolBarHelper::divider();
     }
     JToolBarHelper::publishList($contrl . 'publish');
     JToolBarHelper::unpublishList($contrl . 'unpublish');
     if ($perms->CanAddField) {
         JToolBarHelper::addNew($contrl . 'add');
     }
     if ($perms->CanEditField) {
         JToolBarHelper::editList($contrl . 'edit');
     }
     if ($perms->CanDeleteField) {
         //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove');
         // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag)
         $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE'));
         $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM');
         $btn_task = $contrl . 'remove';
         $extra_js = "";
         flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true);
     }
     JToolbarHelper::checkin($contrl . 'checkin');
     /*
     JToolBarHelper::divider(); JToolBarHelper::spacer();
     $btn_name = 'basicindex';
     $btn_task    = 'fields.toggleprop';
     $extra_js    = "document.getElementById('adminForm').elements['propname'].value='issearch';";
     flexicontent_html::addToolBarButton(
     	'FLEXI_TOGGLE_TEXT_SEARCHABLE', $btn_name, $full_js='', $msg_alert=JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm='',
     	$btn_task, $extra_js, $btn_list=true, $btn_menu=true, $btn_confirm=false, $btn_class="btn-info");
     
     $btn_name = 'basicfilter';
     $btn_task    = 'fields.toggleprop';
     $extra_js    = "document.getElementById('adminForm').elements['propname'].value='isfilter';";
     flexicontent_html::addToolBarButton(
     	'FLEXI_TOGGLE_FILTERABLE', $btn_name, $full_js='', $msg_alert=JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm='',
     	$btn_task, $extra_js, $btn_list=true, $btn_menu=true, $btn_confirm=false, $btn_class="btn-info");
     
     $btn_name = 'advindex';
     $btn_task    = 'fields.toggleprop';
     $extra_js    = "document.getElementById('adminForm').elements['propname'].value='isadvsearch';";
     flexicontent_html::addToolBarButton(
     	'FLEXI_TOGGLE_ADV_TEXT_SEARCHABLE', $btn_name, $full_js='', $msg_alert=JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm='',
     	$btn_task, $extra_js, $btn_list=true, $btn_menu=true, $btn_confirm=false, $btn_class="btn-info");
     
     $btn_name = 'advfilter';
     $btn_task    = 'fields.toggleprop';
     $extra_js    = "document.getElementById('adminForm').elements['propname'].value='isadvfilter';";
     flexicontent_html::addToolBarButton(
     	'FLEXI_TOGGLE_ADV_FILTERABLE', $btn_name, $full_js='', $msg_alert=JText::_('FLEXI_SELECT_FIELDS_TO_TOGGLE_PROPERTY'), $msg_confirm='',
     	$btn_task, $extra_js, $btn_list=true, $btn_menu=true, $btn_confirm=false, $btn_class="btn-info");
     */
     $appsman_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'appsman';
     if (file_exists($appsman_path)) {
         $btn_icon = 'icon-download';
         $btn_name = 'download';
         $btn_task = 'appsman.exportxml';
         $extra_js = " var f=document.getElementById('adminForm'); f.elements['view'].value='appsman'; jQuery('<input>').attr({type: 'hidden', name: 'table', value: 'flexicontent_fields'}).appendTo(jQuery(f));";
         flexicontent_html::addToolBarButton('Export now', $btn_name, $full_js = '', $msg_alert = '', $msg_confirm = 'Export now as XML', $btn_task, $extra_js, $btn_list = false, $btn_menu = true, $btn_confirm = true, $btn_class = "btn-warning", $btn_icon);
         $btn_icon = 'icon-box-add';
         $btn_name = 'box-add';
         $btn_task = 'appsman.addtoexport';
         $extra_js = " var f=document.getElementById('adminForm'); f.elements['view'].value='appsman'; jQuery('<input>').attr({type: 'hidden', name: 'table', value: 'flexicontent_fields'}).appendTo(jQuery(f));";
         flexicontent_html::addToolBarButton('Add to export', $btn_name, $full_js = '', $msg_alert = '', $msg_confirm = 'Add to export list', $btn_task, $extra_js, $btn_list = false, $btn_menu = true, $btn_confirm = true, $btn_class = "btn-warning", $btn_icon);
     }
     /*$btn_icon = 'icon-download';
     		$btn_name = 'download';
     		$btn_task    = 'fields.exportsql';
     		$extra_js    = "";
     		flexicontent_html::addToolBarButton(
     			'Export SQL', $btn_name, $full_js='', $msg_alert='', $msg_confirm='Field\'s configuration will be exported as SQL',
     			$btn_task, $extra_js, $btn_list=false, $btn_menu=true, $btn_confirm=true, $btn_class="btn-warning", $btn_icon);
     		
     		
     		$btn_icon = 'icon-download';
     		$btn_name = 'download';
     		$btn_task    = 'fields.exportcsv';
     		$extra_js    = "";
     		flexicontent_html::addToolBarButton(
     			'Export CSV', $btn_name, $full_js='', $msg_alert='', $msg_confirm='Field\'s configuration will be exported as CSV',
     			$btn_task, $extra_js, $btn_list=false, $btn_menu=true, $btn_confirm=true, $btn_class="btn-warning", $btn_icon);*/
     if ($perms->CanConfig) {
         JToolBarHelper::divider();
         JToolBarHelper::spacer();
         $session = JFactory::getSession();
         $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent');
         $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940;
         $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent');
         $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550;
         JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration');
     }
     $js .= "});";
     $document->addScriptDeclaration($js);
     // Get data from the model
     if ($print_logging_info) {
         $start_microtime = microtime(true);
     }
     $rows = $this->get('Items');
     $allrows = $this->get('AllItems');
     if ($print_logging_info) {
         @($fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
     }
     $pagination = $this->get('Pagination');
     // Pagination
     $types = $this->get('Typeslist');
     // Content types
     $fieldTypes = flexicontent_db::getFieldTypes($_grouped = true, $_usage = true, $_published = false);
     // Field types with content type ASSIGNMENT COUNTING
     $lists = array();
     // build item-type filter
     $lists['filter_type'] = ($filter_type || 1 ? '<label class="label">' . JText::_('FLEXI_TYPE') . '</label>' : '') . flexicontent_html::buildtypesselect($types, 'filter_type', $filter_type, '-', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'filter_type');
     // build orphaned/assigned filter
     $assigned = array();
     $assigned[] = JHTML::_('select.option', '', '-');
     $assigned[] = JHTML::_('select.option', 'O', JText::_('FLEXI_ORPHANED'));
     $assigned[] = JHTML::_('select.option', 'A', JText::_('FLEXI_ASSIGNED'));
     $lists['assigned'] = ($filter_assigned || 1 ? '<label class="label">' . JText::_('FLEXI_ASSIGNED') . '</label>' : '') . JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_assigned);
     // build field-type filter
     $ALL = mb_strtoupper(JText::_('FLEXI_ALL'), 'UTF-8') . ' : ';
     $fftypes = array();
     $fftypes[] = array('value' => '', 'text' => '-');
     $fftypes[] = array('value' => 'BV', 'text' => $ALL . JText::_('FLEXI_BACKEND_FIELDS'));
     $fftypes[] = array('value' => 'C', 'text' => $ALL . JText::_('FLEXI_CORE_FIELDS'));
     $fftypes[] = array('value' => 'NC', 'text' => $ALL . JText::_('FLEXI_NON_CORE_FIELDS'));
     foreach ($fieldTypes as $field_group => $ft_types) {
         $fftypes[] = $field_group;
         foreach ($ft_types as $field_type => $ftdata) {
             $fftypes[] = array('value' => $ftdata->field_type, 'text' => '-' . $ftdata->assigned . '- ' . $ftdata->friendly);
         }
         $fftypes[] = '';
     }
     $lists['fftype'] = ($filter_fieldtype || 1 ? '<label class="label">' . JText::_('FLEXI_FIELD_TYPE') . '</label>' : '') . flexicontent_html::buildfieldtypeslist($fftypes, 'filter_fieldtype', $filter_fieldtype, $_grouped ? 1 : 0, 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"');
     // build publication state filter
     $states = array();
     $states[] = JHTML::_('select.option', '', '-');
     $states[] = JHTML::_('select.option', 'P', JText::_('FLEXI_PUBLISHED'));
     $states[] = JHTML::_('select.option', 'U', JText::_('FLEXI_UNPUBLISHED'));
     //$states[] = JHTML::_('select.option',  '-2', JText::_( 'FLEXI_TRASHED' ) );
     $lists['state'] = ($filter_state || 1 ? '<label class="label">' . JText::_('FLEXI_STATE') . '</label>' : '') . JHTML::_('select.genericlist', $states, 'filter_state', 'class="use_select2_lib" size="1" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"', 'value', 'text', $filter_state);
     //JHTML::_('grid.state', $filter_state );
     // build access level filter
     $options = JHtml::_('access.assetgroups');
     array_unshift($options, JHtml::_('select.option', '', '-'));
     $fieldname = $elementid = 'filter_access';
     $attribs = 'class="use_select2_lib" onchange="document.adminForm.limitstart.value=0; Joomla.submitform()"';
     $lists['access'] = ($filter_access || 1 ? '<label class="label">' . JText::_('FLEXI_ACCESS') . '</label>' : '') . JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_access, $elementid, $translate = true);
     // text search filter
     $lists['search'] = $search;
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     if ($filter_type == '' || $filter_type == 0) {
         $ordering = $lists['order'] == 't.ordering';
     } else {
         $ordering = $lists['order'] == 'typeordering';
     }
     //assign data to template
     $this->assignRef('count_filters', $count_filters);
     $this->assignRef('permission', $perms);
     $this->assignRef('filter_type', $filter_type);
     $this->assignRef('lists', $lists);
     $this->assignRef('rows', $rows);
     $this->assignRef('allrows', $allrows);
     $this->assignRef('types', $types);
     $this->assignRef('ordering', $ordering);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('option', $option);
     $this->assignRef('view', $view);
     $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null;
     parent::display($tpl);
 }
 * FLEXIcontent is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

defined( '_JEXEC' ) or die( 'Restricted access' );
// first define the template name
$tmpl = $this->tmpl;
$user = JFactory::getUser();

// ITEMS as MASONRY tiles
if ($this->params->get('lead_placement', 0)==1 || $this->params->get('intro_placement', 0)==1)
{
	flexicontent_html::loadFramework('masonry');
	flexicontent_html::loadFramework('imagesLoaded');
	
	$js = "
		jQuery(document).ready(function(){
	";
	if ($this->params->get('lead_placement', 0)==1) {
		$js .= "
			var container_lead = document.querySelector('ul.leadingblock');
			var msnry_lead;
			// initialize Masonry after all images have loaded
			imagesLoaded( container_lead, function() {
				msnry_lead = new Masonry( container_lead );
			});
		";
	}
	if ($this->params->get('lead_placement', 0)==1) {
Esempio n. 28
0
    function display($tpl = null)
    {
        // ********************
        // Initialise variables
        // ********************
        $app = JFactory::getApplication();
        $jinput = $app->input;
        $option = $jinput->get('option', '', 'cmd');
        $view = $jinput->get('view', '', 'cmd');
        $task = $jinput->get('task', '', 'cmd');
        $cparams = JComponentHelper::getParams('com_flexicontent');
        $user = JFactory::getUser();
        $db = JFactory::getDBO();
        $document = JFactory::getDocument();
        $session = JFactory::getSession();
        // Get model
        $model = $this->getModel();
        // Some flags
        $has_zlib = function_exists("zlib_encode");
        //version_compare(PHP_VERSION, '5.4.0', '>=');
        // Get session information
        $conf = $session->get('csvimport_config', "", 'flexicontent');
        $conf = unserialize($conf ? $has_zlib ? zlib_decode(base64_decode($conf)) : base64_decode($conf) : "");
        $lineno = $session->get('csvimport_lineno', 999999, 'flexicontent');
        $session->set('csvimport_parse_log', null, 'flexicontent');
        // This is the flag if CSV file has been parsed (import form already submitted), thus to display the imported data
        // **************************
        // Add css and js to document
        // **************************
        $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VHASH);
        $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VHASH);
        // Add JS frameworks
        flexicontent_html::loadFramework('select2');
        $prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable');
        flexicontent_html::loadFramework('flexi-lib');
        // Add js function to overload the joomla submitform validation
        JHTML::_('behavior.formvalidation');
        // load default validation JS to make sure it is overriden
        $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VHASH);
        $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VHASH);
        // *****************************
        // Get user's global permissions
        // *****************************
        $perms = FlexicontentHelperPerm::getPerm();
        // ************************
        // Create Submenu & Toolbar
        // ************************
        // Create Submenu (and also check access to current view)
        FLEXISubmenu('CanImport');
        // Create document/toolbar titles
        $doc_title = JText::_('FLEXI_IMPORT');
        $site_title = $document->getTitle();
        JToolBarHelper::title($doc_title, 'import');
        $document->setTitle($doc_title . ' - ' . $site_title);
        // Create the toolbar
        $toolbar = JToolBar::getInstance('toolbar');
        if (!empty($conf)) {
            if ($task != 'processcsv') {
                $ctrl_task = 'import.processcsv';
                $import_btn_title = empty($lineno) ? 'FLEXI_IMPORT_START_TASK' : 'FLEXI_IMPORT_CONTINUE_TASK';
                JToolBarHelper::custom($ctrl_task, 'save.png', 'save.png', $import_btn_title, $list_check = false);
            }
            $ctrl_task = 'import.clearcsv';
            JToolBarHelper::custom($ctrl_task, 'cancel.png', 'cancel.png', 'FLEXI_IMPORT_CLEAR_TASK', $list_check = false);
        } else {
            $ctrl_task = 'import.initcsv';
            JToolBarHelper::custom($ctrl_task, 'import.png', 'import.png', 'FLEXI_IMPORT_PREPARE_TASK', $list_check = false);
            $ctrl_task = 'import.testcsv';
            JToolBarHelper::custom($ctrl_task, 'test.png', 'test.png', 'FLEXI_IMPORT_TEST_FILE_FORMAT', $list_check = false);
        }
        //JToolBarHelper::Back();
        if ($perms->CanConfig) {
            JToolBarHelper::divider();
            JToolBarHelper::spacer();
            $session = JFactory::getSession();
            $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent');
            $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940;
            $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent');
            $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550;
            JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration');
        }
        // Get types
        $types = flexicontent_html::getTypesList($_type_ids = false, $_check_perms = false, $_published = true);
        // Get Languages
        $languages = FLEXIUtilities::getLanguages('code');
        // Get categories
        global $globalcats;
        $categories = $globalcats;
        // ************************************
        // Decide layout to load: 'import*.php'
        // ************************************
        $this->setLayout('import');
        $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null;
        // Execute the import task, load the log-like AJAX-based layout (import_process.php), to display results including any warnings
        if (!empty($conf) && $task == 'processcsv') {
            $this->assignRef('conf', $conf);
            parent::display('process');
            return;
        } else {
            if (!empty($conf)) {
                $this->assignRef('conf', $conf);
                $this->assignRef('cparams', $cparams);
                $this->assignRef('types', $types);
                $this->assignRef('languages', $languages);
                $this->assignRef('categories', $globalcats);
                parent::display('list');
                return;
            }
        }
        // Session config is empty, means import form has not been submited, display the form
        // We will display import form which is not 'default.php', it is 'import.php'
        // else ...
        // Check is session table DATA column is not mediumtext (16MBs, it can be 64 KBs ('text') in some sites that were not properly upgraded)
        $tblname = 'session';
        $dbprefix = $app->getCfg('dbprefix');
        $dbname = $app->getCfg('db');
        $db->setQuery("SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" . $dbname . "' AND TABLE_NAME = '" . $dbprefix . $tblname . "'");
        $jession_coltypes = $db->loadAssocList('COLUMN_NAME');
        $_dataColType = strtolower($jession_coltypes['data']['DATA_TYPE']);
        $_dataCol_wrongSize = $_dataColType != 'mediumtext' && $_dataColType != 'longtext';
        // If data type is "text" it is safe to assume that it can be converted to "mediumtext",
        // since "text" means that session table is not memory storage,
        // plus it is already stored externally aka operation will be quick ?
        /*if ($_dataCol_wrongSize && $_dataColType == 'text')
        		{
        			$db->setQuery("ALTER TABLE `#__session` MODIFY `data` MEDIUMTEXT");
        			$db->execute();
        			$_dataCol_wrongSize = false;
        		}*/
        if ($_dataCol_wrongSize) {
            $app->enqueueMessage("Joomla DB table: <b>'session'</b> has a <b>'data'</b> column with type: <b>'" . $_dataColType . "'</b>, instead of expected type <b>'mediumtext'</b>. Trying to import large data files may fail", "notice");
        }
        $formvals = array();
        // Retrieve Basic configuration
        $formvals['type_id'] = $model->getState('type_id');
        $formvals['language'] = $model->getState('language');
        $formvals['state'] = $model->getState('state');
        $formvals['access'] = $model->getState('access');
        // Main and secondary categories, tags
        $formvals['maincat'] = $model->getState('maincat');
        $formvals['maincat_col'] = $model->getState('maincat_col');
        $formvals['seccats'] = $model->getState('seccats');
        $formvals['seccats_col'] = $model->getState('seccats_col');
        $formvals['tags_col'] = $model->getState('tags_col');
        // Publication: Author/modifier
        $formvals['created_by_col'] = $model->getState('created_by_col');
        $formvals['modified_by_col'] = $model->getState('modified_by_col');
        // Publication: META data
        $formvals['metadesc_col'] = $model->getState('metadesc_col');
        $formvals['metakey_col'] = $model->getState('metakey_col');
        // Publication: dates
        $formvals['modified_col'] = $model->getState('modified_col');
        $formvals['created_col'] = $model->getState('modified_col');
        $formvals['publish_up_col'] = $model->getState('publish_up_col');
        $formvals['publish_down_col'] = $model->getState('publish_down_col');
        // Advanced configuration
        $formvals['ignore_unused_cols'] = $model->getState('ignore_unused_cols');
        $formvals['id_col'] = $model->getState('id_col');
        $formvals['items_per_step'] = $model->getState('items_per_step');
        // CSV file format
        $formvals['mval_separator'] = $model->getState('mval_separator');
        $formvals['mprop_separator'] = $model->getState('mprop_separator');
        $formvals['field_separator'] = $model->getState('field_separator');
        $formvals['enclosure_char'] = $model->getState('enclosure_char');
        $formvals['record_separator'] = $model->getState('record_separator');
        $formvals['debug_records'] = $model->getState('debug_records');
        // ******************
        // Create form fields
        // ******************
        $lists['type_id'] = flexicontent_html::buildtypesselect($types, 'type_id', $formvals['type_id'], true, 'class="required use_select2_lib"', 'type_id');
        $actions_allowed = array('core.create');
        // Creating categorories tree for item assignment, we use the 'create' privelege
        // build the main category select list
        $attribs = 'class="use_select2_lib required"';
        $fieldname = 'maincat';
        $lists['maincat'] = flexicontent_cats::buildcatselect($categories, $fieldname, $formvals['maincat'], 2, $attribs, false, true, $actions_allowed);
        // build the secondary categories select list
        $class = "use_select2_lib";
        $attribs = 'multiple="multiple" size="10" class="' . $class . '"';
        $fieldname = 'seccats[]';
        $lists['seccats'] = flexicontent_cats::buildcatselect($categories, $fieldname, $formvals['seccats'], false, $attribs, false, true, $actions_allowed, $require_all = true);
        // build languages list
        // Retrieve author configuration
        $authorparams = flexicontent_db::getUserConfig($user->id);
        $allowed_langs = $authorparams->get('langs_allowed', null);
        $allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs);
        // 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('language', ' style="vertical-align:top;" onchange="var m=jQuery(\'#fc_import_about_langcol\'); this.value ? m.hide(600) : m.show(600);"', $formvals['language'], 6, $allowed_langs, $published_only = true, $disable_langs = null, $add_all = true, $conf = array('required' => true)) . '
			<span class="fc-mssg-inline fc-note fc-nobgimage" id="fc_import_about_langcol" style="display:none;">
				' . JText::_('FLEXI_USE_LANGUAGE_COLUMN_TIP') . '
			</span>';
        $lists['states'] = flexicontent_html::buildstateslist('state', ' style="vertical-align:top;" onchange="var m=jQuery(\'#fc_import_about_statecol\'); this.value ? m.hide(600) : m.show(600);"', $formvals['state'], 2) . '<span class="fc-mssg-inline fc-note fc-nobgimage" id="fc_import_about_statecol" style="display:none;">
				' . JText::_('FLEXI_USE_STATE_COLUMN_TIP') . '
			</span>';
        // build access level filter
        $access_levels = JHtml::_('access.assetgroups');
        array_unshift($access_levels, JHtml::_('select.option', '0', "Use 'access' column"));
        array_unshift($access_levels, JHtml::_('select.option', '', 'FLEXI_SELECT_ACCESS_LEVEL'));
        $fieldname = 'access';
        // make multivalue
        $elementid = 'access';
        $attribs = 'class="required use_select2_lib"';
        $lists['access'] = JHTML::_('select.genericlist', $access_levels, $fieldname, $attribs, 'value', 'text', $formvals['access'], $elementid, $translate = true);
        // Ignore warnings because component may not be installed
        $warnHandlers = JERROR::getErrorHandling(E_WARNING);
        JERROR::setErrorHandling(E_WARNING, 'ignore');
        // Reset the warning handler(s)
        foreach ($warnHandlers as $mode) {
            JERROR::setErrorHandling(E_WARNING, $mode);
        }
        // ********************************************************************************
        // Get field names (from the header line (row 0), and remove it form the data array
        // ********************************************************************************
        $file_field_types_list = '"image","file"';
        $q = 'SELECT id, name, label, field_type FROM #__flexicontent_fields AS fi' . ' WHERE fi.field_type IN (' . $file_field_types_list . ')';
        $db->setQuery($q);
        $file_fields = $db->loadObjectList('name');
        //assign data to template
        $this->assignRef('model', $model);
        $this->assignRef('lists', $lists);
        $this->assignRef('user', $user);
        $this->assignRef('cparams', $cparams);
        $this->assignRef('file_fields', $file_fields);
        $this->assignRef('formvals', $formvals);
        parent::display($tpl);
    }
Esempio n. 29
0
 static function createFilter(&$filter, $value = '', $formName = 'adminForm', $indexed_elements = false, $search_prop = '')
 {
     static $apply_cache = null;
     static $faceted_overlimit_msg = null;
     $user = JFactory::getUser();
     $mainframe = JFactory::getApplication();
     //$cparams   = $mainframe->getParams('com_flexicontent');
     $cparams = JComponentHelper::getParams('com_flexicontent');
     // createFilter maybe called in backend too ...
     $print_logging_info = $cparams->get('print_logging_info');
     $option = JRequest::getVar('option');
     $view = JRequest::getVar('view');
     $is_fc_component = $option == 'com_flexicontent';
     $isCategoryView = $is_fc_component && $view == 'category';
     $isSearchView = $is_fc_component && $view == 'search';
     if ($print_logging_info) {
         global $fc_run_times;
         $start_microtime = microtime(true);
     }
     // Apply caching to filters regardless of cache setting ...
     $apply_cache = FLEXI_CACHE;
     if ($apply_cache) {
         $itemcache = JFactory::getCache('com_flexicontent_filters');
         // Get Joomla Cache of '...items' Caching Group
         $itemcache->setCaching(1);
         // Force cache ON
         $itemcache->setLifeTime(FLEXI_CACHE_TIME);
         // Set expire time (default is 1 hour)
     }
     $isdate = in_array($filter->field_type, array('date', 'created', 'modified')) || $filter->parameters->get('isdate', 0);
     $default_size = $isdate ? 15 : 30;
     $_s = $isSearchView ? '_s' : '';
     // Some parameter shortcuts
     $label_filter = $filter->parameters->get('display_label_filter' . $_s, 0);
     // How to show filter label
     $size = $filter->parameters->get('text_filter_size', $default_size);
     // Size of filter
     $faceted_filter = $filter->parameters->get('faceted_filter' . $_s, 2);
     $display_filter_as = $filter->parameters->get('display_filter_as' . $_s, 0);
     // Filter Type of Display
     $filter_as_range = in_array($display_filter_as, array(2, 3));
     $require_all = !in_array($display_filter_as, array(1, 2, 3)) ? $filter->parameters->get('filter_values_require_all', 0) : 0;
     $combine_tip = $filter->parameters->get('filter_values_require_all_tip', 0);
     $show_matching_items = $filter->parameters->get('show_matching_items' . $_s, 1);
     $show_matches = $filter_as_range || !$faceted_filter ? 0 : $show_matching_items;
     $hide_disabled_values = $filter->parameters->get('hide_disabled_values' . $_s, 0);
     $get_filter_vals = in_array($display_filter_as, array(0, 2, 4, 5, 6));
     $filter_ffname = 'filter_' . $filter->id;
     $filter_ffid = $formName . '_' . $filter->id . '_val';
     // Make sure the current filtering values match the field filter configuration to single or multi-value
     if (in_array($display_filter_as, array(2, 3, 5, 6))) {
         if (!is_array($value)) {
             $value = strlen($value) ? array($value) : array();
         }
     } else {
         if (is_array($value)) {
             $value = @$value[0];
         }
     }
     //print_r($value);
     // Alter search property name (indexed fields only), remove underscore _ at start & end of it
     if ($indexed_elements && $search_prop) {
         preg_match("/^_([a-zA-Z_0-9]+)_\$/", $search_prop, $prop_matches);
         $search_prop = @$prop_matches[1];
     }
     // Get filtering values, this can be cached if not filtering according to current category filters
     if ($get_filter_vals) {
         $view_join = '';
         $view_where = '';
         $filters_where = array();
         // *** Limiting of displayed filter values according to current category filtering, but show all field values if filter is active
         if ($isCategoryView) {
             // category view, use parameter to decide if limitting filter values
             global $fc_catview;
             if ($faceted_filter) {
                 $view_join = @$fc_catview['join_clauses'];
                 $view_where = $fc_catview['where_conf_only'];
                 $filters_where = $fc_catview['filters_where'];
                 $view_total = isset($fc_catview['view_total']) ? $fc_catview['view_total'] : 0;
                 if ($fc_catview['alpha_where']) {
                     $filters_where['alpha'] = $fc_catview['alpha_where'];
                 }
                 // we use count bellow ... so add it only if it is non-empty
             }
         } else {
             if ($isSearchView) {
                 // search view, use parameter to decide if limitting filter values
                 global $fc_searchview;
                 if (empty($fc_searchview)) {
                     return array();
                 }
                 // search view plugin disabled ?
                 if ($faceted_filter) {
                     $view_join = $fc_searchview['join_clauses'];
                     $view_where = $fc_searchview['where_conf_only'];
                     $filters_where = $fc_searchview['filters_where'];
                     $view_total = isset($fc_searchview['view_total']) ? $fc_searchview['view_total'] : 0;
                 }
             }
         }
         $createFilterValues = !$isSearchView ? 'createFilterValues' : 'createFilterValuesSearch';
         // This is hack for filter core properties to be filterable in search view without being added to the adv search index
         if ($filter->field_type == 'coreprops' && $view == 'search') {
             $createFilterValues = 'createFilterValues';
         }
         // Get filter values considering PAGE configuration (regardless of ACTIVE filters)
         if ($apply_cache) {
             $results_page = $itemcache->call(array('FlexicontentFields', $createFilterValues), $filter, $view_join, $view_where, array(), $indexed_elements, $search_prop);
         } else {
             if (!$isSearchView) {
                 $results_page = FlexicontentFields::createFilterValues($filter, $view_join, $view_where, array(), $indexed_elements, $search_prop);
             } else {
                 $results_page = FlexicontentFields::createFilterValuesSearch($filter, $view_join, $view_where, array(), $indexed_elements, $search_prop);
             }
         }
         // Get filter values considering ACTIVE filters, but only if there is at least ONE filter active
         $faceted_max_item_limit = 10000;
         if ($faceted_filter == 2 && count($filters_where)) {
             if ($view_total <= $faceted_max_item_limit) {
                 // DO NOT cache at this point the filter combinations are endless, so they will produce big amounts of cached data, that will be rarely used ...
                 if (!$isSearchView) {
                     $results_active = FlexicontentFields::createFilterValues($filter, $view_join, $view_where, $filters_where, $indexed_elements, $search_prop);
                 } else {
                     $results_active = FlexicontentFields::createFilterValuesSearch($filter, $view_join, $view_where, $filters_where, $indexed_elements, $search_prop);
                 }
             } else {
                 if ($faceted_overlimit_msg === null) {
                     // Set a notice message about not counting item per filter values and instead showing item TOTAL of current category / view
                     $faceted_overlimit_msg = 1;
                     $filter_messages = JRequest::getVar('filter_message', array());
                     $filter_messages[] = JText::sprintf('FLEXI_FACETED_ITEM_LIST_OVER_LIMIT', $faceted_max_item_limit, $view_total);
                     JRequest::setVar('filter_messages', $filter_messages);
                 }
             }
         }
         // Decide which results to show those based: (a) on active filters or (b) on page configuration
         // This depends if hiding disabled values (for FACETED: 2) AND if active filters exist
         $use_active_vals = $hide_disabled_values && isset($results_active);
         $results_shown = $use_active_vals ? $results_active : $results_page;
         $update_found = !$use_active_vals && isset($results_active);
         // Set usage counters
         $results = array();
         foreach ($results_shown as $i => $result) {
             $results[$i] = $result;
             // FACETED: 0,1 or NOT showing usage
             // Set usage to non-zero value e.g. -1 ... which maybe used (e.g. disabling values) but not be displayed
             if (!$show_matches || $faceted_filter < 2) {
                 $results[$i]->found = -1;
             } else {
                 if ($update_found) {
                     $results[$i]->found = (int) @$results_active[$i]->found;
                 } else {
                 }
             }
             // Append value usage to value's label
             if ($faceted_filter == 2 && $show_matches && $results[$i]->found) {
                 $results[$i]->text .= ' (' . $results[$i]->found . ')';
             }
         }
     } else {
         $faceted_filter = 0;
         // clear faceted filter flag
     }
     // Prepend Field's Label to filter HTML
     // Commented out because it was moved in to form template file
     //$filter->html = $label_filter==1 ? $filter->label.': ' : '';
     $filter->html = '';
     // *** Create the form field(s) used for filtering
     switch ($display_filter_as) {
         case 0:
         case 2:
         case 6:
             // 0: Select (single value selectable), 2: Dual select (value range), 6: Multi Select (multiple values selectable)
             $options = array();
             // MULTI-select does not has an internal label a drop-down list option
             if ($display_filter_as != 6) {
                 $first_option_txt = $label_filter == 2 ? $filter->label : JText::_('FLEXI_ANY');
                 $options[] = JHTML::_('select.option', '', '- ' . $first_option_txt . ' -');
             }
             // Make use of select2 lib
             flexicontent_html::loadFramework('select2');
             $classes = " use_select2_lib";
             $extra_param = '';
             // MULTI-select: special label and prompts
             if ($display_filter_as == 6) {
                 $classes .= ' fc_label_internal fc_prompt_internal';
                 // Add field's LABEL internally or click to select PROMPT (via js)
                 $_inner_lb = $label_filter == 2 ? $filter->label : JText::_('FLEXI_CLICK_TO_LIST');
                 // Add type to filter PROMPT (via js)
                 $extra_param = ' data-fc_label_text="' . flexicontent_html::escapeJsText($_inner_lb, 's') . '"';
                 $extra_param .= ' fc_prompt_text="' . flexicontent_html::escapeJsText(JText::_('FLEXI_TYPE_TO_FILTER'), 's') . '"';
             }
             // Create HTML tag attributes
             $attribs_str = ' class="fc_field_filter' . $classes . '" ' . $extra_param;
             $attribs_str .= $display_filter_as == 6 ? ' multiple="multiple" size="20" ' : '';
             //$attribs_str .= ($display_filter_as==0 || $display_filter_as==6) ? ' onchange="document.getElementById(\''.$formName.'\').submit();"' : '';
             foreach ($results as $result) {
                 if (!strlen($result->value)) {
                     continue;
                 }
                 $options[] = JHTML::_('select.option', $result->value, $result->text, 'value', 'text', $disabled = $faceted_filter == 2 && !$result->found);
             }
             if ($display_filter_as == 6 && $combine_tip) {
                 $filter->html .= ' <span class="fc_filter_tip_inline">' . JText::_(!$require_all ? 'FLEXI_ANY_OF' : 'FLEXI_ALL_OF') . '</span> ';
             }
             if ($display_filter_as == 0 || $display_filter_as == 6) {
                 $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname . '[]', $attribs_str, 'value', 'text', $value, $filter_ffid);
             } else {
                 $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname . '[1]', $attribs_str, 'value', 'text', @$value[1], $filter_ffid . '1');
                 $filter->html .= '<span class="fc_range"></span>';
                 $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname . '[2]', $attribs_str, 'value', 'text', @$value[2], $filter_ffid . '2');
             }
             break;
         case 1:
         case 3:
             // (TODO: autocomplete) ... 1: Text input, 3: Dual text input (value range), both of these can be JS date calendars
             $_inner_lb = $label_filter == 2 ? $filter->label : JText::_($isdate ? 'FLEXI_CLICK_CALENDAR' : 'FLEXI_TYPE_TO_LIST');
             $_inner_lb = flexicontent_html::escapeJsText($_inner_lb, 's');
             $attribs_str = ' class="fc_field_filter fc_label_internal fc_iscalendar" data-fc_label_text="' . $_inner_lb . '"';
             $attribs_arr = array('class' => 'fc_field_filter fc_label_internal fc_iscalendar', 'data-fc_label_text' => $_inner_lb);
             if ($display_filter_as == 1) {
                 if ($isdate) {
                     $filter->html .= FlexicontentFields::createCalendarField($value, $allowtime = 0, $filter_ffname, $filter_ffid, $attribs_arr);
                 } else {
                     $filter->html .= '<input id="' . $filter_ffid . '" name="' . $filter_ffname . '" ' . $attribs_str . ' type="text" size="' . $size . '" value="' . @$value . '" />';
                 }
             } else {
                 if ($isdate) {
                     $filter->html .= '<span class="fc_filter_element">';
                     $filter->html .= FlexicontentFields::createCalendarField(@$value[1], $allowtime = 0, $filter_ffname . '[1]', $filter_ffid . '1', $attribs_arr);
                     $filter->html .= '</span>';
                     $filter->html .= '<span class="fc_range"></span>';
                     $filter->html .= '<span class="fc_filter_element">';
                     $filter->html .= FlexicontentFields::createCalendarField(@$value[2], $allowtime = 0, $filter_ffname . '[2]', $filter_ffid . '2', $attribs_arr);
                     $filter->html .= '</span>';
                 } else {
                     $size = (int) ($size / 2);
                     $filter->html .= '<span class="fc_filter_element">';
                     $filter->html .= '<input name="' . $filter_ffname . '[1]" ' . $attribs_str . ' type="text" size="' . $size . '" value="' . @$value[1] . '" />';
                     $filter->html .= '</span>';
                     $filter->html .= '<span class="fc_range"></span>';
                     $filter->html .= '<span class="fc_filter_element">';
                     $filter->html .= '<input name="' . $filter_ffname . '[2]" ' . $attribs_str . ' type="text" size="' . $size . '" value="' . @$value[2] . '" />' . "\n";
                     $filter->html .= '</span>';
                 }
             }
             break;
         case 4:
         case 5:
             // 4: radio (single value selectable), 5: checkbox (multiple values selectable)
             $lf_min = 10;
             // add parameter for this ?
             $add_lf = count($results) >= $lf_min;
             if ($add_lf) {
                 flexicontent_html::loadFramework('mCSB');
             }
             $clear_values = 0;
             $value_style = $clear_values ? 'float:left; clear:both;' : '';
             $i = 0;
             $checked = $display_filter_as == 5 ? !count($value) || !strlen(reset($value)) : !strlen($value);
             $checked_attr = $checked ? 'checked="checked"' : '';
             $checked_class = $checked ? 'fc_highlight' : '';
             $checked_class_li = $checked ? ' fc_checkradio_checked' : '';
             $filter->html .= '<span class="fc_checkradio_group_wrapper fc_add_scroller' . ($add_lf ? ' fc_list_filter_wrapper' : '') . '">';
             $filter->html .= '<ul class="fc_field_filter fc_checkradio_group' . ($add_lf ? ' fc_list_filter' : '') . '">';
             $filter->html .= '<li class="fc_checkradio_option fc_checkradio_special' . $checked_class_li . '" style="' . $value_style . '">';
             $filter->html .= $label_filter == 2 ? ' <span class="fc_filter_label_inline">' . $filter->label . '</span> ' : '';
             if ($display_filter_as == 4) {
                 $filter->html .= ' <input href="javascript:;" onchange="fc_toggleClassGrp(this, \'fc_highlight\', 1);" ';
                 $filter->html .= '  id="' . $filter_ffid . $i . '" type="radio" name="' . $filter_ffname . '" ';
                 $filter->html .= '  value="" ' . $checked_attr . ' class="fc_checkradio" />';
             } else {
                 $filter->html .= ' <input href="javascript:;" onchange="fc_toggleClass(this, \'fc_highlight\', 1);" ';
                 $filter->html .= '  id="' . $filter_ffid . $i . '" type="checkbox" name="' . $filter_ffname . '[' . $i . ']" ';
                 $filter->html .= '  value="" ' . $checked_attr . ' class="fc_checkradio" />';
             }
             $filter->html .= '<label class="hasTip ' . $checked_class . '" for="' . $filter_ffid . $i . '" ' . ' title="::' . JText::_('FLEXI_REMOVE_ALL') . '"' . ($checked ? ' style="display:none!important;" ' : 'style="background:none!important; padding-left:0px!important;"') . '>' . '<span class="fc_delall_filters"></span>';
             $filter->html .= '</label> ' . ($combine_tip ? ' <span class="fc_filter_tip_inline">' . JText::_(!$require_all ? 'FLEXI_ANY_OF' : 'FLEXI_ALL_OF') . '</span> ' : '') . ' </li>';
             $i++;
             foreach ($results as $result) {
                 if (!strlen($result->value)) {
                     continue;
                 }
                 $checked = $display_filter_as == 5 ? in_array($result->value, $value) : $result->value == $value;
                 $checked_attr = $checked ? ' checked=checked ' : '';
                 $disable_attr = $faceted_filter == 2 && !$result->found ? ' disabled=disabled ' : '';
                 $checked_class = $checked ? 'fc_highlight' : '';
                 $checked_class .= $faceted_filter == 2 && !$result->found ? ' fcdisabled ' : '';
                 $checked_class_li = $checked ? ' fc_checkradio_checked' : '';
                 $filter->html .= '<li class="fc_checkradio_option' . $checked_class_li . '" style="' . $value_style . '">';
                 if ($display_filter_as == 4) {
                     $filter->html .= ' <input href="javascript:;" onchange="fc_toggleClassGrp(this, \'fc_highlight\');" ';
                     $filter->html .= '  id="' . $filter_ffid . $i . '" type="radio" name="' . $filter_ffname . '" ';
                     $filter->html .= '  value="' . $result->value . '" ' . $checked_attr . $disable_attr . ' class="fc_checkradio" />';
                 } else {
                     $filter->html .= ' <input href="javascript:;" onchange="fc_toggleClass(this, \'fc_highlight\');" ';
                     $filter->html .= '  id="' . $filter_ffid . $i . '" type="checkbox" name="' . $filter_ffname . '[' . $i . ']" ';
                     $filter->html .= '  value="' . $result->value . '" ' . $checked_attr . $disable_attr . ' class="fc_checkradio" />';
                 }
                 $filter->html .= '<label class="' . $checked_class . '" for="' . $filter_ffid . $i . '">';
                 $filter->html .= $result->text;
                 $filter->html .= '</label>';
                 $filter->html .= '</li>';
                 $i++;
             }
             $filter->html .= '</ul>';
             $filter->html .= '</span>';
             break;
     }
     if ($print_logging_info) {
         $current_filter_creation = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
         $flt_active_count = isset($filters_where) ? count($filters_where) : 0;
         $faceted_str = array(0 => 'non-FACETED ', 1 => 'FACETED: current view &nbsp; (cacheable) ', 2 => 'FACETED: current filters:' . " (" . $flt_active_count . ' active) ');
         $fc_run_times['create_filter'][$filter->name] = $current_filter_creation;
         if (isset($fc_run_times['_create_filter_init'])) {
             $fc_run_times['create_filter'][$filter->name] -= $fc_run_times['_create_filter_init'];
             $fc_run_times['create_filter_init'] = $fc_run_times['_create_filter_init'];
             unset($fc_run_times['_create_filter_init']);
         }
         $fc_run_times['create_filter_type'][$filter->name] = $faceted_str[$faceted_filter];
     }
     //$filter_display_typestr = array(0=>'Single Select', 1=>'Single Text', 2=>'Range Dual Select', 3=>'Range Dual Text', 4=>'Radio Buttons', 5=>'Checkbox Buttons');
     //echo "FIELD name: <b>". $filter->name ."</b> Field Type: <b>". $filter->field_type."</b> Filter Type: <b>". $filter_display_typestr[$display_filter_as] ."</b> (".$display_filter_as.") ".sprintf(" %.2f s",$current_filter_creation/1000000)." <br/>";
 }
Esempio n. 30
0
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
if (FLEXI_J16GE) {
    jimport('joomla.html.html');
    jimport('joomla.form.formfield');
    jimport('joomla.form.helper');
    JFormHelper::loadFieldClass('list');
} else {
    require_once JPATH_ROOT . DS . 'libraries' . DS . 'joomla' . DS . 'html' . DS . 'html' . DS . 'select.php';
}
// Load the helper classes
require_once JPATH_ROOT . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.helper.php';
FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
flexicontent_html::loadFramework('jQuery');
flexicontent_html::loadFramework('select2');
/**
 * Renders a author element
 *
 * @package 	Joomla
 * @subpackage	FLEXIcontent
 * @since		1.0
 */
class JElementIlayoutlist extends JElement
{
    /**
     * Element name
     * @access	protected
     * @var		string
     * @since	1.5
     */