예제 #1
0
 /**
  * Returns the xhtml equivalent of the opening of a select input.  This is basically a nice little wrapper
  * to make sure that id's are placed in names and also that it's xhtml compliant.\n
  * Parameters:
  * - 'name' - The name of the field.  Defaults to 'input'.
  * - 'extra' - Text to append to the <input>-statement, ex. for javascript-validation code.  Defaults to ''.
  * - 'html_id' - Id to use for the html id="".  Defaults to an autogenerated value.
  * - 'multiple' - Boolean of whether or not this is should show multiple items.  Defaults to false.
  * - 'size' - Number of items to show if multiple is set to true.  Defaults to 3.
  * - 'params' - An array of key/value pairs to add as attributes to the input tag.  These will merge into any
  *      additional parameters you pass along in to the $params hash that aren't parsed by the function.
  *
  * @param array An array of parameters to pass to the method.  Unrecognized parameters will be added as attributes to the
  *        tag and merged correctly with anything in the 'params' key if passed.
  * @param boolean Test whether keys are all valid or not.  Not helpful if you're
  *        passing extra key/values along, but good for debugging.
  * @return string
  * @author Ted Kulp
  */
 public function create_input_select($params = array(), $check_keys = false)
 {
     $default_params = array('name' => coalesce_key($params, 'name', 'input', FILTER_SANITIZE_STRING), 'extra' => coalesce_key($params, 'extra', ''), 'multiple' => coalesce_key($params, 'multiple', false, FILTER_VALIDATE_BOOLEAN), 'size' => coalesce_key($params, 'size', 3, FILTER_SANITIZE_NUMBER_INT), 'params' => coalesce_key($params, 'params', array()));
     $default_params['id'] = coalesce_key($params, 'html_id', SilkResponse::make_dom_id($default_params['name']), FILTER_SANITIZE_STRING);
     if ($check_keys && !are_all_keys_valid($params, $default_params)) {
         throw new SilkInvalidKeyException(invalid_key($params, $default_params));
     }
     //Combine EVERYTHING together into a big managerie
     $params = array_merge($default_params, forms()->strip_extra_params($params, $default_params, 'params'));
     unset($params['params']);
     if ($params['multiple']) {
         $params['multiple'] = 'multiple';
     } else {
         unset($params['multiple']);
         unset($params['size']);
     }
     $extra = '';
     if ($params['extra']) {
         $extra = $params['extra'];
     }
     unset($params['extra']);
     return forms()->create_start_tag('select', $params, false, $extra);
 }
예제 #2
0
 /**
  * Given a has of key/value pairs, generates and redirects to a URL
  * for this application.  Takes the same parameters as
  * SilkResponse::create_url.
  *
  * @param array List of parameters used to create the url
  * @return void
  * @author Ted Kulp
  **/
 public static function redirect_to_action($params = array())
 {
     SilkResponse::redirect(SilkResponse::create_url($params));
 }
예제 #3
0
/**
 * Global wrapper for CmsResponse::redirect()
 *
 * @param $to The url to redirect to
 *
 * @return void
 * @author Ted Kulp
 **/
function redirect($to)
{
    SilkResponse::redirect($to);
}