示例#1
0
 /**
  *  Build image tags to an image asset
  *
  *  @param mixed  An image asset optionally followed by an
  *                array describing options to apply to the tag
  *                generated for this asset.<br>The asset is a
  *                string in one of the formats accepted as value
  *                of the $source argument of
  *                {@link image_path()}.<br>  The optional second
  *                argument is an array whose keys are names of
  *                attributes of the image tag and whose corresponding
  *                values are the values assigned to each
  *                attribute.  The image size can be specified in
  *                two ways: by specifying option values "width" =>
  *                <i>width</i> and "height" => <i>height</i>, or
  *                by specifying option "size" => "<i>width</i>
  *                x <i>height</i>".  If omitted, options default to:
  *                <ul>
  *                  <li>"alt" => <i>humanized filename</i></li>
  *                  <li>"width" and "height" value computed from
  *                       value of "size"</li>
  *                </ul>
  *  @return string  A image tag for each asset in the argument list
  *  @uses image_path()
  *  @uses tag()
  */
 function image_tag($source, $options = array())
 {
     $options['src'] = $this->image_path($source);
     $options['alt'] = array_key_exists('alt', $options) ? $options['alt'] : Inflector::capitalize(reset($file_array = explode('.', basename($options['src']))));
     if (isset($options['size'])) {
         $size = explode('x', $options["size"]);
         $options['width'] = reset($size);
         $options['height'] = end($size);
         unset($options['size']);
     }
     return $this->tag("img", $options);
 }
示例#2
0
 private function build_callbacks($options)
 {
     $callbacks = array();
     foreach ($options as $callback => $code) {
         if (in_array($callback, $this->javascript_callbacks)) {
             $name = 'on' . Inflector::capitalize($callback);
             $callbacks[$name] = "function(request){{$code}}";
         }
     }
     return $callbacks;
 }