Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • AdjustImage
  • AdjustThumbnail
  • EditBlock
  • GalleryBlock
  • GalleryController
  • Hooks
  • Image
  • ImageUpload
  • ManageBlock
  • Model
  • Module
  • NodeRelation
  • PopImage
  • PopOrUploadImage
  • SaveOperation
  • Thumbnail
  • ThumbnailDecorator
  • ThumbnailOperation
  • UploadImage
  • UploadOperation
  1 <?php
  2 
  3 /*
  4  * This file is part of the Icybee package.
  5  *
  6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
  7  *
  8  * For the full copyright and license information, please view the LICENSE
  9  * file that was distributed with this source code.
 10  */
 11 
 12 namespace Icybee\Modules\Images;
 13 
 14 use ICanBoogie\I18n;
 15 use ICanBoogie\Operation;
 16 
 17 use Brickrouge\Element;
 18 
 19 // @todo-20130521: use Thumbnail and version $icon-m
 20 
 21 class ImageUpload extends \Icybee\Modules\Files\FileUpload
 22 {
 23     const THUMBNAIL_WIDTH = 64;
 24     const THUMBNAIL_HEIGHT = 64;
 25 
 26     static protected function add_assets(\Brickrouge\Document $document)
 27     {
 28         parent::add_assets($document);
 29 
 30         $document->js->add(DIR . 'public/slimbox.js');
 31         $document->css->add(DIR . 'public/slimbox.css');
 32         $document->js->add(DIR . 'public/module.js');
 33         $document->css->add(DIR . 'public/module.css');
 34     }
 35 
 36     protected function preview($path)
 37     {
 38         global $core;
 39 
 40         $w = $this->w;
 41         $h = $this->h;
 42 
 43         $url = Operation::encode
 44         (
 45             'thumbnailer/get', array
 46             (
 47                 'src' => $path,
 48                 'w' => $w,
 49                 'h' => $h,
 50                 'format' => 'jpeg',
 51                 'quality' => 90,
 52                 'background' => 'silver,white,medium',
 53                 'uniqid' => uniqid()
 54             )
 55         );
 56 
 57         $img = new Element
 58         (
 59             'img', array
 60             (
 61                 'src' => $url,
 62                 'width' => $w,
 63                 'height' => $h,
 64                 'alt' => ''
 65             )
 66         );
 67 
 68         $repository = $core->config['repository.temp'];
 69 
 70         if (strpos($path, $repository) === 0)
 71         {
 72             return $img;
 73         }
 74 
 75         return '<a href="' . $path . '&amp;uniqid=' . uniqid() . '" rel="lightbox">' . $img . '</a>';
 76     }
 77 
 78     protected function details($path)
 79     {
 80         $path = $this['value'];
 81 
 82         list($entry_width, $entry_height) = getimagesize($_SERVER['DOCUMENT_ROOT'] . $path);
 83 
 84         $w = $entry_width;
 85         $h = $entry_height;
 86 
 87         #
 88         # if the image is larger then the thumbnail dimensions, we resize the image using
 89         # the "surface" mode.
 90         #
 91 
 92         $resized = false;
 93 
 94         if (($w * $h) > (self::THUMBNAIL_WIDTH * self::THUMBNAIL_HEIGHT))
 95         {
 96             $resized = true;
 97 
 98             $ratio = sqrt($w * $h);
 99 
100             $w = round($w / $ratio * self::THUMBNAIL_WIDTH);
101             $h = round($h / $ratio * self::THUMBNAIL_HEIGHT);
102         }
103 
104         $this->w = $w;
105         $this->h = $h;
106 
107         #
108         # infos
109         #
110 
111         $details = array
112         (
113 //          '<span title="' . $path . '">' . basename($path) . '</span>',
114             I18n\t('Image size: {0}×{1}px', array($entry_width, $entry_height))
115         );
116 
117         if (($entry_width != $w) || ($entry_height != $h))
118         {
119             $details[] = I18n\t('Display ratio: :ratio%', array(':ratio' => round(($w * $h) / ($entry_width * $entry_height) * 100)));
120         }
121         else
122         {
123             $details[] = I18n\t('Displayed as is');
124         }
125 
126         $details[] = I18n\format_size(filesize($_SERVER['DOCUMENT_ROOT'] . $path));
127 
128         return $details;
129     }
130 }
Autodoc API documentation generated by ApiGen 2.8.0