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\Operation;
 15 
 16 use Brickrouge\Element;
 17 
 18 class PopOrUploadImage extends Element
 19 {
 20     const POP_OPTIONS = '#poporuploadimage-pop-options';
 21     const UPLOAD_OPTIONS = '#poporuploadimage-upload-options';
 22 
 23     private $pop_image;
 24 
 25     static protected function add_assets(\Brickrouge\Document $document)
 26     {
 27         parent::add_assets($document);
 28 
 29         $document->js->add(DIR . 'public/module.js');
 30         $document->css->add(DIR . 'public/module.css');
 31     }
 32 
 33     public function __construct(array $attributes=array())
 34     {
 35         $attributes += [
 36 
 37             self::POP_OPTIONS => [],
 38             self::UPLOAD_OPTIONS => []
 39 
 40         ];
 41 
 42         parent::__construct
 43         (
 44             'div', $attributes + array
 45             (
 46                 Element::CHILDREN => array
 47                 (
 48                     $this->pop_image = new PopImage($attributes[self::POP_OPTIONS]),
 49                     $this->upload_image = new UploadImage($attributes[self::UPLOAD_OPTIONS] + [
 50 
 51                         UploadImage::FILE_WITH_LIMIT => true,
 52 
 53                         'data-name' => Image::PATH,
 54                         'data-upload-url' => Operation::encode('images/save')
 55                     ])
 56                 ),
 57 
 58                 Element::WIDGET_CONSTRUCTOR => 'PopOrUploadImage'
 59             )
 60         );
 61     }
 62 
 63     protected function alter_class_names(array $class_names)
 64     {
 65         return parent::alter_class_names($class_names) + array
 66         (
 67             'widget-class' => 'widget-pop-or-upload-image'
 68         );
 69     }
 70 
 71     public function offsetExists($attribute)
 72     {
 73         if ($attribute == 'name' || $attribute == 'value')
 74         {
 75             return isset($this->pop_image[$attribute]);
 76         }
 77 
 78         return parent::offsetExists($attribute);
 79     }
 80 
 81     public function offsetSet($attribute, $value)
 82     {
 83         if ($attribute == 'name' || $attribute == 'value')
 84         {
 85             $this->pop_image[$attribute] = $value;
 86 
 87             return;
 88         }
 89 
 90         parent::offsetSet($attribute, $value);
 91     }
 92 
 93     public function offsetGet($attribute)
 94     {
 95         if ($attribute == 'name' || $attribute == 'value')
 96         {
 97             return $this->pop_image[$attribute];
 98         }
 99 
100         return parent::offsetGet($attribute);
101     }
102 
103     public function offsetUnset($attribute)
104     {
105         if ($attribute == 'name' || $attribute == 'value')
106         {
107             unset($this->pop_image[$attribute]);
108 
109             return;
110         }
111 
112         parent::offsetUnset($attribute);
113     }
114 }
115 
116 class UploadImage extends \Brickrouge\File
117 {
118     const UPLOAD_MODE = '#uploadimage-upload-mode';
119     const UPLOAD_MODE_CREATE = 'create';
120     const UPLOAD_MODE_UPDATE = 'update';
121 
122     protected function alter_dataset(array $dataset)
123     {
124         return parent::alter_dataset($dataset) + [
125 
126             'upload-mode' => $this[self::UPLOAD_MODE] ?: self::UPLOAD_MODE_CREATE
127 
128         ];
129     }
130 }
Autodoc API documentation generated by ApiGen 2.8.0