Beispiel #1
0
 /**
  * Method to get the options to populate to populate list
  *
  * @return  array  The field option objects.
  *
  * @since   1.0
  */
 protected function getOptions()
 {
     // Accepted modifiers
     $hash = md5($this->element);
     if (!isset(static::$cache[$hash])) {
         static::$cache[$hash] = parent::getOptions();
         $options = array();
         $translationTables = RTranslationHelper::getInstalledTranslationTables();
         if (!empty($translationTables)) {
             foreach ($translationTables as $value) {
                 $options[] = JHtml::_('select.option', str_replace('#__', '', $value->table), $value->name);
             }
             static::$cache[$hash] = array_merge(static::$cache[$hash], $options);
         }
     }
     $contentElement = RedcoreHelpersTranslation::getCurrentContentElement();
     if (!empty($contentElement)) {
         $this->value = $contentElement;
     }
     return static::$cache[$hash];
 }
Beispiel #2
0
 /**
  * Gets translation table object
  *
  * @param   string  $default  Default Content Element Name
  *
  * @return  object  Translation Table object
  */
 public static function getTranslationTable($default = '')
 {
     $contentElement = self::getCurrentContentElement();
     $translationTables = RTranslationHelper::getInstalledTranslationTables();
     return !empty($translationTables['#__' . $contentElement]) ? $translationTables['#__' . $contentElement] : null;
 }
Beispiel #3
0
<?php

/**
 * @package     Redcore.Admin
 * @subpackage  Layouts
 *
 * @copyright   Copyright (C) 2008 - 2015 redCOMPONENT.com. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */
defined('_JEXEC') or die;
$option = JFactory::getApplication()->input->getString('component', '');
$view = RInflector::pluralize(JFactory::getApplication()->input->getString('view', ''));
$return = JFactory::getApplication()->input->getString('return', '');
$contentElement = JFactory::getApplication()->input->getString('contentelement', '');
$components = RedcoreHelpersView::getExtensionsRedcore();
$translationTables = RTranslationHelper::getInstalledTranslationTables();
if (empty($return)) {
    $return = base64_encode('index.php?option=com_redcore&view=dashboard');
}
?>
<ul class="nav nav-list">
	<?php 
if ($view === 'dashboards') {
    ?>
		<li class="nav-header"><?php 
    echo JText::_('COM_REDCORE_DASHBOARD');
    ?>
</li>
	<?php 
} else {
    ?>
Beispiel #4
0
 /**
  * Checks if this query is qualified for translation and parses query
  *
  * @param   string  $sql     SQL query
  * @param   string  $prefix  Table prefix
  *
  * @return  mixed  Parsed query with added table joins and fields if found
  */
 public static function buildTranslationQuery($sql = '', $prefix = '')
 {
     $db = JFactory::getDbo();
     $selectedLanguage = !empty($db->forceLanguageTranslation) ? $db->forceLanguageTranslation : JFactory::getLanguage()->getTag();
     if (!empty($db->parseTablesBefore)) {
         foreach ($db->parseTablesBefore as $tableGroup) {
             $sql = self::parseSelectQuery($sql, $prefix, $tableGroup->language, $tableGroup->translationTables);
         }
     }
     /**
      * Basic check for translations, translation will not be inserted if:
      * If we do not have SELECT anywhere in query
      * If current language is site default language
      * If we are in administration
      */
     if (empty($sql) || JFactory::getApplication()->isAdmin() || !stristr(mb_strtolower($sql), 'select') || RTranslationHelper::getSiteLanguage() == $selectedLanguage) {
         if (empty($db->parseTablesBefore) && empty($db->parseTablesAfter)) {
             return null;
         }
     }
     $translationTables = RTranslationHelper::getInstalledTranslationTables();
     $translationTables = RTranslationHelper::removeFromEditForm($translationTables);
     $sql = self::parseSelectQuery($sql, $prefix, $selectedLanguage, $translationTables);
     if (!empty($db->parseTablesAfter)) {
         foreach ($db->parseTablesAfter as $tableGroup) {
             $sql = self::parseSelectQuery($sql, $prefix, $tableGroup->language, $tableGroup->translationTables);
         }
     }
     return $sql;
 }
Beispiel #5
0
 /**
  * Loading of related XML files
  *
  * @param   string  $extensionName    Extension name
  * @param   array   $contentElements  Content elements
  *
  * @return  array  List of objects
  */
 public function loadMissingContentElements($extensionName, $contentElements = array())
 {
     $translationTables = RTranslationHelper::getInstalledTranslationTables();
     $missingTables = array();
     foreach ($translationTables as $translationTableKey => $translationTable) {
         $translationTable->table = str_replace('#__', '', $translationTable->table);
         if ($translationTable->option == $extensionName) {
             $foundTable = false;
             foreach ($contentElements as $contentElement) {
                 if (!empty($contentElement->table) && $contentElement->table == $translationTable->table) {
                     $foundTable = true;
                     break;
                 }
             }
             if (!$foundTable) {
                 $missingTables[$translationTableKey] = $translationTable;
             }
         }
     }
     return $missingTables;
 }
Beispiel #6
0
 /**
  * Uninstall all Translation tables from database
  *
  * @return  void
  */
 protected function uninstallTranslations()
 {
     $class = get_called_class();
     $extensionOption = strtolower(strstr($class, 'Installer', true));
     $translationTables = RTranslationHelper::getInstalledTranslationTables();
     if (!empty($translationTables)) {
         $db = JFactory::getDbo();
         foreach ($translationTables as $translationTable => $translationTableParams) {
             if (method_exists('RTranslationTable', 'getTranslationsTableName') && ($class == 'Com_RedcoreInstallerScript' || $extensionOption == $translationTableParams->option)) {
                 $newTable = RTranslationTable::getTranslationsTableName($translationTable, '');
                 try {
                     RTranslationTable::removeExistingConstraintKeys($translationTable);
                     $db->dropTable($newTable);
                 } catch (Exception $e) {
                     JFactory::getApplication()->enqueueMessage(JText::sprintf('LIB_REDCORE_TRANSLATIONS_DELETE_ERROR', $e->getMessage()), 'error');
                 }
             }
         }
     }
 }
Beispiel #7
0
 /**
  * Method to save the configuration data.
  *
  * @return  bool   True on success, false on failure.
  */
 public static function saveRedcoreTranslationConfig()
 {
     $data = array();
     $component = JComponentHelper::getComponent('com_redcore');
     $component->params->set('translations', RTranslationHelper::getInstalledTranslationTables());
     $data['params'] = $component->params->toString('JSON');
     $dispatcher = RFactory::getDispatcher();
     $table = JTable::getInstance('Extension');
     $isNew = true;
     // Load the previous Data
     if (!$table->load($component->id)) {
         return false;
     }
     // Bind the data.
     if (!$table->bind($data)) {
         return false;
     }
     // Check the data.
     if (!$table->check()) {
         return false;
     }
     // Trigger the onConfigurationBeforeSave event.
     $result = $dispatcher->trigger('onExtensionBeforeSave', array('com_redcore.config', &$table, $isNew));
     if (in_array(false, $result, true)) {
         return false;
     }
     // Store the data.
     if (!$table->store()) {
         return false;
     }
     // Trigger the onConfigurationAfterSave event.
     $dispatcher->trigger('onExtensionAfterSave', array('com_redcore.config', &$table, $isNew));
     return true;
 }