Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SIWECOS
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cHTML
  • cHTMLAlignmentTable
  • cHTMLArticle
  • cHTMLAside
  • cHTMLAudio
  • cHTMLButton
  • cHTMLCanvas
  • cHTMLCheckbox
  • cHTMLContentElement
  • cHTMLDiv
  • cHTMLFieldset
  • cHTMLFooter
  • cHTMLForm
  • cHTMLFormElement
  • cHTMLHeader
  • cHTMLHgroup
  • cHTMLHiddenField
  • cHTMLIFrame
  • cHTMLImage
  • cHTMLLabel
  • cHTMLLegend
  • cHTMLLink
  • cHTMLList
  • cHTMLListItem
  • cHTMLNav
  • cHTMLOptgroup
  • cHTMLOptionElement
  • cHTMLParagraph
  • cHTMLPasswordbox
  • cHTMLRadiobutton
  • cHTMLScript
  • cHTMLSection
  • cHTMLSelectElement
  • cHTMLSpan
  • cHTMLTable
  • cHTMLTableBody
  • cHTMLTableData
  • cHTMLTableHead
  • cHTMLTableHeader
  • cHTMLTableRow
  • cHTMLTextarea
  • cHTMLTextbox
  • cHTMLTime
  • cHTMLUpload
  • cHTMLVideo
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the cHTMLImage class.
  5:  *
  6:  * @package Core
  7:  * @subpackage GUI_HTML
  8:  *
  9:  * @author Simon Sprankel
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * cHTMLImage class represents an image.
 20:  *
 21:  * @package Core
 22:  * @subpackage GUI_HTML
 23:  */
 24: class cHTMLImage extends cHTML {
 25: 
 26:     /**
 27:      * Constructor to create an instance of this class.
 28:      *
 29:      * Creates an HTML IMG element.
 30:      *
 31:      * @param mixed $src [optional]
 32:      *         image source
 33:      * @param string $class [optional]
 34:      *         the class of this element
 35:      */
 36:     public function __construct($src = NULL, $class = '') {
 37:         parent::__construct();
 38: 
 39:         $this->_tag = 'img';
 40:         $this->_contentlessTag = true;
 41: 
 42:         $this->setSrc($src);
 43:         $this->setClass($class);
 44:     }
 45: 
 46:     /**
 47:      * Sets the image's source file
 48:      *
 49:      * @param string $src
 50:      *         source location
 51:      * @return cHTMLImage
 52:      *         $this for chaining
 53:      */
 54:     public function setSrc($src) {
 55:         if ($src === NULL) {
 56:             $src = 'images/spacer.gif';
 57:         }
 58: 
 59:         return $this->updateAttribute('src', $src);
 60:     }
 61: 
 62:     /**
 63:      * Sets the image's width
 64:      *
 65:      * @param int $width
 66:      *         Image width
 67:      * @return cHTMLImage
 68:      *         $this for chaining
 69:      */
 70:     public function setWidth($width) {
 71:         return $this->updateAttribute('width', $width);
 72:     }
 73: 
 74:     /**
 75:      * Sets the image's height
 76:      *
 77:      * @param int $height
 78:      *         Image height
 79:      * @return cHTMLImage
 80:      *         $this for chaining
 81:      */
 82:     public function setHeight($height) {
 83:         return $this->updateAttribute('height', $height);
 84:     }
 85: 
 86:     /**
 87:      * Sets the border size
 88:      *
 89:      * @param int $border
 90:      *         Border size
 91:      * @return cHTMLImage
 92:      *         $this for chaining
 93:      */
 94:     public function setBorder($border) {
 95:         return $this->updateAttribute('border', $border);
 96:     }
 97: 
 98:     /**
 99:      * Apply dimensions from the source image
100:      */
101:     public function applyDimensions() {
102:         // Try to open the image
103:         list($width, $height) = @getimagesize(cRegistry::getBackendPath() . $this->getAttribute('src'));
104: 
105:         if (!empty($width) && !empty($height)) {
106:             $this->setWidth($width);
107:             $this->setHeight($height);
108:         }
109:     }
110: 
111: }
112: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0