Fixed gh-120 that allows export of component with language translations

This commit is contained in:
2017-09-18 02:18:23 +02:00
parent 72c6136bfb
commit 06416e665d
255 changed files with 801 additions and 850 deletions

View File

@ -10,8 +10,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.4
@build 13th September, 2017
@version 2.5.5
@build 17th September, 2017
@created 30th April, 2015
@package Component Builder
@subpackage ajax.php
@ -1085,150 +1085,6 @@ class ComponentbuilderModelAjax extends JModelList
}
// Used in language_translation
protected $functionArray = array(
'translation' => 'checkString',
'language' => 'getLanguageName');
protected function checkString($header, $value)
{
return $value;
}
protected function getLanguageName($header, $value)
{
if ($name = ComponentbuilderHelper::getVar($header, $value, 'langtag', 'name'))
{
return $name . ' (' . $value . ')';
}
return $value;
}
protected function setAutoLangZero()
{
// set the headers
$headers = array(
'translation' => JText::_('COM_COMPONENTBUILDER_TRANSLATION'),
'language' => JText::_('COM_COMPONENTBUILDER_LANGUAGE')
);
// loop the array
foreach ($headers as $key => $lang)
{
$this->setLanguage($key,$lang);
}
}
protected $languageArray = array();
protected function setLanguage($key,$lang)
{
$this->languageArray[$key] = $lang;
}
public function getLanguage()
{
// return the language string that were set
return $this->languageArray;
}
protected function autoLoader()
{
$functions = range(0,10);
foreach ($functions as $function)
{
$function = 'setAutoLang'.ComponentbuilderHelper::safeString($function, 'f');
if (method_exists($this, $function))
{
$this->{$function}();
}
}
foreach ($functions as $function)
{
$function = 'setAutoFunc'.ComponentbuilderHelper::safeString($function, 'f');
if (method_exists($this, $function))
{
$this->{$function}();
}
}
}
public function getBuildTable($idName, $oject)
{
if (ComponentbuilderHelper::checkJson($oject) && ComponentbuilderHelper::checkString($idName))
{
$array = json_decode($oject, true);
if (ComponentbuilderHelper::checkArray($array))
{
// make sure we run the autoloader to insure all is set
$this->autoLoader();
// set the target headers
$targetHeaders = $this->getLanguage();
// start table build
$table = '<table id="table_'.$idName.'" class="uk-table" style="margin: 5px 0 20px;"><thead><tr>';
$rows = array();
foreach ($array as $header => $values)
{
if (ComponentbuilderHelper::checkArray($values))
{
$targetHeader = (isset($targetHeaders[$header])) ? $targetHeaders[$header] : ComponentbuilderHelper::safeString($header, 'W');
$table .= '<th style="padding: 10px; text-align: center; border: 1px solid rgb(221, 221, 221);" scope="col">'.$targetHeader.'</th>';
foreach ($values as $nr => $value)
{
// set the value for the row
$this->setRows($nr, $this->setValue($header, $value), $rows);
}
}
}
// close header start body
$table .= '</tr></thead><tbody>';
// add rows to table
if (ComponentbuilderHelper::checkArray($rows))
{
foreach ($rows as $row)
{
$table .= '<tr>'.$row.'</tr>';
}
}
// close the body and table
$table .= '</tbody></table>';
// return the table
return $table;
}
}
return false;
}
protected function setValue($header, $value)
{
if (array_key_exists($header, $this->functionArray) && method_exists($this, $this->functionArray[$header]))
{
$value = $this->{$this->functionArray[$header]}($header, $value);
}
// if no value are set
if (!ComponentbuilderHelper::checkString($value))
{
$value = '-';
}
// make total stand out
if ('total' == $header)
{
$value = '<b>'.$value.'</b>';
}
return $value;
}
protected function setRows($nr, $value, &$rows)
{
// build rows
if (!isset($rows[$nr]))
{
$rows[$nr] = '<td style="padding: 10px; text-align: center; border: 1px solid rgb(221, 221, 221);">'.$value.'</td>';
}
else
{
$rows[$nr] .= '<td style="padding: 10px; text-align: center; border: 1px solid rgb(221, 221, 221);">'.$value.'</td>';
}
}
protected $viewid = array();