Exemple #1
0
 /**
  * 
  * @param string $path
  * @param \DIPcms\Scripter\CacheObject $file
  * @return string
  * @throws \Exception
  */
 public function getFileLink($path, Scripter $scripter, CacheObject $file_rendering)
 {
     $f = realpath($file_rendering->dir . $path);
     $file = $scripter->addFile($f);
     $name = $file->name;
     if (!file_exists($f)) {
         throw new \Exception($f . ' file Not Found');
     }
     return '/' . $this->config->url_path_name . '/' . $name . '/' . $file->type;
 }
Exemple #2
0
 /**
  * 
  * @return \DIPcms\ACEeditor\Components\Editor
  */
 public function createComponent()
 {
     if (count($this->components) == 0) {
         $this->scripter->addJs(__DIR__ . '/Components/ace_config.js');
         $this->scripter->addCss(__DIR__ . '/Components/ace.css');
     }
     $c = count($this->components) - 1;
     $id = $c < 0 ? 0 : $c;
     $component = new Editor($this->config, $id);
     $this->components[$id] = $component;
     $this->components[] = $component;
     return $component;
 }
 /**
  * 
  * @param Scripter $scripter
  * @param Response $response
  * @param Request $request
  */
 public static function register_shutdown(Scripter $scripter, Response $response, Request $request)
 {
     register_shutdown_function(function () use($scripter, $response, $request) {
         $page = ob_get_contents();
         ob_end_clean();
         $header_type = $response->getHeader("Content-Type");
         if ($header_type && strpos($header_type, "text/html") === 0 && !$request->isAjax()) {
             $scripter->cache->removeNotUseFile();
             preg_match('/(?:<head[^>]*>)(.*?)<\\/head>/s', $page, $matches);
             if (isset($matches[1])) {
                 $replace = $matches[1];
                 $matches[1] .= '<script type="text/javascript" src="' . '/' . $scripter->config->url_path_name . '/' . $scripter->getPageName() . '/js' . '"></script>';
                 $matches[1] .= '<link rel="stylesheet" href="' . '/' . $scripter->config->url_path_name . '/' . $scripter->getPageName() . '/css' . '">';
                 $page = str_replace($replace, $matches[1], $page);
             }
         }
         echo $page;
     });
 }
 public function renderDefault($file_name, $type)
 {
     $response = $this->getHttpResponse();
     $source = $this->scripter->getSource($file_name, $type);
     if ($source->isFile()) {
         $data = $source->getData();
         if ($data) {
             $response->setContentType(mime_content_type($data->path), 'UTF-8');
             $response->addHeader("Content-Disposition", 'inline; filename="' . $data->file_name . '"');
             readfile($data->path);
             exit;
         }
     } else {
         $response->setContentType('text/' . $type, 'UTF-8');
         echo $source->getSource();
         exit;
     }
     //$response->setContentType(\Nette\Http\IResponse::S400_BAD_REQUEST, 'UTF-8');
     //exit;
 }