Finally can get rid of the javascript.php helper script
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 27 Jul 2010 21:32:23 +0000 (15:32 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 27 Jul 2010 21:45:47 +0000 (15:45 -0600)
framework/Core/lib/Horde.php
framework/Core/lib/Horde/Script/Files.php
horde/services/javascript.php [deleted file]

index f34ad78..41b7d2f 100644 (file)
@@ -179,9 +179,6 @@ HTML;
      *                        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
@@ -195,7 +192,7 @@ HTML;
     {
         $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);
         }
index 28a3787..66a3003 100644 (file)
@@ -33,16 +33,14 @@ class Horde_Script_Files
      * 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;
         }
@@ -89,7 +87,7 @@ class Horde_Script_Files
      *
      * @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;
 
@@ -114,38 +112,19 @@ class Horde_Script_Files
             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;
diff --git a/horde/services/javascript.php b/horde/services/javascript.php
deleted file mode 100644 (file)
index 9bdcd50..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?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;
-    }
-}