Beispiel #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);
	}
 function save($key = NULL, $urlVar = NULL)
 {
     parent::save();
     if (JRequest::getVar('fc_doajax_submit')) {
         JFactory::getApplication()->enqueueMessage(JText::_('FLEXI_ITEM_SAVED'), 'message');
         echo flexicontent_html::get_system_messages_html();
         exit;
         // Ajax submit, do not rerender the view
     }
 }
Beispiel #3
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);
 }
Beispiel #4
0
 function add_css_js()
 {
     require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.helper.php';
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadJQuery();
     $document = JFactory::getDocument();
     $js = "\n\t\t\tvar sorttable_fcfield_lists = '';\n\t\t\t\n\t\t\t/* unused to be removed */\n\t\t\tfunction fcfield_add2list(list_tagid, selector){\n\t\t\t\tvar list = jQuery('#'+list_tagid);\n\t\t\t\tvar sep = list.val().trim() ? ', ' : '';\n\t\t\t\tval = list.val() +  sep + jQuery(selector).val();\n\t\t\t\tlist.val(val);\n\t\t\t}\n\t\t\t\n\t\t\tfunction fcfield_del_sortable_element(obj){\n\t\t\t\tvar element = jQuery(obj).parent();\n\t\t\t\tvar parent_element = jQuery(element.parent());\n\t\t\t\telement.remove();\n\t\t\t\tstoreordering( parent_element );\n\t\t\t}\n\t\t\t\n\t\t\tfunction fcfield_add_sortable_element(selector){\n\t\t\t\tvar selobj = jQuery(selector);\n\t\t\t\tvar tagid  = selobj.attr('id').replace('_selector','');\n\t\t\t\tvar container = 'sortable-' + tagid;\n\t\t\t\t\n\t\t\t\tvar val = selobj.val();\n\t\t\t\tif (!val) return;\n\t\t\t\tvar lbl = selobj.find('option:selected').text();\n\t\t\t\tjQuery('#'+container).append('<li id=\"field_'+val+'\" class=\"fields delfield\">'+lbl+\n\t\t\t\t'<a title=\"" . JText::_('FLEXI_REMOVE') . "\" align=\"right\" onclick=\"javascript:fcfield_del_sortable_element(this);\" class=\"deletetag\" href=\"javascript:;\"></a>'+\n\t\t\t\t'</li>');\n\t\t\t\t\n\t\t\t\tvar field_list = jQuery('#'+tagid).val();\n\t\t\t\tfield_list += field_list ? ','+val : val;\n\t\t\t\tjQuery('#'+tagid).val(field_list);\n\t\t\t\tselobj.prop('selectedIndex',0);\n\t\t\t}\n\t\t\t\n\t\t\tfunction storeordering(parent_element) {\n\t\t\t\thidden_id = '#'+jQuery.trim(parent_element.attr('id').replace('sortable-',''));\n\t\t\t\tfields = new Array();\n\t\t\t\ti = 0;\n\t\t\t\tparent_element.children('li').each(function(){\n\t\t\t\t\tfields[i++] = jQuery(this).attr('id').replace('field_', '');\n\t\t\t\t});\n\t\t\t\tjQuery(hidden_id).val(fields.join(','))\n\t\t\t}\n\t\t\t\n\t\t\tjQuery(document).ready(function() {\n\t\t\t\n\t\t\t\tjQuery( sorttable_fcfield_lists ).each(function(index, value) {\n\t\t\t\t\tstoreordering(jQuery(this));\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\tjQuery( sorttable_fcfield_lists ).sortable({\n\t\t\t\t\tconnectWith: sorttable_fcfield_lists,\n\t\t\t\t\tupdate: function(event, ui) {\n\t\t\t\t\t\tif(ui.sender) {\n\t\t\t\t\t\t\tstoreordering(jQuery(ui.sender));\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tstoreordering(jQuery(ui.item).parent());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t\n\t\t\t});\n\t\t";
     if ($js) {
         $document->addScriptDeclaration($js);
     }
 }
 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);
 }
Beispiel #6
0
		<?php 
        }
        ?>
		<!-- EOF Print handling -->
		
	<?php 
    } else {
        ?>
	
		<?php 
        $pdfbutton = flexicontent_html::pdfbutton($item, $this->params);
        $mailbutton = flexicontent_html::mailbutton(FLEXI_ITEMVIEW, $this->params, $item->categoryslug, $item->slug, 0, $item);
        $printbutton = flexicontent_html::printbutton($this->print_link, $this->params);
        $editbutton = flexicontent_html::editbutton($item, $this->params);
        $statebutton = flexicontent_html::statebutton($item, $this->params);
        $approvalbutton = flexicontent_html::approvalbutton($item, $this->params);
        ?>
		
		<?php 
        if ($pdfbutton || $mailbutton || $printbutton || $editbutton || $statebutton || $approvalbutton) {
            ?>
		<!-- BOF buttons -->
		<div class="buttons">
			<?php 
            echo $pdfbutton;
            ?>
			<?php 
            echo $mailbutton;
            ?>
			<?php 
            echo $printbutton;
 $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
Beispiel #8
0
	$legend_tip .= $use_search ? '&lt;b&gt;'.JText::_('FLEXI_TEXT_SEARCH').'&lt;/b&gt;&lt;br/&gt;'.JText::_('FLEXI_TEXT_SEARCH_INFO') : '';
	$legend_tip .= ($use_search || $use_filters) ? '&lt;br/&gt;&lt;br/&gt;' : '';
	$legend_tip .= $use_filters ? '&lt;b&gt;'.JText::_('FLEXI_FIELD_FILTERS').'&lt;/b&gt;&lt;br/&gt;'.JText::_('FLEXI_FIELD_FILTERS_INFO') : '';
} else if ($filter_instructions == 2) {
	$legend_inline ='';
	$legend_inline .= $use_search ? '<strong>'.JText::_('FLEXI_TEXT_SEARCH').'</strong><br/>'.JText::_('FLEXI_TEXT_SEARCH_INFO') : '';
	$legend_inline .= ($use_search || $use_filters) ? '<br/><br/>' : '';
	$legend_inline .= $use_filters ? '<strong>'.JText::_('FLEXI_FIELD_FILTERS').'</strong><br/>'.JText::_('FLEXI_FIELD_FILTERS_INFO') : '';
}

?>

<?php if ( $use_search || $use_filters ) : /* BOF search and filters block */ ?>

	<?php
	$searchphrase_selector = flexicontent_html::searchphrase_selector($params, $form_name);
	?>

<div id="<?php echo $form_id; ?>_filter_box" class="fc_filter_box floattext">
	
	<fieldset class="fc_filter_set">
		
		<?php if ($filter_instructions == 1) : ?>
		<legend>
			<span class="fc_legend_text" >
				<span class="">Поиск препарата</span>
			</span>
		</legend>
		<?php endif; ?>
		
		<?php if ($filter_instructions == 2) :?>
 function onBeforeSaveField(&$field, &$post, &$file, &$item)
 {
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     $use_ingroup = $field->parameters->get('use_ingroup', 0);
     if (!is_array($post) && !strlen($post) && !$use_ingroup) {
         return;
     }
     $is_importcsv = JRequest::getVar('task') == 'importcsv';
     // Server side validation
     $validation = $field->parameters->get('validation', 2);
     $use_html = $field->parameters->get('use_html', 0);
     $maxlength = (int) $field->parameters->get('maxlength', 0);
     $maxlength = $use_html ? 0 : $maxlength;
     // Make sure posted data is an array
     $post = !is_array($post) ? array($post) : $post;
     // Reformat the posted data
     $newpost = array();
     $new = 0;
     foreach ($post as $n => $v) {
         // support for basic CSV import / export
         if ($is_importcsv && !is_array($v)) {
             if (@unserialize($v) !== false || $v === 'b:0;') {
                 // support for exported serialized data)
                 $v = unserialize($v);
             } else {
                 $v = array('title' => $v, 'text' => '');
             }
         }
         // **************************************************************
         // Validate data, skipping values that are empty after validation
         // **************************************************************
         $title = flexicontent_html::dataFilter($v['title'], $maxlength, 'HTML', 0);
         // Skip empty value, but if in group increment the value position
         if (!strlen($title)) {
             if ($use_ingroup) {
                 $newpost[$new++] = null;
             }
             continue;
         }
         $newpost[$new] = array();
         $newpost[$new]['title'] = $title;
         $newpost[$new]['text'] = flexicontent_html::dataFilter($v['text'], $maxlength, $validation, 0);
         $new++;
     }
     $post = $newpost;
     // Serialize multi-property data before storing them into the DB,
     // null indicates to increment valueorder without adding a value
     foreach ($post as $i => $v) {
         if ($v !== null) {
             $post[$i] = serialize($v);
         }
     }
     /*if ($use_ingroup) {
     			$app = JFactory::getApplication();
     			$app->enqueueMessage( print_r($post, true), 'warning');
     		}*/
 }
Beispiel #10
0
 /**
  * Method to decide which item layout to use
  *
  * @access	public
  * @param	int item identifier
  */
 function decideLayout(&$params)
 {
     // *********************************************************************************
     // Get category layout from configuration if not already set (e.g. via HTTP Request)
     // *********************************************************************************
     //echo "decideLayout: ". $this->_clayout ."<br/>";
     $clayout = $this->_clayout;
     if (!$clayout) {
         // Decide to use mobile or normal category template layout
         $useMobile = $params->get('use_mobile_layouts', 0);
         if ($useMobile) {
             $force_desktop_layout = $params->get('force_desktop_layout', 0);
             $mobileDetector = flexicontent_html::getMobileDetector();
             $isMobile = $mobileDetector->isMobile();
             $isTablet = $mobileDetector->isTablet();
             $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile;
         }
         $desktop_clayout = $params->get('clayout', 'blog');
         $clayout = !$useMobile ? $desktop_clayout : $params->get('clayout_mobile', $desktop_clayout);
     }
     // Get cached template data, without loading language file, (this will be done at the view)
     $themes = flexicontent_tmpl::getTemplates(null);
     // *********************************
     // Verify the category layout exists
     // *********************************
     if (!isset($themes->category->{$clayout})) {
         $cat_default_layout = 'blog';
         // Layout default
         $fixed_clayout = isset($themes->category->{$cat_default_layout}) ? $cat_default_layout : 'default';
         JFactory::getApplication()->enqueueMessage("<small>Current category Layout (template) is '{$clayout}' does not exist<br/>- Please correct this in the URL or in Content Type configuration.<br/>- Using Template Layout: '{$fixed_clayout}'</small>", 'notice');
         $clayout = $fixed_clayout;
         FLEXIUtilities::loadTemplateLanguageFile($clayout);
         // Manually load Template-Specific language file of back fall clayout
     }
     // *****************************************************************************************
     // Finally set the clayout (template name) into model / category's parameters / HTTP Request
     // *****************************************************************************************
     $this->setCatLayout($clayout);
     $params->set('clayout', $clayout);
     JRequest::setVar('clayout', $clayout);
 }
Beispiel #11
0
 function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     // execute the code only if the field type match the plugin type
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     // Get isMobile / isTablet Flags
     static $isMobile = null;
     static $isTablet = null;
     static $useMobile = null;
     if ($useMobile === null) {
         $cparams = JComponentHelper::getParams('com_flexicontent');
         $force_desktop_layout = $cparams->get('force_desktop_layout', 0);
         //$start_microtime = microtime(true);
         $mobileDetector = flexicontent_html::getMobileDetector();
         $isMobile = $mobileDetector->isMobile();
         $isTablet = $mobileDetector->isTablet();
         $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile;
         //$time_passed = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
         //printf('<br/>-- [Detect Mobile: %.3f s] ', $time_passed/1000000);
     }
     $field->label = JText::_($field->label);
     // some parameter shortcuts
     $target = $field->parameters->get('targetblank', 0);
     $target_param = $target ? ' target="_blank"' : '';
     $display_hits = $field->parameters->get('display_hits', 0);
     $add_hits_img = $display_hits == 1 || $display_hits == 3;
     $add_hits_txt = $display_hits == 2 || $display_hits == 3 || $isMobile;
     $rel_nofollow = $field->parameters->get('add_rel_nofollow', 0) ? ' rel="nofollow"' : '';
     // This is field 's MAIN value property
     $link_usage = $field->parameters->get('link_usage', 0);
     $default_link = $link_usage == 2 ? $field->parameters->get('default_value_link', '') : '';
     // Optional value properties
     $usetitle = $field->parameters->get('use_title', 0);
     $title_usage = $field->parameters->get('title_usage', 0);
     $default_title = $title_usage == 2 ? JText::_($field->parameters->get('default_value_title', '')) : '';
     // Get field values
     $values = $values ? $values : $field->value;
     // DO NOT terminate yet if value is empty since a default value on empty may have been defined
     // Handle default value loading, instead of empty value
     if (empty($values) && !strlen($default_link)) {
         $field->{$prop} = '';
         return;
     } else {
         if (empty($values) && strlen($default_link)) {
             $values = array();
             $values[0]['link'] = JText::_($default_link);
             $values[0]['title'] = JText::_($default_title);
             $values[0]['hits'] = 0;
             $values[0] = serialize($values[0]);
         }
     }
     // Value handling parameters
     $multiple = $field->parameters->get('allow_multiple', 1);
     // Prefix - Suffix - Separator parameters, replacing other field values if found
     $remove_space = $field->parameters->get('remove_space', 0);
     $pretext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('pretext', ''), 'pretext');
     $posttext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('posttext', ''), 'posttext');
     $separatorf = $field->parameters->get('separatorf', 1);
     $opentag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('opentag', ''), 'opentag');
     $closetag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('closetag', ''), 'closetag');
     if ($pretext) {
         $pretext = $remove_space ? $pretext : $pretext . ' ';
     }
     if ($posttext) {
         $posttext = $remove_space ? $posttext : ' ' . $posttext;
     }
     switch ($separatorf) {
         case 0:
             $separatorf = '&nbsp;';
             break;
         case 1:
             $separatorf = '<br />';
             break;
         case 2:
             $separatorf = '&nbsp;|&nbsp;';
             break;
         case 3:
             $separatorf = ',&nbsp;';
             break;
         case 4:
             $separatorf = $closetag . $opentag;
             break;
         case 5:
             $separatorf = '';
             break;
         default:
             $separatorf = '&nbsp;';
             break;
     }
     // Optimization, do some stuff outside the loop
     static $hits_icon = null;
     if ($hits_icon === null && ($display_hits == 1 || $display_hits == 3)) {
         $_attribs = $display_hits == 1 ? 'class="hasTip" title=":: %s ' . JText::_('FLEXI_HITS', true) . '"' : '';
         $hits_icon = FLEXI_J16GE ? JHTML::image('components/com_flexicontent/assets/images/' . 'user.png', JText::_('FLEXI_HITS'), $_attribs) : JHTML::_('image.site', 'user.png', 'components/com_flexicontent/assets/images/', NULL, NULL, JText::_('FLEXI_HITS'), $_attribs);
     }
     // needed for backend display
     //if ($display_hits)
     //	$isAdmin = JFactory::getApplication()->isAdmin();
     // initialise property
     $field->{$prop} = array();
     $n = 0;
     foreach ($values as $value) {
         if (!strlen($value)) {
             continue;
         }
         // Compatibility for old unserialized values
         if (@unserialize($value) !== false || $value === 'b:0;') {
             $value = unserialize($value);
         } else {
             $value = array('link' => $value, 'title' => '', 'hits' => 0);
         }
         if (empty($value['link'])) {
             continue;
         }
         // no link ...
         // If not using property or property is empty, then use default property value
         // NOTE: default property values have been cleared, if (propertyname_usage != 2)
         $title = $usetitle && @$value['title'] ? $value['title'] : $default_title;
         $hits = (int) @$value['hits'];
         $link_params = $title ? ' title="' . $title . '"' : '';
         $link_params .= $target_param;
         $link_params .= $rel_nofollow;
         if ($field->parameters->get('use_direct_link', 0)) {
             // Direct access to the web-link, hits counting not possible
             $href = $value['link'];
         } else {
             // Indirect access to the web-link, via calling FLEXIcontent component, thus counting hits too
             $href = JRoute::_('index.php?option=com_flexicontent&fid=' . $field->id . '&cid=' . $field->item_id . '&ord=' . ($n + 1) . '&task=weblink');
         }
         // Create indirect link to web-link address with custom displayed text
         $linktext = $title ? $title : $this->cleanurl($value['link']);
         $field->{$prop}[$n] = $pretext . '<a href="' . $href . '" ' . $link_params . '>' . $linktext . '</a>' . $posttext;
         // HITS: either as icon or as inline text or both
         $hits_html = '';
         if ($display_hits && $hits) {
             $hits_html = '<span class="fcweblink_hits">';
             if ($add_hits_img && @$hits_icon) {
                 $hits_html .= sprintf($hits_icon, $hits);
             }
             if ($add_hits_txt) {
                 $hits_html .= '(' . $hits . '&nbsp;' . JTEXT::_('FLEXI_HITS') . ')';
             }
             $hits_html .= '</span>';
             if ($prop == 'display_hitsonly') {
                 $field->{$prop}[$n] = $hits_html;
             } else {
                 $field->{$prop}[$n] .= ' ' . $hits_html;
             }
         }
         $n++;
         if (!$multiple) {
             break;
         }
         // multiple values disabled, break out of the loop, not adding further values even if the exist
     }
     // Apply seperator and open/close tags
     if (count($field->{$prop})) {
         $field->{$prop} = implode($separatorf, $field->{$prop});
         $field->{$prop} = $opentag . $field->{$prop} . $closetag;
     } else {
         $field->{$prop} = '';
     }
 }
 function onBeforeSaveField(&$field, &$post, &$file, &$item)
 {
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     $use_ingroup = $field->parameters->get('use_ingroup', 0);
     if (!is_array($post) && !strlen($post) && !$use_ingroup) {
         return;
     }
     // Make sure posted data is an array
     //echo "<pre>"; print_r($post); exit;
     $post = !is_array($post) ? array($post) : $post;
     //echo "<pre>"; print_r($post);
     // Get configuration
     $inputmode = (int) $field->parameters->get('inputmode', 1);
     $is_importcsv = JRequest::getVar('task') == 'importcsv';
     $import_docs_folder = JRequest::getVar('import_docs_folder');
     $iform_allowdel = $field->parameters->get('iform_allowdel', 1);
     $iform_title = $inputmode == 1 ? 0 : $field->parameters->get('iform_title', 1);
     $iform_desc = $inputmode == 1 ? 0 : $field->parameters->get('iform_desc', 1);
     $iform_lang = $inputmode == 1 ? 0 : $field->parameters->get('iform_lang', 0);
     $iform_dir = $inputmode == 1 ? 0 : $field->parameters->get('iform_dir', 0);
     // Execute once
     static $initialized = null;
     static $srcpath_original = '';
     if (!$initialized) {
         $initialized = 1;
         jimport('joomla.filesystem.folder');
         jimport('joomla.filesystem.path');
         $srcpath_original = JPath::clean(JPATH_SITE . DS . $import_docs_folder . DS);
     }
     $newpost = array();
     $new = 0;
     foreach ($post as $n => $v) {
         if (empty($v)) {
             if ($use_ingroup) {
                 // empty value for group
                 $newpost[$new] = '';
                 $new++;
             }
             continue;
         }
         // support for basic CSV import / export
         if ($is_importcsv) {
             if (!is_numeric($v)) {
                 $filename = basename($v);
                 $sub_folder = dirname($v);
                 $sub_folder = $sub_folder && $sub_folder != '.' ? DS . $sub_folder : '';
                 $fman = new FlexicontentControllerFilemanager();
                 $Fobj = new stdClass();
                 $Fobj->return_url = null;
                 $Fobj->file_dir_path = DS . $import_docs_folder . $sub_folder;
                 $Fobj->file_filter_re = preg_quote($filename);
                 $Fobj->secure = 0;
                 $Fobj->keep = 1;
                 $file_ids = $fman->addlocal($Fobj);
                 $v = !empty($file_ids) ? reset($file_ids) : false;
                 // Get fist element
                 //$_filetitle = key($file_ids);  this is the cleaned up filename, currently not needed
             }
         } else {
             $file_id = isset($v['file-id']) ? (int) $v['file-id'] : $v;
             $file_id = is_numeric($file_id) ? (int) $file_id : 0;
             // if $v is not an array
             $err_code = $_FILES["custom"]["error"][$field->name][$n]['file-data'];
             $new_file = $err_code == 0;
             if ($err_code && $err_code != UPLOAD_ERR_NO_FILE) {
                 $err_msg = array(UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini', UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded', UPLOAD_ERR_NO_FILE => 'No file was uploaded', UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder', UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk', UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload');
                 JFactory::getApplication()->enqueueMessage("FILE FIELD: " . $err_msg[$err_code], 'warning');
                 continue;
             }
             // validate data or empty/set default values
             $v['file-del'] = !$iform_allowdel ? 0 : (int) @$v['file-del'];
             $v['file-title'] = !$iform_title ? '' : flexicontent_html::dataFilter($v['file-title'], 1000, 'STRING', 0);
             $v['file-desc'] = !$iform_desc ? '' : flexicontent_html::dataFilter($v['file-desc'], 10000, 'STRING', 0);
             $v['file-lang'] = !$iform_lang ? '' : flexicontent_html::dataFilter($v['file-lang'], 9, 'STRING', 0);
             $v['secure'] = !$iform_dir ? 0 : ((int) $v['secure'] ? 1 : 0);
             // UPDATE existing file
             if (!$new_file && $file_id) {
                 $dbdata = array();
                 $dbdata['id'] = $file_id;
                 if ($iform_title) {
                     $dbdata['altname'] = $v['file-title'];
                 }
                 if ($iform_desc) {
                     $dbdata['description'] = $v['file-desc'];
                 }
                 if ($iform_lang) {
                     $dbdata['language'] = $v['file-lang'];
                 }
                 // !! Do not change folder for existing files
                 //if ($iform_dir) {  $dbdata['secure'] = $v['secure'];
                 // Load file data from DB
                 $row = JTable::getInstance('flexicontent_files', '');
                 $row->load($file_id);
                 $_filename = $row->filename_original ? $row->filename_original : $row->filename;
                 $dbdata['secure'] = $row->secure ? 1 : 0;
                 // !! Do not change media/secure -folder- for existing files
                 // Security concern, check file is assigned to current item
                 $isAssigned = $this->checkFileAssignment($field, $file_id, $item);
                 if ($v['file-del']) {
                     if (!$isAssigned) {
                         //JFactory::getApplication()->enqueueMessage("FILE FIELD: refusing to delete file: '".$_filename."', that is not assigned to current item", 'warning' );
                     } else {
                         //JFactory::getApplication()->enqueueMessage("FILE FIELD: refusing to update file properties of a file: '".$_filename."', that is not assigned to current item", 'warning' );
                     }
                 }
                 // Delete existing file if so requested
                 if ($v['file-del']) {
                     $canDelete = $this->canDeleteFile($field, $file_id, $item);
                     if ($isAssigned && $canDelete) {
                         $fm = new FlexicontentModelFilemanager();
                         $fm->delete(array($file_id));
                     }
                     continue;
                     // Skip file since unloading / removal was requested
                 }
                 // Set the changed data into the object
                 foreach ($dbdata as $index => $data) {
                     $row->{$index} = $data;
                 }
                 // Update DB data of the file
                 if (!$row->check() || !$row->store()) {
                     JFactory::getApplication()->enqueueMessage("FILE FIELD: " . JFactory::getDBO()->getErrorMsg(), 'warning');
                     continue;
                 }
                 // Set file id as value of the field
                 $v = $file_id;
             } else {
                 if ($new_file) {
                     // new file was uploaded, but also handle previous selected file ...
                     if ($file_id) {
                         // Security concern, check file is assigned to current item
                         $isAssigned = $this->checkFileAssignment($field, $file_id, $item);
                         if (!$isAssigned) {
                             /*$row = JTable::getInstance('flexicontent_files', '');
                             		$row->load( $file_id );
                             		$_filename = $row->filename_original ? $row->filename_original : $row->filename;
                             		JFactory::getApplication()->enqueueMessage("FILE FIELD: refusing to delete file: '".$_filename."', that is not assigned to current item", 'warning' );*/
                         } else {
                             if ($this->canDeleteFile($field, $file_id, $item)) {
                                 $fm = new FlexicontentModelFilemanager();
                                 $fm->delete(array($file_id));
                             }
                         }
                     }
                     // Skip file if unloading / removal was requested
                     if ($v['file-del']) {
                         continue;
                     }
                     $fman = new FlexicontentControllerFilemanager();
                     // Controller will do the data filter too
                     JRequest::setVar('return-url', null, 'post');
                     // needed !
                     JRequest::setVar('secure', $v['secure'], 'post');
                     JRequest::setVar('file-title', $v['file-title'], 'post');
                     JRequest::setVar('file-desc', $v['file-desc'], 'post');
                     JRequest::setVar('file-lang', $v['file-lang'], 'post');
                     // The dform field name of the <input type="file" ...
                     JRequest::setVar('file-ffname', 'custom', 'post');
                     JRequest::setVar('fname_level1', $field->name, 'post');
                     JRequest::setVar('fname_level2', $n, 'post');
                     JRequest::setVar('fname_level3', 'file-data', 'post');
                     $file_id = $fman->upload();
                     $v = !empty($file_id) ? $file_id : false;
                 } else {
                     // no existing file and no new file uploaded
                     $v = 0;
                 }
             }
         }
         if (!$use_ingroup) {
             // NOT inside field group, add it only if not empty reverse the file array, indexing it by file IDs, to add each file only once
             if (!empty($v) && is_numeric($v)) {
                 $newpost[(int) $v] = $new++;
             }
         } else {
             // Inside fieldgroup, allow same file multiple times
             $newpost[$new++] = (int) $v;
         }
     }
     // IF NOT inside field group, the file array was reversed (indexed by file IDs), so that the same file can be added once
     $post = !$use_ingroup ? array_flip($newpost) : $newpost;
 }
        echo $orderby_selector;
        ?>
</span>
			</span>
		<?php 
    }
    ?>
		
		<?php 
    if ($orderby_selector_2nd) {
        ?>
			<span class="fc_orderby_box <?php 
        echo $tooltip_class;
        ?>
" title="<?php 
        echo flexicontent_html::getToolTip('FLEXI_ORDERBY', 'FLEXI_ORDERBY_INFO', 1, 1);
        ?>
">
				<span class="fc_orderby_selector"><?php 
        echo $orderby_selector_2nd;
        ?>
</span>
			</span>
		<?php 
    }
    ?>
		
		<span class="fc_pages_counter">
			<span class="label"><?php 
    echo $this->pageNav->getPagesCounter();
    ?>
Beispiel #14
0
 /**
  * Creates the Entrypage
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     //initialise variables
     $app = JFactory::getApplication();
     $option = JRequest::getVar('option');
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     $document = JFactory::getDocument();
     $cparams = JComponentHelper::getParams('com_flexicontent');
     $print_logging_info = $cparams->get('print_logging_info');
     if ($print_logging_info) {
         global $fc_run_times;
     }
     JHTML::_('behavior.tooltip');
     //get vars
     $filter_order = $app->getUserStateFromRequest($option . '.types.filter_order', 'filter_order', 't.name', 'cmd');
     $filter_order_Dir = $app->getUserStateFromRequest($option . '.types.filter_order_Dir', 'filter_order_Dir', '', 'word');
     $filter_state = $app->getUserStateFromRequest($option . '.types.filter_state', 'filter_state', '*', 'word');
     $search = $app->getUserStateFromRequest($option . '.types.search', 'search', '', 'string');
     $search = FLEXI_J16GE ? $db->escape(trim(JString::strtolower($search))) : $db->getEscaped(trim(JString::strtolower($search)));
     //add css and submenu to document
     $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css');
     if (FLEXI_J30GE) {
         $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css');
     } else {
         if (FLEXI_J16GE) {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css');
         } else {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css');
         }
     }
     // Get User's Global Permissions
     $perms = FlexicontentHelperPerm::getPerm();
     // Create Submenu (and also check access to current view)
     FLEXISubmenu('CanTypes');
     // Create document/toolbar titles
     $doc_title = JText::_('FLEXI_TYPES');
     $site_title = $document->getTitle();
     JToolBarHelper::title($doc_title, 'types');
     $document->setTitle($doc_title . ' - ' . $site_title);
     // Create the toolbar
     $contrl = FLEXI_J16GE ? "types." : "";
     JToolBarHelper::custom($contrl . 'copy', 'copy.png', 'copy_f2.png', 'FLEXI_COPY');
     JToolBarHelper::divider();
     JToolBarHelper::spacer();
     JToolBarHelper::publishList($contrl . 'publish');
     JToolBarHelper::unpublishList($contrl . 'unpublish');
     JToolBarHelper::addNew($contrl . 'add');
     JToolBarHelper::editList($contrl . 'edit');
     //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove');
     // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag)
     $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE'));
     $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM');
     $btn_task = $contrl . 'remove';
     $extra_js = "";
     flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true);
     if ($perms->CanConfig) {
         JToolBarHelper::divider();
         JToolBarHelper::spacer();
         $session = JFactory::getSession();
         $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent');
         $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940;
         $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent');
         $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550;
         JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration');
     }
     // Get data from the model
     if ($print_logging_info) {
         $start_microtime = microtime(true);
     }
     if (FLEXI_J16GE) {
         $rows = $this->get('Items');
     } else {
         $rows = $this->get('Data');
     }
     if ($print_logging_info) {
         @($fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
     }
     // Create type's parameters
     foreach ($rows as $type) {
         $type->config = FLEXI_J16GE ? new JRegistry($type->config) : new JParameter($type->config);
     }
     // Create pagination object
     $pagination = $this->get('Pagination');
     $lists = array();
     //publish unpublished filter
     $lists['state'] = JHTML::_('grid.state', $filter_state);
     // search filter
     $lists['search'] = $search;
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     //assign data to template
     $this->assignRef('lists', $lists);
     $this->assignRef('rows', $rows);
     $this->assignRef('pagination', $pagination);
     parent::display($tpl);
 }
Beispiel #15
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);
 }
Beispiel #16
0
    /**
     * Method to select new state for many items
     * 
     * @since 1.5
     */
    function selectsearchflag()
    {
        $user = JFactory::getUser();
        $document = JFactory::getDocument();
        $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VHASH);
        $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VHASH);
        // Load jquery Framework
        flexicontent_html::loadJQuery();
        JHtml::_('bootstrap.framework');
        JHtml::_('bootstrap.tooltip');
        $btn_class = 'hasTooltip btn btn-small';
        $state['issearch'] = array('name' => 'FLEXI_TOGGLE_TEXT_SEARCHABLE', 'desc' => 'FLEXI_FIELD_CONTENT_LIST_TEXT_SEARCHABLE_DESC', 'icon' => 'search', 'btn_class' => 'btn-success', 'clear' => true);
        $state['isfilter'] = array('name' => 'FLEXI_TOGGLE_FILTERABLE', 'desc' => 'FLEXI_FIELD_CONTENT_LIST_FILTERABLE_DESC', 'icon' => 'filter', 'btn_class' => 'btn-success', 'clear' => true);
        $state['isadvsearch'] = array('name' => 'FLEXI_TOGGLE_ADV_TEXT_SEARCHABLE', 'desc' => 'FLEXI_FIELD_ADVANCED_TEXT_SEARCHABLE_DESC', 'icon' => 'search', 'btn_class' => 'btn-info', 'clear' => true);
        $state['isadvfilter'] = array('name' => 'FLEXI_TOGGLE_ADV_FILTERABLE', 'desc' => 'FLEXI_FIELD_ADVANCED_FILTERABLE_DESC', 'icon' => 'filter', 'btn_class' => 'btn-info', 'clear' => true);
        ?>
<div id="flexicontent" class="flexicontent" style="padding-top:5%;"><?php 
        foreach ($state as $shortname => $statedata) {
            $css = "width:216px; margin:0px 24px 12px 0px; text-align: left;";
            $link = JURI::base(true) . "/index.php?option=com_flexicontent&task=fields.toggleprop&propname=" . $shortname . "&" . (FLEXI_J30GE ? JSession::getFormToken() : JUtility::getToken()) . "=1";
            $icon = $statedata['icon'];
            if ($shortname == 'issearch') {
                echo '<br/><span class="label">' . JText::_('FLEXI_TOGGLE') . '</span> ' . JText::_('Content Lists') . '<br/>';
            } else {
                if ($shortname == 'isadvsearch') {
                    echo '<br/><span class="label">' . JText::_('FLEXI_TOGGLE') . '</span> ' . JText::_('Search View') . '<br/>';
                }
            }
            ?>
			<span style="<?php 
            echo $css;
            ?>
" class="<?php 
            echo $btn_class . ' ' . $statedata['btn_class'];
            ?>
" title="<?php 
            echo JText::_($statedata['desc']);
            ?>
" data-placement="right"
				onclick="window.parent.document.adminForm.propname.value='<?php 
            echo $shortname;
            ?>
'; window.parent.document.adminForm.boxchecked.value==0  ?  alert('<?php 
            echo JText::_('FLEXI_NO_ITEMS_SELECTED');
            ?>
')  :  window.parent.Joomla.submitbutton('fields.toggleprop')"
			>
				<span class="icon-<?php 
            echo $icon;
            ?>
"></span><?php 
            echo JText::_($statedata['name']);
            ?>
			</span>
			<?php 
            if (isset($statedata['clear'])) {
                echo '<div class="fcclear"></div>';
            }
        }
        ?>
</div><?php 
        return;
    }
 /**
  * Creates the RSS for the View
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     $db = JFactory::getDBO();
     $doc = JFactory::getDocument();
     $app = JFactory::getApplication();
     $params = $this->get('Params');
     $doc->link = JRoute::_('index.php?option=com_flexicontent&view=flexicontent&rootcat=' . (int) $params->get('rootcat', FLEXI_J16GE ? 1 : 0));
     JRequest::setVar('limit', $params->get('feed_limit'));
     // Force a specific limit, this will be moved to the model
     $cats = $this->get('Feed');
     //$feed_summary = $params->get('feed_summary', 0);
     $feed_summary_cut = $params->get('feed_summary_cut', 200);
     $feed_use_image = $params->get('feed_use_image', 1);
     $feed_image_source = $params->get('feed_image_source', '');
     $feed_link_image = $params->get('feed_link_image', 1);
     $feed_image_method = $params->get('feed_image_method', 1);
     $feed_image_width = $params->get('feed_image_width', 100);
     $feed_image_height = $params->get('feed_image_height', 80);
     // Retrieve default image for the image field
     if ($feed_use_image && $feed_image_source) {
         $query = 'SELECT attribs, name FROM #__flexicontent_fields WHERE id = ' . (int) $feed_image_source;
         $db->setQuery($query);
         $image_dbdata = $db->loadObject();
         //$image_dbdata->params = FLEXI_J16GE ? new JRegistry($image_dbdata->params) : new JParameter($image_dbdata->params);
         $img_size_map = array('l' => 'large', 'm' => 'medium', 's' => 'small', '' => '');
         $img_field_size = $img_size_map[$image_size];
         $img_field_name = $image_dbdata->name;
     }
     foreach ($cats as $cat) {
         // strip html from feed item title
         $title = $this->escape($cat->title);
         $title = html_entity_decode($title);
         // url link to article
         // & used instead of &amp; as this is converted by feed creator
         $link = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug));
         // strip html from feed item description text
         $description = $cat->description;
         //$feed_summary ? $cat->description : '';
         $description = flexicontent_html::striptagsandcut($description, $feed_summary_cut);
         if ($feed_use_image) {
             // feed image is enabled
             // Get some variables
             $joomla_image_path = $app->getCfg('image_path', FLEXI_J16GE ? '' : 'images' . DS . 'stories');
             $joomla_image_url = str_replace(DS, '/', $joomla_image_path);
             $joomla_image_path = $joomla_image_path ? $joomla_image_path . DS : '';
             $joomla_image_url = $joomla_image_url ? $joomla_image_url . '/' : '';
             // **************
             // CATEGORY IMAGE
             // **************
             // category image params
             $show_cat_image = $params->get('show_description_image', 0);
             // we use different name for variable
             $cat_image_source = $params->get('cat_image_source', 2);
             // 0: extract, 1: use param, 2: use both
             $cat_link_image = $params->get('cat_link_image', 1);
             $cat_image_method = $params->get('cat_image_method', 1);
             $cat_image_width = $params->get('cat_image_width', 80);
             $cat_image_height = $params->get('cat_image_height', 80);
             $cat =& $category;
             $thumb = "";
             if ($cat->id && $show_cat_image) {
                 $cat->image = FLEXI_J16GE ? $params->get('image') : $cat->image;
                 $thumb = "";
                 $cat->introtext =& $cat->description;
                 $cat->fulltext = "";
                 if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) {
                     $src = JURI::base(true) . "/" . $joomla_image_url . $cat->image;
                     $h = '&amp;h=' . $cat_image_height;
                     $w = '&amp;w=' . $cat_image_width;
                     $aoe = '&amp;aoe=1';
                     $q = '&amp;q=95';
                     $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
                     $ext = pathinfo($src, PATHINFO_EXTENSION);
                     $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                     $conf = $w . $h . $aoe . $q . $zc . $f;
                     $thumb = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
                 } else {
                     if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) {
                         $h = '&amp;h=' . $feed_image_height;
                         $w = '&amp;w=' . $feed_image_width;
                         $aoe = '&amp;aoe=1';
                         $q = '&amp;q=95';
                         $zc = $feed_image_method ? '&amp;zc=' . $feed_image_method : '';
                         $ext = pathinfo($src, PATHINFO_EXTENSION);
                         $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                         $conf = $w . $h . $aoe . $q . $zc . $f;
                         $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : '';
                         $src = $base_url . $src;
                         $thumb = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
                     }
                 }
             }
             if ($thumb) {
                 $description = "<a href='" . $link . "'><img src='" . $thumb . "' alt='" . $title . "' title='" . $title . "' align='left'/></a><p>" . $description . "</p>";
             }
         }
         //$author = $cat->created_by_alias ? $cat->created_by_alias : $cat->author;
         @($date = $cat->created ? date('r', strtotime($cat->created)) : '');
         // load individual item creator class
         $item = new JFeedItem();
         $item->title = $title . ' (' . (int) $cat->assigneditems . ')';
         $item->link = $link;
         $item->description = $description;
         $item->date = $date;
         //$item->author    = $author;
         //$item->category  = $this->escape( $category->title );
         // loads item info into rss array
         $doc->addItem($item);
     }
 }
Beispiel #18
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);
     }
 }
Beispiel #19
0
            echo $item->is_active_item ? 'fcitem_active' : '';
            ?>
" >
				<?php 
            if ($add_tooltips) {
                ?>
				<a href="<?php 
                echo $item->link;
                ?>
"
						class="fcitem_link <?php 
                echo $tooltip_class;
                ?>
"
						title="<?php 
                echo flexicontent_html::getToolTip($item->fulltitle, $item->text, 0, 1);
                ?>
">
					<?php 
                echo $item->title;
                ?>
				</a>
				<?php 
            } else {
                ?>
				<a href="<?php 
                echo $item->link;
                ?>
"><?php 
                echo $item->title;
                ?>
				<img src="' . $field->prevThumb . '" alt="Previous"/>
			' : '') . '
		</a>
	</span>';
} else {
    $html .= '
	<span class="fc-pagenav-prev">
		<span class="btn disabled">
			<i class="icon-previous"></i>
			' . htmlspecialchars($prev_label, ENT_NOQUOTES, 'UTF-8') . '
		</span>
	</span>';
}
// Previous item linking
if ($field->next) {
    $tooltip = $use_tooltip ? ' title="' . flexicontent_html::getToolTip($tooltip_title_next, $field->nexttitle, 0) . '"' : '';
    $html .= '
	<span class="fc-pagenav-next' . ($use_tooltip ? $tooltip_class : '') . '" ' . ($use_tooltip ? $tooltip : '') . '>
		<a class="btn" href="' . $field->nexturl . '">
			<i class="icon-next"></i>
			' . ($use_title ? $field->nexttitle : htmlspecialchars($next_label, ENT_NOQUOTES, 'UTF-8')) . '
			' . ($field->nextThumb ? '
				<br/>
				<img src="' . $field->nextThumb . '" alt="Next"/>
			' : '') . '
		</a>
	</span>';
} else {
    $html .= '
	<span class="fc-pagenav-next">
		<span class="btn disabled">
Beispiel #21
0
 function display($tpl = null)
 {
     //initialise variables
     global $globalcats;
     $app = JFactory::getApplication();
     $option = JRequest::getVar('option');
     $view = JRequest::getVar('view');
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     $document = JFactory::getDocument();
     $cparams = JComponentHelper::getParams('com_flexicontent');
     $print_logging_info = $cparams->get('print_logging_info');
     if ($print_logging_info) {
         global $fc_run_times;
     }
     JHTML::_('behavior.tooltip');
     //get vars
     $order_property = !FLEXI_J16GE ? 'c.ordering' : 'c.lft';
     $filter_order = $app->getUserStateFromRequest($option . '.' . $view . '.filter_order', 'filter_order', $order_property, 'cmd');
     $filter_order_Dir = $app->getUserStateFromRequest($option . '.' . $view . '.filter_order_Dir', 'filter_order_Dir', '', 'word');
     $filter_state = $app->getUserStateFromRequest($option . '.' . $view . '.filter_state', 'filter_state', '', 'string');
     $filter_cats = $app->getUserStateFromRequest($option . '.' . $view . '.filter_cats', 'filter_cats', '', 'int');
     $filter_level = $app->getUserStateFromRequest($option . '.' . $view . '.filter_level', 'filter_level', '', 'string');
     $filter_access = $app->getUserStateFromRequest($option . '.' . $view . '.filter_access', 'filter_access', '', 'string');
     if (FLEXI_J16GE) {
         $filter_language = $app->getUserStateFromRequest($option . '.' . $view . '.filter_language', 'filter_language', '', 'string');
     }
     $search = $app->getUserStateFromRequest($option . '.' . $view . '.search', 'search', '', 'string');
     $search = FLEXI_J16GE ? $db->escape(trim(JString::strtolower($search))) : $db->getEscaped(trim(JString::strtolower($search)));
     // Prepare the document: add css files, etc
     $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css');
     if (FLEXI_J30GE) {
         $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css');
     } else {
         if (FLEXI_J16GE) {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css');
         } else {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css');
         }
     }
     // Get User's Global Permissions
     $perms = FlexicontentHelperPerm::getPerm();
     // Create Submenu (and also check access to current view)
     FLEXISubmenu('CanCats');
     // Create document/toolbar titles
     $doc_title = JText::_('FLEXI_CATEGORIES');
     $site_title = $document->getTitle();
     JToolBarHelper::title($doc_title, 'fc_categories');
     $document->setTitle($doc_title . ' - ' . $site_title);
     // ******************
     // Create the toolbar
     // ******************
     $js = "window.addEvent('domready', function(){";
     $contrl = FLEXI_J16GE ? "categories." : "";
     $contrl_singular = FLEXI_J16GE ? "category." : "";
     $toolbar = JToolBar::getInstance('toolbar');
     // Copy Parameters
     $btn_task = '';
     $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent&view=categories&layout=params&tmpl=component';
     if (FLEXI_J30GE || !FLEXI_J16GE) {
         // Layout of Popup button broken in J3.1, add in J1.5 it generates duplicate HTML tag id (... just for validation), so add manually
         $js .= "\n\t\t\t\tjQuery('#toolbar-params a.toolbar, #toolbar-params button')\n\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 600, y: 440}, onClose: function() {}}');\n\t\t\t";
         JToolBarHelper::custom($btn_task, 'params.png', 'params_f2.png', 'FLEXI_COPY_PARAMS', false);
         JHtml::_('behavior.modal', '#toolbar-params a.toolbar, #toolbar-params button');
     } else {
         $toolbar->appendButton('Popup', 'params', JText::_('FLEXI_COPY_PARAMS'), str_replace('&', '&amp;', $popup_load_url), 600, 440);
     }
     //if (FLEXI_J16GE)
     //	$toolbar->appendButton('Popup', 'move', JText::_('FLEXI_COPY_MOVE'), JURI::base().'index.php?option=com_flexicontent&amp;view=categories&amp;layout=batch&amp;tmpl=component', 800, 440);
     JToolBarHelper::divider();
     $add_divider = false;
     if (!FLEXI_J16GE || $user->authorise('core.create', 'com_flexicontent')) {
         $cancreate_cat = true;
     } else {
         $usercats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true, $check_published = true, $specific_catids = false, $find_first = true);
         $cancreate_cat = count($usercats) > 0;
     }
     if ($cancreate_cat) {
         JToolBarHelper::addNew($contrl_singular . 'add');
         $add_divider = true;
     }
     if (!FLEXI_J16GE || ($user->authorise('core.edit', 'com_flexicontent') || $user->authorise('core.edit.own', 'com_flexicontent'))) {
         JToolBarHelper::editList($contrl_singular . 'edit');
         $add_divider = true;
     }
     if (FLEXI_J16GE && $user->authorise('core.admin', 'checkin')) {
         JToolBarHelper::checkin($contrl . 'checkin');
         $add_divider = true;
     }
     if ($add_divider) {
         JToolBarHelper::divider();
     }
     $add_divider = false;
     if (!FLEXI_J16GE || ($user->authorise('core.edit.state', 'com_flexicontent') || $user->authorise('core.edit.state.own', 'com_flexicontent'))) {
         JToolBarHelper::publishList($contrl . 'publish');
         JToolBarHelper::unpublishList($contrl . 'unpublish');
         JToolBarHelper::divider();
         if (FLEXI_J16GE) {
             JToolBarHelper::archiveList($contrl . 'archive');
         }
     }
     $add_divider = false;
     if (!FLEXI_J16GE || $filter_state == -2 && $user->authorise('core.delete', 'com_flexicontent')) {
         //JToolBarHelper::deleteList(JText::_('FLEXI_ARE_YOU_SURE'), $contrl.'remove');
         // This will work in J2.5+ too and is offers more options (above a little bogus in J1.5, e.g. bad HTML id tag)
         $msg_alert = JText::sprintf('FLEXI_SELECT_LIST_ITEMS_TO', JText::_('FLEXI_DELETE'));
         $msg_confirm = JText::_('FLEXI_ITEMS_DELETE_CONFIRM');
         $btn_task = $contrl . 'remove';
         $extra_js = "";
         flexicontent_html::addToolBarButton('FLEXI_DELETE', 'delete', '', $msg_alert, $msg_confirm, $btn_task, $extra_js, $btn_list = true, $btn_menu = true, $btn_confirm = true);
         $add_divider = true;
     } elseif ($user->authorise('core.edit.state', 'com_flexicontent')) {
         JToolBarHelper::trash($contrl . 'trash');
         $add_divider = true;
     }
     if ($add_divider) {
         JToolBarHelper::divider();
     }
     if ($perms->CanConfig) {
         //JToolBarHelper::custom($contrl.'rebuild', 'refresh.png', 'refresh_f2.png', 'JTOOLBAR_REBUILD', false);
         $session = JFactory::getSession();
         $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent');
         $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940;
         $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent');
         $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550;
         JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration');
     }
     $js .= "});";
     $document->addScriptDeclaration($js);
     //Get data from the model
     if ($print_logging_info) {
         $start_microtime = microtime(true);
     }
     if (FLEXI_J16GE) {
         $rows = $this->get('Items');
     } else {
         $rows = $this->get('Data');
     }
     if ($print_logging_info) {
         @($fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
     }
     // Get assigned items
     $model = $this->getModel();
     $rowids = array();
     foreach ($rows as $row) {
         $rowids[] = $row->id;
     }
     if ($print_logging_info) {
         $start_microtime = microtime(true);
     }
     $rowtotals = $model->getAssignedItems($rowids);
     if ($print_logging_info) {
         @($fc_run_times['execute_sec_queries'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
     }
     foreach ($rows as $row) {
         $row->nrassigned = isset($rowtotals[$row->id]) ? $rowtotals[$row->id]->nrassigned : 0;
     }
     // Parse configuration for every category
     foreach ($rows as $cat) {
         $cat->config = FLEXI_J16GE ? new JRegistry($cat->config) : new JParameter($cat->config);
     }
     if (FLEXI_J16GE) {
         $this->state = $this->get('State');
         // Preprocess the list of items to find ordering divisions.
         foreach ($rows as &$item) {
             $this->ordering[$item->parent_id][] = $item->id;
         }
     }
     $pagination = $this->get('Pagination');
     $categories =& $globalcats;
     $lists['copyid'] = flexicontent_cats::buildcatselect($categories, 'copycid', '', 2, 'class="inputbox"', false, true, $actions_allowed = array('core.edit'));
     $lists['destid'] = flexicontent_cats::buildcatselect($categories, 'destcid[]', '', false, 'class="inputbox" size="15" multiple="true"', false, true, $actions_allowed = array('core.edit'));
     // *******************
     // Create Form Filters
     // *******************
     // filter by a category (it's subtree will be displayed)
     $categories = $globalcats;
     $lists['cats'] = flexicontent_cats::buildcatselect($categories, 'filter_cats', $filter_cats, 2, 'class="inputbox" size="1" onchange="this.form.submit();"', $check_published = true, $check_perms = false);
     // filter depth level
     $options = array();
     $options[] = JHtml::_('select.option', '', JText::_('FLEXI_SELECT_MAX_DEPTH'));
     for ($i = 1; $i <= 10; $i++) {
         $options[] = JHtml::_('select.option', $i, $i);
     }
     $fieldname = $elementid = 'filter_level';
     $attribs = ' size="1" class="inputbox" onchange="this.form.submit();" ';
     $lists['level'] = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_level, $elementid, $translate = true);
     // filter publication state
     if (FLEXI_J16GE) {
         $options = JHtml::_('jgrid.publishedOptions');
         array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_SELECT_PUBLISHED')));
         $fieldname = $elementid = 'filter_state';
         $attribs = ' size="1" class="inputbox" onchange="Joomla.submitform()" ';
         $lists['state'] = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_state, $elementid, $translate = true);
     } else {
         $lists['state'] = JHTML::_('grid.state', $filter_state);
     }
     if (FLEXI_J16GE) {
         // filter access level
         $options = JHtml::_('access.assetgroups');
         array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_SELECT_ACCESS')));
         $fieldname = $elementid = 'filter_access';
         $attribs = ' size="1" class="inputbox" onchange="Joomla.submitform()" ';
         $lists['access'] = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_access, $elementid, $translate = true);
         // filter language
         $lists['language'] = flexicontent_html::buildlanguageslist('filter_language', 'size="1" class="inputbox" onchange="submitform();"', $filter_language, 2);
     } else {
         // filter access level
         $options = array();
         $options[] = JHtml::_('select.option', '', JText::_('FLEXI_SELECT_ACCESS_LEVEL'));
         $options[] = JHtml::_('select.option', '0', JText::_('Public'));
         $options[] = JHtml::_('select.option', '1', JText::_('Registered'));
         $options[] = JHtml::_('select.option', '2', JText::_('SPECIAL'));
         $fieldname = $elementid = 'filter_access';
         $attribs = ' size="1" class="inputbox" onchange="this.form.submit()" ';
         $lists['access'] = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_access, $elementid, $translate = true);
     }
     // filter search word
     $lists['search'] = $search;
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     $ordering = $lists['order'] == $order_property ? $order_property : '';
     //assign data to template
     $this->assignRef('lists', $lists);
     $this->assignRef('rows', $rows);
     $this->assignRef('perms', $perms);
     if (FLEXI_J16GE) {
         $this->assignRef('orderingx', $ordering);
     } else {
         $this->assignRef('ordering', $ordering);
     }
     $this->assignRef('pagination', $pagination);
     $this->assignRef('user', $user);
     parent::display($tpl);
 }
 function getLabel()
 {
     $node =& $this->element;
     $attributes = get_object_vars($node->attributes());
     $attributes = $attributes['@attributes'];
     if (@$attributes['enableparam']) {
         $cparams = JComponentHelper::getParams('com_flexicontent');
         if (!$cparams->get($attributes['enableparam'])) {
             return '';
         }
     }
     $label = $this->element['label'];
     $class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip';
     if (@$attributes['labelclass']) {
         $class .= ' ' . $attributes['labelclass'];
     }
     $title = "...";
     if ($this->element['description']) {
         $title = flexicontent_html::getToolTip($label, $this->element['description'], 1, 1);
     }
     return '<label style=""  class="' . $class . '" title="' . $title . '" >' . JText::_($label) . '</label>';
 }
Beispiel #23
0
			<td align="left" style="padding:0px;">
				<?php 
    $translated_label = JText::_($row->label);
    $original_label_text = $translated_label != $row->label ? '<br/><small>' . $row->label . '</small>' : '';
    $escaped_label = htmlspecialchars(JText::_($row->label), ENT_QUOTES, 'UTF-8');
    $field_desc = '';
    $field_desc_len = JString::strlen($row->description);
    if ($field_desc_len > 50) {
        $field_desc = JString::substr(htmlspecialchars($row->description, ENT_QUOTES, 'UTF-8'), 0, 50) . '...';
    } else {
        if ($field_desc_len) {
            $field_desc = htmlspecialchars($row->description, ENT_QUOTES, 'UTF-8');
        }
    }
    if ($field_desc) {
        echo ' <img src="components/com_flexicontent/assets/images/comment.png" class="fc-man-icon-s ' . $tip_class . '" title="' . flexicontent_html::getToolTip($_desc_label, $field_desc, 0, 0) . '" />';
    }
    ?>
			</td>

			<td align="left">
				<?php 
    if (isset($row->grouping_field)) {
        $_r = $row->grouping_field;
        $_link = 'index.php?option=com_flexicontent&amp;' . $fields_task . 'edit&amp;cid[]=' . $_r->id;
        echo '
					<a style="padding:2px;" href="' . $_link . '" title="' . $edit_entry . '">
						<img align="left" style="max-height:24px; padding:0px; margin:0px;" alt="Note" src="components/com_flexicontent/assets/images/insert_merge_field.png" title="Grouped inside: ' . htmlspecialchars($_r->label, ENT_QUOTES, 'UTF-8') . '" class="fc-man-icon-s ' . $tip_class . '" />
					</a>';
    }
    echo $padspacer;
    function getUploadLimitsTxt(&$field)
    {
        $tip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip';
        $hint_image = JHTML::image('components/com_flexicontent/assets/images/comment.png', JText::_('FLEXI_NOTES'), '');
        $upload_maxsize = $field->parameters->get('upload_maxsize');
        $phpUploadLimit = flexicontent_upload::getPHPuploadLimit();
        $server_limit_exceeded = $phpUploadLimit['value'] < $upload_maxsize;
        if ($server_limit_exceeded) {
            $warn_image = JHTML::image('components/com_flexicontent/assets/images/warning.png', JText::_('FLEXI_NOTES'), '');
        }
        $conf_limit_class = $server_limit_exceeded ? '' : 'badge-success';
        $conf_limit_style = $server_limit_exceeded ? 'text-decoration: line-through;' : '';
        $conf_lim_image = $server_limit_exceeded ? $warn_image . $hint_image : $hint_image;
        $sys_limit_class = $server_limit_exceeded ? 'badge-important' : '';
        return '
		<span class="fc-img-field-upload-limits-box">
			<span class="label label-info fc-upload-box-lbl">' . JText::_($server_limit_exceeded ? 'FLEXI_UPLOAD_LIMITS' : 'FLEXI_UPLOAD_LIMIT') . '</span>
			<span class="fc-php-upload-limit-box">
				<span class="' . $tip_class . '" style="margin-left:24px;" title="' . flexicontent_html::getToolTip('FLEXI_FIELD_CONF_UPLOAD_MAX_LIMIT', 'FLEXI_FIELD_CONF_UPLOAD_MAX_LIMIT_DESC', 1, 1) . '">' . $conf_lim_image . '</span>
				<span class="badge ' . $conf_limit_class . '" style="' . $conf_limit_style . '">' . round($upload_maxsize / (1024 * 1024), 2) . ' M </span>
			</span>
			' . ($server_limit_exceeded ? '
			<span class="fc-sys-upload-limit-box">
				<span class="' . $tip_class . '" style="margin-left:24px;" title="' . flexicontent_html::getToolTip(JText::_('FLEXI_SERVER_UPLOAD_MAX_LIMIT'), JText::sprintf('FLEXI_SERVER_UPLOAD_MAX_LIMIT_DESC', $phpUploadLimit['name']), 0, 1) . '">' . $hint_image . '</span>
				<span class="badge ' . $sys_limit_class . '">' . round($phpUploadLimit['value'] / (1024 * 1024), 2) . ' M </span>
			</span>' : '') . '
		</span>
		';
    }
		<div class="nowrap_box inlinefile-lang-box">
			<label class="label inlinefile-lang-lbl ' . $tip_class . '" title="' . flexicontent_html::getToolTip('FLEXI_LANGUAGE', 'FLEXI_FILE_LANGUAGE_DESC', 1, 1) . '" id="' . $elementid_n . '_file-lang-lbl" for="' . $elementid_n . '_file-lang">
				' . JText::_('FLEXI_LANGUAGE') . '
			</label>
			<span class="inlinefile-lang-data">
				' . flexicontent_html::buildlanguageslist($fieldname_n . '[file-lang]', 'class="fc_filelang use_select2_lib"', !isset($form_data[$file_id]) ? $file_data->language : $form_data[$file_id]['file-lang'], 1) . '
			</span>
		</div>' : '') . ($iform_desc ? '
		<div class="nowrap_box inlinefile-desc-box">
			<label class="label inlinefile-desc-lbl ' . $tip_class . '" title="' . flexicontent_html::getToolTip('FLEXI_DESCRIPTION', 'FLEXI_FILE_DESCRIPTION_DESC', 1, 1) . '" id="' . $elementid_n . '_file-desc-lbl" for="' . $elementid_n . '_file-desc">
				' . JText::_('FLEXI_DESCRIPTION') . '
			</label>
			<span class="inlinefile-desc-data">
				<textarea id="' . $elementid_n . '_file-desc" cols="24" rows="3" name="' . $fieldname_n . '[file-desc]" class="fc_filedesc">' . (!isset($form_data[$file_id]) ? $file_data->description : $form_data[$file_id]['file-desc']) . '</textarea>
			</span>
		</div>' : '') . ($iform_dir ? '
		<div class="nowrap_box inlinefile-secure-box">
			<label class="label inlinefile-secure-lbl ' . $tip_class . '" data-placement="top" title="' . flexicontent_html::getToolTip('FLEXI_URL_SECURE', 'FLEXI_URL_SECURE_DESC', 1, 1) . '" id="' . $elementid_n . '_secure-lbl">
				' . JText::_('FLEXI_URL_SECURE') . '
			</label>
			' . ($has_values ? '
			<span class="inlinefile-secure-info" style="' . (!$has_values ? 'display:none;' : '') . '">
				<span class="badge badge-info">' . JText::_($file_data->secure ? 'FLEXI_YES' : 'FLEXI_NO') . '</span>
			</span>' : '') . '
			<span class="inlinefile-secure-data" style="' . ($has_values ? 'display:none;' : '') . '">
				' . flexicontent_html::buildradiochecklist(array(1 => JText::_('FLEXI_YES'), 0 => JText::_('FLEXI_NO')), $fieldname_n . '[secure]', !isset($form_data[$file_id]) ? 1 : (int) $form_data[$file_id]['secure'], 0, ' class="fc_filedir" ', $elementid_n . '_secure') . '
			</span>
		</div>' : '') . '
	<div class="fcclear"></div>';
    $n++;
}
// Dates displayed in the item form, are in user timezone for J2.5, and in site's default timezone for J1.5
$site_zone = JFactory::getApplication()->getCfg('offset');
$user_zone = JFactory::getUser()->getParam('timezone', $site_zone);
$tz = new DateTimeZone($user_zone);
$tz_offset = $tz->getOffset(new JDate()) / 3600;
$tz_info = $tz_offset > 0 ? ' UTC +' . $tz_offset : ' UTC ' . $tz_offset;
$tz_info .= ' (' . $user_zone . ')';
$date_note_msg = JText::sprintf(FLEXI_J16GE ? 'FLEXI_DATES_IN_USER_TIMEZONE_NOTE' : 'FLEXI_DATES_IN_SITE_TIMEZONE_NOTE', ' ', $tz_info);
$date_note_attrs = ' class="fc-man-icon-s ' . $tip_class . '" title="' . flexicontent_html::getToolTip(null, $date_note_msg, 0, 1) . '" ';
$date_zone_tip = JHTML::image('administrator/components/com_flexicontent/assets/images/comment.png', JText::_('FLEXI_NOTES'), $date_note_attrs);
$list_total_cols = 13;
// COMMON repeated texts
$edit_entry = JText::_('FLEXI_EDIT_TAG', true);
$view_entry = JText::_('FLEXI_VIEW', true);
$rem_filt_txt = JText::_('FLEXI_REMOVE_FILTER');
$rem_filt_tip = ' class="' . $tip_class . ' filterdel" title="' . flexicontent_html::getToolTip('FLEXI_ACTIVE_FILTER', 'FLEXI_CLICK_TO_REMOVE_THIS_FILTER', 1, 1) . '" ';
?>
<script type="text/javascript">

// the function overloads joomla standard event
function submitform(pressbutton)
{
	form = document.adminForm;
	// If formvalidator activated
	if( pressbutton == 'remove' ) {
		var answer = confirm('<?php 
echo JText::_('FLEXI_ITEMS_DELETE_CONFIRM', true);
?>
')
		if (!answer){
			new Event(e).stop();
Beispiel #27
0
 function display($tpl = null)
 {
     //initialise variables
     $app = JFactory::getApplication();
     $option = JRequest::getVar('option');
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     $document = JFactory::getDocument();
     $cparams = JComponentHelper::getParams('com_flexicontent');
     $print_logging_info = $cparams->get('print_logging_info');
     if ($print_logging_info) {
         global $fc_run_times;
     }
     JHTML::_('behavior.tooltip');
     //get vars
     $filter_order = $app->getUserStateFromRequest($option . '.tags.filter_order', 'filter_order', 't.name', 'cmd');
     $filter_order_Dir = $app->getUserStateFromRequest($option . '.tags.filter_order_Dir', 'filter_order_Dir', '', 'word');
     $filter_state = $app->getUserStateFromRequest($option . '.tags.filter_state', 'filter_state', '*', 'word');
     $filter_assigned = $app->getUserStateFromRequest($option . '.tags.filter_assigned', 'filter_assigned', '*', 'word');
     $search = $app->getUserStateFromRequest($option . '.tags.search', 'search', '', 'string');
     $search = FLEXI_J16GE ? $db->escape(trim(JString::strtolower($search))) : $db->getEscaped(trim(JString::strtolower($search)));
     //add css and submenu to document
     $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css');
     if (FLEXI_J30GE) {
         $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css');
     } else {
         if (FLEXI_J16GE) {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css');
         } else {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css');
         }
     }
     // Get User's Global Permissions
     $perms = FlexicontentHelperPerm::getPerm();
     // Create Submenu (and also check access to current view)
     FLEXISubmenu('CanTags');
     // Create document/toolbar titles
     $doc_title = JText::_('FLEXI_TAGS');
     $site_title = $document->getTitle();
     JToolBarHelper::title($doc_title, 'tags');
     $document->setTitle($doc_title . ' - ' . $site_title);
     // Create the toolbar
     $js = "window.addEvent('domready', function(){";
     $contrl = FLEXI_J16GE ? "tags." : "";
     $toolbar = JToolBar::getInstance('toolbar');
     if ($perms->CanConfig) {
         $btn_task = '';
         $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent&view=tags&layout=import&tmpl=component';
         if (FLEXI_J30GE || !FLEXI_J16GE) {
             // Layout of Popup button broken in J3.1, add in J1.5 it generates duplicate HTML tag id (... just for validation), so add manually
             $js .= "\n\t\t\t\t\tjQuery('#toolbar-import a.toolbar, #toolbar-import button')\n\t\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 430, y: 500}, onClose: function() {}}');\n\t\t\t\t";
             JToolBarHelper::custom($btn_task, 'import.png', 'import_f2.png', 'FLEXI_IMPORT', false);
             JHtml::_('behavior.modal', '#toolbar-import a.toolbar, #toolbar-import button');
         } else {
             $toolbar->appendButton('Popup', 'import', JText::_('FLEXI_IMPORT'), str_replace('&', '&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);
     }
     $rows = $this->get('Data');
     if ($print_logging_info) {
         @($fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
     }
     // Get assigned items
     $model = $this->getModel();
     $rowids = array();
     foreach ($rows as $row) {
         $rowids[] = $row->id;
     }
     if ($print_logging_info) {
         $start_microtime = microtime(true);
     }
     $rowtotals = $model->getAssignedItems($rowids);
     if ($print_logging_info) {
         @($fc_run_times['execute_sec_queries'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
     }
     foreach ($rows as $row) {
         $row->nrassigned = isset($rowtotals[$row->id]) ? $rowtotals[$row->id]->nrassigned : 0;
     }
     $pagination = $this->get('Pagination');
     $lists = array();
     //build arphaned/assigned filter
     $assigned = array();
     $assigned[] = JHTML::_('select.option', '', '- ' . JText::_('FLEXI_ALL_TAGS') . ' -');
     $assigned[] = JHTML::_('select.option', 'O', JText::_('FLEXI_ORPHANED'));
     $assigned[] = JHTML::_('select.option', 'A', JText::_('FLEXI_ASSIGNED'));
     $lists['assigned'] = JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="inputbox" size="1" onchange="submitform( );"', 'value', 'text', $filter_assigned);
     //publish unpublished filter
     $lists['state'] = JHTML::_('grid.state', $filter_state);
     // search filter
     $lists['search'] = $search;
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     //assign data to template
     $this->assignRef('lists', $lists);
     $this->assignRef('rows', $rows);
     $this->assignRef('pagination', $pagination);
     parent::display($tpl);
 }
Beispiel #28
0
 /**
  * Logic to save an item
  *
  * @access public
  * @return void
  * @since 1.0
  */
 function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     //echo '<html>  <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <body>';
     // Initialize variables
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $config = JFactory::getConfig();
     $session = JFactory::getSession();
     $task = JRequest::getVar('task');
     $ctrl_task = 'task=items.';
     // *********************
     // Get data from request
     // *********************
     // Retrieve form data these are subject to basic filtering
     $data = JRequest::getVar('jform', array(), 'post', 'array');
     // Core Fields and and item Parameters
     $custom = JRequest::getVar('custom', array(), 'post', 'array');
     // Custom Fields
     $jfdata = JRequest::getVar('jfdata', array(), 'post', 'array');
     // Joomfish Data
     // Set into model: id (needed for loading correct item), and type id (e.g. needed for getting correct type parameters for new items)
     $data_id = (int) $data['id'];
     $isnew = $data_id == 0;
     // If new make sure that type id is set too, before creating the model
     if ($isnew) {
         $typeid = JRequest::setvar('typeid', (int) @$data['type_id']);
     }
     // Get the model
     $model = $this->getModel('item');
     $model->setId($data_id);
     // Make sure id is correct
     // Get some flags this will also trigger item loading if not already loaded
     $isOwner = $model->get('created_by') == $user->get('id');
     // Get merged parameters: component, type, menu (FE)
     $params = new JRegistry();
     $model_params = $model->getComponentTypeParams();
     $params->merge($model_params);
     // Unique id for new items, needed by some fields for temporary data
     $unique_tmp_itemid = JRequest::getVar('unique_tmp_itemid');
     // Auto title for some content types
     if ($params->get('auto_title', 0)) {
         $data['title'] = (int) $data['id'];
     }
     // item id or ZERO for new items
     // *************************************
     // ENFORCE can change category ACL perms
     // *************************************
     $perms = FlexicontentHelperPerm::getPerm();
     // Per content type change category permissions
     $current_type_id = $isnew || !$model->get('type_id') ? (int) @$data['type_id'] : $model->get('type_id');
     // GET current (existing/old) item TYPE ID
     $CanChangeFeatCat = $user->authorise('flexicontent.change.cat.feat', 'com_flexicontent.type.' . $current_type_id);
     $CanChangeSecCat = $user->authorise('flexicontent.change.cat.sec', 'com_flexicontent.type.' . $current_type_id);
     $CanChangeCat = $user->authorise('flexicontent.change.cat', 'com_flexicontent.type.' . $current_type_id);
     $AutoApproveChanges = $perms->AutoApproveChanges;
     $enable_featured_cid_selector = $perms->MultiCat && $CanChangeFeatCat;
     $enable_cid_selector = $perms->MultiCat && $CanChangeSecCat;
     $enable_catid_selector = $isnew && !$params->get('catid_default') || !$isnew && !$model->get('catid') || $CanChangeCat;
     // Enforce maintaining featured categories
     $featured_cats_parent = $params->get('featured_cats_parent', 0);
     $featured_cats = array();
     if ($featured_cats_parent && !$enable_featured_cid_selector) {
         $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_cid = array();
         if (!$isnew) {
             foreach ($model->get('categories') as $item_cat) {
                 if (isset($featured_tree[$item_cat]) && !isset($disabled_cats[$item_cat])) {
                     $featured_cid[] = $item_cat;
                 }
             }
         }
         $data['featured_cid'] = $featured_cid;
     }
     // Enforce maintaining secondary categories
     if (!$enable_cid_selector) {
         if ($isnew) {
             $data['cid'] = $params->get('cid_default');
         } else {
             if (isset($featured_cid)) {
                 $featured_cid_arr = array_flip($featured_cid);
                 $sec_cid = array();
                 foreach ($model->get('cats') as $item_cat) {
                     if (!isset($featured_cid_arr[$item_cat])) {
                         $sec_cid[] = $item_cat;
                     }
                 }
                 $data['cid'] = $sec_cid;
             } else {
                 $data['cid'] = $model->get('cats');
             }
         }
     }
     if (!$enable_catid_selector) {
         if ($isnew && $params->get('catid_default')) {
             $data['catid'] = $params->get('catid_default');
         } else {
             if ($model->get('catid')) {
                 $data['catid'] = $model->get('catid');
             }
         }
     }
     // **************************
     // Basic Form data validation
     // **************************
     // Get the JForm object, but do not pass any data we only want the form object,
     // in order to validate the data and not create a filled-in form
     $form = $model->getForm();
     // Validate Form data for core fields and for parameters
     $post = $model->validate($form, $data);
     // Check for validation error
     if (!$post) {
         // Get the validation messages and push up to three validation messages out to the user
         $errors = $form->getErrors();
         for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
             $app->enqueueMessage($errors[$i] instanceof Exception ? $errors[$i]->getMessage() : $errors[$i], 'error');
         }
         // Set POST form date into the session, so that they get reloaded
         $app->setUserState($form->option . '.edit.' . $form->context . '.data', $data);
         // Save the jform data in the session
         $app->setUserState($form->option . '.edit.' . $form->context . '.custom', $custom);
         // Save the custom fields data in the session
         $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', $jfdata);
         // Save the falang translations into the session
         $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', $unique_tmp_itemid);
         // Save temporary unique item id into the session
         // Redirect back to the item form
         $this->setRedirect($_SERVER['HTTP_REFERER']);
         if (JRequest::getVar('fc_doajax_submit')) {
             echo flexicontent_html::get_system_messages_html();
             exit;
             // Ajax submit, do not rerender the view
         }
         return false;
         //die('error');
     }
     // Some values need to be assigned after validation
     $post['attribs'] = @$data['attribs'];
     // Workaround for item's template parameters being clear by validation since they are not present in item.xml
     $post['custom'] =& $custom;
     // Assign array of custom field values, they are in the 'custom' form array instead of jform
     $post['jfdata'] =& $jfdata;
     // Assign array of Joomfish field values, they are in the 'jfdata' form array instead of jform
     // Assign template parameters of the select ilayout as an sub-array (the DB model will handle the merging of parameters)
     $ilayout = $data['attribs']['ilayout'];
     if (!empty($data['layouts'][$ilayout])) {
         //echo "<pre>"; print_r($post['attribs']);
         //$post['attribs'] = array_merge($post['attribs'], $data['layouts'][$ilayout]);
         $post['attribs']['layouts'] = $data['layouts'];
         //echo "<pre>"; print_r($post['attribs']); exit;
     }
     // USEFULL FOR DEBUGING for J2.5 (do not remove commented code)
     //$diff_arr = array_diff_assoc ( $data, $post);
     //echo "<pre>"; print_r($diff_arr); jexit();
     // Make sure Content ID in the REQUEST is set, this is needed in BACKEND, needed in some cases
     // NOTE this is not the same as jform['cid'] which is the category IDs of the Content Item
     JRequest::setVar('cid', array($model->getId()), 'post', 'array');
     // ********************************************************************************
     // PERFORM ACCESS CHECKS, NOTE: we need to check access again, despite having
     // checked them on edit form load, because user may have tampered with the form ...
     // ********************************************************************************
     $itemAccess = $model->getItemAccess();
     $canAdd = $itemAccess->get('access-create');
     // includes check of creating in at least one category
     $canEdit = $itemAccess->get('access-edit');
     // includes privileges edit and edit-own
     $type_id = (int) @$post['type_id'];
     // Typecast to int, (already done for J2.5 via validating)
     if (!$isnew && $model->get('type_id') == $type_id) {
         // Existing item with Type not being ALTERED, content type can be maintained regardless of privilege
         $canCreateType = true;
     } else {
         // New item or existing item with Type is being ALTERED, check privilege to create items of this type
         $canCreateType = $model->canCreateType(array($type_id), true, $types);
     }
     // *****************************************************************
     // Calculate user's CREATE / EDIT privileges on current content item
     // *****************************************************************
     $hasCoupon = false;
     // Normally used in frontend only
     if (!$isnew) {
         // If no edit privilege, check if item is editable till logoff
         if (!$canEdit) {
             if ($session->has('rendered_uneditable', 'flexicontent')) {
                 $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent');
                 $canEdit = isset($rendered_uneditable[$model->get('id')]) && $rendered_uneditable[$model->get('id')];
                 $hasCoupon = isset($rendered_uneditable[$model->get('id')]) && $rendered_uneditable[$model->get('id')] == 2;
                 // editable via coupon
             }
         }
     } else {
         // No special CREATE allowing case for backend
     }
     // New item: check if user can create in at least one category
     if ($isnew && !$canAdd) {
         JError::raiseWarning(403, JText::_('FLEXI_NO_ACCESS_CREATE'));
         $this->setRedirect($_SERVER['HTTP_REFERER']);
         if (JRequest::getVar('fc_doajax_submit')) {
             echo flexicontent_html::get_system_messages_html();
             exit;
             // Ajax submit, do not rerender the view
         }
         return;
     }
     // Existing item: Check if user can edit current item
     if (!$isnew && !$canEdit) {
         JError::raiseWarning(403, JText::_('FLEXI_NO_ACCESS_EDIT'));
         $this->setRedirect($_SERVER['HTTP_REFERER']);
         if (JRequest::getVar('fc_doajax_submit')) {
             echo flexicontent_html::get_system_messages_html();
             exit;
             // Ajax submit, do not rerender the view
         }
         return;
     }
     if (!$canCreateType) {
         $msg = isset($types[$type_id]) ? JText::sprintf('FLEXI_NO_ACCESS_CREATE_CONTENT_OF_TYPE', JText::_($types[$type_id]->name)) : ' Content Type ' . $type_id . ' was not found OR is not published';
         JError::raiseWarning(403, $msg);
         $this->setRedirect($_SERVER['HTTP_REFERER']);
         if (JRequest::getVar('fc_doajax_submit')) {
             echo flexicontent_html::get_system_messages_html();
             exit;
             // Ajax submit, do not rerender the view
         }
         return;
     }
     // Get "BEFORE SAVE" categories for information mail
     $before_cats = array();
     if (!$isnew) {
         $query = 'SELECT DISTINCT c.id, c.title FROM #__categories AS c' . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.catid = c.id' . ' WHERE rel.itemid = ' . (int) $model->get('id');
         $db->setQuery($query);
         $before_cats = $db->loadObjectList('id');
         $before_maincat = $model->get('catid');
         $original_item = $model->getItem($post['id'], $check_view_access = false, $no_cache = true, $force_version = 0);
     }
     // ****************************************
     // Try to store the form data into the item
     // ****************************************
     if (!$model->store($post)) {
         // Set error message about saving failed, and also the reason (=model's error message)
         $msg = JText::_('FLEXI_ERROR_STORING_ITEM');
         JError::raiseWarning(500, $msg . ": " . $model->getError());
         // Set POST form date into the session, so that they get reloaded
         $app->setUserState($form->option . '.edit.' . $form->context . '.data', $data);
         // Save the jform data in the session
         $app->setUserState($form->option . '.edit.' . $form->context . '.custom', $custom);
         // Save the custom fields data in the session
         $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', $jfdata);
         // Save the falang translations into the session
         $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', $unique_tmp_itemid);
         // Save temporary unique item id into the session
         // Saving has failed check-in and redirect back to the item form,
         // redirect back to the item form reloading the posted data
         $model->checkin();
         $this->setRedirect($_SERVER['HTTP_REFERER']);
         if (JRequest::getVar('fc_doajax_submit')) {
             echo flexicontent_html::get_system_messages_html();
             exit;
             // Ajax submit, do not rerender the view
         }
         return;
         //die('save error');
     }
     // **************************************************
     // Check in model and get item id in case of new item
     // **************************************************
     $model->checkin();
     $post['id'] = $isnew ? (int) $model->get('id') : $post['id'];
     // Get items marked as newly submitted
     $newly_submitted = $session->get('newly_submitted', array(), 'flexicontent');
     if ($isnew) {
         // Mark item as newly submitted, to allow to a proper "THANKS" message after final save & close operation (since user may have clicked add instead of add & close)
         $newly_submitted[$model->get('id')] = 1;
         $session->set('newly_submitted', $newly_submitted, 'flexicontent');
     }
     $newly_submitted_item = @$newly_submitted[$model->get('id')];
     // ***********************************************************************************************************
     // Get newly saved -latest- version (store task gets latest) of the item, and also calculate publish privelege
     // ***********************************************************************************************************
     $item = $model->getItem($post['id'], $check_view_access = false, $no_cache = true, $force_version = -1);
     $canPublish = $model->canEditState($item, $check_cat_perm = true) || $hasCoupon;
     // ********************************************************************************************
     // Use session to detect multiple item saves to avoid sending notification EMAIL multiple times
     // ********************************************************************************************
     $is_first_save = true;
     if ($session->has('saved_fcitems', 'flexicontent')) {
         $saved_fcitems = $session->get('saved_fcitems', array(), 'flexicontent');
         $is_first_save = $isnew ? true : !isset($saved_fcitems[$model->get('id')]);
     }
     // Add item to saved items of the corresponding session array
     $saved_fcitems[$model->get('id')] = $timestamp = time();
     // Current time as seconds since Unix epoc;
     $session->set('saved_fcitems', $saved_fcitems, 'flexicontent');
     // ********************************************
     // Get categories added / removed from the item
     // ********************************************
     $query = 'SELECT DISTINCT c.id, c.title FROM #__categories AS c' . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.catid = c.id' . ' WHERE rel.itemid = ' . (int) $model->get('id');
     $db->setQuery($query);
     $after_cats = $db->loadObjectList('id');
     if (!$isnew) {
         $cats_added_ids = array_diff(array_keys($after_cats), array_keys($before_cats));
         foreach ($cats_added_ids as $cats_added_id) {
             $cats_added_titles[] = $after_cats[$cats_added_id]->title;
         }
         $cats_removed_ids = array_diff(array_keys($before_cats), array_keys($after_cats));
         foreach ($cats_removed_ids as $cats_removed_id) {
             $cats_removed_titles[] = $before_cats[$cats_removed_id]->title;
         }
         $cats_altered = count($cats_added_ids) + count($cats_removed_ids);
         $after_maincat = $model->get('catid');
     }
     // *******************************************************************************************************************
     // We need to get emails to notify, from Global/item's Content Type parameters -AND- from item's categories parameters
     // *******************************************************************************************************************
     $notify_emails = array();
     if ($is_first_save || $cats_altered || $params->get('nf_enable_debug', 0)) {
         // Get needed flags regarding the saved items
         $approve_version = 2;
         $pending_approval_state = -3;
         $draft_state = -4;
         $current_version = FLEXIUtilities::getCurrentVersions($item->id, true);
         // Get current item version
         $last_version = FLEXIUtilities::getLastVersions($item->id, true);
         // Get last version (=latest one saved, highest version id),
         // $post variables vstate & state may have been (a) tampered in the form, and/or (b) altered by save procedure so better not use them
         $needs_version_reviewal = !$isnew && $last_version > $current_version && !$canPublish && !$AutoApproveChanges;
         $needs_publication_approval = $isnew && $item->state == $pending_approval_state && !$canPublish;
         $draft_from_non_publisher = $item->state == $draft_state && !$canPublish;
         if ($draft_from_non_publisher) {
             // Suppress notifications for draft-state items (new or existing ones), for these each author will publication approval manually via a button
             $nConf = false;
         } else {
             // Get notifications configuration and select appropriate emails for current saving case
             $nConf = $model->getNotificationsConf($params);
             //echo "<pre>"; print_r($nConf); "</pre>";
         }
         if ($nConf) {
             $states_notify_new = $params->get('states_notify_new', array(1, 0, FLEXI_J16GE ? 2 : -1, -3, -4, -5));
             if (empty($states_notify_new)) {
                 $states_notify_new = array();
             } else {
                 if (!is_array($states_notify_new)) {
                     $states_notify_new = !FLEXI_J16GE ? array($states_notify_new) : explode("|", $states_notify_new);
                 }
             }
             $states_notify_existing = $params->get('states_notify_existing', array(1, 0, FLEXI_J16GE ? 2 : -1, -3, -4, -5));
             if (empty($states_notify_existing)) {
                 $states_notify_existing = array();
             } else {
                 if (!is_array($states_notify_existing)) {
                     $states_notify_existing = !FLEXI_J16GE ? array($states_notify_existing) : explode("|", $states_notify_existing);
                 }
             }
             $n_state_ok = in_array($item->state, $states_notify_new);
             $e_state_ok = in_array($item->state, $states_notify_existing);
             if ($needs_publication_approval) {
                 $notify_emails = $nConf->emails->notify_new_pending;
             } else {
                 if ($isnew && $n_state_ok) {
                     $notify_emails = $nConf->emails->notify_new;
                 } else {
                     if ($isnew) {
                         $notify_emails = array();
                     } else {
                         if ($needs_version_reviewal) {
                             $notify_emails = $nConf->emails->notify_existing_reviewal;
                         } else {
                             if (!$isnew && $e_state_ok) {
                                 $notify_emails = $nConf->emails->notify_existing;
                             } else {
                                 if (!$isnew) {
                                     $notify_emails = array();
                                 }
                             }
                         }
                     }
                 }
             }
             if ($needs_publication_approval) {
                 $notify_text = $params->get('text_notify_new_pending');
             } else {
                 if ($isnew) {
                     $notify_text = $params->get('text_notify_new');
                 } else {
                     if ($needs_version_reviewal) {
                         $notify_text = $params->get('text_notify_existing_reviewal');
                     } else {
                         if (!$isnew) {
                             $notify_text = $params->get('text_notify_existing');
                         }
                     }
                 }
             }
             //print_r($notify_emails); jexit();
         }
     }
     // *********************************************************************************************************************
     // If there are emails to notify for current saving case, then send the notifications emails, but
     // *********************************************************************************************************************
     if (!empty($notify_emails) && count($notify_emails)) {
         $notify_vars = new stdClass();
         $notify_vars->needs_version_reviewal = $needs_version_reviewal;
         $notify_vars->needs_publication_approval = $needs_publication_approval;
         $notify_vars->isnew = $isnew;
         $notify_vars->notify_emails = $notify_emails;
         $notify_vars->notify_text = $notify_text;
         $notify_vars->before_cats = $before_cats;
         $notify_vars->after_cats = $after_cats;
         $notify_vars->original_item = @$original_item;
         $model->sendNotificationEmails($notify_vars, $params, $manual_approval_request = 0);
     }
     // ***************************************************
     // CLEAN THE CACHE so that our changes appear realtime
     // ***************************************************
     $cache = FLEXIUtilities::getCache($group = '', 0);
     $cache->clean('com_flexicontent_items');
     $cache->clean('com_flexicontent_filters');
     $cache = FLEXIUtilities::getCache($group = '', 1);
     $cache->clean('com_flexicontent_items');
     $cache->clean('com_flexicontent_filters');
     // ****************************************************************************************************************************
     // Recalculate EDIT PRIVILEGE of new item. Reason for needing to do this is because we can have create permission in a category
     // and thus being able to set this category as item's main category, but then have no edit/editown permission for this category
     // ****************************************************************************************************************************
     $asset = 'com_content.article.' . $model->get('id');
     $canEdit = $user->authorise('core.edit', $asset) || $user->authorise('core.edit.own', $asset) && $isOwner;
     // ALTERNATIVE 1
     //$canEdit = $model->getItemAccess()->get('access-edit'); // includes privileges edit and edit-own
     // ALTERNATIVE 2
     //$rights = FlexicontentHelperPerm::checkAllItemAccess($user->get('id'), 'item', $model->get('id'));
     //$canEdit = in_array('edit', $rights) || (in_array('edit.own', $rights) && $isOwner) ;
     // *******************************************************************************************************
     // Check if user can not edit item further (due to changed main category, without edit/editown permission)
     // *******************************************************************************************************
     if (!$canEdit) {
         if ($task == 'apply' || $task == 'apply_type') {
             // APPLY TASK: Temporarily set item to be editable till closing it and not through all session
             // (we will/should clear this flag when item is closed, since we have another flag to indicate new items
             $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent');
             $rendered_uneditable[$model->get('id')] = -1;
             $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent');
             $canEdit = 1;
         } else {
             if ($newly_submitted_item) {
                 // NEW ITEM: Do not use editable till logoff behaviour
                 // ALSO: Clear editable FLAG set in the case that 'apply' button was used during new item creation
                 if (!$params->get('items_session_editable', 0)) {
                     $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent');
                     if (isset($rendered_uneditable[$model->get('id')])) {
                         unset($rendered_uneditable[$model->get('id')]);
                         $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent');
                     }
                 }
             } else {
                 // EXISTING ITEM: (if enabled) Use the editable till logoff behaviour
                 if ($params->get('items_session_editable', 0)) {
                     // Set notice for existing item being editable till logoff
                     JError::raiseNotice(403, JText::_('FLEXI_CANNOT_EDIT_AFTER_LOGOFF'));
                     // Allow item to be editable till logoff
                     $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent');
                     $rendered_uneditable[$model->get('id')] = 1;
                     $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent');
                     $canEdit = 1;
                 }
             }
         }
         // Set notice about saving an item that cannot be changed further
         if (!$canEdit) {
             $app->enqueueMessage(JText::_('FLEXI_CANNOT_MAKE_FURTHER_CHANGES_TO_CONTENT'), 'message');
         }
     }
     // ****************************************************************
     // Check for new Content Item is being closed, and clear some flags
     // ****************************************************************
     if ($task != 'apply' && $task != 'apply_type' && $newly_submitted_item) {
         // Clear item from being marked as newly submitted
         unset($newly_submitted[$model->get('id')]);
         $session->set('newly_submitted', $newly_submitted, 'flexicontent');
         // The 'apply' task may set 'editable till logoff' FLAG ...
         // CLEAR IT, since NEW content this is meant to be used temporarily
         if (!$params->get('items_session_editable', 0)) {
             $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent');
             if (isset($rendered_uneditable[$model->get('id')])) {
                 unset($rendered_uneditable[$model->get('id')]);
                 $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent');
             }
         }
     }
     // ****************************************
     // Saving is done, decide where to redirect
     // ****************************************
     switch ($task) {
         case 'apply':
         case 'apply_type':
             $link = 'index.php?option=com_flexicontent&' . $ctrl_task . 'edit&cid=' . (int) $model->get('id');
             break;
         case 'saveandnew':
             $link = $type_id ? 'index.php?option=com_flexicontent&view=item&typeid=' . $type_id : 'index.php?option=com_flexicontent&view=item';
             break;
         default:
             $link = 'index.php?option=com_flexicontent&view=items';
             break;
     }
     $msg = JText::_('FLEXI_ITEM_SAVED');
     $this->setRedirect($link, $msg);
     if (JRequest::getVar('fc_doajax_submit')) {
         JFactory::getApplication()->enqueueMessage($msg, 'message');
         echo flexicontent_html::get_system_messages_html();
         exit;
         // Ajax submit, do not rerender the view
     }
 }
 static function createItemsListHTML(&$params, &$item_list, $isform = 0, &$parentfield, &$parentitem, &$_item_data = null)
 {
     $db = JFactory::getDBO();
     global $globalcats, $globalnoroute, $fc_run_times;
     if (!is_array($globalnoroute)) {
         $globalnoroute = array();
     }
     // Get fields of type relation
     static $disallowed_fieldnames = null;
     $disallowed_fields = array('relation', 'relation_reverse');
     if ($disallowed_fieldnames === null) {
         $query = "SELECT name FROM #__flexicontent_fields WHERE field_type IN ('" . implode("','", $disallowed_fields) . "')";
         $db->setQuery($query);
         $field_name_col = FLEXI_J16GE ? $db->loadColumn() : $db->loadResultArray();
         $disallowed_fieldnames = !$field_name_col ? array() : array_flip($field_name_col);
     }
     // Prefix - Suffix - Separator parameters, replacing other field values if found
     $remove_space = $params->get('remove_space', 0);
     $pretext = $params->get($isform ? 'pretext_form' : 'pretext', '');
     $posttext = $params->get($isform ? 'posttext_form' : 'posttext', '');
     $separatorf = $params->get($isform ? 'separator' : 'separatorf');
     $opentag = $params->get($isform ? 'opentag_form' : 'opentag', '');
     $closetag = $params->get($isform ? 'closetag_form' : 'closetag', '');
     if ($pretext) {
         $pretext = $remove_space ? $pretext : $pretext . ' ';
     }
     if ($posttext) {
         $posttext = $remove_space ? $posttext : ' ' . $posttext;
     }
     switch ($separatorf) {
         case 0:
             $separatorf = '&nbsp;';
             break;
         case 1:
             $separatorf = '<br />';
             break;
         case 2:
             $separatorf = '&nbsp;|&nbsp;';
             break;
         case 3:
             $separatorf = ',&nbsp;';
             break;
         case 4:
             $separatorf = $closetag . $opentag;
             break;
         case 5:
             $separatorf = '';
             break;
         default:
             $separatorf = '&nbsp;';
             break;
     }
     // some parameter shortcuts
     $relitem_html = $params->get($isform ? 'relitem_html_form' : 'relitem_html', '__display_text__');
     $displayway = $params->get($isform ? 'displayway_form' : 'displayway', 1);
     $addlink = $params->get($isform ? 'addlink_form' : 'addlink', 1);
     $addtooltip = $params->get($isform ? 'addtooltip_form' : 'addtooltip', 1);
     // Parse and identify custom fields
     $result = preg_match_all("/\\{\\{([a-zA-Z_0-9]+)(##)?([a-zA-Z_0-9]+)?\\}\\}/", $relitem_html, $field_matches);
     $custom_field_reps = $result ? $field_matches[0] : array();
     $custom_field_names = $result ? $field_matches[1] : array();
     $custom_field_methods = $result ? $field_matches[3] : array();
     /*foreach ($custom_field_names as $i => $custom_field_name)
     			$parsed_fields[] = $custom_field_names[$i] . ($custom_field_methods[$i] ? "->". $custom_field_methods[$i] : "");
     		echo "$relitem_html :: Fields for Related Items List: ". implode(", ", $parsed_fields ? $parsed_fields : array() ) ."<br/>\n";*/
     // Parse and identify language strings and then make language replacements
     $result = preg_match_all("/\\%\\%([^%]+)\\%\\%/", $relitem_html, $translate_matches);
     $translate_strings = $result ? $translate_matches[1] : array('FLEXI_READ_MORE_ABOUT');
     foreach ($translate_strings as $translate_string) {
         $relitem_html = str_replace('%%' . $translate_string . '%%', JText::_($translate_string), $relitem_html);
     }
     foreach ($item_list as $result) {
         // Check if related item is published and skip if not published
         if ($result->state != 1 && $result->state != -5) {
             continue;
         }
         $itemslug = $result->id . ":" . $result->alias;
         $catslug = "";
         // Check if removed from category or inside a noRoute category or inside a non-published category
         // and use main category slug or other routable & published category slug
         $catid_arr = explode(",", $result->catidlist);
         $catalias_arr = explode(",", $result->cataliaslist);
         for ($i = 0; $i < count($catid_arr); $i++) {
             $itemcataliases[$catid_arr[$i]] = $catalias_arr[$i];
         }
         $rel_itemid = $result->id;
         $rel_catid = !empty($result->rel_catid) ? $result->rel_catid : $result->catid;
         if (isset($itemcataliases[$rel_catid]) && !in_array($rel_catid, $globalnoroute) && $globalcats[$rel_catid]->published) {
             $catslug = $rel_catid . ":" . $itemcataliases[$rel_catid];
         } else {
             if (!in_array($result->catid, $globalnoroute) && $globalcats[$result->catid]->published) {
                 $catslug = $globalcats[$result->catid]->slug;
             } else {
                 foreach ($catid_arr as $catid) {
                     if (!in_array($catid, $globalnoroute) && $globalcats[$catid]->published) {
                         $catslug = $globalcats[$catid]->slug;
                         break;
                     }
                 }
             }
         }
         $result->slug = $itemslug;
         $result->categoryslug = $catslug;
     }
     // Perform field's display replacements
     if ($i_slave = $parentfield ? $parentitem->id . "_" . $parentfield->id : '') {
         $fc_run_times['render_subfields'][$i_slave] = 0;
     }
     foreach ($custom_field_names as $i => $custom_field_name) {
         if (isset($disallowed_fieldnames[$custom_field_name])) {
             continue;
         }
         if ($custom_field_methods[$i] == 'label') {
             continue;
         }
         if ($i_slave) {
             $start_microtime = microtime(true);
         }
         $display_var = $custom_field_methods[$i] ? $custom_field_methods[$i] : 'display';
         FlexicontentFields::getFieldDisplay($item_list, $custom_field_name, $custom_field_values = null, $display_var);
         if ($i_slave) {
             $fc_run_times['render_subfields'][$i_slave] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
         }
     }
     $tooltip_class = FLEXI_J30GE ? 'hasTooltip' : 'hasTip';
     $display = array();
     foreach ($item_list as $result) {
         $url_read_more = JText::_(isset($_item_data->url_read_more) ? $_item_data->url_read_more : 'FLEXI_READ_MORE_ABOUT', 1);
         $url_class = isset($_item_data->url_class) ? $_item_data->url_class : 'relateditem';
         // Check if related item is published and skip if not published
         if ($result->state != 1 && $result->state != -5) {
             continue;
         }
         // a. Replace some custom made strings
         $item_url = JRoute::_(FlexicontentHelperRoute::getItemRoute($result->slug, $result->categoryslug, 0, $result));
         $item_title_escaped = htmlspecialchars($result->title, ENT_COMPAT, 'UTF-8');
         $tooltip_title = flexicontent_html::getToolTip($url_read_more, $item_title_escaped, $translate = 0, $escape = 0);
         $item_tooltip = ' class="' . $tooltip_class . ' ' . $url_class . '" title="' . $tooltip_title . '" ';
         $display_text = $displayway ? $result->title : $result->id;
         $display_text = !$addlink ? $display_text : '<a href="' . $item_url . '"' . ($addtooltip ? $item_tooltip : '') . ' >' . $display_text . '</a>';
         $curr_relitem_html = $relitem_html;
         $curr_relitem_html = str_replace('__item_url__', $item_url, $curr_relitem_html);
         $curr_relitem_html = str_replace('__item_title_escaped__', $item_title_escaped, $curr_relitem_html);
         $curr_relitem_html = str_replace('__item_tooltip__', $item_tooltip, $curr_relitem_html);
         $curr_relitem_html = str_replace('__display_text__', $display_text, $curr_relitem_html);
         // b. Replace item properties, e.g. {item->id}, (item->title}, etc
         $null_field = null;
         FlexicontentFields::doQueryReplacements($curr_relitem_html, $null_field, $result);
         // c. Replace HTML display of various item fields
         $err_mssg = 'Cannot replace field: "%s" because it is of not allowed field type: "%s", which can cause loop or other problem';
         foreach ($custom_field_names as $i => $custom_field_name) {
             $_field = @$result->fields[$custom_field_name];
             $custom_field_display = '';
             if ($is_disallowed_field = isset($disallowed_fieldnames[$custom_field_name])) {
                 $custom_field_display .= sprintf($err_mssg, $custom_field_name, @$_field->field_type);
             } else {
                 $display_var = $custom_field_methods[$i] ? $custom_field_methods[$i] : 'display';
                 $custom_field_display .= @$_field->{$display_var};
             }
             $curr_relitem_html = str_replace($custom_field_reps[$i], $custom_field_display, $curr_relitem_html);
         }
         $display[] = trim($pretext . $curr_relitem_html . $posttext);
     }
     $display = $opentag . implode($separatorf, $display) . $closetag;
     return $display;
 }
			<?php if ($this->params->get('intro_use_image', 1) && $src) : ?>
			<figure class="image<?php echo $this->params->get('intro_position') ? ' right' : ' left'; ?>">
				<?php if ($this->params->get('intro_link_image', 1)) : ?>
					<a href="<?php echo JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $item->categoryslug, 0, $item)); ?>" class="hasTip" title="<?php echo JText::_( 'FLEXI_READ_MORE_ABOUT' ) . '::' . htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8'); ?>">
						<img src="<?php echo $thumb; ?>" alt="<?php echo htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8'); ?>" />
					</a>
				<?php else : ?>
					<img src="<?php echo $thumb; ?>" alt="<?php echo htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8'); ?>" />
				<?php endif; ?>
			</figure>
			<?php endif; ?>
			<p>
			<?php
				FlexicontentFields::getFieldDisplay($item, 'text', $values=null, $method='display');
				if ($this->params->get('intro_strip_html', 1)) :
					echo flexicontent_html::striptagsandcut( $item->fields['text']->display, $this->params->get('intro_cut_text', 200) );
				else :
					echo $item->fields['text']->display;
				endif;
			?>
			</p>
			</div>

			<!-- BOF under-description-line1 block -->
			<?php if (isset($item->positions['under-description-line1'])) : ?>
			<div class="lineinfo line3">
				<?php foreach ($item->positions['under-description-line1'] as $field) : ?>
				<span class="element">
					<?php if ($field->label) : ?>
					<span class="flexi label field_<?php echo $field->name; ?>"><?php echo $field->label; ?></span>
					<?php endif; ?>