function display($tpl = null) { /** @var $gantry Gantry */ global $gantry; $language = JFactory::getLanguage(); $language->load('com_templates'); $this->item = $this->get('Item'); JHtml::_('behavior.framework', true); require_once JPATH_LIBRARIES . "/gantry/gantry.php"; gantry_import('core.config.gantryform'); GantryForm::addFormPath(JPATH_COMPONENT_ADMINISTRATOR); GantryForm::addFormPath($gantry->templatePath); GantryForm::addFieldPath($gantry->gantryPath . '/admin/forms/fields'); GantryForm::addFieldPath($gantry->templatePath . '/fields'); GantryForm::addFieldPath($gantry->templatePath . '/admin/forms/fields'); GantryForm::addGroupPath($gantry->gantryPath . '/admin/forms/groups'); GantryForm::addGroupPath($gantry->templatePath . '/admin/forms/groups'); $this->state = $this->get('State'); $this->form = $this->get('Form'); $this->override = $this->get('Override'); $this->gantryForm = $this->get('GantryForm'); $this->activeTab = isset($_COOKIE['gantry-admin-tab']) ? $_COOKIE['gantry-admin-tab'] + 1 : 1; $this->tabs = $this->getTabs($this->gantryForm); $this->assignmentCount = $this->getAssignmentCount($this->item->id); $model = $this->getModel(); $model->checkForGantryUpdate(); //$this->addToolbar(); JToolBarHelper::title(''); ob_start(); parent::display($tpl); $buffer = ob_get_clean(); echo $buffer; }
function form($instance) { gantry_import('core.config.gantryform'); global $gantry; $defaults = $this->_defaults; $gantry->addScript('mootools.js'); $instance = wp_parse_args((array) $instance, $defaults); foreach ($instance as $variable => $value) { ${$variable} = GantryWidget::_cleanOutputVariable($variable, $value); $instance[$variable] = ${$variable}; } $this->_values = $instance; $form = GantryForm::getInstance($this, $this->short_name, $this->short_name); $form->bind($this->_values); ob_start(); $fieldSets = $form->getFieldsets(); foreach ($fieldSets as $name => $fieldSet) { ?> <fieldset class="panelform"> <?php foreach ($form->getFieldset($name) as $field) { ?> <div class="field-wrapper"> <?php echo $field->label; ?> <?php echo $field->input; ?> </div> <?php } ?> </fieldset> <?php } echo ob_get_clean(); }
/** * Method to attach a JForm object to the field. * * @param object $form The JForm object to attach to the form field. * * @return object The form field object so that the method can be used in a chain. * @since 1.6 */ public function setForm(GantryForm $form) { $this->form = $form; $this->formControl = $form->getFormControl(); return $this; }
/** * Method to load the form description from an XML file. * * The reset option works on a group basis. If the XML file references * groups that have already been created they will be replaced with the * fields in the new XML file unless the $reset parameter has been set * to false. * * @param string $file The filesystem path of an XML file. * @param string $replace Flag to toggle whether form fields should be replaced if a field * already exists with the same group/name. * @param string $xpath An optional xpath to search for the fields. * * @return boolean True on success, false otherwise. * @since 1.6 */ public function loadFile($file, $reset = true, $xpath = false) { // Check to see if the path is an absolute path. if (!is_file($file)) { // Not an absolute path so let's attempt to find one using JPath. $file = GantryFormHelper::find(self::addFormPath(), $file . '.xml'); // If unable to find the file return false. if (!$file) { return false; } } // Attempt to load the XML file. $xml = GantryForm::getXML($file, true); return $this->load($xml, $reset, $xpath); }
public function getGantryForm() { gantry_import('core.config.gantryform'); gantry_import('core.config.gantryformnaminghelper'); $pk = !empty($pk) ? $pk : (int) $this->getState('template.id'); $item = $this->getItem($pk); $item->params['current_id'] = $pk; if (!isset($this->_formCache[$pk])) { $form = GantryForm::getInstance(GantryFormNamingHelper::getInstance(), 'template-options', 'template-options', array(), true, "//form"); $form->bind($item->params); $this->_formCache[$pk] = $form; } return $this->_formCache[$pk]; }
$gantry->addScript($gantry->gantryUrl . '/admin/widgets/gantry.js'); // Setup the JS for the admin $gantry->addInlineScript(gantryLang()); if (file_exists($gantry->templatePath . "/gantry.scripts.php") && is_readable($gantry->templatePath . "/gantry.scripts.php")) { include_once $gantry->templatePath . "/gantry.scripts.php"; if (function_exists('gantry_params_init')) { gantry_params_init(); } } $override_catalog = gantry_get_override_catalog($gantry->templateName); $data = array(); $data['template-options'] = get_option($gantry->templateName . '-template-options'); GantryForm::addFormPath($gantry->templatePath); GantryForm::addFieldPath($gantry->templatePath . '/fields'); GantryForm::addFieldPath($gantry->templatePath . '/admin/forms/fields'); $form = GantryForm::getInstance(GantryTemplateInfo::getInstance(), 'template-options', 'templateDetails', array(), true, '//config'); $form->bind($data); $fieldSets = $form->getFieldsets('template-options'); $form->initialize(); ?> <div id="hack-panel"> <?php $fields = $form->getFullFieldset('toolbar-panel'); foreach ($fields as $name => $field) { $gantry->addDomReadyScript("Gantry.ToolBar.add('" . $field->type . "');"); echo "<div id=\"contextual-" . $field->type . "-wrap\" class=\"hidden contextual-custom-wrap\">\n"; echo "\t\t<div class=\"metabox-prefs\">\n"; echo $field->input; echo "\t\t</div>\n"; echo "</div>\n"; }
public function form($instance) { gantry_import('core.config.gantryform'); global $gantry; GantryForm::addFieldPath($gantry->gantryPath . '/widgets/gantrymenu/admin/fields'); $themes = self::$themes; foreach ($themes as $theme) { GantryForm::addFormPath($theme['path']); } // TODO see if we need this $gantry->addScript('mootools.js'); $instance = wp_parse_args($instance, $this->getDefaults()); // If no menus exists, direct the user to go and create some. foreach ($instance as $variable => $value) { ${$variable} = self::_cleanOutputVariable($variable, $value); $instance[$variable] = ${$variable}; } $this->_values = $instance; $form = GantryForm::getInstance($this, $this->short_name, $this->short_name); $form->bind($this->_values); $fieldSets = $form->getFieldsets(); $subforms = array(); foreach ($themes as $theme) { $subform = GantryForm::getInstance($this, $theme['name'], $theme['name']); $subform->bind($this->_values); $subforms[$theme['name']] = $subform; } ob_start(); ?> <fieldset class="panelform"> <?php foreach ($fieldSets as $name => $fieldSet) { ?> <?php foreach ($form->getFieldset($name) as $field) { ?> <div class="field-wrapper"> <?php echo $field->label; ?> <?php echo $field->input; ?> </div> <?php } ?> <?php foreach ($subforms as $subform_name => $subform) { ?> <?php foreach ($subform->getFieldset($subform_name) as $field) { ?> <div class="field-wrapper"> <?php echo $field->label; ?> <?php echo $field->input; ?> </div> <?php } ?> <?php } ?> <?php } ?> </fieldset> <?php echo ob_get_clean(); }
/** * Gets the xml config for all gantry widgets * @return void */ function _getWidgetConfigs() { gantry_import('core.config.gantryform'); $form_paths = array($this->gantryPath . DS . 'widgets', $this->templatePath . DS . 'widgets'); foreach ($form_paths as $form_path) { if (file_exists($form_path) && is_dir($form_path)) { GantryForm::addFormPath($form_path); } } $field_paths = array($this->gantryPath . DS . 'admin/forms/fields', $this->templatePath . DS . 'admin/forms/fields'); foreach ($field_paths as $field_path) { if (file_exists($field_path) && is_dir($field_path)) { GantryForm::addFieldPath($field_path); } } $group_paths = array($this->gantryPath . DS . 'admin/forms/groups', $this->templatePath . DS . 'admin/forms/groups'); foreach ($group_paths as $group_path) { if (file_exists($group_path) && is_dir($group_path)) { GantryForm::addGroupPath($group_path); } } }