{"action":"created","comment":{"url":"https://api.github.com/repos/FluidTYPO3/vhs/pulls/comments/22431561","id":22431561,"diff_hunk":"@@ -0,0 +1,143 @@\n+<?php\r\n+namespace FluidTYPO3\\Vhs\\ViewHelpers\\Language;\r\n+/***************************************************************\r\n+ *  Copyright notice\r\n+ *\r\n+ *  (c) 2015 Cornel Boppart <cornel@bopp-art.com>\r\n+ *\r\n+ *  All rights reserved\r\n+ *\r\n+ *  This script is part of the TYPO3 project. The TYPO3 project is\r\n+ *  free software; you can redistribute it and/or modify\r\n+ *  it under the terms of the GNU General Public License as published by\r\n+ *  the Free Software Foundation; either version 2 of the License, or\r\n+ *  (at your option) any later version.\r\n+ *\r\n+ *  The GNU General Public License can be found at\r\n+ *  http://www.gnu.org/copyleft/gpl.html.\r\n+ *\r\n+ *  This script is distributed in the hope that it will be useful,\r\n+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\n+ *  GNU General Public License for more details.\r\n+ *\r\n+ *  This copyright notice MUST APPEAR in all copies of the script!\r\n+ ***************************************************************/\r\n+\r\n+use \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility;\r\n+use \\TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\AbstractViewHelper;\r\n+\r\n+/**\r\n+ * Language: ReadFile\r\n+ *\r\n+ * Reads a certain language file with returning not just one single label,\r\n+ * but all the translated labels as an array or in JSON format.\r\n+ *\r\n+ * ### Example\r\n+ *\r\n+ *     <!-- Tag usage for force getting labels in a specific language (not current is possible too) -->\r\n+ *     <v:language.readFile extensionName=\"myext\" path=\"Path/To/Locallang.xlf\" languageKey=\"en\"/>\r\n+ \r\n+ *     <!-- Tag usage for getting labels of current language, returned in JSON format -->\r\n+ *     <v:language.readFile extensionName=\"myext\" path=\"Path/To/Locallang.xlf\" returnAsJson=\"TRUE\"/>\r\n+ *\r\n+ * @author\t\tCornel Boppart <cornel@bopp-art.com>\r\n+ * @package\t\tVhs\r\n+ * @subpackage\tViewHelpers\\Language\r\n+ */\r\n+class ReadFileViewHelper extends AbstractViewHelper {\r\n+\r\n+\t/**\r\n+\t * @var\tarray\r\n+\t */\r\n+\tprotected $locallang;\r\n+\r\n+\t/**\r\n+\t * Initializes all arguments\r\n+\t *\r\n+\t * @return void\r\n+\t * @api\r\n+\t */\r\n+\tpublic function initializeArguments() {\r\n+\t\t$this->registerArgument('extensionName', 'string', 'Name of the extension');\r\n+\t\t$this->registerArgument('path', 'string', 'Path to the locallang file');\r\n+\t\t$this->registerArgument('languageKey', NULL, 'The language key to force getting labels from (override)');\r\n+\t\t$this->registerArgument('returnAsJson', FALSE, 'If TRUE, it returns all labels as JSON object');\r\n+\t}\r\n+\r\n+\t/**\r\n+\t * Render method\r\n+\t *\r\n+\t * @return\tarray\r\n+\t */\r\n+\tpublic function render() {\r\n+\t\t// Set key from current language if no key was defined as attribute\r\n+\t\tif ($this->arguments['languageKey'] === NULL) {\r\n+\t\t\t$this->arguments['languageKey'] = self::getCurrentLanguageKey();\r\n+\t\t}\r\n+\r\n+\t\t// Read locallang file\r\n+\t\t$this->locallang = GeneralUtility::readLLfile('EXT:' . strtolower($this->arguments['extensionName']) . '/' . $this->arguments['path'], $this->arguments['languageKey']);\r\n+\t\t$labels = $this->getLabelsByLanguageKey($this->arguments['languageKey']);\r\n+\t\t$labels = $this->getLabelsFromTarget($labels);\r\n+\r\n+\t\t// Encode array to JSON if argument 'returnAsJson' is set to TRUE\r\n+\t\tif ((bool)$this->arguments['returnAsJson'] === TRUE) {\r\n+\t\t\t$labels = json_encode($labels);\r\n+\t\t}\r\n+\r\n+\t\treturn $labels;\r\n+\t}\r\n+\t\r\n+\t/**\r\n+\t * Gets the translated labels by a specific language key\r\n+\t *\r\n+\t * @param\tarray\t$languageKey\tThe language key to get labels from (fallback is 'default')\r\n+\t * @return\tarray\t$labels\r\n+\t */\r\n+\tprotected function getLabelsByLanguageKey($languageKey) {\r\n+\t\tif (!empty($this->locallang[$languageKey])) {\r\n+\t\t\t$labels = $this->locallang[$languageKey];\r\n+\t\t} elseif (!empty($this->locallang['default'])) {\r\n+\t\t\t$labels = $this->locallang['default'];\r\n+\t\t} else {\r\n+\t\t\t$labels = array();\r\n+\t\t}\r\n+\r\n+\t\treturn $labels;\r\n+\t}\r\n+\t\r","path":"Classes/ViewHelpers/Language/ReadFileViewHelper.php","position":90,"original_position":109,"commit_id":"d4ec939ad6ac403f082582e732ae634841442c1c","original_commit_id":"d5b43158c7ef6252055dadc374d5ef1ee5959bff","user":{"login":"NamelessCoder","id":2228052,"avatar_url":"https://avatars.githubusercontent.com/u/2228052?v=3","gravatar_id":"","url":"https://api.github.com/users/NamelessCoder","html_url":"https://github.com/NamelessCoder","followers_url":"https://api.github.com/users/NamelessCoder/followers","following_url":"https://api.github.com/users/NamelessCoder/following{/other_user}","gists_url":"https://api.github.com/users/NamelessCoder/gists{/gist_id}","starred_url":"https://api.github.com/users/NamelessCoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NamelessCoder/subscriptions","organizations_url":"https://api.github.com/users/NamelessCoder/orgs","repos_url":"https://api.github.com/users/NamelessCoder/repos","events_url":"https://api.github.com/users/NamelessCoder/events{/privacy}","received_events_url":"https://api.github.com/users/NamelessCoder/received_events","type":"User","site_admin":false},"body":"Whitespace found at end of line","created_at":"2015-01-03T13:54:09Z","updated_at":"2015-01-03T13:54:09Z","html_url":"https://github.com/FluidTYPO3/vhs/pull/746#discussion_r22431561","pull_request_url":"https://api.github.com/repos/FluidTYPO3/vhs/pulls/746","_links":{"self":{"href":"https://api.github.com/repos/FluidTYPO3/vhs/pulls/comments/22431561"},"html":{"href":"https://github.com/FluidTYPO3/vhs/pull/746#discussion_r22431561"},"pull_request":{"href":"https://api.github.com/repos/FluidTYPO3/vhs/pulls/746"}}},"pull_request":{"url":"https://api.github.com/repos/FluidTYPO3/vhs/pulls/746","id":26782914,"html_url":"https://github.com/FluidTYPO3/vhs/pull/746","diff_url":"https://github.com/FluidTYPO3/vhs/pull/746.diff","patch_url":"https://github.com/FluidTYPO3/vhs/pull/746.patch","issue_url":"https://api.github.com/repos/FluidTYPO3/vhs/issues/746","number":746,"state":"open","locked":false,"title":"[FEATURE] New language viewhelper for reading a full language file","user":{"login":"cbopp-art","id":2764787,"avatar_url":"https://avatars.githubusercontent.com/u/2764787?v=3","gravatar_id":"","url":"https://api.github.com/users/cbopp-art","html_url":"https://github.com/cbopp-art","followers_url":"https://api.github.com/users/cbopp-art/followers","following_url":"https://api.github.com/users/cbopp-art/following{/other_user}","gists_url":"https://api.github.com/users/cbopp-art/gists{/gist_id}","starred_url":"https://api.github.com/users/cbopp-art/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbopp-art/subscriptions","organizations_url":"https://api.github.com/users/cbopp-art/orgs","repos_url":"https://api.github.com/users/cbopp-art/repos","events_url":"https://api.github.com/users/cbopp-art/events{/privacy}","received_events_url":"https://api.github.com/users/cbopp-art/received_events","type":"User","site_admin":false},"body":"This is a new ViewHelper which reads a full language file and returns all the translated labels from. ```extensionName``` and ```path``` must be defined, where ```languageKey``` and ```returnAsJson``` just are optional arguments.\r\nWith defining a specific language key (e.g. 'de') it forces to get all those translated labels. Otherwise, if the language key isn't defined, it would take the currently initialized language.\r\nThe reason to have the possibility returning labels as a JSON object basically is for providing those labels via javascript in frontend.\r\nOf course, there is already a Format/Json ViewHelper available. But in my opinion, it may would be less performant or convenient for integrators respectively to wrap this viewhelper tag additionally before they can apply it as content of an asset.script viewhelper for instance.","created_at":"2015-01-03T13:38:38Z","updated_at":"2015-01-03T13:54:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f2e6a0e533786e9df87135c1b7f9b11088c1e7b5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/FluidTYPO3/vhs/pulls/746/commits","review_comments_url":"https://api.github.com/repos/FluidTYPO3/vhs/pulls/746/comments","review_comment_url":"https://api.github.com/repos/FluidTYPO3/vhs/pulls/comments/{number}","comments_url":"https://api.github.com/repos/FluidTYPO3/vhs/issues/746/comments","statuses_url":"https://api.github.com/repos/FluidTYPO3/vhs/statuses/d4ec939ad6ac403f082582e732ae634841442c1c","head":{"label":"cbopp-art:development","ref":"development","sha":"d4ec939ad6ac403f082582e732ae634841442c1c","user":{"login":"cbopp-art","id":2764787,"avatar_url":"https://avatars.githubusercontent.com/u/2764787?v=3","gravatar_id":"","url":"https://api.github.com/users/cbopp-art","html_url":"https://github.com/cbopp-art","followers_url":"https://api.github.com/users/cbopp-art/followers","following_url":"https://api.github.com/users/cbopp-art/following{/other_user}","gists_url":"https://api.github.com/users/cbopp-art/gists{/gist_id}","starred_url":"https://api.github.com/users/cbopp-art/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbopp-art/subscriptions","organizations_url":"https://api.github.com/users/cbopp-art/orgs","repos_url":"https://api.github.com/users/cbopp-art/repos","events_url":"https://api.github.com/users/cbopp-art/events{/privacy}","received_events_url":"https://api.github.com/users/cbopp-art/received_events","type":"User","site_admin":false},"repo":{"id":28742329,"name":"vhs","full_name":"cbopp-art/vhs","owner":{"login":"cbopp-art","id":2764787,"avatar_url":"https://avatars.githubusercontent.com/u/2764787?v=3","gravatar_id":"","url":"https://api.github.com/users/cbopp-art","html_url":"https://github.com/cbopp-art","followers_url":"https://api.github.com/users/cbopp-art/followers","following_url":"https://api.github.com/users/cbopp-art/following{/other_user}","gists_url":"https://api.github.com/users/cbopp-art/gists{/gist_id}","starred_url":"https://api.github.com/users/cbopp-art/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbopp-art/subscriptions","organizations_url":"https://api.github.com/users/cbopp-art/orgs","repos_url":"https://api.github.com/users/cbopp-art/repos","events_url":"https://api.github.com/users/cbopp-art/events{/privacy}","received_events_url":"https://api.github.com/users/cbopp-art/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cbopp-art/vhs","description":"TYPO3 extension VHS: Fluid ViewHelpers","fork":true,"url":"https://api.github.com/repos/cbopp-art/vhs","forks_url":"https://api.github.com/repos/cbopp-art/vhs/forks","keys_url":"https://api.github.com/repos/cbopp-art/vhs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cbopp-art/vhs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cbopp-art/vhs/teams","hooks_url":"https://api.github.com/repos/cbopp-art/vhs/hooks","issue_events_url":"https://api.github.com/repos/cbopp-art/vhs/issues/events{/number}","events_url":"https://api.github.com/repos/cbopp-art/vhs/events","assignees_url":"https://api.github.com/repos/cbopp-art/vhs/assignees{/user}","branches_url":"https://api.github.com/repos/cbopp-art/vhs/branches{/branch}","tags_url":"https://api.github.com/repos/cbopp-art/vhs/tags","blobs_url":"https://api.github.com/repos/cbopp-art/vhs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cbopp-art/vhs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cbopp-art/vhs/git/refs{/sha}","trees_url":"https://api.github.com/repos/cbopp-art/vhs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cbopp-art/vhs/statuses/{sha}","languages_url":"https://api.github.com/repos/cbopp-art/vhs/languages","stargazers_url":"https://api.github.com/repos/cbopp-art/vhs/stargazers","contributors_url":"https://api.github.com/repos/cbopp-art/vhs/contributors","subscribers_url":"https://api.github.com/repos/cbopp-art/vhs/subscribers","subscription_url":"https://api.github.com/repos/cbopp-art/vhs/subscription","commits_url":"https://api.github.com/repos/cbopp-art/vhs/commits{/sha}","git_commits_url":"https://api.github.com/repos/cbopp-art/vhs/git/commits{/sha}","comments_url":"https://api.github.com/repos/cbopp-art/vhs/comments{/number}","issue_comment_url":"https://api.github.com/repos/cbopp-art/vhs/issues/comments/{number}","contents_url":"https://api.github.com/repos/cbopp-art/vhs/contents/{+path}","compare_url":"https://api.github.com/repos/cbopp-art/vhs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cbopp-art/vhs/merges","archive_url":"https://api.github.com/repos/cbopp-art/vhs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cbopp-art/vhs/downloads","issues_url":"https://api.github.com/repos/cbopp-art/vhs/issues{/number}","pulls_url":"https://api.github.com/repos/cbopp-art/vhs/pulls{/number}","milestones_url":"https://api.github.com/repos/cbopp-art/vhs/milestones{/number}","notifications_url":"https://api.github.com/repos/cbopp-art/vhs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cbopp-art/vhs/labels{/name}","releases_url":"https://api.github.com/repos/cbopp-art/vhs/releases{/id}","created_at":"2015-01-03T11:43:02Z","updated_at":"2015-01-03T13:54:05Z","pushed_at":"2015-01-03T13:54:05Z","git_url":"git://github.com/cbopp-art/vhs.git","ssh_url":"git@github.com:cbopp-art/vhs.git","clone_url":"https://github.com/cbopp-art/vhs.git","svn_url":"https://github.com/cbopp-art/vhs","homepage":"http://fluidtypo3.org","size":2949,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"development"}},"base":{"label":"FluidTYPO3:development","ref":"development","sha":"feec8a1c570b21166049e6c1bc9fb9656aaa5729","user":{"login":"FluidTYPO3","id":3912401,"avatar_url":"https://avatars.githubusercontent.com/u/3912401?v=3","gravatar_id":"","url":"https://api.github.com/users/FluidTYPO3","html_url":"https://github.com/FluidTYPO3","followers_url":"https://api.github.com/users/FluidTYPO3/followers","following_url":"https://api.github.com/users/FluidTYPO3/following{/other_user}","gists_url":"https://api.github.com/users/FluidTYPO3/gists{/gist_id}","starred_url":"https://api.github.com/users/FluidTYPO3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FluidTYPO3/subscriptions","organizations_url":"https://api.github.com/users/FluidTYPO3/orgs","repos_url":"https://api.github.com/users/FluidTYPO3/repos","events_url":"https://api.github.com/users/FluidTYPO3/events{/privacy}","received_events_url":"https://api.github.com/users/FluidTYPO3/received_events","type":"Organization","site_admin":false},"repo":{"id":6505090,"name":"vhs","full_name":"FluidTYPO3/vhs","owner":{"login":"FluidTYPO3","id":3912401,"avatar_url":"https://avatars.githubusercontent.com/u/3912401?v=3","gravatar_id":"","url":"https://api.github.com/users/FluidTYPO3","html_url":"https://github.com/FluidTYPO3","followers_url":"https://api.github.com/users/FluidTYPO3/followers","following_url":"https://api.github.com/users/FluidTYPO3/following{/other_user}","gists_url":"https://api.github.com/users/FluidTYPO3/gists{/gist_id}","starred_url":"https://api.github.com/users/FluidTYPO3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FluidTYPO3/subscriptions","organizations_url":"https://api.github.com/users/FluidTYPO3/orgs","repos_url":"https://api.github.com/users/FluidTYPO3/repos","events_url":"https://api.github.com/users/FluidTYPO3/events{/privacy}","received_events_url":"https://api.github.com/users/FluidTYPO3/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FluidTYPO3/vhs","description":"TYPO3 extension VHS: Fluid ViewHelpers","fork":false,"url":"https://api.github.com/repos/FluidTYPO3/vhs","forks_url":"https://api.github.com/repos/FluidTYPO3/vhs/forks","keys_url":"https://api.github.com/repos/FluidTYPO3/vhs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FluidTYPO3/vhs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FluidTYPO3/vhs/teams","hooks_url":"https://api.github.com/repos/FluidTYPO3/vhs/hooks","issue_events_url":"https://api.github.com/repos/FluidTYPO3/vhs/issues/events{/number}","events_url":"https://api.github.com/repos/FluidTYPO3/vhs/events","assignees_url":"https://api.github.com/repos/FluidTYPO3/vhs/assignees{/user}","branches_url":"https://api.github.com/repos/FluidTYPO3/vhs/branches{/branch}","tags_url":"https://api.github.com/repos/FluidTYPO3/vhs/tags","blobs_url":"https://api.github.com/repos/FluidTYPO3/vhs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FluidTYPO3/vhs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FluidTYPO3/vhs/git/refs{/sha}","trees_url":"https://api.github.com/repos/FluidTYPO3/vhs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FluidTYPO3/vhs/statuses/{sha}","languages_url":"https://api.github.com/repos/FluidTYPO3/vhs/languages","stargazers_url":"https://api.github.com/repos/FluidTYPO3/vhs/stargazers","contributors_url":"https://api.github.com/repos/FluidTYPO3/vhs/contributors","subscribers_url":"https://api.github.com/repos/FluidTYPO3/vhs/subscribers","subscription_url":"https://api.github.com/repos/FluidTYPO3/vhs/subscription","commits_url":"https://api.github.com/repos/FluidTYPO3/vhs/commits{/sha}","git_commits_url":"https://api.github.com/repos/FluidTYPO3/vhs/git/commits{/sha}","comments_url":"https://api.github.com/repos/FluidTYPO3/vhs/comments{/number}","issue_comment_url":"https://api.github.com/repos/FluidTYPO3/vhs/issues/comments/{number}","contents_url":"https://api.github.com/repos/FluidTYPO3/vhs/contents/{+path}","compare_url":"https://api.github.com/repos/FluidTYPO3/vhs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FluidTYPO3/vhs/merges","archive_url":"https://api.github.com/repos/FluidTYPO3/vhs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FluidTYPO3/vhs/downloads","issues_url":"https://api.github.com/repos/FluidTYPO3/vhs/issues{/number}","pulls_url":"https://api.github.com/repos/FluidTYPO3/vhs/pulls{/number}","milestones_url":"https://api.github.com/repos/FluidTYPO3/vhs/milestones{/number}","notifications_url":"https://api.github.com/repos/FluidTYPO3/vhs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FluidTYPO3/vhs/labels{/name}","releases_url":"https://api.github.com/repos/FluidTYPO3/vhs/releases{/id}","created_at":"2012-11-02T11:19:14Z","updated_at":"2014-12-19T13:57:43Z","pushed_at":"2014-12-19T13:57:42Z","git_url":"git://github.com/FluidTYPO3/vhs.git","ssh_url":"git@github.com:FluidTYPO3/vhs.git","clone_url":"https://github.com/FluidTYPO3/vhs.git","svn_url":"https://github.com/FluidTYPO3/vhs","homepage":"http://fluidtypo3.org","size":12533,"stargazers_count":72,"watchers_count":72,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":92,"mirror_url":null,"open_issues_count":7,"forks":92,"open_issues":7,"watchers":72,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/FluidTYPO3/vhs/pulls/746"},"html":{"href":"https://github.com/FluidTYPO3/vhs/pull/746"},"issue":{"href":"https://api.github.com/repos/FluidTYPO3/vhs/issues/746"},"comments":{"href":"https://api.github.com/repos/FluidTYPO3/vhs/issues/746/comments"},"review_comments":{"href":"https://api.github.com/repos/FluidTYPO3/vhs/pulls/746/comments"},"review_comment":{"href":"https://api.github.com/repos/FluidTYPO3/vhs/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/FluidTYPO3/vhs/pulls/746/commits"},"statuses":{"href":"https://api.github.com/repos/FluidTYPO3/vhs/statuses/d4ec939ad6ac403f082582e732ae634841442c1c"}}}}