Ejemplo n.º 1
0
	/**
	 * Test the getInput method.
	 */
	public function testGetInput()
	{
		$form = new JFormInspector('form1');

		$this->assertThat(
			$form->load('<form><field name="list" type="list" /></form>'),
			$this->isTrue(),
			'Line:'.__LINE__.' XML string should load successfully.'
		);

		$field = new JFormFieldList($form);

		$this->assertThat(
			$field->setup($form->getXml()->field, 'value'),
			$this->isTrue(),
			'Line:'.__LINE__.' The setup method should return true.'
		);

		$this->assertThat(
			strlen($field->input),
			$this->greaterThan(0),
			'Line:'.__LINE__.' The getInput method should return something without error.'
		);

		// TODO: Should check all the attributes have come in properly.
	}
Ejemplo n.º 2
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 public function getOptions()
 {
     $options = array();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('code As value, title As `text`, print_title')->from('#__sibdiet_countries')->order('title')->where('published = 1');
     $db->setQuery($query);
     try {
         $options = $db->loadObjectList();
     } catch (RuntimeException $e) {
         JError::raiseWarning(500, $e->getMessage());
     }
     $lang_tag = JFactory::getLanguage()->get('tag');
     foreach ($options as $option) {
         // Convert the print_title field to an array.
         $registry = new JRegistry();
         $registry->loadString($option->print_title);
         $print_title = $registry->toArray();
         if (array_key_exists($lang_tag, $print_title)) {
             $option->text = $print_title[$lang_tag];
         }
     }
     // Sort Options
     usort($options, function ($a, $b) {
         return strcmp($a->text, $b->text);
     });
     return array_merge(parent::getOptions(), $options);
 }
Ejemplo n.º 3
0
 protected function getOptions()
 {
     $options = array();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query = '
     SELECT
         ct.id AS id,
         c.locale_key AS container_name,
         ct.liters AS liters
     FROM #__reomi_container_types AS ct
     INNER JOIN #__reomi_containers AS c ON ct.container_id = c.id
     ORDER BY
         c.name ASC,
         ct.liters ASC
     ';
     $db->setQuery($query);
     $containers = $db->loadObjectList();
     $options = array();
     if ($containers) {
         foreach ($containers as $item) {
             $options[] = JHtml::_('select.option', $item->id, JText::_($item->container_name) . " " . $item->liters . "L");
         }
     }
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Ejemplo n.º 4
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()
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     // Select the required fields from the table.
     $query->select('c.id, c.country, c.country_jtext');
     $query->from('`#__tj_country` AS c');
     $query->where('c.com_quick2cart = 1');
     $query->order($db->escape('c.ordering ASC'));
     $db->setQuery($query);
     // Get all countries.
     $countries = $db->loadObjectList();
     $options = array();
     // Load lang file for countries
     $lang = JFactory::getLanguage();
     $lang->load('tjgeo.countries', JPATH_SITE, null, false, true);
     foreach ($countries as $c) {
         if ($lang->hasKey(strtoupper($c->country_jtext))) {
             $c->country = JText::_($c->country_jtext);
         }
         $options[] = JHtml::_('select.option', $c->id, $c->country);
     }
     if (!$this->loadExternally) {
         // Merge any additional options in the XML definition.
         $options = array_merge(parent::getOptions(), $options);
     }
     return $options;
 }
Ejemplo n.º 5
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[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value}));
             } else {
                 $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value});
             }
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Ejemplo n.º 6
0
 /**
  * Method to get the field options.
  *
  * @since 2.0
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     $options = parent::getOptions();
     if (!empty($options)) {
         return $options;
     }
     // If no custom options were defined let's figure out which ones of the
     // defaults we shall use...
     $config = array('published' => 1, 'unpublished' => 1, 'archived' => 0, 'trash' => 0, 'all' => 0);
     $stack = array();
     // We are no longer using jgrid.publishedOptions as it's returning
     // untranslated strings, unsuitable for our purposes.
     if ($this->element['show_published'] == 'false') {
         $stack[] = JHtml::_('select.option', '1', JText::_('JPUBLISHED'));
     }
     if ($this->element['show_unpublished'] == 'false') {
         $stack[] = JHtml::_('select.option', '0', JText::_('JUNPUBLISHED'));
     }
     if ($this->element['show_archived'] == 'true') {
         $stack[] = JHtml::_('select.option', '2', JText::_('JARCHIVED'));
     }
     if ($this->element['show_trash'] == 'true') {
         $stack[] = JHtml::_('select.option', '-2', JText::_('JTRASHED'));
     }
     if ($this->element['show_all'] == 'true') {
         $stack[] = JHtml::_('select.option', '*', JText::_('JALL'));
     }
     return $stack;
 }
Ejemplo n.º 7
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()
	{
		// 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 = JText::_($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;
	}
Ejemplo n.º 8
0
 public function getOptions()
 {
     # The options available are based on what type was selected
     $options = array();
     $type = $this->form->getField('entity_type')->value;
     return array_merge(parent::getOptions(), JFormFieldParentEntity::getParents($type));
 }
Ejemplo n.º 9
0
 /**
  * Method to attach a JForm object to the field.
  *
  * @param   object  $element  The SimpleXMLElement object representing the <field /> tag for the form field object.
  * @param   mixed   $value    The form field value to validate.
  * @param   string  $group    The field name group control value. This acts as as an array container for the field.
  *                            For example if the field has name="foo" and the group value is set to "bar" then the
  *                            full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  *
  * @since   11.1
  */
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     $return = parent::setup($element, $value, $group);
     $defaultToTableValue = $this->element->attributes()->default_to_table;
     if ($defaultToTableValue) {
         $defaultToTableValue = (bool) $this->element->attributes()->{$defaultToTableValue}[0];
     } else {
         $defaultToTableValue = true;
     }
     if ($this->value == '' && $return && $defaultToTableValue) {
         $db = JFactory::getDbo();
         /*
          * Attempt to get the real Db collation (tmp fix before this makes it into J itself
          * see - https://github.com/joomla/joomla-cms/pull/2092
          */
         $db->setQuery('SHOW VARIABLES LIKE "collation_database"');
         try {
             $res = $db->loadObject();
             if (isset($res->Value)) {
                 $this->value = $res->Value;
             }
         } catch (RuntimeException $e) {
             $this->value = $db->getCollation();
         }
     }
     return $return;
 }
Ejemplo n.º 10
0
 /**
  * Method to get a list of options for a list input.
  *
  * @return      array           An array of JHtml options.
  */
 protected function getOptions()
 {
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select($db->quoteName('car.id') . ', ' . $db->quoteName('car.name'));
     $query->from($db->quoteName('#__agendadirigentes_cargos', 'car'));
     if ($this->getAttribute('includecategory', false) == true) {
         $query->select($db->quoteName('cat.title', 'category_name'));
         $query->join('INNER', $db->quoteName('#__categories', 'cat') . ' ON ' . $db->quoteName('car.catid') . ' = ' . $db->quoteName('cat.id'));
         $query->order($db->quoteName('cat.title') . 'ASC, ' . $db->quoteName('car.name') . ' ASC');
     } else {
         $query->order($db->quoteName('car.name') . ' ASC');
     }
     $db->setQuery((string) $query);
     $cargos = $db->loadObjectList();
     $options = array();
     $options[] = JHtml::_('select.option', '', JText::_('COM_AGENDADIRIGENTES_SELECT_CARGO'));
     if ($cargos) {
         foreach ($cargos as $cargo) {
             if ($this->getAttribute('includecategory', false)) {
                 $options[] = JHtml::_('select.option', $cargo->id, $cargo->category_name . ' - ' . $cargo->name);
             } else {
                 $options[] = JHtml::_('select.option', $cargo->id, $cargo->name);
             }
         }
     }
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Ejemplo n.º 11
0
 protected function getOptions()
 {
     $session = JFactory::getSession();
     $attr = '';
     // 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'] . '"' : '';
     $db = JFactory::getDBO();
     $db->setQuery("SELECT t.name AS name, t.id AS id FROM #__k2_tags AS t WHERE published = 1 ORDER BY t.name ASC");
     $results = $db->loadObjectList();
     $tags = array();
     if (count($results)) {
         foreach ($results as $tag) {
             $tags[] = JHtml::_('select.option', $tag->id, $tag->name);
         }
         $tags = array_merge(parent::getOptions(), $tags);
         return $tags;
     } else {
         $tags = array();
         return $tags;
     }
 }
Ejemplo n.º 12
0
 /**
  * Method to get the options to populate list
  *
  * @return  array  The field option objects.
  *
  * @since   3.2
  */
 protected function getOptions()
 {
     // Hash for caching
     $hash = md5($this->element);
     if (!isset(static::$options[$hash])) {
         static::$options[$hash] = parent::getOptions();
         $options = array();
         $db = JFactory::getDbo();
         $user = JFactory::getUser();
         $query = $db->getQuery(true)->select('a.id AS value')->select('a.title AS text')->select('COUNT(DISTINCT b.id) AS level')->from('#__categories as a')->where('a.extension = "' . $this->extension . '"')->join('LEFT', '#__categories AS b ON a.lft > b.lft AND a.rgt < b.rgt')->group('a.id, a.title, a.lft, a.rgt')->order('a.lft ASC');
         $isRoot = $user->authorise('core.admin');
         if (!$isRoot) {
             require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/imc.php';
             $allowed_catids = ImcHelper::getCategoriesByUserGroups();
             $allowed_catids = implode(',', $allowed_catids);
             if (!empty($allowed_catids)) {
                 $query->where('a.id IN (' . $allowed_catids . ')');
             }
         }
         $db->setQuery($query);
         if ($options = $db->loadObjectList()) {
             foreach ($options as &$option) {
                 $option->text = str_repeat('- ', $option->level) . $option->text;
             }
             static::$options[$hash] = array_merge(static::$options[$hash], $options);
         }
     }
     return static::$options[$hash];
 }
Ejemplo n.º 13
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  * @since   1.6
  */
 protected function getOptions()
 {
     $options = array();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('a.id AS value, a.name AS text, a.level')->from('#__jdeveloper_forms AS a')->join('LEFT', $db->quoteName('#__jdeveloper_forms') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt')->where('a.parent_id > 0');
     // Prevent parenting to children of this item.
     if ($id = $this->form->getValue('id')) {
         $query->join('LEFT', $db->quoteName('#__jdeveloper_forms') . ' AS p ON p.id = ' . (int) $id)->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)');
     }
     $query->group('a.id, a.name, a.level, a.lft, a.rgt, a.parent_id');
     $query->order('a.lft ASC');
     // Get the options.
     $db->setQuery($query);
     try {
         $root = new JObject(array("value" => 1, "text" => JText::_("JGLOBAL_ROOT_PARENT"), "level" => 0));
         $options = array_merge(array($root), $db->loadObjectList());
     } catch (RuntimeException $e) {
         throw new Exception($e->getMessage());
     }
     // Pad the option text with spaces using depth level as a multiplier.
     for ($i = 0, $n = count($options); $i < $n; $i++) {
         $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Ejemplo n.º 14
0
 function getOptions()
 {
     // Base name of the HTML control.
     //    $ctrl  = $control_name .'['. $name .']';
     $courses = JoomdleHelperContent::getCourseList(0);
     // Construct an array of the HTML OPTION statements.
     $options = array();
     $c = array();
     foreach ($courses as $course) {
         $val = $course['remoteid'];
         $text = $course['fullname'];
         $options[] = JHtml::_('select.option', $val, $text);
         //		$op->id = $course['remoteid'];
         //		$op->text = $course['fullname'];
         //		$c[] = $op;
     }
     $options = array_merge(parent::getOptions(), $options);
     return $options;
     // Construct the various argument calls that are supported.
     $attribs = ' ';
     if ($v = $node->attributes('size')) {
         $attribs .= 'size="' . $v . '"';
     }
     if ($v = $node->attributes('class')) {
         $attribs .= 'class="' . $v . '"';
     } else {
         $attribs .= 'class="inputbox"';
     }
     if ($m = $node->attributes('multiple')) {
         $attribs .= ' multiple="multiple"';
         $ctrl .= '[]';
     }
     // Render the HTML SELECT list.
     return JHTML::_('select.genericlist', $options, $ctrl, $attribs, 'value', 'text', $value, $control_name . $name);
 }
Ejemplo n.º 15
0
 /**
  * Method to get the field input markup with an image tag.
  *
  * @return  string  The field input markup.
  */
 protected function getInput()
 {
     // This Form is used outside of our component, therefor fix the path
     JLoader::import('mapicons', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_simplegeotag' . DS . 'models');
     $model = JModel::getInstance('MapIcons', 'SimpleGeoTagModel');
     $this->items = $model->getItems();
     //var_dump($this->items);
     // Add Google Map's js
     $doc =& JFactory::getDocument();
     /*
     $lang = & JFactory::getLanguage();
     $langcode = $lang->getTag();
     $doc->addScript('http://maps.google.com/maps/api/js?sensor=false&language='.$langcode );
     */
     // Add data to javascript array (for image preview)
     $js = array();
     $js[] = "var mapicons = ";
     $js[] = json_encode($this->items);
     $js[] = ";\n";
     $js[] = "function setMapIcon (val) {\n";
     $js[] = "\tvar mapicon = mapicons.filter(function(item, index, arr) { if(item[\"id\"] == val) return true;  },val)[0];\n";
     $js[] = "\tvar imgtag = \$('jform_metadata_mapicon_img')\n";
     $js[] = "\timgtag.src = mapicon['image'];\n";
     $js[] = "\timgtag.width = mapicon['size_width'];\n";
     $js[] = "\timgtag.height = mapicon['size_height'];\n";
     $js[] = "}\n";
     $doc->addScriptDeclaration(implode($js));
     $this->element['onchange'] = "setMapIcon(this.value)";
     $html = parent::getInput();
     $this->imgid = $this->id . '_' . $this->imgid;
     $html = $html . '<img id="' . $this->imgid . '" src="" />';
     return $html;
 }
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  * @since   1.6
  */
 protected function getOptions()
 {
     $options = array();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('a.id AS value, a.title AS text, a.level')->from('#__menu AS a')->join('LEFT', $db->quoteName('#__menu') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
     if ($menuType = $this->form->getValue('menutype')) {
         $query->where('a.menutype = ' . $db->quote($menuType));
     } else {
         $query->where('a.menutype != ' . $db->quote(''));
     }
     // Prevent parenting to children of this item.
     if ($id = $this->form->getValue('id')) {
         $query->join('LEFT', $db->quoteName('#__menu') . ' AS p ON p.id = ' . (int) $id)->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)');
     }
     $query->where('a.published != -2')->group('a.id, a.title, a.level, a.lft, a.rgt, a.menutype, a.parent_id, a.published')->order('a.lft ASC');
     // Get the options.
     $db->setQuery($query);
     try {
         $options = $db->loadObjectList();
     } catch (RuntimeException $e) {
         JError::raiseWarning(500, $e->getMessage());
     }
     // Pad the option text with spaces using depth level as a multiplier.
     for ($i = 0, $n = count($options); $i < $n; $i++) {
         $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Ejemplo n.º 17
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  *
  * @since   1.6
  */
 protected function getOptions()
 {
     $app = JFactory::getApplication();
     // Detect the native language.
     $native = JLanguageHelper::detectLanguage();
     if (empty($native)) {
         $native = 'en-GB';
     }
     // Get a forced language if it exists.
     $forced = $app->getLocalise();
     if (!empty($forced['language'])) {
         $native = $forced['language'];
     }
     // If a language is already set in the session, use this instead
     $model = new InstallationModelSetup();
     $options = $model->getOptions();
     if (isset($options['language'])) {
         $native = $options['language'];
     }
     // Get the list of available languages.
     $options = JLanguageHelper::createLanguageList($native);
     if (!$options || $options instanceof Exception) {
         $options = array();
     } else {
         usort($options, array($this, '_sortLanguages'));
     }
     // Set the default value from the native language.
     $this->value = $native;
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
 /**
  * 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.
     $filter = (string) $this->element['filter'];
     $exclude = (string) $this->element['exclude'];
     $hideNone = (string) $this->element['hide_none'];
     $hideDefault = (string) $this->element['hide_default'];
     // Get the path in which to search for file options.
     $path = JPATH_ROOT . '/components/com_joomleague/extensions';
     if (!is_dir($path)) {
         $path = JPATH_ROOT . '/' . $path;
     }
     // Get a list of folders in the search path with the given filter.
     $folders = JFolder::folders($path, $filter);
     // Build the options list from the list of folders.
     if (is_array($folders)) {
         foreach ($folders as $folder) {
             // Check to see if the file is in the exclude mask.
             if ($exclude) {
                 if (preg_match(chr(1) . $exclude . chr(1), $folder)) {
                     continue;
                 }
             }
             $options[] = JHtml::_('select.option', $folder, $folder);
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Ejemplo n.º 19
0
	/**
	 * Method to get a list of options for a list input.
	 *
	 * @return  array  An array of JHtml options.
	 */
	protected function getOptions()
	{
		$db    = JFactory::getDBO();
		$query = $db->getQuery(true);
		$query->select('#__helloworld.id as id,greeting,#__categories.title as category,catid');
		$query->from('#__helloworld');
		$query->leftJoin('#__categories on catid=#__categories.id');
		// Retrieve only published items
		$query->where('#__helloworld.published = 1');
		$db->setQuery((string) $query);
		$messages = $db->loadObjectList();
		$options  = array();

		if ($messages)
		{
			foreach ($messages as $message)
			{
				$options[] = JHtml::_('select.option', $message->id, $message->greeting .
				                      ($message->catid ? ' (' . $message->category . ')' : ''));
			}
		}

		$options = array_merge(parent::getOptions(), $options);

		return $options;
	}
Ejemplo n.º 20
0
 /**
  * Method to get a list of options for a list input.
  *
  * @return array An array of JHtml options.
  */
 protected function getOptions()
 {
     $current_category_id = JRequest::getInt('id', '0');
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select('`id`, `categoryname`, `parentid`');
     $query->from('#__youtubegallery_categories');
     $db->setQuery((string) $query);
     $messages = $db->loadObjectList();
     if (!$db->query()) {
         die($db->stderr());
     }
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('COM_YOUTUBEGALLERY_SELECT_CATEGORYROOT'));
     $children = $this->getAllChildren($current_category_id);
     if ($messages) {
         foreach ($messages as $message) {
             if ($current_category_id == 0) {
                 $options[] = JHtml::_('select.option', $message->id, $message->categoryname);
             } else {
                 if ($message->id != $current_category_id and $message->parentid != $current_category_id and !in_array($message->id, $children)) {
                     $options[] = JHtml::_('select.option', $message->id, $message->categoryname);
                 }
             }
         }
     }
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Ejemplo n.º 21
0
    protected function getOptions()
    {
        $options = array();
        if (!class_exists('tsmartModelVendor')) {
            require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
        }
        $vendor_id = tsmartModelVendor::getLoggedVendor();
        // set currency_id to logged vendor
        if (empty($this->value)) {
            $currency = tsmartModelVendor::getVendorCurrency($vendor_id);
            $this->value = $currency->tsmart_currency_id;
        }
        // why not logged vendor? shared is missing
        $db = JFactory::getDBO();
        $query = 'SELECT `tsmart_currency_id` AS value, `currency_name` AS text
			FROM `#__tsmart_currencies`
			WHERE `tsmart_vendor_id` = "1"  AND `published` = "1" ORDER BY `currency_name` ASC ';
        // default value should be vendor currency
        $db->setQuery($query);
        $values = $db->loadObjectList();
        foreach ($values as $v) {
            $options[] = JHtml::_('select.option', $v->value, $v->text);
        }
        // Merge any additional options in the XML definition.
        $options = array_merge(parent::getOptions(), $options);
        return $options;
    }
Ejemplo n.º 22
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));
     // Set the default value active language
     if ($langParams = JComponentHelper::getParams('com_languages')) {
         switch ((string) $this->value) {
             case 'site':
             case 'frontend':
             case '0':
                 $this->value = $langParams->get('site', 'en-GB');
                 break;
             case 'admin':
             case 'administrator':
             case 'backend':
             case '1':
                 $this->value = $langParams->get('administrator', 'en-GB');
                 break;
             case 'active':
             case 'auto':
                 $lang = JFactory::getLanguage();
                 $this->value = $lang->getTag();
                 break;
             default:
                 break;
         }
     }
     return $options;
 }
Ejemplo n.º 23
0
 /**
  * Method to get a list of content types
  *
  * @return  array  The field option objects.
  *
  * @since   3.1
  */
 protected function getOptions()
 {
     $lang = JFactory::getLanguage();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('a.type_id AS value, a.type_title AS text, a.type_alias AS alias')->from('#__content_types AS a')->order('a.type_title ASC');
     // Get the options.
     $db->setQuery($query);
     try {
         $options = $db->loadObjectList();
     } catch (RuntimeException $e) {
         return false;
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     foreach ($options as $option) {
         // Make up the string from the component sys.ini file
         $parts = explode('.', $option->alias);
         $comp = array_shift($parts);
         // Make sure the component sys.ini is loaded
         $lang->load($comp . '.sys', JPATH_ADMINISTRATOR, null, false, true) || $lang->load($comp . '.sys', JPATH_ADMINISTRATOR . '/components/' . $comp, null, false, true);
         $option->string = implode('_', $parts);
         $option->string = $comp . '_CONTENT_TYPE_' . $option->string;
         if ($lang->hasKey($option->string)) {
             $option->text = JText::_($option->string);
         }
     }
     return $options;
 }
Ejemplo n.º 24
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  *
  * @since   1.6
  */
 public function getOptions()
 {
     $app = JFactory::getApplication();
     $clientId = $app->getUserStateFromRequest('com_templates.styles.filter.client_id', 'filter_client_id', null);
     $options = TemplatesHelper::getTemplateOptions($clientId);
     return array_merge(parent::getOptions(), $options);
 }
Ejemplo n.º 25
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[] = JHtml::_('select.option', $i);
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
    /**
     * Override to add new button
     *
     * @return  string  The field input markup.
     *
     * @since   3.2
     */
    protected function getInput()
    {
        // see if we should add buttons
        $setButton = $this->getAttribute('button');
        // get html
        $html = parent::getInput();
        // if true set button
        if ($setButton === 'true') {
            $button = array();
            $script = array();
            $buttonName = $this->getAttribute('name');
            // get the input from url
            $jinput = JFactory::getApplication()->input;
            // get the view name & id
            $values = $jinput->getArray(array('id' => 'int', 'view' => 'word'));
            // check if new item
            $ref = '';
            $refJ = '';
            if (!is_null($values['id']) && strlen($values['view'])) {
                // only load referal if not new item.
                $ref = '&amp;ref=' . $values['view'] . '&amp;refid=' . $values['id'];
                $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
            }
            $user = JFactory::getUser();
            // only add if user allowed to create intervention
            if ($user->authorise('intervention.create', 'com_costbenefitprojection')) {
                // build Create button
                $buttonNamee = trim($buttonName);
                $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
                $buttonNamee = preg_replace('/\\s+/', ' ', $buttonNamee);
                $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
                $buttonNamee = ucfirst(strtolower($buttonNamee));
                $button[] = '<a id="' . $buttonName . 'Create" class="btn btn-small btn-success hasTooltip" title="' . JText::sprintf('COM_COSTBENEFITPROJECTION_CREATE_NEW_S', $buttonNamee) . '" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
					href="index.php?option=com_costbenefitprojection&amp;view=intervention&amp;layout=edit' . $ref . '" >
					<span class="icon-new icon-white"></span></a>';
            }
            // only add if user allowed to edit intervention
            if (($buttonName == 'intervention' || $buttonName == 'interventions') && $user->authorise('intervention.edit', 'com_costbenefitprojection')) {
                // build edit button
                $buttonNamee = trim($buttonName);
                $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
                $buttonNamee = preg_replace('/\\s+/', ' ', $buttonNamee);
                $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
                $buttonNamee = ucfirst(strtolower($buttonNamee));
                $button[] = '<a id="' . $buttonName . 'Edit" class="btn btn-small hasTooltip" title="' . JText::sprintf('COM_COSTBENEFITPROJECTION_EDIT_S', $buttonNamee) . '" style="display: none; padding: 4px 4px 4px 7px;" href="#" >
					<span class="icon-edit"></span></a>';
                // build script
                $script[] = "\n\t\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\tjQuery('#adminForm').on('change', '#jform_" . $buttonName . "',function (e) {\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\tvar " . $buttonName . "Value = jQuery('#jform_" . $buttonName . "').val();\n\t\t\t\t\t\t\t" . $buttonName . "Button(" . $buttonName . "Value);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tvar " . $buttonName . "Value = jQuery('#jform_" . $buttonName . "').val();\n\t\t\t\t\t\t" . $buttonName . "Button(" . $buttonName . "Value);\n\t\t\t\t\t});\n\t\t\t\t\tfunction " . $buttonName . "Button(value) {\n\t\t\t\t\t\tif (value > 0) {\n\t\t\t\t\t\t\t// hide the create button\n\t\t\t\t\t\t\tjQuery('#" . $buttonName . "Create').hide();\n\t\t\t\t\t\t\t// show edit button\n\t\t\t\t\t\t\tjQuery('#" . $buttonName . "Edit').show();\n\t\t\t\t\t\t\tvar url = 'index.php?option=com_costbenefitprojection&view=interventions&task=intervention.edit&id='+value+'" . $refJ . "';\n\t\t\t\t\t\t\tjQuery('#" . $buttonName . "Edit').attr('href', url);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// show the create button\n\t\t\t\t\t\t\tjQuery('#" . $buttonName . "Create').show();\n\t\t\t\t\t\t\t// hide edit button\n\t\t\t\t\t\t\tjQuery('#" . $buttonName . "Edit').hide();\n\t\t\t\t\t\t}\n\t\t\t\t\t}";
            }
            // check if button was created for intervention field.
            if (is_array($button) && count($button) > 0) {
                // Load the needed script.
                $document = JFactory::getDocument();
                $document->addScriptDeclaration(implode(' ', $script));
                // return the button attached to input field.
                return '<div class="input-append">' . $html . implode('', $button) . '</div>';
            }
        }
        return $html;
    }
Ejemplo n.º 27
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     $options = array();
     $options[] = JHtml::_('select.option', 'id', JText::_('COM_VISFORMS_ID'), 'value', 'text', false);
     $options[] = JHtml::_('select.option', 'created', JText::_('COM_VISFORMS_SUBMISSIONDATE'), 'value', 'text', false);
     $options[] = JHtml::_('select.option', 'ismfd', JText::_('COM_VISFORMS_MODIFIED'), 'value', 'text', false);
     $id = 0;
     //extract form id
     $form = $this->form;
     $link = $form->getValue('link');
     if (isset($link) && $link != "") {
         $parts = array();
         parse_str($link, $parts);
         if (isset($parts['id']) && is_numeric($parts['id'])) {
             $id = $parts['id'];
         }
     }
     // Create options according to visfield settings
     $db = JFactory::getDbo();
     $query = ' SELECT c.id , c.label from #__visfields as c where c.fid=' . $id . ' AND c.published = 1 AND (c.frontdisplay is null or c.frontdisplay = 1 or c.frontdisplay = 2) ' . "and !(c.typefield = 'reset') and !(c.typefield = 'submit') and !(c.typefield = 'image') and !(c.typefield = 'fieldsep') and !(c.typefield = 'hidden')";
     $db->setQuery($query);
     $fields = $db->loadObjectList();
     if ($fields) {
         foreach ($fields as $field) {
             $tmp = JHtml::_('select.option', $field->id, $field->label, 'value', 'text', false);
             // Add the option object to the result set.
             $options[] = $tmp;
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Ejemplo n.º 28
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
  */
 protected function getInput()
 {
     $document = JFactory::getDocument();
     $jsPath = JURI::root(true) . '/modules/mod_currentdatetime/js';
     $joomlaVersion = new JVersion();
     if ($joomlaVersion->isCompatible('3')) {
         JHtml::_('jquery.ui', array('core', 'sortable'));
     } else {
         $document->addStyleSheet($jsPath . '/25/css/chosen.min.css');
         $document->addScript($jsPath . '/25/jquery.min.js');
         $document->addScript($jsPath . '/25/jquery-noconflict.js');
         $document->addScript($jsPath . '/25/chosen.jquery.min.js');
         $document->addScript($jsPath . '/25/jquery.ui.core.min.js');
         $document->addScript($jsPath . '/25/jquery.ui.widget.min.js');
         $document->addScript($jsPath . '/25/jquery.ui.mouse.min.js');
         $document->addScript($jsPath . '/25/jquery.ui.sortable.min.js');
     }
     $document->addScript($jsPath . '/jquery-chosen-sortable.min.js');
     $script = 'jQuery(function(){jQuery(".chzn-sortable").chosen().chosenSortable();});';
     $document->addScriptDeclaration($script);
     if (!is_array($this->value)) {
         $this->value = explode(',', $this->value);
     }
     $html = parent::getInput();
     return $html;
 }
Ejemplo n.º 29
0
 /**
 * Method to get the field options.
 *
 * @return	array	The field option objects.
 * @since	1.6
 */
 protected function getOptions()
 {
     // Get the database object and a new query object.
     $path = str_replace('administrator', '', JPATH_BASE);
     $path = $path . 'components' . DS . 'com_awdwall' . DS . 'images' . DS;
     $ldirs = listdirs($path);
     //print_r($ldirs);
     foreach ($ldirs as $ldir) {
         $folders[] = str_replace($path . '/', '', $ldir);
     }
     $dir = str_replace('administrator', '', JPATH_BASE);
     $dir = $dir . 'components' . DS . 'com_awdwall' . DS . 'css';
     $needle = 'style_';
     $length = strlen($needle);
     $dh = opendir($dir);
     while (false !== ($filename = readdir($dh))) {
         if ($filename != "." && $filename != "..") {
             if (substr($filename, 0, $length) === $needle) {
                 $order = '';
                 $newstr = '';
                 $order = array("style_", ".css");
                 $replace = '';
                 $newstr = str_replace($order, $replace, $filename);
                 if (in_array($newstr, $folders)) {
                     $files[] = $newstr;
                     $options[] = array('value' => $newstr, 'text' => $newstr);
                 }
             }
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Ejemplo n.º 30
-3
 /**
  * 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 = ' . $db->q($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 = JText::_($item->text);
         }
         if ($db->getErrorMsg()) {
             JError::raiseWarning(500, JText::_('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY'));
             return '';
         }
     } else {
         JError::raiseWarning(500, JText::_('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY'));
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }