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
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * This file contains the cHTMLLink class.
  4:  *
  5:  * @package Core
  6:  * @subpackage GUI_HTML
  7:  * @version SVN Revision $Rev:$
  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:  * cHTMLLink class represents a link.
 20:  *
 21:  * @package Core
 22:  * @subpackage GUI_HTML
 23:  */
 24: class cHTMLLink extends cHTMLContentElement {
 25: 
 26:     /* Stores the link location */
 27:     protected $_link;
 28: 
 29:     /* Stores the content */
 30:     protected $_content;
 31: 
 32:     /* Stores the anchor */
 33:     protected $_anchor;
 34: 
 35:     /* Stores the custom entries */
 36:     protected $_custom;
 37: 
 38:     protected $_image;
 39: 
 40:     /**
 41:      * Constructor.
 42:      * Creates an HTML link.
 43:      *
 44:      * @param string $href String with the location to link to
 45:      */
 46:     public function __construct($href = '') {
 47:         global $sess;
 48:         parent::__construct();
 49: 
 50:         $this->setLink($href);
 51:         $this->_tag = 'a';
 52:         $this->_image = '';
 53: 
 54:         // Check for backend
 55:         if (is_object($sess)) {
 56:             if ($sess->classname == 'cSession') {
 57:                 $this->enableAutomaticParameterAppend();
 58:             }
 59:         }
 60:     }
 61: 
 62:     public function enableAutomaticParameterAppend() {
 63:         return $this->setEvent('click', 'var doit = true; try { var i = get_registered_parameters() } catch (e) { doit = false; }; if (doit == true) { this.href += i; }');
 64:     }
 65: 
 66:     public function disableAutomaticParameterAppend() {
 67:         return $this->unsetEvent('click');
 68:     }
 69: 
 70:     /**
 71:      * Sets the link to a specific location
 72:      *
 73:      * @param string $href String with the location to link to
 74:      * @return cHTMLLink $this
 75:      */
 76:     public function setLink($href) {
 77:         $this->_link = $href;
 78:         $this->_type = 'link';
 79: 
 80:         if (strpos($href, 'javascript:') !== false) {
 81:             $this->disableAutomaticParameterAppend();
 82:         }
 83: 
 84:         return $this;
 85:     }
 86: 
 87:     /**
 88:      * Sets the target frame
 89:      *
 90:      * @param string $target Target frame identifier
 91:      * @return cHTMLLink $this
 92:      */
 93:     public function setTargetFrame($target) {
 94:         return $this->updateAttribute('target', $target);
 95:     }
 96: 
 97:     /**
 98:      * Sets a CONTENIDO link (area, frame, action)
 99:      *
100:      * @param string $targetarea Target backend area
101:      * @param string $targetframe Target frame (1-4)
102:      * @param string $targetaction Target action
103:      * @return cHTMLLink $this
104:      */
105:     public function setCLink($targetarea, $targetframe, $targetaction = '') {
106:         $this->_targetarea = $targetarea;
107:         $this->_targetframe = $targetframe;
108:         $this->_targetaction = $targetaction;
109:         $this->_type = 'clink';
110: 
111:         return $this;
112:     }
113: 
114:     /**
115:      * Sets a multilink
116:      *
117:      * @param string $righttoparea Area (right top)
118:      * @param string $righttopaction Action (right top)
119:      * @param string $rightbottomarea Area (right bottom)
120:      * @param string $rightbottomaction Action (right bottom)
121:      * @return cHTMLLink $this
122:      */
123:     public function setMultiLink($righttoparea, $righttopaction, $rightbottomarea, $rightbottomaction) {
124:         $this->_targetarea = $righttoparea;
125:         $this->_targetframe = 3;
126:         $this->_targetaction = $righttopaction;
127:         $this->_targetarea2 = $rightbottomarea;
128:         $this->_targetframe2 = 4;
129:         $this->_targetaction2 = $rightbottomaction;
130:         $this->_type = 'multilink';
131: 
132:         return $this;
133:     }
134: 
135:     /**
136:      * Sets a custom attribute to be appended to the link
137:      *
138:      * @param string $key Parameter name
139:      * @param string $value Parameter value
140:      * @return cHTMLLink $this
141:      */
142:     public function setCustom($key, $value) {
143:         $this->_custom[$key] = $value;
144: 
145:         return $this;
146:     }
147: 
148:     public function setImage($src) {
149:         $this->_image = $src;
150: 
151:         return $this;
152:     }
153: 
154:     /**
155:      * Unsets a previous set custom attribute
156:      *
157:      * @param string $key Parameter name
158:      * @return cHTMLLink $this
159:      */
160:     public function unsetCustom($key) {
161:         if (isset($this->_custom[$key])) {
162:             unset($this->_custom[$key]);
163:         }
164: 
165:         return $this;
166:     }
167: 
168:     public function getHref() {
169:         global $sess;
170: 
171:         if (is_array($this->_custom)) {
172:             $custom = '';
173: 
174:             foreach ($this->_custom as $key => $value) {
175:                 $custom .= "&$key=$value";
176:             }
177:         }
178: 
179:         if ($this->_anchor) {
180:             $anchor = '#' . $this->_anchor;
181:         } else {
182:             $anchor = '';
183:         }
184: 
185:         switch ($this->_type) {
186:             case 'link':
187:                 $custom = '';
188:                 if (is_array($this->_custom)) {
189:                     foreach ($this->_custom as $key => $value) {
190:                         if ($custom == '') {
191:                             $custom .= "?$key=$value";
192:                         } else {
193:                             $custom .= "&$key=$value";
194:                         }
195:                     }
196:                 }
197: 
198:                 return $this->_link . $custom . $anchor;
199:                 break;
200:             case 'clink':
201:                 $this->disableAutomaticParameterAppend();
202:                 return 'main.php?area=' . $this->_targetarea . '&frame=' . $this->_targetframe . '&action=' . $this->_targetaction . $custom . '&contenido=' . $sess->id . $anchor;
203:                 break;
204:             case 'multilink':
205:                 $this->disableAutomaticParameterAppend();
206:                 $tmp_mstr = 'javascript:Con.multiLink(\'%s\',\'%s\',\'%s\',\'%s\');';
207:                 $mstr = sprintf($tmp_mstr, 'right_top', $sess->url('main.php?area=' . $this->_targetarea . '&frame=' . $this->_targetframe . '&action=' . $this->_targetaction . $custom), 'right_bottom', $sess->url('main.php?area=' . $this->_targetarea2 . '&frame=' . $this->_targetframe2 . '&action=' . $this->_targetaction2 . $custom));
208:                 return $mstr;
209:                 break;
210:         }
211:     }
212: 
213:     /**
214:      * Sets an anchor
215:      * Only works for the link types Link and cLink.
216:      *
217:      * @param string $content Anchor name
218:      * @return cHTMLLink $this
219:      */
220:     public function setAnchor($anchor) {
221:         $this->_anchor = $anchor;
222: 
223:         return $this;
224:     }
225: 
226:     /**
227:      * Renders the link
228:      *
229:      * @return string Rendered HTML
230:      */
231:     public function toHTML() {
232:         $this->updateAttribute('href', $this->getHref());
233: 
234:         if ($this->_image != '') {
235:             $image = new cHTMLImage($this->_image);
236:             $this->setContent($image);
237:         }
238: 
239:         return parent::toHTML();
240:     }
241: 
242: }
243: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen