/**
  * Show confirmation before moving anything
  *
  * @return void
  */
 public function show()
 {
     $input = JFactory::getApplication()->input;
     // Overwrite the view
     $input->set('view', 'moveelementconfirm');
     $groups = $input->get('groups', array(), 'array');
     $tables = $input->get('tables', array(), 'array');
     $files = $input->get('files', array(), 'files');
     // If a group is selected then load all the elements from that group
     if (!empty($groups)) {
         foreach ($groups as $groupId) {
             $group = NenoContentElementGroup::getGroup($groupId);
             // Handle tables
             $groupTables = $group->getTables();
             if (!empty($groupTables)) {
                 /* @var $groupTable NenoContentElementGroup */
                 foreach ($groupTables as $groupTable) {
                     // Add the table id to the tables array
                     $tables[] = $groupTable->getId();
                 }
             }
             // Handle files
             $groupFiles = $group->getLanguageFiles();
             if (!empty($groupFiles)) {
                 /* @var $groupFile NenoContentElementLanguageFile */
                 foreach ($groupFiles as $groupFile) {
                     // Add the file id to the files array
                     $files[] = $groupFile->getId();
                 }
             }
         }
     }
     // Remove duplicates
     array_unique($tables);
     array_unique($files);
     // Load table info
     if (!empty($tables)) {
         foreach ($tables as $key => $table) {
             $tables[$key] = NenoContentElementTable::load($table);
         }
     }
     // Load files info
     if (!empty($files)) {
         foreach ($files as $key => $file) {
             $files[$key] = NenoContentElementLanguageFile::load($file);
         }
     }
     // Show output
     // Get the view
     /* @var $view NenoViewMoveElementConfirm */
     $view = $this->getView('MoveElementConfirm', 'html');
     $view->groups = NenoHelper::convertNenoObjectListToJObjectList(NenoHelper::getGroups());
     // Assign data from the model
     $view->tables = NenoHelper::convertNenoObjectListToJObjectList($tables);
     $view->files = NenoHelper::convertNenoObjectListToJObjectList($files);
     // Display the view
     $view->display();
 }
Beispiel #2
0
 /**
  * Return all groups.
  *
  * @param   bool $loadExtraData       Load Extra data flag
  * @param   bool $avoidDoNotTranslate Don't return fields/keys marked as Don't translate
  *
  * @return  array
  */
 public static function getGroups($loadExtraData = true, $avoidDoNotTranslate = false)
 {
     $cacheId = NenoCache::getCacheId(__FUNCTION__, array(1));
     $cacheData = NenoCache::getCacheData($cacheId);
     if ($cacheData === null) {
         // Create a new query object.
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $subquery1 = $db->getQuery(true);
         $arrayWhere1 = array('t.group_id = g.id');
         if ($avoidDoNotTranslate) {
             $arrayWhere1[] = 't.translate = 1';
         }
         $subquery1->select('1')->from(' #__neno_content_element_tables AS t')->where($arrayWhere1);
         $subquery2 = $db->getQuery(true);
         $subquery2->select('1')->from('#__neno_content_element_language_files AS lf')->where('lf.group_id = g.id');
         $query->select('g.id')->from('`#__neno_content_element_groups` AS g')->where(array('EXISTS (' . (string) $subquery1 . ')', 'EXISTS (' . (string) $subquery2 . ')', '(NOT EXISTS (' . (string) $subquery1 . ') AND NOT EXISTS (' . (string) $subquery2 . ') AND NOT EXISTS(SELECT 1 FROM #__neno_content_element_groups_x_extensions AS ge WHERE g.id = ge.group_id))'), 'OR')->order(array('IFNULL((SELECT DISTINCT 1 FROM #__neno_content_element_groups_x_translation_methods AS gtm WHERE gtm.group_id = g.id) ,0)', 'group_name'));
         $db->setQuery($query);
         $groups = $db->loadObjectList();
         $countGroups = count($groups);
         for ($i = 0; $i < $countGroups; $i++) {
             $group = NenoContentElementGroup::getGroup($groups[$i]->id, $loadExtraData);
             $translationMethods = $group->getAssignedTranslationMethods();
             if ($avoidDoNotTranslate && empty($translationMethods)) {
                 unset($groups[$i]);
                 continue;
             }
             $groups[$i] = $group;
         }
         NenoCache::setCacheData($cacheId, $groups);
         $cacheData = $groups;
     }
     return $cacheData;
 }