Skip to content
Snippets Groups Projects
Commit be5b9674 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

clean baseHelper

parent 8ca071f4
Branches
Tags
4 merge requests!2334Master,!2102#57574 : correction orthographe des jours de la semaine,!2078Sandbox upgrade form buttons,!2066Sandbox upgrade form buttons
Pipeline #746 failed with stage
in 8 minutes and 28 seconds
......@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
trait Trait_Translator {
......@@ -30,6 +30,7 @@ trait Trait_Translator {
return $this->_($libelle);
}
/**
* @return Zend_Translate
*/
......@@ -39,12 +40,18 @@ trait Trait_Translator {
return $this->_translate;
}
public function translate() {
return $this->_translate();
}
/**
* @return string
*/
public function _() {
$args = func_get_args();
if ('' == $args[0])
if ('' == $args[0])
return '';
return call_user_func_array(array($this->_translate(), '_'), $args);
}
......
......@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_BaseHelper extends Zend_View_Helper_HtmlElement {
protected static $_translate;
use Trait_Translator;
public function __construct() {
$this->init();
......@@ -29,63 +29,12 @@ class ZendAfi_View_Helper_BaseHelper extends Zend_View_Helper_HtmlElement {
public function init() {}
/**
* @param string $libelle
* @return string
*/
public function traduire($libelle) {
return $this->view->traduire($libelle);
}
/**
* @return Zend_View_Interface
*/
public function getView() {
return $this->view;
}
/**
* @param string $js_function
* @return string
*/
public function addLoadEvent($js_function) {
$html = '<script type="text/javascript">';
$html .= '$(document).ready('.$js_function.')';
$html .= '</script>';
return $html;
}
/**
* @param string $js_function
* @return string
*/
public function addUnloadEvent($js_function) {
$html = '<script type="text/javascript">';
$html .= '$(document).unload('.$js_function.')';
$html .= '</script>';
return $html;
}
protected function _tag() {
return call_user_func_array([$this->view, 'tag'], func_get_args());
}
protected function _() {
return call_user_func_array([$this->view, '_'], func_get_args());
}
/**
* @return Zend_Translate
*/
public static function translate() {
if (!isset(self::$_translate))
self::$_translate = Zend_Registry::get('translate');
return self::$_translate;
}
}
\ No newline at end of file
......@@ -16,16 +16,31 @@
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_MapEvents extends ZendAfi_View_Helper_BaseHelper {
/*Ajoute le chargement / déchargement des javascripts pour Google Maps*/
public function mapEvents() {
$html = $this->addLoadEvent("init_carte");
$html .= $this->addLoadEvent("controle_clef");
$html .= $this->addUnloadEvent("GUnload");
$html = $this->_addLoadEvent("init_carte");
$html .= $this->_addLoadEvent("controle_clef");
$html .= $this->_addUnloadEvent("GUnload");
return $html;
}
protected function _addLoadEvent($js_function) {
$html = '<script type="text/javascript">';
$html .= '$(document).ready('.$js_function.')';
$html .= '</script>';
return $html;
}
protected function _addUnloadEvent($js_function) {
$html = '<script type="text/javascript">';
$html .= '$(document).unload('.$js_function.')';
$html .= '</script>';
return $html;
}
}
?>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment