Ejemplo n.º 1
0
 /**
  * A widget containing a menu
  * @param string $id The HTML #id of the element
  * @param string $class The HTML .class of element
  * @param string[][] $links The links in the menu
  * @param string $selected The title of the selected item in the menu
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($id, $class, $links, $selected = null, $args = null)
 {
     HtmlAttributes::Assure($args);
     $args->Add('id', $id);
     $args->Add('class', $class);
     $url = $title = null;
     $items = array();
     foreach ($links as $link) {
         if (_array::IsLongerThan($link, 1)) {
             $url = $link[0];
             $title = $link[1];
         } else {
             $url = $title = $link;
         }
         $linkargs = null;
         $forcehttps = false;
         if (_string::StartsWith($title, '_')) {
             $title = _string::RemovePrefix($title, '_');
             $forcehttps = true;
         }
         if ($selected != null && $selected == $title) {
             $linkargs = array('selected' => true);
         }
         $items[] = new RTK_Link($url, $title, $forcehttps, $linkargs);
     }
     parent::__construct($items, $args);
 }
Ejemplo n.º 2
0
 /**
  * Remove an HTML attributes from the list
  * @param var $key The key of the value to remove from the array
  **/
 public function Remove($key)
 {
     _array::Remove($this->_list, $key);
 }
Ejemplo n.º 3
0
 /**
  * Add a row of radiobuttons to the form
  * @param string $name The HTML name (and #id) of the input field
  * @param string $title The text written next to the input field
  * @param string[][] $options An array of options, each of which is an array of value and title
  * @param string $selected The value of the selected radiobutton
  * @param HtmlElement $container (optional) The "container" to add it to
  **/
 public function AddRadioButtons($name, $title, $options, $selected = null, $container = null)
 {
     $group = new HtmlElement('div', array('class' => 'formgroup'));
     $option_value = EMPTYSTRING;
     $option_title = EMPTYSTRING;
     foreach ($options as $option) {
         if (_array::IsLongerThan($option, 1)) {
             $option_value = $option[0];
             $option_title = $option[1];
         } else {
             $option_value = $option_title = $option;
         }
         $args = new HtmlAttributes();
         $args->Add('type', 'radio');
         $args->Add('class', 'radiobox');
         $args->Add('name', $name);
         $args->Add('id', $name);
         $args->Add('value', $option_value);
         if ($selected == $option_value) {
             $args->Add('checked', true);
         }
         $group->AddChild(new HtmlElement('input', $args));
         $group->AddChild(new HtmlElement('span', EMPTYSTRING, $option_title));
     }
     $field = new HtmlElement('div', array('class' => 'formline'));
     $field->AddChild(new HtmlElement('label', array('for' => $name), $title));
     $field->AddChild($group);
     $this->AddToContainer($field, $container);
 }
Ejemplo n.º 4
0
<?php

// Page Logic
$home_text = 'Congratulations! You have made it to the front page of our website! Won&apos;t you also please try to log in?';
$home_link = 'Go to the login page.';
$listheaders = array("Recipe Name");
$recipes = Recipe::LoadNewest(50, 0);
// Page Output
include_once 'Pages/OnAllPages.php';
$RTK->AddElement(new RTK_Header("Welcome to securipe"));
$RTK->AddElement(new RTK_Textview($home_text));
// Show newest recipies
if (_array::IsLongerThan($recipes, 0)) {
    $list = new RTK_Listview($listheaders);
    foreach ($recipes as $recipe) {
        $link = new RTK_Link('ViewRecipe' . URLPAGEEXT . '?id=' . $recipe->GetId(), $recipe->GetTitle());
        $list->AddRow(array($link));
    }
    $RTK->AddElement($list);
}
Ejemplo n.º 5
0
 /**
  * resolve the path with insensitive behavioral pattern
  * @param string $path target path to resolve
  * @param boolean $convert_to_real_path should the function convert the ultimate to realpath?
  * @param boolean $cache_built_path should enable caching during the building path?
  * @return string|null is path exists the resolved path will be returned otherwise null
  */
 public static function resolve_path($path, $convert_to_real_path = 1, $cache_built_path = 0)
 {
     # check if string is valid
     if (!strlen($path)) {
         return FALSE;
     }
     # a primary check
     if (file_exists($path)) {
         return $path;
     }
     # open the cache file
     require_once ZINUX_ROOT . 'kernel/caching/xCache.php';
     # we will use fileCache to cache
     # don't use xCache it will overload the session file
     $fc = new \zinux\kernel\caching\fileCache(__CLASS__);
     # create a base cache signiture
     $base_cache_sig = __FUNCTION__ . "@";
     # create the cache sig
     $cache_sig = "{$base_cache_sig}" . strtolower($path);
     # check cache file and validate it
     if ($fc->isCached($cache_sig) && file_exists($fc->fetch($cache_sig))) {
         # it was a HIT!
         return $fc->fetch($cache_sig);
     }
     # if it is ab
     $is_absolute_path = $path[0] == DIRECTORY_SEPARATOR;
     # depart the path
     # normalizing array's parts
     require_once '_array.php';
     # create a path part
     $path_parts = explode(DIRECTORY_SEPARATOR, strtolower($path));
     # normalize the path parts
     _array::array_normalize($path_parts);
     # a fail safe
     if (!count($path_parts)) {
         return false;
     }
     # UNIX fs style
     $resolved_path = $is_absolute_path ? "" : ".";
     # WINNT fs style
     require_once 'string.php';
     if (string::Contains($path_parts[0], ":")) {
         $is_absolute_path = 1;
         $resolved_path = $is_absolute_path ? "{$path_parts[0]}:" : "." . DIRECTORY_SEPARATOR;
     }
     # create a departed array
     $depart = explode(DIRECTORY_SEPARATOR, $path);
     # normalize the array
     _array::array_normalize($depart);
     # fetch the target file's name
     $file = $depart[count($depart) - 1];
     # unset the file's name
     unset($depart[count($depart) - 1]);
     # create a cache sig
     $this_cache_sig = $base_cache_sig . strtolower(DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $depart));
     # check for cache for files directory
     if ($fc->isCached($this_cache_sig)) {
         # fetch the file's directory
         $resolved_path = $fc->fetch($this_cache_sig);
         # through a hunch for file's address
         $hunch = $resolved_path . DIRECTORY_SEPARATOR . $file;
         if (file_exists($hunch)) {
             $resolved_path = $hunch;
             goto __RETURN;
         }
         # update the directory which bellow FOREACH will search under
         $path_parts = array($path_parts[count($path_parts) - 1]);
     }
     # do a BFS in subdirz
     foreach ($path_parts as $part) {
         if (!empty($part)) {
             $target_path = $resolved_path . DIRECTORY_SEPARATOR . $part;
             # create cache sig for this path
             $this_cache_sig = $base_cache_sig . strtolower($target_path);
             # check for fore head cache existance
             if ($fc->isCached($this_cache_sig)) {
                 $target_path = $fc->fetch($this_cache_sig);
                 if ($target_path[strlen($target_path) - 1] == DIRECTORY_SEPARATOR) {
                     $target_path = strlen($target_path, 0, strlen($target_path) - 1);
                 }
             }
             # check target path
             if (file_exists($target_path)) {
                 if ($cache_built_path) {
                     $fc->save($this_cache_sig, $target_path);
                 }
                 $resolved_path = $target_path;
                 continue;
             } else {
                 # delete any possible miss-formed cache data regarding to current path
                 $fc->delete($this_cache_sig);
             }
             # a fail safe
             if (!is_readable($resolved_path)) {
                 return false;
             }
             $files = scandir($resolved_path);
             $match_found = FALSE;
             foreach ($files as $file) {
                 if (strtolower($file) == strtolower($part)) {
                     # flag found
                     $match_found = TRUE;
                     # update target path
                     $target_path = $resolved_path . DIRECTORY_SEPARATOR . $file;
                     # update cache sig for this file
                     $this_cache_sig = $base_cache_sig . strtolower($resolved_path . DIRECTORY_SEPARATOR . $part);
                     # cache the path
                     $fc->save($this_cache_sig, $target_path);
                     # update resolved path
                     $resolved_path = $target_path;
                     # goto for next file iter.
                     break;
                 }
             }
             if (!$match_found) {
                 return FALSE;
             }
         }
     }
     __RETURN:
     if ($convert_to_real_path) {
         $resolved_path = realpath($resolved_path);
     }
     # cache the result
     $fc->save($cache_sig, $resolved_path);
     return $resolved_path;
 }