Source for file Javascript.php

Documentation is available at Javascript.php

  1. <?php
  2. // vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 fdm=marker encoding=utf8 :
  3. /**
  4.  * Pxxo - build self-supported and interoperable Web graphical components
  5.  * 
  6.  * Copyright (c) 2008, Nicolas Thouvenin
  7.  *
  8.  * All rights reserved.
  9.  *
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions are met:
  12.  *
  13.  *     * Redistributions of source code must retain the above copyright
  14.  *       notice, this list of conditions and the following disclaimer.
  15.  *     * Redistributions in binary form must reproduce the above copyright
  16.  *       notice, this list of conditions and the following disclaimer in the
  17.  *       documentation and/or other materials provided with the distribution.
  18.  *     * Neither the name of the author nor the names of its contributors may be
  19.  *       used to endorse or promote products derived from this software without
  20.  *       specific prior written permission.
  21.  *
  22.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
  23.  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25.  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
  26.  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  27.  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  29.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31.  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32.  
  33.  * @package    Pxxo
  34.  * @copyright  Copyright (c) 2008 Nicolas Thouvenin
  35.  * @license    http://opensource.org/licenses/bsd-license.php
  36.  * @version    $Id$
  37.  */
  38. require_once 'Pxxo/Buffer/Resource.php';
  39.  
  40. /**
  41. * Classe permet de gérer l'accès à des flux de données comme des ressources Javascript
  42.  *
  43.  * @package    Pxxo
  44.  * @copyright  Copyright (c) 2008 Nicolas Thouvenin
  45.  * @license    http://opensource.org/licenses/bsd-license.php
  46.  */
  47. {
  48.     /**
  49.      * @var     string type du contenu du flux
  50.      */
  51.      protected $type = 'js';
  52.      /**
  53.      * @var integer importance du Buffer
  54.      */
  55.      protected $weight = 500;
  56.     /**
  57.      * Constructeur PHP5
  58.      *
  59.      * @param    string localisation du flux
  60.      */
  61.     function __construct($p)
  62.     {
  63.         parent::__construct($p);
  64.     }
  65.     /**
  66.      * Filtre permettant de minimiser du Code Javascript
  67.      *
  68.      * @param   string chaine de caractère
  69.      * @return    string chaine de caractère compressée
  70.      */
  71.     public function compress($s
  72.     {
  73.         include_once 'jsmin.php';
  74.         return JSMin::minify($s);
  75.     }
  76.     /**
  77.      * Retrourne une chaine en HTML permettant de charger la ressource
  78.      *
  79.      * @return    string chaine de caractère en HTML
  80.      * @abstract
  81.      */
  82.     function getHTML(
  83.     {
  84.         $htmlstring '';
  85.         if ($this->disposition != 'inline'{
  86.             $htmlstring .= '<script type="text/javascript" src="'.$this->get().'"></script>'."\n";
  87.         }
  88.         else {
  89.             $htmlstring .= '<script type="text/javascript">'.$this->getContent().'</script>'."\n";
  90.         }
  91.         return $htmlstring;
  92.     }
  93. }

Documentation generated on Thu, 13 Mar 2008 22:03:14 +0100 by phpDocumentor 1.4.1