Esempio n. 1
0
 /**
  * Create a new instance of the blade view factory.
  *
  * @param string|null $path The default path for views
  * @param string|null $cache The default path for cached php
  */
 public function __construct($path = null, $cache = null)
 {
     if ($path === null) {
         $path = Env::path("views");
     }
     $this->path = $path;
     if ($cache === null) {
         $cache = Env::path("cache/views");
     }
     $this->cache = $cache;
 }
Esempio n. 2
0
 public static function img($options)
 {
     if (!is_array($options)) {
         $options = array("src" => $options);
     }
     $options = Helper::getOptions($options, ["id" => "", "src" => "", "default" => "", "class" => "", "alt" => "", "title" => "", "getSize" => false]);
     $path = Env::getPath($options["src"]);
     /**
      * If a default image has been specifed then check if the image requested exists
      * If the image doesn't exist, then use the default image instead
      */
     if ($options["default"]) {
         if (!file_exists($path)) {
             $options["src"] = $options["default"];
         }
     }
     /**
      * If no alt text was specified then use any title text that may have been specified
      */
     if (!$options["alt"]) {
         $options["alt"] = $options["title"];
     }
     $img = "<img ";
     $img .= "src='" . $options["src"] . "' ";
     if ($options["id"]) {
         $img .= "id='" . $options["id"] . "' ";
     }
     if ($options["class"]) {
         $img .= "class='" . $options["class"] . "' ";
     }
     if ($options["alt"]) {
         $img .= "alt='" . Html::entities($options["alt"]) . "' ";
     }
     if ($options["title"]) {
         $img .= "title='" . Html::entities($options["title"]) . "' ";
     }
     if ($options["getSize"]) {
         list($width, $height) = getimagesize($path);
         if ($width > 0 && $height > 0) {
             $img .= "style='width:" . $width . "px;height:" . $height . "px;' ";
         }
     }
     $img .= ">";
     return $img;
 }