Пример #1
0
 public function getRealUrl()
 {
     if (strpos($this->url, '://')) {
         return $this->url;
     }
     return (dev() ? '/dev.php' : '') . $this->url;
 }
Пример #2
0
function popup()
{
    $lvm = new lvm_org($_GET["ou"]);
    $array = $lvm->disklist;
    while (list($num, $ligne) = each($array)) {
        $devs[] = $num;
        $list[$num] = basename($num);
    }
    $list[null] = "{select}";
    $select = Field_array_Hash($list, "dev", null, "HD_OU_DEV_SELECT()", null, 0, "font-size:14px;padding:5px");
    $_GET["dev"] = $devs[0];
    $html = "\n\t<table style='width:100%;text-color:black'>\n\t<tr>\n\t\t<td valign='top'><p class=caption>{your_storage_text}</p></td>\n\t\t<td valign='top'>{$select}</td>\n\t</tr>\n\t</table>\n\t<div id='hdou'>" . dev(1) . "</div>\n\t";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
Пример #3
0
 function initTwig($file = null)
 {
     $dirs = $this->getDirs();
     /**
      * We need to duplicate every dir for proper relative includes ...
      *
      *
      */
     if ($file) {
         $tempDirs = $dirs;
         foreach ($dirs as $dir) {
             $partDir = realpath($dir) . path('ds');
             $tempDir = $partDir . substr(str_replace('\\', path('ds'), $file), 0, strrpos($file, path('ds')));
             if (is_dir($tempDir)) {
                 $tempDirs[] = $tempDir;
             }
         }
         $dirs = array_unique($tempDirs);
     }
     $this->twig = new TwigEnv(new Twig_Loader_Chain([new Twig_Loader_Filesystem($dirs), new \Twig_Loader_String()]), ['debug' => dev()]);
     $this->twig->addExtension(new Twig_Extension_StringLoader());
     /**
      * This should be added to Dev environment Provider.
      */
     $this->twig->addExtension(new Twig_Extension_Debug());
     /**
      * This should be added to Framework/Inter Provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('__', function ($key, $data = [], $lang = null) {
         return __($key, $data, $lang);
     }, ['is_safe' => ['html']]));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('config', function ($text, $default = null) {
         return config($text, $default);
     }));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('flash', function ($key, $delete = true) {
         return context()->getOrCreate(Flash::class)->get($key, $delete);
     }));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('url', function ($url, $params = [], $absolute = false) {
         return context()->get(Router::class)->make($url, $params, $absolute);
     }));
     $this->twig->addFunction(new Twig_SimpleFunction('dev', function () {
         return dev();
     }));
     $this->twig->addFunction(new Twig_SimpleFunction('implicitDev', function () {
         return implicitDev();
     }));
     $this->twig->addFunction(new Twig_SimpleFunction('prod', function () {
         return prod();
     }));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('media', function ($file, $path = null, $relative = true, $base = null) {
         return media($file, $path, $relative, $base);
     }));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('relativePath', function ($key) {
         return relativePath($key);
     }));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('select', function ($options, $attributes = [], $valueKey = null) {
         $select = new Select();
         $select->setAttributes($attributes ?? []);
         foreach ($options as $key => $option) {
             $select->addOption($valueKey ? $option->id : $key, $valueKey ? $option->{$valueKey} : $option);
         }
         return $select;
     }));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFilter(new Twig_SimpleFilter('price', function ($price) {
         if (is_null($price)) {
             $price = 0.0;
         }
         $localeManager = resolve(Locale::class);
         return number_format($price, 2, $localeManager->getDecimalPoint(), $localeManager->getThousandSeparator()) . ' €';
     }));
     $this->twig->addFilter(new Twig_SimpleFilter('roundPrice', function ($price) {
         if (is_null($price)) {
             $price = 0.0;
         }
         $localeManager = resolve(Locale::class);
         return trim((string) number_format($price, 2, $localeManager->getDecimalPoint(), $localeManager->getThousandSeparator()), '0') . ' €';
     }));
     $this->twig->addFilter(new Twig_SimpleFilter('datetime', function ($date) {
         return (new Carbon($date))->format(resolve(Locale::class)->getDatetimeFormat());
     }));
     $this->twig->addFilter(new Twig_SimpleFilter('date', function ($date) {
         return (new Carbon($date))->format(resolve(Locale::class)->getDateFormat());
     }));
     $this->twig->getExtension('core')->setDateFormat(resolve(Locale::class)->getDateFormat(), '%d days');
 }
Пример #4
0
<?php

include_once "../include/page.php";
include_once "../include/linklist.php";
$p = new Page("news", 2);
$l = new LinkList($p->u);
dev();
$l->additem("news items", "news", 0);
echo $l->dispList();
$p->addJs("\$(\"#accordion\").accordion({autoHeight: false, navigation: true})");
if (!isset($_GET['action'])) {
    //if no action, do nothing. This is just so we do not need to check every time.
} elseif ($_GET['action'] == 'addnews') {
    if (!isset($_GET['item']) || $_GET['item'] == "") {
        $p->db->qry("INSERT INTO news (title, uid, content) VALUES ('{$_GET['title']}','{$p->u->id}', '" . addSlashes($_GET['newscontent']) . "')");
    } else {
        $p->db->qry("UPDATE news SET uid = '{$p->u->id}',time = CURRENT_TIMESTAMP, title = '{$_GET['title']}',content = '" . addSlashes($_GET['newscontent']) . "' WHERE id='" . $_GET['item'] . "'");
    }
} elseif ($_GET['action'] == 'modify') {
    extract($_GET);
    $p->db->qry("SELECT title, content FROM news WHERE id='{$item}' LIMIT 1");
    $row = $p->db->fetchLast();
    $p->addJs("document.addnews.newscontent.value='" . addSlashes($row['content']) . "';");
    $p->addJs("document.addnews.title.value='{$row['title']}';");
    $p->addJs("document.addnews.item.value='{$item}';");
} elseif ($_GET['action'] == 'delete') {
    $p->db->qry("DELETE FROM news WHERE id = {$_GET['item']}");
}
//new
echo "<div id=\"accordion\"><h3><a>Edit Entry</a></h3><div>";
echo "<form name=\"addnews\" id=\"addnews\" onsubmit=\"sendForm(this,'admin_news');false;\">\r\n<input type=\"text\" name=\"title\" /> by {$p->u->username} @ [now] wrote:<br/><textarea id=\"newscontent\" name=\"newscontent\" cols=\"45\" rows=\"5\"></textarea><br/><input type=\"submit\" class=\"ui-button ui-widget ui-state-default ui-corner-all\" /><input type=\"hidden\" name=\"item\" id=\"item\" value=\"\" /></form></div>";
Пример #5
0
 public function make($routeName = null, $arguments = [], $absolute = false, $envPrefix = true)
 {
     if (!$routeName) {
         $routeName = $this->data["name"];
     }
     foreach ($this->routes as $routeArr) {
         foreach ($routeArr as $route) {
             if ($route["name"] == $routeName) {
                 $args = [];
                 foreach ($arguments as $key => $val) {
                     $args["[" . $key . "]"] = $val;
                 }
                 foreach ($route['resolvers'] ?? [] as $key => $resolver) {
                     /**
                      * If index is not set, argument should be resolved by post/get data or similar.
                      * T00D00 - this needs to be resolved without proper index (find by class)
                      */
                     if (isset($args['[' . $key . ']'])) {
                         $args['[' . $key . ']'] = resolve($resolver)->parametrize($args['[' . $key . ']']);
                     }
                 }
                 if ($args) {
                     /**
                      * Replace parameters in url.
                      */
                     foreach ($args as $key => &$arg) {
                         if (is_string($arg)) {
                             if (strpos(strtolower($key), 'url') !== false) {
                                 $arg = sluggify($arg);
                             } else {
                                 $arg = urlencode($arg);
                             }
                         }
                     }
                     $filteredArgs = (new Collection($args))->reduce(function ($item) {
                         return !is_object($item);
                     }, true)->all();
                     $route['url'] = str_replace(array_keys($filteredArgs), $filteredArgs, $route['url']);
                 }
                 return ($absolute || isConsole() ? $this->config->get("protocol") . '://' . ($this->config->get("domain") ?? $_SERVER['HTTP_HOST']) : "") . ($envPrefix && dev() && !isConsole() ? "/dev.php" : "") . $route["url"];
             }
         }
     }
 }
Пример #6
0
  这里使用了系统内置的异常类exception和自定义的一个customException异常类
  捕获到多个异常会处理先抛出的异常*/
function dev($a, $b)
{
    if ($a == 0) {
        throw new exception("deviding 0,meaningless");
    } else {
        if ($b == 0) {
            throw new customException();
        } else {
            return $a / $b;
        }
    }
}
try {
    dev(0, 0);
} catch (customException $e) {
    echo "Message:" . $e->errorMessage();
} catch (exception $e) {
    echo "Message:" . $e->getMessage();
}
class customException extends exception
{
    //定义异常类,继承自exception
    public function errorMessage()
    {
        $errorMsg = 'Error On Line ' . $this->getLine() . '<br />in ' . $this->getFile() . ':<br/>' . $this->getMessage() . '<br />can not devided by 0';
        return $errorMsg;
    }
}
?>
Пример #7
0
 public function vueJS()
 {
     $this->addAssets(["bower_components/vue/dist/vue." . (dev() ? 'min.' : '') . "js"], 'libraries');
     return $this;
 }
Пример #8
0
function change_couleurs($css, $couleur_cible, $ref = false)
{
    $css = preg_replace("#\\s+#", " ", $css);
    $css = css2array($css);
    $final = "";
    foreach ($css as $chem => $proprietes) {
        foreach ($proprietes as $k => $p) {
            if (trim($p) != "") {
                preg_match_all("#(\\#[0-9A-F]{3,6})#is", $p, $test);
                if (count($test[0]) > 0) {
                    foreach ($test[0] as $n => $c) {
                        $color = $test[1][$n];
                        if (strlen($color) == 4) {
                            $color = "#" . substr($color, 1, 1) . substr($color, 1, 1) . substr($color, 2, 1) . substr($color, 2, 1) . substr($color, 3, 1) . substr($color, 3, 1);
                        }
                        if (false && dev()) {
                            $final .= $chem . "{ " . $k . ":" . str_replace($test[1][$n], couleur::invert(couleur::tocolor($color, $couleur_cible, $ref)), $p) . ";}\n";
                        } else {
                            $final .= $chem . "{ " . $k . ":" . str_replace($test[1][$n], couleur::tocolor($color, $couleur_cible, $ref), $p) . ";}\n";
                        }
                    }
                }
            }
        }
    }
    return $final;
}