Example #1
0
 /**
  * Compiles the CSS using the engine and caches the result
  * @access public
  * @param $source Scaffold_Source
  * @return array
  */
 public function compile(Scaffold_Source $source)
 {
     $id = $source->id();
     $modified = $source->last_modified();
     $expired = $this->cache->expired($id, $modified);
     if ($this->production === false or $expired === true) {
         $this->cache->set($id, $this->parse($source));
     }
     $result = array();
     $result['string'] = $this->cache->get($id);
     $result['last_modified'] = $this->cache->modified($id);
     return $result;
 }
 public static function create_gradient($direction, $size, $from, $to, $stops = false)
 {
     if (!class_exists('GradientGD')) {
         include dirname(__FILE__) . '/libraries/gradientgd.php';
     }
     $file = "{$direction}_{$size}_" . str_replace('#', '', $from) . "_" . str_replace('#', '', $to) . ".png";
     if ($direction == 'horizontal') {
         $height = 50;
         $width = $size;
         $repeat = 'y';
     } else {
         $height = $size;
         $width = 50;
         $repeat = 'x';
     }
     if (!Scaffold_Cache::exists('gradients/' . $file)) {
         Scaffold_Cache::create('gradients');
         $file = Scaffold_Cache::find('gradients') . '/' . $file;
         $gradient = new GradientGD($width, $height, $direction, $from, $to, $stops);
         $gradient->save($file);
     }
     $file = Scaffold_Cache::find('gradients') . '/' . $file;
     self::$gradients[] = array($direction, $size, $from, $to, $file);
     $properties = "\n\t\t\tbackground-position: top left;\n\t\t    background-repeat: repeat-{$repeat};\n\t\t    background-image: url(" . Scaffold::url_path($file) . ");\n\t\t";
     return $properties;
 }
Example #3
0
 public static function create_rgba($r, $g, $b, $a)
 {
     if (!class_exists('RgbaGd')) {
         include dirname(__FILE__) . '/libraries/rgbagd.php';
     }
     $file = "color_r{$r}_g{$g}_b{$b}_a{$a}.png";
     $alpha = intval(127 - 127 * $a);
     if (!Scaffold_Cache::exists('rgba/' . $file)) {
         Scaffold_Cache::create('rgba');
         $file = Scaffold_Cache::find('rgba') . '/' . $file;
         $rgba = new RgbaGd($r, $g, $b, $alpha);
         $rgba->save($file);
     }
     $file = Scaffold_Cache::find('rgba') . '/' . $file;
     self::$rgba[] = array($r, $g, $b, $alpha);
     $properties = "\n\t\t\tbackground-position: top left;\n\t\t  background-repeat: repeat;\n\t\t  background-image: url(" . Scaffold::url_path($file) . ") !important;\n\t\t  background-image:none;\n\t\t  background: rgba({$r},{$g},{$b},{$a});\n\t\t  filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" . Scaffold::url_path($file) . ", sizingMethod=scale);\n\t\t";
     return $properties;
 }
Example #4
0
 /**
  * Sets the initial variables, checks if we need to process the css
  * and then sends whichever file to the browser.
  *
  * @return void
  */
 public static function setup($config)
 {
     /**
      * Choose whether to show or hide errors
      */
     if (SCAFFOLD_PRODUCTION === false) {
         ini_set('display_errors', true);
         error_reporting(E_ALL & ~E_STRICT);
     } else {
         ini_set('display_errors', false);
         error_reporting(0);
     }
     /**
      * Define contstants for system paths for easier access.
      */
     if (!defined('SCAFFOLD_SYSPATH') && !defined('SCAFFOLD_DOCROOT')) {
         define('SCAFFOLD_SYSPATH', self::fix_path($config['system']));
         define('SCAFFOLD_DOCROOT', $config['document_root']);
         define('SCAFFOLD_URLPATH', str_replace(SCAFFOLD_DOCROOT, '', SCAFFOLD_SYSPATH));
     }
     /**
      * Add include paths for finding files
      */
     Scaffold::add_include_path(SCAFFOLD_SYSPATH, SCAFFOLD_DOCROOT);
     /**
      * Tell the cache where to save files and for how long to keep them for
      */
     Scaffold_Cache::setup(Scaffold::fix_path($config['cache']), $config['cache_lifetime']);
     /**
      * The level at which logged messages will halt processing and be thrown as errors
      */
     self::$error_threshold = $config['error_threshold'];
     /**
      * Disabling flags allows for quicker processing
      */
     if ($config['disable_flags'] === true) {
         self::$flags = false;
     }
     /**
      * Tell the log where to save it's files. Set it to automatically save the log on exit
      */
     if ($config['enable_log'] === true) {
         // START - Modified by Webligo Developments
         if ($config['log_path']) {
             Scaffold_Log::log_directory($config['log_path']);
         } else {
             Scaffold_Log::log_directory(SCAFFOLD_SYSPATH . 'logs');
         }
         // END - Modified by Webligo Developments
         //Scaffold_Log::log_directory(SCAFFOLD_SYSPATH.'logs');
         Scaffold_Event::add('system.shutdown', array('Scaffold_Log', 'save'));
     }
     /**
      * Load each of the modules
      */
     foreach (Scaffold::list_files(SCAFFOLD_SYSPATH . 'modules') as $module) {
         $name = basename($module);
         $module_config = SCAFFOLD_SYSPATH . 'config/' . $name . '.php';
         if (file_exists($module_config)) {
             unset($config);
             include $module_config;
             self::$config[$name] = $config;
         }
         self::add_include_path($module);
         if ($controller = Scaffold::find_file($name . '.php', false, true)) {
             require_once $controller;
             self::$modules[$name] = new $name();
         }
     }
     /**
      * Module Initialization Hook
      * This hook allows modules to load libraries and create events
      * before any processing is done at all. 
      */
     self::hook('initialize');
     /**
      * Create the shutdown event
      */
     Scaffold_Event::add('system.shutdown', array('Scaffold', 'shutdown'));
 }
Example #5
0
 /**
  * Saves the contents of the source object
  * @access public
  * @param $source Scaffold_Source
  * @return void
  */
 public function save(Scaffold_Source $source)
 {
     $this->cache->set($source->id, $source->contents, $source->last_modified);
 }
 /**
  * Generates the background grid.png
  *
  * @author Anthony Short
  * @param $cl Column width
  * @param $bl Baseline
  * @param $gw Gutter Width
  * @return null
  */
 private static function create_grid_image($cw, $bl, $lgw, $rgw)
 {
     # Path to the image
     $file = "{$lgw}_{$cw}_{$rgw}_{$bl}_grid.png";
     if (($cache = Scaffold_Cache::find('Layout/' . $file)) === false) {
         Scaffold_Cache::create('Layout');
         $image = ImageCreate($cw + $lgw + $rgw, $bl);
         $colorWhite = ImageColorAllocate($image, 255, 255, 255);
         $colorGrey = ImageColorAllocate($image, 200, 200, 200);
         $colorBlue = ImageColorAllocate($image, 240, 240, 255);
         # Draw left gutter
         Imagefilledrectangle($image, 0, 0, $lgw - 1, $bl, $colorWhite);
         # Draw column
         Imagefilledrectangle($image, $lgw, 0, $cw + $lgw - 1, $bl, $colorBlue);
         # Draw right gutter
         Imagefilledrectangle($image, $lgw + $cw + 1, 0, $lgw + $cw + $rgw, $bl, $colorWhite);
         # Draw baseline
         imageline($image, 0, $bl - 1, $lgw + $cw + $rgw, $bl - 1, $colorGrey);
         $cache = Scaffold_Cache::find('Layout') . '/' . $file;
         ImagePNG($image, $cache);
         # Kill it
         ImageDestroy($image);
     }
     return Scaffold::url_path($cache);
 }
 /**
  * Sets the lifetime of the cache
  *
  * @param $time
  * @return void
  */
 public function lifetime($time)
 {
     self::$lifetime = $time;
 }