|
From: <gem...@li...> - 2012-11-09 12:13:59
|
Revision: 1009
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1009&view=rev
Author: matijsdejong
Date: 2012-11-09 12:13:47 +0000 (Fri, 09 Nov 2012)
Log Message:
-----------
Fix for HtmlElement.php '0' was not seen as content.
Speed improvement: removed __call() use in standard Zend_Translate Traits
Modified Paths:
--------------
trunk/library/classes/Gems/Default/SurveyAction.php
trunk/library/classes/Gems/Export/ExportAbstract.php
trunk/library/classes/Gems/Export/RespondentExport.php
trunk/library/classes/Gems/Menu/MenuAbstract.php
trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php
trunk/library/classes/GemsEscort.php
trunk/library/classes/MUtil/Controller/Action.php
trunk/library/classes/MUtil/Html/HtmlElement.php
trunk/library/classes/MUtil/Snippets/SnippetAbstract.php
Modified: trunk/library/classes/Gems/Default/SurveyAction.php
===================================================================
--- trunk/library/classes/Gems/Default/SurveyAction.php 2012-11-09 11:30:20 UTC (rev 1008)
+++ trunk/library/classes/Gems/Default/SurveyAction.php 2012-11-09 12:13:47 UTC (rev 1009)
@@ -56,33 +56,41 @@
public $trackType = 'S';
+ /**
+ * Overrules specific translations for this action
+ *
+ * @param string $text Translation string
+ * @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with locale
+ * identifier, @see Zend_Locale for more information
+ * @return string
+ */
public function _($text, $locale = null)
{
// Thanks to Potemkin adapter there is always a translate variable in MUtil_Controller_Action
switch ($text) {
case 'Add track':
- return $this->translate->_('Add survey', $locale);
+ return $this->translate->getAdapter()->_('Add survey', $locale);
case 'Add another %s track':
- return $this->translate->_('Add another %s survey', $locale);
+ return $this->translate->getAdapter()->_('Add another %s survey', $locale);
case 'Adding the %s track to respondent %s':
- return $this->translate->_('Adding the %s survey to respondent %s', $locale);
+ return $this->translate->getAdapter()->_('Adding the %s survey to respondent %s', $locale);
case 'Available tracks':
- return $this->translate->_('Available surveys', $locale);
+ return $this->translate->getAdapter()->_('Available surveys', $locale);
case 'No tracks found':
- return $this->translate->_('No surveys found', $locale);
+ return $this->translate->getAdapter()->_('No surveys found', $locale);
case 'Overview of %s track for respondent %s: %s':
- return $this->translate->_('Overview of %s survey for respondent %s: %s', $locale);
+ return $this->translate->getAdapter()->_('Overview of %s survey for respondent %s: %s', $locale);
case 'This track is currently not assigned to this respondent.':
- return $this->translate->_('This survey has not been assigned to this respondent.', $locale);
+ return $this->translate->getAdapter()->_('This survey has not been assigned to this respondent.', $locale);
case 'Track %s does not exist.':
- return $this->translate->_('Survey %s does not exist.', $locale);
+ return $this->translate->getAdapter()->_('Survey %s does not exist.', $locale);
default:
return parent::_($text, $locale);
Modified: trunk/library/classes/Gems/Export/ExportAbstract.php
===================================================================
--- trunk/library/classes/Gems/Export/ExportAbstract.php 2012-11-09 11:30:20 UTC (rev 1008)
+++ trunk/library/classes/Gems/Export/ExportAbstract.php 2012-11-09 12:13:47 UTC (rev 1009)
@@ -79,6 +79,6 @@
*/
public function _($text, $locale = null)
{
- return $this->translate->_($text, $locale);
+ return $this->translate->getAdapter()->_($text, $locale);
}
}
\ No newline at end of file
Modified: trunk/library/classes/Gems/Export/RespondentExport.php
===================================================================
--- trunk/library/classes/Gems/Export/RespondentExport.php 2012-11-09 11:30:20 UTC (rev 1008)
+++ trunk/library/classes/Gems/Export/RespondentExport.php 2012-11-09 12:13:47 UTC (rev 1009)
@@ -2,7 +2,7 @@
/**
* Copyright (c) 2011, Erasmus MC
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
@@ -13,7 +13,7 @@
* * Neither the name of Erasmus MC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -52,21 +52,21 @@
* @var GemsEscort
*/
public $escort;
-
+
protected $html;
-
+
/**
*
* @var Gems_Loader
*/
public $loader;
-
+
/**
*
* @var Gems_Project_ProjectSettings
*/
public $project;
-
+
/**
* @var Zend_Translate_Adapter
*/
@@ -79,7 +79,7 @@
public $util;
public $view;
-
+
/**
* @var Gems_Pdf
*/
@@ -88,13 +88,24 @@
public function afterRegistry()
{
parent::afterRegistry();
-
+
$this->_pdf = $this->loader->getPdf();
}
-
+
+ /**
+ * Copy from Zend_Translate_Adapter
+ *
+ * Translates the given string
+ * returns the translation
+ *
+ * @param string $text Translation string
+ * @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with locale
+ * identifier, @see Zend_Locale for more information
+ * @return string
+ */
public function _($messageid, $locale = null)
{
- return $this->translate->_($messageid, $locale);
+ return $this->translate->getAdapter()->_($messageid, $locale);
}
/**
@@ -125,7 +136,7 @@
if ($token->getReceptionCode()->isSuccess()) {
return true;
}
-
+
return false;
}
@@ -178,7 +189,7 @@
}
}
- if ($showToken) {
+ if ($showToken) {
$params = array(
'token' => $token,
'tokenId' => $token->getTokenId(),
@@ -187,16 +198,16 @@
'showSelected' => false,
'showTakeButton' => false,
'grouped' => $groupSurveys);
-
+
$snippets = $token->getAnswerSnippetNames();
-
+
if (is_array($snippets)) {
list($snippets, $snippetParams) = MUtil_Ra::keySplit($snippets);
$params = $params + $snippetParams;
}
-
+
$this->html->snippet('Export_SurveyHeaderSnippet', 'token', $token);
-
+
foreach($snippets as $snippet) {
$this->html->snippet($snippet, $params);
}
@@ -288,7 +299,7 @@
$this->_exportTrack($track);
}
}
-
+
/**
* Constructs the form
*
Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php
===================================================================
--- trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-11-09 11:30:20 UTC (rev 1008)
+++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-11-09 12:13:47 UTC (rev 1009)
@@ -56,9 +56,20 @@
protected $_subItems;
+ /**
+ * Copy from Zend_Translate_Adapter
+ *
+ * Translates the given string
+ * returns the translation
+ *
+ * @param string $text Translation string
+ * @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with locale
+ * identifier, @see Zend_Locale for more information
+ * @return string
+ */
public function _($text, $locale = null)
{
- return $this->escort->translate->_($text, $locale);
+ return $this->escort->translate->getAdapter()->_($text, $locale);
}
public function __construct(GemsEscort $escort)
@@ -604,6 +615,26 @@
abstract public function isVisible();
/**
+ * Copy from Zend_Translate_Adapter
+ *
+ * Translates the given string using plural notations
+ * Returns the translated string
+ *
+ * @see Zend_Locale
+ * @param string $singular Singular translation string
+ * @param string $plural Plural translation string
+ * @param integer $number Number for detecting the correct plural
+ * @param string|Zend_Locale $locale (Optional) Locale/Language to use, identical with
+ * locale identifier, @see Zend_Locale for more information
+ * @return string
+ */
+ public function plural($singular, $plural, $number, $locale = null)
+ {
+ $args = func_get_args();
+ return call_user_func_array(array($this->escort->translate->getAdapter(), 'plural'), $args);
+ }
+
+ /**
* Make sure only the active branch is visible
*
* @param array $activeBranch Of Gems_Menu_Menu Abstract items
Modified: trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php
===================================================================
--- trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2012-11-09 11:30:20 UTC (rev 1008)
+++ trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2012-11-09 12:13:47 UTC (rev 1009)
@@ -130,7 +130,7 @@
*/
public function _($text, $locale = null)
{
- return $this->translate->_($text, $locale);
+ return $this->translate->getAdapter()->_($text, $locale);
}
/**
Modified: trunk/library/classes/GemsEscort.php
===================================================================
--- trunk/library/classes/GemsEscort.php 2012-11-09 11:30:20 UTC (rev 1008)
+++ trunk/library/classes/GemsEscort.php 2012-11-09 12:13:47 UTC (rev 1009)
@@ -66,13 +66,24 @@
*/
public $menu;
+ /**
+ * Copy from Zend_Translate_Adapter
+ *
+ * Translates the given string
+ * returns the translation
+ *
+ * @param string $text Translation string
+ * @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with locale
+ * identifier, @see Zend_Locale for more information
+ * @return string
+ */
public function _($text, $locale = null)
{
if (! isset($this->request)) {
// Locale is fixed by request.
$this->setException(new Gems_Exception_Coding('Requested translation before request was made available.'));
}
- return $this->translate->_($text, $locale);
+ return $this->translate->getAdapter()->_($text, $locale);
}
/**
@@ -1456,6 +1467,26 @@
}
/**
+ * Copy from Zend_Translate_Adapter
+ *
+ * Translates the given string using plural notations
+ * Returns the translated string
+ *
+ * @see Zend_Locale
+ * @param string $singular Singular translation string
+ * @param string $plural Plural translation string
+ * @param integer $number Number for detecting the correct plural
+ * @param string|Zend_Locale $locale (Optional) Locale/Language to use, identical with
+ * locale identifier, @see Zend_Locale for more information
+ * @return string
+ */
+ public function plural($singular, $plural, $number, $locale = null)
+ {
+ $args = func_get_args();
+ return call_user_func_array(array($this->translate->getAdapter(), 'plural'), $args);
+ }
+
+ /**
* Hook 8: Start of dispatchLoop. Called before an action is dispatched
* by Zend_Controller_Dispatcher.
*
Modified: trunk/library/classes/MUtil/Controller/Action.php
===================================================================
--- trunk/library/classes/MUtil/Controller/Action.php 2012-11-09 11:30:20 UTC (rev 1008)
+++ trunk/library/classes/MUtil/Controller/Action.php 2012-11-09 12:13:47 UTC (rev 1009)
@@ -138,7 +138,7 @@
*/
public function _($text, $locale = null)
{
- return $this->translate->_($text, $locale);
+ return $this->translate->getAdapter()->_($text, $locale);
}
/**
@@ -483,7 +483,7 @@
public function plural($singular, $plural, $number, $locale = null)
{
$args = func_get_args();
- return call_user_func_array(array($this->translate, 'plural'), $args);
+ return call_user_func_array(array($this->translate->getAdapter(), 'plural'), $args);
}
/* currently not in use
Modified: trunk/library/classes/MUtil/Html/HtmlElement.php
===================================================================
--- trunk/library/classes/MUtil/Html/HtmlElement.php 2012-11-09 11:30:20 UTC (rev 1008)
+++ trunk/library/classes/MUtil/Html/HtmlElement.php 2012-11-09 12:13:47 UTC (rev 1009)
@@ -1068,8 +1068,11 @@
return $html;
}
- } elseif ($content = $renderer->renderAny($view, $this->_content)) {
- return $content;
+ } else {
+ $content = $renderer->renderAny($view, $this->_content);
+ if (strlen($content)) {
+ return $content;
+ }
}
}
Modified: trunk/library/classes/MUtil/Snippets/SnippetAbstract.php
===================================================================
--- trunk/library/classes/MUtil/Snippets/SnippetAbstract.php 2012-11-09 11:30:20 UTC (rev 1008)
+++ trunk/library/classes/MUtil/Snippets/SnippetAbstract.php 2012-11-09 12:13:47 UTC (rev 1009)
@@ -102,7 +102,7 @@
*/
public function _($text, $locale = null)
{
- return $this->translate->_($text, $locale);
+ return $this->translate->getAdapter()->_($text, $locale);
}
/**
@@ -230,7 +230,7 @@
public function plural($singular, $plural, $number, $locale = null)
{
$args = func_get_args();
- return call_user_func_array(array($this->translate, 'plural'), $args);
+ return call_user_func_array(array($this->translate->getAdapter(), 'plural'), $args);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|