/** * Method to get the field options. * * @return array The field option objects. * @since 1.6 */ protected function getOptions() { // Merge any additional options in the XML definition. global $gantry; $options = parent::getOptions(); $unique = $this->getBool('unique', false); if ($unique) { $positions = $gantry->getUniquePositions(); } else { $positions = $gantry->getPositions(); } $hide_mobile = $this->getBool('hide_mobile', false); $options = array(); foreach ($positions as $position) { $positionInfo = $gantry->getPositionInfo($position); if ($hide_mobile && $positionInfo->mobile) { continue; } $val = $position; $text = $position; $tmp = GantryHtmlSelect::option($val, $text, 'value', 'text', false); $options[] = $tmp; } return $options; }
protected function getOptions() { global $gantry; $options = array(); $options = parent::getOptions(); $hide_mobile = false; $positions = $gantry->getUniquePositions(); foreach ($positions as $position) { $positionInfo = $gantry->getPositionInfo($position); if ($hide_mobile && $positionInfo->mobile) { continue; } if (1 == (int) $positionInfo->max_positions) { $split_postions[] = $positionInfo->id; continue; } for ($i = 1; $i <= (int) $positionInfo->max_positions; $i++) { $split_postions[] = $positionInfo->id . '-' . chr(96 + $i); } } foreach ($split_postions as $position) { // Create a new option object based on the <option /> element. $tmp = GantryHtmlSelect::option($position, $position, 'value', 'text', false); $options[] = $tmp; } return $options; }
/** * Method to get the field options. * * @return array The field option objects. * @since 1.6 */ protected function getOptions() { global $gantry; $options = array(); $options = parent::getOptions(); $choices = array("linear", "Quad.easeOut", "Quad.easeIn", "Quad.easeInOut", "Cubic.easeOut", "Cubic.easeIn", "Cubic.easeInOut", "Quart.easeOut", "Quart.easeIn", "Quart.easeInOut", "Quint.easeOut", "Quint.easeIn", "Quint.easeInOut", "Expo.easeOut", "Expo.easeIn", "Expo.easeInOut", "Circ.easeOut", "Circ.easeIn", "Circ.easeInOut", "Sine.easeOut", "Sine.easeIn", "Sine.easeInOut", "Back.easeOut", "Back.easeIn", "Back.easeInOut", "Bounce.easeOut", "Bounce.easeIn", "Bounce.easeInOut", "Elastic.easeOut", "Elastic.easeIn", "Elastic.easeInOut"); foreach ($choices as $choice) { // Create a new option object based on the <option /> element. $tmp = GantryHtmlSelect::option($choice, $choice, 'value', 'text', false); $options[] = $tmp; } return $options; }
/** * Method to get the field options. * * @return array The field option objects. * @since 1.6 */ protected function getOptions() { // Merge any additional options in the XML definition. global $gantry; $options = parent::getOptions(); $menus = JHtml::_('menu.menus'); foreach ($menus as $menu) { // Create a new option object based on the <option /> element. $tmp = GantryHtmlSelect::option($menu->value, $menu->text, 'value', 'text', false); $options[] = $tmp; } return $options; }
protected function getOptions() { global $gantry; $options = array(); $options = parent::getOptions(); if ($this->position_info != null) { if ($this->position_info->max_positions < (int) $this->value) { $gantry->set($this->id, $this->position_info->max_positions); $this->value = $this->position_info->max_positions; } for ($i = 1; $i <= $this->position_info->max_positions; $i++) { // Create a new option object based on the <option /> element. $tmp = GantryHtmlSelect::option($i, $i, 'value', 'text', false); $options[] = $tmp; } } return $options; }
/** * Method to get the field options. * * @return array The field option objects. * @since 1.6 */ public function getOptions() { // Initialize variables. $options = array(); // Initialize some field attributes. $filter = (string) $this->element['filter']; $exclude = (string) $this->element['exclude']; $stripExt = (string) $this->element['stripext']; $hideNone = (string) $this->element['hide_none']; $hideDefault = (string) $this->element['hide_default']; // Get the path in which to search for file options. $path = (string) $this->element['directory']; if (!is_dir($path)) { $path = JPATH_ROOT . '/' . $path; } // Prepend some default options based on field attributes. if (!$hideNone) { $options[] = GantryHtmlSelect::option('-1', JText::alt('JOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname))); } if (!$hideDefault) { $options[] = GantryHtmlSelect::option('', JText::alt('JOPTION_USE_DEFAULT', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname))); } // Get a list of files in the search path with the given filter. $files = JFolder::files($path, $filter); // Build the options list from the list of files. if (is_array($files)) { foreach ($files as $file) { // Check to see if the file is in the exclude mask. if ($exclude) { if (preg_match(chr(1) . $exclude . chr(1), $file)) { continue; } } // If the extension is to be stripped, do it. if ($stripExt) { $file = JFile::stripExt($file); } $options[] = GantryHtmlSelect::option($file, $file); } } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
protected function getOptions() { global $gantry; $options = array(); $options = parent::getOptions(); if (!defined("GANTRY_FONTS")) { $gantry->addScript($gantry->gantryUrl . '/admin/widgets/fonts/js/fonts.js'); $gantry->addDomReadyScript("GantryFonts.init('webfonts_enabled', 'webfonts_source', 'font_family');"); define("GANTRY_FONTS", 1); } // only google right now if ($gantry->get('webfonts-source') == 'google') { $webfonts = $this->_google_fonts; } if ($gantry->get('webfonts-enabled')) { $disabled = false; } else { $disabled = true; } foreach ($webfonts as $webfont) { $webfontsData = $webfont; $webfontsValue = $webfont; $text = $webfontsData; // Create a new option object based on the <option /> element. $tmp = GantryHtmlSelect::option((string) $webfontsValue, JText::_(trim((string) $text)), 'value', 'text', $disabled); // adding reference source class if (in_array($webfont, $this->_google_fonts)) { $option['class'] = 'google'; } else { $option['class'] = 'native'; } // Set some option attributes. $tmp->class = (string) $option['class']; // Set some JavaScript option attributes. $tmp->onclick = isset($option['onclick']) ? (string) $option['onclick'] : ''; // Add the option object to the result set. $options[] = $tmp; } return $options; }
/** * Method to get the field options. * * @return array The field option objects. * @since 1.6 */ protected function getOptions() { // Initialise variables. $options = array(); $extension = $this->element['extension'] ? (string) $this->element['extension'] : (string) $this->element['scope']; $published = (string) $this->element['published']; // Load the category options for a given extension. if (!empty($extension)) { // Filter over published state or not depending upon if it is present. if ($published) { $options = JHtml::_('category.options', $extension, array('filter.published' => explode(',', $published))); } else { $options = JHtml::_('category.options', $extension); } // Verify permissions. If the action attribute is set, then we scan the options. if ($action = (string) $this->element['action']) { // Get the current user object. $user = JFactory::getUser(); foreach ($options as $i => $option) { // To take save or create in a category you need to have create rights for that category // unless the item is already in that category. // Unset the option if the user isn't authorised for it. In this field assets are always categories. if ($user->authorise('core.create', $extension . '.category.' . $option->value) != true) { unset($options[$i]); } } } if (isset($this->element['show_root'])) { array_unshift($options, JHtml::_('select.option', '0', JText::_('-- Select Category --'))); } } else { JError::raiseWarning(500, JText::_('JLIB_FORM_ERROR_FIELDS_CATEGORY_ERROR_EXTENSION_EMPTY')); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
function getInput() { JHTML::_('behavior.modal'); /** @var $gantry Gantry */ global $gantry; $layout = $link = $dropdown = ""; $options = $choices = array(); $nomargin = false; $rokgallery = self::checkForRokGallery(); //$rokgallery = false; // debug $value = str_replace("'", '"', $this->value); $data = json_decode($value); if (!$data && strlen($value)) { $nomargin = true; $data = json_decode('{"path":"' . $value . '"}'); } $preview = ""; $preview_width = 'width="100"'; $preview_height = 'height="70"'; if (!$data && (!isset($data->preview) || !isset($data->path))) { $preview = $gantry->gantryUrl . '/admin/widgets/imagepicker/images/no-image.png'; } else { if (isset($data->preview)) { $preview = $data->preview; } else { $preview = JURI::root(true) . '/' . $data->path; $preview_height = ""; } } if (!defined('ELEMENT_RTIMAGEPICKER')) { $gantry->addStyle($gantry->gantryUrl . '/admin/widgets/imagepicker/css/imagepicker.css'); gantry_addInlineScript("\n\t\t\tif (typeof jInsertEditorText == 'undefined'){\n\t\t\t\tfunction jInsertEditorText(text, editor) {\n\t\t\t\t\tvar source = text.match(/(src)=(\"[^\"]*\")/i), img;\n\t\t\t\t\ttext = source[2].replace(/\\\"/g, '');\n\t\t\t\t\timg = '" . JURI::root(true) . "/' + text;\n\n\t\t\t\t\tdocument.getElementById(editor + '-img').src = img;\n\t\t\t\t\tdocument.getElementById(editor + '-img').removeProperty('height');\n\t\t\t\t\tdocument.getElementById(editor).value = JSON.encode({path: text});\n\t\t\t\t};\n\t\t\t};\n\t\t\t"); gantry_addInlineScript("\n\t\t\t\tvar AdminURI = '" . JURI::base(true) . "/';\n\t\t\t\tvar GalleryPickerInsertText = function(input, string, size, minithumb){\n\t\t\t\t\tvar data = {\n\t\t\t\t\t\tpath: string,\n\t\t\t\t\t\twidth: size.width,\n\t\t\t\t\t\theight: size.height,\n\t\t\t\t\t\tpreview: minithumb\n\t\t\t\t\t};\n\n\t\t\t\t\tdocument.getElementById(input + '-img').src = minithumb;\n\t\t\t\t\tdocument.getElementById(input + '-infos').innerHTML = data.width + ' x ' + data.height;\n\t\t\t\t\tdocument.getElementById(input).value = JSON.encode(data);\n\n\t\t\t\t};\n\n\t\t\t\tvar empty_background_img = '" . $gantry->gantryUrl . "/admin/widgets/imagepicker/images/no-image.png';\n\n\t\t\t"); define('ELEMENT_RTIMAGEPICKER', true); } gantry_addInlineScript("\n\t\t\twindow.addEvent('domready', function(){\n\t\t\t\tdocument.id('" . $this->id . "').addEvent('keyup', function(value){\n\t\t\t\t\tdocument.id('" . $this->id . "-infos').innerHTML = '';\n\t\t\t\t\tif (!value || !value.length) document.id('" . $this->id . "-img').set('src', empty_background_img);\n\t\t\t\t\telse {\n\t\t\t\t\t\tvar data = JSON.decode(value);\n\t\t\t\t\t\tdocument.id('" . $this->id . "-img').set('src', (data.preview ? data.preview : '" . JURI::root(true) . "/' + data.path));\n\t\t\t\t\t\tif (!data.preview){\n\t\t\t\t\t\t\tdocument.id('" . $this->id . "-img').removeProperty('height');\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.id('" . $this->id . "-img').set('height', '50');\n\t\t\t\t\t\t\tif (data.width && data.height) document.id('" . $this->id . "-infos').innerHTML = data.width + ' x ' + data.height;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.setProperty('value', value);\n\t\t\t\t});\n\n\t\t\t\tdocument.id('" . $this->id . "-clear').addEvent('click', function(e){\n\t\t\t\t\te.stop();\n\t\t\t\t\tdocument.id('" . $this->id . "').set('value', '').fireEvent('set', '');\n\t\t\t\t\tdocument.id('" . $this->id . "-img').src = empty_background_img;\n\t\t\t\t\tdocument.id('" . $this->id . "-infos').innerHTML = '';\n\t\t\t\t});\n\n\t\t\t\tvar dropdown = document.id('" . $this->id . "mediatype');\n\t\t\t\tif (dropdown){\n\t\t\t\t\tdropdown.addEvent('change', function(){\n\t\t\t\t\t\tdocument.id('" . $this->id . "-link').set('href', this.value);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t"); if ($rokgallery) { $link = 'index.php?option=com_rokgallery&view=gallerypicker&tmpl=component&show_menuitems=0&inputfield=' . $this->id; } else { $link = "index.php?option=com_media&view=images&layout=default&tmpl=component&e_name=" . $this->id; } if ($rokgallery) { $choices = array(array('RokGallery', 'index.php?option=com_rokgallery&view=gallerypicker&tmpl=component&show_menuitems=0&inputfield=' . $this->id), array('MediaManager', 'index.php?option=com_media&view=images&layout=default&tmpl=component&e_name=' . $this->id)); foreach ($choices as $option) { $options[] = GantryHtmlSelect::option($option[1], $option[0], 'value', 'text'); } include_once $gantry->gantryPath . '/' . 'admin' . '/' . 'forms' . '/' . 'fields' . '/' . 'selectbox.php'; $selectbox = new GantryFormFieldSelectBox(); $selectbox->id = $this->id . 'mediatype'; $selectbox->value = $link; $selectbox->addOptions($options); $dropdown = '<div id="' . $this->id . '-mediadropdown" class="mediadropdown">' . $selectbox->getInput() . "</div>"; } $value = str_replace('"', "'", $value); $layout .= ' <div class="wrapper">' . "\n" . ' <div id="' . $this->id . '-wrapper" class="backgroundpicker">' . "\n" . ' <img id="' . $this->id . '-img" class="backgroundpicker-img" ' . $preview_width . ' ' . $preview_height . ' alt="" src="' . $preview . '" /> <div id="' . $this->id . '-infos" class="backgroundpicker-infos" ' . ($rokgallery && !$nomargin ? 'style="display:inline-block;"' : 'style="display:none;"') . ' >' . (isset($data->width) && isset($data->height) ? $data->width . ' x ' . $data->height : '') . '</div> <a id="' . $this->id . '-link" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 675, y: 450}}" class="rok-button modal">' . "\n" . ' Select </a>' . "\n" . ' <a id="' . $this->id . '-clear" href="#" class="rok-button bg-button-clear">' . "\n" . ' Reset </a>' . "\n" . ' ' . $dropdown . ' <input class="background-picker" type="hidden" id="' . $this->id . '" name="' . $this->name . '" value="' . $value . '" />' . "\n" . ' <div class="clr"></div> </div>' . "\n" . ' </div>' . "\n" . ' '; return $layout; }