/** * A button widget * @param string $name The name/id of the button * @param string $title The text written on the button * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended) **/ public function __construct($name = 'submit', $title = 'Submit', $args = null) { parent::__construct('input', array('type' => 'submit', 'name' => $name, 'class' => 'submit', 'value' => $title)); if (RTK::SetAndNotNull($args)) { $this->AddAttributes($args); } }
/** * A widget for containing/structuring other widgets (div) * @param string $id The HTML #id of the box * @param string $class The HTML .class of box * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended) **/ public function __construct($id = null, $class = null, $args = null) { parent::__construct('div', array('id' => $id, 'class' => $class)); if (RTK::SetAndNotNull($args)) { $this->AddAttributes($args); } }
/** * Add a password input field 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 $value The predefined value in the input field (not recommended, use with caution) * @param HtmlElement $container (optional) The "container" to add it to **/ public function AddPasswordField($name, $title, $value = null, $container = null) { $args = array('type' => 'password', 'name' => $name, 'id' => $name); if (RTK::SetAndNotNull($value)) { $args['value'] = $value; } $line = new HtmlElement('div', array('class' => 'formline')); $line->AddChild(new HtmlElement('label', array('for' => $name), $title)); $group = new HtmlElement('div', array('class' => 'formgroup')); $group->AddChild(new HtmlElement('input', $args)); $line->AddChild($group); $this->AddToContainer($line, $container); }
public function __tostring() { $result = RTK_EMPTYSTRING; if (RTK::SetAndNotNull($this->_list) && is_array($this->_list)) { ksort($this->_list); foreach ($this->_list as $key => $val) { if (strstr(RTK_BOOLEANPARAMETERS, '|' . $key . '|') && $val == true) { $result .= RTK_SINGLESPACE . $key; } else { $result .= RTK_SINGLESPACE . $key . '="' . $val . '"'; } } } return $result; }
<?php define("STARTTIME", microtime(true)); session_start(); define("RTK-TEST", true); error_reporting(E_ALL); ini_set('display_errors', '1'); // load all necessary config and class files, etc. include_once "class" . DIRECTORY_SEPARATOR . "RTK" . DIRECTORY_SEPARATOR . "rtk.php"; $showpage = RTK_EMPTYSTRING; if (RTK::SetAndNotNull($_GET, 'page')) { $showpage = $_GET['page']; } $showstyle = RTK_EMPTYSTRING; if (RTK::SetAndNotNull($_GET, 'style')) { $showstyle = $_GET['style']; } $pages = $styles = array(); foreach (glob('example' . DIRECTORY_SEPARATOR . '*.php') as $file) { $pages[] = pathinfo($file)['filename']; } foreach (glob(RTK_DIRECTORY . 'style' . DIRECTORY_SEPARATOR . '*') as $dir) { $styles[] = RTK::RemovePrefix(pathinfo($dir)['filename'], 'rtk-'); } if (!in_array($showpage, $pages)) { $showpage = $pages[0]; } if (!in_array($showstyle, $styles)) { $showstyle = $styles[0]; } // create the requested page
/** * Converts the element into an HTML string * @param boolean $newline Specifies whether or not to start with a newline * @return string A string containing the entire HTML structure of the element and it's children **/ public function ToString(&$newline) { $return = RTK_EMPTYSTRING; if ($this->_tag != null) { if ($newline) { $return .= RTK_OUTPUTNEWLINE; } else { $newline = true; } if ($this->_oneline <= 1) { $return .= str_repeat(RTK_OUTPUTINDENT, $this->_indent); } $return .= '<' . $this->_tag; if (RTK::SetAndNotNull($this->_attributes) && RTK::ArrayIsLongerThan($this->_attributes, 0)) { ksort($this->_attributes); foreach ($this->_attributes as $key => $val) { if (strstr(RTK_BOOLEANPARAMETERS, '|' . $key . '|') && $val == true) { $return .= RTK_SINGLESPACE . $key; } else { $return .= RTK_SINGLESPACE . $key . '="' . $val . '"'; } } } if ($this->_endtag != RTK_EMPTYSTRING) { $return .= $this->_endtag . ">"; } else { if (sizeof($this->_children) == 0) { if ($this->_content != RTK_EMPTYSTRING) { if (strstr($this->_content, RTK_NEWLINE) && !strstr(RTK_PRESERVECONTENTS, $this->_tag)) { $return .= '>'; foreach (explode(NEWLINE, $this->_content) as $line) { if ($line == RTK_EMPTYSTRING || $line[strlen($line) - 1] != '>') { $line .= '<br />'; } $return .= RTK_OUTPUTNEWLINE . str_repeat(RTK_OUTPUTINDENT, $this->_indent + 1) . $line; } $return .= RTK_OUTPUTNEWLINE . str_repeat(RTK_OUTPUTINDENT, $this->_indent) . '</' . $this->_tag . '>'; } else { $return .= '>' . $this->_content . '</' . $this->_tag . '>'; } } elseif (strstr(RTK_VOIDELEMENTS, '|' . $this->_tag . '|')) { $return .= ' />'; } elseif (strstr(RTK_NONVOIDELEMENTS, '|' . $this->_tag . '|') || $this->_oneline) { $return .= '></' . $this->_tag . '>'; } else { $return .= ' />'; } } else { if ($this->_oneline) { $return .= '>'; foreach ($this->_children as $c) { $return .= $c; } $return .= '</' . $this->_tag . '>'; } else { $return .= '>' . RTK_OUTPUTNEWLINE; if ($this->_content != RTK_EMPTYSTRING) { $return .= str_repeat(RTK_OUTPUTINDENT, $this->_indent + 1) . str_replace("\n", '<br />' . RTK_OUTPUTNEWLINE . str_repeat(RTK_OUTPUTINDENT, $this->_indent), $this->_content) . RTK_OUTPUTNEWLINE; } if (sizeof($this->_children) > 0) { $newline = false; foreach ($this->_children as $c) { $return .= $c->ToString($newline); } } $return .= RTK_OUTPUTNEWLINE . str_repeat(RTK_OUTPUTINDENT, $this->_indent) . '</' . $this->_tag . '>'; } } } } else { $sizeofchildren = sizeof($this->_children); if ($sizeofchildren > 0) { $this->UpdateChildren(); // INFO: commenting this line seems to have fixed a double-linebreak issue, but may now cause a no-linebreak in some cases... stay tuned... //if ($newline) { $return .= RTK_OUTPUTNEWLINE; } for ($i = 0; $i < $sizeofchildren; $i++) { $return .= $this->_children[$i]->ToString($newline); } } } return $return; }