extranet/application/views/default/helpers/JavascriptHelper.php

28 lines
1.0 KiB
PHP
Raw Normal View History

<?php
2011-08-18 15:23:25 +00:00
class Zend_View_Helper_JavascriptHelper extends Zend_View_Helper_Abstract
{
function javascriptHelper()
{
2011-08-18 15:23:25 +00:00
$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);
2011-08-18 15:23:25 +00:00
}
}
}