Ejemplo n.º 1
0
    function display($tpl = null)
    {
        //initialise variables
        $app = JFactory::getApplication();
        $user = JFactory::getUser();
        //JHTML::_('behavior.tooltip');
        //get vars
        $cid = JRequest::getVar('cid');
        $field_type = JRequest::getVar('field_type', 0);
        //Get data from the model
        $model = $this->getModel();
        $form = $this->get('Form');
        if (!FLEXI_J16GE) {
            $row =& $this->get('Field');
            //Import File system
            jimport('joomla.filesystem.file');
            // Create the form
            $pluginpath = JPATH_PLUGINS . DS . 'flexicontent_fields' . DS . $field_type . '.xml';
            if (JFile::exists($pluginpath)) {
                $form = new JParameter('', $pluginpath);
            } else {
                $form = new JParameter('', JPATH_PLUGINS . DS . 'flexicontent_fields' . DS . 'core.xml');
            }
            $form->loadINI($row->attribs);
        }
        $isnew = FLEXI_J16GE ? !$form->getValue('id') : !$row->id;
        // fail if checked out not by 'me'
        if (!$isnew) {
            if ($model->isCheckedOut($user->get('id'))) {
                JError::raiseWarning('SOME_ERROR_CODE', $row->name . ' ' . JText::_('FLEXI_EDITED_BY_ANOTHER_ADMIN'));
                $app->redirect('index.php?option=com_flexicontent&view=fields');
            }
        }
        /*if ($field_type)
        		{
        			if (!FLEXI_J16GE) {
        				echo $form->render('params', 'group-' . $field_type );
        			} else {
        				foreach ($form->getFieldset('group-' . $field_type) as $field) {
        					echo '<fieldset class="panelform">' . $field->label . $field->input . '</fieldset>' . "\n";
        				}
        			}
        		} else {
        			echo "<br /><span style=\"padding-left:25px;\"'>" . JText::_( 'FLEXI_APPLY_TO_SEE_THE_PARAMETERS' ) . "</span><br /><br />";
        		}*/
        ?>
			<div class="fctabber fields_tabset" id="field_specific_props_tabset">
			<?php 
        $fieldSets = $form->getFieldsets('attribs');
        $prefix_len = strlen('group-' . $field_type . '-');
        foreach ($fieldSets as $name => $fieldSet) {
            if ($name != 'basic' && $name != 'standard' && (substr($name, 0, $prefix_len) != 'group-' . $field_type . '-' || $name === 'group-' . $field_type)) {
                continue;
            }
            if ($fieldSet->label) {
                $label = JText::_($fieldSet->label);
            } else {
                $label = $name == 'basic' || $name == 'standard' ? JText::_('FLEXI_BASIC') : ucfirst(str_replace("group-", "", $name));
            }
            if (@$fieldSet->label_prefix) {
                $label = JText::_($fieldSet->label_prefix) . ' - ' . $label;
            }
            $icon = @$fieldSet->icon_class ? 'data-icon-class="' . $fieldSet->icon_class . '"' : '';
            $prepend = @$fieldSet->prepend_text ? 'data-prefix-text="' . JText::_($fieldSet->prepend_text) . '"' : '';
            $description = $fieldSet->description ? JText::_($fieldSet->description) : '';
            ?>
				<div class="tabbertab" id="fcform_tabset_<?php 
            echo $name;
            ?>
_tab" <?php 
            echo $icon;
            ?>
 <?php 
            echo $prepend;
            ?>
>
					<h3 class="tabberheading hasTooltip" title="<?php 
            echo $description;
            ?>
"><?php 
            echo $label;
            ?>
 </h3>
					<?php 
            $i = 0;
            ?>
					<?php 
            foreach ($form->getFieldset($name) as $field) {
                $_depends = FLEXI_J30GE ? $field->getAttribute('depend_class') : $form->getFieldAttribute($field->__get('fieldname'), 'depend_class', '', 'attribs');
                echo '
						<fieldset class="panelform' . ($i ? '' : ' fc-nomargin') . ' ' . ($_depends ? ' ' . $_depends : '') . '" id="' . $field->id . '-container">
							' . ($field->label ? '
								<span class="label-fcouter">' . str_replace('class="', 'class="label label-fcinner ', $field->label) . '</span>
								<div class="container_fcfield">' . $field->input . '</div>
							' : $field->input) . '
						</fieldset>
						';
                $i++;
            }
            ?>
				</div>
		<?php 
        }
        ?>
		</div>
		
		<?php 
        //parent::display($tpl);
    }
Ejemplo n.º 2
0
    /**
     * Logic to render an XML file as form parameters
     * NOTE: this does not work with Request Data validation in J2.5+. The validation
     *       must be skipped or the parameters must be re-added after the validation
     *
     * @access public
     * @return void
     * @since 1.5
     */
    function getlayoutparams()
    {
        jimport('joomla.filesystem.file');
        $app = JFactory::getApplication();
        $user = JFactory::getUser();
        //get vars
        $ext_option = JRequest::getVar('ext_option', '');
        $ext_view = JRequest::getVar('ext_view', '');
        $ext_id = JRequest::getInt('ext_id', 0);
        $layout_name = JRequest::getVar('layout_name', 0);
        $directory = JRequest::getVar('directory', 0);
        $path = (!is_dir($directory) ? JPATH_ROOT : '') . $directory;
        $db = JFactory::getDBO();
        if ($ext_view == 'module') {
            $query = 'SELECT params FROM #__modules WHERE id = ' . $ext_id;
            // load english language file for 'mod_flexicontent' module then override with current language file
            $module_name = basename(dirname($directory));
            JFactory::getLanguage()->load($module_name, JPATH_SITE, 'en-GB', true);
            JFactory::getLanguage()->load($module_name, JPATH_SITE, null, true);
        } else {
            if ($ext_view == 'field') {
                $query = 'SELECT attribs FROM #__flexicontent_fields WHERE id = ' . $ext_id;
            } else {
                echo "not supported extension/view: " . $ext_view;
                return;
            }
        }
        if ($ext_option != 'com_flexicontent' && $ext_option != 'com_modules' && $ext_option != 'com_advancedmodules' && $ext_option != 'com_menus') {
            echo '<div class="alert fcpadded fcinlineblock" style="">You are editing module via extension: <span class="label label-warning">' . $ext_option . '</span><br/> - If extension does not call Joomla event <span class="label label-warning">onExtensionBeforeSave</span> then custom layout parameters may not be saved</div>';
        }
        $db->setQuery($query);
        $ext_params_str = $db->loadResult();
        $layout_names = explode(':', $layout_name);
        if (count($layout_names) > 1) {
            $layout_name = $layout_names[1];
            $layoutpath = JPATH_ROOT . DS . 'templates' . DS . $layout_names[0] . DS . 'html' . DS . 'mod_flexicontent/' . $layout_name . '.xml';
        } else {
            $layoutpath = $path . DS . $layout_name . '.xml';
        }
        if (!file_exists($layoutpath)) {
            if (file_exists($path . DS . '_fallback' . DS . '_fallback.xml')) {
                $layoutpath = $path . DS . '_fallback' . DS . '_fallback.xml';
                echo '<div class="alert fcpadded fcinlineblock">Currently selected layout: <b>"' . $layout_name . '"</b> does not have a parameters XML file, using general defaults. if this is an old template then these parameters will allow to continue using it, but we recommend that you create parameter file: ' . $layout_name . '.xml</div><div class="clear"></div>';
            } else {
                echo !FLEXI_J16GE ? '<div style="font-size: 11px; color: gray; background-color: lightyellow; border: 1px solid lightgray; width: auto; padding: 4px 2%; margin: 1px 8px; height: auto;">' : '<p class="tip">';
                echo ' Currently selected layout: <b>"' . $layout_name . '"</b> does not have layout specific parameters';
                echo !FLEXI_J16GE ? '</div>' : '</p>';
                exit;
            }
        }
        //Get data from the model
        if (FLEXI_J16GE) {
            // Load XML file
            if (FLEXI_J30GE) {
                $xml = simplexml_load_file($layoutpath);
                $xmldoc =& $xml;
            } else {
                $xml = JFactory::getXMLParser('Simple');
                $xml->loadFile($layoutpath);
                $xmldoc =& $xml->document;
            }
            // Create form object, (form name seems not to cause any problem)
            $jform = new JForm('com_flexicontent.template.item', array('control' => 'jform', 'load_data' => true));
            $tmpl_params = FLEXI_J30GE ? $xmldoc->asXML() : $xmldoc->toString();
            $jform->load($tmpl_params);
            // Load existing layout values into the object (that we got from DB)
            $ext_params = new JRegistry($ext_params_str);
            // and for J1.5:  new JParameter($ext_params_str);
            $grpname = 'params';
            // this is the name of <fields> container
            foreach ($jform->getGroup($grpname) as $field) {
                $fieldname = $field->__get('fieldname');
                $value = $ext_params->get($fieldname);
                if (strlen($value)) {
                    $jform->setValue($fieldname, $grpname, $value);
                }
            }
        } else {
            // Create a parameters object
            $form = new JParameter('', $layoutpath);
            // Load existing layout values into the object (that we got from DB)
            $form->loadINI($ext_params_str);
        }
        if ($layout_name) {
            if (!FLEXI_J16GE) {
                echo $form->render('params', 'layout');
            } else {
                ?>
				<fieldset class="panelform"><?php 
                /*<ul class="adminformlist">*/
                ?>
					<?php 
                $grpname = 'params';
                // this is the name of <fields> container
                foreach ($jform->getGroup($grpname) as $field) {
                    //echo '<li>'. $field->label . $field->input .'</li>';
                    $_depends = FLEXI_J30GE ? $field->getAttribute('depend_class') : $form->getFieldAttribute($field->__get('fieldname'), 'depend_class', '', 'attribs');
                    echo '
						<fieldset class="panelform ' . ($_depends ? ' ' . $_depends : '') . '" id="' . $field->id . '-container">
							' . ($field->label ? '
								<span class="label-fcouter">' . str_replace('class="', 'class="label label-fcinner ', $field->label) . '</span>
								<div class="container_fcfield">' . $field->input . '</div>
							' : $field->input) . '
						</fieldset>';
                }
                ?>
				<?php 
                /*</ul>*/
                ?>
</fieldset>
				<?php 
            }
        } else {
            echo "<br /><span style=\"padding-left:25px;\"'>" . JText::_('FLEXI_APPLY_TO_SEE_THE_PARAMETERS') . "</span><br /><br />";
        }
        //parent::display($tpl);
    }