extranet/application/views/default/helpers/JavascriptHelper.php
2012-11-19 15:53:10 +00:00

28 lines
1.0 KiB
PHP

<?php
class Zend_View_Helper_JavascriptHelper extends Zend_View_Helper_Abstract
{
function javascriptHelper()
{
$request = Zend_Controller_Front::getInstance()->getRequest();
$controller = $request->getControllerName();
$action = $request->getActionName();
$paramsTheme = Zend_Registry::get('theme');
$fileController = APPLICATION_PATH . '/../public/' .
$paramsTheme->pathScript . '/' . $controller . '.js';
if ( file_exists($fileController) ) {
$contentScript = file_get_contents($fileController);
$view->inlineScript()->appendScript($contentScript);
}
$fileControllerAction = APPLICATION_PATH . '/../public/' .
$paramsTheme->pathScript . '/' . $controller . '-' . $action . '.js';
if ( file_exists($fileControllerAction) ) {
$contentScript = file_get_contents($fileControllerAction);
$view->inlineScript()->appendScript($contentScript);
}
}
}