From 95716e22cf0b975d38d88d2df5cbb7f188942f2e Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Thu, 14 Dec 2017 15:30:21 +0200 Subject: [PATCH] Updated the compiler to also target JText::script() & Joomla.JText._() in language constant replacement. Added field counter. Resolved gh-198 --- README.md | 4 +- admin/README.txt | 4 +- admin/controllers/compiler.php | 1 + admin/controllers/snippets.php | 4 +- admin/helpers/compiler.php | 33 ++++ admin/helpers/compiler/a_Get.php | 141 ++++++++++++++---- admin/helpers/compiler/b_Structure.php | 7 + admin/helpers/compiler/c_Fields.php | 33 +++- admin/views/get_snippets/view.html.php | 122 +++++++-------- .../import_joomla_components/tmpl/default.php | 2 +- componentbuilder.xml | 2 +- 11 files changed, 250 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index 2ee827e34..7cd672fc0 100644 --- a/README.md +++ b/README.md @@ -111,11 +111,11 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](http://vdm.bz/component-builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 12th December, 2017 ++ *Last Build*: 14th December, 2017 + *Version*: 2.6.6 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **177938** ++ *Line count*: **177939** + *File count*: **1142** + *Folder count*: **184** diff --git a/admin/README.txt b/admin/README.txt index 2ee827e34..7cd672fc0 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -111,11 +111,11 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](http://vdm.bz/component-builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 12th December, 2017 ++ *Last Build*: 14th December, 2017 + *Version*: 2.6.6 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **177938** ++ *Line count*: **177939** + *File count*: **1142** + *Folder count*: **184** diff --git a/admin/controllers/compiler.php b/admin/controllers/compiler.php index 148a01761..bd5d9355f 100644 --- a/admin/controllers/compiler.php +++ b/admin/controllers/compiler.php @@ -105,6 +105,7 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin $message .= ''; diff --git a/admin/controllers/snippets.php b/admin/controllers/snippets.php index 5b62be4b5..ca628187b 100644 --- a/admin/controllers/snippets.php +++ b/admin/controllers/snippets.php @@ -150,12 +150,12 @@ class ComponentbuilderControllerSnippets extends JControllerAdmin if (count($pks) > 1) { $message = '

' . JText::_('COM_COMPONENTBUILDER_THE_SNIPPETS_WERE_SUCCESSFULLY_EXPORTED') . '

'; - $message .= '

' . JText::sprintf('To share these snippets with the rest of the JCB community,'); + $message .= '

' . JText::sprintf('COM_COMPONENTBUILDER_TO_SHARE_THESE_SNIPPETS_WITH_THE_REST_OF_THE_JCB_COMMUNITY'); } else { $message = '

' . JText::_('COM_COMPONENTBUILDER_THE_SNIPPET_WAS_SUCCESSFULLY_EXPORTED') . '

'; - $message .= '

' . JText::sprintf('To share this snippet with the rest of the JCB community,'); + $message .= '

' . JText::sprintf('COM_COMPONENTBUILDER_TO_SHARE_THIS_SNIPPET_WITH_THE_REST_OF_THE_JCB_COMMUNITY'); } $message .= JText::sprintf('COM_COMPONENTBUILDER_YOU_WILL_NEED_TO_KNOW_HOW_S_WORKS_BASIC_YOU_WILL_ALSO_NEED_A_S_ACCOUNT_AND_KNOW_HOW_TO_MAKE_A_PULL_REQUEST_ON_GITHUB', 'git', diff --git a/admin/helpers/compiler.php b/admin/helpers/compiler.php index 5f5127bf9..e000b987a 100644 --- a/admin/helpers/compiler.php +++ b/admin/helpers/compiler.php @@ -146,6 +146,38 @@ class Compiler extends Infusion // done with error return false; } + // do lang mismatch check + if (ComponentbuilderHelper::checkArray($this->langMismatch)) + { + if (ComponentbuilderHelper::checkArray($this->langMatch)) + { + $mismatch = array_diff(array_unique($this->langMismatch), array_unique($this->langMatch)); + } + else + { + $mismatch = array_unique($this->langMismatch); + } + // set a notice if we have a mismatch + if (ComponentbuilderHelper::checkArray($mismatch)) + { + if (count($mismatch) > 1) + { + $this->app->enqueueMessage(JText::_('

Please check the following mismatching Joomla.JText language constants.

'), 'Warning'); + } + else + { + $this->app->enqueueMessage(JText::_('

Please check the following mismatch Joomla.JText language constant.

'), 'Warning'); + } + // add the mismatching issues + foreach ($mismatch as $string) + { + $constant = $this->langPrefix.'_'.ComponentbuilderHelper::safeString($string,'U'); + $this->app->enqueueMessage(JText::sprintf('The Joomla.JText._(\'%s\') language constant for (%s) does not have a corresponding JText::Script() decalaration.', + $constant, $string), 'Warning'); + } + $this->app->enqueueMessage('
', 'Warning'); + } + } // end the timer here $this->time_end = microtime(true); $this->secondsCompiled = $this->time_end - $this->time_start; @@ -396,6 +428,7 @@ class Compiler extends Infusion { // set some defaults $this->fileContentStatic['###LINE_COUNT###'] = $this->lineCount; + $this->fileContentStatic['###FIELD_COUNT###'] = $this->fieldCount; $this->fileContentStatic['###FILE_COUNT###'] = $this->fileCount; $this->fileContentStatic['###FOLDER_COUNT###'] = $this->folderCount; $this->fileContentStatic['###PAGE_COUNT###'] = $this->pageCount; diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 0db6ae613..c5ddc01cf 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -218,6 +218,32 @@ class Get */ protected $existingLangStrings = array(); + /** + * The Language JS matching check + * + * @var array + */ + public $langMismatch = array(); + + /** + * The Language SC matching check + * + * @var array + */ + public $langMatch = array(); + + /** + * The Language string targets + * + * @var array + */ + public $langStringTargets = array( + 'Joomla.JText._(', + 'JText::script(', + 'JText::_(', + 'JText::sprintf(' + ); + /** * The Component Code Name * @@ -1773,18 +1799,6 @@ class Get $this->getModule[$this->target][$view->code] = true; } } - // (TODO) we may want to automate this .... lets see if someone asks -// if (strpos($view->$scripter,"token") !== false || strpos($view->$scripter,"task=ajax") !== false) -// { -// if(!isset($this->customScriptBuilder['token'])) -// { -// $this->customScriptBuilder['token'] = array(); -// } -// if (!isset($this->customScriptBuilder['token'][$this->target.$view->code]) || !$this->customScriptBuilder['token'][$this->target.$view->code]) -// { -// $this->customScriptBuilder['token'][$this->target.$view->code] = true; -// } -// } } } // add_Ajax for this view @@ -3109,18 +3123,64 @@ class Get */ public function setLangStrings($content) { - // first check if we should continue - if (strpos($content, 'JText::_(') !== false || strpos($content, 'JText::sprintf(') !== false) + // get targets to search for + $langStringTargets = array_filter( + $this->langStringTargets, + function($get) use($content){ + if (strpos($content, $get) !== false) + { + return true; + } + return false; + }); + // check if we should continue + if (ComponentbuilderHelper::checkArray($langStringTargets)) { // insure string is not broken $content = str_replace('COM_###COMPONENT###',$this->langPrefix,$content); + // first get the Joomla.JText._() + if (in_array('Joomla.JText._(',$langStringTargets)) + { + $jsTEXT[] = ComponentbuilderHelper::getAllBetween($content, "Joomla.JText._('","'"); + $jsTEXT[] = ComponentbuilderHelper::getAllBetween($content, 'Joomla.JText._("','"'); + // combine into one array + $jsTEXT = ComponentbuilderHelper::mergeArrays($jsTEXT); + // we need to add a check to insure these JavaScript lang matchup + if (ComponentbuilderHelper::checkArray($jsTEXT)) //<-- not really needed hmmm + { + // load the JS text to mismatch array + $langCheck[] = $jsTEXT; + $this->langMismatch = ComponentbuilderHelper::mergeArrays(array($jsTEXT, $this->langMismatch)); + } + } + // now get the JText::script() + if (in_array('JText::script(',$langStringTargets)) + { + $scTEXT[] = ComponentbuilderHelper::getAllBetween($content, "JText::script('","'"); + $scTEXT[] = ComponentbuilderHelper::getAllBetween($content, 'JText::script("','"'); + // combine into one array + $scTEXT = ComponentbuilderHelper::mergeArrays($scTEXT); + // we need to add a check to insure these JavaScript lang matchup + if (ComponentbuilderHelper::checkArray($scTEXT)) //<-- not really needed hmmm + { + // load the Script text to match array + $langCheck[] = $scTEXT; + $this->langMatch = ComponentbuilderHelper::mergeArrays(array($scTEXT, $this->langMatch)); + } + } // set language data - $langCheck[] = ComponentbuilderHelper::getAllBetween($content, "JText::_('","'"); - $langCheck[] = ComponentbuilderHelper::getAllBetween($content, 'JText::_("','"'); - $langCheck[] = ComponentbuilderHelper::getAllBetween($content, "JText::sprintf('","'"); - $langCheck[] = ComponentbuilderHelper::getAllBetween($content, 'JText::sprintf("','"'); + foreach($langStringTargets as $langStringTarget) + { + // need some special treatment here + if ($langStringTarget === 'Joomla.JText._(' || $langStringTarget === 'JText::script(') + { + continue; + } + $langCheck[] = ComponentbuilderHelper::getAllBetween($content, $langStringTarget."'","'"); + $langCheck[] = ComponentbuilderHelper::getAllBetween($content, $langStringTarget.'"','"'); + } $langArray = ComponentbuilderHelper::mergeArrays($langCheck); - if (ComponentbuilderHelper::checkArray($langArray)) + if (ComponentbuilderHelper::checkArray($langArray)) //<-- not really needed hmmm { foreach ($langArray as $string) { @@ -3135,10 +3195,12 @@ class Get { $this->langContent[$this->lang][$keyLang] = trim($string); } - $langHolders["JText::_('".$string."')"] = "JText::_('".$keyLang."')"; - $langHolders['JText::_("'.$string.'")'] = 'JText::_("'.$keyLang.'")'; - $langHolders["JText::sprintf('".$string."',"] = "JText::sprintf('".$keyLang."',"; - $langHolders['JText::sprintf("'.$string.'",'] = 'JText::sprintf("'.$keyLang.'",'; + // load the language targets + foreach($langStringTargets as $langStringTarget) + { + $langHolders[$langStringTarget."'".$string."'"] = $langStringTarget."'".$keyLang."'"; + $langHolders[$langStringTarget.'"'.$string.'"'] = $langStringTarget.'"'.$keyLang.'"'; + } } // only continue if we have value to replace if (isset($langHolders) && ComponentbuilderHelper::checkArray($langHolders)) @@ -4772,21 +4834,33 @@ class Get */ protected function setReverseLangPlaceholders($updateString, $string) { - if (strpos($string, 'JText::_(') !== false || strpos($string, 'JText::sprintf(') !== false) + // get targets to search for + $langStringTargets = array_filter( + $this->langStringTargets, + function($get) use($string){ + if (strpos($string, $get) !== false) + { + return true; + } + return false; + }); + // check if we should continue + if (ComponentbuilderHelper::checkArray($langStringTargets)) { $langHolders = array(); // set the lang for both since we don't know what area is being targeted $_tmp = $this->lang; $this->lang = 'both'; // set language data - $langCheck[] = ComponentbuilderHelper::getAllBetween($string, "JText::_('","'"); - $langCheck[] = ComponentbuilderHelper::getAllBetween($string, 'JText::_("','"'); - $langCheck[] = ComponentbuilderHelper::getAllBetween($string, "JText::sprintf('","'"); - $langCheck[] = ComponentbuilderHelper::getAllBetween($string, 'JText::sprintf("','"'); + foreach($langStringTargets as $langStringTarget) + { + $langCheck[] = ComponentbuilderHelper::getAllBetween($string, $langStringTarget."'","'"); + $langCheck[] = ComponentbuilderHelper::getAllBetween($string, $langStringTarget."'","'"); + } // merge arrays $langArray = ComponentbuilderHelper::mergeArrays($langCheck); // continue only if strings were found - if (ComponentbuilderHelper::checkArray($langArray)) + if (ComponentbuilderHelper::checkArray($langArray)) //<-- not really needed hmmm { foreach ($langArray as $lang) { @@ -4803,10 +4877,11 @@ class Get $this->langContent[$this->lang][$keyLang] = trim($lang); } // reverse the placeholders - $langHolders["JText::_('".$keyLang."')"] = "JText::_('".$lang."')"; - $langHolders['JText::_("'.$keyLang.'")'] = 'JText::_("'.$lang.'")'; - $langHolders["JText::sprintf('".$keyLang."',"] = "JText::sprintf('".$lang."',"; - $langHolders['JText::sprintf("'.$keyLang.'",'] = 'JText::sprintf("'.$lang.'",'; + foreach($langStringTargets as $langStringTarget) + { + $langHolders[$langStringTarget."'".$keyLang."'"] = $langStringTarget."'".$lang."'"; + $langHolders[$langStringTarget.'"'.$keyLang.'"'] = $langStringTarget.'"'.$lang.'"'; + } } // return the found placeholders $updateString = $this->setPlaceholders($updateString, $langHolders); diff --git a/admin/helpers/compiler/b_Structure.php b/admin/helpers/compiler/b_Structure.php index 307156e86..aaa5207df 100644 --- a/admin/helpers/compiler/b_Structure.php +++ b/admin/helpers/compiler/b_Structure.php @@ -59,6 +59,13 @@ class Structure extends Get */ public $lineCount = 0; + /** + * The field counter + * + * @var int + */ + public $fieldCount = 0; + /** * The seconds counter * diff --git a/admin/helpers/compiler/c_Fields.php b/admin/helpers/compiler/c_Fields.php index ddd5c0299..e17e33744 100644 --- a/admin/helpers/compiler/c_Fields.php +++ b/admin/helpers/compiler/c_Fields.php @@ -497,6 +497,8 @@ class Fields extends Structure ); $fieldXML = $fieldSetXML->addChild('field'); $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; } // if created is not set if (!isset($this->fieldsNames[$viewName]['created'])) @@ -514,6 +516,8 @@ class Fields extends Structure $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Date Created Field. Type: Calendar (joomla)"); $fieldXML = $fieldSetXML->addChild('field'); $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; } // if created_by is not set if (!isset($this->fieldsNames[$viewName]['created_by'])) @@ -528,6 +532,8 @@ class Fields extends Structure $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " User Created Field. Type: User (joomla)"); $fieldXML = $fieldSetXML->addChild('field'); $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; } // if published is not set if (!isset($this->fieldsNames[$viewName]['published'])) @@ -541,6 +547,8 @@ class Fields extends Structure $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Published Field. Type: List (joomla)"); $fieldXML = $fieldSetXML->addChild('field'); $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; foreach (array('JPUBLISHED' => 1, 'JUNPUBLISHED' => 0, 'JARCHIVED' => 2, 'JTRASHED' => -2) as $text => $value) { $optionXML = $fieldXML->addChild('option'); @@ -565,6 +573,8 @@ class Fields extends Structure $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Date Modified Field. Type: Calendar (joomla)"); $fieldXML = $fieldSetXML->addChild('field'); $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; } // if modified_by is not set if (!isset($this->fieldsNames[$viewName]['modified_by'])) @@ -581,6 +591,8 @@ class Fields extends Structure $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " User Modified Field. Type: User (joomla)"); $fieldXML = $fieldSetXML->addChild('field'); $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; } // check if view has access if (isset($this->accessBuilder[$viewName]) && ComponentbuilderHelper::checkString($this->accessBuilder[$viewName]) && !isset($this->fieldsNames[$viewName]['access'])) @@ -597,6 +609,8 @@ class Fields extends Structure $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Access Field. Type: Accesslevel (joomla)"); $fieldXML = $fieldSetXML->addChild('field'); $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; } // if ordering is not set if (!isset($this->fieldsNames[$viewName]['ordering'])) @@ -615,6 +629,8 @@ class Fields extends Structure $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Ordering Field. Type: Numbers (joomla)"); $fieldXML = $fieldSetXML->addChild('field'); $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; } // if version is not set if (!isset($this->fieldsNames[$viewName]['version'])) @@ -632,6 +648,8 @@ class Fields extends Structure $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Version Field. Type: Text (joomla)"); $fieldXML = $fieldSetXML->addChild('field'); $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; } // check if metadata is added to this view if (isset($this->metadataBuilder[$viewName]) && ComponentbuilderHelper::checkString($this->metadataBuilder[$viewName])) @@ -648,6 +666,8 @@ class Fields extends Structure $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Metakey Field. Type: Textarea (joomla)"); $fieldXML = $fieldSetXML->addChild('field'); $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; // metadesc $attributes['name'] = 'metadesc'; $attributes['label'] = 'JFIELD_META_DESCRIPTION_LABEL'; @@ -655,6 +675,8 @@ class Fields extends Structure $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Metadesc Field. Type: Textarea (joomla)"); $fieldXML = $fieldSetXML->addChild('field'); $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; } // load the dynamic fields now if (count($dynamicFieldsXML)) @@ -685,6 +707,8 @@ class Fields extends Structure 'description' => 'JFIELD_METADATA_ROBOTS_DESC' ); $this->xmlAddAttributes($robots, $attributes); + // count the static field created + $this->fieldCount++; $options = array( 'JGLOBAL_USE_GLOBAL' => '', 'JGLOBAL_INDEX_FOLLOW' => 'index, follow', @@ -709,6 +733,8 @@ class Fields extends Structure 'size' => 20 ); $this->xmlAddAttributes($author, $attributes); + // count the static field created + $this->fieldCount++; // rights $this->xmlComment($fieldsFieldSetXML, $this->setLine(__LINE__) . " Rights Field. Type: Textarea (joomla)"); $rights = $fieldsFieldSetXML->addChild('field'); @@ -723,6 +749,8 @@ class Fields extends Structure 'rows' => 2 ); $this->xmlAddAttributes($rights, $attributes); + // count the static field created + $this->fieldCount++; } // just to be safe, lets clear the view placeholders $this->clearFromPlaceHolders('view'); @@ -2342,7 +2370,8 @@ class Fields extends Structure public function xmlAppend(&$xml, $node) { if (!$node) - { // element was not returned + { + // element was not returned return; } switch (get_class($node)) @@ -2364,6 +2393,8 @@ class Fields extends Structure $xml = simplexml_import_dom($domXML); break; } + // count the dynamic fields created + $this->fieldCount++; } /** diff --git a/admin/views/get_snippets/view.html.php b/admin/views/get_snippets/view.html.php index 257a6cba7..088b777f1 100644 --- a/admin/views/get_snippets/view.html.php +++ b/admin/views/get_snippets/view.html.php @@ -189,38 +189,38 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy // set an error message if needed $this->document->addScriptDeclaration("var returnError = '

".JText::_('COM_COMPONENTBUILDER_AN_ERROR_HAS_OCCURRED')."!

".JText::_('COM_COMPONENTBUILDER_PLEASE_TRY_AGAIN_LATER').".

';"); // need to add some language strings - $this->document->addScriptDeclaration("var lang_Community_Snippets = '".JText::_('COM_COMPONENTBUILDER_JCB_COMMUNITY_SNIPPETS')."';"); - $this->document->addScriptDeclaration("var lang_Snippets = '".JText::_('COM_COMPONENTBUILDER_SNIPPETS')."';"); - $this->document->addScriptDeclaration("var lang_Snippet = '".JText::_('COM_COMPONENTBUILDER_SNIPPET')."';"); - $this->document->addScriptDeclaration("var lang_Snippet_Tooltip = '".JText::_('COM_COMPONENTBUILDER_VIEW_SNIPPET_OF_COMMUNITY_VERSION')."';"); - $this->document->addScriptDeclaration("var lang_Get_Snippet = '".JText::_('COM_COMPONENTBUILDER_GET_SNIPPET')."';"); - $this->document->addScriptDeclaration("var lang_Dont_Get_Snippet = '".JText::_('COM_COMPONENTBUILDER_LOCAL_SNIPPET')."';"); - $this->document->addScriptDeclaration("var lang_Get_Snippet_Tooltip = '".JText::_('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_UPDATE_THE_LOCAL_VERSION')."';"); - $this->document->addScriptDeclaration("var lang_Get_Snippet_New_Tooltip = '".JText::_('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_INSTALL_IT_LOCALLY')."';"); - $this->document->addScriptDeclaration("var lang_Get_Snippet_Dont_Tooltip = '".JText::_('COM_COMPONENTBUILDER_NO_NEED_TO_GET_IT_SINCE_IT_IS_ALREADY_IN_SYNC_WITH_YOUR_LOCAL_VERSION')."';"); - $this->document->addScriptDeclaration("var lang_Usage = '".JText::_('COM_COMPONENTBUILDER_USAGE')."';"); - $this->document->addScriptDeclaration("var lang_Usage_Tooltip = '".JText::_('COM_COMPONENTBUILDER_VIEW_USAGE_OF_COMMUNITY_VERSION')."';"); - $this->document->addScriptDeclaration("var lang_Description = '".JText::_('COM_COMPONENTBUILDER_DESCRIPTION')."';"); - $this->document->addScriptDeclaration("var lang_Description_Tooltip = '".JText::_('COM_COMPONENTBUILDER_VIEW_DESCRIPTION_OF_COMMUNITY_VERSION')."';"); - $this->document->addScriptDeclaration("var lang_View_Blame = '".JText::_('COM_COMPONENTBUILDER_VIEW_BLAME')."';"); - $this->document->addScriptDeclaration("var lang_View_Blame_Tooltip = '".JText::_('COM_COMPONENTBUILDER_VIEW_WHO_CONTRIBUTED_TO_THIS_SNIPPET')."';"); - $this->document->addScriptDeclaration("var lang_URL_Tooltip = '".JText::_('COM_COMPONENTBUILDER_VIEW_SNIPPET_REFERENCE_URL')."';"); - $this->document->addScriptDeclaration("var lang_Update_Error_Tooltip = '".JText::_('COM_COMPONENTBUILDER_SNIPPET_COULD_NOT_BE_UPDATEDSAVED')."';"); - $this->document->addScriptDeclaration("var lang_Updates_Error_Tooltip = '".JText::_('COM_COMPONENTBUILDER_SNIPPETS_COULD_NOT_BE_UPDATEDSAVED')."';"); - $this->document->addScriptDeclaration("var lang_Contributor_URL_Tooltip = '".JText::_('COM_COMPONENTBUILDER_LINK_TO_THE_CONTRIBUTOR')."';"); - $this->document->addScriptDeclaration("var lang_Contributor_Modal_Tooltip = '".JText::_('COM_COMPONENTBUILDER_VIEW_THE_CONTRIBUTOR_DETAILS')."';"); - $this->document->addScriptDeclaration("var lang_JCB_Community = '".JText::_('COM_COMPONENTBUILDER_JCB_COMMUNITY')."';"); - $this->document->addScriptDeclaration("var lang_Company_Name = '".JText::_('COM_COMPONENTBUILDER_COMPANY_NAME')."';"); - $this->document->addScriptDeclaration("var lang_Author_Name = '".JText::_('COM_COMPONENTBUILDER_AUTHOR_NAME')."';"); - $this->document->addScriptDeclaration("var lang_Author_Email = '".JText::_('COM_COMPONENTBUILDER_AUTHOR_EMAIL')."';"); - $this->document->addScriptDeclaration("var lang_Author_Website = '".JText::_('COM_COMPONENTBUILDER_AUTHOR_WEBSITE')."';"); - $this->document->addScriptDeclaration("var lang_Get_Snippets_New_Tooltip = '".JText::_('COM_COMPONENTBUILDER_THERE_ARE_NO_NEW_SNIPPETS_AT_THIS_TIME')."';"); - $this->document->addScriptDeclaration("var lang_Get_Snippets_Diverged_Tooltip = '".JText::_('COM_COMPONENTBUILDER_THERE_ARE_NO_DIVERGED_SNIPPETS_AT_THIS_TIME')."';"); - $this->document->addScriptDeclaration("var lang_Get_Snippets_Ahead_Tooltip = '".JText::_('COM_COMPONENTBUILDER_THERE_ARE_NO_AHEAD_SNIPPETS_AT_THIS_TIME')."';"); - $this->document->addScriptDeclaration("var lang_Get_Snippets_Behind_Tooltip = '".JText::_('COM_COMPONENTBUILDER_THERE_ARE_NO_OUT_OF_DATE_SNIPPETS_AT_THIS_TIME')."';"); - $this->document->addScriptDeclaration("var lang_Get_Snippets_All_Tooltip = '".JText::_('COM_COMPONENTBUILDER_THERE_ARE_NO_SNIPPETS_TO_UPDATE_AT_THIS_TIME')."';"); - $this->document->addScriptDeclaration("var lang_Available_Libraries = '".JText::_('COM_COMPONENTBUILDER_AVAILABLE_LIBRARIES')."';"); - $this->document->addScriptDeclaration("var lang_Open_Lib_Snippets = '".JText::_('COM_COMPONENTBUILDER_OPEN_LIBRARY_SNIPPETS')."';"); + JText::script('COM_COMPONENTBUILDER_JCB_COMMUNITY_SNIPPETS'); + JText::script('COM_COMPONENTBUILDER_SNIPPETS'); + JText::script('COM_COMPONENTBUILDER_SNIPPET'); + JText::script('COM_COMPONENTBUILDER_VIEW_SNIPPET_OF_COMMUNITY_VERSION'); + JText::script('COM_COMPONENTBUILDER_GET_SNIPPET'); + JText::script('COM_COMPONENTBUILDER_LOCAL_SNIPPET'); + JText::script('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_UPDATE_THE_LOCAL_VERSION'); + JText::script('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_INSTALL_IT_LOCALLY'); + JText::script('COM_COMPONENTBUILDER_NO_NEED_TO_GET_IT_SINCE_IT_IS_ALREADY_IN_SYNC_WITH_YOUR_LOCAL_VERSION'); + JText::script('COM_COMPONENTBUILDER_USAGE'); + JText::script('COM_COMPONENTBUILDER_VIEW_USAGE_OF_COMMUNITY_VERSION'); + JText::script('COM_COMPONENTBUILDER_DESCRIPTION'); + JText::script('COM_COMPONENTBUILDER_VIEW_DESCRIPTION_OF_COMMUNITY_VERSION'); + JText::script('COM_COMPONENTBUILDER_VIEW_BLAME'); + JText::script('COM_COMPONENTBUILDER_VIEW_WHO_CONTRIBUTED_TO_THIS_SNIPPET'); + JText::script('COM_COMPONENTBUILDER_VIEW_SNIPPET_REFERENCE_URL'); + JText::script('COM_COMPONENTBUILDER_SNIPPET_COULD_NOT_BE_UPDATEDSAVED'); + JText::script('COM_COMPONENTBUILDER_SNIPPETS_COULD_NOT_BE_UPDATEDSAVED'); + JText::script('COM_COMPONENTBUILDER_LINK_TO_THE_CONTRIBUTOR'); + JText::script('COM_COMPONENTBUILDER_VIEW_THE_CONTRIBUTOR_DETAILS'); + JText::script('COM_COMPONENTBUILDER_JCB_COMMUNITY'); + JText::script('COM_COMPONENTBUILDER_COMPANY_NAME'); + JText::script('COM_COMPONENTBUILDER_AUTHOR_NAME'); + JText::script('COM_COMPONENTBUILDER_AUTHOR_EMAIL'); + JText::script('COM_COMPONENTBUILDER_AUTHOR_WEBSITE'); + JText::script('COM_COMPONENTBUILDER_THERE_ARE_NO_NEW_SNIPPETS_AT_THIS_TIME'); + JText::script('COM_COMPONENTBUILDER_THERE_ARE_NO_DIVERGED_SNIPPETS_AT_THIS_TIME'); + JText::script('COM_COMPONENTBUILDER_THERE_ARE_NO_AHEAD_SNIPPETS_AT_THIS_TIME'); + JText::script('COM_COMPONENTBUILDER_THERE_ARE_NO_OUT_OF_DATE_SNIPPETS_AT_THIS_TIME'); + JText::script('COM_COMPONENTBUILDER_THERE_ARE_NO_SNIPPETS_TO_UPDATE_AT_THIS_TIME'); + JText::script('COM_COMPONENTBUILDER_AVAILABLE_LIBRARIES'); + JText::script('COM_COMPONENTBUILDER_OPEN_LIBRARY_SNIPPETS'); // add some lang verfy messages $this->document->addScriptDeclaration(" // set the snippet from gitHub @@ -302,7 +302,7 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy //do something special if ('snippets' === ajaxcall) { setTimeout( function() { - jQuery('#snippets-github').html('

'+lang_Community_Snippets+'

'); + jQuery('#snippets-github').html('

'+Joomla.JText._('COM_COMPONENTBUILDER_JCB_COMMUNITY_SNIPPETS')+'

'); jQuery('#snippets-display').show(); jQuery('#snippets-grid').trigger('display.uk.check'); jQuery('#loading').hide(); @@ -362,7 +362,7 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy setLibrary(value); }); setTimeout( function() { - jQuery('#snippets-github').html('

'+lang_Available_Libraries+'

'); + jQuery('#snippets-github').html('

'+Joomla.JText._('COM_COMPONENTBUILDER_AVAILABLE_LIBRARIES')+'

'); jQuery('#libraries-display').show(); jQuery('#libraries-grid').trigger('display.uk.check'); }, 1000); @@ -387,7 +387,7 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy } function setLibButtons(name) { - return ''; + return ''; } // get the snippets @@ -404,7 +404,7 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy fromLocal = false; if (_paths) { setSnippets(_paths, libraryName); - jQuery('#snippets-github').html('

'+lang_Community_Snippets+'

'); + jQuery('#snippets-github').html('

'+Joomla.JText._('COM_COMPONENTBUILDER_JCB_COMMUNITY_SNIPPETS')+'

'); } else { jQuery.get(path) .success(function(paths) { @@ -506,27 +506,27 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy function setDataButtons(snippet, key, status) { var html = '
'; - html += ''; - html += ''; - html += ''; + html += ''; + html += ''; + html += ''; html += '
'; // return data buttons return html; } function setRefButtons(snippet, key, status, keyID) { - var html = '
' + snippet.name + '
'; + var html = '
' + snippet.name + '
'; // set the update button html += '
'; if ('equal' !== status) { if ('new' === status) { - var tooltip = lang_Get_Snippet_New_Tooltip; + var tooltip = Joomla.JText._('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_INSTALL_IT_LOCALLY'); } else { - var tooltip = lang_Get_Snippet_Tooltip; + var tooltip = Joomla.JText._('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_UPDATE_THE_LOCAL_VERSION'); } - html += ''; + html += ''; } else { - html += ''; + html += ''; } html += '
'; // return data buttons @@ -540,7 +540,7 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy } else if (snippet.contributor_name) { var contributor_name = snippet.contributor_name; } else { - var contributor_name = lang_JCB_Community; + var contributor_name = Joomla.JText._('COM_COMPONENTBUILDER_JCB_COMMUNITY'); } // set the contributor url if (snippet.contributor_website) { @@ -551,9 +551,9 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy var contributor_url = 'https://github.com/vdm-io/Joomla-Component-Builder-Snippets'; } var html = '
'; - html += ''; - html += ' ' + contributor_name + ''; - html += ' '+lang_View_Blame+''; + html += ''; + html += ' ' + contributor_name + ''; + html += ' '+Joomla.JText._('COM_COMPONENTBUILDER_VIEW_BLAME')+''; html += '
'; // return contributor buttons return html; @@ -564,31 +564,31 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy // check if there is new items if (bulkItems.new.length === 0) { jQuery('#bulk-button-new').prop('disabled', true); - jQuery('#bulk-button-new').attr('title', lang_Get_Snippets_New_Tooltip); + jQuery('#bulk-button-new').attr('title', Joomla.JText._('COM_COMPONENTBUILDER_THERE_ARE_NO_NEW_SNIPPETS_AT_THIS_TIME')); jQuery('#bulk-notice-new').show(); } // check if there is diverged items if (bulkItems.diverged.length === 0) { jQuery('#bulk-button-diverged').prop('disabled', true); - jQuery('#bulk-button-diverged').attr('title', lang_Get_Snippets_Diverged_Tooltip); + jQuery('#bulk-button-diverged').attr('title', Joomla.JText._('COM_COMPONENTBUILDER_THERE_ARE_NO_DIVERGED_SNIPPETS_AT_THIS_TIME')); jQuery('#bulk-notice-diverged').show(); } // check if there is ahead items if (bulkItems.ahead.length === 0) { jQuery('#bulk-button-ahead').prop('disabled', true); - jQuery('#bulk-button-ahead').attr('title', lang_Get_Snippets_Ahead_Tooltip); + jQuery('#bulk-button-ahead').attr('title', Joomla.JText._('COM_COMPONENTBUILDER_THERE_ARE_NO_AHEAD_SNIPPETS_AT_THIS_TIME')); jQuery('#bulk-notice-ahead').show(); } // check if there is behind items if (bulkItems.behind.length === 0) { jQuery('#bulk-button-behind').prop('disabled', true); - jQuery('#bulk-button-behind').attr('title', lang_Get_Snippets_Behind_Tooltip); + jQuery('#bulk-button-behind').attr('title', Joomla.JText._('COM_COMPONENTBUILDER_THERE_ARE_NO_OUT_OF_DATE_SNIPPETS_AT_THIS_TIME')); jQuery('#bulk-notice-behind').show(); } // check if all we should close the all button if (bulkItems.behind.length === 0 && bulkItems.new.length === 0 && bulkItems.ahead.length === 0 && bulkItems.diverged.length === 0) { jQuery('#bulk-button-all').prop('disabled', true); - jQuery('#bulk-button-all').attr('title', lang_Get_Snippets_All_Tooltip); + jQuery('#bulk-button-all').attr('title', Joomla.JText._('COM_COMPONENTBUILDER_THERE_ARE_NO_SNIPPETS_TO_UPDATE_AT_THIS_TIME')); jQuery('#bulk-notice-all').show(); } } @@ -618,7 +618,7 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy updateSnippetDisplay(keyID, 'equal'); } } else { - UIkit.notify(lang_Update_Error_Tooltip, {status:'danger'}); + UIkit.notify(Joomla.JText._('COM_COMPONENTBUILDER_SNIPPET_COULD_NOT_BE_UPDATEDSAVED'), {status:'danger'}); } }); }, 200); @@ -661,7 +661,7 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy updateSnippetDisplay(keyID, 'equal'); } } else { - UIkit.notify(lang_Update_Error_Tooltip, {status:'danger'}); + UIkit.notify(Joomla.JText._('COM_COMPONENTBUILDER_SNIPPET_COULD_NOT_BE_UPDATEDSAVED'), {status:'danger'}); } }); }); @@ -691,9 +691,9 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy // update button if ('equal' === status) { // update notice - jQuery('#'+keyID+'-getbutton').attr('title', lang_Get_Snippet_Dont_Tooltip); + jQuery('#'+keyID+'-getbutton').attr('title', Joomla.JText._('COM_COMPONENTBUILDER_NO_NEED_TO_GET_IT_SINCE_IT_IS_ALREADY_IN_SYNC_WITH_YOUR_LOCAL_VERSION')); jQuery('#'+keyID+'-getbutton').prop('disabled', true); - jQuery('#'+keyID+'-getbutton').html(' ' + lang_Dont_Get_Snippet); + jQuery('#'+keyID+'-getbutton').html(' ' + Joomla.JText._('COM_COMPONENTBUILDER_LOCAL_SNIPPET')); // counter delay just incase setTimeout(function(){ jQuery('#'+keyID+'-getbutton').prop('disabled', true); @@ -735,13 +735,13 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy html += '

' + snippet.library + ' - (' + snippet.type + ') ' + snippet.name + '

'; if ('contributor' === type) { html += '
'; - html += '
'+lang_Company_Name+'
'; + html += '
'+Joomla.JText._('COM_COMPONENTBUILDER_COMPANY_NAME')+'
'; html += '
'+snippet.contributor_company+'
'; - html += '
'+lang_Author_Name+'
'; + html += '
'+Joomla.JText._('COM_COMPONENTBUILDER_AUTHOR_NAME')+'
'; html += '
'+snippet.contributor_name+'
'; - html += '
'+lang_Author_Email+'
'; + html += '
'+Joomla.JText._('COM_COMPONENTBUILDER_AUTHOR_EMAIL')+'
'; html += '
'+snippet.contributor_email+'
'; - html += '
'+lang_Author_Website+'
'; + html += '
'+Joomla.JText._('COM_COMPONENTBUILDER_AUTHOR_WEBSITE')+'
'; html += '
'+snippet.contributor_website+'
'; html += '
'; } else { diff --git a/admin/views/import_joomla_components/tmpl/default.php b/admin/views/import_joomla_components/tmpl/default.php index 573423f42..68476580a 100644 --- a/admin/views/import_joomla_components/tmpl/default.php +++ b/admin/views/import_joomla_components/tmpl/default.php @@ -159,7 +159,7 @@ jQuery(document).ready(function($) { hasPackage && ComponentbuilderHelper::checkArray($this->headerList) && ComponentbuilderHelper::checkArray($this->headers)) : ?> $this->activeTab)); ?> - +
diff --git a/componentbuilder.xml b/componentbuilder.xml index 224d7756f..596186fec 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 12th December, 2017 + 14th December, 2017 Llewellyn van der Merwe joomla@vdm.io http://vdm.bz/component-builder