Exemplo n.º 1
0
 public static function init()
 {
     NISE::$rootpath = dirname(__FILE__);
     SESSION::init();
     CONFIG::load();
     CONFIG::apply();
     PROJECT::launch();
     OUTPUT::render();
 }
Exemplo n.º 2
0
 public function view()
 {
     $app_data = [];
     $homelist = [];
     $articles = MODEL::MYSQLDB("home")->articles;
     $tree = $articles->fetch_tree();
     $i = 0;
     foreach ($tree as $article) {
         $date = date("d M Y H:i", $article->date);
         $images = count($article->_linked) - 1;
         $count = rand(0, $images);
         $x = 0;
         $image = "";
         foreach ($article->_linked as $blogimages) {
             if ($x == $count) {
                 $image = $blogimages->bi_image;
                 break;
             }
             $x++;
         }
         $byline = $article->up_byline == 1 ? $article->up_firstname . " " . $article->up_surname : $article->up_screenname;
         $homelist[$i]["image"] = $image;
         $homelist[$i]["subject"] = $article->subject;
         $homelist[$i]["byline"] = $date . " by " . $byline;
         $homelist[$i]["article_id"] = $article->id;
         $i++;
         if ($i == 5) {
             if (!REQUEST::$JSON) {
                 break;
             }
         }
         if (REQUEST::$JSON) {
             $app = [];
             $app["DATE"] = $date;
             $app["IMAGE"] = $image;
             $app["TITLE"] = $article->subject;
             $app["BYLINE"] = $byline;
             $app["ID"] = $article->id;
             $app_data[] = $app;
         }
     }
     if (self::$APPNEWS) {
         $this->app_format("news", $app_data, true);
     }
     NISE::put(["homelist" => $homelist]);
 }
Exemplo n.º 3
0
 public function __construct($view)
 {
     NISE::put($view);
     NISE::put(["footer_smallprint" => "© CHARLES JOHANNISEN - " . date("Y")]);
 }
Exemplo n.º 4
0
 public static function nise_html_decode($text, $vars)
 {
     foreach ($vars as $varname => $varvalue) {
         $text = preg_replace('/var(.*?)\\((.*?)' . $varname . '(.*?)\\)/', $varvalue, $text);
     }
     $text = preg_replace('/var(.*?)\\((.*?)\\)/', "", $text);
     $text = preg_replace('/frag(.*?)\\((.*?)\\)/', "htmlfragment[name:\\2]", $text);
     $text = preg_replace_callback('/nise(.*?)\\((.*?)\\)/', function ($match) {
         return \Nise\NISE::get($match[2]);
     }, $text);
     $elements = explode(chr(10), ltrim($text));
     $lastparent = 0;
     $parents = [];
     $show = [];
     $id = -1;
     $fragment = new \Nise\HTML\FRAGMENT();
     foreach ($elements as $element) {
         $root = null;
         $attributes = null;
         $contents = null;
         $showelement = true;
         if (preg_match('/when(.*?)\\((.*?)\\)/', $element, $match)) {
             $element = str_replace($match[0], "", $element);
             $when = \Nise\NISE::get(trim($match[2]));
             if (is_bool($when) && !$when) {
                 $showelement = false;
             }
         }
         $el = preg_split('/(\\[)/i', $element, 2);
         if (count($el) > 1) {
             $root = rtrim($el[0]);
             $attr = preg_split('/\\]\\{/i', $el[1]);
             if (count($attr) > 1) {
                 $attributes = $attr[0];
                 $contents = rtrim(trim($attr[1]), "}");
             } else {
                 $attributes = rtrim(trim($attr[0]), "]");
             }
         } else {
             $el = preg_split('/(\\{)/i', $element, 2);
             if (count($el) > 1) {
                 $root = rtrim($el[0]);
                 $contents = rtrim(trim($attr[0]), "}");
             } else {
                 $root = rtrim($element);
             }
         }
         if ($root != null) {
             if ($attributes != null) {
                 $attributes = self::nise_attribute_decode($attributes);
             }
             if ($id > -1) {
                 $lastcount = $parents[$id];
             } else {
                 $lastcount = 0;
             }
             $id++;
             $show[$id] = $showelement;
             preg_match_all('/\\t/', $root, $match);
             $root = trim($root);
             $parents[$id] = count($match[0]);
             $currentcount = $parents[$id];
             $parent = 0;
             if ($currentcount > $lastcount) {
                 $parent = $id - 1;
             } elseif ($currentcount == $lastcount) {
                 $parent = $lastparent;
             } elseif ($currentcount < $lastcount) {
                 $lookup = array_reverse($parents, true);
                 foreach ($lookup as $parent_id => $indent) {
                     if ($indent < $currentcount) {
                         $parent = $parent_id;
                         break;
                     }
                 }
             }
             $lastparent = $parent;
             if ($show[$lastparent] && $show[$id]) {
                 $fragment->{$root}(json_encode($attributes), $id, [$parent]);
                 if ($contents != null) {
                     $fragment->content($contents);
                 }
             }
         }
     }
     return $fragment;
 }