\AdminTranslationsControllerCore

Summary

Methods
Properties
Constants
__construct()
setTypeSelected()
initContent()
initForm()
initToolbar()
initMain()
submitCopyLang()
changeModulesKeyTranslation()
exportTabs()
submitExportLang()
checkAndAddMailsFiles()
checkAndAddThemesFiles()
addNewTabs()
checkTranslationFile()
submitImportLang()
filterTranslationFiles()
filesListToPaths()
submitAddLang()
clearModuleFiles()
getFileToParseByTypeTranslation()
getTranslationsInformations()
getInformations()
renderKpis()
postProcess()
fileExists()
displayToggleButton()
displayLimitPostWarning()
checkIfKeyUseSprintf()
initFormFront()
initFormBack()
getListModules()
initFormErrors()
initFormFields()
getMailFiles()
getModulesHasMails()
getModulesHasPDF()
initFormMails()
copyMailFilesForAllLanguages()
initFormModules()
initFormPDF()
listFiles()
No public properties found
DEFAULT_THEME_NAME
TEXTAREA_SIZED
getModuleTranslations()
checkDirAndCreate()
writeTranslationFile()
findAndWriteTranslationsIntoFile()
findAndFillTranslations()
userParseFile()
redirect()
getMailPattern()
submitTranslationsMails()
getMailContent()
displayMailContent()
displayMailBlockTxt()
displayMailBlockHtml()
displayMailEditor()
cleanMailContent()
getTinyMCEForMails()
getSubjectMail()
getSubjectMailContent()
writeSubjectTranslationFile()
recursiveGetModuleFiles()
getAllModuleFiles()
parsePdfClass()
theme_exists()
$link_lang_pack
$total_expression
$missing_translations
$all_iso_lang
$modules_translations
$ignore_folder
$translations_informations
$languages
$themes
$theme_selected
$type_selected
$lang_selected
$post_limit_exceed
N/A
No private methods found
No private properties found
N/A

Constants

DEFAULT_THEME_NAME

DEFAULT_THEME_NAME

Name of theme by default

TEXTAREA_SIZED

TEXTAREA_SIZED

Properties

$link_lang_pack

$link_lang_pack : string

Type

string — : Link which list all pack of language

$total_expression

$total_expression : integer

Type

integer — : number of sentence which can be translated

$missing_translations

$missing_translations : integer

Type

integer — : number of sentence which aren't translated

$all_iso_lang

$all_iso_lang : array

Type

array — : List of ISO code for all languages

$modules_translations

$modules_translations : array

Type

array

$ignore_folder

$ignore_folder : array

Type

array — : List of folder which must be ignored

$translations_informations

$translations_informations : array

Type

array — : List of theme by translation type : FRONT, BACK, ERRORS...

$languages

$languages : array

Type

array — : List of all languages

$themes

$themes : array

Type

array — : List of all themes

$theme_selected

$theme_selected : string

Type

string — : Directory of selected theme

$type_selected

$type_selected : string

Type

string — : Name of translations type

$lang_selected

$lang_selected : \Language

Type

\Language — object : Language for the selected language

$post_limit_exceed

$post_limit_exceed : boolean

Type

boolean — : Is true if number of var exceed the suhosin request or post limit

Methods

__construct()

__construct() 

setTypeSelected()

setTypeSelected(  $type_selected) 

Parameters

$type_selected

initContent()

initContent() 

AdminController::initContent() override

initForm()

initForm(  $method_name) : \call

This function create vars by default and call the good method for generate form

Parameters

$method_name

Returns

\call —

the method $this->method_name()

initToolbar()

initToolbar() 

AdminController::initToolbar() override

initMain()

initMain() 

Generate the Main page

submitCopyLang()

submitCopyLang() 

changeModulesKeyTranslation()

changeModulesKeyTranslation(string  $path, string  $theme_from, string  $theme_to) : boolean

Change the key translation to according it to theme name.

Parameters

string $path
string $theme_from
string $theme_to

Returns

boolean

exportTabs()

exportTabs() 

submitExportLang()

submitExportLang() 

checkAndAddMailsFiles()

checkAndAddMailsFiles(  $iso_code,   $files_list) 

Parameters

$iso_code
$files_list

checkAndAddThemesFiles()

checkAndAddThemesFiles(array  $files, array  $themes_selected) 

Move theme translations in selected themes

Parameters

array $files
array $themes_selected

addNewTabs()

addNewTabs(array  $iso_code, array  $files) 

Add new translations tabs by code ISO

Parameters

array $iso_code
array $files

checkTranslationFile()

checkTranslationFile(  $content) 

Parameters

$content

submitImportLang()

submitImportLang() 

filterTranslationFiles()

filterTranslationFiles(  $list) 

Filter the translation files contained in a .gzip pack and return only the ones that we want.

Right now the function only needs to check that the modules for which we want to add translations are present on the shop (installed or not).

$list is the output of Archive_Tar::listContent()

Parameters

$list

filesListToPaths()

filesListToPaths(  $list) 

Turn the list returned by AdminTranslationsController::filterTranslationFiles() into a list of paths that can be passed to Archive_Tar::extractList()

Parameters

$list

submitAddLang()

submitAddLang() 

clearModuleFiles()

clearModuleFiles(  $files, string  $type_clear = 'file', string  $path = '') : array

Clear the list of module file by type (file or directory)

Parameters

$files

: list of files

string $type_clear

(file|directory)

string $path

Returns

array —

: list of a good files

getFileToParseByTypeTranslation()

getFileToParseByTypeTranslation() : array

Get list of files which must be parsed by directory and by type of translations

Returns

array —

: list of files by directory

getTranslationsInformations()

getTranslationsInformations() 

Get all translations informations for all type of translations

array( 'type' => array( 'name' => string : title for the translation type, 'var' => string : name of var for the translation file, 'dir' => string : dir of translation file 'file' => string : file name of translation file ) )

getInformations()

getInformations() 

Get all informations on : languages, theme and the translation type.

renderKpis()

renderKpis() 

postProcess()

postProcess() 

AdminController::postProcess() override

fileExists()

fileExists() 

Include file $dir/$file and return the var $var declared in it.

This create the file if not exists

return array : translations

displayToggleButton()

displayToggleButton(  $closed = false) 

Parameters

$closed

displayLimitPostWarning()

displayLimitPostWarning(  $count) 

Parameters

$count

checkIfKeyUseSprintf()

checkIfKeyUseSprintf(  $key) : array|boolean

Find sentence which use %d, %s, %%, %1$d, %1$s.

..

Parameters

$key

: english sentence

Returns

array|boolean —

return list of matches

initFormFront()

initFormFront() 

This method generate the form for front translations

initFormBack()

initFormBack() 

This method generate the form for back translations

getListModules()

getListModules() : array

Check if directory and file exist and return an list of modules

Returns

array —

: list of modules

initFormErrors()

initFormErrors() 

This method generate the form for errors translations

initFormFields()

initFormFields() 

This method generate the form for fields translations

getMailFiles()

getMailFiles(string  $dir, string  $group_name = 'mail') : array

Get each informations for each mails found in the folder $dir.

Parameters

string $dir
string $group_name

Returns

array —

: list of mails

getModulesHasMails()

getModulesHasMails(  $with_module_name = false) : array

Check in each module if contains mails folder.

Parameters

$with_module_name

Returns

array —

of module which has mails

getModulesHasPDF()

getModulesHasPDF(  $classes = false) : array

Check in each module if contains pdf folder.

Parameters

$classes

Returns

array —

of module which has pdf

initFormMails()

initFormMails(  $no_display = false) 

This method generate the form for mails translations

Parameters

$no_display

copyMailFilesForAllLanguages()

copyMailFilesForAllLanguages() 

initFormModules()

initFormModules() 

This method generate the form for modules translations

initFormPDF()

initFormPDF() 

This method generate the form for PDF translations

listFiles()

listFiles(  $dir,   $list = array(),   $file_ext = 'tpl') 

recursively list files in directory $dir

Parameters

$dir
$list
$file_ext

getModuleTranslations()

getModuleTranslations() 

This method merge each arrays of modules translation in the array of modules translations

checkDirAndCreate()

checkDirAndCreate(string  $dest) : boolean

This method is only used by AdminTranslations::submitCopyLang().

It try to create folder in new theme.

When a translation file is copied for a module, its translation key is wrong. We have to change the translation key and rewrite the file.

Parameters

string $dest

file name

Returns

boolean

writeTranslationFile()

writeTranslationFile(boolean  $override_file = false) 

Read the Post var and write the translation file.

This method overwrites the old translation file.

Parameters

boolean $override_file

: set true if this file is a override

findAndWriteTranslationsIntoFile()

findAndWriteTranslationsIntoFile(string  $file_name, array  $files, string  $theme_name, string  $module_name, string|boolean  $dir = false) : void

This method check each file (tpl or php file), get its sentences to translate, compare with posted values and write in iso code translation file.

Parameters

string $file_name
array $files
string $theme_name
string $module_name
string|boolean $dir

findAndFillTranslations()

findAndFillTranslations(array  $files, string  $theme_name, string  $module_name, string|boolean  $dir = false) : void

This method get translation for each files of a module, compare with global $_MODULES array and fill AdminTranslations::modules_translations array With key as English sentences and values as their iso code translations.

Parameters

array $files
string $theme_name
string $module_name
string|boolean $dir

userParseFile()

userParseFile(  $content,   $type_translation, string|boolean  $type_file = false, string  $module_name = '') : \return

This method parse a file by type of translation and type file

Parameters

$content
$type_translation

: front, back, errors, modules...

string|boolean $type_file

: (tpl|php)

string $module_name

: name of the module

Returns

\return —

$matches

redirect()

redirect(boolean  $save_and_stay = false, boolean  $conf = false) 

This method redirect in the translation main page or in the translation page

Parameters

boolean $save_and_stay

: true if the user has clicked on the button "save and stay"

boolean $conf

: id of confirmation message

getMailPattern()

getMailPattern() 

submitTranslationsMails()

submitTranslationsMails() 

This method is used to write translation for mails.

This writes subject translation files (in root/mails/lang_choosen/lang.php or root/_PS_THEMESDIR/mails/lang_choosen/lang.php) and mails files.

getMailContent()

getMailContent(string  $dir, string  $file) : array

Get content of the mail file.

Parameters

string $dir
string $file

Returns

array —

: content of file

displayMailContent()

displayMailContent(array  $mails, array  $all_subject_mail, \Language  $obj_lang, string  $id_html, string  $title, string|boolean  $name_for_module = false) 

Display mails in html format.

This was create for factorize the html displaying

Parameters

array $mails
array $all_subject_mail
\Language $obj_lang
string $id_html

use for set html id attribute for the block

string $title

Set the title for the block

string|boolean $name_for_module

is not false define add a name for disntiguish mails module

displayMailBlockTxt()

displayMailBlockTxt(array  $content, string  $lang, string  $mail_name, string  $group_name, string|boolean  $name_for_module = false) 

Just build the html structure for display txt mails

Parameters

array $content

with english and language needed contents

string $lang

iso code of the needed language

string $mail_name

name of the file to translate (same for txt and html files)

string $group_name

group name allow to distinguish each block of mail.

string|boolean $name_for_module

is not false define add a name for disntiguish mails module

displayMailBlockHtml()

displayMailBlockHtml(array  $content, string  $lang, string  $url, string  $mail_name, string  $group_name, string|boolean  $name_for_module = false) 

Just build the html structure for display html mails.

Parameters

array $content

with english and language needed contents

string $lang

iso code of the needed language

string $url

for the html page and displaying an outline

string $mail_name

name of the file to translate (same for txt and html files)

string $group_name

group name allow to distinguish each block of mail.

string|boolean $name_for_module

is not false define add a name for disntiguish mails module

displayMailEditor()

displayMailEditor(  $content,   $lang,   $url,   $mail_name,   $group_name,   $name_for_module = false) 

Parameters

$content
$lang
$url
$mail_name
$group_name
$name_for_module

cleanMailContent()

cleanMailContent(  $content,   $lang,   $title) 

Parameters

$content
$lang
$title

getTinyMCEForMails()

getTinyMCEForMails(  $iso_lang) 

Parameters

$iso_lang

getSubjectMail()

getSubjectMail(  $dir,   $file,   $subject_mail) : array

Get list of subjects of mails

Parameters

$dir
$file
$subject_mail

Returns

array —

: list of subjects of mails

getSubjectMailContent()

getSubjectMailContent(  $directory) : array

Parameters

$directory

: name of directory

Returns

array

writeSubjectTranslationFile()

writeSubjectTranslationFile(  $sub,   $path) 

Parameters

$sub
$path

recursiveGetModuleFiles()

recursiveGetModuleFiles(string  $path, array  $array_files, string  $module_name, string  $lang_file, boolean  $is_default = false) 

This get files to translate in module directory.

Recursive method allow to get each files for a module no matter his depth.

Parameters

string $path

directory path to scan

array $array_files

by reference - array which saved files to parse.

string $module_name

module name

string $lang_file

full path of translation file

boolean $is_default

getAllModuleFiles()

getAllModuleFiles(array  $modules, string  $root_dir = null, string  $lang, boolean  $is_default = false) 

This method get translation in each translations file.

The file depend on $lang param.

Parameters

array $modules

list of modules

string $root_dir

path where it get each modules

string $lang

iso code of choosen language to translate

boolean $is_default

set it if modules are located in root/prestashop/modules folder This allow to distinguish overrided prestashop theme and original module

parsePdfClass()

parsePdfClass(string  $file_path, string  $file_type,   $lang_array, string  $tab, array  $tabs_array,   $count_missing) : array

Parse PDF class

Parameters

string $file_path

file to parse

string $file_type

type of file

$lang_array
string $tab

name to use with the md5 key

array $tabs_array
$count_missing

Returns

array —

containing all datas needed for building the translation form

theme_exists()

theme_exists(  $theme) 

Parameters

$theme