Exemplo n.º 1
0
    /**
     * Hook callback function for TemplateManager::display
     * @param $hookName string
     * @param $args array
     * @return boolean
     */
    function displayCallback($hookName, $args)
    {
        // Only pages can receive scripts
        $request =& Registry::get('request');
        if (!is_a($request->getRouter(), 'PKPPageRouter')) {
            return null;
        }
        $page = Request::getRequestedPage();
        $op = Request::getRequestedOp();
        $scripts = JQueryPlugin::getEnabledScripts($page, $op);
        if (empty($scripts)) {
            return null;
        }
        $templateManager =& $args[0];
        $additionalHeadData = $templateManager->get_template_vars('additionalHeadData');
        $baseUrl = $templateManager->get_template_vars('baseUrl');
        if (Config::getVar('general', 'enable_cdn')) {
            $jQueryScript = '<script src="http://www.google.com/jsapi"></script>
			<script>
				google.load("jquery", "1");
				google.load("jqueryui", "1");
			</script>';
        } else {
            $jQueryScript = '<script type="text/javascript" src="' . Request::getBaseUrl() . '/lib/pkp/js/lib/jquery/jquery.min.js"></script>
			<script type="text/javascript" src="' . Request::getBaseUrl() . '/lib/pkp/js/lib/jquery/plugins/jqueryUi.min.js"></script>';
        }
        $jQueryScript .= "\n" . JQueryPlugin::addScripts($baseUrl, $scripts);
        $templateManager->assign('additionalHeadData', $additionalHeadData . "\n" . $jQueryScript);
    }
Exemplo n.º 2
0
 /**
  * Hook callback function for TemplateManager::display
  * @param $hookName string
  * @param $args array
  * @return boolean
  */
 function displayCallback($hookName, $args)
 {
     $page = Request::getRequestedPage();
     $op = Request::getRequestedOp();
     $scripts = JQueryPlugin::getEnabledScripts($page, $op);
     if (empty($scripts)) {
         return null;
     }
     $templateManager =& $args[0];
     $additionalHeadData = $templateManager->get_template_vars('additionalHeadData');
     $baseUrl = $templateManager->get_template_vars('baseUrl');
     $jQueryScript = JQueryPlugin::addScripts($baseUrl, $scripts);
     $templateManager->assign('additionalHeadData', $additionalHeadData . "\n" . $jQueryScript);
 }