public static function getLanguageCodes()
 {
     static $langs;
     if (is_array($langs)) {
         return $langs;
     }
     $db = JFactory::getDBO();
     jimport('joomla.version');
     $version = new JVersion();
     if (version_compare($version->getShortVersion(), '1.6', '<')) {
         $langs = array();
         $client =& JApplicationHelper::getClientInfo(0);
         jimport('joomla.filesystem.folder');
         $path = JLanguage::getLanguagePath($client->path);
         $dirs = JFolder::folders($path);
         jimport('joomla.filesystem.folder');
         $path = JLanguage::getLanguagePath($client->path);
         $dirs = JFolder::folders($path);
         foreach ($dirs as $dir) {
             $files = JFolder::files($path . DS . $dir, '^([-_A-Za-z]*)\\.xml$');
             foreach ($files as $file) {
                 $data = JApplicationHelper::parseXMLLangMetaFile($path . DS . $dir . DS . $file);
                 $language = substr($file, 0, -4);
                 if (!is_array($data)) {
                     continue;
                 }
                 // if current than set published
                 $params = JComponentHelper::getParams('com_languages');
                 //if ( $params->get($client->name, 'en-GB') == $language) {
                 $langs[] = $language;
                 //}
             }
         }
         return $langs;
     } else {
         $db->setQuery("Select lang_code From #__languages Where published = 1 Order By ordering");
         $langs = CBCompat::loadColumn();
         return $langs;
     }
 }
示例#2
0
 function delete()
 {
     jimport('joomla.database.table');
     jimport('joomla.event.dispatcher');
     jimport('joomla.version');
     $is15 = true;
     $version = new JVersion();
     if (version_compare($version->getShortVersion(), '1.6', '>=')) {
         $is15 = false;
     }
     $cids = JRequest::getVar('cid', array(0), 'post', 'array');
     JArrayHelper::toInteger($cids);
     $row = $this->getTable();
     foreach ($cids as $cid) {
         $this->_db->setQuery("Select article.article_id From #__contentbuilder_articles As article, #__contentbuilder_forms As form Where form.delete_articles > 0 And form.id = article.form_id And article.form_id = " . intval($cid));
         $articles = CBCompat::loadColumn();
         if (count($articles)) {
             $article_items = array();
             foreach ($articles as $article) {
                 $article_items[] = $this->_db->Quote('com_content.article.' . $article);
                 $dispatcher = JDispatcher::getInstance();
                 $table = JTable::getInstance('content');
                 // Trigger the onContentBeforeDelete event.
                 if (!$is15 && $table->load($article)) {
                     $dispatcher->trigger('onContentBeforeDelete', array('com_content.article', $table));
                 }
                 $this->_db->setQuery("Delete From #__content Where id = " . intval($article));
                 $this->_db->query();
                 // Trigger the onContentAfterDelete event.
                 $table->reset();
                 if (!$is15) {
                     $dispatcher->trigger('onContentAfterDelete', array('com_content.article', $table));
                 }
             }
             $this->_db->setQuery("Delete From #__assets Where `name` In (" . implode(',', $article_items) . ")");
             $this->_db->query();
         }
         $this->_db->setQuery("\n                Delete\n                    `elements`.*\n                From\n                    #__contentbuilder_elements As `elements`\n                Where\n                    `elements`.form_id = " . $cid);
         $this->_db->query();
         $this->_db->setQuery("\n                Delete\n                    `states`.*\n                From\n                    #__contentbuilder_list_states As `states`\n                Where\n                    `states`.form_id = " . $cid);
         $this->_db->query();
         $this->_db->setQuery("\n                Delete\n                    `records`.*\n                From\n                    #__contentbuilder_list_records As `records`\n                Where\n                    `records`.form_id = " . $cid);
         $this->_db->query();
         $this->_db->setQuery("\n                Delete\n                    `access`.*\n                From\n                    #__contentbuilder_resource_access As `access`\n                Where\n                    `access`.form_id = " . $cid);
         $this->_db->query();
         $this->_db->setQuery("\n                Delete\n                    `users`.*\n                From\n                    #__contentbuilder_users As `users`\n                Where\n                    `users`.form_id = " . $cid);
         $this->_db->query();
         $this->_db->setQuery("\n                Delete\n                    `users`.*\n                From\n                    #__contentbuilder_registered_users As `users`\n                Where\n                    `users`.form_id = " . $cid);
         $this->_db->query();
         $this->getTable('elements')->reorder('form_id = ' . $cid);
         jimport('joomla.version');
         $version = new JVersion();
         if (version_compare($version->getShortVersion(), '1.6', '<')) {
             $this->_db->setQuery("Delete From #__components Where admin_menu_link = 'option=com_contentbuilder&controller=list&id=" . intval($cid) . "'");
             $this->_db->query();
             $this->_db->setQuery("Select count(id) From #__components Where admin_menu_link Like 'option=com_contentbuilder&controller=list&id=%'");
             $amount = $this->_db->loadResult();
             if (!$amount) {
                 $this->_db->setQuery("Delete From #__components Where admin_menu_link = 'option=com_contentbuilder&viewcontainer=true'");
                 $this->_db->query();
             }
         } else {
             $this->_db->setQuery("Delete From #__menu Where `link` = 'index.php?option=com_contentbuilder&controller=list&id=" . intval($cid) . "'");
             $this->_db->query();
             $this->_db->setQuery("Select count(id) From #__menu Where `link` Like 'index.php?option=com_contentbuilder&controller=list&id=%'");
             $amount = $this->_db->loadResult();
             if (!$amount) {
                 $this->_db->setQuery("Delete From #__menu Where `link` = 'index.php?option=com_contentbuilder&viewcontainer=true'");
                 $this->_db->query();
             }
         }
         if (!$row->delete($cid)) {
             $this->setError($row->getErrorMsg());
             return false;
         }
     }
     $row->reorder();
     /*
             $this->_db->setQuery("Select `reference_id` From #__contentbuilder_forms");
             $references = $this->_db->loadResultArray();
     
             $cnt = count($references);
             if ($cnt) {
                 $new_items = array();
                 for ($i = 0; $i < $cnt; $i++) {
                     $new_items[] = $this->_db->Quote($references[$i]);
                 }
                 $this->_db->setQuery("Delete From #__contentbuilder_records Where `reference_id` Not In (" . implode(',',$new_items) . ") ");
                 $this->_db->query();
             }else{
                 $this->_db->setQuery("Delete From #__contentbuilder_records");
                 $this->_db->query();
             }*/
     // article deletion if required
     $this->_db->setQuery("Select `id` From #__contentbuilder_forms");
     jimport('joomla.version');
     $version = new JVersion();
     if (version_compare($version->getShortVersion(), '3.0', '>=')) {
         $references = $this->_db->loadColumn();
     } else {
         $references = $this->_db->loadResultArray();
     }
     $cnt = count($references);
     if ($cnt) {
         $new_items = array();
         for ($i = 0; $i < $cnt; $i++) {
             $new_items[] = $this->_db->Quote($references[$i]);
         }
         $this->_db->setQuery("Delete From #__contentbuilder_articles Where `form_id` Not In (" . implode(',', $new_items) . ") ");
         $this->_db->query();
     } else {
         $this->_db->setQuery("Delete From #__contentbuilder_articles");
         $this->_db->query();
     }
     return true;
 }