/**
  * @param \Components\Io_Image $image_
  *
  * @return \Components\Uri
  */
 public static function uri(Io_Image $image_)
 {
     $path = $image_->getPathAsString();
     $extension = $image_->getMimetype()->fileExtension();
     $key = md5($path);
     Cache::set($key, $path);
     return Uri::valueOf(Environment::uriComponents('ui', 'image', "{$key}.{$extension}"));
 }
 protected function init()
 {
     parent::init();
     // FIXME (CSH) Re-implement fallback / root panel submission / find a better solution ...
     //       $this->form('POST', null, Io_Mimetype::APPLICATION_FORM_URLENCODED(), 'ISO-8859-15');
     $this->form();
     //       $this->ajaxEnabled=false;
     $this->add(new Ui_Panel_Label('labela', null, 'Google.com.hk 使用下列语言: 中文(繁體) English'));
     $this->add(new Ui_Panel_Label('labelb', null, I18n_Script::Hans()->transformToLatn('Google.com.hk 使用下列语言: 中文(繁體) English')));
     $this->add(new Ui_Panel_Label('labelc', null, I18n_Script::Hans()->transformToAscii('Google.com.hk 使用下列语言: 中文(繁體) English')));
     $this->add(new Ui_Panel_Label('labeld', null, String::toLowercaseUrlIdentifier(I18n_Script::Hans()->transformToAscii('Google.com.hk 使用下列语言: 中文(繁體) English'))));
     $this->add(new Ui_Panel_Tabs('tabs'));
     $this->tabs->add(new Ui_Panel_Disclosure('disclosure', null, 'Disclosure'));
     $this->tabs->disclosure->add(new Ui_Panel_Datetime('date'));
     $this->tabs->add(new Ui_Panel_Editor_Text('text', null, 'Text'));
     $this->tabs->add(new Ui_Panel_Image('image', Io_Image::valueOf(__DIR__ . '/test.jpg'), 'Image'));
     $this->tabs->image->attribute('width', 64);
     $this->tabs->image->embedded = true;
     $this->tabs->add(new Ui_Panel_Upload_File('file', null, 'File'));
     $this->tabs->add(new Ui_Panel_Select('list', null, 'List', ['A', 'B', 'C']));
     $this->tabs->add(new Ui_Panel_Editor_Html('html', null, 'HTML'));
     $button = new Ui_Panel_Button_Submit('submit', null, 'Submit');
     $button->callback = [$this, 'onSubmit'];
     $this->add($button);
 }
 public function render($panel_ = null)
 {
     /* @var $value \Components\Io_Image */
     if (($value = $this->value()) && $value->exists()) {
         $image = $value;
         $height = (int) $this->attribute('height');
         $width = (int) $this->attribute('width');
         if ($width || $height) {
             $dimensions = $value->getDimensions();
             if (!$width) {
                 $width = round($dimensions->x / ($dimensions->y / $height));
             } else {
                 if (!$height) {
                     $height = round($dimensions->y / ($dimensions->x / $width));
                 }
             }
             if ($this->embedded) {
                 $image = Io_Image::valueOf(Environment::pathResource('ui', 'image', 'tmp', $width, $height, $value->getName()));
                 if (false === $image->exists()) {
                     $value->scale(Point::of($width, $height));
                     $value->saveAs($image);
                 }
             }
         }
         $this->attribute('width', $width);
         $this->attribute('height', $height);
         if ($this->embedded) {
             $this->attribute('src', sprintf('data:%s;base64,%s', $image->getMimetype(), $image->getBase64()));
         } else {
             $this->attribute('src', (string) Media_Scriptlet_Engine::imageUri('thumbnail', $image->getPath(), $width, $height));
         }
     } else {
         if (null !== $value && Debug::active()) {
             Log::debug('components/ui/panel/image', 'Image for given location does not exist [%s].', $value);
         }
     }
     return parent::render();
 }
 /**
  * @param string $path_
  * @param integer $width_
  * @param integer $height_
  *
  * @return \Components\Io_Image
  */
 public static function imageCreate($path_, $width_, $height_)
 {
     return Io_Image::create($path_, new Point($width_, $height_));
 }
 public function setBackgroundImage(Io_Image $image_)
 {
     if (!$image_->exists()) {
         throw new Io_Exception('io/archive/passbook/generic', sprintf('Given background image does not exist [icon: %s].', Io_Mimetype::IMAGE_PNG(), $image_));
     }
     if (!Io_Mimetype::IMAGE_PNG()->equals($image_->getMimetype())) {
         throw new Io_Exception('io/archive/passbook/generic', sprintf('Background image must be of type %s [logo: %s].', Io_Mimetype::IMAGE_PNG(), $image_));
     }
     $this->add($image_, self::FILE_BACKGROUND);
 }
 /**
  * @param string $name_
  *
  * @return \Components\Io_Image
  */
 public function getImage($name_)
 {
     return Io_Image::forPath("{$this->m_path}/{$name_}");
 }