Beispiel #1
0
 public static function compileDir($dir, $destFile)
 {
     $dh = opendir($dir);
     if (!$dh) {
         throw new Exception('Unknown dir: ' . $dir);
     }
     while ($file = readdir($dh)) {
         if ($file[0] == '.') {
             continue;
         }
         $absfile = Dir::normalize($dir) . $file;
         if (is_file($absfile) && File::getExtension($file) == 'js') {
             File::append($destFile, "//FILE: {$file}" . chr(10));
             if (filesize($absfile) > 200000) {
                 File::append($destFile, file_get_contents($absfile));
             } else {
                 File::append($destFile, self::minify($absfile));
             }
             File::append($destFile, chr(10) . chr(10));
         } else {
             if (is_dir($absfile)) {
                 self::compileDir($absfile, $destFile);
             }
         }
     }
     closedir($dh);
 }
Beispiel #2
0
require_once 'lib/Controller.php';
require_once 'lib/controller/PimpleController.php';
//Handlers
require_once 'lib/handlers/MessageHandler.php';
require_once 'lib/handlers/SessionHandler.php';
require_once 'lib/handlers/AccessHandler.php';
//Main class
require_once 'lib/Pimple.php';
require_once 'lib/TagLib.php';
require_once 'lib/taglib/CoreTagLib.php';
require_once 'lib/taglib/ValueTagLib.php';
require_once 'lib/taglib/BasicTagLib.php';
require_once 'lib/taglib/FormTagLib.php';
require_once 'lib/taglib/WidgetTagLib.php';
require_once 'lib/taglib/JavascriptTagLib.php';
require_once 'lib/taglib/UserTagLib.php';
require_once 'lib/taglib/JSTemplateTagLib.php';
//Add pimple lib to include path
IncludePath::instance()->addPath(Pimple::instance()->getBaseDir() . '/lib');
//Add pimple ressources lib to include path
IncludePath::instance()->addPath(Pimple::instance()->getRessource('lib/'), 1);
define('CACHEDIR', Dir::normalize(BASEDIR) . 'cache');
Dir::ensure(CACHEDIR);
Pimple::instance()->registerTagLib('c', new CoreTagLib());
Pimple::instance()->registerTagLib('val', new ValueTagLib());
Pimple::instance()->registerTagLib('p', new BasicTagLib());
Pimple::instance()->registerTagLib('user', new UserTagLib());
Pimple::instance()->registerTagLib('f', new FormTagLib());
Pimple::instance()->registerTagLib('w', new WidgetTagLib());
Pimple::instance()->registerTagLib('js', new JavascriptTagLib());
Pimple::instance()->registerTagLib('jst', new JSTemplateTagLib());
Beispiel #3
0
 public static function getSiteDir()
 {
     return Dir::normalize(BASEDIR);
 }
Beispiel #4
0
 /**
  * Outputs script tag
  * @param string path | if specified - outputs an include js script - else outputs a script tag with body
  * @container both
  * @deprecated
  * @See JavascriptTagLib
  */
 protected function tagJavascript($attrs)
 {
     if ($this->body()) {
         return sprintf('<script type="text/javascript">%s</script>', $this->body());
     } else {
         return sprintf('<script type="text/javascript" src="%s"></script>', Dir::normalize(BASEURL) . $attrs->path);
     }
 }
Beispiel #5
0
 public static function basePath()
 {
     $host = $_SERVER['HTTP_HOST'];
     if (isset($_SERVER['HTTPS'])) {
         $p = 'https';
     } else {
         $p = 'http';
     }
     return "{$p}://{$host}" . Dir::normalize(BASEURL);
 }