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\PropertyNotWritable;
15 
16 use Icybee\Modules\Nodes\Node;
17 
18 /**
19  * A representation of relation between an image and a node.
20  *
21  * @property-read Image $image The image associated with the node.
22  * @property-read Node $node The node.
23  * @property-read Thumbnail $thumbnail Thumbnail for the `view` version.
24  */
25 class NodeRelation
26 {
27     protected $node;
28     protected $image;
29 
30     /**
31      * Initializes the {@link $node} and {@link $image} properties.
32      *
33      * @param Node $node
34      * @param Image $image
35      */
36     public function __construct(Node $node, Image $image)
37     {
38         $this->node = $node;
39         $this->image = $image;
40     }
41 
42     public function __get($property)
43     {
44         switch ($property)
45         {
46             case 'node': return $this->node;
47             case 'image': return $this->image;
48             case 'thumbnail': return $this->thumbnail(':view');
49             default: return $this->image->$property;
50         }
51     }
52 
53     /**
54      * @throws PropertyNotWritable in attempt to set a property.
55      */
56     public function __set($property, $value)
57     {
58         throw new PropertyNotWritable(array($property, $this));
59     }
60 
61     public function __call($name, array $arguments)
62     {
63         return call_user_func_array(array($this->image, $name), $arguments);
64     }
65 
66     /**
67      * Returns an HTML representation of the image.
68      *
69      * @return string
70      */
71     public function __toString()
72     {
73         return (string) $this->image;
74     }
75 
76     /**
77      * Returns a {@link Thumbnail} instance.
78      *
79      * @param string $version The version of the thumbnail. If the version starts with a column
80      * ":", it is removed and the node's constructor is prependend to the version. e.g. ":list"
81      * becomes "news-list" for a news node. This is refered to as "shorthand version".
82      *
83      * @param mixed $additionnal_options Additionnal options.
84      *
85      * @return Thumbnail
86      */
87     public function thumbnail($version, $additionnal_options=null)
88     {
89         if ($version && $version{0} == ':')
90         {
91             $version = $this->node->constructor . '-' . substr($version, 1);
92         }
93 
94         return new Thumbnail($this->image, $version, $additionnal_options);
95     }
96 }
Autodoc API documentation generated by ApiGen 2.8.0