예제 #1
0
 public function getAbsoluteLink($relative)
 {
     $starts = array("http", "www");
     if (str_starts_with_any($relative, $starts)) {
         return $relative;
     }
     return RuntimeService::getInstance()->getRouteUrl() . "/" . $relative;
 }
예제 #2
0
 public function editDatabaseProperties(BaseDatabaseModel $model, ViewBase $view, $excludedProps = null)
 {
     $html = "";
     $props = $model->getDatabaseArray();
     foreach ($props as $key => $val) {
         if (in_array($key, $excludedProps)) {
             continue;
         }
         if (str_ends_with($key, "Id") && strlen($key) > 2) {
             $objName = substr($key, 0, -2);
             $arrName = $objName . "s";
             $arr = $view->tryRetrieve($arrName);
             if (is_array($arr)) {
                 $html .= $this->getInput($model, $key, $objName, "select", "choose a " . $objName, $arr);
             }
         } else {
             $type = "text";
             $equals = array("Id");
             $starts = array("Is");
             $ends = array("Text", "Email", "Password", "AuthHash", "DateTime", "Time", "Date");
             $equalAssign = array("Id" => "hidden");
             $startAssign = array("Is" => "checkbox");
             $endAssign = array("Text" => "text", "Email" => "email", "Password" => "password", "AuthHash" => "hidden", "DateTime" => "datetime", "Time" => "time", "Date" => "date");
             $equalVal = str_equals_with_any($key, $equals, true);
             $startVal = str_starts_with_any($key, $starts, true);
             $endVal = str_ends_with_any($key, $ends, true);
             if ($equalAssign !== false) {
                 $type = $equalAssign[$equalVal];
             } else {
                 if ($startVal !== false) {
                     $type = $startAssign[$startVal];
                 } else {
                     if ($endVal !== false) {
                         $type = $endAssign[$endVal];
                     }
                 }
             }
             $html .= $this->getInput($model, $key, null, $type);
         }
     }
     return $html;
 }