Exemplo n.º 1
0
 /**
  * Method to get the custom field options.
  * Use the query attribute to supply a query to generate the list.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Initialize some field attributes.
     $key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value';
     $value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name'];
     $translate = $this->element['translate'] ? (string) $this->element['translate'] : false;
     $query = (string) $this->element['query'];
     // Get the database object.
     $db = JFactory::getDBO();
     // Set the query and get the result list.
     $db->setQuery($query);
     $items = $db->loadObjectlist();
     // Check for an error.
     if ($db->getErrorNum()) {
         JError::raiseWarning(500, $db->getErrorMsg());
         return $options;
     }
     // Build the field options.
     if (!empty($items)) {
         foreach ($items as $item) {
             if ($translate == true) {
                 $options[] = RokCommon_HTML_SelectList::option($item->{$key}, rc__($item->{$value}));
             } else {
                 $options[] = RokCommon_HTML_SelectList::option($item->{$key}, $item->{$value});
             }
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Exemplo n.º 2
0
 /**
  * Method to get the field options for the list of installed editors.
  *
  * @return  array  The field option objects.
  * @since   11.1
  */
 protected function getOptions()
 {
     $container = RokCommon_Service::getContainer();
     /** @var $model RokSprocket_Model_Widgets */
     $model = $container->getService('roksprocket.widgets.model');
     $widgets = $model->getAvailableInstances();
     $fieldname = $this->element['name'];
     $options = array();
     $options[] = RokCommon_HTML_SelectList::option('', rc__('- Select RokSprocket Widget -'));
     foreach ($widgets as $info) {
         if ($this->value == $info['id']) {
             $selected = ' selected="selected"';
         } else {
             $selected = "";
         }
         $tmp = RokCommon_HTML_SelectList::option($info['id'], $info['title']);
         $options[] = $tmp;
     }
     $options = array_merge(parent::getOptions(), $options);
     foreach ($options as &$option) {
         // Set some option attributes.
         $option->attr = array('class' => $option->value, 'rel' => $fieldname . '_' . $option->value);
     }
     reset($options);
     return $options;
 }
Exemplo n.º 3
0
 /**
  * Method to get the field options for the list of installed editors.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     JLog::add('RokCommon_Form_Field_Editors is deprecated. Use RokCommon_Form_Field_Plugins instead (with folder="editors").', JLog::WARNING, 'deprecated');
     // Get the database object and a new query object.
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     // Build the query.
     $query->select('element AS value, name AS text');
     $query->from('#__extensions');
     $query->where('folder = ' . $db->quote('editors'));
     $query->where('enabled = 1');
     $query->order('ordering, name');
     // Set the query and load the options.
     $db->setQuery($query);
     $options = $db->loadObjectList();
     $lang = JFactory::getLanguage();
     foreach ($options as $i => $option) {
         $lang->load('plg_editors_' . $option->value, JPATH_ADMINISTRATOR, null, false, false) || $lang->load('plg_editors_' . $option->value, JPATH_PLUGINS . '/editors/' . $option->value, null, false, false) || $lang->load('plg_editors_' . $option->value, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load('plg_editors_' . $option->value, JPATH_PLUGINS . '/editors/' . $option->value, $lang->getDefault(), false, false);
         $options[$i]->text = rc__($option->text);
     }
     // Check for a database error.
     if ($db->getErrorNum()) {
         JError::raiseWarning(500, $db->getErrorMsg());
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Exemplo n.º 4
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Initialize some field attributes.
     $first = (int) $this->element['first'];
     $last = (int) $this->element['last'];
     $step = (int) $this->element['step'];
     // Sanity checks.
     if ($step == 0) {
         // Step of 0 will create an endless loop.
         return $options;
     } elseif ($first < $last && $step < 0) {
         // A negative step will never reach the last number.
         return $options;
     } elseif ($first > $last && $step > 0) {
         // A position step will never reach the last number.
         return $options;
     }
     // Build the options array.
     for ($i = $first; $i <= $last; $i += $step) {
         $options[] = RokCommon_HTML_SelectList::option($i);
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Exemplo n.º 5
0
 /**
  * Method to get a list of options for a list input.
  *
  * @return	array		An array of JHtml options.
  *
  * @since   11.4
  */
 protected function getOptions()
 {
     // Initialise variables
     $folder = $this->element['folder'];
     if (!empty($folder)) {
         // Get list of plugins
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('element AS value, name AS text');
         $query->from('#__extensions');
         $query->where('folder = "' . $folder . '"');
         $query->where('enabled = 1');
         $query->order('ordering, name');
         $db->setQuery($query);
         $options = $db->loadObjectList();
         $lang = JFactory::getLanguage();
         foreach ($options as $i => $item) {
             $source = JPATH_PLUGINS . '/' . $folder . '/' . $item->value;
             $extension = 'plg_' . $folder . '_' . $item->value;
             $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension . '.sys', $source, null, false, false) || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false);
             $options[$i]->text = rc__($item->text);
         }
         if ($db->getErrorMsg()) {
             JError::raiseWarning(500, rc__('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY'));
             return '';
         }
     } else {
         JError::raiseWarning(500, rc__('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY'));
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Exemplo n.º 6
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     // Initialize some field attributes.
     $client = (string) $this->element['client'];
     if ($client != 'site' && $client != 'administrator') {
         $client = 'site';
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), JLanguageHelper::createLanguageList($this->value, constant('JPATH_' . strtoupper($client)), true, true));
     return $options;
 }
Exemplo n.º 7
0
 /**
  * Method to get the field options.
  *
  * @return    array    The field option objects.
  * @since    1.6
  */
 protected function getOptions()
 {
     $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 = RokCommon_HTML_SelectList::option($choice, $choice, 'value', 'text', false);
         $options[] = $tmp;
     }
     return $options;
 }
Exemplo n.º 8
0
 /**
  * Method to get the field options.
  *
  * @return  array    The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Convert to name => name array.
     foreach (JCache::getStores() as $store) {
         $options[] = RokCommon_HTML_SelectList::option($store, rc__('JLIB_FORM_VALUE_CACHE_' . $store), 'value', 'text');
     }
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Exemplo n.º 9
0
 /**
  * Method to get the session handler field options.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Get the options from JSession.
     foreach (JSession::getStores() as $store) {
         $options[] = RokCommon_HTML_SelectList::option($store, rc__('JLIB_FORM_VALUE_SESSION_' . $store), 'value', 'text');
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Exemplo n.º 10
0
 /**
  * Method to get the list of files for the field options.
  * Specify the target directory with a directory attribute
  * Attributes allow an exclude mask and stripping of extensions from file name.
  * Default attribute may optionally be set to null (no file) or -1 (use a default).
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected 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[] = RokCommon_HTML_SelectList::option('-1', rc_alt('JOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)));
     }
     if (!$hideDefault) {
         $options[] = RokCommon_HTML_SelectList::option('', rc_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[] = RokCommon_HTML_SelectList::option($file, $file);
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Exemplo n.º 11
0
 /**
  * Method to get the field input markup for a generic list.
  * Use the multiple attribute to enable multiselect.
  *
  * @return  string  The field input markup.
  *
  * @since   11.1
  */
 public function getInput()
 {
     // Initialize variables.
     $html = array();
     $attr = '';
     if (!self::$js_loaded) {
         RokCommon_Header::addInlineScript($this->attachJavaScript());
         self::$js_loaded = true;
     }
     // Initialize some field attributes.
     $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     // To avoid user's confusion, readonly="true" should imply disabled="true".
     if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') {
         $attr .= ' disabled="disabled"';
     }
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $attr .= $this->multiple ? ' multiple="multiple"' : '';
     // Initialize JavaScript field attributes.
     $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     if ($this->element['attrs']) {
         $additional_attrs = explode(',', (string) $this->element['attrs']);
         foreach ($additional_attrs as $additional_attr) {
             $additional_attr = strtolower(trim($additional_attr));
             $attr .= $this->element[$additional_attr] ? sprintf(' %s="', $additional_attr) . (string) $this->element[$additional_attr] . '"' : '';
         }
     }
     // Get the field options.
     $options = (array) $this->getOptions();
     // Create a read-only list (no name) with a hidden input to store the value.
     if ((string) $this->element['readonly'] == 'true' || $this->element['disabled'] == true) {
         $html[] = RokCommon_HTML_SelectList::genericlist($options, '', trim($attr), 'value', 'text', $this->value, $this->id);
         $html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value) . '"/>';
     } else {
         $list = RokCommon_HTML_SelectList::genericlist($options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id);
         $html[] = $list;
     }
     return implode($html);
 }
Exemplo n.º 12
0
 /**
  * Method to get the field options for category
  * Use the extension attribute in a form to specify the.specific extension for
  * which categories should be displayed.
  * Use the show_root attribute to specify whether to show the global category root in the list.
  *
  * @return  array    The field option objects.
  *
  * @since   11.1
  */
 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 ((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, RokCommon_HTML_SelectList::option('0', rc__('JGLOBAL_ROOT')));
         }
     } else {
         JError::raiseWarning(500, rc__('JLIB_FORM_ERROR_FIELDS_CATEGORY_ERROR_EXTENSION_EMPTY'));
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Exemplo n.º 13
0
 /**
  * Method to get the field options for the list of installed editors.
  *
  * @return  array  The field option objects.
  * @since   11.1
  */
 protected function getOptions()
 {
     $container = RokCommon_Service::getContainer();
     $fieldname = $this->element['name'];
     $options = array();
     if (isset($this->element['configkey'])) {
         $configkey = (string) $this->element['configkey'];
         $params = $container[$configkey];
         foreach ($params as $id => $info) {
             if ($this->value == $id) {
                 $selected = ' selected="selected"';
             } else {
                 $selected = "";
             }
             $tmp = RokCommon_HTML_SelectList::option($id, $info->displayname);
             $options[] = $tmp;
         }
     }
     $options = array_merge(parent::getOptions(), $options);
     foreach ($options as &$option) {
         // Set some option attributes.
         $option->attr = array('class' => $option->value, 'rel' => $fieldname . '_' . $option->value);
     }
     reset($options);
     return $options;
 }
Exemplo n.º 14
0
 /**
  * Method to get the help site field options.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), JHelp::createSiteList(JPATH_ADMINISTRATOR . '/help/helpsites.xml', $this->value));
     return $options;
 }
Exemplo n.º 15
0
 /**
  * Method to get the list of menus for the field options.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), JHtml::_('menu.menus'));
     return $options;
 }
Exemplo n.º 16
0
 /**
  * Method to get the field options for content languages.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     // Merge any additional options in the XML definition.
     return array_merge(parent::getOptions(), JHtml::_('contentlanguage.existing'));
 }