public static function form() { $args = func_get_args(); $options = array_pop($args); // use GET method as default if (!isset($options['hash']['method'])) { $options['hash']['method'] = 'get'; } $html = '<form' . html_attributes($options['hash']) . '>' . "\n" . $options['fn']() . '</form>'; return $html; }
public static function form() { $args = func_get_args(); $options = array_pop($args); // use empty string as default action if (!isset($options['hash']['action'])) { $options['hash']['action'] = ""; } // use GET method as default if (!isset($options['hash']['method'])) { $options['hash']['method'] = 'get'; } // evaluate action url $app_key = \Hook\Application\Context::getKey(); $action_url = parse_url($options['hash']['action']); if (!isset($action_url['query'])) { $action_url['query'] = 'X-App-Id=' . $app_key->app_id . '&X-App-Key=' . $app_key->key; } $options['hash']['action'] = unparse_url($action_url); $html = '<form' . html_attributes($options['hash']) . '>' . "\n" . $options['fn']() . '</form>'; return $html; }
public static function select($args, $attributes) { $options = array_remove($attributes, 'options'); $selected_option = array_remove($attributes, 'selected'); if (!isset($attributes['name']) && isset($args[0])) { // TODO: analyse context recursively if (Router::getInstance()->view->context->count() > 0) { $attributes['name'] = Router::getInstance()->view->context->top() . '[' . $args[0] . ']'; } else { $attributes['name'] = $args[0]; } } $html_options = ''; foreach ($options as $key => $value) { $key = isset($value['_id']) ? $value['_id'] : $key; $value = isset($value['name']) ? $value['name'] : $value; $is_selected = $selected_option == $key ? ' selected="selected"' : ''; $html_options .= '<option value="' . $key . '"' . $is_selected . '>' . $value . '</option>'; } return array('<select' . html_attributes($attributes) . '>' . $html_options . '</select>', 'raw'); }
/** * Opens a HTML div tag. * * @param array $options * * @return string '</div>' */ function open_div(array $options = array()) { return '<div' . html_attributes($options) . '>'; }
<tbody> <?php if (!empty($data)) { ?> <?php foreach ($data as $row) { ?> <tr <?php echo html_attributes($row->getAttributes()); ?> > <?php foreach ($row->getData() as $cell_name => $cell) { ?> <td <?php echo html_attributes($row->getCellAttributes($cell_name)); ?> > <?php echo $cell; ?> </td> <?php } ?> </tr> <?php } ?> <?php }
public static function embed_img($args, $attributes = null) { $cid = \Hook\View\MailHelper::embed($args); return array('<img src="' . $cid . '"' . html_attributes($attributes) . ' />', 'raw'); }
/** construct the opening of a HTML form * * @param string $action the url to submit to * @param string $method either get or post (default) * @param string|array $attributes holds the attributes to add to the tag * @return string ready-to-user HTML-code */ function html_form($action, $method = 'post', $attributes = '') { $method = 0 == strcasecmp($method, 'get') ? 'get' : 'post'; return '<form' . html_attributes(array('action' => $action, 'method' => $method)) . html_attributes($attributes) . '>'; }