/** * 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); } }
public function getItem($pk = null) { $input = JFactory::getApplication()->input; $id = $input->getInt('id'); if (!$id) { return false; } $adapter = JalangHelper::getHelperContent(); if (!$adapter) { return false; } $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('*')->from('#__' . $adapter->table)->where($db->quoteName($adapter->primarykey) . '=' . $id); $db->setQuery($query); $row = $db->loadObject(); //get reference value if (count($adapter->reference_fields)) { foreach ($adapter->reference_fields as $field => $table) { $adapter2 = JalangHelperContent::getInstance($table); if ($adapter2) { $query = $db->getQuery(true); $query->select('*')->from('#__' . $adapter2->table)->where($db->quoteName($adapter2->primarykey) . '=' . $row->{$field}); $db->setQuery($query); $row2 = $db->loadObject(); if ($row2) { $row->{$field . '_ref'} = $row2->{$adapter2->title_field}; } } } } return $row; }
public function __construct($config = array()) { $this->table_type = 'alias'; $this->table = 'menu_types'; $this->alias_field = 'menutype'; $this->edit_context = 'com_menus.edit.menu'; $this->associate_context = 'menu_types.item'; $this->translate_filters = array("`menutype` <> 'default-all'"); $this->translate_fields = array('title', 'description'); parent::__construct($config); }
public function __construct($config = array()) { $this->table = 'newsfeeds'; $this->edit_context = 'com_newsfeeds.edit.newsfeed'; $this->associate_context = 'com_newsfeeds.item'; $this->alias_field = 'alias'; $this->translate_fields = array('name', 'metakey', 'metadesc'); $this->reference_fields = array('catid' => 'categories'); $this->title_field = 'name'; $this->fixed_fields = array(); parent::__construct($config); }
public function __construct($config = array()) { $this->table = 'weblinks'; $this->edit_context = 'com_weblinks.edit.weblink'; $this->associate_context = 'com_weblinks.item'; $this->alias_field = 'alias'; $this->translate_fields = array('title', 'description', 'metakey', 'metadesc'); $this->reference_fields = array('catid' => 'categories'); $this->title_field = 'title'; $this->fixed_fields = array(); parent::__construct($config); }
public function __construct($config = array()) { $this->table = 'banners'; $this->edit_context = 'com_banners.edit.banner'; $this->associate_context = 'com_banners.item'; $this->alias_field = 'alias'; $this->translate_fields = array('name', 'description'); $this->reference_fields = array('catid' => 'categories'); $this->title_field = 'name'; $this->fixed_fields = array(); parent::__construct($config); }
public function __construct($config = array()) { $this->table = 'contact_details'; $this->edit_context = 'com_contact.edit.contact'; $this->associate_context = 'com_contact.item'; $this->alias_field = 'alias'; $this->translate_fields = array('name', 'con_position', 'address', 'suburb', 'state', 'country', 'misc', 'metakey', 'metadesc'); $this->reference_fields = array('catid' => 'categories'); $this->title_field = 'name'; $this->fixed_fields = array(); parent::__construct($config); }
public function __construct($config = array()) { $this->table = 'categories'; $this->edit_context = 'com_categories.edit.category'; $this->associate_context = 'com_categories.item'; $this->alias_field = 'alias'; $this->translate_fields = array('title', 'description', 'metakey', 'metadesc'); $this->translate_filters = array('`id` <> 1'); $this->fixed_fields = array('asset_id' => 0, 'version' => 1); $this->nested_field = 'parent_id'; $this->nested_value = 1; parent::__construct($config); }
public function __construct($config = array()) { $this->table_type = 'table'; $this->table = 'virtuemart_vendors'; $this->primarykey = 'virtuemart_vendor_id'; $this->edit_context = 'virtuemart.edit.category'; $this->associate_context = 'virtuemart.category'; $this->translate_fields = array('vendor_store_desc', 'vendor_terms_of_service', 'vendor_legal_info', 'vendor_store_name', 'metakey', 'metadesc'); $this->translate_filters = array(); $this->alias_field = ''; $this->title_field = 'vendor_store_name'; parent::__construct($config); }
public function __construct($config = array()) { $this->table_type = 'table'; $this->table = 'virtuemart_shipmentmethods'; $this->primarykey = 'virtuemart_shipmentmethod_id'; $this->edit_context = 'virtuemart.edit.category'; $this->associate_context = 'virtuemart.category'; $this->translate_fields = array('shipment_name', 'shipment_desc'); $this->translate_filters = array(); $this->alias_field = ''; $this->title_field = 'shipment_name'; parent::__construct($config); }
public function __construct($config = array()) { $this->table_type = 'table'; $this->table = 'virtuemart_manufacturercategories'; $this->primarykey = 'virtuemart_manufacturercategories_id'; $this->edit_context = 'virtuemart.edit.manufacturercategories'; $this->associate_context = 'virtuemart.manufacturercategories'; $this->translate_fields = array('mf_category_name', 'mf_category_desc'); $this->translate_filters = array(); $this->alias_field = ''; $this->title_field = 'mf_category_name'; parent::__construct($config); }
public function __construct($config = array()) { $this->table = 'easyblog_category'; $this->edit_context = 'com_easyblog.edit.category'; $this->associate_context = 'com_easyblog.category'; $this->translate_fields = array('title', 'description'); //$this->translate_filters = array('trash <> 1'); $this->alias_field = 'alias'; $this->nested_field = 'parent_id'; $this->nested_value = 0; $this->title_field = 'title'; parent::__construct($config); }
public function __construct($config = array()) { $this->table = 'k2_categories'; $this->edit_context = 'com_k2.edit.category'; $this->associate_context = 'com_k2.category'; $this->translate_fields = array('name', 'description'); $this->translate_filters = array('trash <> 1'); $this->alias_field = 'alias'; $this->nested_field = 'parent'; $this->nested_value = 0; $this->title_field = 'name'; parent::__construct($config); }
public function __construct($config = array()) { $this->table_type = 'table'; $this->table = 'virtuemart_products'; $this->primarykey = 'virtuemart_product_id'; $this->edit_context = 'virtuemart.edit.products'; $this->associate_context = 'virtuemart.products'; $this->translate_fields = array('product_s_desc', 'product_desc', 'product_name', 'metakey', 'metadesc'); $this->translate_filters = array(); $this->alias_field = ''; $this->title_field = 'product_name'; parent::__construct($config); }
public function __construct($config = array()) { $this->table_type = 'table_ml'; $this->language_field = 'language_id'; $this->language_mode = 'id'; $this->table = 'mijoshop_option_description'; $this->primarykey = 'option_id'; $this->edit_context = 'mijoshop.edit.option'; $this->associate_context = 'mijoshop.option'; $this->translate_fields = array('name'); $this->translate_filters = array(); $this->alias_field = ''; $this->title_field = 'name'; parent::__construct($config); }
/** * 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); }
public function afterSave(&$translator, $sourceid, &$row) { //Clone images? $clone = (int) $translator->params->get('k2_clone_image', 1); if ($clone) { $imgpath = JPATH_ROOT . '/media/k2/items/'; $srcfile = md5('Image' . $sourceid); $dstfile = md5('Image' . $row[$this->primarykey]); if (JFile::exists($imgpath . 'src/' . $srcfile . '.jpg') && !JFile::exists($imgpath . 'src/' . $dstfile . '.jpg')) { JFile::copy($imgpath . 'src/' . $srcfile . '.jpg', $imgpath . 'src/' . $dstfile . '.jpg'); JFile::copy($imgpath . 'cache/' . $srcfile . '_Generic.jpg', $imgpath . 'cache/' . $dstfile . '_Generic.jpg'); JFile::copy($imgpath . 'cache/' . $srcfile . '_L.jpg', $imgpath . 'cache/' . $dstfile . '_L.jpg'); JFile::copy($imgpath . 'cache/' . $srcfile . '_M.jpg', $imgpath . 'cache/' . $dstfile . '_M.jpg'); JFile::copy($imgpath . 'cache/' . $srcfile . '_S.jpg', $imgpath . 'cache/' . $dstfile . '_S.jpg'); JFile::copy($imgpath . 'cache/' . $srcfile . '_XL.jpg', $imgpath . 'cache/' . $dstfile . '_XL.jpg'); JFile::copy($imgpath . 'cache/' . $srcfile . '_XS.jpg', $imgpath . 'cache/' . $dstfile . '_XS.jpg'); } } // parent::afterSave($translator, $sourceid, $row); }
public static function getHelperContent() { $app = JFactory::getApplication(); $itemtype = $app->getUserState('com_jalang.itemtype', 'content'); return JalangHelperContent::getInstance($itemtype); }
public function afterSave(&$translator, $sourceid, &$row) { //clone tag $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('tag_id')->from('#__easyblog_post_tag')->where('post_id=' . $db->quote($sourceid)); $db->setQuery($query); $items = $db->loadObjectList(); if (count($items)) { $targetid = $row[$this->primarykey]; $date = JFactory::getDate()->toSql(); $query->clear(); $query->delete('#__easyblog_post_tag')->where('post_id=' . $db->quote($targetid)); $db->setQuery($query); $db->execute(); foreach ($items as $item) { $query->clear(); $query->insert('#__easyblog_post_tag')->columns('tag_id, post_id, created'); $query->values($db->quote($item->tag_id) . ',' . $db->quote($targetid) . ',' . $db->quote($date)); $db->setQuery($query); $db->execute(); } } //check & update featured entry $query->clear(); $query->select('id')->from('#__easyblog_featured')->where('type="post" AND content_id=' . $db->quote($sourceid)); $db->setQuery($query); $item = $db->loadResult(); if ($item) { $date = JFactory::getDate()->toSql(); $query->clear(); $query->insert('#__easyblog_featured')->columns('content_id, type, created'); $query->values($db->quote($row['id']) . ',"post",' . $db->quote($date)); $db->setQuery($query); $db->execute(); } // parent::afterSave($translator, $sourceid, $row); }
public function afterSave(&$translator, $sourceid, &$row) { //Update menu assignment $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('menuid')->from('#__modules_menu')->where('moduleid=' . $db->quote($sourceid)); $db->setQuery($query); $items = $db->loadObjectList(); if (count($items)) { $targetid = $row[$this->primarykey]; $query->clear(); $query->delete('#__modules_menu')->where('moduleid=' . $db->quote($targetid)); $db->setQuery($query); $db->execute(); foreach ($items as $item) { if ($item->menuid == 0) { //all $menuid = 0; } elseif ($item->menuid > 0) { //selected menu $menuid = $translator->getAssociatedItem('menu', $item->menuid, $item->menuid); } else { //all but exclude selected $oldmenuid = abs($item->menuid); $menuid = -$translator->getAssociatedItem('menu', $oldmenuid, $oldmenuid); } $query->clear(); $query->insert('#__modules_menu')->columns('moduleid, menuid'); $query->values($db->quote($targetid) . ',' . $db->quote($menuid)); $db->setQuery($query); $db->execute(); } } // parent::afterSave($translator, $sourceid, $row); }
public function getNewAlias($alias, $fromLangTag, $toLangTag, $row = null, $generateFrom = '', $makeUnique = false) { if (empty($generateFrom)) { if (is_array($row) && isset($row['type'])) { if ($row['type'] == 'alias' || $row['type'] == 'url') { //$generateFrom = 'alias'; $date = JFactory::getDate()->format('Y-m-d-H-i-s'); return parent::getNewAlias($date, $fromLangTag, $toLangTag, $row, $generateFrom, $makeUnique); } } } return parent::getNewAlias($alias, $fromLangTag, $toLangTag, $row, $generateFrom, $makeUnique); }
public function loadAssociate($table, $id = 'id', $context, $reload = false, $filter = array()) { $defaultLanguage = JalangHelper::getDefaultLanguage(); if ($this->fromLangTag == '*' && $this->convertLangTag) { $fromLangTag = $this->convertLangTag; } else { $fromLangTag = $this->fromLangTag; } $adapter = JalangHelperContent::getInstance($table); if ($adapter->table_type == 'table') { $this->createLangTable('#__' . $table, $fromLangTag); $this->createLangTable('#__' . $table, $this->toLangTag); } if (!isset($this->aAssociation[$table]) || $reload || $adapter->table_type == 'table') { if (!isset($this->aAssociation[$table])) { $this->aAssociation[$table] = array(); } $aMap =& $this->aAssociation[$table]; $db = JFactory::getDbo(); if ($adapter->table_type == 'table') { $from_table = $this->getLangTable('#__' . $table, $fromLangTag); $to_table = $this->getLangTable('#__' . $table, $this->toLangTag); $query = $db->getQuery(true); $query->select('st.' . $adapter->primarykey . ' AS sourceid, dt.' . $adapter->primarykey . ' AS newid'); $query->from($from_table . ' AS st'); $query->innerJoin($to_table . ' AS dt ON (st.' . $adapter->primarykey . ' = dt.' . $adapter->primarykey . ')'); if (count($filter)) { $query->where($filter); } $db->setQuery($query); $rows = $db->loadObjectList(); if (count($rows)) { foreach ($rows as $row) { if (!isset($aMap[$row->sourceid])) { $aMap[$row->sourceid] = array(); } $aMap[$row->sourceid][$fromLangTag] = $row->sourceid; $aMap[$row->sourceid][$this->toLangTag] = $row->newid; } } } elseif ($adapter->table_type == 'table_ml') { $query = $db->getQuery(true); // content association $langField = $db->quoteName($adapter->language_field); $query->select('a.' . $adapter->primarykey . " AS sourceid, GROUP_CONCAT(l.lang_code, ',', a.{$adapter->primarykey} SEPARATOR '|') AS `data`")->from('#__' . $adapter->table . ' AS a'); if ($adapter->language_mode == 'id') { $query->innerJoin('#__languages AS l ON l.lang_id = a.' . $adapter->language_field); } else { $query->innerJoin('#__languages AS l ON l.lang_code = a.' . $adapter->language_field); } $query->group('a.' . $adapter->primarykey); $db->setQuery($query); $rows = $db->loadObjectList(); if (count($rows)) { foreach ($rows as $row) { if (!$row->data) { continue; } $aMap[$row->sourceid] = array(); $data = explode('|', $row->data); $assoc = array(); foreach ($data as $d) { list($language, $contentid) = explode(',', $d); if ($language != $fromLangTag) { $aMap[$row->sourceid][$language] = $contentid; } } } } } elseif ($adapter->table_type == 'alias') { $query = $db->getQuery(true); $query->select('a.lang_code, a.title, a.title_native')->from('#__languages AS a'); $db->setQuery($query); $list = $db->loadObjectList(); $languages = array(); foreach ($list as $item) { $lang_code = preg_replace('/\\-.*/', '', $item->lang_code); $languages[$lang_code] = $item; } // $query = $db->getQuery(true); $query->select('*')->from('#__' . $adapter->table); if ($this->fromLangTag != '*') { $lang_code = preg_replace('/\\-.*/', '', $this->fromLangTag); if ($this->fromLangTag == $defaultLanguage) { $query->where('(' . $db->quoteName($adapter->alias_field) . ' LIKE ' . $db->quote('%-' . $lang_code) . ' OR ' . $db->quoteName($adapter->alias_field) . ' NOT REGEXP ' . $db->quote('-[a-z]{2}$') . ')'); } else { $query->where($db->quoteName($adapter->alias_field) . ' LIKE ' . $db->quote('%-' . $lang_code)); } } else { $query->where($db->quoteName($adapter->alias_field) . ' NOT REGEXP ' . $db->quote('-[a-z]{2}$')); } $db->setQuery($query); $rows = $db->loadObjectList(); if (count($rows)) { foreach ($rows as $row) { $sourceid = $row->{$adapter->primarykey}; if (!isset($aMap[$sourceid])) { $aMap[$sourceid] = array(); } $aMap[$sourceid][$this->fromLangTag] = $sourceid; $alias = $row->{$adapter->alias_field}; if ($this->fromLangTag != '*') { $lang_code = preg_replace('/\\-.*/', '', $this->fromLangTag); $alias = preg_replace('/\\-' . $lang_code . '$/', '', $alias); } $query = $db->getQuery(true); $query->select('*')->from('#__' . $adapter->table); $where = array(); $where[] = $db->quoteName($adapter->alias_field) . ' = ' . $db->quote($alias); $where[] = $db->quoteName($adapter->alias_field) . ' REGEXP ' . $db->quote($alias . '-[a-z]{2}$'); $query->where($where, 'OR'); $db->setQuery($query); $rows2 = $db->loadObjectList(); if (count($rows2)) { foreach ($rows2 as $row2) { if ($alias == $row2->{$adapter->alias_field}) { $aMap[$sourceid]['*'] = $row2->{$adapter->primarykey}; if (!isset($aMap[$sourceid][$defaultLanguage])) { $aMap[$sourceid][$defaultLanguage] = $row2->{$adapter->primarykey}; } } else { foreach ($languages as $lang_code => $item) { if ($alias . '-' . $lang_code == $row2->{$adapter->alias_field}) { $aMap[$sourceid][$item->lang_code] = $row2->{$adapter->primarykey}; } } } } } } } } else { //table_type = native $query = $db->getQuery(true); // content association $langField = $db->quoteName($adapter->language_field); $query->select("a.key, GROUP_CONCAT(c.{$langField}, ',', c.id SEPARATOR '|') AS `data`"); $query->from('#__associations AS a'); $query->innerJoin('#__' . $table . ' AS c ON (a.id=c.' . $id . ' AND a.context = ' . $db->quote($context) . ')'); $query->group('a.key'); $db->setQuery($query); $rows = $db->loadObjectList(); if (count($rows)) { foreach ($rows as $row) { if (!$row->data) { continue; } $data = explode('|', $row->data); $assoc = array(); foreach ($data as $d) { list($language, $contentid) = explode(',', $d); $assoc[$language] = $contentid; if ($language == '*' && !isset($assoc[$defaultLanguage])) { $assoc[$defaultLanguage] = $contentid; } } if (isset($assoc[$fromLangTag])) { $aMap[$assoc[$fromLangTag]] = $assoc; } } } } } //return @$this->aAssociation[$table]; }
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 static function loadAdapters() { if (!self::$scanned) { $path = dirname(__FILE__) . '/adapters/'; $adapters = JFolder::files($path, '\\.php$', false, true); foreach ($adapters as $adapter) { include_once $adapter; } self::$scanned = 1; } return self::$adapters; }
echo JText::_('WHICH_COMPONENT_WILL_BEING_MOVED_ITEMS'); ?> <a href="#" onclick="jQuery('#component-list').toggle(300);" title="<?php echo JText::_('JHIDE'); ?> "><?php echo JText::_('JHIDE'); ?> </a> <div id="component-list" style=""> <ol> <?php foreach ($this->adapters as $itemtype => $props) { ?> <?php $adapter = JalangHelperContent::getInstance($props['name']); if (!$adapter || $adapter->table_type != 'native') { continue; } ?> <li><?php echo $props['title']; ?> </li> <?php } ?> </ol> </div> </td> </tr>