* application.
* @param array $options Additional options:
* <pre>
- * 'direct' - (boolean) Include the file directly without passing it
- * through javascript.php.
- * DEFAULT: true
* 'external' - (boolean) Treat $file as an external URL.
* DEFAULT: $file is located in the app's js/ directory.
* 'full' - (boolean) Output a full URL
{
$hsf = $GLOBALS['injector']->getInstance('Horde_Script_Files');
if (empty($options['external'])) {
- $hsf->add($file, $app, isset($options['direct']) ? $options['direct'] : true, !empty($options['full']));
+ $hsf->add($file, $app, !empty($options['full']));
} else {
$hsf->addExternal($file, $app);
}
* Adds the javascript code to the output (if output has already started)
* or to the list of script files to include.
*
- * @param string $file The full javascript file name.
- * @param string $app The application name. Defaults to the current
- * application.
- * @param boolean $direct Include the file directly without passing it
- * through javascript.php?
- * @param boolean $full Output a full url?
+ * @param string $file The full javascript file name.
+ * @param string $app The application name. Defaults to the current
+ * application.
+ * @param boolean $full Output a full url?
*/
- public function add($file, $app = null, $direct = false, $full = false)
+ public function add($file, $app = null, $full = false)
{
- if (($this->_add($file, $app, $direct, $full) === false) ||
+ if (($this->_add($file, $app, $full) === false) ||
!Horde::contentSent()) {
return;
}
*
* @return boolean True if the file needs to be output.
*/
- public function _add($file, $app, $direct, $full)
+ public function _add($file, $app, $full)
{
global $registry;
Horde::addInlineScript('Horde.popup_block_text=' . Horde_Serialize::serialize(_("A popup window could not be opened. Your browser may be blocking popups."), Horde_Serialize::JSON), 'dom');
}
- // Explicitly check for a directly serve-able version of the script.
- $path = $registry->get('fileroot', $app);
- if (!$direct &&
- file_exists($file[0] == '/'
- ? $path . $file
- : $registry->get('jsfs', $app) . '/' . $file)) {
- $direct = true;
- }
-
- if ($direct) {
- if ($file[0] == '/') {
- $url = Horde::url($registry->get('webroot', $app) . $file,
- $full, -1);
- } else {
- $url = Horde::url($registry->get('jsuri', $app) . '/' . $file,
- $full, -1);
- $path = $registry->get('jsfs', $app) . '/';
- }
-
+ if ($file[0] == '/') {
+ $url = Horde::url($registry->get('webroot', $app) . $file, $full, -1);
+ $path = $registry->get('fileroot', $app);
} else {
- $path = $registry->get('templates', $app) . '/javascript/';
- $url = Horde::url(
- Horde_Util::addParameter(
- $registry->get('webroot', 'horde') . '/services/javascript.php',
- array('file' => $file, 'app' => $app)));
+ $url = Horde::url($registry->get('jsuri', $app) . '/' . $file, $full, -1);
+ $path = $registry->get('jsfs', $app) . '/';
}
$this->_files[$app][] = array(
+ 'd' => true,
'f' => $file,
- 'd' => $direct,
- 'u' => $url,
- 'p' => $path
+ 'p' => $path,
+ 'u' => $url
);
return true;
+++ /dev/null
-<?php
-/**
- * Copyright 2000-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Chuck Hagenbuch <chuck@horde.org>
- */
-
-require_once dirname(__FILE__) . '/../lib/Application.php';
-Horde_Registry::appInit('horde', array('authentication' => 'none', 'session_control' => 'readonly'));
-
-// Figure out if we've been inlined, or called directly.
-$send_headers = strstr($_SERVER['PHP_SELF'], 'javascript.php');
-
-$app = Horde_Util::getFormData('app', Horde_Util::nonInputVar('app'));
-$file = Horde_Util::getFormData('file', Horde_Util::nonInputVar('file'));
-if (!empty($app) && !empty($file) && strpos($file, '..') === false) {
- $script_file = $registry->get('templates', $app) . '/javascript/' . $file;
- if (file_exists($script_file)) {
- $registry->pushApp($app, array('check_perms' => false));
-
- header('Cache-Control: no-cache');
- header('Content-Type: text/javascript');
- require $script_file;
- }
-}