Example #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);
 }
Example #2
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);
}
Example #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);
 }