Beispiel #1
0
 /**
  * Method to get the field option groups.
  *
  * @return  array  The field option objects as a nested array in groups.
  *
  * @since   11.1
  * @throws  UnexpectedValueException
  */
 protected function getGroups()
 {
     $db = JFactory::getDbo();
     $groups = array("Components", "Tables");
     // Component relations
     $query = $db->getQuery(true)->select("a.relation")->from("#__jdeveloper_forms AS a")->where("a.relation LIKE 'component%'")->where("a.level = 1");
     $rows = $db->setQuery($query)->loadAssocList();
     $model = JModelLegacy::getInstance("Component", "JDeveloperModel");
     $group = JText::_("COM_JDEVELOPER_FORM_FILTER_GROUP_COMPONENTS");
     foreach ($rows as $row) {
         $id = explode(".", $row->relation)[1];
         $item = $model->getItem($id);
         $groups[$group][] = JHtml::_('select.option', $row->relation, ucfirst($item->name));
     }
     // Table relations
     $query = $db->getQuery(true)->select("a.relation")->from("#__jdeveloper_forms AS a")->where("a.relation LIKE 'table%'")->where("a.level = 1");
     $rows = $db->setQuery($query)->loadObjectList();
     $model = JModelLegacy::getInstance("Table", "JDeveloperModel");
     $group = JText::_("COM_JDEVELOPER_FORM_FILTER_GROUP_TABLES");
     foreach ($rows as $row) {
         $id = explode(".", $row->relation)[1];
         $item = $model->getItem($id);
         $groups[$group][] = JHtml::_('select.option', $row->relation, ucfirst($item->name));
     }
     return array_merge(parent::getGroups(), $groups);
 }
Beispiel #2
0
 /**
  * Method to get the field option groups.
  *
  * @return  array  The field option objects as a nested array in groups.
  *
  * @since   11.1
  * @throws  UnexpectedValueException
  */
 protected function getGroups()
 {
     jimport('joomla.filesystem.folder');
     $groups = array();
     $paths = array("Joomla" => JPATH_ROOT . "/libraries/joomla/form/fields", "Legacy" => JPATH_ROOT . "/libraries/legacy/form/field", "Cms" => JPATH_ROOT . "/libraries/cms/form/field");
     foreach ($paths as $groupname => $path) {
         $fields = JFolder::files($path, "\\.php");
         foreach ($fields as $field) {
             $field = str_replace(".php", "", $field);
             $groups[$groupname][] = JHtml::_('select.option', $field, ucfirst($field));
         }
     }
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select("a.id, a.name")->from("#__jdeveloper_formfields as a");
     $results = $db->setQuery($query)->loadObjectList();
     foreach ($results as $result) {
         $groups["JDeveloper"][] = JHtml::_('select.option', $result->name, ucfirst($result->name));
     }
     return array_merge(parent::getGroups(), $groups);
 }
 /**
  * Method to get the field option groups.
  *
  * @return  array  The field option objects as a nested array in groups.
  *
  * @since   11.1
  * @throws  UnexpectedValueException
  */
 protected function getGroups()
 {
     $db = JFactory::getDbo();
     $user = JFactory::getUser();
     $query = $db->getQuery(true);
     $query->select("a.id, a.name")->from("#__jdeveloper_tables as a");
     $query->select('c.name AS component, c.display_name AS component_name')->join('LEFT', '#__jdeveloper_components AS c ON c.id = a.component');
     if (!empty($this->component)) {
         $query->where('a.component = ' . $db->quote($this->component));
     }
     if (!empty($this->current_table)) {
         $query->where('a.id != ' . $db->quote($this->current_table));
     }
     if (!$user->authorise('core.admin', 'com_jdeveloper')) {
         $query->where('a.created_by = ' . $user->get('id'));
     }
     $results = $db->setQuery($query)->loadObjectList();
     $groups = array();
     foreach ($results as $result) {
         $groups[$result->component_name][] = JHtml::_('select.option', $result->id, $result->name);
     }
     return array_merge(parent::getGroups(), $groups);
 }