예제 #1
0
 /**
  * Core render handler for including CSS and JS resources to html
  *
  * @param sting $view View content
  * @param array $data View data
  * @return string Processed view content
  */
 public function renderer(&$view, $data = array(), iModule $m = null)
 {
     // Define resource urls
     $css = url()->base() . str_replace(__SAMSON_PUBLIC_PATH, '', $this->cached['css']);
     $js = url()->base() . str_replace(__SAMSON_PUBLIC_PATH, '', $this->cached['js']);
     // TODO: Прорисовка зависит от текущего модуля, сделать єто через параметр прорисовщика
     // If called from compressor
     if ($m->id() == 'compressor' || $m->id() == 'deploy') {
         $css = url()->base() . basename($this->cached['css']);
         $js = url()->base() . basename($this->cached['js']);
     }
     // Put css link at the end of <head> page block
     $view = str_ireplace('</head>', "\n" . '<link type="text/css" rel="stylesheet" href="' . $css . '">' . "\n" . '</head>', $view);
     // Put javascript link in the end of the document
     $view = str_ireplace($this->javascriptMarker, "\n" . '<script type="text/javascript" src="' . $js . '"></script>' . "\n" . $this->javascriptMarker, $view);
     //elapsed('Rendering view =)');
     return $view;
 }
예제 #2
0
 /**
  * Свернуть модуль
  *
  * @param iModule $module Указатель на модуль для сворачивания
  * @param ResourceMap $data
  */
 public function compress_module(iModule &$module, ResourceMap &$data)
 {
     // Идентификатор модуля
     $id = $module->id();
     // Сохраним указатель на текущий модуль
     $this->current =& $module;
     // Build output module path
     $module_output_path = $id == 'local' ? '' : basename($module->path()) . '/';
     // Build resource source path
     $module_path = $id == 'local' ? $module->path() . __SAMSON_PUBLIC_PATH : $module->path();
     $this->log('  - Compressing module[##] from [##]', $id, $module_path);
     // Call special method enabling module personal resource pre-management on compressing
     if ($module->beforeCompress($this, $this->php) !== false) {
         // Copy all module resources
         $this->copy_path_resources($data->resources, $module_path, $module_output_path);
         // Internal collection of module php code, not views
         $module_php = array();
         foreach ($data->classes as $key => $php) {
             $this->compress_php($key, $module, $module_php);
         }
         // Iterate module plain php code
         foreach ($data->php as $php) {
             $this->compress_php($php, $module, $module_php);
         }
         foreach ($data->globals as $php) {
             $this->compress_php($php, $module, $module_php);
         }
         // Iterate module controllers php code
         foreach ($data->controllers as $php) {
             $this->compress_php($php, $module, $module_php);
         }
         // Iterate module controllers php code
         foreach ($data->modules as $php) {
             $this->compress_php($php[1], $module, $module_php);
         }
         // Iterate module model php code
         foreach ($data->models as $php) {
             $this->compress_php($php, $module, $module_php);
         }
         // Iterate module views
         foreach ($data->views as $php) {
             $this->compress_view($php, $module);
         }
     }
     // Call special method enabling module personal resource post-management on compressing
     $module->afterCompress($this, $module_php);
     // Gather all code in to global code collection with namespaces
     $this->code_array_combine($module_php, $this->php);
     // Change module path
     $module->path($id . '/');
 }