示例#1
0
文件: form.php 项目: dapepe/tymio
 /**
  * Returns a "<select></select>" box and selects the option matching the HTTP POST/GET data, or the value if the former is missing.
  *
  * @param string $name The <select> tag name.
  * @param array $options An associative array of options. The keys contain
  *     the captions while the array elements contain the values. You can
  *     define an option group ("<optgroup>") by specifying an array of
  *     options as the value. For options with additional XHTML attributes,
  *     specify an array with the option value as the very first element and
  *     additional attributes thereafter.
  *     Example:
  *     <code>
  *         select('pizza', array(
  *             'Regular' => array(
  *                 'Margherita'    => array('margherita', 'title' => '50% Off Special'),
  *                 'Funghi'        => 'funghi',
  *                 'Prosciutto'    => 'prosciutto',
  *                 'Salame'        => 'salame',
  *             ),
  *             'Specials' => array(
  *                 'Mexican Style' => 'mexican',
  *                 'Spicy Curry'   => 'curry',
  *             ),
  *         ));
  *     </code>
  * @param mixed $value Optional. The value to select if no matching HTTP
  *     POST/GET variable exists. Default is NULL.
  * @param array $attributes Optional. Additional attributes to include.
  *     You can use this e.g. to set a tag ID or to override the "type"
  *     attribute. Default is NULL.
  * @param string $method Optional. Default is {@link METHOD_POST}.
  * @return string
  * @uses expandOptions()
  */
 public static function select($name, array $options, $value = null, array $attributes = null, $method = self::METHOD_POST)
 {
     $selectedValue = $method == self::METHOD_POST ? HTTP::readPOST($name, $value) : HTTP::readGET($name, $value);
     return '<select name="' . HTML::entities($name) . '" ' . HTML::expandAttributes($attributes) . '>' . self::expandOptions($options, $selectedValue) . '</select>';
 }
示例#2
0
文件: index.php 项目: dapepe/tymio
     if (!$userAuthenticated) {
         if (isset($_REQUEST['username']) && $_REQUEST['username'] != '') {
             $message = 'Wrong username or password!';
         } else {
             $message = 'Please login!';
         }
         throw new Exception($message);
     }
 } catch (Exception $e) {
     if ($e->getMessage() != '') {
         $xmlMeta->addChild(new \Xily\Xml('message', $e->getMessage(), array('class' => 'alert alert-error')));
     }
     $view = 'login';
 }
 if ($view === 'login') {
     $returnUrl = HTTP::readGET('return', '');
     if (!Form::verify('loginreturn', Form::METHOD_GET)) {
         $returnUrl = '';
     }
     $xmlMeta->addChildren(array(new \Xily\Xml('tokenName', Form::getTokenName()), new \Xily\Xml('tokenValue', Form::getToken('login')), new \Xily\Xml('return', empty($returnUrl) ? $_SERVER['SCRIPT_URI'] : $returnUrl)));
 }
 // Check if there is a controller for the view
 if (file_exists(CONTROLLER_DIR . $view . '.php')) {
     include_once CONTROLLER_DIR . $view . '.php';
 }
 $controllerClass = ucfirst($view) . 'Controller';
 if (class_exists($controllerClass)) {
     $controller = new $controllerClass($locale);
     $controller->enrichMeta($xmlMeta);
     $xlyPage = $controller->getView();
 } else {