Exemplo n.º 1
0
 function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     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 variables
     $is_ingroup = !empty($field->ingroup);
     $use_ingroup = $field->parameters->get('use_ingroup', 0);
     $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
     // Value handling parameters
     $lang_filter_values = 0;
     //$field->parameters->get( 'lang_filter_values', 1);
     // 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"' : '';
     // URL value
     $link_usage = $field->parameters->get('link_usage', 0);
     $default_link = $link_usage == 2 ? $field->parameters->get('default_value_link', '') : '';
     $default_link = $default_link ? JText::_($default_link) : '';
     // URL title & linking text (optional)
     $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', '')) : '';
     $default_title = $default_title ? JText::_($default_title) : '';
     // Get field values
     $values = $values ? $values : $field->value;
     // Check for no values and no default value, and return empty display
     if (empty($values)) {
         if (!strlen($default_link)) {
             $field->{$prop} = $is_ingroup ? array() : '';
             return;
         }
         $values = array();
         $values[0]['link'] = $default_link;
         $values[0]['title'] = $default_title;
         $values[0]['hits'] = 0;
         $values[0] = serialize($values[0]);
     }
     $unserialize_vals = true;
     if ($unserialize_vals) {
         // (* BECAUSE OF THIS, the value display loop expects unserialized values)
         foreach ($values as &$value) {
             // Compatibility for unserialized values or for NULL values in a field group
             if (!is_array($value)) {
                 $v = !empty($value) ? @unserialize($value) : false;
                 $value = $v !== false || $v === 'b:0;' ? $v : array('link' => $value, 'title' => '', 'hits' => 0);
             }
         }
         unset($value);
         // Unset this or you are looking for trouble !!!, because it is a reference and reusing it will overwrite the pointed variable !!!
     }
     // 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;
     }
     // Get layout name
     $viewlayout = $field->parameters->get('viewlayout', '');
     $viewlayout = $viewlayout ? 'value_' . $viewlayout : 'value_default';
     // Create field's HTML, using layout file
     $field->{$prop} = array();
     //$this->values = $values;
     //$this->displayFieldValue( $prop, $viewlayout );
     include self::getFormPath($this->fieldtypes[0], $viewlayout);
     // Do not convert the array to string if field is in a group, and do not add: FIELD's opetag, closetag, value separator
     if (!$is_ingroup) {
         // Apply values separator
         $field->{$prop} = implode($separatorf, $field->{$prop});
         if ($field->{$prop} !== '') {
             // Apply field 's opening / closing texts
             $field->{$prop} = $opentag . $field->{$prop} . $closetag;
         }
     }
 }
Exemplo n.º 2
0
    function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
    {
        if (!in_array($field->field_type, self::$field_types)) {
            return;
        }
        $field->label = JText::_($field->label);
        // Some variables
        $is_ingroup = !empty($field->ingroup);
        $use_ingroup = $field->parameters->get('use_ingroup', 0);
        $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
        $image_source = $field->parameters->get('image_source', 0);
        // ***********************
        // One time initialization
        // ***********************
        static $initialized = null;
        static $app, $document, $option;
        static $isMobile, $isTablet, $useMobile;
        if ($initialized === null) {
            $app = JFactory::getApplication();
            $document = JFactory::getDocument();
            $option = JRequest::getVar('option');
            jimport('joomla.filesystem');
            // *****************************
            // Get isMobile / isTablet Flags
            // *****************************
            $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);
        }
        // **********************************************
        // Static FLAGS indicating if JS libs were loaded
        // **********************************************
        static $multiboxadded = false;
        static $fancyboxadded = false;
        static $gallerifficadded = false;
        static $elastislideadded = false;
        static $photoswipeadded = false;
        // *****************************
        // Current view variable / FLAGs
        // *****************************
        $realview = JRequest::getVar('view', FLEXI_ITEMVIEW);
        $view = JRequest::getVar('flexi_callview', $realview);
        $isFeedView = JRequest::getCmd('format', null) == 'feed';
        $isItemsManager = $app->isAdmin() && $realview == 'items' && $option == 'com_flexicontent';
        $isSite = $app->isSite();
        // *************************************************
        // TODO:  implement MODES >= 2, and remove this CODE
        // *************************************************
        if ($image_source > 1) {
            global $fc_folder_mode_err;
            if (empty($fc_folder_mode_err[$field->id])) {
                echo __FUNCTION__ . "(): folder-mode: " . $image_source . " not implemented please change image-source mode in image/gallery field with id: " . $field->id;
                $fc_folder_mode_err[$field->id] = 1;
                $image_source = 1;
            }
        }
        $all_media = $field->parameters->get('list_all_media_files', 0);
        $unique_thumb_method = $field->parameters->get('unique_thumb_method', 0);
        $dir = $field->parameters->get('dir');
        $dir_url = str_replace('\\', '/', $dir);
        // Check if using folder of original content being translated
        $of_usage = $field->untranslatable ? 1 : $field->parameters->get('of_usage', 0);
        $u_item_id = $of_usage && $item->lang_parent_id && $item->lang_parent_id != $item->id ? $item->lang_parent_id : $item->id;
        // FLAG to indicate if images are shared across fields, has the effect of adding field id to image thumbnails
        $multiple_image_usages = !$image_source && $all_media && $unique_thumb_method == 0;
        $extra_prefix = $multiple_image_usages ? 'fld' . $field->id . '_' : '';
        $usealt = $field->parameters->get('use_alt', 1);
        $alt_usage = $field->parameters->get('alt_usage', 0);
        $default_alt = $alt_usage == 2 ? $field->parameters->get('default_alt', '') : '';
        $usetitle = $field->parameters->get('use_title', 1);
        $title_usage = $field->parameters->get('title_usage', 0);
        $default_title = $title_usage == 2 ? JText::_($field->parameters->get('default_title', '')) : '';
        $usedesc = $field->parameters->get('use_desc', 1);
        $desc_usage = $field->parameters->get('desc_usage', 0);
        $default_desc = $desc_usage == 2 ? $field->parameters->get('default_desc', '') : '';
        $usecust1 = $field->parameters->get('use_cust1', 0);
        $cust1_usage = $field->parameters->get('cust1_usage', 0);
        $default_cust1 = $cust1_usage == 2 ? JText::_($field->parameters->get('default_cust1', '')) : '';
        $usecust2 = $field->parameters->get('use_cust2', 0);
        $cust2_usage = $field->parameters->get('cust2_usage', 0);
        $default_cust2 = $cust2_usage == 2 ? JText::_($field->parameters->get('default_cust2', '')) : '';
        // Separators / enclosing characters
        $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', 0);
        $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;
        }
        // **************************************************
        // SETUP VALUES: retrieve, verify, load defaults, etc
        // **************************************************
        $values = $values ? $values : $field->value;
        // Intro-full mode get their values from item's parameters
        if ($image_source == -1) {
            $values = array();
            $_image_name = $view == 'item' ? 'fulltext' : 'intro';
            if ($item->images) {
                if (!is_object($item->images)) {
                    $item->images = new JRegistry($item->images);
                }
                //echo "<pre>"; print_r($item->images); echo "</pre>";
                $_image_path = $item->images->get('image_' . $_image_name, '');
                $image_by_params = array();
                // field attributes (mode-specific)
                $image_by_params['image_size'] = $_image_name;
                $image_by_params['image_path'] = $_image_path;
                // field attributes (value)
                $image_by_params['originalname'] = basename($_image_path);
                $image_by_params['alt'] = $item->images->get('image_' . $_image_name . '_alt', '');
                $image_by_params['title'] = $item->images->get('image_' . $_image_name . '_alt', '');
                $image_by_params['desc'] = $item->images->get('image_' . $_image_name . '_caption', '');
                $image_by_params['cust1'] = '';
                $image_by_params['cust2'] = '';
                $image_by_params['urllink'] = '';
                $values = array(serialize($image_by_params));
                //echo "<pre>"; print_r($image_by_params); echo "</pre>"; exit;
            }
        }
        // Check for deleted image files or image files that cannot be thumbnailed,
        // rebuilding thumbnails as needed, and then assigning checked values to a new array
        $usable_values = array();
        if ($values) {
            foreach ($values as $index => $value) {
                $value = unserialize($value);
                if (plgFlexicontent_fieldsImage::rebuildThumbs($field, $value, $item)) {
                    $usable_values[] = $values[$index];
                }
            }
        }
        $values =& $usable_values;
        // Allow for thumbnailing of the default image
        $field->using_default_value = false;
        if (!count($values)) {
            // Create default image to be used if  (a) no image assigned  OR  (b) images assigned have been deleted
            $default_image = $field->parameters->get('default_image', '');
            if ($default_image) {
                $default_image_val = array();
                // field attributes (default value specific)
                $default_image_val['default_image'] = $default_image;
                // holds complete relative path and indicates that it is default image for field
                // field attributes (value)
                $default_image_val['originalname'] = basename($default_image);
                $default_image_val['alt'] = $default_alt;
                $default_image_val['title'] = $default_title;
                $default_image_val['desc'] = $default_desc;
                $default_image_val['cust1'] = $default_cust1;
                $default_image_val['cust2'] = $default_cust2;
                $default_image_val['urllink'] = '';
                // Create thumbnails for default image
                if (plgFlexicontent_fieldsImage::rebuildThumbs($field, $default_image_val, $item)) {
                    $values = array(serialize($default_image_val));
                }
                // Also default image can (possibly) be used across multiple fields, so set flag to add field id to filenames of thumbnails
                $multiple_image_usages = true;
                $extra_prefix = 'fld' . $field->id . '_';
                $field->using_default_value = true;
            }
        }
        // *********************************************
        // Check for no values, and return empty display
        // *********************************************
        if (!count($values)) {
            $field->{$prop} = $is_ingroup ? array() : '';
            return;
        }
        // Assign (possibly) altered value array to back to the field
        $field->value = $values;
        // This is not done for onDisplayFieldValue, TODO check if this is needed
        // **************************************
        // Default display method depends on view
        // **************************************
        if ($prop == 'display' && ($view == FLEXI_ITEMVIEW || $view == 'category')) {
            $_method = $view == FLEXI_ITEMVIEW ? $field->parameters->get('default_method_item', 'display') : $field->parameters->get('default_method_cat', 'display_single_total');
        } else {
            $_method = $prop;
        }
        $cat_link_single_to = $field->parameters->get('cat_link_single_to', 1);
        // Calculate some flags, SINGLE image display and Link-to-Item FLAG
        $isSingle = isset(self::$single_displays[$_method]);
        $linkToItem = $_method == 'display_link' || $_method == 'display_single_link' || $_method == 'display_single_total_link' || $view != 'item' && $cat_link_single_to && $isSingle;
        // ************************
        // JS gallery configuration
        // ************************
        $usepopup = (int) $field->parameters->get('usepopup', 1);
        // use JS gallery
        $popuptype = (int) $field->parameters->get('popuptype', 1);
        // JS gallery type
        // Different for mobile clients
        $popuptype_mobile = (int) $field->parameters->get('popuptype_mobile', $popuptype);
        // this defaults to desktop when empty
        $popuptype = $useMobile ? $popuptype_mobile : $popuptype;
        // Enable/Disable GALLERY JS according to current view and according to other parameters
        $popupinview = $field->parameters->get('popupinview', array(FLEXI_ITEMVIEW, 'category', 'backend'));
        $popupinview = FLEXIUtilities::paramToArray($popupinview);
        if ($view == FLEXI_ITEMVIEW && !in_array(FLEXI_ITEMVIEW, $popupinview)) {
            $usepopup = 0;
        }
        if ($view == 'category' && !in_array('category', $popupinview)) {
            $usepopup = 0;
        }
        if ($view == 'module' && !in_array('module', $popupinview)) {
            $usepopup = 0;
        }
        if ($isItemsManager && !in_array('backend', $popupinview)) {
            $usepopup = 0;
        }
        // Enable/Disable GALLERY JS if linking to item view
        if ($linkToItem) {
            $usepopup = 0;
        }
        // Only allow multibox and fancybox in items manager, in other cases force fancybox
        if ($isItemsManager && !in_array($popuptype, array(1, 4))) {
            $popuptype = 4;
        }
        // Displays that need special container are not allowed when field in a group, force fancybox
        $no_container_needed = array(1, 2, 3, 4, 6);
        if ($is_ingroup && !in_array($popuptype, $no_container_needed)) {
            $popuptype = 4;
        }
        // Optionally group images from all image fields of current item ... or of all items in view too
        $grouptype = $field->parameters->get('grouptype', 1);
        $grouptype = $multiple ? 0 : $grouptype;
        // Field in gallery mode: Force grouping of images per field (current item)
        // Needed by some js galleries
        $thumb_w_s = $field->parameters->get('w_s', 120);
        $thumb_h_s = $field->parameters->get('h_s', 90);
        // ******************************
        // Hovering ToolTip configuration
        // ******************************
        $uselegend = $field->parameters->get('uselegend', 1);
        $tip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip';
        // Enable/disable according to current view
        $legendinview = $field->parameters->get('legendinview', array(FLEXI_ITEMVIEW, 'category'));
        $legendinview = FLEXIUtilities::paramToArray($legendinview);
        if ($view == FLEXI_ITEMVIEW && !in_array(FLEXI_ITEMVIEW, $legendinview)) {
            $uselegend = 0;
        }
        if ($view == 'category' && !in_array('category', $legendinview)) {
            $uselegend = 0;
        }
        if ($isItemsManager && !in_array('backend', $legendinview)) {
            $uselegend = 0;
        }
        // load the tooltip library if required
        if ($uselegend && !FLEXI_J30GE) {
            JHTML::_('behavior.tooltip');
        }
        // **************************************
        // Title/Description in inline thumbnails
        // **************************************
        $showtitle = $field->parameters->get('showtitle', 0);
        $showdesc = $field->parameters->get('showdesc', 0);
        // *************************
        // Link to URL configuration
        // *************************
        $linkto_url = $field->parameters->get('linkto_url', 0);
        $url_target = $field->parameters->get('url_target', '_self');
        $isLinkToPopup = $linkto_url && ($url_target == 'multibox' || $url_target == 'fancybox');
        // Force opening in new window in backend, if URL target is _self
        if ($isItemsManager && $url_target == '_self') {
            $url_target = "_blank";
        }
        // Only allow multibox (and TODO: add fancybox) when linking to URL, in other cases force fancybox
        if ($isLinkToPopup && $url_target == 'multibox') {
            $popuptype = 1;
        }
        if ($isLinkToPopup && $url_target == 'fancybox') {
            $popuptype = 4;
        } else {
            if ($linkto_url) {
                $usepopup = 0;
            }
        }
        // ************************************
        // Social website sharing configuration
        // ************************************
        $useogp = $field->parameters->get('useogp', 0);
        $ogpinview = $field->parameters->get('ogpinview', array());
        $ogpinview = FLEXIUtilities::paramToArray($ogpinview);
        $ogpthumbsize = $field->parameters->get('ogpthumbsize', 2);
        // **********************************************
        // Load the configured (or the forced) JS gallery
        // **********************************************
        // Do not load JS, for value only displays
        if (!isset(self::$value_only_displays[$prop])) {
            // MultiBox maybe added in extra cases besides popup
            // (a) in Item manager, (b) When linking to URL in popup target
            $view_allows_mb = $isItemsManager || $isSite && !$isFeedView;
            $config_needs_mb = $isLinkToPopup || $usepopup && $popuptype == 1;
            if ($view_allows_mb && $config_needs_mb) {
                if (!$multiboxadded) {
                    flexicontent_html::loadFramework('jmultibox');
                    //echo $field->name.": multiboxadded";
                    $js = "\n\t\t\t\t\twindow.addEvent('domready', function(){\n\t\t\t\t\t\tjQuery('a.mb').jmultibox({\n\t\t\t\t\t\t\tinitialWidth: 250,  //(number) the width of the box when it first opens while loading the item. Default: 250\n\t\t\t\t\t\t\tinitialHeight: 250, //(number) the width of the box when it first opens while loading the item. Default: 250\n\t\t\t\t\t\t\tcontainer: document.body, //(element) the element that the box will take it coordinates from. Default: document.body\n\t\t\t\t\t\t\tcontentColor: '#000', //(string) the color of the content area inside the box. Default: #000\n\t\t\t\t\t\t\tshowNumbers: " . ($isItemsManager ? 'false' : 'true') . ",    //(boolean) show the number of the item e.g. 2/10. Default: true\n\t\t\t\t\t\t\tshowControls: " . ($isItemsManager ? 'false' : 'true') . ",   //(boolean) show the navigation controls. Default: true\n\t\t\t\t\t\t\tdescClassName: 'multiBoxDesc',  //(string) the classname of the divs that contain the description for the item. Default: false\n\t\t\t\t\t\t\tdescMinWidth: 400,     //(number) the min width of the description text, useful when the item is small. Default: 400\n\t\t\t\t\t\t\tdescMaxWidth: 600,     //(number) the max width of the description text, so it can wrap to multiple lines instead of being on a long single line. Useful when the item is large. Default: 600\n\t\t\t\t\t\t\tmovieWidth: 576,    //(number) the default width of the box that contains content of a movie type. Default: 576\n\t\t\t\t\t\t\tmovieHeight: 324,   //(number) the default height of the box that contains content of a movie type. Default: 324\n\t\t\t\t\t\t\toffset: {x: 0, y: 0},  //(object) containing x & y coords that adjust the positioning of the box. Default: {x:0, y:0}\n\t\t\t\t\t\t\tfixedTop: false,       //(number) gives the box a fixed top position relative to the container. Default: false\n\t\t\t\t\t\t\tpath: '',            //(string) location of the resources files, e.g. flv player, etc. Default: ''\n\t\t\t\t\t\t\topenFromLink: true,  //(boolean) opens the box relative to the link location. Default: true\n\t\t\t\t\t\t\topac:0.7,            //(decimal) overlay opacity Default: 0.7\n\t\t\t\t\t\t\tuseOverlay:false,    //(boolean) use a semi-transparent background. Default: false\n\t\t\t\t\t\t\toverlaybg:'01.png',  //(string) overlay image in 'overlays' folder. Default: '01.png'\n\t\t\t\t\t\t\tonOpen:function(){},   //(object) a function to call when the box opens. Default: function(){} \n\t\t\t\t\t\t\tonClose:function(){},  //(object) a function to call when the box closes. Default: function(){} \n\t\t\t\t\t\t\teasing:'swing',        //(string) effect of jQuery Default: 'swing'\n\t\t\t\t\t\t\tuseratio:false,        //(boolean) windows size follows ratio. (iframe or Youtube) Default: false\n\t\t\t\t\t\t\tratio:'90'             //(number) window ratio Default: '90'\n\t\t\t\t\t\t});\n\t\t\t\t\t})";
                    $document->addScriptDeclaration($js);
                    $multiboxadded = true;
                }
            }
            // Regardless if above has added multibox , we will add a different JS gallery if so configured because it maybe needed
            if (!$isSite || $isFeedView) {
                // Is backend OR it is a feed view, do not add any JS library
            } else {
                if ($usepopup) {
                    switch ($popuptype) {
                        // Add Fancybox image popup
                        case 4:
                            if (!$fancyboxadded) {
                                $fancyboxadded = true;
                                flexicontent_html::loadFramework('fancybox');
                            }
                            break;
                            // Add Galleriffic inline slideshow gallery
                        // Add Galleriffic inline slideshow gallery
                        case 5:
                            $inline_gallery = 1;
                            // unused
                            if (!$gallerifficadded) {
                                flexicontent_html::loadFramework('galleriffic');
                                $gallerifficadded = true;
                                $js = "\n\t\t\t\t\t\t//document.write('<style>.noscript { display: none; }</style>');\n\t\t\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\t\t// We only want these styles applied when javascript is enabled\n\t\t\t\t\t\t\tjQuery('div.navigation').css({'width' : '150px', 'float' : 'left'});\n\t\t\t\t\t\t\tjQuery('div.content').css({'display' : 'inline-block', 'float' : 'none'});\n\t\t\t\n\t\t\t\t\t\t\t// Initially set opacity on thumbs and add\n\t\t\t\t\t\t\t// additional styling for hover effect on thumbs\n\t\t\t\t\t\t\tvar onMouseOutOpacity = 0.67;\n\t\t\t\t\t\t\tjQuery('#gf_thumbs ul.thumbs li').opacityrollover({\n\t\t\t\t\t\t\t\tmouseOutOpacity:   onMouseOutOpacity,\n\t\t\t\t\t\t\t\tmouseOverOpacity:  1.0,\n\t\t\t\t\t\t\t\tfadeSpeed:         'fast',\n\t\t\t\t\t\t\t\texemptionSelector: '.selected'\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Initialize Advanced Galleriffic Gallery\n\t\t\t\t\t\t\tjQuery('#gf_thumbs').galleriffic({\n\t\t\t\t\t\t\t\t/*enableFancybox: true,*/\n\t\t\t\t\t\t\t\tdelay:                     2500,\n\t\t\t\t\t\t\t\tnumThumbs:                 4,\n\t\t\t\t\t\t\t\tpreloadAhead:              10,\n\t\t\t\t\t\t\t\tenableTopPager:            true,\n\t\t\t\t\t\t\t\tenableBottomPager:         true,\n\t\t\t\t\t\t\t\tmaxPagesToShow:            20,\n\t\t\t\t\t\t\t\timageContainerSel:         '#gf_slideshow',\n\t\t\t\t\t\t\t\tcontrolsContainerSel:      '#gf_controls',\n\t\t\t\t\t\t\t\tcaptionContainerSel:       '#gf_caption',\n\t\t\t\t\t\t\t\tloadingContainerSel:       '#gf_loading',\n\t\t\t\t\t\t\t\trenderSSControls:          true,\n\t\t\t\t\t\t\t\trenderNavControls:         true,\n\t\t\t\t\t\t\t\tplayLinkText:              'Play Slideshow',\n\t\t\t\t\t\t\t\tpauseLinkText:             'Pause Slideshow',\n\t\t\t\t\t\t\t\tprevLinkText:              '&lsaquo; Previous Photo',\n\t\t\t\t\t\t\t\tnextLinkText:              'Next Photo &rsaquo;',\n\t\t\t\t\t\t\t\tnextPageLinkText:          'Next &rsaquo;',\n\t\t\t\t\t\t\t\tprevPageLinkText:          '&lsaquo; Prev',\n\t\t\t\t\t\t\t\tenableHistory:             false,\n\t\t\t\t\t\t\t\tautoStart:                 false,\n\t\t\t\t\t\t\t\tsyncTransitions:           true,\n\t\t\t\t\t\t\t\tdefaultTransitionDuration: 900,\n\t\t\t\t\t\t\t\tonSlideChange:             function(prevIndex, nextIndex) {\n\t\t\t\t\t\t\t\t\t// 'this' refers to the gallery, which is an extension of jQuery('#gf_thumbs')\n\t\t\t\t\t\t\t\t\tthis.find('ul.thumbs').children()\n\t\t\t\t\t\t\t\t\t\t.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()\n\t\t\t\t\t\t\t\t\t\t.eq(nextIndex).fadeTo('fast', 1.0);\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tonPageTransitionOut:       function(callback) {\n\t\t\t\t\t\t\t\t\tthis.fadeTo('fast', 0.0, callback);\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tonPageTransitionIn:        function() {\n\t\t\t\t\t\t\t\t\tthis.fadeTo('fast', 1.0);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\t";
                                $document->addScriptDeclaration($js);
                            }
                            break;
                            // Add Elastislide inline carousel gallery (Responsive image gallery with togglable thumbnail-strip, plus previewer and description)
                        // Add Elastislide inline carousel gallery (Responsive image gallery with togglable thumbnail-strip, plus previewer and description)
                        case 7:
                            if (!$elastislideadded) {
                                flexicontent_html::loadFramework('elastislide');
                                $elastislideadded = true;
                            }
                            $uid = 'es_' . $field->name . "_fcitem" . $item->id;
                            $js = file_get_contents(JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'librairies' . DS . 'elastislide' . DS . 'js' . DS . 'gallery_tmpl.js');
                            $js = str_replace('unique_gal_id', $uid, $js);
                            $js = str_replace('__thumb_width__', $field->parameters->get('w_s', 120), $js);
                            $document->addScriptDeclaration($js);
                            $document->addCustomTag('
					<script id="img-wrapper-tmpl_' . $uid . '" type="text/x-jquery-tmpl">	
						<div class="rg-image-wrapper">
							{{if itemsCount > 1}}
								<div class="rg-image-nav">
									<a href="#" class="rg-image-nav-prev">' . JText::_('FLEXI_PREVIOUS') . '</a>
									<a href="#" class="rg-image-nav-next">' . JText::_('FLEXI_NEXT') . '</a>
								</div>
							{{/if}}
							<div class="rg-image"></div>
							<div class="rg-loading"></div>
							<div class="rg-caption-wrapper">
								<div class="rg-caption" style="display:none;">
									<p></p>
								</div>
							</div>
						</div>
					</script>
					');
                            break;
                            // Add PhotoSwipe popup carousel gallery
                        // Add PhotoSwipe popup carousel gallery
                        case 8:
                            if (!$photoswipeadded) {
                                flexicontent_html::loadFramework('photoswipe');
                                $photoswipeadded = true;
                            }
                            break;
                    }
                }
            }
        }
        // *******************************
        // Prepare for value handling loop
        // *******************************
        // Extra thumbnails sub-folder for various
        if ($field->using_default_value) {
            $extra_folder = '';
            // default value
        } else {
            if ($image_source == -1) {
                $extra_folder = 'intro_full';
                // intro-full images mode
            } else {
                if ($image_source > 0) {
                    $extra_folder = 'item_' . $u_item_id . '_field_' . $field->id;
                    // folder-mode 1
                    if ($image_source > 1) {
                    }
                    // TODO
                } else {
                    $extra_folder = '';
                    // db-mode
                }
            }
        }
        // Create thumbs/image Folder and URL paths
        $thumb_folder = JPATH_SITE . DS . JPath::clean($dir . ($extra_folder ? DS . $extra_folder : ''));
        $thumb_urlpath = $dir_url . ($extra_folder ? '/' . $extra_folder : '');
        if ($field->using_default_value) {
            // default image of this field, these are relative paths up to site root
            $orig_urlpath = str_replace('\\', '/', dirname($default_image_val['default_image']));
        } else {
            if ($image_source == -1) {
                // intro-full image values, these are relative paths up to the site root, must be calculated later !!
                $orig_urlpath = str_replace('\\', '/', dirname($image_by_params['image_path']));
            } else {
                if ($image_source > 0) {
                    // various folder-mode(s)
                    $orig_urlpath = $thumb_urlpath . '/original';
                } else {
                    // db-mode
                    $cparams = JComponentHelper::getParams('com_flexicontent');
                    $orig_urlpath = str_replace('\\', '/', JPath::clean($cparams->get('file_path', 'components/com_flexicontent/uploads')));
                }
            }
        }
        // Initialize value handling arrays and loop's common variables
        $i = -1;
        $field->{$prop} = array();
        $field->thumbs_src['backend'] = array();
        $field->thumbs_src['small'] = array();
        $field->thumbs_src['medium'] = array();
        $field->thumbs_src['large'] = array();
        $field->thumbs_src['original'] = array();
        $field->{"display_backend_src"} = array();
        $field->{"display_small_src"} = array();
        $field->{"display_medium_src"} = array();
        $field->{"display_large_src"} = array();
        $field->{"display_original_src"} = array();
        $cust1_label = JText::_('FLEXI_FIELD_IMG_CUST1');
        $cust2_label = JText::_('FLEXI_FIELD_IMG_CUST2');
        // Decide thumbnail to use
        $thumb_size = 0;
        if ($isItemsManager) {
            $thumb_size = -1;
        } else {
            if ($view == 'category') {
                $thumb_size = $field->parameters->get('thumbincatview', 1);
            } else {
                if ($view == FLEXI_ITEMVIEW) {
                    $thumb_size = $field->parameters->get('thumbinitemview', 2);
                }
            }
        }
        // ***************
        // The values loop
        // ***************
        foreach ($values as $val) {
            // Unserialize value's properties and check for empty original name property
            $value = unserialize($val);
            $image_name = trim(@$value['originalname']);
            if (!strlen($image_name)) {
                if ($is_ingroup) {
                    $field->{$prop}[] = '';
                }
                // add empty position to the display array
                continue;
            }
            $i++;
            // Create thumbnails urls, note thumbnails have already been verified above
            $wl = $field->parameters->get('w_l', 800);
            $hl = $field->parameters->get('h_l', 600);
            // Optional properties
            $title = $usetitle && @$value['title'] ? $value['title'] : '';
            $alt = $usealt && @$value['alt'] ? $value['alt'] : flexicontent_html::striptagsandcut($item->title, 60);
            $desc = $usedesc && @$value['desc'] ? $value['desc'] : '';
            // Optional custom properties
            $cust1 = $usecust1 && @$value['cust1'] ? $value['cust1'] : '';
            $desc .= $cust1 ? $cust1_label . ': ' . $cust1 : '';
            // ... Append custom properties to description
            $cust2 = $usecust2 && @$value['cust2'] ? $value['cust2'] : '';
            $desc .= $cust2 ? $cust2_label . ': ' . $cust2 : '';
            // ... Append custom properties to description
            // HTML encode output
            $title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8');
            $alt = htmlspecialchars($alt, ENT_COMPAT, 'UTF-8');
            $desc = htmlspecialchars($desc, ENT_COMPAT, 'UTF-8');
            $srcb = $thumb_urlpath . '/b_' . $extra_prefix . $image_name;
            // backend
            $srcs = $thumb_urlpath . '/s_' . $extra_prefix . $image_name;
            // small
            $srcm = $thumb_urlpath . '/m_' . $extra_prefix . $image_name;
            // medium
            $srcl = $thumb_urlpath . '/l_' . $extra_prefix . $image_name;
            // large
            $srco = $orig_urlpath . '/' . $image_name;
            // original image
            // Create a popup url link
            $urllink = @$value['urllink'] ? $value['urllink'] : '';
            if ($urllink && false === strpos($urllink, '://')) {
                $urllink = 'http://' . $urllink;
            }
            // Create a popup tooltip (legend)
            $class = 'fc_field_image';
            if ($uselegend && (!empty($title) || !empty($desc))) {
                $class .= $tip_class;
                $legend = ' title="' . flexicontent_html::getToolTip($title, $desc, 0, 1) . '"';
            } else {
                $legend = '';
            }
            // Handle single image display, with/without total, TODO: verify all JS handle & ignore display none on the img TAG
            $style = $i != 0 && $isSingle ? 'display:none;' : '';
            // Create a unique id for the link tags, and a class name for image tags
            $uniqueid = $item->id . '_' . $field->id . '_' . $i;
            switch ($thumb_size) {
                case -1:
                    $src = $srcb;
                    break;
                case 1:
                    $src = $srcs;
                    break;
                case 2:
                    $src = $srcm;
                    break;
                case 3:
                    $src = $srcl;
                    break;
                    // this makes little sense, since both thumbnail and popup image are size 'large'
                // this makes little sense, since both thumbnail and popup image are size 'large'
                case 4:
                    $src = $srco;
                    break;
                default:
                    $src = $srcs;
                    break;
            }
            // Create a grouping name
            switch ($grouptype) {
                case 0:
                    $group_name = 'fcview_' . $view . '_fcitem_' . $item->id . '_fcfield_' . $field->id;
                    break;
                case 1:
                    $group_name = 'fcview_' . $view . '_fcitem_' . $item->id;
                    break;
                case 2:
                    $group_name = 'fcview_' . $view;
                    break;
                default:
                    $group_name = '';
                    break;
            }
            // ADD some extra (display) properties that point to all sizes, currently SINGLE IMAGE only
            if ($is_ingroup) {
                // In case of field displayed via in fieldgroup, this is an array
                $field->{"display_backend_src"}[] = JURI::root(true) . '/' . $srcb;
                $field->{"display_small_src"}[] = JURI::root(true) . '/' . $srcs;
                $field->{"display_medium_src"}[] = JURI::root(true) . '/' . $srcm;
                $field->{"display_large_src"}[] = JURI::root(true) . '/' . $srcl;
                $field->{"display_original_src"}[] = JURI::root(true) . '/' . $srco;
            } else {
                if ($i == 0) {
                    // Field displayed not via fieldgroup return only the 1st value
                    $field->{"display_backend_src"} = JURI::root(true) . '/' . $srcb;
                    $field->{"display_small_src"} = JURI::root(true) . '/' . $srcs;
                    $field->{"display_medium_src"} = JURI::root(true) . '/' . $srcm;
                    $field->{"display_large_src"} = JURI::root(true) . '/' . $srcl;
                    $field->{"display_original_src"} = JURI::root(true) . '/' . $srco;
                }
            }
            $field->thumbs_src['backend'][] = JURI::root(true) . '/' . $srcb;
            $field->thumbs_src['small'][] = JURI::root(true) . '/' . $srcs;
            $field->thumbs_src['medium'][] = JURI::root(true) . '/' . $srcm;
            $field->thumbs_src['large'][] = JURI::root(true) . '/' . $srcl;
            $field->thumbs_src['original'][] = JURI::root(true) . '/' . $srco;
            $field->thumbs_path['backend'][] = JPATH_SITE . DS . $srcb;
            $field->thumbs_path['small'][] = JPATH_SITE . DS . $srcs;
            $field->thumbs_path['medium'][] = JPATH_SITE . DS . $srcm;
            $field->thumbs_path['large'][] = JPATH_SITE . DS . $srcl;
            $field->thumbs_path['original'][] = JPATH_SITE . DS . $srco;
            // Suggest image for external use, e.g. for Facebook etc
            if ($isSite && !$isFeedView && $useogp) {
                if (in_array($view, $ogpinview)) {
                    switch ($ogpthumbsize) {
                        case 1:
                            $ogp_src = $field->thumbs_src['small'][$i];
                            break;
                            // this maybe problematic, since it maybe too small or not accepted by social website
                        // this maybe problematic, since it maybe too small or not accepted by social website
                        case 2:
                            $ogp_src = $field->thumbs_src['medium'][$i];
                            break;
                        case 3:
                            $ogp_src = $field->thumbs_src['large'][$i];
                            break;
                        case 4:
                            $ogp_src = $field->thumbs_src['original'][$i];
                            break;
                        default:
                            $ogp_src = $field->thumbs_src['medium'][$i];
                            break;
                    }
                    $document->addCustomTag('<link rel="image_src" href="' . $ogp_src . '" />');
                    $document->addCustomTag('<meta property="og:image" content="' . $ogp_src . '" />');
                }
            }
            // ****************************************************************
            // CHECK if we were asked for value only display (e.g. image source)
            // if so we will not be creating the HTML code for Image / Gallery
            // ****************************************************************
            if (isset(self::$value_only_displays[$prop])) {
                continue;
            }
            // *********************************************************
            // Create image tags (according to configuration parameters)
            // that will be used for the requested 'display' variable
            // *********************************************************
            switch ($prop) {
                case 'display_backend':
                    $img_legend = '<img src="' . JURI::root(true) . '/' . $srcb . '" alt="' . $alt . '"' . $legend . ' class="' . $class . '" itemprop="image"/>';
                    $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcb . '" alt="' . $alt . '" class="' . $class . '" itemprop="image"/>';
                    break;
                case 'display_small':
                    $img_legend = '<img src="' . JURI::root(true) . '/' . $srcs . '" alt="' . $alt . '"' . $legend . ' class="' . $class . '" itemprop="image"/>';
                    $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcs . '" alt="' . $alt . '" class="' . $class . '" itemprop="image"/>';
                    break;
                case 'display_medium':
                    $img_legend = '<img src="' . JURI::root(true) . '/' . $srcm . '" alt="' . $alt . '"' . $legend . ' class="' . $class . '" itemprop="image"/>';
                    $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcm . '" alt="' . $alt . '" class="' . $class . '" itemprop="image"/>';
                    break;
                case 'display_large':
                    $img_legend = '<img src="' . JURI::root(true) . '/' . $srcl . '" alt="' . $alt . '"' . $legend . ' class="' . $class . '" itemprop="image"/>';
                    $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcl . '" alt="' . $alt . '" class="' . $class . '" itemprop="image"/>';
                    break;
                case 'display_original':
                    $img_legend = '<img src="' . JURI::root(true) . '/' . $srco . '" alt="' . $alt . '"' . $legend . ' class="' . $class . '" itemprop="image"/>';
                    $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srco . '" alt="' . $alt . '" class="' . $class . '" itemprop="image"/>';
                    break;
                case 'display':
                default:
                    $img_legend = '<img src="' . JURI::root(true) . '/' . $src . '" alt="' . $alt . '"' . $legend . ' class="' . $class . '" itemprop="image"/>';
                    $img_nolegend = '<img src="' . JURI::root(true) . '/' . $src . '" alt="' . $alt . '" class="' . $class . '" itemprop="image"/>';
                    break;
            }
            // *************************************************
            // Create thumbnail appending text (not linked text)
            // *************************************************
            // For galleries that are not inline/special, we can have inline text ??
            $inline_info = '';
            if ($linkto_url || ($prop == 'display_large' || $prop == 'display_original') || !$usepopup || $popuptype != 5 && $popuptype != 7) {
                // Add inline display of title/desc
                if ($showtitle && $title || $showdesc && $desc) {
                    $inline_info = '<div class="fc_img_tooltip_data alert alert-info" style="' . $style . '" >';
                }
                if ($showtitle && $title) {
                    $inline_info .= '<div class="fc_img_tooltip_title" style="line-height:1em; font-weight:bold;">' . $title . '</div>';
                }
                if ($showdesc && $desc) {
                    $inline_info .= '<div class="fc_img_tooltip_desc" style="line-height:1em;">' . $desc . '</div>';
                }
                if ($showtitle && $title || $showdesc && $desc) {
                    $inline_info .= '</div>';
                }
            }
            // *********************************************
            // FINALLY CREATE the field display variable ...
            // *********************************************
            if ($linkToItem) {
                // CASE 0: Add single image display information (e.g. image count)
                $item_link = JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $item->categoryslug, 0, $item));
                $field->{$prop}[] = '<span style="display: inline-block; text-align:center; ">
					<a href="' . $item_link . '" style="display: inline-block;">
					' . $img_nolegend . '
					</a><br/>' . ($_method == 'display_single_total' || $_method == 'display_single_total_link' ? '
					<span class="fc_img_total_data badge badge-info" style="display: inline-block;" >
						' . count($values) . ' ' . JText::_('FLEXI_IMAGES') . '
					</span>' : '') . '
				</span>';
                // If single display and not in field group then do not add more images
                if (!$is_ingroup && $isSingle) {
                    break;
                }
            } else {
                if ($linkto_url) {
                    // CASE 1: Handle linking to a URL instead of image zooming popup
                    if (!$urllink) {
                        // CASE: Just image thumbnail since url link is empty
                        $field->{$prop}[] = $pretext . '<div class="fc_img_container">' . $img_legend . $inline_info . '</div>' . $posttext;
                    } else {
                        if ($url_target == 'multibox') {
                            // CASE: Link to URL that opens inside a popup via multibox
                            $field->{$prop}[] = $pretext . '
					<script>document.write(\'<a style="' . $style . '" href="' . $urllink . '" id="mb' . $uniqueid . '" class="mb" rel="width:\'+(jQuery(window).width()-150)+\',height:\'+(jQuery(window).height()-150)+\'">\')</script>
						' . $img_legend . '
					<script>document.write(\'</a>\')</script>
					<div class="multiBoxDesc mbox_img_url mb' . $uniqueid . '">' . ($desc ? $desc : $title) . '</div>
					' . $inline_info . $posttext;
                        } else {
                            if ($url_target == 'fancybox') {
                                // CASE: Link to URL that opens inside a popup via fancybox
                                $field->{$prop}[] = $pretext . '
					<span class="fc_image_thumb" style="' . $style . '; cursor: pointer;" ' . 'onclick="jQuery.fancybox.open([{ type: \'iframe\', href: \'' . $urllink . '\', topRatio: 0.9, leftRatio: 0.9, title: \'' . ($desc ? $title . ': ' . $desc : $title) . '\' }], { padding : 0});"
					>
						' . $img_legend . '
					</span>
					' . $inline_info . $posttext;
                            } else {
                                // CASE: Just link to URL without popup
                                $field->{$prop}[] = $pretext . '
					<a href="' . $urllink . '" target="' . $url_target . '">
						' . $img_legend . '
					</a>
					' . $inline_info . $posttext;
                            }
                        }
                    }
                } else {
                    if (!$usepopup || ($prop == 'display_large' || $prop == 'display_original')) {
                        // CASE 2: // No gallery code ... just apply pretext/posttext
                        $field->{$prop}[] = $pretext . $img_legend . $inline_info . $posttext;
                    } else {
                        if ($popuptype == 5 || $popuptype == 7) {
                            // CASE 3: Inline/special galleries OR --> GALLERIES THAT NEED SPECIAL ENCLOSERS
                            // !!! ... pretext/posttext/inline_info/etc not meaningful or not supported or not needed
                            switch ($popuptype) {
                                case 5:
                                    // Galleriffic inline slideshow gallery
                                    $group_str = '';
                                    // image grouping: not needed / not applicatble
                                    $field->{$prop}[] = '<a href="' . $srcl . '" class="fc_image_thumb thumb" name="drop">
							' . $img_legend . '
						</a>
						<div class="caption">
							<b>' . $title . '</b>
							<br/>' . $desc . '
						</div>';
                                    break;
                                case 7:
                                    // Elastislide inline carousel gallery (Responsive image gallery with togglable thumbnail-strip, plus previewer and description)
                                    // *** NEEDS: thumbnail list must be created with large size thubmnails, these will be then thumbnailed by the JS gallery code
                                    $title_attr = $desc ? $desc : $title;
                                    $img_legend_custom = '
						 <img src="' . JURI::root(true) . '/' . $src . '" alt ="' . $alt . '"' . $legend . ' class="' . $class . '"
						 	data-large="' . JURI::root(true) . '/' . $srcl . '" data-description="' . $title_attr . '" itemprop="image"/>
					';
                                    $group_str = $group_name ? 'rel="[' . $group_name . ']"' : '';
                                    $field->{$prop}[] = '
						<li><a href="javascript:;" class="fc_image_thumb">
							' . $img_legend_custom . '
						</a></li>';
                                    break;
                                default:
                                    // ERROR unhandled INLINE GALLERY case
                                    $field->{$prop}[] = ' Unhandled INLINE GALLERY case in image with field name: {$field->name} ';
                                    break;
                            }
                        } else {
                            // CASE 4: Popup galleries
                            switch ($popuptype) {
                                case 1:
                                    // Multibox image popup
                                    $group_str = $group_name ? 'rel="[' . $group_name . ']"' : '';
                                    $field->{$prop}[] = $pretext . '<a style="' . $style . '" href="' . $srcl . '" id="mb' . $uniqueid . '" class="fc_image_thumb mb" ' . $group_str . ' >
							' . $img_legend . '
						</a>
						<div class="multiBoxDesc mb' . $uniqueid . '">' . ($desc ? '<span class="badge">' . $title . '</span> ' . $desc : $title) . '</div>' . $inline_info . $posttext;
                                    break;
                                case 2:
                                    // Rokbox image popup
                                    $title_attr = $desc ? $desc : $title;
                                    $group_str = '';
                                    // no support for image grouping
                                    $field->{$prop}[] = $pretext . '<a style="' . $style . '" href="' . $srcl . '" rel="rokbox[' . $wl . ' ' . $hl . ']" ' . $group_str . ' title="' . $title_attr . '" class="fc_image_thumb" data-rokbox data-rokbox-caption="' . $title_attr . '">
							' . $img_legend . '
						</a>' . $inline_info . $posttext;
                                    break;
                                case 3:
                                    // JCE popup image popup
                                    $title_attr = $desc ? $title . ': ' . $desc : $title;
                                    // does not support HTML
                                    $group_str = $group_name ? 'rel="group[' . $group_name . ']"' : '';
                                    $field->{$prop}[] = $pretext . '<a style="' . $style . '" href="' . $srcl . '"  class="fc_image_thumb jcepopup" ' . $group_str . ' title="' . $title_attr . '">
							' . $img_nolegend . '
						</a>' . $inline_info . $posttext;
                                    break;
                                case 4:
                                    // Fancybox image popup
                                    $title_attr = $desc ? '<span class=\'badge\'>' . $title . '</span> ' . $desc : $title;
                                    $group_str = $group_name ? 'data-fancybox-group="' . $group_name . '"' : '';
                                    $field->{$prop}[] = $pretext . '<a style="' . $style . '" href="' . $srcl . '"  class="fc_image_thumb fancybox" ' . $group_str . ' title="' . $title_attr . '">
							' . $img_legend . '
						</a>' . $inline_info . $posttext;
                                    break;
                                case 6:
                                    // (Widgetkit) SPOTlight image popup
                                    $title_attr = $desc ? $desc : $title;
                                    $group_str = $group_name ? 'data-spotlight-group="' . $group_name . '"' : '';
                                    $field->{$prop}[] = $pretext . '<a style="' . $style . '" href="' . $srcl . '" class="fc_image_thumb" data-lightbox="on" data-spotlight="effect:bottom" ' . $group_str . ' title="' . $title_attr . '">
							' . $img_legend . '
							<div class="overlay">
								' . '<b>' . $title . '</b>: ' . $desc . '
							</div>
						</a>' . $inline_info . $posttext;
                                    break;
                                case 8:
                                    // PhotoSwipe popup carousel gallery
                                    $group_str = $group_name ? 'rel="[' . $group_name . ']"' : '';
                                    $field->{$prop}[] = $pretext . '<a style="' . $style . '" href="' . $srcl . '" ' . $group_str . ' class="fc_image_thumb">
							' . $img_legend . '
						</a>' . $inline_info . $posttext;
                                    break;
                                default:
                                    // Unknown / Other Gallery Type, just add thumbails ... maybe pretext/posttext/separator/opentag/closetag will add a gallery
                                    $field->{$prop}[] = $pretext . $img_legend . $inline_info . $posttext;
                                    break;
                            }
                        }
                    }
                }
            }
        }
        // **************************************************************
        // Apply separator and open/close tags and handle SPECIAL CASEs:
        // by adding (container) HTML required by some JS image libraries
        // **************************************************************
        // Using in field group, return array
        if ($is_ingroup) {
            return;
        }
        // Check for value only displays and return
        if (isset(self::$value_only_displays[$prop])) {
            return;
        }
        // Check for no values found
        if (!count($field->{$prop})) {
            $field->{$prop} = '';
            return;
        }
        // Galleriffic inline slideshow gallery
        if ($usepopup && $popuptype == 5) {
            $field->{$prop} = '
			<div id="gf_container">
				<div id="gallery" class="content">
					<div id="gf_controls" class="controls"></div>
					<div class="slideshow-container">
						<div id="gf_loading" class="loader"></div>
						<div id="gf_slideshow" class="slideshow"></div>
					</div>
					<div id="gf_caption" class="caption-container"></div>
				</div>
				<div id="gf_thumbs" class="navigation">
					<ul class="thumbs noscript">
						<li>
						' . implode("</li>\n<li>", $field->{$prop}) . '
						</li>
					</ul>
				</div>
				<div style="clear: both;"></div>
			</div>
			';
        } else {
            if ($usepopup && $popuptype == 7) {
                //$max_width = $field->parameters->get( 'w_l', 800 );
                // this should be size of previewer aka size of large image thumbnail
                $uid = 'es_' . $field->name . "_fcitem" . $item->id;
                $field->{$prop} = '
			<div id="rg-gallery_' . $uid . '" class="rg-gallery" >
				<div class="rg-thumbs">
					<!-- Elastislide Carousel Thumbnail Viewer -->
					<div class="es-carousel-wrapper">
						<div class="es-nav">
							<span class="es-nav-prev">' . JText::_('FLEXI_PREVIOUS') . '</span>
							<span class="es-nav-next">' . JText::_('FLEXI_NEXT') . '</span>
						</div>
						<div class="es-carousel">
							<ul>
								' . implode('', $field->{$prop}) . '
							</ul>
						</div>
					</div>
					<!-- End Elastislide Carousel Thumbnail Viewer -->
				</div><!-- rg-thumbs -->
			</div><!-- rg-gallery -->
			';
            } else {
                if ($usepopup && $popuptype == 8) {
                    $field->{$prop} = '
			<span class="photoswipe_fccontainer" >
				' . implode($separatorf, $field->{$prop}) . '
			</span>
			';
                } else {
                    $field->{$prop} = implode($separatorf, $field->{$prop});
                }
            }
        }
        // Apply open/close tags
        $field->{$prop} = $opentag . $field->{$prop} . $closetag;
    }
Exemplo n.º 3
0
    function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
    {
        if (!in_array($field->field_type, self::$field_types)) {
            return;
        }
        $field->label = JText::_($field->label);
        // Some variables
        $is_ingroup = !empty($field->ingroup);
        $use_ingroup = $field->parameters->get('use_ingroup', 0);
        $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
        // Value handling parameters
        $lang_filter_values = 0;
        //$field->parameters->get( 'lang_filter_values', 1);
        $clean_output = $field->parameters->get('clean_output', 0);
        $encode_output = $field->parameters->get('encode_output', 0);
        // Term Title
        $title_label = JText::_($field->parameters->get('title_label', 'FLEXI_FIELD_TERMTITLE'));
        $title_usage = $field->parameters->get('title_usage', 0);
        $default_title = $title_usage == 2 ? JText::_($field->parameters->get('default_value_title', '')) : '';
        $default_title = $default_title ? JText::_($default_title) : '';
        // Term (description) Text
        $value_label = JText::_($field->parameters->get('value_label', 'FLEXI_FIELD_TERMTEXT'));
        $value_usage = $field->parameters->get('default_value_use', 0);
        $default_value = $value_usage == 2 ? $field->parameters->get('default_value', '') : '';
        $default_value = $default_value ? JText::_($default_value) : '';
        // Get field values
        $values = $values ? $values : $field->value;
        // Check for no values and no default value, and return empty display
        if (empty($values)) {
            if (!strlen($default_value)) {
                $field->{$prop} = $is_ingroup ? array() : '';
                return;
            }
            $values = array();
            $values[0]['title'] = $default_title;
            $values[0]['text'] = $default_value;
            $values[0] = serialize($values[0]);
        }
        // ******************************************
        // Language filter, clean output, encode HTML
        // ******************************************
        if ($clean_output) {
            $ifilter = $clean_output == 1 ? JFilterInput::getInstance(null, null, 1, 1) : JFilterInput::getInstance();
        }
        if (1) {
            // (* BECAUSE OF THIS, the value display loop expects unserialized values)
            foreach ($values as &$value) {
                // Compatibility for unserialized values or for NULL values in a field group
                if (!is_array($value)) {
                    $v = !empty($value) ? @unserialize($value) : false;
                    $value = $v !== false || $v === 'b:0;' ? $v : array('title' => $value, 'text' => '');
                }
                if ($lang_filter_values) {
                    $value['title'] = JText::_($value['title']);
                    $value['text'] = JText::_($value['text']);
                }
                if ($clean_output) {
                    $value['title'] = $ifilter->clean($value['title'], 'string');
                    $value['text'] = $ifilter->clean($value['text'], 'string');
                }
                if ($encode_output) {
                    $value['title'] = htmlspecialchars($value['title'], ENT_QUOTES, 'UTF-8');
                    $value['text'] = htmlspecialchars($value['text'], ENT_QUOTES, 'UTF-8');
                }
            }
            unset($value);
            // Unset this or you are looking for trouble !!!, because it is a reference and reusing it will overwrite the pointed variable !!!
        }
        // 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;
        }
        // Create field's HTML
        $field->{$prop} = array();
        $n = 0;
        foreach ($values as $value) {
            if (!strlen($value['title']) && !$is_ingroup) {
                continue;
            }
            // Skip empty if not in field group
            if (!strlen($value['title'])) {
                $field->{$prop}[$n++] = '';
                continue;
            }
            $html = '
				<label class="fc_termtitle label label-success">' . $value['title'] . '</label>
				<div class="fc_termdesc">' . $value['text'] . '</div>';
            // Add prefix / suffix
            $field->{$prop}[$n] = $pretext . $html . $posttext;
            $n++;
            if (!$multiple) {
                break;
            }
            // multiple values disabled, break out of the loop, not adding further values even if the exist
        }
        if (!$is_ingroup) {
            // Apply separator and open/close tags
            $field->{$prop} = implode($separatorf, $field->{$prop});
            if ($field->{$prop} !== '') {
                $field->{$prop} = $opentag . $field->{$prop} . $closetag;
            } else {
                $field->{$prop} = '';
            }
        }
    }
Exemplo n.º 4
0
    function onDisplayCoreFieldValue(&$_field, &$_item, &$params, $_tags = null, $_categories = null, $_favourites = null, $_favoured = null, $_vote = null, $values = null, $prop = 'display')
    {
        // this function is a mess and need complete refactoring
        // execute the code only if the field type match the plugin type
        $view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW));
        static $cat_links = array();
        static $tag_links = array();
        if (!is_array($_item)) {
            $items = array(&$_item);
        } else {
            $items =& $_item;
        }
        // Prefix - Suffix - Separator parameters
        // these parameters should be common so we will retrieve them from the first item instead of inside the loop
        $item = reset($items);
        if (is_object($_field)) {
            $field = $_field;
        } else {
            $field = $item->fields[$_field];
        }
        $remove_space = $field->parameters->get('remove_space', 0);
        $_pretext = $field->parameters->get('pretext', '');
        $_posttext = $field->parameters->get('posttext', '');
        $separatorf = $field->parameters->get('separatorf', 3);
        $_opentag = $field->parameters->get('opentag', '');
        $_closetag = $field->parameters->get('closetag', '');
        $pretext_cacheable = $posttext_cacheable = $opentag_cacheable = $closetag_cacheable = false;
        foreach ($items as $item) {
            //if (!is_object($_field)) echo $item->id." - ".$_field ."<br/>";
            if (is_object($_field)) {
                $field = $_field;
            } else {
                $field = $item->fields[$_field];
            }
            if ($field->iscore != 1) {
                continue;
            }
            $field->item_id = $item->id;
            // Replace item properties or values of other fields
            if (!$pretext_cacheable) {
                $pretext = FlexicontentFields::replaceFieldValue($field, $item, $_pretext, 'pretext', $pretext_cacheable);
                if ($pretext && !$remove_space) {
                    $pretext = $pretext . ' ';
                }
            }
            if (!$posttext_cacheable) {
                $posttext = FlexicontentFields::replaceFieldValue($field, $item, $_posttext, 'posttext', $posttext_cacheable);
                if ($posttext && !$remove_space) {
                    $posttext = ' ' . $posttext;
                }
            }
            if (!$opentag_cacheable) {
                $opentag = FlexicontentFields::replaceFieldValue($field, $item, $_opentag, 'opentag', $opentag_cacheable);
            }
            // used by some fields
            if (!$closetag_cacheable) {
                $closetag = FlexicontentFields::replaceFieldValue($field, $item, $_closetag, 'closetag', $closetag_cacheable);
            }
            // used by some fields
            switch ($separatorf) {
                case 0:
                    $separatorf = ' ';
                    break;
                case 1:
                    $separatorf = '<br />';
                    break;
                case 2:
                    $separatorf = ' | ';
                    break;
                case 3:
                    $separatorf = ', ';
                    break;
                case 4:
                    $separatorf = $closetag . $opentag;
                    break;
                case 5:
                    $separatorf = '';
                    break;
                default:
                    $separatorf = '&nbsp;';
                    break;
            }
            $field->value = array();
            switch ($field->field_type) {
                case 'created':
                    // created
                    $field->value[] = $item->created;
                    $dateformat = $field->parameters->get('date_format', '');
                    $customdate = $field->parameters->get('custom_date', '');
                    $dateformat = $dateformat ? $dateformat : $customdate;
                    $field->display = $pretext . JHTML::_('date', $item->created, JText::_($dateformat)) . $posttext;
                    break;
                case 'createdby':
                    // created by
                    $field->value[] = $item->created_by;
                    $field->display = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->cuname : $item->creator) . $posttext;
                    break;
                case 'modified':
                    // modified
                    $field->value[] = $item->modified;
                    $dateformat = $field->parameters->get('date_format', '');
                    $customdate = $field->parameters->get('custom_date', '');
                    $dateformat = $dateformat ? $dateformat : $customdate;
                    $field->display = $pretext . JHTML::_('date', $item->modified, JText::_($dateformat)) . $posttext;
                    break;
                case 'modifiedby':
                    // modified by
                    $field->value[] = $item->modified_by;
                    $field->display = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->muname : $item->modifier) . $posttext;
                    break;
                case 'title':
                    // title
                    $field->value[] = $item->title;
                    $field->display = $pretext . $item->title . $posttext;
                    // Get ogp configuration
                    $useogp = $field->parameters->get('useogp', 1);
                    $ogpinview = $field->parameters->get('ogpinview', array());
                    $ogpinview = FLEXIUtilities::paramToArray($ogpinview);
                    $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300);
                    if ($useogp && $field->{$prop}) {
                        if (in_array($view, $ogpinview)) {
                            $content_val = flexicontent_html::striptagsandcut($field->display, $ogpmaxlen);
                            JFactory::getDocument()->addCustomTag('<meta property="og:title" content="' . $content_val . '" />');
                        }
                    }
                    break;
                case 'hits':
                    // hits
                    $field->value[] = $item->hits;
                    $field->display = $pretext . $item->hits . $posttext;
                    break;
                case 'type':
                    // document type
                    $field->value[] = $item->type_id;
                    $field->display = $pretext . JText::_($item->typename) . $posttext;
                    break;
                case 'version':
                    // version
                    $field->value[] = $item->version;
                    $field->display = $pretext . $item->version . $posttext;
                    break;
                case 'state':
                    // state
                    $field->value[] = $item->state;
                    $field->display = $pretext . flexicontent_html::stateicon($item->state, $field->parameters) . $posttext;
                    break;
                case 'voting':
                    // voting button
                    if ($_vote === false) {
                        $vote =& $item->vote;
                    } else {
                        $vote =& $_vote;
                    }
                    $field->value[] = 'button';
                    // dummy value to force display
                    $field->display = $pretext . flexicontent_html::ItemVote($field, 'all', $vote) . $posttext;
                    break;
                case 'favourites':
                    // favourites button
                    if ($_favourites === false) {
                        $favourites =& $item->favs;
                    } else {
                        $favourites =& $_favourites;
                    }
                    if ($_favoured === false) {
                        $favoured =& $item->fav;
                    } else {
                        $favoured =& $_favoured;
                    }
                    $field->value[] = 'button';
                    // dummy value to force display
                    $favs = flexicontent_html::favoured_userlist($field, $item, $favourites);
                    $field->display = $pretext . '
					<span class="fav-block">
						' . flexicontent_html::favicon($field, $favoured, $item) . '
						<span id="fcfav-reponse_' . $field->item_id . '" class="fcfav-reponse">
							<small>' . $favs . '</small>
						</span>
					</span>
						' . $posttext;
                    break;
                case 'categories':
                    // assigned categories
                    $field->display = '';
                    if ($_categories === false) {
                        $categories =& $item->cats;
                    } else {
                        $categories =& $_categories;
                    }
                    if ($categories) {
                        // Get categories that should be excluded from linking
                        global $globalnoroute;
                        if (!is_array($globalnoroute)) {
                            $globalnoroute = array();
                        }
                        // Create list of category links, excluding the "noroute" categories
                        $field->display = array();
                        foreach ($categories as $category) {
                            $cat_id = $category->id;
                            if (in_array($cat_id, @$globalnoroute)) {
                                continue;
                            }
                            if (!isset($cat_links[$cat_id])) {
                                $cat_links[$cat_id] = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug));
                            }
                            $cat_link = $cat_links[$cat_id];
                            $display = '<a class="fc_categories fc_category_' . $cat_id . ' link_' . $field->name . '" href="' . $cat_link . '">' . $category->title . '</a>';
                            $field->display[] = $pretext . $display . $posttext;
                            $field->value[] = $category->title;
                        }
                        $field->display = implode($separatorf, $field->display);
                        $field->display = $opentag . $field->display . $closetag;
                    }
                    break;
                case 'tags':
                    // assigned tags
                    $field->display = '';
                    if ($_tags === false) {
                        $tags =& $item->tags;
                    } else {
                        $tags =& $_tags;
                    }
                    if ($tags) {
                        // Create list of tag links
                        $field->display = array();
                        foreach ($tags as $tag) {
                            $tag_id = $tag->id;
                            if (!isset($tag_links[$tag_id])) {
                                $tag_links[$tag_id] = JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->slug));
                            }
                            $tag_link = $tag_links[$tag_id];
                            $display = '<a class="fc_tags fc_tag_' . $tag->id . ' link_' . $field->name . '" href="' . $tag_link . '">' . $tag->name . '</a>';
                            $field->display[] = $pretext . $display . $posttext;
                            $field->value[] = $tag->name;
                        }
                        $field->display = implode($separatorf, $field->display);
                        $field->display = $opentag . $field->display . $closetag;
                    }
                    break;
                case 'maintext':
                    // main text
                    // Special display variables
                    if ($prop != 'display') {
                        switch ($prop) {
                            case 'display_if':
                                $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext;
                                break;
                            case 'display_i':
                                $field->{$prop} = $item->introtext;
                                break;
                            case 'display_f':
                                $field->{$prop} = $item->fulltext;
                                break;
                        }
                    } else {
                        if (!$item->fulltext) {
                            $field->display = $item->introtext;
                        } else {
                            if ($view != FLEXI_ITEMVIEW) {
                                if ($item->parameters->get('force_full', 0)) {
                                    $field->display = $item->introtext . chr(13) . chr(13) . $item->fulltext;
                                } else {
                                    $field->display = $item->introtext;
                                }
                            } else {
                                if ($item->parameters->get('show_intro', 1)) {
                                    $field->display = $item->introtext . chr(13) . chr(13) . $item->fulltext;
                                } else {
                                    $field->display = $item->fulltext;
                                }
                            }
                        }
                    }
                    // Get ogp configuration
                    $useogp = $field->parameters->get('useogp', 1);
                    $ogpinview = $field->parameters->get('ogpinview', array());
                    $ogpinview = FLEXIUtilities::paramToArray($ogpinview);
                    $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300);
                    if ($useogp && $field->{$prop}) {
                        if (in_array($view, $ogpinview)) {
                            if ($item->metadesc) {
                                JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $item->metadesc . '" />');
                            } else {
                                $content_val = flexicontent_html::striptagsandcut($field->display, $ogpmaxlen);
                                JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $content_val . '" />');
                            }
                        }
                    }
                    break;
            }
        }
    }
Exemplo n.º 5
0
 function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     $field->label = JText::_($field->label);
     // Some variables
     $is_ingroup = !empty($field->ingroup);
     $use_ingroup = $field->parameters->get('use_ingroup', 0);
     $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
     // Get field values
     $values = $values ? $values : $field->value;
     // Check for no values and not displaying ALL elements
     $display_all = $field->parameters->get('display_all', 0) && !$is_ingroup;
     // NOT supported inside fielgroup yet
     if (empty($values) && !$display_all) {
         if (!$is_ingroup) {
             $field->{$prop} = '';
             $field->display_index = '';
         } else {
             $field->{$prop} = array();
             $field->display_index = array();
         }
         return;
     }
     // 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');
     // Microdata (classify the field values for search engines)
     $itemprop = $field->parameters->get('microdata_itemprop');
     if ($pretext) {
         $pretext = $remove_space ? $pretext : $pretext . ' ';
     }
     if ($posttext) {
         $posttext = $remove_space ? $posttext : ' ' . $posttext;
     }
     // Value creation
     $sql_mode = $field->parameters->get('sql_mode', 0);
     $field_elements = $field->parameters->get('field_elements', '');
     $text_or_value = $field->parameters->get('text_or_value', 2);
     // image specific or image related variables
     $imagedir = preg_replace('#^(/)*#', '', $field->parameters->get('imagedir'));
     $imgpath = JURI::root(true) . '/' . $imagedir;
     $tooltip_class = FLEXI_J30GE ? 'hasTooltip' : 'hasTip';
     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;
     }
     // Get indexed element values
     $elements = FlexicontentFields::indexedField_getElements($field, $item, self::$extra_props);
     if (!$elements) {
         if ($sql_mode) {
             $field->{$prop} = JText::_('FLEXI_FIELD_INVALID_QUERY');
         } else {
             $field->{$prop} = JText::_('FLEXI_FIELD_INVALID_ELEMENTS');
         }
         return;
     }
     // Check for no elements found
     if (empty($elements)) {
         $field->{$prop} = '';
         $field->display_index = '';
         return;
     }
     // Handle case of FORM fields that each value is an array of values
     // (e.g. selectmultiple, checkbox), and that multi-value input is also enabled
     // we make sure that values should be an array of arrays
     $values = $multiple && self::$valueIsArr ? $values : array($values);
     // Create display of field
     $field->{$prop} = array();
     $display_index = array();
     // Prepare for looping
     if (!$values) {
         $values = array();
     }
     if ($display_all) {
         // non-selected value shortcuts
         $ns_pretext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('ns_pretext', ''), 'ns_pretext');
         $ns_posttext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('ns_posttext', ''), 'ns_posttext');
         $ns_pretext = $ns_pretext . '<span class="fc_field_unsused_val">';
         $ns_posttext = '</span>' . $ns_posttext;
         $ns_pretext = $remove_space ? $ns_pretext : $ns_pretext . ' ';
         $ns_posttext = $remove_space ? $ns_posttext : ' ' . $ns_posttext;
     }
     foreach ($values as $value) {
         // Compatibility for serialized values
         if ($multiple && self::$valueIsArr) {
             if (is_array($value)) {
             } else {
                 if (@unserialize($value) !== false || $value === 'b:0;') {
                     $value = unserialize($value);
                 }
             }
         }
         // Make sure value is an array
         if (!is_array($value)) {
             $value = strlen($value) ? array($value) : array();
         }
         // Skip empty if not in field group
         if (!count($value) && !$is_ingroup) {
             continue;
         }
         $html = array();
         $index = array();
         // CASE a. Display ALL elements (selected and NON-selected)   ***  NOT supported inside fieldgroup YET
         if ($display_all) {
             // *** value is always an array we made sure above
             $indexes = array_flip($value);
             foreach ($elements as $val => $element) {
                 if ($text_or_value == 0) {
                     $disp = $element->value;
                 } else {
                     if ($text_or_value == 1) {
                         $disp = $element->text;
                     } else {
                         $disp = '<img src="' . $imgpath . $element->image . '" class="' . $tooltip_class . '" title="' . flexicontent_html::getToolTip(null, $element->text, 0) . '" alt="' . $element->text . '" />';
                     }
                 }
                 if (isset($indexes[$val])) {
                     $html[] = $pretext . $disp . $posttext;
                     $index[] = $element->value;
                 } else {
                     $html[] = $ns_pretext . $disp . $ns_posttext;
                 }
             }
         } else {
             foreach ($value as $v) {
                 // Skip empty/invalid values but add empty display, if in field group
                 $element = !strlen($v) ? false : @$elements[$v];
                 if (!$element) {
                     if ($use_ingroup) {
                         $html[] = '';
                     }
                     continue;
                 }
                 if ($text_or_value == 0) {
                     $disp = $element->value;
                 } else {
                     if ($text_or_value == 1) {
                         $disp = $element->text;
                     } else {
                         $disp = '<img src="' . $imgpath . $element->image . '" class="' . $tooltip_class . '" title="' . flexicontent_html::getToolTip(null, $element->text, 0) . '" alt="' . $element->text . '" />';
                     }
                 }
                 $html[] = $pretext . $disp . $posttext;
                 $index[] = $pretext . $element->value . $posttext;
             }
         }
         if ($multiple && self::$valueIsArr) {
             // For current array of values, apply values separator, and field 's opening / closing texts
             $field->{$prop}[] = !count($html) ? '' : $opentag . implode($separatorf, $html) . $closetag;
             $display_index[] = !count($html) ? '' : $opentag . implode($separatorf, $index) . $closetag;
         } else {
             // Done, there should not be more !!, since we handled an array of singular values
             $field->{$prop} = $html;
             $display_index = $index;
             break;
         }
     }
     // Add microdata to every group of values if field -- is -- in a field group
     if ($is_ingroup && $itemprop) {
         foreach ($field->{$prop} as $n => $disp_html) {
             $field->{$prop}[$n] = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop}[$n] . '</div>';
         }
     }
     // Do not convert the array to string if field is in a group, and do not add: FIELD's opetag, closetag, value separator
     if (!$is_ingroup) {
         if ($multiple && self::$valueIsArr) {
             // Values separator, field 's opening / closing texts, were already applied for every array of values
             $field->{$prop} = implode("", $field->{$prop});
             $field->display_index = implode("", $display_index);
         } else {
             // Apply values separator, and field 's opening / closing texts
             $field->{$prop} = !count($field->{$prop}) ? '' : $opentag . implode($separatorf, $field->{$prop}) . $closetag;
             $field->display_index = !count($field->{$prop}) ? '' : $opentag . implode($separatorf, $display_index) . $closetag;
         }
         // Add microdata once for all values, if field -- is NOT -- in a field group
         if ($field->{$prop} !== '' && $itemprop) {
             $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>';
         }
     }
 }
Exemplo n.º 6
0
 function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     // Some variables
     $is_ingroup = !empty($field->ingroup);
     $use_ingroup = $field->parameters->get('use_ingroup', 0);
     $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 1);
     static $langs = null;
     if ($langs === null) {
         $langs = FLEXIUtilities::getLanguages('code');
     }
     static $tooltips_added = false;
     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();
         //$time_passed = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
         //printf('<br/>-- [Detect Mobile: %.3f s] ', $time_passed/1000000);
     }
     if (!$tooltips_added) {
         FLEXI_J30GE ? JHtml::_('bootstrap.tooltip') : JHTML::_('behavior.tooltip');
         $tooltips_added = true;
     }
     $field->label = JText::_($field->label);
     $values = $values ? $values : $field->value;
     // Check for no values and no default value, and return empty display
     if (empty($values)) {
         $field->{$prop} = $is_ingroup ? array() : '';
         return;
     }
     // 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');
     // Microdata (classify the field values for search engines)
     $itemprop = '';
     //$field->parameters->get('microdata_itemprop');
     if ($pretext) {
         $pretext = $remove_space ? $pretext : $pretext . ' ';
     }
     if ($posttext) {
         $posttext = $remove_space ? $posttext : ' ' . $posttext;
     }
     // some parameter shortcuts
     $useicon = $field->parameters->get('useicon', 1);
     $lowercase_filename = $field->parameters->get('lowercase_filename', 1);
     $link_filename = $field->parameters->get('link_filename', 1);
     $display_filename = $field->parameters->get('display_filename', 1);
     $display_lang = $field->parameters->get('display_lang', 1);
     $display_size = $field->parameters->get('display_size', 0);
     $display_hits = $field->parameters->get('display_hits', 0);
     $display_descr = $field->parameters->get('display_descr', 1);
     $add_lang_img = $display_lang == 1 || $display_lang == 3;
     $add_lang_txt = $display_lang == 2 || $display_lang == 3 || $isMobile;
     $add_hits_img = $display_hits == 1 || $display_hits == 3;
     $add_hits_txt = $display_hits == 2 || $display_hits == 3 || $isMobile;
     $usebutton = $field->parameters->get('usebutton', 1);
     $buttonsposition = $field->parameters->get('buttonsposition', 1);
     $use_infoseptxt = $field->parameters->get('use_infoseptxt', 1);
     $use_actionseptxt = $field->parameters->get('use_actionseptxt', 1);
     $infoseptxt = $use_infoseptxt ? ' ' . $field->parameters->get('infoseptxt', '') . ' ' : ' ';
     $actionseptxt = $use_actionseptxt ? ' ' . $field->parameters->get('actionseptxt', '') . ' ' : ' ';
     $allowdownloads = $field->parameters->get('allowdownloads', 1);
     $downloadstext = $allowdownloads == 2 ? $field->parameters->get('downloadstext', 'FLEXI_DOWNLOAD') : 'FLEXI_DOWNLOAD';
     $downloadstext = JText::_($downloadstext);
     $downloadsinfo = JText::_('FLEXI_FIELD_FILE_DOWNLOAD_INFO', true);
     $allowview = $field->parameters->get('allowview', 0);
     $viewtext = $allowview == 2 ? $field->parameters->get('viewtext', 'FLEXI_FIELD_FILE_VIEW') : 'FLEXI_FIELD_FILE_VIEW';
     $viewtext = JText::_($viewtext);
     $viewinfo = JText::_('FLEXI_FIELD_FILE_VIEW_INFO', true);
     $allowshare = $field->parameters->get('allowshare', 0);
     $sharetext = $allowshare == 2 ? $field->parameters->get('sharetext', 'FLEXI_FIELD_FILE_EMAIL_TO_FRIEND') : 'FLEXI_FIELD_FILE_EMAIL_TO_FRIEND';
     $sharetext = JText::_($sharetext);
     $shareinfo = JText::_('FLEXI_FIELD_FILE_EMAIL_TO_FRIEND_INFO', true);
     $allowaddtocart = $field->parameters->get('use_downloads_manager', 0);
     $addtocarttext = $allowaddtocart == 2 ? $field->parameters->get('addtocarttext', 'FLEXI_FIELD_FILE_ADD_TO_DOWNLOADS_CART') : 'FLEXI_FIELD_FILE_ADD_TO_DOWNLOADS_CART';
     $addtocarttext = JText::_($addtocarttext);
     $addtocartinfo = JText::_('FLEXI_FIELD_FILE_ADD_TO_DOWNLOADS_CART_INFO', true);
     $noaccess_display = $field->parameters->get('noaccess_display', 1);
     $noaccess_url_unlogged = $field->parameters->get('noaccess_url_unlogged', false);
     $noaccess_url_logged = $field->parameters->get('noaccess_url_logged', false);
     $noaccess_msg_unlogged = JText::_($field->parameters->get('noaccess_msg_unlogged', ''));
     $noaccess_msg_logged = JText::_($field->parameters->get('noaccess_msg_logged', ''));
     $noaccess_addvars = $field->parameters->get('noaccess_addvars', 0);
     // Select appropriate messages depending if user is logged on
     $noaccess_url = JFactory::getUser()->guest ? $noaccess_url_unlogged : $noaccess_url_logged;
     $noaccess_msg = JFactory::getUser()->guest ? $noaccess_msg_unlogged : $noaccess_msg_logged;
     // VERIFY downloads manager module is installed and enabled
     static $mod_is_enabled = null;
     if ($allowaddtocart && $mod_is_enabled === null) {
         $db = JFactory::getDBO();
         $query = "SELECT published FROM #__modules WHERE module = 'mod_flexidownloads' AND published = 1";
         $db->setQuery($query);
         $mod_is_enabled = $db->loadResult();
         if (!$mod_is_enabled) {
             JFactory::getApplication()->enqueueMessage("FILE FIELD: please disable parameter \"Use Downloads Manager Module\", the module is not install or not published", 'message');
         }
     }
     $allowaddtocart = $allowaddtocart ? $mod_is_enabled : 0;
     // Downloads manager feature
     if ($allowshare) {
         if (file_exists(JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php')) {
             $com_mailto_found = true;
             require_once JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php';
             $status = 'width=700,height=360,menubar=yes,resizable=yes';
         } else {
             $com_mailto_found = false;
         }
     }
     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;
     }
     // Get user access level (these are multiple for J2.5)
     $user = JFactory::getUser();
     $aid_arr = JAccess::getAuthorisedViewLevels($user->id);
     $n = 0;
     // Get All file information at once (Data maybe cached already)
     // TODO (maybe) e.g. contentlists should could call this function ONCE for all file fields,
     // This may be done by adding a new method to fields to prepare multiple fields with a single call
     $files_data = $this->getFileData($values, $published = true);
     //if ($field->id==NNN) { echo "<pre>"; print_r($files_data); exit; }
     // Optimization, do some stuff outside the loop
     static $hits_icon = null;
     if ($hits_icon === null && ($display_hits == 1 || $display_hits == 3)) {
         if ($display_hits == 1) {
             $_tooltip_title = '';
             $_tooltip_content = '%s ' . JText::_('FLEXI_HITS', true);
             $_attribs = 'class="hasTooltip fcicon-hits" title="' . JHtml::tooltipText($_tooltip_title, $_tooltip_content, 0, 0) . '"';
         } else {
             $_attribs = ' class="fcicon-hits"';
         }
         $hits_icon = JHTML::image('components/com_flexicontent/assets/images/' . 'user.png', JText::_('FLEXI_HITS'), $_attribs) . ' ';
     }
     $show_filename = $display_filename || $prop == 'namelist';
     $public_acclevel = 1;
     $empty_file_data = array('filename' => false, 'filename_original' => false, 'altname' => false, 'description' => false, 'ext' => false, 'id' => 0);
     // Get layout name
     $viewlayout = $field->parameters->get('viewlayout', '');
     $viewlayout = $viewlayout ? 'value_' . $viewlayout : 'value_InlineBoxes';
     // Create field's HTML, using layout file
     $field->{$prop} = array();
     //$this->values = $values;
     //$this->displayFieldValue( $prop, $viewlayout );
     include self::getFormPath($this->fieldtypes[0], $viewlayout);
     if (!empty($fancybox_needed)) {
         flexicontent_html::loadFramework('fancybox');
     }
     // Do not convert the array to string if field is in a group, and do not add: FIELD's opetag, closetag, value separator
     if (!$is_ingroup) {
         // Apply values separator
         $field->{$prop} = implode($separatorf, $field->{$prop});
         if ($field->{$prop} !== '') {
             // Apply field 's opening / closing texts
             $field->{$prop} = $opentag . $field->{$prop} . $closetag;
             // Add microdata once for all values, if field -- is NOT -- in a field group
             if ($itemprop) {
                 $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>';
             }
         }
     }
 }
 function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     $field->label = JText::_($field->label);
     // Some variables
     $is_ingroup = !empty($field->ingroup);
     $use_ingroup = $field->parameters->get('use_ingroup', 0);
     $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
     $view = JRequest::getVar('flexi_callview', JRequest::getVar('view', FLEXI_ITEMVIEW));
     // Get field values
     $values = $values ? $values : $field->value;
     $values = !is_array($values) ? array($values) : $values;
     // make sure values is an array
     $isempty = !count($values) || !strlen($values[0]);
     // detect empty value
     if ($isempty) {
         return;
     }
     // Optional display
     $display_phone_label = $field->parameters->get('display_phone_label', 1);
     $display_country_code = $field->parameters->get('display_phone_label', 1);
     $display_area_code = $field->parameters->get('display_area_code', 1);
     // Property Separators
     $label_prefix = $field->parameters->get('label_prefix', '');
     $label_suffix = $field->parameters->get('label_suffix', '');
     $country_code_prefix = $field->parameters->get('country_code_prefix', '');
     $separator_cc_phone1 = $field->parameters->get('separator_cc_phone1', '');
     $separator_phone1_phone2 = $field->parameters->get('separator_phone1_phone2', '');
     $separator_phone2_phone3 = $field->parameters->get('separator_phone2_phone3', '');
     // Open/close tags (every value)
     $opentag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('opentag', ''), 'opentag');
     $closetag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('closetag', ''), 'closetag');
     // Prefix/suffix (value list)
     $field_prefix = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('field_prefix', ''), 'field_prefix');
     $field_suffix = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('field_suffix', ''), 'field_suffix');
     // initialise property
     $field->{$prop} = array();
     $n = 0;
     foreach ($values as $value) {
         // Compatibility for unserialized values or for NULL values in a field group
         if (!is_array($value)) {
             $v = !empty($value) ? @unserialize($value) : false;
             $value = $v !== false || $v === 'b:0;' ? $v : array('label' => '', 'cc' => '', 'phone1' => $value, 'phone2' => '', 'phone3' => '');
         }
         if (empty($value['phone1']) && empty($value['phone2']) && empty($value['phone3']) && !$is_ingroup) {
             continue;
         }
         // Skip empty values if not in field group
         $field->{$prop}[] = '' . $opentag . ($display_phone_label ? $label_prefix . $value['label'] . $label_suffix : '') . ($display_country_code ? $country_code_prefix . $value['cc'] . $separator_cc_phone1 : '') . ($display_area_code ? $value['phone1'] . $separator_phone1_phone2 : '') . $value['phone2'] . $separator_phone2_phone3 . $value['phone3'] . $closetag;
         $n++;
         if (!$multiple) {
             break;
         }
         // multiple values disabled, break out of the loop, not adding further values even if the exist
     }
     if (!$is_ingroup) {
         // Apply separator and open/close tags
         if (count($field->{$prop})) {
             $field->{$prop} = implode('', $field->{$prop});
             $field->{$prop} = $field_prefix . $field->{$prop} . $field_suffix;
         } else {
             $field->{$prop} = '';
         }
     }
 }
Exemplo n.º 8
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;
     }
     $field->label = JText::_($field->label);
     // 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
     $default_value_use = $field->parameters->get('default_value_use', 0);
     $default_value = $default_value_use == 2 ? $field->parameters->get('default_value', '') : '';
     if (empty($values) && !strlen($default_value)) {
         $field->{$prop} = '';
         return;
     } else {
         if (empty($values) && strlen($default_value)) {
             $values = array($default_value);
         }
     }
     // Value handling parameters
     $multiple = $field->parameters->get('allow_multiple', 1);
     // Language filter the values
     $lang_filter_values = $field->parameters->get('lang_filter_values', 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;
     }
     // initialise property
     $field->{$prop} = array();
     $n = 0;
     foreach ($values as $value) {
         if (!strlen($value)) {
             continue;
         }
         $field->{$prop}[$n] = $pretext . ($lang_filter_values ? JText::_($value) : $value) . $posttext;
         $n++;
         if (!$multiple) {
             break;
         }
         // multiple values disabled, break out of the loop, not adding further values even if the exist
     }
     // Apply separator and open/close tags
     $field->{$prop} = implode($separatorf, $field->{$prop});
     if ($field->{$prop} !== '') {
         $field->{$prop} = $opentag . $field->{$prop} . $closetag;
     } else {
         $field->{$prop} = '';
     }
     // Add OGP Data
     $useogp = $field->parameters->get('useogp', 0);
     $ogpinview = $field->parameters->get('ogpinview', array());
     $ogpinview = FLEXIUtilities::paramToArray($ogpinview);
     $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300);
     $ogpusage = $field->parameters->get('ogpusage', 0);
     if ($useogp && $field->{$prop}) {
         $view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW));
         if (in_array($view, $ogpinview)) {
             switch ($ogpusage) {
                 case 1:
                     $usagetype = 'title';
                     break;
                 case 2:
                     $usagetype = 'description';
                     break;
                 default:
                     $usagetype = '';
                     break;
             }
             if ($usagetype) {
                 $content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen);
                 JFactory::getDocument()->addCustomTag('<meta property="og:' . $usagetype . '" content="' . $content_val . '" />');
             }
         }
     }
 }
Exemplo n.º 9
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;
		
		$field->label = JText::_($field->label);
		
		// Some variables
		$document = JFactory::getDocument();
		$view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW));
		
		// 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
		$default_value_use= $field->parameters->get( 'default_value_use', 0 ) ;
		$default_value		= ($default_value_use == 2) ? $field->parameters->get( 'default_value', '' ) : '';
		if ( empty($values) && !strlen($default_value) ) {
			$field->{$prop} = '';
			return;
		} else if ( empty($values) && strlen($default_value) ) {
			$values = array($default_value);
		}
		
		// Prefix - Suffix - Separator parameters, replacing other field values if found
		$opentag		= FlexicontentFields::replaceFieldValue( $field, $item, $field->parameters->get( 'opentag', '' ), 'opentag' );
		$closetag		= FlexicontentFields::replaceFieldValue( $field, $item, $field->parameters->get( 'closetag', '' ), 'closetag' );
		
		// some parameter shortcuts
		$use_html			= $field->parameters->get( 'use_html', 0 ) ;
		
		// Get ogp configuration
		$useogp     = $field->parameters->get('useogp', 0);
		$ogpinview  = $field->parameters->get('ogpinview', array());
		$ogpinview  = FLEXIUtilities::paramToArray($ogpinview);
		$ogpmaxlen  = $field->parameters->get('ogpmaxlen', 300);
		$ogpusage   = $field->parameters->get('ogpusage', 0);
		
		// Apply seperator and open/close tags
		if ($values) {
			$field->{$prop} = $use_html ? $values[0] : nl2br($values[0]);
			$field->{$prop} = $opentag . $field->{$prop} . $closetag;
		} else {
			$field->{$prop} = '';
		}
		
		if ($useogp && $field->{$prop}) {
			if ( in_array($view, $ogpinview) ) {
				switch ($ogpusage)
				{
					case 1: $usagetype = 'title'; break;
					case 2: $usagetype = 'description'; break;
					default: $usagetype = ''; break;
				}
				if ($usagetype) {
					$content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen);
					$document->addCustomTag('<meta property="og:'.$usagetype.'" content="'.$content_val.'" />');
				}
			}
		}
	}
Exemplo n.º 10
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;
        }
        static $langs = null;
        if ($langs === null) {
            $langs = FLEXIUtilities::getLanguages('code');
        }
        static $tooltips_added = false;
        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();
            //$time_passed = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
            //printf('<br/>-- [Detect Mobile: %.3f s] ', $time_passed/1000000);
        }
        if (!$tooltips_added) {
            FLEXI_J30GE ? JHtml::_('bootstrap.tooltip') : JHTML::_('behavior.tooltip');
            $tooltips_added = true;
        }
        $field->label = JText::_($field->label);
        $values = $values ? $values : $field->value;
        if (empty($values)) {
            $field->{$prop} = '';
            return;
        }
        // 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;
        }
        // some parameter shortcuts
        $useicon = $field->parameters->get('useicon', 1);
        $lowercase_filename = $field->parameters->get('lowercase_filename', 1);
        $link_filename = $field->parameters->get('link_filename', 1);
        $display_filename = $field->parameters->get('display_filename', 1);
        $display_lang = $field->parameters->get('display_lang', 1);
        $display_size = $field->parameters->get('display_size', 0);
        $display_hits = $field->parameters->get('display_hits', 0);
        $display_descr = $field->parameters->get('display_descr', 1);
        $add_lang_img = $display_lang == 1 || $display_lang == 3;
        $add_lang_txt = $display_lang == 2 || $display_lang == 3 || $isMobile;
        $add_hits_img = $display_hits == 1 || $display_hits == 3;
        $add_hits_txt = $display_hits == 2 || $display_hits == 3 || $isMobile;
        $usebutton = $field->parameters->get('usebutton', 1);
        $buttonsposition = $field->parameters->get('buttonsposition', 1);
        $use_infoseptxt = $field->parameters->get('use_infoseptxt', 1);
        $use_actionseptxt = $field->parameters->get('use_actionseptxt', 1);
        $infoseptxt = $use_infoseptxt ? ' ' . $field->parameters->get('infoseptxt', '') . ' ' : ' ';
        $actionseptxt = $use_actionseptxt ? ' ' . $field->parameters->get('actionseptxt', '') . ' ' : ' ';
        $allowdownloads = $field->parameters->get('allowdownloads', 1);
        $downloadstext = $allowdownloads == 2 ? $field->parameters->get('downloadstext', 'FLEXI_DOWNLOAD') : 'FLEXI_DOWNLOAD';
        $downloadstext = JText::_($downloadstext);
        $downloadsinfo = JText::_('FLEXI_FIELD_FILE_DOWNLOAD_INFO', true);
        $allowview = $field->parameters->get('allowview', 0);
        $viewtext = $allowview == 2 ? $field->parameters->get('viewtext', 'FLEXI_FIELD_FILE_VIEW') : 'FLEXI_FIELD_FILE_VIEW';
        $viewtext = JText::_($viewtext);
        $viewinfo = JText::_('FLEXI_FIELD_FILE_VIEW_INFO', true);
        $allowshare = $field->parameters->get('allowshare', 0);
        $sharetext = $allowshare == 2 ? $field->parameters->get('sharetext', 'FLEXI_FIELD_FILE_EMAIL_TO_FRIEND') : 'FLEXI_FIELD_FILE_EMAIL_TO_FRIEND';
        $sharetext = JText::_($sharetext);
        $shareinfo = JText::_('FLEXI_FIELD_FILE_EMAIL_TO_FRIEND_INFO', true);
        $allowaddtocart = $field->parameters->get('use_downloads_manager', 0);
        $addtocarttext = $allowaddtocart == 2 ? $field->parameters->get('addtocarttext', 'FLEXI_FIELD_FILE_ADD_TO_DOWNLOADS_CART') : 'FLEXI_FIELD_FILE_ADD_TO_DOWNLOADS_CART';
        $addtocarttext = JText::_($addtocarttext);
        $addtocartinfo = JText::_('FLEXI_FIELD_FILE_ADD_TO_DOWNLOADS_CART_INFO', true);
        $noaccess_display = $field->parameters->get('noaccess_display', 1);
        $noaccess_url_unlogged = $field->parameters->get('noaccess_url_unlogged', false);
        $noaccess_url_logged = $field->parameters->get('noaccess_url_logged', false);
        $noaccess_msg_unlogged = JText::_($field->parameters->get('noaccess_msg_unlogged', ''));
        $noaccess_msg_logged = JText::_($field->parameters->get('noaccess_msg_logged', ''));
        $noaccess_addvars = $field->parameters->get('noaccess_addvars', 0);
        // Select appropriate messages depending if user is logged on
        $noaccess_url = JFactory::getUser()->guest ? $noaccess_url_unlogged : $noaccess_url_logged;
        $noaccess_msg = JFactory::getUser()->guest ? $noaccess_msg_unlogged : $noaccess_msg_logged;
        // VERIFY downloads manager module is installed and enabled
        static $mod_is_enabled = null;
        if ($allowaddtocart && $mod_is_enabled === null) {
            $db = JFactory::getDBO();
            $query = "SELECT published FROM #__modules WHERE module = 'mod_flexidownloads' AND published = 1";
            $db->setQuery($query);
            $mod_is_enabled = $db->loadResult();
            if (!$mod_is_enabled) {
                $app = JFactory::getApplication();
                $app->enqueueMessage("FILE FIELD: please disable parameter \"Use Downloads Manager Module\", the module is not install or not published", 'message');
            }
        }
        $allowaddtocart = $allowaddtocart ? $mod_is_enabled : 0;
        // Downloads manager feature
        if ($allowshare) {
            if (file_exists(JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php')) {
                $com_mailto_found = true;
                require_once JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php';
                $status = 'width=700,height=360,menubar=yes,resizable=yes';
            } else {
                $com_mailto_found = false;
            }
        }
        if ($pretext) {
            $pretext = $remove_space ? $pretext : $pretext . ' ';
        }
        if ($posttext) {
            $posttext = $remove_space ? $posttext : ' ' . $posttext;
        }
        // Description as tooltip
        if ($display_descr == 2) {
            JHTML::_('behavior.tooltip');
        }
        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;
        }
        // initialise property
        $field->{$prop} = array();
        // Get user access level (these are multiple for J2.5)
        $user = JFactory::getUser();
        if (FLEXI_J16GE) {
            $aid_arr = JAccess::getAuthorisedViewLevels($user->id);
        } else {
            $aid = (int) $user->get('aid');
        }
        $n = 0;
        // Get All file information at once (Data maybe cached already)
        // TODO (maybe) e.g. contentlists should could call this function ONCE for all file fields,
        // This may be done by adding a new method to fields to prepare multiple fields with a single call
        $files_data = $this->getFileData($values, $published = true);
        //print_r($files_data); exit;
        // Optimization, do some stuff outside the loop
        static $hits_icon = null;
        if ($hits_icon === null && ($display_hits == 1 || $display_hits == 3)) {
            if ($display_hits == 1) {
                $_tooltip_title = '';
                $_tooltip_content = '%s ' . JText::_('FLEXI_HITS', true);
                $_attribs = FLEXI_J30GE ? 'class="hasTooltip icon-hits" title="' . JHtml::tooltipText($_tooltip_title, $_tooltip_content, 0, 0) . '"' : 'class="hasTip icon-hits" title="' . $_tooltip_title . '::' . $_tooltip_content . '"';
            } else {
                $_attribs = ' class="icon-hits"';
            }
            $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);
            $hits_icon .= ' ';
        }
        $show_filename = $display_filename || $prop == 'namelist';
        $public_acclevel = !FLEXI_J16GE ? 0 : 1;
        foreach ($files_data as $file_id => $file_data) {
            // Check if it exists and get file size
            $basePath = $file_data->secure ? COM_FLEXICONTENT_FILEPATH : COM_FLEXICONTENT_MEDIAPATH;
            $abspath = str_replace(DS, '/', JPath::clean($basePath . DS . $file_data->filename));
            if ($display_size) {
                $path_exists = file_exists($abspath);
                $file_data->size = $path_exists ? filesize($abspath) : 0;
            }
            // *****************************
            // Check user access on the file
            // *****************************
            $authorized = true;
            $is_public = true;
            if (!empty($file_data->access)) {
                if (FLEXI_J16GE) {
                    $authorized = in_array($file_data->access, $aid_arr);
                    $is_public = in_array($public_acclevel, $aid_arr);
                } else {
                    $authorized = $file_data->access <= $aid;
                    $is_public = $file_data->access <= $public_acclevel;
                }
            }
            // If no access and set not to show then continue
            if (!$authorized && !$noaccess_display) {
                continue;
            }
            // Initialize CSS classes variable
            $file_classes = !$authorized ? 'fcfile_noauth' : '';
            // *****************************
            // Prepare displayed information
            // *****************************
            // a. ICON: create it according to filetype
            $icon = '';
            if ($useicon) {
                $file_data = $this->addIcon($file_data);
                $_tooltip_title = '';
                $_tooltip_content = JText::_('FLEXI_FIELD_FILE_TYPE', true) . ': ' . $file_data->ext;
                $icon = FLEXI_J30GE ? JHTML::image($file_data->icon, $file_data->ext, 'class="icon-mime hasTooltip" title="' . JHtml::tooltipText($_tooltip_title, $_tooltip_content, 1, 0) . '"') : JHTML::image($file_data->icon, $file_data->ext, 'class="icon-mime hasTip" title="' . $_tooltip_title . '::' . $_tooltip_content . '"');
                $icon = '<span class="fcfile_mime">' . $icon . '</span>';
            }
            // b. LANGUAGE: either as icon or as inline text or both
            $lang = '';
            $lang_str = '';
            $file_data->language = $file_data->language == '' ? '*' : $file_data->language;
            if ($display_lang && $file_data->language != '*') {
                $lang = '<span class="fcfile_lang">';
                if ($add_lang_img && @$langs->{$file_data->language}->imgsrc) {
                    if (!$add_lang_txt) {
                        $_tooltip_title = JText::_('FLEXI_LANGUAGE', true);
                        $_tooltip_content = $file_data->language == '*' ? JText::_("All") : $langs->{$file_data->language}->name;
                        $_attribs = FLEXI_J30GE ? 'class="hasTooltip icon-lang" title="' . JHtml::tooltipText($_tooltip_title, $_tooltip_content, 0, 0) . '"' : 'class="hasTip icon-lang" title="' . $_tooltip_title . '::' . $_tooltip_content . '"';
                    } else {
                        $_attribs = ' class="icon-lang"';
                    }
                    $lang .= "\n" . '<img src="' . $langs->{$file_data->language}->imgsrc . '" ' . $_attribs . ' /> ';
                }
                if ($add_lang_txt) {
                    $lang .= '[' . ($file_data->language == '*' ? JText::_("FLEXI_ALL_LANGUAGES") : $langs->{$file_data->language}->name) . ']';
                }
                $lang .= '</span>';
            }
            // c. SIZE: in KBs / MBs
            $sizeinfo = '';
            if ($display_size) {
                $sizeinfo = '<span class="fcfile_size">';
                if ($display_size == 1) {
                    $sizeinfo .= '(' . number_format($file_data->size / 1024, 0) . '&nbsp;' . JTEXT::_('FLEXI_KBS') . ')';
                } else {
                    if ($display_size == 2) {
                        $sizeinfo .= '(' . number_format($file_data->size / 1048576, 2) . '&nbsp;' . JTEXT::_('FLEXI_MBS') . ')';
                    } else {
                        $sizeinfo .= '(' . number_format($file_data->size / 1073741824, 2) . '&nbsp;' . JTEXT::_('FLEXI_GBS') . ')';
                    }
                }
                $sizeinfo .= '</span>';
            }
            // d. HITS: either as icon or as inline text or both
            $hits = '';
            if ($display_hits) {
                $hits = '<span class="fcfile_hits">';
                if ($add_hits_img && @$hits_icon) {
                    $hits .= sprintf($hits_icon, $file_data->hits);
                }
                if ($add_hits_txt) {
                    $hits .= '(' . $file_data->hits . '&nbsp;' . JTEXT::_('FLEXI_HITS') . ')';
                }
                $hits .= '</span>';
            }
            // e. FILENAME / TITLE: decide whether to show it (if we do not use button, then displaying of filename is forced)
            $_filetitle = $file_data->altname ? $file_data->altname : $file_data->filename;
            if ($lowercase_filename) {
                $_filetitle = mb_strtolower($_filetitle, "UTF-8");
            }
            $filename_original = $file_data->filename_original ? $file_data->filename_original : $file_data->filename;
            ${$filename_original} = str_replace(array("'", "\""), array("\\'", ""), $filename_original);
            $filename_original = htmlspecialchars($filename_original, ENT_COMPAT, 'UTF-8');
            $name_str = $display_filename == 2 ? $filename_original : $_filetitle;
            $name_classes = $file_classes . ($file_classes ? ' ' : '') . 'fcfile_title';
            $name_html = '<span class="' . $name_classes . '">' . $name_str . '</span>';
            // f. DESCRIPTION: either as tooltip or as inline text
            $descr_tip = $descr_inline = $descr_icon = '';
            if (!empty($file_data->description)) {
                if (!$authorized) {
                    if ($noaccess_display != 2) {
                        $descr_tip = flexicontent_html::escapeJsText($name_str . '::' . $file_data->description, 's');
                        $descr_icon = '<img src="components/com_flexicontent/assets/images/comment.png" class="hasTip" title="' . $descr_tip . '"/>';
                        $descr_inline = '';
                    }
                } else {
                    if ($display_descr == 1 || $prop == 'namelist') {
                        // As tooltip
                        $descr_tip = flexicontent_html::escapeJsText($name_str . '::' . $file_data->description, 's');
                        $descr_icon = '<img src="components/com_flexicontent/assets/images/comment.png" class="hasTip" title="' . $descr_tip . '"/>';
                        $descr_inline = '';
                    } else {
                        if ($display_descr == 2) {
                            // As inline text
                            $descr_inline = ' <span class="fcfile_descr_inline fc-mssg fc-caption" style="max-wdith">' . nl2br($file_data->description) . '</span>';
                        }
                    }
                }
                if ($descr_icon) {
                    $descr_icon = ' <span class="fcfile_descr_tip">' . $descr_icon . '</span>';
                }
            }
            // *****************************
            // Create field's displayed html
            // *****************************
            // [1]: either create the download link -or- use no authorized link ...
            if (!$authorized) {
                $dl_link = $noaccess_url;
                if ($noaccess_msg) {
                    $str = '<span class="fcfile_noauth_msg fc-mssg-inline fc-noauth">' . $noaccess_msg . '</span> ';
                }
            } else {
                $dl_link = JRoute::_('index.php?option=com_flexicontent&id=' . $file_id . '&cid=' . $field->item_id . '&fid=' . $field->id . '&task=download');
                $str = '';
            }
            // SOME behavior FLAGS
            $not_downloadable = !$dl_link || $prop == 'namelist';
            $filename_shown = !$authorized || $show_filename;
            $filename_shown_as_link = $filename_shown && $link_filename && !$usebutton;
            // [2]: Add information properties: filename, and icons with optional inline text
            $info_arr = array();
            if ($filename_shown && !$filename_shown_as_link || $not_downloadable) {
                // Filename will be shown if not l
                $info_arr[] = $icon . ' ' . $name_html;
            }
            if ($lang) {
                $info_arr[] = $lang;
            }
            if ($sizeinfo) {
                $info_arr[] = $sizeinfo;
            }
            if ($hits) {
                $info_arr[] = $hits;
            }
            if ($descr_icon) {
                $info_arr[] = $descr_icon;
            }
            $str .= implode($info_arr, $infoseptxt);
            // [3]: Display the buttons:  DOWNLOAD, SHARE, ADD TO CART
            $actions_arr = array();
            // ***********************
            // CASE 1: no download ...
            // ***********************
            // EITHER (a) Current user NOT authorized to download file AND no access URL is not configured
            // OR     (b) creating a file list with no download links, (the 'prop' display variable is 'namelist')
            if ($not_downloadable) {
                // nothing to do here, the file name/title will be shown above
            } else {
                if ($usebutton) {
                    $file_classes .= ($file_classes ? ' ' : '') . 'fc_button fcsimple';
                    // Add an extra css class (button display)
                    // DOWNLOAD: single file instant download
                    if ($allowdownloads) {
                        // NO ACCESS: add file info via form field elements, in case the URL target needs to use them
                        $file_data_fields = "";
                        if (!$authorized && $noaccess_addvars) {
                            $file_data_fields = '<input type="hidden" name="fc_field_id" value="' . $field->id . '"/>' . "\n" . '<input type="hidden" name="fc_item_id" value="' . $field->item_id . '"/>' . "\n" . '<input type="hidden" name="fc_file_id" value="' . $file_id . '"/>' . "\n";
                        }
                        // The download button in a mini form ...
                        $actions_arr[] = '' . '<form id="form-download-' . $field->id . '-' . ($n + 1) . '" method="post" action="' . $dl_link . '" style="display:inline-block;" >' . $file_data_fields . '<input type="submit" name="download-' . $field->id . '[]" class="' . $file_classes . ' fcfile_downloadFile" title="' . $downloadsinfo . '" value="' . $downloadstext . '"/>' . '</form>' . "\n";
                    }
                    if ($authorized && $allowview && !$file_data->url) {
                        $actions_arr[] = '
						<a href="' . $dl_link . '?method=view" class="fancybox ' . $file_classes . ' fcfile_viewFile" data-fancybox-type="iframe" title="' . $viewinfo . '" style="line-height:1.3em;" >
							' . $viewtext . '
						</a>';
                        $fancybox_needed = 1;
                    }
                    // ADD TO CART: the link will add file to download list (tree) (handled via a downloads manager module)
                    if ($authorized && $allowaddtocart && !$file_data->url) {
                        // CSS class to anchor downloads list adding function
                        $addtocart_classes = $file_classes . ($file_classes ? ' ' : '') . 'fcfile_addFile';
                        $attribs = ' class="' . $addtocart_classes . '"';
                        $attribs .= ' title="' . $addtocartinfo . '"';
                        $attribs .= ' filename="' . flexicontent_html::escapeJsText($_filetitle, 's') . '"';
                        $attribs .= ' fieldid="' . $field->id . '"';
                        $attribs .= ' contentid="' . $field->item_id . '"';
                        $attribs .= ' fileid="' . $file_data->id . '"';
                        $actions_arr[] = '<input type="button" ' . $attribs . ' value="' . $addtocarttext . '" />';
                    }
                    // SHARE FILE VIA EMAIL: open a popup or inline email form ...
                    if ($is_public && $allowshare && !$com_mailto_found) {
                        // skip share popup form button if com_mailto is missing
                        $actions_arr[] = ' com_mailto component not found, please disable <b>download link sharing parameter</b> in this file field';
                    } else {
                        if ($is_public && $allowshare) {
                            $send_onclick = 'window.open(\'%s\',\'win2\',\'' . $status . '\'); return false;';
                            $send_form_url = 'index.php?option=com_flexicontent&tmpl=component' . '&task=call_extfunc&exttype=plugins&extfolder=flexicontent_fields&extname=file&extfunc=share_file_form' . '&file_id=' . $file_id . '&content_id=' . $item->id . '&field_id=' . $field->id;
                            $actions_arr[] = '<input type="button" class="' . $file_classes . ' fcfile_shareFile" onclick="' . sprintf($send_onclick, JRoute::_($send_form_url)) . '" title="' . $shareinfo . '" value="' . $sharetext . '" />';
                        }
                    }
                } else {
                    // DOWNLOAD: single file instant download
                    if ($allowdownloads) {
                        // NO ACCESS: add file info via URL variables, in case the URL target needs to use them
                        if (!$authorized && $noaccess_addvars) {
                            $dl_link .= '&fc_field_id="' . $field->id . '&fc_item_id="' . $field->item_id . '&fc_file_id="' . $file_id;
                        }
                        // The download link, if filename/title not shown, then display a 'download' prompt text
                        $actions_arr[] = ($filename_shown && $link_filename ? $icon . ' ' : '') . '<a href="' . $dl_link . '" class="' . $file_classes . ' fcfile_downloadFile" title="' . $downloadsinfo . '" >' . ($filename_shown && $link_filename ? $name_str : $downloadstext) . '</a>';
                    }
                    if ($authorized && $allowview && !$file_data->url) {
                        $actions_arr[] = '
						<a href="' . $dl_link . '?method=view" class="fancybox ' . $file_classes . ' fcfile_viewFile" data-fancybox-type="iframe" title="' . $viewinfo . '" >
							' . $viewtext . '
						</a>';
                        $fancybox_needed = 1;
                    }
                    // ADD TO CART: the link will add file to download list (tree) (handled via a downloads manager module)
                    if ($authorized && $allowaddtocart && !$file_data->url) {
                        // CSS class to anchor downloads list adding function
                        $addtocart_classes = $file_classes . ($file_classes ? ' ' : '') . 'fcfile_addFile';
                        $attribs = ' class="' . $addtocart_classes . '"';
                        $attribs .= ' title="' . $addtocartinfo . '"';
                        $attribs .= ' filename="' . flexicontent_html::escapeJsText($_filetitle, 's') . '"';
                        $attribs .= ' fieldid="' . $field->id . '"';
                        $attribs .= ' contentid="' . $field->item_id . '"';
                        $attribs .= ' fileid="' . $file_data->id . '"';
                        $actions_arr[] = '<a href="javascript:;" ' . $attribs . ' >' . $addtocarttext . '</a>';
                    }
                    // SHARE FILE VIA EMAIL: open a popup or inline email form ...
                    if ($is_public && $allowshare && !$com_mailto_found) {
                        // skip share popup form button if com_mailto is missing
                        $str .= ' com_mailto component not found, please disable <b>download link sharing parameter</b> in this file field';
                    } else {
                        if ($is_public && $allowshare) {
                            $send_onclick = 'window.open(\'%s\',\'win2\',\'' . $status . '\'); return false;';
                            $send_form_url = 'index.php?option=com_flexicontent&tmpl=component' . '&task=call_extfunc&exttype=plugins&extfolder=flexicontent_fields&extname=file&extfunc=share_file_form' . '&file_id=' . $file_id . '&content_id=' . $item->id . '&field_id=' . $field->id;
                            $actions_arr[] = '<a href="javascript:;" class="fcfile_shareFile" onclick="' . sprintf($send_onclick, JRoute::_($send_form_url)) . '" title="' . $shareinfo . '">' . $sharetext . '</a>';
                        }
                    }
                }
            }
            //Display the buttons "DOWNLOAD, SHARE, ADD TO CART" before or after the filename
            if ($buttonsposition) {
                $str .= (count($actions_arr) ? $infoseptxt : "") . '<span class="fcfile_actions">' . implode($actions_arr, $actionseptxt) . '</span>';
            } else {
                $str = (count($actions_arr) ? $infoseptxt : "") . '<span class="fcfile_actions">' . implode($actions_arr, $actionseptxt) . '</span>' . $str;
            }
            // [4]: Add the file description (if displayed inline)
            if ($descr_inline) {
                $str .= $descr_inline;
            }
            // Values Prefix and Suffix Texts
            $field->{$prop}[] = $pretext . $str . $posttext;
            // Some extra data for developers: (absolute) file URL and (absolute) file path
            $field->url[] = $dl_link;
            $file->abspath[] = $abspath;
            $field->file_data[] = $file_data;
            $n++;
        }
        if (!empty($fancybox_needed)) {
            flexicontent_html::loadFramework('fancybox');
        }
        // 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} = '';
        }
    }
Exemplo n.º 11
0
 function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     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 variables
     $is_ingroup = !empty($field->ingroup);
     $use_ingroup = $field->parameters->get('use_ingroup', 0);
     $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
     // Value handling parameters
     $lang_filter_values = 0;
     //$field->parameters->get( 'lang_filter_values', 1);
     // 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"' : '';
     // URL value
     $link_usage = $field->parameters->get('link_usage', 0);
     $default_link = $link_usage == 2 ? $field->parameters->get('default_value_link', '') : '';
     $default_link = $default_link ? JText::_($default_link) : '';
     // URL title & linking text (optional)
     $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', '')) : '';
     $default_title = $default_title ? JText::_($default_title) : '';
     // Get field values
     $values = $values ? $values : $field->value;
     // Check for no values and no default value, and return empty display
     if (empty($values)) {
         if (!strlen($default_link)) {
             $field->{$prop} = $is_ingroup ? array() : '';
             return;
         }
         $values = array();
         $values[0]['link'] = $default_link;
         $values[0]['title'] = $default_title;
         $values[0]['hits'] = 0;
         $values[0] = serialize($values[0]);
     }
     // (* BECAUSE OF THIS, the value display loop expects unserialized values)
     foreach ($values as &$value) {
         // Compatibility for unserialized values or for NULL values in a field group
         if (!is_array($value)) {
             $v = !empty($value) ? @unserialize($value) : false;
             $value = $v !== false || $v === 'b:0;' ? $v : array('link' => $value, 'title' => '', 'hits' => 0);
         }
     }
     unset($value);
     // Unset this or you are looking for trouble !!!, because it is a reference and reusing it will overwrite the pointed variable !!!
     // 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)) {
         $_hits_tip = flexicontent_html::getToolTip(null, '%s ' . JText::_('FLEXI_HITS', true), 0, 0);
         $_attribs = $display_hits == 1 ? 'class="' . (FLEXI_J30GE ? 'hasTooltip' : 'hasTip') . '" title="' . $_hits_tip . '"' : '';
         $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);
     }
     // Initialise property with default value
     $field->{$prop} = array();
     $n = 0;
     foreach ($values as $value) {
         if (empty($value['link']) && !$is_ingroup) {
             continue;
         }
         // Skip empty if not in field group
         if (empty($value['link'])) {
             $field->{$prop}[$n++] = '';
             continue;
         }
         // 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;
         $linktext = '';
         // no linktext for weblink for extended web link field if this is needed
         $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=' . $item->id . '&ord=' . ($n + 1) . '&task=weblink');
         }
         // Create indirect link to web-link address with custom displayed text
         if (empty($linktext)) {
             $linktext = $title ? $title : $this->cleanurl(FLEXI_J30GE ? JStringPunycode::urlToUTF8($value['link']) : $value['link']);
         }
         $html = '<a href="' . $href . '" ' . $link_params . ' itemprop="url">' . $linktext . '</a>';
         // 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') {
                 $html = $hits_html;
             } else {
                 $html .= ' ' . $hits_html;
             }
         }
         // Add prefix / suffix
         $field->{$prop}[$n] = $pretext . $html . $posttext;
         $n++;
         if (!$multiple) {
             break;
         }
         // multiple values disabled, break out of the loop, not adding further values even if the exist
     }
     if (!$is_ingroup) {
         // Apply separator and open/close tags
         $field->{$prop} = implode($separatorf, $field->{$prop});
         if ($field->{$prop} !== '') {
             $field->{$prop} = $opentag . $field->{$prop} . $closetag;
         } else {
             $field->{$prop} = '';
         }
     }
 }
Exemplo n.º 12
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;
     }
     $field->label = JText::_($field->label);
     // initialize framework objects and other variables
     $config = JFactory::getConfig();
     $user = JFactory::getUser();
     // 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
     $date_source = $field->parameters->get('date_source', 0);
     if ($date_source) {
         static $nullDate, $never_date;
         if ($nullDate == null) {
             $nullDate = JFactory::getDBO()->getNullDate();
             $never_date = '';
             //JText::_('FLEXI_NEVER');
         }
         $_value = $date_source == 1 ? $item->publish_up : $item->publish_down;
         if ($_value == $nullDate) {
             $field->{$prop} = $date_source == 2 ? $never_date : '';
             return;
         }
         $values = array($_value);
     }
     // Value handling parameters
     $multiple = $field->parameters->get('allow_multiple', 1);
     $date_allowtime = $field->parameters->get('date_allowtime', 1);
     $use_editor_tz = $field->parameters->get('use_editor_tz', 0);
     $use_editor_tz = $date_allowtime ? $use_editor_tz : 0;
     $customdate = $field->parameters->get('custom_date', FLEXI_J16GE ? 'Y-m-d' : '%Y-%m-%d');
     $dateformat = $field->parameters->get('date_format', $customdate);
     $show_no_value = $field->parameters->get('show_no_value', 0);
     $no_value_msg = $field->parameters->get('no_value_msg', 'FLEXI_NO_VALUE');
     $display_tz_logged = $field->parameters->get('display_tz_logged', 2);
     $display_tz_guests = $field->parameters->get('display_tz_guests', 2);
     $display_tz_suffix = $field->parameters->get('display_tz_suffix', 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;
     }
     // Get timezone to use for displaying the date,  this is a string for J2.5 and an (offset) number for J1.5
     if (!$use_editor_tz) {
         // Raw date output, ignore timezone (no timezone info is printed), NOTE: this is OLD BEHAVIOUR of this field
         $tz_suffix_type = -1;
     } else {
         if ($user->id) {
             $tz_suffix_type = $display_tz_logged;
         } else {
             $tz_suffix_type = $display_tz_guests;
         }
     }
     $tz_info = '';
     switch ($tz_suffix_type) {
         default:
             // including value -1 for raw for output, see above
         // including value -1 for raw for output, see above
         case 0:
             $timezone = FLEXI_J16GE ? 'UTC' : 0;
             //$tz_info = '';
             break;
         case 1:
             $timezone = FLEXI_J16GE ? 'UTC' : 0;
             //$tz_info = ' UTC+0';
             break;
         case 2:
             $timezone = $config->get('offset');
             //$tz_info = ' (site's timezone)';
             break;
         case 3:
             $timezone = $user->getParam('timezone');
             //$tz_info = ' (local time)';
             break;
     }
     // display timezone suffix if this is enabled
     if ($display_tz_suffix && $tz_suffix_type > 0) {
         if (FLEXI_J16GE) {
             $tz = new DateTimeZone($timezone);
             $tz_offset = $tz->getOffset(new JDate()) / 3600;
         } else {
             // Raw date output  // FLEXI_J16GE ? 'UTC' : 0
             $tz_offset = $timezone;
         }
         $tz_info = $tz_offset > 0 ? ' UTC +' . $tz_offset : ' UTC ' . $tz_offset;
     }
     // initialise property
     $field->{$prop} = array();
     $n = 0;
     foreach ($values as $value) {
         if (!strlen($value)) {
             continue;
         }
         // Check if dates are allowed to have time part
         if ($date_allowtime) {
             $date = $value;
         } else {
             @(list($date, $time) = preg_split('#\\s+#', $value, $limit = 2));
         }
         if (empty($date)) {
             continue;
         }
         try {
             $date = JHTML::_('date', $date, JText::_($dateformat), $timezone) . $tz_info;
         } catch (Exception $e) {
             $date = '';
         }
         $field->{$prop}[$n] = $pretext . $date . $posttext;
         $n++;
         if (!$multiple) {
             break;
         }
         // multiple values disabled, break out of the loop, not adding further values even if the exist
     }
     // Apply separator and open/close tags
     $field->{$prop} = implode($separatorf, $field->{$prop});
     if ($field->{$prop} !== '') {
         $field->{$prop} = $opentag . $field->{$prop} . $closetag;
     } else {
         $field->{$prop} = $show_no_value ? JText::_($no_value_msg) : '';
     }
 }
Exemplo n.º 13
0
 function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     $field->label = JText::_($field->label);
     // Some variables
     $is_ingroup = !empty($field->ingroup);
     $use_ingroup = $field->parameters->get('use_ingroup', 0);
     $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
     $view = JRequest::getVar('flexi_callview', JRequest::getVar('view', FLEXI_ITEMVIEW));
     // Value handling parameters
     $lang_filter_values = $field->parameters->get('lang_filter_values', 0);
     $clean_output = $field->parameters->get('clean_output', 0);
     $encode_output = $field->parameters->get('encode_output', 0);
     $format_output = $field->parameters->get('format_output', 0);
     if ($format_output == 1) {
         $decimal_digits_displayed = (int) $field->parameters->get('decimal_digits_displayed', 2);
         $decimal_digits_sep = $field->parameters->get('decimal_digits_sep', '.');
         $decimal_thousands_sep = $field->parameters->get('decimal_thousands_sep', ',');
     }
     // Default value
     $value_usage = $field->parameters->get('default_value_use', 0);
     $default_value = $value_usage == 2 ? $field->parameters->get('default_value', '') : '';
     $default_value = $default_value ? JText::_($default_value) : '';
     // Get field values
     $values = $values ? $values : $field->value;
     // Load default value
     if (empty($values)) {
         if (!strlen($default_value)) {
             $field->{$prop} = $is_ingroup ? array() : '';
             return;
         }
         $values = array($default_value);
     }
     // Language filter, clean output, encode HTML
     if ($clean_output) {
         $ifilter = $clean_output == 1 ? JFilterInput::getInstance(null, null, 1, 1) : JFilterInput::getInstance();
     }
     if ($lang_filter_values || $clean_output || $encode_output || $format_output) {
         // (* BECAUSE OF THIS, the value display loop expects unserialized values)
         foreach ($values as &$value) {
             if ($format_output == 1) {
                 $value = @number_format($value, $decimal_digits_displayed, $decimal_digits_sep, $decimal_thousands_sep);
                 $value = $value === NULL ? 0 : '';
             }
             if (!strlen($value)) {
                 continue;
             }
             // skip further actions
             if ($lang_filter_values) {
                 $value = JText::_($value);
             }
             if ($clean_output) {
                 $value = $ifilter->clean($value, 'string');
             }
             if ($encode_output) {
                 $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
             }
         }
         unset($value);
         // Unset this or you are looking for trouble !!!, because it is a reference and reusing it will overwrite the pointed variable !!!
     }
     // 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');
     $itemprop = $field->parameters->get('microdata_itemprop');
     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;
     }
     // Initialise property with default value
     $field->{$prop} = array();
     $n = 0;
     foreach ($values as $value) {
         if (!strlen($value) && !$is_ingroup) {
             continue;
         }
         // Skip empty if not in field group
         if (!strlen($value)) {
             $field->{$prop}[$n++] = '';
             continue;
         }
         // Add prefix / suffix
         $field->{$prop}[$n] = $pretext . $value . $posttext;
         // Add microdata to every value if field -- is -- in a field group
         if ($is_ingroup && $itemprop) {
             $field->{$prop}[$n] = '<span itemprop="' . $itemprop . '" >' . $field->{$prop}[$n] . '</span>';
         }
         $n++;
         if (!$multiple) {
             break;
         }
         // multiple values disabled, break out of the loop, not adding further values even if the exist
     }
     // Do not convert the array to string if field is in a group, and do not add: FIELD's opetag, closetag, value separator
     if (!$is_ingroup) {
         // Apply values separator
         $field->{$prop} = implode($separatorf, $field->{$prop});
         if ($field->{$prop} !== '') {
             // Apply field 's opening / closing texts
             $field->{$prop} = $opentag . $field->{$prop} . $closetag;
             // Add microdata once for all values, if field -- is NOT -- in a field group
             if ($itemprop) {
                 $field->{$prop} = '<span itemprop="' . $itemprop . '" >' . $field->{$prop} . '</span>';
             }
         }
     }
     // ************
     // Add OGP tags
     // ************
     if ($field->parameters->get('useogp', 0) && !empty($field->{$prop})) {
         // Get ogp configuration
         $ogpinview = $field->parameters->get('ogpinview', array());
         $ogpinview = FLEXIUtilities::paramToArray($ogpinview);
         $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300);
         $ogpusage = $field->parameters->get('ogpusage', 0);
         if (in_array($view, $ogpinview)) {
             switch ($ogpusage) {
                 case 1:
                     $usagetype = 'title';
                     break;
                 case 2:
                     $usagetype = 'description';
                     break;
                 default:
                     $usagetype = '';
                     break;
             }
             if ($usagetype) {
                 $content_val = !$is_ingroup ? flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen) : flexicontent_html::striptagsandcut($opentag . implode($separatorf, $field->{$prop}) . $closetag, $ogpmaxlen);
                 JFactory::getDocument()->addCustomTag('<meta property="og:' . $usagetype . '" content="' . $content_val . '" />');
             }
         }
     }
 }
Exemplo n.º 14
0
 public function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     static $all_langs = null;
     static $cat_links = array();
     static $acclvl_names = null;
     $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');
     // Microdata (classify the field values for search engines)
     $itemprop = $field->parameters->get('microdata_itemprop');
     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;
     }
     $props_type = $field->parameters->get('props_type');
     switch ($props_type) {
         case 'language':
             if ($all_langs === null) {
                 $all_langs = FLEXIUtilities::getLanguages($hash = 'code');
             }
             $lang_data = $all_langs->{$item->language};
             $field->{$prop} = @$lang_data->title_native ? $lang_data->title_native : $lang_data->name;
             break;
         case 'alias':
             $field->{$prop} = $item->{$props_type};
             break;
         case 'category':
             $link_maincat = $field->parameters->get('link_maincat', 1);
             if ($link_maincat) {
                 $maincatid = isset($item->maincatid) ? $item->maincatid : $item->catid;
                 // maincatid is used by item view
                 if (!isset($cat_links[$maincatid])) {
                     $maincat_slug = $item->maincatid ? $item->maincatid . ':' . $item->maincat_alias : $item->catid;
                     $cat_links[$maincatid] = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($maincat_slug));
                 }
             }
             $maincat_title = !empty($item->maincat_title) ? $item->maincat_title : 'catid: ' . $item->catid;
             $field->{$prop} = $link_maincat ? '<a class="fc_coreprop fc_maincat link_' . $field->name . '" href="' . $cat_links[$maincatid] . '">' . $maincat_title . '</a>' : $maincat_title;
             break;
         case 'access':
             if ($acclvl_names === null) {
                 $acclvl_names = flexicontent_db::getAccessNames();
             }
             $field->{$prop} = isset($acclvl_names[$item->access]) ? $acclvl_names[$item->access] : 'unknown access level id: ' . $item->access;
             break;
         default:
             $field->{$prop} = $props_type;
             break;
     }
     if (strlen($field->{$prop})) {
         $field->{$prop} = $opentag . $pretext . $field->{$prop} . $posttext . $closetag;
     }
 }
Exemplo n.º 15
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;
     }
     $field->label = JText::_($field->label);
     // some parameter shortcuts
     // This is field 's MAIN value property
     $addr_usage = $field->parameters->get('default_value_use', 0);
     $default_addr = $addr_usage == 2 ? $field->parameters->get('default_value', '') : '';
     // 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_addr)) {
         $field->{$prop} = '';
         return;
     } else {
         if (empty($values) && strlen($default_addr)) {
             $values = array();
             $values[0]['addr'] = JText::_($default_addr);
             $values[0]['text'] = JText::_($default_title);
             $values[0] = serialize($values[0]);
         }
     }
     $format = JRequest::getCmd('format', null);
     // 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;
     }
     // initialise property
     $field->{$prop} = array();
     $n = 0;
     foreach ($values as $value) {
         if (!strlen($value)) {
             continue;
         }
         // Compatibility for old unserialized values
         $value = @unserialize($value) !== false || $value === 'b:0;' ? unserialize($value) : $value;
         if (is_array($value)) {
             $addr = $value['addr'];
             $text = $value['text'];
         } else {
             $addr = $value;
             $text = '';
         }
         // If not using property or property is empty, then use default property value
         // NOTE: default property values have been cleared, if (propertyname_usage != 2)
         $text = $usetitle && strlen($text) ? $text : $default_title;
         // Create cloacked email address with custom displayed text
         if (strlen($text) && $usetitle) {
             $field->{$prop}[] = $format != 'feed' ? $pretext . JHTML::_('email.cloak', $addr, 1, $text, 0) . $posttext : $pretext . '<a href="mailto:' . $addr . '" target="_blank">' . $text . '</a>' . $posttext;
         } else {
             $field->{$prop}[] = $format != 'feed' ? $pretext . JHTML::_('email.cloak', $addr) . $posttext : $pretext . '<a href="mailto:' . $addr . '" target="_blank">' . $addr . '</a>' . $posttext;
         }
         $n++;
     }
     // 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} = '';
     }
 }
Exemplo n.º 16
0
    function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
    {
        // 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);
        }
        // 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);
        static $multiboxadded = false;
        static $fancyboxadded = false;
        static $gallerifficadded = false;
        static $elastislideadded = false;
        static $photoswipeadded = false;
        $values = $values ? $values : $field->value;
        $view = JRequest::getVar('flexi_callview', JRequest::getVar('view', FLEXI_ITEMVIEW));
        $multiple = $field->parameters->get('allow_multiple', 0);
        $image_source = $field->parameters->get('image_source', 0);
        if ($image_source > 1) {
            global $fc_folder_mode_err;
            if (empty($fc_folder_mode_err[$field->id])) {
                echo __FUNCTION__ . "(): folder-mode: " . $image_source . " not implemented please change image-source mode in image/gallery field with id: " . $field->id;
                $fc_folder_mode_err[$field->id] = 1;
                $image_source = 1;
            }
        }
        $all_media = $field->parameters->get('list_all_media_files', 0);
        $unique_thumb_method = $field->parameters->get('unique_thumb_method', 0);
        $dir = $field->parameters->get('dir');
        $dir_url = str_replace('\\', '/', $dir);
        // Check if using folder of original content being translated
        $of_usage = $field->untranslatable ? 1 : $field->parameters->get('of_usage', 0);
        $u_item_id = $of_usage && $item->lang_parent_id && $item->lang_parent_id != $item->id ? $item->lang_parent_id : $item->id;
        // FLAG to indicate if images are shared across fields, has the effect of adding field id to image thumbnails
        $multiple_image_usages = !$image_source && $all_media && $unique_thumb_method == 0;
        $extra_prefix = $multiple_image_usages ? 'fld' . $field->id . '_' : '';
        $usealt = $field->parameters->get('use_alt', 1);
        $alt_usage = $field->parameters->get('alt_usage', 0);
        $default_alt = $alt_usage == 2 ? $field->parameters->get('default_alt', '') : '';
        $usetitle = $field->parameters->get('use_title', 1);
        $title_usage = $field->parameters->get('title_usage', 0);
        $default_title = $title_usage == 2 ? JText::_($field->parameters->get('default_title', '')) : '';
        $usedesc = $field->parameters->get('use_desc', 1);
        $desc_usage = $field->parameters->get('desc_usage', 0);
        $default_desc = $desc_usage == 2 ? $field->parameters->get('default_desc', '') : '';
        // Separators / enclosing characters
        $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', 0);
        $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;
        }
        // intro-full mode get their values from item's parameters
        if ($image_source == -1) {
            $values = array();
            $_image_name = $view == 'item' ? 'full' : 'intro';
            $_image_path = $item->images->get('image_' . $_image_name, '');
            if ($_image_path) {
                $image_by_params = array();
                // field attributes (mode-specific)
                $image_by_params['image_size'] = $_image_name;
                $image_by_params['image_path'] = $_image_path;
                // field attributes (value)
                $image_by_params['originalname'] = basename($_image_path);
                $image_by_params['alt'] = $item->images->get($_image_name . '_alt', '');
                $image_by_params['title'] = $item->images->get($_image_name . '_alt', '');
                $image_by_params['desc'] = $item->images->get($_image_name . '_caption', '');
                $image_by_params['urllink'] = '';
                $values = array(serialize($image_by_params));
            }
        }
        // Check for deleted image files or image files that cannot be thumbnailed,
        // rebuilding thumbnails as needed, and then assigning checked values to a new array
        $usable_values = array();
        if ($values) {
            foreach ($values as $index => $value) {
                $value = unserialize($value);
                if (plgFlexicontent_fieldsImage::rebuildThumbs($field, $value, $item)) {
                    $usable_values[] = $values[$index];
                }
            }
        }
        $values =& $usable_values;
        // Allow for thumbnailing of the default image
        $field->using_default_value = false;
        if (!count($values)) {
            // Create default image to be used if  (a) no image assigned  OR  (b) images assigned have been deleted
            $default_image = $field->parameters->get('default_image', '');
            if ($default_image) {
                $default_image_val = array();
                // field attributes (default value specific)
                $default_image_val['default_image'] = $default_image;
                // holds complete relative path and indicates that it is default image for field
                // field attributes (value)
                $default_image_val['originalname'] = basename($default_image);
                $default_image_val['alt'] = $default_alt;
                $default_image_val['title'] = $default_title;
                $default_image_val['desc'] = $default_desc;
                $default_image_val['urllink'] = '';
                // Create thumbnails for default image
                if (plgFlexicontent_fieldsImage::rebuildThumbs($field, $default_image_val, $item)) {
                    $values = array(serialize($default_image_val));
                }
                // Also default image can (possibly) be used across multiple fields, so set flag to add field id to filenames of thumbnails
                $multiple_image_usages = true;
                $extra_prefix = 'fld' . $field->id . '_';
                $field->using_default_value = true;
            }
        }
        // Check for no values, and return empty display, otherwise assign (possibly) altered value array to back to the field
        if (!count($values)) {
            $field->{$prop} = '';
            return;
        }
        $field->value = $values;
        $app = JFactory::getApplication();
        $document = JFactory::getDocument();
        $option = JRequest::getVar('option');
        jimport('joomla.filesystem');
        $isFeedView = JRequest::getCmd('format', null) == 'feed';
        $isItemsManager = $app->isAdmin() && $view == 'items' && $option == 'com_flexicontent';
        $isSite = $app->isSite();
        // some parameter shortcuts
        $uselegend = $field->parameters->get('uselegend', 1);
        $usepopup = $field->parameters->get('usepopup', 1);
        $popuptype = $field->parameters->get('popuptype', 1);
        $popuptype_mobile = $field->parameters->get('popuptype_mobile', $popuptype);
        // this defaults to desktop when empty
        $popuptype = $useMobile ? $popuptype_mobile : $popuptype;
        $grouptype = $field->parameters->get('grouptype', 1);
        $grouptype = $multiple ? 0 : $grouptype;
        // Field in gallery mode: Force grouping of images per field (current item)
        // Needed by some js galleries
        $thumb_w_s = $field->parameters->get('w_s', 120);
        $thumb_h_s = $field->parameters->get('h_s', 90);
        // Check and disable 'uselegend'
        $legendinview = $field->parameters->get('legendinview', array(FLEXI_ITEMVIEW, 'category'));
        $legendinview = FLEXIUtilities::paramToArray($legendinview);
        if ($view == FLEXI_ITEMVIEW && !in_array(FLEXI_ITEMVIEW, $legendinview)) {
            $uselegend = 0;
        }
        if ($view == 'category' && !in_array('category', $legendinview)) {
            $uselegend = 0;
        }
        if ($isItemsManager && !in_array('backend', $legendinview)) {
            $uselegend = 0;
        }
        // Check and disable 'usepopup'
        $popupinview = $field->parameters->get('popupinview', array(FLEXI_ITEMVIEW, 'category', 'backend'));
        $popupinview = FLEXIUtilities::paramToArray($popupinview);
        if ($view == FLEXI_ITEMVIEW && !in_array(FLEXI_ITEMVIEW, $popupinview)) {
            $usepopup = 0;
        }
        if ($view == 'category' && !in_array('category', $popupinview)) {
            $usepopup = 0;
        }
        if ($view == 'module' && !in_array('module', $popupinview)) {
            $usepopup = 0;
        }
        if ($isItemsManager && !in_array('backend', $popupinview)) {
            $usepopup = 0;
        }
        // FORCE multibox popup in backend ...
        if ($isItemsManager) {
            $popuptype = 1;
        }
        // remaining parameters shortcuts
        $showtitle = $field->parameters->get('showtitle', 0);
        $showdesc = $field->parameters->get('showdesc', 0);
        $linkto_url = $field->parameters->get('linkto_url', 0);
        $url_target = $field->parameters->get('url_target', '_self');
        $isLinkToPopup = $linkto_url && $url_target == 'multibox';
        $useogp = $field->parameters->get('useogp', 0);
        $ogpinview = $field->parameters->get('ogpinview', array());
        $ogpinview = FLEXIUtilities::paramToArray($ogpinview);
        $ogpthumbsize = $field->parameters->get('ogpthumbsize', 2);
        // load the tooltip library if redquired
        if ($uselegend) {
            JHTML::_('behavior.tooltip');
        }
        // MultiBox maybe added in extra cases besides popup
        // (a) in Item manager, (b) When linking to URL in popup target
        $view_allows_mb = $isItemsManager || $isSite && !$isFeedView;
        $config_needs_mb = $isLinkToPopup || $usepopup && $popuptype == 1;
        if ($view_allows_mb && $config_needs_mb) {
            if (!$multiboxadded) {
                //echo $field->name.": multiboxadded";
                FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
                // Multibox integration use different version for FC v2x
                if (FLEXI_J16GE) {
                    // Include MultiBox CSS files
                    $document->addStyleSheet(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/Styles/multiBox.css');
                    // NEW ie6 hack
                    if (substr($_SERVER['HTTP_USER_AGENT'], 0, 34) == "Mozilla/4.0 (compatible; MSIE 6.0;") {
                        $document->addStyleSheet(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/Styles/multiBoxIE6.css');
                    }
                    // This is the new code for new multibox version, old multibox hack is the following lines
                    // Include MultiBox Javascript files
                    $document->addScript(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/Scripts/overlay.js');
                    $document->addScript(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/Scripts/multiBox.js');
                    // Add js code for creating a multibox instance
                    $extra_options = '';
                    if ($isItemsManager) {
                        $extra_options .= '' . ',showNumbers: false' . ',showControls: false';
                    }
                    $box = "\n\t\t\t\t\t\twindow.addEvent('domready', function(){\n\t\t\t\t\t\t\t//call multiBox\n\t\t\t\t\t\t\tvar initMultiBox = new multiBox({\n\t\t\t\t\t\t\t\tmbClass: '.mb',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)\n\t\t\t\t\t\t\t\tcontainer: \$(document.body),//where to inject multiBox\n\t\t\t\t\t\t\t\tdescClassName: 'multiBoxDesc',//the class name of the description divs\n\t\t\t\t\t\t\t\tpath: './Files/',//path to mp3 and flv players\n\t\t\t\t\t\t\t\tuseOverlay: true,//use a semi-transparent background. default: false;\n\t\t\t\t\t\t\t\tmaxSize: {w:4000, h:3000},//max dimensions (width,height) - set to null to disable resizing\n\t\t\t\t\t\t\t\taddDownload: false,//do you want the files to be downloadable?\n\t\t\t\t\t\t\t\tpathToDownloadScript: './Scripts/forceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)\n\t\t\t\t\t\t\t\taddRollover: true,//add rollover fade to each multibox link\n\t\t\t\t\t\t\t\taddOverlayIcon: true,//adds overlay icons to images within multibox links\n\t\t\t\t\t\t\t\taddChain: true,//cycle through all images fading them out then in\n\t\t\t\t\t\t\t\trecalcTop: true,//subtract the height of controls panel from top position\n\t\t\t\t\t\t\t\taddTips: true,//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)\n\t\t\t\t\t\t\t\tautoOpen: 0//to auto open a multiBox element on page load change to (1, 2, or 3 etc)\n\t\t\t\t\t\t\t\t" . $extra_options . "\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t";
                    $document->addScriptDeclaration($box);
                } else {
                    // Include MultiBox CSS files
                    $document->addStyleSheet(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/multibox.css');
                    // OLD ie6 hack
                    $csshack = '
					<!--[if lte IE 6]>
					<style type="text/css">
					.MultiBoxClose, .MultiBoxPrevious, .MultiBoxNext, .MultiBoxNextDisabled, .MultiBoxPreviousDisabled { 
						behavior: url(' . 'components/com_flexicontent/librairies/multibox/iepngfix.htc); 
					}
					</style>
					<![endif]-->
					';
                    $document->addCustomTag($csshack);
                    // Include MultiBox Javascript files
                    $document->addScript(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/js/overlay.js');
                    $document->addScript(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/js/multibox.js');
                    // Add js code for creating a multibox instance
                    $extra_options = $isItemsManager ? ', showNumbers: false, showControls: false' : '';
                    $box = "\n\t\t\t\t\t\tvar box = {};\n\t\t\t\t\t\twindow.addEvent('domready', function(){\n\t\t\t\t\t\t\tbox = new MultiBox('mb', {descClassName: 'multiBoxDesc', useOverlay: true" . $extra_options . " });\n\t\t\t\t\t\t});\n\t\t\t\t\t";
                    $document->addScriptDeclaration($box);
                }
                $multiboxadded = true;
            }
        }
        // Regardless if above has added multibox , we will add a different JS gallery if so configured because it maybe needed
        if (!$isSite || $isFeedView) {
            // Is backend OR it is a feed view, do not add any JS library
        } else {
            if ($usepopup) {
                switch ($popuptype) {
                    // Add Fancybox image popup
                    case 4:
                        if (!$fancyboxadded) {
                            $fancyboxadded = true;
                            flexicontent_html::loadFramework('fancybox');
                        }
                        break;
                        // Add Galleriffic inline slideshow gallery
                    // Add Galleriffic inline slideshow gallery
                    case 5:
                        $inline_gallery = 1;
                        if (!$gallerifficadded) {
                            flexicontent_html::loadFramework('galleriffic');
                            $gallerifficadded = true;
                        }
                        break;
                        // Add Elastislide inline carousel gallery (Responsive image gallery with togglable thumbnail-strip, plus previewer and description)
                    // Add Elastislide inline carousel gallery (Responsive image gallery with togglable thumbnail-strip, plus previewer and description)
                    case 7:
                        if (!$elastislideadded) {
                            flexicontent_html::loadFramework('elastislide');
                            $elastislideadded = true;
                        }
                        $uid = 'es_' . $field->name . "_fcitem" . $item->id;
                        $js = file_get_contents(JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'librairies' . DS . 'elastislide' . DS . 'js' . DS . 'gallery_tmpl.js');
                        $js = str_replace('unique_gal_id', $uid, $js);
                        $js = str_replace('__thumb_width__', $field->parameters->get('w_s', 120), $js);
                        $document->addScriptDeclaration($js);
                        $document->addCustomTag('
				<script id="img-wrapper-tmpl_' . $uid . '" type="text/x-jquery-tmpl">	
					<div class="rg-image-wrapper">
						{{if itemsCount > 1}}
							<div class="rg-image-nav">
								<a href="#" class="rg-image-nav-prev">' . JText::_('FLEXI_PREVIOUS') . '</a>
								<a href="#" class="rg-image-nav-next">' . JText::_('FLEXI_NEXT') . '</a>
							</div>
						{{/if}}
						<div class="rg-image"></div>
						<div class="rg-loading"></div>
						<div class="rg-caption-wrapper">
							<div class="rg-caption" style="display:none;">
								<p></p>
							</div>
						</div>
					</div>
				</script>
				');
                        break;
                        // Add PhotoSwipe popup carousel gallery
                    // Add PhotoSwipe popup carousel gallery
                    case 8:
                        if (!$photoswipeadded) {
                            flexicontent_html::loadFramework('photoswipe');
                            $photoswipeadded = true;
                        }
                        break;
                }
            }
        }
        // Extra thumbnails sub-folder for various
        if ($field->using_default_value) {
            $extra_folder = '';
            // default value
        } else {
            if ($image_source == -1) {
                $extra_folder = 'intro_full';
                // intro-full images mode
            } else {
                if ($image_source > 0) {
                    $extra_folder = 'item_' . $u_item_id . '_field_' . $field->id;
                    // folder-mode 1
                    if ($image_source > 1) {
                    }
                    // TODO
                } else {
                    $extra_folder = '';
                    // db-mode
                }
            }
        }
        // Create thumbs/image Folder and URL paths
        $thumb_folder = JPATH_SITE . DS . JPath::clean($dir . ($extra_folder ? DS . $extra_folder : ''));
        $thumb_urlpath = $dir_url . ($extra_folder ? '/' . $extra_folder : '');
        if ($field->using_default_value) {
            // default image of this field, these are relative paths up to site root
            $orig_urlpath = str_replace('\\', '/', dirname($default_image_val['default_image']));
        } else {
            if ($image_source == -1) {
                // intro-full image values, these are relative paths up to the site root, must be calculated later !!
                $orig_urlpath = str_replace('\\', '/', dirname($image_by_params['image_path']));
            } else {
                if ($image_source > 0) {
                    // various folder-mode(s)
                    $orig_urlpath = $thumb_urlpath . '/original';
                } else {
                    // db-mode
                    $cparams = JComponentHelper::getParams('com_flexicontent');
                    $orig_urlpath = str_replace('\\', '/', JPath::clean($cparams->get('file_path', 'components/com_flexicontent/uploads')));
                }
            }
        }
        $i = -1;
        $field->{$prop} = array();
        $field->thumbs_src['backend'] = array();
        $field->thumbs_src['small'] = array();
        $field->thumbs_src['medium'] = array();
        $field->thumbs_src['large'] = array();
        $field->thumbs_src['original'] = array();
        foreach ($values as $val) {
            // Unserialize value's properties and check for empty original name property
            $value = unserialize($val);
            $image_name = trim(@$value['originalname']);
            if (!strlen($image_name)) {
                continue;
            }
            $i++;
            // Create thumbnails urls, note thumbnails have already been verified above
            $wl = $field->parameters->get('w_l', 800);
            $hl = $field->parameters->get('h_l', 600);
            $title = @$value['title'] ? $value['title'] : '';
            $alt = @$value['alt'] ? $value['alt'] : flexicontent_html::striptagsandcut($item->title, 60);
            $alt = flexicontent_html::escapeJsText($alt, 's');
            $desc = @$value['desc'] ? $value['desc'] : '';
            $srcb = $thumb_urlpath . '/b_' . $extra_prefix . $image_name;
            // backend
            $srcs = $thumb_urlpath . '/s_' . $extra_prefix . $image_name;
            // small
            $srcm = $thumb_urlpath . '/m_' . $extra_prefix . $image_name;
            // medium
            $srcl = $thumb_urlpath . '/l_' . $extra_prefix . $image_name;
            // large
            $srco = $orig_urlpath . '/' . $image_name;
            // original image
            // Create a popup url link
            $urllink = @$value['urllink'] ? $value['urllink'] : '';
            if ($urllink && false === strpos($urllink, '://')) {
                $urllink = 'http://' . $urllink;
            }
            // Create a popup tooltip (legend)
            $tip = $title . '::' . $desc;
            $tip = flexicontent_html::escapeJsText($tip, 's');
            $legend = $uselegend && (!empty($title) || !empty($desc)) ? ' class="hasTip" title="' . $tip . '"' : '';
            // Create a unique id for the link tags, and a class name for image tags
            $uniqueid = $field->item_id . '_' . $field->id . '_' . $i;
            $class_img_field = 'fc_field_image';
            // Decide thumbnail to use
            $thumb_size = 0;
            if ($isItemsManager) {
                $thumb_size = -1;
            } else {
                if ($view == 'category') {
                    $thumb_size = $field->parameters->get('thumbincatview', 1);
                } else {
                    if ($view == FLEXI_ITEMVIEW) {
                        $thumb_size = $field->parameters->get('thumbinitemview', 2);
                    }
                }
            }
            switch ($thumb_size) {
                case -1:
                    $src = $srcb;
                    break;
                case 1:
                    $src = $srcs;
                    break;
                case 2:
                    $src = $srcm;
                    break;
                case 3:
                    $src = $srcl;
                    break;
                    // this makes little sense, since both thumbnail and popup image are size 'large'
                // this makes little sense, since both thumbnail and popup image are size 'large'
                case 4:
                    $src = $srco;
                    break;
                default:
                    $src = $srcs;
                    break;
            }
            // Create a grouping name
            switch ($grouptype) {
                case 0:
                    $group_name = 'fcview_' . $view . '_fcitem_' . $field->item_id . '_fcfield_' . $field->id;
                    break;
                case 1:
                    $group_name = 'fcview_' . $view . '_fcitem_' . $field->item_id;
                    break;
                case 2:
                    $group_name = 'fcview_' . $view;
                    break;
                default:
                    $group_name = '';
                    break;
            }
            // ADD some extra (display) properties that point to all sizes, currently SINGLE IMAGE only
            if ($i == 0) {
                $field->{"display_backend_src"} = JURI::root(true) . '/' . $srcb;
                $field->{"display_small_src"} = JURI::root(true) . '/' . $srcs;
                $field->{"display_medium_src"} = JURI::root(true) . '/' . $srcm;
                $field->{"display_large_src"} = JURI::root(true) . '/' . $srcl;
                $field->{"display_original_src"} = JURI::root(true) . '/' . $srco;
            }
            $field->thumbs_src['backend'][] = JURI::root(true) . '/' . $srcb;
            $field->thumbs_src['small'][] = JURI::root(true) . '/' . $srcs;
            $field->thumbs_src['medium'][] = JURI::root(true) . '/' . $srcm;
            $field->thumbs_src['large'][] = JURI::root(true) . '/' . $srcl;
            $field->thumbs_src['original'][] = JURI::root(true) . '/' . $srco;
            $field->thumbs_path['backend'][] = JPATH_SITE . DS . $srcb;
            $field->thumbs_path['small'][] = JPATH_SITE . DS . $srcs;
            $field->thumbs_path['medium'][] = JPATH_SITE . DS . $srcm;
            $field->thumbs_path['large'][] = JPATH_SITE . DS . $srcl;
            $field->thumbs_path['original'][] = JPATH_SITE . DS . $srco;
            // Suggest image for external use, e.g. for Facebook etc
            if ($isSite && !$isFeedView && $useogp) {
                if (in_array($view, $ogpinview)) {
                    switch ($ogpthumbsize) {
                        case 1:
                            $ogp_src = $field->{"display_small_src"};
                            break;
                            // this maybe problematic, since it maybe too small or not accepted by social website
                        // this maybe problematic, since it maybe too small or not accepted by social website
                        case 2:
                            $ogp_src = $field->{"display_medium_src"};
                            break;
                        case 3:
                            $ogp_src = $field->{"display_large_src"};
                            break;
                        case 4:
                            $ogp_src = $field->{"display_original_src"};
                            break;
                        default:
                            $ogp_src = $field->{"display_medium_src"};
                            break;
                    }
                    $document->addCustomTag('<link rel="image_src" href="' . $ogp_src . '" />');
                    $document->addCustomTag('<meta property="og:image" content="' . $ogp_src . '" />');
                }
            }
            // Check if a custom URL-only (display) variable was requested and return it here,
            // without rendering the extra image parameters like legend, pop-up, etc
            if (in_array($prop, array("display_backend_src", "display_small_src", "display_medium_src", "display_large_src", "display_original_src"))) {
                return $field->{$prop};
            }
            // Create image tags (according to configuration parameters) that will be used for the requested 'display' variable
            switch ($prop) {
                case 'display_backend':
                    $img_legend = '<img src="' . JURI::root(true) . '/' . $srcb . '" alt="' . $alt . '"' . $legend . ' class="' . $class_img_field . '" />';
                    $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcb . '" alt="' . $alt . '" class="' . $class_img_field . '" />';
                    break;
                case 'display_small':
                    $img_legend = '<img src="' . JURI::root(true) . '/' . $srcs . '" alt="' . $alt . '"' . $legend . ' class="' . $class_img_field . '" />';
                    $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcs . '" alt="' . $alt . '" class="' . $class_img_field . '" />';
                    break;
                case 'display_medium':
                    $img_legend = '<img src="' . JURI::root(true) . '/' . $srcm . '" alt="' . $alt . '"' . $legend . ' class="' . $class_img_field . '" />';
                    $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcm . '" alt="' . $alt . '" class="' . $class_img_field . '" />';
                    break;
                case 'display_large':
                    $img_legend = '<img src="' . JURI::root(true) . '/' . $srcl . '" alt="' . $alt . '"' . $legend . ' class="' . $class_img_field . '" />';
                    $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcl . '" alt="' . $alt . '" class="' . $class_img_field . '" />';
                    break;
                case 'display_original':
                    $img_legend = '<img src="' . JURI::root(true) . '/' . $srco . '" alt="' . $alt . '"' . $legend . ' class="' . $class_img_field . '" />';
                    $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srco . '" alt="' . $alt . '" class="' . $class_img_field . '" />';
                    break;
                case 'display':
                default:
                    $img_legend = '<img src="' . JURI::root(true) . '/' . $src . '" alt="' . $alt . '"' . $legend . ' class="' . $class_img_field . '" />';
                    $img_nolegend = '<img src="' . JURI::root(true) . '/' . $src . '" alt="' . $alt . '" class="' . $class_img_field . '" />';
                    break;
            }
            // *********************************************
            // FINALLY CREATE the field display variable ...
            // *********************************************
            if ($isItemsManager) {
                // CASE 1: Handle image displayed in backend items manager
                if ($usepopup) {
                    $field->{$prop} = '
					<a href="../' . $srcl . '" id="mb' . $uniqueid . '" class="mb" rel="[images]" >
						' . $img_legend . '
					</a>
					<div class="multiBoxDesc mb' . $uniqueid . '">' . ($desc ? $desc : $title) . '</div>
					';
                } else {
                    $field->{$prop} = $img_legend;
                }
                return;
                // Single image always ...
            } else {
                if ($linkto_url && $urllink) {
                    // CASE 2: Handle linking to a URL instead of image zooming popup
                    if ($url_target == 'multibox') {
                        // (a) Link to URL that opens inside a popup
                        $field->{$prop}[] = '
					<script>document.write(\'<a href="' . $urllink . '" id="mb' . $uniqueid . '" class="mb" rel="width:\'+((MooTools.version>=\'1.2.4\' ? window.getSize().x : window.getSize().size.x)-150)+\',height:\'+((MooTools.version>=\'1.2.4\' ? window.getSize().y : window.getSize().size.y)-150)+\'">\')</script>
						' . $img_legend . '
					<script>document.write(\'</a>\')</script>
					<div class="multiBoxDesc mbox_img_url mb' . $uniqueid . '">' . ($desc ? $desc : $title) . '</div>
					';
                    } else {
                        // (b) Just link to URL
                        $field->{$prop}[] = '
					<a href="' . $urllink . '" target="' . $url_target . '">
						' . $img_legend . '
					</a>
					';
                    }
                } else {
                    if ($usepopup) {
                        // CASE 3: Handle image zooming popup
                        // no popup if image is the largest one
                        if ($prop == 'display_large' || $prop == 'display_original') {
                            $field->{$prop}[] = $img_legend;
                            continue;
                        }
                        switch ($popuptype) {
                            case 1:
                                // Multibox image popup
                                $group_str = $group_name ? 'rel="[' . $group_name . ']"' : '';
                                $field->{$prop}[] = '
						<a href="' . $srcl . '" id="mb' . $uniqueid . '" class="mb" ' . $group_str . ' >
							' . $img_legend . '
						</a>
						<div class="multiBoxDesc mb' . $uniqueid . '">' . ($desc ? $desc : $title) . '</div>
						';
                                break;
                            case 2:
                                // Rokbox image popup
                                $title_attr = flexicontent_html::escapeJsText($desc ? $desc : $title, 's');
                                $group_str = '';
                                // no support for image grouping
                                $field->{$prop}[] = '
						<a href="' . $srcl . '" rel="rokbox[' . $wl . ' ' . $hl . ']" ' . $group_str . ' title="' . $title_attr . '" data-rokbox data-rokbox-caption="' . $title_attr . '">
							' . $img_nolegend . '
						</a>
						';
                                break;
                            case 3:
                                // JCE popup image popup
                                $title_attr = flexicontent_html::escapeJsText($desc ? $desc : $title, 's');
                                $group_str = $group_name ? 'rel="group[' . $group_name . ']"' : '';
                                $field->{$prop}[] = '
						<a href="' . $srcl . '" class="jcepopup" ' . $group_str . ' title="' . $title_attr . '">
							' . $img_nolegend . '
						</a>
						';
                                break;
                            case 4:
                                // Fancybox image popup
                                $title_attr = flexicontent_html::escapeJsText($desc ? $desc : $title, 's');
                                $group_str = $group_name ? 'data-fancybox-group="' . $group_name . '"' : '';
                                $field->{$prop}[] = '
						<a href="' . $srcl . '" class="fancybox" ' . $group_str . ' title="' . $title_attr . '">
							' . $img_nolegend . '
						</a>
						';
                                break;
                            case 5:
                                // Galleriffic inline slideshow gallery
                                $group_str = '';
                                // image grouping: not needed / not applicatble
                                $field->{$prop}[] = '
						<a class="thumb" name="drop" href="' . $srcl . '" style="">
							' . $img_legend . '
						</a>
						<div class="caption">
							' . '<b>' . $title . '</b><br/>' . $desc . '
						</div>
						';
                                break;
                            case 6:
                                // (Widgetkit) SPOTlight image popup
                                $title_attr = flexicontent_html::escapeJsText($desc ? $desc : $title, 's');
                                $group_str = $group_name ? 'data-spotlight-group="' . $group_name . '"' : '';
                                $field->{$prop}[] = '
						<a href="' . $srcl . '" data-lightbox="on" data-spotlight="effect:bottom" ' . $group_str . ' title="' . $title_attr . '">
							' . $img_nolegend . '
							<div class="overlay">
								' . '<b>' . $title . '</b>: ' . $desc . '
							</div>
						</a>
						';
                                break;
                            case 7:
                                // Elastislide inline carousel gallery (Responsive image gallery with togglable thumbnail-strip, plus previewer and description)
                                // *** NEEDS: thumbnail list must be created with large size thubmnails, these will be then thumbnailed by the JS gallery code
                                $title_attr = flexicontent_html::escapeJsText($desc ? $desc : $title, 's');
                                $img_legend_custom = '
						 <img src="' . JURI::root(true) . '/' . $src . '" alt ="' . $alt . '"' . $legend . ' class="' . $class_img_field . '"
						 	data-large="' . JURI::root(true) . '/' . $srcl . '" data-description="' . $title_attr . '"/>
					';
                                $group_str = $group_name ? 'rel="[' . $group_name . ']"' : '';
                                $field->{$prop}[] = '
						<li><a href="javascript:;">
							' . $img_legend_custom . '
						</a></li>
						';
                                break;
                            case 8:
                                // PhotoSwipe popup carousel gallery
                                $group_str = $group_name ? 'rel="[' . $group_name . ']"' : '';
                                $field->{$prop}[] = '
						<a href="' . $srcl . '" ' . $group_str . ' >
							' . $img_legend . '
						</a>
						';
                                break;
                            default:
                                // Unknown Gallery Type, just add thumbails ...
                                $field->{$prop}[] = $img_legend;
                                break;
                        }
                    } else {
                        // CASE 4: Plain Thumbnail List without any (popup / inline) gallery code
                        $field->{$prop}[] = $img_legend;
                    }
                }
            }
            $n = count($field->{$prop}) - 1;
            if ($showtitle && $title || $showdesc && $desc) {
                $field->{$prop}[$n] = '<div class="fc_img_tooltip_data" style="float:left; margin-right:8px;" >' . $field->{$prop}[$i];
            }
            if ($showtitle && $title) {
                $field->{$prop}[$n] .= '<div class="fc_img_tooltip_title" style="line-height:1em; font-weight:bold;">' . $title . '</div>';
            }
            if ($showdesc && $desc) {
                $field->{$prop}[$n] .= '<div class="fc_img_tooltip_desc" style="line-height:1em;">' . $desc . '</div>';
            }
            if ($showtitle && $title || $showdesc && $desc) {
                $field->{$prop}[$n] .= '</div>';
            }
            $field->{$prop}[$n] = $pretext . $field->{$prop}[$i] . $posttext;
        }
        // ************************************************************
        // Apply separator and open/close tags and handle SPECIAL CASEs:
        // by add some exta html required by some JS image libraries
        // ************************************************************
        // Check for no values found
        if (!count($field->{$prop})) {
            $field->{$prop} = '';
            return;
        }
        // Galleriffic inline slideshow gallery
        if ($usepopup && $popuptype == 5) {
            $field->{$prop} = $opentag . '
			<div id="gf_container">
				<div id="gallery" class="content">
					<div id="gf_controls" class="controls"></div>
					<div class="slideshow-container">
						<div id="gf_loading" class="loader"></div>
						<div id="gf_slideshow" class="slideshow"></div>
					</div>
					<div id="gf_caption" class="caption-container"></div>
				</div>
				<div id="gf_thumbs" class="navigation">
					<ul class="thumbs noscript">
						<li>
						' . implode("</li>\n<li>", $field->{$prop}) . '
						</li>
					</ul>
				</div>
				<div style="clear: both;"></div>
			</div>
			' . $closetag;
        } else {
            if ($usepopup && $popuptype == 7) {
                //$max_width = $field->parameters->get( 'w_l', 800 );
                // this should be size of previewer aka size of large image thumbnail
                $field->{$prop} = '
			<div id="rg-gallery_' . $uid . '" class="rg-gallery" >
				<div class="rg-thumbs">
					<!-- Elastislide Carousel Thumbnail Viewer -->
					<div class="es-carousel-wrapper">
						<div class="es-nav">
							<span class="es-nav-prev">' . JText::_('FLEXI_PREVIOUS') . '</span>
							<span class="es-nav-next">' . JText::_('FLEXI_NEXT') . '</span>
						</div>
						<div class="es-carousel">
							<ul>
								' . implode('', $field->{$prop}) . '
							</ul>
						</div>
					</div>
					<!-- End Elastislide Carousel Thumbnail Viewer -->
				</div><!-- rg-thumbs -->
			</div><!-- rg-gallery -->
			';
            } else {
                if ($usepopup && $popuptype == 8) {
                    $field->{$prop} = '
			<span class="photoswipe_fccontainer" >
				' . implode($separatorf, $field->{$prop}) . '
			</span>
			';
                } else {
                    $field->{$prop} = implode($separatorf, $field->{$prop});
                }
            }
        }
        // Apply open/close tags
        $field->{$prop} = $opentag . $field->{$prop} . $closetag;
    }
Exemplo n.º 17
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;
		
		$field->label = JText::_($field->label);
		
		// some parameter shortcuts
		
		// This is field 's MAIN value property
		$value_usage   = $field->parameters->get( 'default_value_use', 0 ) ;
		$default_value = ($value_usage == 2) ? $field->parameters->get( 'default_value', '' ) : '';
		
		// 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;
		
		// Handle default value loading, instead of empty value
		if ( empty($values) && !strlen($default_value) ) {
			$field->{$prop} = '';
			return;
		} else if ( empty($values) && strlen($default_value) ) {
			$values = array();
			$values[0]['title'] = JText::_($default_title);
			$values[0]['text'] = JText::_($default_value);
			$values[0] = serialize($values[0]);
		}
		
		
		// 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;
		}
		
		// initialise property
		$field->{$prop} = array();
		$n = 0;
		foreach ($values as $value)
		{
			if ( empty($value) ) continue;
			
			// Compatibility for old unserialized values
			$value = (@unserialize($value)!== false || $value === 'b:0;') ? unserialize($value) : $value;
			if ( is_array($value) ) {
				$title = $value['title'];
				$text = $value['text'];
			} else {
				$title = $value;
				$text = '';
			}
			
			// If not using property or property is empty, then use default property value
			// NOTE: default property values have been cleared, if (propertyname_usage != 2)
			$text = ($usetitle && strlen($title))  ?  $title  :  $default_title;
			
			$title = '<label class="label">'.JText::_( 'FLEXI_FIELD_TERMTITLE' ).' '.($n+1).':</label>'.$title;
			$text = '<div class="fcclear"></div><label class="label">'.JText::_('FLEXI_FIELD_TERMTEXT').' '.($n+1).':</label>'.$text;

			// Add prefix / suffix
			$field->{$prop}[]	= $pretext. $title . $text . $posttext;
			
			$n++;
		}

		// 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} = '';
		}
	}
Exemplo n.º 18
0
    function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
    {
        if (!in_array($field->field_type, self::$field_types)) {
            return;
        }
        $field->label = JText::_($field->label);
        // Get field values
        $values = $values ? $values : $field->value;
        // Some variables
        $is_ingroup = !empty($field->ingroup);
        $use_ingroup = $field->parameters->get('use_ingroup', 0);
        $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
        $_MEDIA_ = 'MEDIA';
        // Meta DATA that will be displayed
        $display_title = $field->parameters->get('display_title', 1);
        $display_author = $field->parameters->get('display_author', 0);
        $display_duration = $field->parameters->get('display_duration', 0);
        $display_description = $field->parameters->get('display_description', 0);
        $headinglevel = $field->parameters->get('headinglevel', 3);
        $width = (int) $field->parameters->get('width', 960);
        $height = (int) $field->parameters->get('height', 540);
        $autostart = $field->parameters->get('autostart', 0);
        $player_position = $field->parameters->get('player_position', 0);
        $display_edit_size_form = $field->parameters->get('display_edit_size_form', 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;
        }
        // Create field's HTML
        $field->{$prop} = array();
        $n = 0;
        foreach ($values as $value) {
            if (empty($value) && !$is_ingroup) {
                continue;
            }
            // Skip empty if not in field group
            if (empty($value)) {
                $field->{$prop}[$n++] = '';
                continue;
            }
            $value = unserialize($value);
            // Compatibility with deprecated fields
            if (empty($value['api_type'])) {
                $value['api_type'] = isset($value['videotype']) ? $value['videotype'] : (isset($value['audiotype']) ? $value['audiotype'] : '');
            }
            if (empty($value['media_id'])) {
                $value['media_id'] = isset($value['videoid']) ? $value['videoid'] : (isset($value['audioid']) ? $value['audioid'] : '');
            }
            if ((empty($value['api_type']) || empty($value['media_id'])) && empty($value['embed_url'])) {
                if ($is_ingroup) {
                    $field->{$prop}[$n] = '';
                }
                continue;
            }
            $duration = intval($value['duration']);
            if ($display_duration && $duration) {
                $h = $duration >= 3600 ? intval($duration / 3600) : 0;
                $m = $duration >= 60 ? intval($duration / 60 - $h * 60) : 0;
                $s = $duration - $m * 60 - $h * 3600;
                $duration_str = $h > 0 ? $h . ":" : "";
                $duration_str .= str_pad($m, 2, '0', STR_PAD_LEFT) . ':';
                $duration_str .= str_pad($s, 2, '0', STR_PAD_LEFT);
            } else {
                $duration_str = '';
            }
            // Create field's html
            $html_meta = '
				' . ($display_title && !empty($value['title']) ? '<h' . $headinglevel . '>' . $value['title'] . '</h' . $headinglevel . '>' : '') . '
				' . ($display_author && !empty($value['author']) ? '<span class="label label-info label-small fc_sm_author-lbl">' . JText::_('Author') . '</span> <b class="fc_sm_author">' . $value['author'] . '</b> ' : '') . '
				' . ($duration_str ? '<span class="label label-info label-small fc_sm_duration-lbl">' . JText::_('Duration') . '</span> <b class="fc_sm_duration">' . $duration_str . '</b> ' : '') . '
				' . ($display_description && !empty($value['description']) ? '<div class="description">' . $value['description'] . '</div>' : '');
            if (!empty($value['embed_url'])) {
                $embed_url = $value['embed_url'];
                $_show_related = '';
                $_show_srvlogo = '';
            } else {
                $content_id = $value['media_id'];
                switch ($value['api_type']) {
                    case 'youtube':
                        $embed_url = '//www.youtube.com/embed/' . $content_id;
                        $_show_related = '&rel=0';
                        $_show_srvlogo = '&modestbranding=1&maxwidth=0&modestbranding=1';
                        break;
                    case 'vimeo':
                        $embed_url = '//player.vimeo.com/video/' . $content_id;
                        $_show_related = '';
                        $_show_srvlogo = '';
                        break;
                    case 'dailymotion':
                        $embed_url = '//www.dailymotion.com/embed/video/' . $content_id;
                        $_show_related = '&related=0';
                        $_show_srvlogo = '&logo=0';
                        break;
                    default:
                        // For embed.ly , the full URL is inside content ID
                        $embed_url = $content_id;
                        $_show_related = '';
                        $_show_srvlogo = '';
                        break;
                }
            }
            $player_url = ($embed_url ? $embed_url : 'about:blank') . '?autoplay=' . $autostart . $_show_related . $_show_srvlogo;
            $_width = $display_edit_size_form && (int) $value['width'] ? (int) $value['width'] : $width;
            $_height = $display_edit_size_form && (int) $value['height'] ? (int) $value['height'] : $height;
            $player_html = '
			<div class="fc_sharedmedia_player_outer">
				<iframe class="fc_sharedmedia_player_frame seamless" src="' . $player_url . '" style="width:' . $_width . 'px; height:' . $_height . 'px; border: none; overflow:hidden;" allowFullScreen></iframe>
			</div>';
            $field->{$prop}[$n] = $pretext . ($player_position ? '' : $player_html) . $html_meta . ($player_position ? $player_html : '') . $posttext;
            $n++;
            if (!$multiple) {
                break;
            }
            // multiple values disabled, break out of the loop, not adding further values even if the exist
        }
        if (!$is_ingroup) {
            // Apply separator and open/close tags
            $field->{$prop} = implode($separatorf, $field->{$prop});
            if ($field->{$prop} !== '') {
                $field->{$prop} = $opentag . $field->{$prop} . $closetag;
            } else {
                $field->{$prop} = '';
            }
        }
    }
Exemplo n.º 19
0
 function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     $field->label = JText::_($field->label);
     // Some variables
     $is_ingroup = !empty($field->ingroup);
     $use_ingroup = $field->parameters->get('use_ingroup', 0);
     $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
     $view = JRequest::getVar('flexi_callview', JRequest::getVar('view', FLEXI_ITEMVIEW));
     // Value handling parameters
     $lang_filter_values = 0;
     //$field->parameters->get( 'lang_filter_values', 1);
     $clean_output = $field->parameters->get('clean_output', 0);
     $encode_output = $field->parameters->get('encode_output', 0);
     $use_html = $field->field_type == 'maintext' ? !$field->parameters->get('hide_html', 0) : $field->parameters->get('use_html', 0);
     // Default value
     $value_usage = $field->parameters->get('default_value_use', 0);
     $default_value = $value_usage == 2 ? $field->parameters->get('default_value', '') : '';
     $default_value = $default_value ? JText::_($default_value) : '';
     // Get field values
     $values = $values ? $values : $field->value;
     // Check for no values and no default value, and return empty display
     if (empty($values)) {
         if (!strlen($default_value)) {
             $field->{$prop} = $is_ingroup ? array() : '';
             return;
         }
         $values = array($default_value);
     }
     // ******************************************
     // Language filter, clean output, encode HTML
     // ******************************************
     if ($clean_output) {
         $ifilter = $clean_output == 1 ? JFilterInput::getInstance(null, null, 1, 1) : JFilterInput::getInstance();
     }
     if ($lang_filter_values || $clean_output || $encode_output || !$use_html) {
         // (* BECAUSE OF THIS, the value display loop expects unserialized values)
         foreach ($values as &$value) {
             if (empty($value)) {
                 continue;
             }
             // skip further actions
             if ($lang_filter_values) {
                 $value = JText::_($value);
             }
             if ($clean_output) {
                 $value = $ifilter->clean($value, 'string');
             }
             if ($encode_output) {
                 $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
             }
             if (!$use_html) {
                 $value = nl2br(preg_replace("/(\r\n|\r|\n){3,}/", "\n\n", $value));
             }
         }
         unset($value);
         // Unset this or you are looking for trouble !!!, because it is a reference and reusing it will overwrite the pointed variable !!!
     }
     // 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;
     }
     // Create field's HTML
     $field->{$prop} = array();
     $n = 0;
     foreach ($values as $value) {
         if (!strlen($value) && !$is_ingroup) {
             continue;
         }
         // Skip empty if not in field group
         if (!strlen($value)) {
             $field->{$prop}[$n++] = '';
             continue;
         }
         // Add prefix / suffix
         $field->{$prop}[$n] = $pretext . $value . $posttext;
         $n++;
         if (!$multiple) {
             break;
         }
         // multiple values disabled, break out of the loop, not adding further values even if the exist
     }
     if (!$is_ingroup) {
         // Apply separator and open/close tags
         $field->{$prop} = implode($separatorf, $field->{$prop});
         if ($field->{$prop} !== '') {
             $field->{$prop} = $opentag . $field->{$prop} . $closetag;
         } else {
             $field->{$prop} = '';
         }
     }
     // ************
     // Add OGP tags
     // ************
     if ($field->parameters->get('useogp', 0) && !empty($field->{$prop})) {
         // Get ogp configuration
         $ogpinview = $field->parameters->get('ogpinview', array());
         $ogpinview = FLEXIUtilities::paramToArray($ogpinview);
         $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300);
         $ogpusage = $field->parameters->get('ogpusage', 0);
         if (in_array($view, $ogpinview)) {
             switch ($ogpusage) {
                 case 1:
                     $usagetype = 'title';
                     break;
                 case 2:
                     $usagetype = 'description';
                     break;
                 default:
                     $usagetype = '';
                     break;
             }
             if ($usagetype) {
                 $content_val = !$is_ingroup ? flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen) : flexicontent_html::striptagsandcut($opentag . implode($separatorf, $field->{$prop}) . $closetag, $ogpmaxlen);
                 JFactory::getDocument()->addCustomTag('<meta property="og:' . $usagetype . '" content="' . $content_val . '" />');
             }
         }
     }
 }
Exemplo n.º 20
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;
		
		$field->label = JText::_($field->label);
		
		// Some variables
		$document = JFactory::getDocument();
		$view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW));
		
		// 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
		$default_value_use= $field->parameters->get( 'default_value_use', 0 ) ;
		$default_value		= ($default_value_use == 2) ? $field->parameters->get( 'default_value', '' ) : '';
		if ( empty($values) && !strlen($default_value) ) {
			$field->{$prop} = '';
			return;
		} else if ( empty($values) && strlen($default_value) ) {
			$values = array($default_value);
		}
		
		// Prefix - Suffix - Separator parameters, replacing other field values if found
		$opentag		= FlexicontentFields::replaceFieldValue( $field, $item, $field->parameters->get( 'opentag', '' ), 'opentag' );
		$closetag		= FlexicontentFields::replaceFieldValue( $field, $item, $field->parameters->get( 'closetag', '' ), 'closetag' );
		
		// some parameter shortcuts
		$use_html			= $field->parameters->get( 'use_html', 0 ) ;
		
		// Get ogp configuration
		$useogp     = $field->parameters->get('useogp', 0);
		$ogpinview  = $field->parameters->get('ogpinview', array());
		$ogpinview  = FLEXIUtilities::paramToArray($ogpinview);
		$ogpmaxlen  = $field->parameters->get('ogpmaxlen', 300);
		$ogpusage   = $field->parameters->get('ogpusage', 0);
		
		// Apply seperator and open/close tags
		if ($values) {
			$field->{$prop} = $use_html ? $values[0] : nl2br($values[0]);
			$field->{$prop} = $opentag . $field->{$prop} . $closetag;
		} else {
			$field->{$prop} = '';
		}
		
		if ($useogp && $field->{$prop}) {
			if ( in_array($view, $ogpinview) ) {
				switch ($ogpusage)
				{
					case 1: $usagetype = 'title'; break;
					case 2: $usagetype = 'description'; break;
					default: $usagetype = ''; break;
				}
				if ($usagetype) {
					$content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen);
					$document->addCustomTag('<meta property="og:'.$usagetype.'" content="'.$content_val.'" />');
				}
			}
		}
                
                
                
                //view
                if ( !$field->{$prop} ) {
			
		} else {
			$tmp_val = unserialize($field->{$prop});
                        //var_dump($tmp_val);
                        $header_html = '<table class="flexitable">'
                            .'<thead>'
                                .'<tr>'
                                    .'<th style="font-size:80%;">'.JText::_("Страна").'</th>'
                                    .'<th style="font-size:80%;">'.JText::_("Наименование").'</th>'
                                    .'<th style="font-size:80%;">'.JText::_("Форма выпуска").'</th>'
                                    .'<th style="font-size:80%;">'.JText::_("Регистрационный №").'</th>'
                                    .'<th style="font-size:80%;">'.JText::_("Дата окончания регистрации").'</th>'
                                .'</tr>'
                            .'</thead>'
                            .'<tbody>';
			for($intA = 0; $intA < count($tmp_val['country']); $intA++){
                            $header_html .= '<tr>';
                            $header_html .= '<td>' . $tmp_val['country'][$intA] . '</td>';
                            $header_html .= '<td>' . $tmp_val['naimen'][$intA] . '</td>';
                            $header_html .= '<td>' . $tmp_val['vypusk'][$intA] . '</td>';
                            $header_html .= '<td>' . $tmp_val['reg'][$intA] . '</td>';
                            $header_html .= '<td>' . $tmp_val['date'][$intA] . '</td>';
                            $header_html .= '<tr>';
                        }
                        $header_html .= '</tbody>';
                        $header_html .= '</table>';
                        $field->{$prop} = $header_html;
                        //var_dump($field->{$prop});
                        //var_dump($field->value[0]);
		}
                
	}
Exemplo n.º 21
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;
		
		$field->label = JText::_($field->label);
		
		// Get field values
		$values = $values ? $values : $field->value;
		
		// Check for no values and not displaying ALL elements
    $display_all = $field->parameters->get( 'display_all', 0 ) ;
		if ( empty($values) && !$display_all ) { $field->{$prop} = ''; $field->display_index = ''; return; }
		
		// 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; }
		
		// some parameter shortcuts
		$sql_mode			= $field->parameters->get( 'sql_mode', 0 ) ;
		$field_elements = $field->parameters->get( 'field_elements', '' ) ;
		$text_or_value= $field->parameters->get( 'text_or_value', 1 ) ;
		
		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;
		}
		
		
		// Get indexed element values
		$elements = FlexicontentFields::indexedField_getElements($field, $item, self::$extra_props);
		if ( !$elements ) {
			if ($sql_mode)
				$field->{$prop} = JText::_('FLEXI_FIELD_INVALID_QUERY');
			else
				$field->{$prop} = JText::_('FLEXI_FIELD_INVALID_ELEMENTS');
			return;
		}
		// Check for no elements found
		if ( empty($elements) )  { $field->{$prop} = ''; $field->display_index = ''; return; }
		
		// Create display of field
		$display = array();
		$display_index = array();
		
		// Prepare for looping
		if ( !$values ) $values = array();
		if ( $display_all ) {
			$indexes = array_flip($values);
			
			// non-selected value shortcuts
	    $ns_pretext			= FlexicontentFields::replaceFieldValue( $field, $item, $field->parameters->get( 'ns_pretext', '' ), 'ns_pretext' );
  	  $ns_posttext		= FlexicontentFields::replaceFieldValue( $field, $item, $field->parameters->get( 'ns_posttext', '' ), 'ns_posttext' );
  	  $ns_pretext  = $ns_pretext . '<span class="fc_field_unsused_val">';
  	  $ns_posttext = '</span>' . $ns_posttext;
    	$ns_pretext  = $remove_space ? $ns_pretext : $ns_pretext . ' ';
	    $ns_posttext = $remove_space ? $ns_posttext : ' ' . $ns_posttext;
		}
		
		// CASE a. Display ALL elements (selected and NON-selected)
		if ( $display_all ) foreach ($elements as $val => $element)
		{
			if ($text_or_value == 0) $disp = $element->value;
			else if ($text_or_value == 1) $disp =JText::_($element->text);
			
			$is_selected = isset($indexes[$val]);
			
			$display[] = $is_selected ?  $pretext.$disp.$posttext : $ns_pretext.$disp.$ns_posttext;
			if ( $is_selected ) $display_index[] = $element->value;
		}
		
		// CASE b. Display only selected elements
		else foreach ($values as $n => $val)
		{
			$element = @$elements[ $val ];
			if ( !$element ) continue;
			
			if ($text_or_value == 0) $disp = $element->value;
			else if ($text_or_value == 1) $disp =JText::_($element->text);
			
			$display[] = $pretext.$disp.$posttext;
			$display_index[] = $element->value;
		}
		
		// Apply values separator
		$field->{$prop} = implode($separatorf, $display);
		$field->display_index = implode($separatorf, $display_index);
		
		// Apply field 's opening / closing texts
		if ($field->{$prop})
			$field->{$prop} = $opentag . $field->{$prop} . $closetag;
	}
Exemplo n.º 22
0
 function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     $field->label = JText::_($field->label);
     // Some variables
     $is_ingroup = !empty($field->ingroup);
     $use_ingroup = $field->parameters->get('use_ingroup', 0);
     $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
     $config = JFactory::getConfig();
     $user = JFactory::getUser();
     // Value handling parameters
     $lang_filter_values = 0;
     //$field->parameters->get( 'lang_filter_values', 1);
     $date_source = $field->parameters->get('date_source', 0);
     $show_no_value = $field->parameters->get('show_no_value', 0);
     $no_value_msg = $field->parameters->get('no_value_msg', 'FLEXI_NO_VALUE');
     $no_value_msg = $show_no_value ? JText::_($no_value_msg) : '';
     // Get field values
     $values = $values ? $values : $field->value;
     // Load publish_up/publish_down values if so configured
     if ($date_source) {
         static $nullDate, $never_date;
         if ($nullDate == null) {
             $nullDate = JFactory::getDBO()->getNullDate();
             $never_date = '';
             //JText::_('FLEXI_NEVER');
         }
         $_value = $date_source == 1 ? $item->publish_up : $item->publish_down;
         if ($_value == $nullDate) {
             $field->{$prop} = $date_source == 2 ? $never_date : '';
             return;
         }
         $values = array($_value);
     }
     // Check for no values and no default value, and return empty display
     if (empty($values)) {
         $field->{$prop} = $is_ingroup ? array() : '';
         return;
     }
     // Timezone configuration
     $date_allowtime = $field->parameters->get('date_allowtime', 1);
     $use_editor_tz = $field->parameters->get('use_editor_tz', 0);
     $use_editor_tz = $date_allowtime ? $use_editor_tz : 0;
     $customdate = $field->parameters->get('custom_date', 'Y-m-d');
     $dateformat = $field->parameters->get('date_format', '');
     $dateformat = $dateformat ? JText::_($dateformat) : ($field->parameters->get('lang_filter_format', 0) ? JText::_($customdate) : $customdate);
     $display_tz_logged = $field->parameters->get('display_tz_logged', 2);
     $display_tz_guests = $field->parameters->get('display_tz_guests', 2);
     $display_tz_suffix = $field->parameters->get('display_tz_suffix', 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');
     $itemprop = $field->parameters->get('microdata_itemprop');
     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;
     }
     // Get timezone to use for displaying the date,  this is a string for J2.5 and an (offset) number for J1.5
     if (!$use_editor_tz) {
         // Raw date output, ignore timezone (no timezone info is printed), NOTE: this is OLD BEHAVIOUR of this field
         $tz_suffix_type = -1;
     } else {
         if ($user->id) {
             $tz_suffix_type = $display_tz_logged;
         } else {
             $tz_suffix_type = $display_tz_guests;
         }
     }
     $tz_info = '';
     switch ($tz_suffix_type) {
         default:
             // including value -1 for raw for output, see above
         // including value -1 for raw for output, see above
         case 0:
             $timezone = 'UTC';
             //$tz_info = '';
             break;
         case 1:
             $timezone = 'UTC';
             //$tz_info = ' UTC+0';
             break;
         case 2:
             $timezone = $config->get('offset');
             //$tz_info = ' (site's timezone)';
             break;
         case 3:
             $timezone = $user->getParam('timezone');
             //$tz_info = ' (local time)';
             break;
     }
     // display timezone suffix if this is enabled
     if ($display_tz_suffix && $tz_suffix_type > 0) {
         $tz = new DateTimeZone($timezone);
         $tz_offset = $tz->getOffset(new JDate()) / 3600;
         $tz_info = $tz_offset > 0 ? ' UTC +' . $tz_offset : ' UTC ' . $tz_offset;
     }
     // initialise property
     $field->{$prop} = array();
     $n = 0;
     foreach ($values as $value) {
         if (!strlen($value) && !$is_ingroup) {
             continue;
         }
         // Skip empty if not in field group
         if (!strlen($value)) {
             $field->{$prop}[$n++] = $no_value_msg;
             continue;
         }
         // Check if dates are allowed to have time part
         if ($date_allowtime) {
             $date = $value;
         } else {
             @(list($date, $time) = preg_split('#\\s+#', $value, $limit = 2));
         }
         if (empty($date)) {
             continue;
         }
         try {
             $date = JHTML::_('date', $date, $dateformat, $timezone) . $tz_info;
         } catch (Exception $e) {
             $date = '';
         }
         // Add prefix / suffix
         $field->{$prop}[$n] = $pretext . $date . $posttext;
         // Add microdata to every value if field -- is -- in a field group
         if ($is_ingroup && $itemprop) {
             $field->{$prop}[$n] = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop}[$n] . '</div>';
         }
         $n++;
         if (!$multiple) {
             break;
         }
         // multiple values disabled, break out of the loop, not adding further values even if the exist
     }
     if (!$is_ingroup) {
         // Apply separator and open/close tags
         $field->{$prop} = implode($separatorf, $field->{$prop});
         if ($field->{$prop} !== '') {
             $field->{$prop} = $opentag . $field->{$prop} . $closetag;
             if ($itemprop) {
                 $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>';
             }
         } else {
             $field->{$prop} = $no_value_msg;
         }
     }
 }
Exemplo n.º 23
0
    function onDisplayCoreFieldValue(&$_field, &$_item, &$params, $_tags = null, $_categories = null, $_favourites = null, $_favoured = null, $_vote = null, $values = null, $prop = 'display')
    {
        $view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW));
        static $cat_links = array();
        static $tag_links = array();
        static $cparams = null;
        if ($cparams === null) {
            $cparams = JComponentHelper::getParams('com_flexicontent');
        }
        if (!is_array($_item)) {
            $items = array(&$_item);
        } else {
            $items =& $_item;
        }
        // Prefix - Suffix - Separator parameters
        // these parameters should be common so we will retrieve them from the first item instead of inside the loop
        $item = reset($items);
        if (is_object($_field)) {
            $field = $_field;
        } else {
            $field = $item->fields[$_field];
        }
        $remove_space = $field->parameters->get('remove_space', 0);
        $_pretext = $field->parameters->get('pretext', '');
        $_posttext = $field->parameters->get('posttext', '');
        $separatorf = $field->parameters->get('separatorf', 3);
        $_opentag = $field->parameters->get('opentag', '');
        $_closetag = $field->parameters->get('closetag', '');
        $pretext_cacheable = $posttext_cacheable = $opentag_cacheable = $closetag_cacheable = false;
        switch ($separatorf) {
            case 0:
                $separatorf = ' ';
                break;
            case 1:
                $separatorf = '<br />';
                break;
            case 2:
                $separatorf = ' | ';
                break;
            case 3:
                $separatorf = ', ';
                break;
            case 4:
                $separatorf = $closetag . $opentag;
                break;
            case 5:
                $separatorf = '';
                break;
            default:
                $separatorf = '&nbsp;';
                break;
        }
        foreach ($items as $item) {
            //if (!is_object($_field)) echo $item->id." - ".$_field ."<br/>";
            if (is_object($_field)) {
                $field = $_field;
            } else {
                $field = $item->fields[$_field];
            }
            if ($field->iscore != 1) {
                continue;
            }
            $field->item_id = $item->id;
            // Replace item properties or values of other fields
            if (!$pretext_cacheable) {
                $pretext = FlexicontentFields::replaceFieldValue($field, $item, $_pretext, 'pretext', $pretext_cacheable);
                if ($pretext && !$remove_space) {
                    $pretext = $pretext . ' ';
                }
            }
            if (!$posttext_cacheable) {
                $posttext = FlexicontentFields::replaceFieldValue($field, $item, $_posttext, 'posttext', $posttext_cacheable);
                if ($posttext && !$remove_space) {
                    $posttext = ' ' . $posttext;
                }
            }
            if (!$opentag_cacheable) {
                $opentag = FlexicontentFields::replaceFieldValue($field, $item, $_opentag, 'opentag', $opentag_cacheable);
            }
            // used by some fields
            if (!$closetag_cacheable) {
                $closetag = FlexicontentFields::replaceFieldValue($field, $item, $_closetag, 'closetag', $closetag_cacheable);
            }
            // used by some fields
            $field->value = array();
            switch ($field->field_type) {
                case 'created':
                    // created
                    $field->value = array($item->created);
                    // Get date format
                    $customdate = $field->parameters->get('custom_date', 'Y-m-d');
                    $dateformat = $field->parameters->get('date_format', '');
                    $dateformat = $dateformat ? JText::_($dateformat) : ($field->parameters->get('lang_filter_format', 0) ? JText::_($customdate) : $customdate);
                    // Add prefix / suffix
                    $field->{$prop} = $pretext . JHTML::_('date', $item->created, $dateformat) . $posttext;
                    // Add microdata property
                    $itemprop = $field->parameters->get('microdata_itemprop', 'dateCreated');
                    if ($itemprop) {
                        $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>';
                    }
                    break;
                case 'createdby':
                    // created by
                    $field->value[] = $item->created_by;
                    $field->{$prop} = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->cuname : $item->creator) . $posttext;
                    break;
                case 'modified':
                    // modified
                    $field->value = array($item->modified);
                    // Get date format
                    $customdate = $field->parameters->get('custom_date', 'Y-m-d');
                    $dateformat = $field->parameters->get('date_format', '');
                    $dateformat = $dateformat ? JText::_($dateformat) : ($field->parameters->get('lang_filter_format', 0) ? JText::_($customdate) : $customdate);
                    // Add prefix / suffix
                    $field->{$prop} = $pretext . JHTML::_('date', $item->modified, $dateformat) . $posttext;
                    // Add microdata property
                    $itemprop = $field->parameters->get('microdata_itemprop', 'dateModified');
                    if ($itemprop) {
                        $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>';
                    }
                    break;
                case 'modifiedby':
                    // modified by
                    $field->value[] = $item->modified_by;
                    $field->{$prop} = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->muname : $item->modifier) . $posttext;
                    break;
                case 'title':
                    // title
                    $field->value[] = $item->title;
                    $field->{$prop} = $pretext . $item->title . $posttext;
                    // Get ogp configuration
                    $useogp = $field->parameters->get('useogp', 1);
                    $ogpinview = $field->parameters->get('ogpinview', array());
                    $ogpinview = FLEXIUtilities::paramToArray($ogpinview);
                    $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300);
                    if ($useogp && $field->{$prop}) {
                        if (in_array($view, $ogpinview)) {
                            $content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen);
                            JFactory::getDocument()->addCustomTag('<meta property="og:title" content="' . $content_val . '" />');
                        }
                    }
                    // Add microdata property (currently no parameter in XML for this field)
                    $itemprop = $field->parameters->get('microdata_itemprop', 'name');
                    if ($itemprop) {
                        $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>';
                    }
                    break;
                case 'hits':
                    // hits
                    $field->value[] = $item->hits;
                    $field->{$prop} = $pretext . $item->hits . $posttext;
                    break;
                case 'type':
                    // document type
                    $field->value[] = $item->type_id;
                    $field->{$prop} = $pretext . JText::_($item->typename) . $posttext;
                    break;
                case 'version':
                    // version
                    $field->value[] = $item->version;
                    $field->{$prop} = $pretext . $item->version . $posttext;
                    break;
                case 'state':
                    // state
                    $field->value[] = $item->state;
                    $field->{$prop} = $pretext . flexicontent_html::stateicon($item->state, $field->parameters) . $posttext;
                    break;
                case 'voting':
                    // voting button
                    if ($_vote === false) {
                        $vote =& $item->vote;
                    } else {
                        $vote =& $_vote;
                    }
                    $field->value[] = 'button';
                    // dummy value to force display
                    $field->{$prop} = $pretext . flexicontent_html::ItemVote($field, 'all', $vote) . $posttext;
                    break;
                case 'favourites':
                    // favourites button
                    if ($_favourites === false) {
                        $favourites =& $item->favs;
                    } else {
                        $favourites =& $_favourites;
                    }
                    if ($_favoured === false) {
                        $favoured =& $item->fav;
                    } else {
                        $favoured =& $_favoured;
                    }
                    $field->value[] = 'button';
                    // dummy value to force display
                    $favs = flexicontent_html::favoured_userlist($field, $item, $favourites);
                    $field->{$prop} = $pretext . '
					<div class="fav-block">
						' . flexicontent_html::favicon($field, $favoured, $item) . '
						<div id="fcfav-reponse_item_' . $item->id . '" class="fcfav-reponse-tip">
							<div class="fc-mssg-inline fc-info fc-iblock fc-nobgimage ' . ($favoured ? 'fcfavs-is-subscriber' : 'fcfavs-isnot-subscriber') . '">
								' . JText::_($favoured ? 'FLEXI_FAVS_YOU_HAVE_SUBSCRIBED' : 'FLEXI_FAVS_CLICK_TO_SUBSCRIBE') . '
							</div>
							' . $favs . '
						</div>
					</div>
						' . $posttext;
                    break;
                case 'categories':
                    // assigned categories
                    $field->{$prop} = '';
                    if ($_categories === false) {
                        $categories =& $item->cats;
                    } else {
                        $categories =& $_categories;
                    }
                    if ($categories) {
                        // Get categories that should be excluded from linking
                        global $globalnoroute;
                        if (!is_array($globalnoroute)) {
                            $globalnoroute = array();
                        }
                        // Create list of category links, excluding the "noroute" categories
                        $field->{$prop} = array();
                        foreach ($categories as $category) {
                            $cat_id = $category->id;
                            if (in_array($cat_id, @$globalnoroute)) {
                                continue;
                            }
                            if (!isset($cat_links[$cat_id])) {
                                $cat_links[$cat_id] = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug));
                            }
                            $cat_link =& $cat_links[$cat_id];
                            $display = '<a class="fc_categories fc_category_' . $cat_id . ' link_' . $field->name . '" href="' . $cat_link . '">' . $category->title . '</a>';
                            $field->{$prop}[] = $pretext . $display . $posttext;
                            $field->value[] = $category->title;
                        }
                        $field->{$prop} = implode($separatorf, $field->{$prop});
                        $field->{$prop} = $opentag . $field->{$prop} . $closetag;
                    }
                    break;
                case 'tags':
                    // assigned tags
                    $use_catlinks = $cparams->get('tags_using_catview', 0);
                    $field->{$prop} = '';
                    if ($_tags === false) {
                        $tags =& $item->tags;
                    } else {
                        $tags =& $_tags;
                    }
                    if ($tags) {
                        // Create list of tag links
                        $field->{$prop} = array();
                        foreach ($tags as $tag) {
                            $tag_id = $tag->id;
                            if (!isset($tag_links[$tag_id])) {
                                $tag_links[$tag_id] = $use_catlinks ? JRoute::_(FlexicontentHelperRoute::getCategoryRoute(0, 0, array('layout' => 'tags', 'tagid' => $tag->slug))) : JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->slug));
                            }
                            $tag_link =& $tag_links[$tag_id];
                            $display = '<a class="fc_tags fc_tag_' . $tag->id . ' link_' . $field->name . '" href="' . $tag_link . '">' . $tag->name . '</a>';
                            $field->{$prop}[] = $pretext . $display . $posttext;
                            $field->value[] = $tag->name;
                        }
                        $field->{$prop} = implode($separatorf, $field->{$prop});
                        $field->{$prop} = $opentag . $field->{$prop} . $closetag;
                    }
                    break;
                case 'maintext':
                    // main text
                    // Special display variables
                    if ($prop != 'display') {
                        switch ($prop) {
                            case 'display_if':
                                $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext;
                                break;
                            case 'display_i':
                                $field->{$prop} = $item->introtext;
                                break;
                            case 'display_f':
                                $field->{$prop} = $item->fulltext;
                                break;
                        }
                    } else {
                        if (!$item->fulltext) {
                            $field->{$prop} = $item->introtext;
                        } else {
                            if ($view != FLEXI_ITEMVIEW) {
                                if ($item->parameters->get('force_full', 0)) {
                                    $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext;
                                } else {
                                    $field->{$prop} = $item->introtext;
                                }
                            } else {
                                if ($item->parameters->get('show_intro', 1)) {
                                    $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext;
                                } else {
                                    $field->{$prop} = $item->fulltext;
                                }
                            }
                        }
                    }
                    // Get ogp configuration
                    $useogp = $field->parameters->get('useogp', 1);
                    $ogpinview = $field->parameters->get('ogpinview', array());
                    $ogpinview = FLEXIUtilities::paramToArray($ogpinview);
                    $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300);
                    if ($useogp && $field->{$prop}) {
                        if (in_array($view, $ogpinview)) {
                            if ($item->metadesc) {
                                JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $item->metadesc . '" />');
                            } else {
                                $content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen);
                                JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $content_val . '" />');
                            }
                        }
                    }
                    break;
            }
        }
    }
Exemplo n.º 24
0
 function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     $field->label = JText::_($field->label);
     // Some variables
     $is_ingroup = !empty($field->ingroup);
     $use_ingroup = $field->parameters->get('use_ingroup', 0);
     $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
     $format = JRequest::getCmd('format', null);
     // Value handling parameters
     $lang_filter_values = 0;
     //$field->parameters->get( 'lang_filter_values', 1);
     // Email address
     $addr_usage = $field->parameters->get('default_value_use', 0);
     $default_addr = $addr_usage == 2 ? $field->parameters->get('default_value', '') : '';
     $default_addr = $default_addr ? JText::_($default_addr) : '';
     // Email title & linking text (optional)
     $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', '')) : '';
     $default_title = $default_title ? JText::_($default_title) : '';
     // Rendering options
     $email_cloaking = $field->parameters->get('email_cloaking', 1);
     $mailto_link = $field->parameters->get('mailto_link', 1);
     // Get field values
     $values = $values ? $values : $field->value;
     // Check for no values and no default value, and return empty display
     if (empty($values)) {
         if (!strlen($default_addr)) {
             $field->{$prop} = $is_ingroup ? array() : '';
             return;
         }
         $values = array();
         $values[0]['addr'] = JText::_($default_addr);
         $values[0]['text'] = JText::_($default_title);
         $values[0] = serialize($values[0]);
     }
     $unserialize_vals = true;
     if ($unserialize_vals) {
         // (* BECAUSE OF THIS, the value display loop expects unserialized values)
         foreach ($values as &$value) {
             // Compatibility for unserialized values or for NULL values in a field group
             if (!is_array($value)) {
                 $v = !empty($value) ? @unserialize($value) : false;
                 $value = $v !== false || $v === 'b:0;' ? $v : array('addr' => $value, 'text' => '');
             }
         }
         unset($value);
         // Unset this or you are looking for trouble !!!, because it is a reference and reusing it will overwrite the pointed variable !!!
     }
     // 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;
     }
     // Get layout name
     $viewlayout = $field->parameters->get('viewlayout', '');
     $viewlayout = $viewlayout ? 'value_' . $viewlayout : 'value_default';
     // Create field's HTML, using layout file
     $field->{$prop} = array();
     //$this->values = $values;
     //$this->displayFieldValue( $prop, $viewlayout );
     include self::getFormPath($this->fieldtypes[0], $viewlayout);
     // Do not convert the array to string if field is in a group, and do not add: FIELD's opetag, closetag, value separator
     if (!$is_ingroup) {
         // Apply values separator
         $field->{$prop} = implode($separatorf, $field->{$prop});
         if ($field->{$prop} !== '') {
             // Apply field 's opening / closing texts
             $field->{$prop} = $opentag . $field->{$prop} . $closetag;
         }
     }
 }
Exemplo n.º 25
0
    function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
    {
        if (!in_array($field->field_type, self::$field_types)) {
            return;
        }
        // Use custom HTML display parameter
        $display_mode = (int) $field->parameters->get('display_mode', 0);
        // 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');
        // Microdata (classify the field group values for search engines)
        // we use itemtype and not itemprop as it is more appropriate for the a grouping field
        $fieldgroup_itemtype = $field->parameters->get('fieldgroup_itemtype');
        $fieldgroup_itemtype_code = $fieldgroup_itemtype ? 'itemscope itemtype="http://schema.org/' . $fieldgroup_itemtype . '"' : '';
        if ($pretext) {
            $pretext = $remove_space ? $pretext : $pretext . ' ';
        }
        if ($posttext) {
            $posttext = $remove_space ? $posttext : ' ' . $posttext;
        }
        if (!$pretext && !$posttext && !$display_mode) {
            $pretext = '<div class="fc-fieldgrp-value-box">';
            $posttext = '</div>';
        }
        $pretext = '<span ' . $fieldgroup_itemtype_code . '" >' . $pretext;
        $posttext = $posttext . '</span>';
        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;
        }
        // Get fields belonging to this field group
        $grouped_fields = $this->getGroupFields($field);
        // Get values of fields making sure that also empty values are created too
        $max_count = 0;
        $this->getGroupFieldsValues($grouped_fields, $item, $max_count);
        // **********************************************
        // Create a CUSTOMIZED display of the field group
        // **********************************************
        if ($display_mode) {
            $custom_html = trim($field->parameters->get('custom_html', ''));
            $field->{$prop} = $this->_createDisplayHTML($field, $item, $grouped_fields, $custom_html, $max_count, $pretext, $posttext);
        } else {
            // Render HTML of fields in the group
            $method = 'display';
            $view = JRequest::getVar('flexi_callview', JRequest::getVar('view', FLEXI_ITEMVIEW));
            foreach ($grouped_fields as $grouped_field) {
                // Render the display method for the given field
                $_values = $grouped_field->value;
                $grouped_field->ingroup = 1;
                // render as array
                //echo 'Rendering: '. $grouped_field->name . ', method: ' . $method . '<br/>';
                //FLEXIUtilities::call_FC_Field_Func($grouped_field->field_type, 'onDisplayFieldValue', array(&$grouped_field, $item, $_values, $method));
                unset($grouped_field->{$method});
                // Unset display variable to make sure display HTML it is created, because we reuse the field
                FlexicontentFields::renderField($item, $grouped_field, $_values, $method, $view);
                // Includes content plugins triggering
                unset($grouped_field->ingroup);
            }
            // Render the list of groups
            $field->{$prop} = array();
            for ($n = 0; $n < $max_count; $n++) {
                $default_html = array();
                foreach ($grouped_fields as $grouped_field) {
                    $_values = null;
                    $default_html[] = '
					<div class="fc-field-box">
						' . ($grouped_field->parameters->get('display_label') ? '
						<span class="flexi label">' . $grouped_field->label . '</span>' : '') . (isset($grouped_field->{$prop}[$n]) ? '<div class="flexi value">' . $grouped_field->{$prop}[$n] . '</div>' : '') . '
					</div>';
                }
                $field->{$prop}[] = $pretext . implode('<div class="clear"></div>', $default_html) . '<div class="clear"></div>' . $posttext;
            }
            // Unset display of fields in case they need to be rendered again
            //foreach($grouped_fields as $grouped_field)  unset($grouped_field->$prop);
        }
        if (count($field->{$prop})) {
            $field->{$prop} = implode($separatorf, $field->{$prop});
            $field->{$prop} = $opentag . $field->{$prop} . $closetag;
        } else {
            $field->{$prop} = '';
        }
    }
Exemplo n.º 26
0
 function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     $field->label = JText::_($field->label);
     // Some variables
     $is_ingroup = !empty($field->ingroup);
     $use_ingroup = $field->parameters->get('use_ingroup', 0);
     $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
     $view = JRequest::getVar('flexi_callview', JRequest::getVar('view', FLEXI_ITEMVIEW));
     // Value handling parameters
     $lang_filter_values = $field->parameters->get('lang_filter_values', 0);
     $clean_output = $field->parameters->get('clean_output', 0);
     $encode_output = $field->parameters->get('encode_output', 0);
     $format_output = $field->parameters->get('format_output', 0);
     if ($format_output > 0) {
         // 1: decimal, 2: integer
         $decimal_digits_displayed = $format_output == 2 ? 0 : (int) $field->parameters->get('decimal_digits_displayed', 2);
         $decimal_digits_sep = $field->parameters->get('decimal_digits_sep', '.');
         $decimal_thousands_sep = $field->parameters->get('decimal_thousands_sep', ',');
         $output_prefix = JText::_($field->parameters->get('output_prefix', ''));
         $output_suffix = JText::_($field->parameters->get('output_suffix', ''));
     } else {
         if ($format_output == -1) {
             $output_custom_func = $field->parameters->get('output_custom_func', '');
         }
     }
     // Default value
     $value_usage = $field->parameters->get('default_value_use', 0);
     $default_value = $value_usage == 2 ? $field->parameters->get('default_value', '') : '';
     $default_value = $default_value ? JText::_($default_value) : '';
     // Get field values
     $values = $values ? $values : $field->value;
     // Check for no values and no default value, and return empty display
     if (empty($values)) {
         if (!strlen($default_value)) {
             $field->{$prop} = $is_ingroup ? array() : '';
             return;
         }
         $values = array($default_value);
     }
     // ******************************************
     // Language filter, clean output, encode HTML
     // ******************************************
     if ($clean_output) {
         $ifilter = $clean_output == 1 ? JFilterInput::getInstance(null, null, 1, 1) : JFilterInput::getInstance();
     }
     if ($lang_filter_values || $clean_output || $encode_output || $format_output) {
         // (* BECAUSE OF THIS, the value display loop expects unserialized values)
         foreach ($values as &$value) {
             if (!strlen($value)) {
                 continue;
             }
             // skip further actions
             if ($format_output > 0) {
                 // 1: decimal, 2: integer
                 $value = @number_format($value, $decimal_digits_displayed, $decimal_digits_sep, $decimal_thousands_sep);
                 $value = $value === NULL ? 0 : $value;
                 $value = $output_prefix . $value . $output_suffix;
             } else {
                 if (!empty($output_custom_func)) {
                     $value = eval("\$value= \"{$value}\";" . $output_custom_func);
                 }
             }
             if ($lang_filter_values) {
                 $value = JText::_($value);
             }
             if ($clean_output) {
                 $value = $ifilter->clean($value, 'string');
             }
             if ($encode_output) {
                 $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
             }
         }
         unset($value);
         // Unset this or you are looking for trouble !!!, because it is a reference and reusing it will overwrite the pointed variable !!!
     }
     // 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');
     // Microdata (classify the field values for search engines)
     $itemprop = $field->parameters->get('microdata_itemprop');
     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;
     }
     // Get layout name
     $viewlayout = $field->parameters->get('viewlayout', '');
     $viewlayout = $viewlayout ? 'value_' . $viewlayout : 'value_default';
     // Create field's HTML, using layout file
     $field->{$prop} = array();
     //$this->values = $values;
     //$this->displayFieldValue( $prop, $viewlayout );
     include self::getFormPath($this->fieldtypes[0], $viewlayout);
     // Do not convert the array to string if field is in a group, and do not add: FIELD's opetag, closetag, value separator
     if (!$is_ingroup) {
         // Apply values separator
         $field->{$prop} = implode($separatorf, $field->{$prop});
         if ($field->{$prop} !== '') {
             // Apply field 's opening / closing texts
             $field->{$prop} = $opentag . $field->{$prop} . $closetag;
             // Add microdata once for all values, if field -- is NOT -- in a field group
             if ($itemprop) {
                 $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>';
             }
         }
     }
     // ************
     // Add OGP tags
     // ************
     if ($field->parameters->get('useogp', 0) && !empty($field->{$prop})) {
         // Get ogp configuration
         $ogpinview = $field->parameters->get('ogpinview', array());
         $ogpinview = FLEXIUtilities::paramToArray($ogpinview);
         $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300);
         $ogpusage = $field->parameters->get('ogpusage', 0);
         if (in_array($view, $ogpinview)) {
             switch ($ogpusage) {
                 case 1:
                     $usagetype = 'title';
                     break;
                 case 2:
                     $usagetype = 'description';
                     break;
                 default:
                     $usagetype = '';
                     break;
             }
             if ($usagetype) {
                 $content_val = !$is_ingroup ? flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen) : flexicontent_html::striptagsandcut($opentag . implode($separatorf, $field->{$prop}) . $closetag, $ogpmaxlen);
                 JFactory::getDocument()->addCustomTag('<meta property="og:' . $usagetype . '" content="' . $content_val . '" />');
             }
         }
     }
 }
Exemplo n.º 27
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} = '';
     }
 }
Exemplo n.º 28
0
 function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     $field->label = JText::_($field->label);
     // Some variables
     $is_ingroup = !empty($field->ingroup);
     $use_ingroup = $field->parameters->get('use_ingroup', 0);
     $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
     $format = JRequest::getCmd('format', null);
     // Value handling parameters
     $lang_filter_values = 0;
     //$field->parameters->get( 'lang_filter_values', 1);
     // Email address
     $addr_usage = $field->parameters->get('default_value_use', 0);
     $default_addr = $addr_usage == 2 ? $field->parameters->get('default_value', '') : '';
     $default_addr = $default_addr ? JText::_($default_addr) : '';
     // Email title & linking text (optional)
     $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', '')) : '';
     $default_title = $default_title ? JText::_($default_title) : '';
     // Get field values
     $values = $values ? $values : $field->value;
     // Check for no values and no default value, and return empty display
     if (empty($values)) {
         if (!strlen($default_addr)) {
             $field->{$prop} = $is_ingroup ? array() : '';
             return;
         }
         $values = array();
         $values[0]['addr'] = JText::_($default_addr);
         $values[0]['text'] = JText::_($default_title);
         $values[0] = serialize($values[0]);
     }
     // (* BECAUSE OF THIS, the value display loop expects unserialized values)
     foreach ($values as &$value) {
         // Compatibility for unserialized values or for NULL values in a field group
         if (!is_array($value)) {
             $v = !empty($value) ? @unserialize($value) : false;
             $value = $v !== false || $v === 'b:0;' ? $v : array('addr' => $value, 'text' => '');
         }
     }
     unset($value);
     // Unset this or you are looking for trouble !!!, because it is a reference and reusing it will overwrite the pointed variable !!!
     // 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;
     }
     // initialise property
     $field->{$prop} = array();
     $n = 0;
     foreach ($values as $value) {
         if (empty($value['addr']) && !$is_ingroup) {
             continue;
         }
         // Skip empty if not in field group
         if (empty($value['addr'])) {
             $field->{$prop}[$n++] = '';
             continue;
         }
         // If not using property or property is empty, then use default property value
         // NOTE: default property values have been cleared, if (propertyname_usage != 2)
         $addr = $value['addr'];
         $text = @$value['text'];
         $text = $usetitle && strlen($text) ? $text : $default_title;
         if (!strlen($text) || !$usetitle) {
             $text = FLEXI_J30GE ? JStringPunycode::emailToUTF8($addr) : $addr;
             // email in Punycode to UTF8, for the purpose of displaying it
             $text_is_email = 1;
         } else {
             $text_is_email = strpos($text, '@') !== false;
         }
         // Create field's display
         // A cloacked email address with custom linking text
         $html = $format != 'feed' ? JHTML::_('email.cloak', $addr, 1, $text, $text_is_email) : '<a href="mailto:' . $addr . '" target="_blank" itemprop="email">' . $text . '</a>';
         // Add prefix / suffix
         $field->{$prop}[$n] = $pretext . $html . $posttext;
         $n++;
         if (!$multiple) {
             break;
         }
         // multiple values disabled, break out of the loop, not adding further values even if the exist
     }
     if (!$is_ingroup) {
         // Apply separator and open/close tags
         $field->{$prop} = implode($separatorf, $field->{$prop});
         if ($field->{$prop} !== '') {
             $field->{$prop} = $opentag . $field->{$prop} . $closetag;
         } else {
             $field->{$prop} = '';
         }
     }
 }
Exemplo n.º 29
0
 protected function getCloseTag()
 {
     return FlexicontentFields::replaceFieldValue($this->field, $this->item, $this->field->parameters->get('closetag', ''), 'closetag');
 }
Exemplo n.º 30
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;
     }
     $field->label = JText::_($field->label);
     // Get field values
     $values = $values ? $values : $field->value;
     // Check for no values and not displaying ALL elements
     $display_all = $field->parameters->get('display_all', 0);
     if (empty($values) && !$display_all) {
         $field->{$prop} = '';
         $field->display_index = '';
         return;
     }
     // 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;
     }
     // some parameter shortcuts
     $sql_mode = $field->parameters->get('sql_mode', 0);
     $field_elements = $field->parameters->get('field_elements', '');
     $text_or_value = $field->parameters->get('text_or_value', 2);
     // image specific variables
     $prefix = JFactory::getApplication()->isAdmin() ? '../' : '';
     $imagedir = preg_replace('#^(/)*#', '', $field->parameters->get('imagedir'));
     $imgpath = $prefix . $imagedir;
     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;
     }
     // Get indexed element values
     $elements = FlexicontentFields::indexedField_getElements($field, $item, self::$extra_props);
     if (!$elements) {
         if ($sql_mode) {
             $field->{$prop} = JText::_('FLEXI_FIELD_INVALID_QUERY');
         } else {
             $field->{$prop} = JText::_('FLEXI_FIELD_INVALID_ELEMENTS');
         }
         return;
     }
     // Check for no elements found
     if (empty($elements)) {
         $field->{$prop} = '';
         $field->display_index = '';
         return;
     }
     // Create display of field
     $display = array();
     $display_index = array();
     // Prepare for looping
     if (!$values) {
         $values = array();
     }
     if ($display_all) {
         $index = reset($values);
         // non-selected value shortcuts
         $ns_pretext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('ns_pretext', ''), 'ns_pretext');
         $ns_posttext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('ns_posttext', ''), 'ns_posttext');
         $ns_pretext = $ns_pretext . '<span class="fc_field_unsused_val">';
         $ns_posttext = '</span>' . $ns_posttext;
         $ns_pretext = $remove_space ? $ns_pretext : $ns_pretext . ' ';
         $ns_posttext = $remove_space ? $ns_posttext : ' ' . $ns_posttext;
     }
     // CASE a. Display ALL elements (selected and NON-selected)
     if ($display_all) {
         foreach ($elements as $val => $element) {
             if ($text_or_value == 0) {
                 $disp = $element->value;
             } else {
                 if ($text_or_value == 1) {
                     $disp = JText::_($element->text);
                 } else {
                     $disp = '<img src="' . $imgpath . $element->image . '" class="hasTip" title="' . $field->label . '::' . $element->text . '" alt="' . JText::_($element->text) . '" />';
                 }
             }
             $is_selected = $index == $val;
             $display[] = $is_selected ? $pretext . $disp . $posttext : $ns_pretext . $disp . $ns_posttext;
             if ($is_selected) {
                 $display_index[] = $element->value;
             }
         }
     } else {
         if (count($values)) {
             $element = @$elements[reset($values)];
             if (!$element) {
                 return '';
             }
             if ($text_or_value == 0) {
                 $disp = $element->value;
             } else {
                 if ($text_or_value == 1) {
                     $disp = JText::_($element->text);
                 } else {
                     $disp = '<img src="' . $imgpath . $element->image . '" class="hasTip" title="' . $field->label . '::' . $element->text . '" alt="' . JText::_($element->text) . '" />';
                 }
             }
             $display[] = $pretext . $disp . $posttext;
             $display_index[] = $element->value;
         }
     }
     // Apply values separator
     $field->{$prop} = implode($separatorf, $display);
     $field->display_index = implode($separatorf, $display_index);
     // Apply field 's opening / closing texts
     if ($field->{$prop}) {
         $field->{$prop} = $opentag . $field->{$prop} . $closetag;
     }
 }