Example #1
0
 function work(Request $request)
 {
     $name = $this->name();
     $version = $this->version->value();
     if (!is_dir(DIR . 'vendor_front/' . $name)) {
         CLI::run_php('bowerphp.phar install --save ' . $name . '#' . $version, false, true);
     }
     $files = explode(';', $this->import->value());
     if ($file = $this->file()) {
         $files[] = $file;
     }
     foreach ($files as $file) {
         $file = '/vendor_front/' . trim($file);
         switch (File::fileExtention($file)) {
             case 'js':
                 $request->htmlHead('script', ['type' => 'text/javascript', 'src' => $file, 'text' => '']);
                 break;
             case 'css':
                 $request->htmlHead('link', ['rel' => "stylesheet", 'type' => "text/css", 'href' => $file]);
                 break;
             default:
         }
     }
 }
Example #2
0
 /**
  * Файл, ассоциированный с объектом
  * @param null|array|string $new Информация о новом файле. Полный путь к новому файлу или сведения из $_FILES
  * @param bool $root Возвращать полный путь или от директории сайта
  * @return null|string
  */
 function file($new = null, $root = false)
 {
     // Установка нового файла
     if (isset($new)) {
         if (empty($new)) {
             $this->change('file', '');
         } else {
             if (is_string($new)) {
                 $new = ['tmp_name' => $new, 'name' => basename($new), 'size' => @filesize($new), 'error' => is_file($new) ? 0 : true];
             }
             if (empty($new['name']) && $this->is_file()) {
                 $new['name'] = $this->name() . '.' . File::fileExtention($this->file());
             }
             $this->change('file', $new);
         }
         $this->change('is_default_file', false);
         $this->_def_file = null;
     }
     // Возврат пути к текущему файлу, если есть
     if ($this->is_file()) {
         if (($proto = $this->is_default_file(null, true)) && $proto->is_exists()) {
             return $proto->file(null, $root);
         } else {
             if (is_array($this->_attributes['file'])) {
                 return $this->_attributes['file'];
             }
             return $this->dir($root) . $this->_attributes['file'];
         }
     }
     return null;
 }