Example #1
1
 /**
  * Check
  */
 public function check()
 {
     // check title
     if (trim($this->title) == '') {
         $this->setError(JText::_('COM_JKIT_TAG_ERROR_TITLE'));
         return false;
     }
     // / create alias from title, and make safe
     $this->alias = JApplication::stringURLSafe($this->title);
     if (trim(str_replace('-', '', $this->alias)) == '') {
         $this->setError(JText::_('COM_JKIT_TAG_ERROR_ALIAS'));
         return false;
     }
     // verify unique alias
     $table = JTable::getInstance('Tag', 'JKitTable', array('dbo' => $this->getDbo()));
     if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) {
         $this->setError(JText::_('COM_JKIT_TAG_ERROR_ALIAS'));
         return false;
     }
     // check translations titles and alias
     if ($this->language != '*') {
         $db = JFactory::getDbo();
         $langs = JKitHelperLangs::getLangs();
         foreach ($langs as $lang) {
             if ($this->language != $lang->lang_code) {
                 // check translation title
                 $t_title = trim(JRequest::getString('translation_title_' . $lang->lang_code));
                 if ($t_title == '') {
                     $this->setError(JText::sprintf('COM_JKIT_TAG_ERROR_TRANSLATION_TITLE', $lang->title));
                     return false;
                 }
                 // check translation alias
                 $t_alias = JApplication::stringURLSafe($t_title);
                 if (trim(str_replace('-', '', $t_alias)) == '') {
                     $this->setError(JText::sprintf('COM_JKIT_TAG_ERROR_TRANSLATION_ALIAS', $lang->title));
                     return false;
                 }
                 // check translation repeated alias
                 $q_l = $db->quote($lang->lang_code);
                 $q_a = $db->quote($t_alias);
                 $ref_id = $this->id ? " AND `ref_id` != {$this->id}" : '';
                 $q1 = "SELECT `ref_id` FROM `#__jkit_translations` WHERE `ref_table` = 'tags' AND `alias` = {$q_a} AND `lang` = {$q_l} {$ref_id}";
                 $t_ids1 = $db->setQuery($q1)->loadColumn();
                 if ($t_ids1) {
                     $this->setError(JText::sprintf('COM_JKIT_TAG_ERROR_TRANSLATION_ALIAS', $lang->title));
                     return false;
                 }
                 // check duplicated tags in different languages
                 $tid = $this->id ? " AND id != {$this->id}" : '';
                 $q2 = "SELECT `id` FROM `#__jkit_tags` WHERE `alias` = {$q_a} AND `language` = {$q_l} {$tid}";
                 $t_ids2 = $db->setQuery($q2)->loadColumn();
                 if ($t_ids2) {
                     $this->setError(JText::sprintf('COM_JKIT_TAG_ERROR_TRANSLATION_ALIAS', $lang->title));
                     return false;
                 }
             }
         }
     }
     return true;
 }
Example #2
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     // get the data
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->params = JComponentHelper::getParams('com_jkit');
     // lists
     $this->lists = new stdClass();
     $this->lists->langs = JKitHelperLangs::getLangs();
     $this->lists->translations = array();
     // get tag translations
     if (isset($this->item->id)) {
         $translations = JKitHelperLangs::getTranslations(array($this->item), 'tags');
         if (count($translations)) {
             foreach ($translations as $translation) {
                 $this->lists->translations[$translation->lang] = new stdClass();
                 $this->lists->translations[$translation->lang]->title = $translation->title;
                 $this->lists->translations[$translation->lang]->alias = $translation->alias;
             }
         }
     }
     // create the toolbar
     JKitHelper::getToolbar(false, $this->item->id, $this->item->title);
     // display the view template
     parent::display($tpl);
 }
Example #3
0
 /**
  * Get site languages
  */
 public function getLangs()
 {
     if (!isset($this->langs)) {
         $langs = JKitHelperLangs::getLangs();
         $this->langs['*'] = JText::_('COM_JKIT_PANEL_CATEGORIES');
         foreach ($langs as $lang) {
             $this->langs[$lang->lang_code] = $lang->title;
         }
     }
     return $this->langs;
 }
Example #4
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     // get the data from the model
     $this->item = $this->get('Item');
     $this->translation = $this->get('Translation');
     $this->language = JKitHelperLangs::getLangTitle(JRequest::getCmd('lang'));
     $this->params = JComponentHelper::getParams('com_jkit');
     // create the toolbar
     JKitHelper::getToolbar(false, true, $this->item->title . ' (' . JText::sprintf('COM_JKIT_TRANSLATION_TITLE', $this->language) . ')');
     // display the view template
     parent::display($tpl);
 }
Example #5
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     // get the data from the model
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     // filters
     $this->filterForm = $this->get('FilterForm');
     $this->activeFilters = $this->get('ActiveFilters');
     // lists
     $this->lists = new stdClass();
     $this->lists->langs = JKitHelperLangs::getLangs();
     $this->lists->translations = JKitHelperLangs::getTranslations($this->items, 'tags');
     // toolbar and sidbar
     JKitHelper::getToolbar(false, $this->state->get('filter.state') == -2);
     $this->sidebar = JHtmlSidebar::render();
     // display the view template
     parent::display($tpl);
 }
Example #6
0
 /**
  * Override save method to add tag translations
  */
 public function save($data)
 {
     // perform default save
     $save = parent::save($data);
     if (!$save) {
         return false;
     }
     // delete current translations
     $tag_id = $this->getState('tag.id');
     $this->_db->setQuery("DELETE FROM #__jkit_translations WHERE `ref_table` = 'tags' AND `ref_id` = {$tag_id}")->query();
     // get the language
     $table = $this->getTable();
     $table->load($tag_id);
     // store translations
     if ($table->language != '*') {
         // prepare data
         $langs = JKitHelperLangs::getLangs();
         $values = array();
         foreach ($langs as $lang) {
             // get translations preventing tag own language transaltion
             if (JRequest::getString('translation_title_' . $lang->lang_code) && $lang->lang_code != $table->language) {
                 $title = JRequest::getString('translation_title_' . $lang->lang_code);
                 $alias = JRequest::getString('translation_alias_' . $lang->lang_code);
                 if (!$alias) {
                     $alias = $title;
                 }
                 $safe_alias = JApplication::stringURLSafe($alias);
                 $values[] = "('tags', {$tag_id}, " . $this->_db->quote($lang->lang_code) . ", " . $this->_db->quote($title) . ", " . $this->_db->quote($safe_alias) . ")";
             }
         }
         // insert translations
         if (count($values)) {
             $this->_db->setQuery('INSERT INTO #__jkit_translations (ref_table, ref_id, lang, title, alias) VALUES ' . implode(',', $values))->query();
         }
     }
     return true;
 }
Example #7
0
            echo JText::alt('JALL', 'language');
            ?>
								<?php 
        } else {
            ?>
									<?php 
            echo $item->language_title ? $this->escape($item->language_title) : JText::_('JUNDEFINED');
            ?>
								<?php 
        }
        ?>
							</td>

							<!-- languages -->
							<?php 
        echo JKitHelperLangs::listItem($this->lists->langs, $this->lists->translations, $item);
        ?>

							<td class="nowrap center small">
								<?php 
        echo $item->user ? $item->user : '******';
        ?>
							</td>

							<td class="nowrap center small">
								<?php 
        echo JHtml::_('date', $item->modified, JText::_('DATE_FORMAT_LC4') . ' H:m');
        ?>
							</td>

							<td class="nowrap center small">
Example #8
0
<?php

/**
 * @package		JKit
 * @copyright	Copyright (C) CloudHotelier. All rights reserved.
 * @license		GNU GPLv2 <http://www.gnu.org/licenses/gpl.html>
 * @author		Xavier Pallicer <*****@*****.**>
 */
//
defined('_JEXEC') or die;
$langs = JKitHelperLangs::getLangs();
$imageHelper = new JKitHelperImage(JComponentHelper::getParams('com_jkit'));
$path_items = JURI::root() . "/images/jkit/items/";
$path_images = JURI::root() . "/images/jkit/images/";
$types = JKitHelper::defaultTypes();
?>

<!-- adminForm -->
<form action="<?php 
echo JRoute::_('index.php?option=com_jkit&view=items');
?>
" method="post" name="adminForm" id="adminForm">

    <!-- sidebar -->
    <div id="j-sidebar-container" class="span2">

		<?php 
echo $this->sidebar;
?>

        <!-- categories -->