gh-60 language translation component added, basic implementation

This commit is contained in:
dev
2017-04-05 14:21:10 +01:00
parent f3f91f492f
commit 34d14ed95d
262 changed files with 1876 additions and 928 deletions

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.4.2
@build 3rd April, 2017
@build 5th April, 2017
@created 30th April, 2015
@package Component Builder
@subpackage ajax.json.php
@ -57,7 +57,9 @@ class ComponentbuilderControllerAjax extends JControllerLegacy
$this->registerTask('viewTableColumns', 'ajax');
$this->registerTask('checkFunctionName', 'ajax');
$this->registerTask('usedin', 'ajax');
$this->registerTask('fieldOptions', 'ajax');
$this->registerTask('fieldOptions', 'ajax');
$this->registerTask('getBuildTable', 'ajax');
$this->registerTask('getButton', 'ajax');
}
public function ajax()
@ -687,6 +689,83 @@ class ComponentbuilderControllerAjax extends JControllerLegacy
echo "(".json_encode($e).");";
}
}
break;
case 'getBuildTable':
try
{
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
$idNameValue = $jinput->get('idName', NULL, 'CMD');
$objectValue = $jinput->get('object', NULL, 'STRING');
if($idNameValue && $objectValue && $user->id != 0)
{
$result = $this->getModel('ajax')->getBuildTable($idNameValue, $objectValue);
}
else
{
$result = false;
}
if($callback = $jinput->get('callback', null, 'CMD'))
{
echo $callback . "(".json_encode($result).");";
}
elseif($returnRaw)
{
echo json_encode($result);
}
else
{
echo "(".json_encode($result).");";
}
}
catch(Exception $e)
{
if($callback = $jinput->get('callback', null, 'CMD'))
{
echo $callback."(".json_encode($e).");";
}
else
{
echo "(".json_encode($e).");";
}
}
break;
case 'getButton':
try
{
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
$typeValue = $jinput->get('type', NULL, 'WORD');
if($typeValue && $user->id != 0)
{
$result = $this->getModel('ajax')->getButton($typeValue);
}
else
{
$result = false;
}
if($callback = $jinput->get('callback', null, 'CMD'))
{
echo $callback . "(".json_encode($result).");";
}
elseif($returnRaw)
{
echo json_encode($result);
}
else
{
echo "(".json_encode($result).");";
}
}
catch(Exception $e)
{
if($callback = $jinput->get('callback', null, 'CMD'))
{
echo $callback."(".json_encode($e).");";
}
else
{
echo "(".json_encode($e).");";
}
}
break;
}
}

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.4.2
@build 3rd April, 2017
@build 5th April, 2017
@created 30th April, 2015
@package Component Builder
@subpackage componentbuilder.php

View File

@ -10,8 +10,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 81 of this MVC
@build 1st March, 2017
@version @update number 82 of this MVC
@build 3rd April, 2017
@created 11th October, 2016
@package Component Builder
@subpackage custom_code.php

View File

@ -10,8 +10,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 81 of this MVC
@build 1st March, 2017
@version @update number 82 of this MVC
@build 3rd April, 2017
@created 11th October, 2016
@package Component Builder
@subpackage custom_codes.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.4.2
@build 3rd April, 2017
@build 5th April, 2017
@created 30th April, 2015
@package Component Builder
@subpackage help.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.4.2
@build 3rd April, 2017
@build 5th April, 2017
@created 30th April, 2015
@package Component Builder
@subpackage import.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.4.2
@build 3rd April, 2017
@build 5th April, 2017
@created 30th April, 2015
@package Component Builder
@subpackage import_joomla_components.php

View File

@ -10,8 +10,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 311 of this MVC
@build 1st April, 2017
@version @update number 314 of this MVC
@build 5th April, 2017
@created 6th May, 2015
@package Component Builder
@subpackage joomla_component.php

View File

@ -10,8 +10,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 311 of this MVC
@build 1st April, 2017
@version @update number 314 of this MVC
@build 5th April, 2017
@created 6th May, 2015
@package Component Builder
@subpackage joomla_components.php

View File

@ -10,11 +10,11 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 8 of this MVC
@build 3rd April, 2017
@version @update number 28 of this MVC
@build 5th April, 2017
@created 3rd April, 2017
@package Component Builder
@subpackage language_placeholder.php
@subpackage language_translation.php
@author Llewellyn van der Merwe <http://vdm.bz/component-builder>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
@ -30,9 +30,9 @@ defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.controllerform');
/**
* Language_placeholder Controller
* Language_translation Controller
*/
class ComponentbuilderControllerLanguage_placeholder extends JControllerForm
class ComponentbuilderControllerLanguage_translation extends JControllerForm
{
/**
* Current or most recently performed task.
@ -45,7 +45,7 @@ class ComponentbuilderControllerLanguage_placeholder extends JControllerForm
public function __construct($config = array())
{
$this->view_list = 'Language_placeholders'; // safeguard for setting the return view listing to the main view.
$this->view_list = 'Language_translations'; // safeguard for setting the return view listing to the main view.
parent::__construct($config);
}
@ -61,13 +61,13 @@ class ComponentbuilderControllerLanguage_placeholder extends JControllerForm
protected function allowAdd($data = array())
{
// Access check.
$access = JFactory::getUser()->authorise('language_placeholder.access', 'com_componentbuilder');
$access = JFactory::getUser()->authorise('language_translation.access', 'com_componentbuilder');
if (!$access)
{
return false;
}
// In the absense of better information, revert to the component permissions.
return JFactory::getUser()->authorise('language_placeholder.create', $this->option);
return JFactory::getUser()->authorise('language_translation.create', $this->option);
}
/**
@ -89,7 +89,7 @@ class ComponentbuilderControllerLanguage_placeholder extends JControllerForm
// Access check.
$access = ($user->authorise('language_placeholder.access', 'com_componentbuilder.language_placeholder.' . (int) $recordId) && $user->authorise('language_placeholder.access', 'com_componentbuilder'));
$access = ($user->authorise('language_translation.access', 'com_componentbuilder.language_translation.' . (int) $recordId) && $user->authorise('language_translation.access', 'com_componentbuilder'));
if (!$access)
{
return false;
@ -98,10 +98,10 @@ class ComponentbuilderControllerLanguage_placeholder extends JControllerForm
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('language_placeholder.edit', 'com_componentbuilder.language_placeholder.' . (int) $recordId);
$permission = $user->authorise('language_translation.edit', 'com_componentbuilder.language_translation.' . (int) $recordId);
if (!$permission)
{
if ($user->authorise('language_placeholder.edit.own', 'com_componentbuilder.language_placeholder.' . $recordId))
if ($user->authorise('language_translation.edit.own', 'com_componentbuilder.language_translation.' . $recordId))
{
// Now test the owner is the user.
$ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
@ -120,7 +120,7 @@ class ComponentbuilderControllerLanguage_placeholder extends JControllerForm
// If the owner matches 'me' then allow.
if ($ownerId == $user->id)
{
if ($user->authorise('language_placeholder.edit.own', 'com_componentbuilder'))
if ($user->authorise('language_translation.edit.own', 'com_componentbuilder'))
{
return true;
}
@ -130,7 +130,7 @@ class ComponentbuilderControllerLanguage_placeholder extends JControllerForm
}
}
// Since there is no permission, revert to the component permissions.
return $user->authorise('language_placeholder.edit', $this->option);
return $user->authorise('language_translation.edit', $this->option);
}
/**
@ -196,10 +196,10 @@ class ComponentbuilderControllerLanguage_placeholder extends JControllerForm
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Set the model
$model = $this->getModel('Language_placeholder', '', array());
$model = $this->getModel('Language_translation', '', array());
// Preset the redirect
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=language_placeholders' . $this->getRedirectToListAppend(), false));
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=language_translations' . $this->getRedirectToListAppend(), false));
return parent::batch($model);
}

View File

@ -10,11 +10,11 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 8 of this MVC
@build 3rd April, 2017
@version @update number 28 of this MVC
@build 5th April, 2017
@created 3rd April, 2017
@package Component Builder
@subpackage language_placeholders.php
@subpackage language_translations.php
@author Llewellyn van der Merwe <http://vdm.bz/component-builder>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
@ -30,16 +30,16 @@ defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.controlleradmin');
/**
* Language_placeholders Controller
* Language_translations Controller
*/
class ComponentbuilderControllerLanguage_placeholders extends JControllerAdmin
class ComponentbuilderControllerLanguage_translations extends JControllerAdmin
{
protected $text_prefix = 'COM_COMPONENTBUILDER_LANGUAGE_PLACEHOLDERS';
protected $text_prefix = 'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS';
/**
* Proxy for getModel.
* @since 2.5
*/
public function getModel($name = 'Language_placeholder', $prefix = 'ComponentbuilderModel', $config = array())
public function getModel($name = 'Language_translation', $prefix = 'ComponentbuilderModel', $config = array())
{
$model = parent::getModel($name, $prefix, array('ignore_request' => true));
@ -52,7 +52,7 @@ class ComponentbuilderControllerLanguage_placeholders extends JControllerAdmin
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
// check if export is allowed for this user.
$user = JFactory::getUser();
if ($user->authorise('language_placeholder.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder'))
if ($user->authorise('language_translation.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder'))
{
// Get the input
$input = JFactory::getApplication()->input;
@ -60,19 +60,19 @@ class ComponentbuilderControllerLanguage_placeholders extends JControllerAdmin
// Sanitize the input
JArrayHelper::toInteger($pks);
// Get the model
$model = $this->getModel('Language_placeholders');
$model = $this->getModel('Language_translations');
// get the data to export
$data = $model->getExportData($pks);
if (ComponentbuilderHelper::checkArray($data))
{
// now set the data to the spreadsheet
$date = JFactory::getDate();
ComponentbuilderHelper::xls($data,'Language_placeholders_'.$date->format('jS_F_Y'),'Language placeholders exported ('.$date->format('jS F, Y').')','language placeholders');
ComponentbuilderHelper::xls($data,'Language_translations_'.$date->format('jS_F_Y'),'Language translations exported ('.$date->format('jS F, Y').')','language translations');
}
}
// Redirect to the list screen with error.
$message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED');
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=language_placeholders', false), $message, 'error');
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=language_translations', false), $message, 'error');
return;
}
@ -83,10 +83,10 @@ class ComponentbuilderControllerLanguage_placeholders extends JControllerAdmin
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
// check if import is allowed for this user.
$user = JFactory::getUser();
if ($user->authorise('language_placeholder.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder'))
if ($user->authorise('language_translation.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder'))
{
// Get the import model
$model = $this->getModel('Language_placeholders');
$model = $this->getModel('Language_translations');
// get the headers to import
$headers = $model->getExImPortHeaders();
if (ComponentbuilderHelper::checkObject($headers))
@ -94,18 +94,18 @@ class ComponentbuilderControllerLanguage_placeholders extends JControllerAdmin
// Load headers to session.
$session = JFactory::getSession();
$headers = json_encode($headers);
$session->set('language_placeholder_VDM_IMPORTHEADERS', $headers);
$session->set('backto_VDM_IMPORT', 'language_placeholders');
$session->set('dataType_VDM_IMPORTINTO', 'language_placeholder');
$session->set('language_translation_VDM_IMPORTHEADERS', $headers);
$session->set('backto_VDM_IMPORT', 'language_translations');
$session->set('dataType_VDM_IMPORTINTO', 'language_translation');
// Redirect to import view.
$message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_LANGUAGE_PLACEHOLDERS');
$message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_LANGUAGE_TRANSLATIONS');
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message);
return;
}
}
// Redirect to the list screen with error.
$message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED');
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=language_placeholders', false), $message, 'error');
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=language_translations', false), $message, 'error');
return;
}