Beispiel #1
0
 /**
  * Add the page title and toolbar.
  *
  * @since   1.6
  */
 protected function addToolbar()
 {
     $user = JFactory::getUser();
     // Get the toolbar object instance
     $bar = JToolBar::getInstance('toolbar');
     JToolbarHelper::title(JText::_('TRANSLATION_MANAGER'), 'article.png');
     JToolbarHelper::preferences('com_jalang');
     if (JalangHelper::isJoomla3x()) {
         JHtmlSidebar::setAction('index.php?option=com_jalang&view=items');
     }
     $app = JFactory::getApplication();
     $itemtype = $app->getUserState('com_jalang.itemtype', 'content');
     $adapters = JalangHelperContent::getListAdapters();
     $options = array();
     $types = array();
     foreach ($adapters as $props) {
         $types[$props['name']] = $props['title'];
     }
     //Sort by Alphabet
     ksort($types);
     foreach ($types as $name => $title) {
         $options[] = JHtml::_('select.option', $name, $title);
     }
     $mainlanguage = $app->getUserState('com_jalang.mainlanguage', '*');
     if (JalangHelper::isJoomla3x()) {
         JHtmlSidebar::addFilter(JText::_('SELECT_ITEM_TYPE'), 'itemtype', JHtml::_('select.options', $options, 'value', 'text', $itemtype));
         JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_LANGUAGE'), 'mainlanguage', JHtml::_('select.options', JHtml::_('contentlanguage.existing', true, true), 'value', 'text', $mainlanguage));
     } else {
         $this->filterByItemtype = JHtml::_('select.options', $options, 'value', 'text', $itemtype);
         $this->filterByLanguage = JHtml::_('select.options', JHtml::_('contentlanguage.existing', true, true), 'value', 'text', $mainlanguage);
     }
 }
Beispiel #2
0
 /**
  * Display the view
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     JalangHelper::addSubmenu('tool', $this->getLayout());
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->addToolbar();
     if (JalangHelper::isJoomla3x()) {
         $this->sidebar = JHtmlSidebar::render();
     }
     //
     $this->adapters = JalangHelperContent::getListAdapters();
     parent::display($tpl);
 }
Beispiel #3
0
 public final function removeLanguage($languageTag)
 {
     if (!$languageTag || $languageTag == '*') {
         $this->sendOutput(JText::_('SOURCE_LANGUAGE_IS_NOT_SPECIFIED_OR_NOT_SUPPORTED'));
         return false;
     }
     if ($languageTag == JalangHelper::getDefaultLanguage()) {
         $this->sendOutput(JText::_('ALERT_CANNOT_REMOVE_DEFAULT_LANGUAGE'));
         return false;
     }
     $langId = JalangHelper::getLanguageIdFromCode($languageTag);
     $parts = explode('-', $languageTag);
     $langCode = strtolower(trim($parts[0]));
     $adapters = JalangHelperContent::getListAdapters();
     $db = JFactory::getDbo();
     foreach ($adapters as $adapter) {
         $component = $adapter['title'];
         $adapter = JalangHelperContent::getInstance($adapter['name']);
         $table = '#__' . $adapter->table;
         $this->sendOutput('<h3>' . JText::sprintf('START_TO_REMOVE_ITEM_FROM_THE_COMPONENT', $component) . '</h3>');
         if ($adapter->table_type == 'native' || $adapter->table_type == 'table_ml') {
             if (!$adapter->language_field) {
                 continue;
             }
             if ($adapter->language_mode == 'id') {
                 $where = $db->quoteName($adapter->language_field) . '=' . $db->quote($langId);
             } else {
                 $where = $db->quoteName($adapter->language_field) . '=' . $db->quote($languageTag);
             }
             if ($adapter->table_type == 'native') {
                 //delete association data
                 $query = "DELETE FROM #__associations\r\n\t\t\t\t\t\tWHERE id IN (\r\n\t\t\t\t\t\t\tSELECT " . $db->quote($adapter->primarykey) . "\r\n\t\t\t\t\t\t\tFROM " . $table . "\r\n\t\t\t\t\t\t\tWHERE `context` = " . $db->quote($adapter->associate_context) . "\r\n\t\t\t\t\t\t\tAND " . $where . "\r\n\t\t\t\t\t\t)";
                 $db->setQuery($query);
                 $db->execute();
             }
             //delete items
             $query = $db->getQuery(true);
             $query->delete($table);
             $query->where($where);
             $db->setQuery($query);
             $db->execute();
             $num_items = $db->getAffectedRows();
             $this->sendOutput(JText::sprintf('NUM_ITEMS_ARE_REMOVED', $num_items) . '<br />');
         } elseif ($adapter->table_type == 'alias') {
             $query = $db->getQuery(true);
             $query->delete($table);
             $query->where($db->quoteName($adapter->alias_field) . ' LIKE ' . $db->quote('%-' . $langCode));
             $db->setQuery($query);
             $db->execute();
             $num_items = $db->getAffectedRows();
             $this->sendOutput(JText::sprintf('NUM_ITEMS_ARE_REMOVED', $num_items) . '<br />');
         } elseif ($adapter->table_type == 'table') {
             $tableml = $this->getLangTable($table, $languageTag);
             $query = "DROP TABLE " . $db->quoteName($tableml);
             $db->setQuery($query);
             $db->execute();
             $this->sendOutput(JText::sprintf('DROP_THE_LANGUAGE_TABLE', $tableml) . '<br />');
         }
     }
     //remove content language?
 }
 public final function translateAllTables($from, $to)
 {
     $adapters = JalangHelperContent::getListAdapters();
     foreach ($adapters as $adapter) {
         $this->translateTable($adapter['name'], $from, $to);
     }
     $this->updateTemplateStyles();
 }