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

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 cHTMLLink class.
  5:  *
  6:  * @package Core
  7:  * @subpackage GUI_HTML
  8:  * @version SVN Revision $Rev:$
  9:  *
 10:  * @author Simon Sprankel
 11:  * @copyright four for business AG <www.4fb.de>
 12:  * @license http://www.contenido.org/license/LIZENZ.txt
 13:  * @link http://www.4fb.de
 14:  * @link http://www.contenido.org
 15:  */
 16: 
 17: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 18: 
 19: /**
 20:  * cHTMLLink class represents a link.
 21:  *
 22:  * @package Core
 23:  * @subpackage GUI_HTML
 24:  */
 25: class cHTMLLink extends cHTMLContentElement {
 26: 
 27:     /**
 28:      * Stores the link location
 29:      *
 30:      * @var unknown_type
 31:      */
 32:     protected $_link;
 33: 
 34:     /**
 35:      * Stores the content
 36:      *
 37:      * @var unknown_type
 38:      */
 39:     protected $_content;
 40: 
 41:     /**
 42:      * Stores the anchor
 43:      *
 44:      * @var unknown_type
 45:      */
 46:     protected $_anchor;
 47: 
 48:     /**
 49:      * Stores the custom entries
 50:      *
 51:      * @var unknown_type
 52:      */
 53:     protected $_custom;
 54: 
 55:     /**
 56:      *
 57:      * @var unknown_type
 58:      */
 59:     protected $_image;
 60: 
 61:     /**
 62:      * Constructor.
 63:      * Creates an HTML link.
 64:      *
 65:      * @param string $href [optional]
 66:      *         String with the location to link to
 67:      */
 68:     public function __construct($href = '') {
 69:         global $sess;
 70:         parent::__construct();
 71: 
 72:         $this->setLink($href);
 73:         $this->_tag = 'a';
 74:         $this->_image = '';
 75: 
 76:         // Check for backend
 77:         if (is_object($sess)) {
 78:             if ($sess->classname == 'cSession') {
 79:                 $this->enableAutomaticParameterAppend();
 80:             }
 81:         }
 82:     }
 83: 
 84:     /**
 85:      *
 86:      * @return cHTML
 87:      *         $this for chaining
 88:      */
 89:     public function enableAutomaticParameterAppend() {
 90:         return $this->setEvent('click', 'var doit = true; try { var i = get_registered_parameters() } catch (e) { doit = false; }; if (doit == true) { this.href += i; }');
 91:     }
 92: 
 93:     /**
 94:      *
 95:      * @return cHTML
 96:      *         $this for chaining
 97:      */
 98:     public function disableAutomaticParameterAppend() {
 99:         return $this->unsetEvent('click');
100:     }
101: 
102:     /**
103:      * Sets the link to a specific location
104:      *
105:      * @param string $href
106:      *         String with the location to link to
107:      * @return cHTMLLink
108:      *         $this for chaining
109:      */
110:     public function setLink($href) {
111:         $this->_link = $href;
112:         $this->_type = 'link';
113: 
114:         if (strpos($href, 'javascript:') !== false) {
115:             $this->disableAutomaticParameterAppend();
116:         }
117: 
118:         return $this;
119:     }
120: 
121:     /**
122:      * Sets the target frame
123:      *
124:      * @param string $target
125:      *         Target frame identifier
126:      * @return cHTMLLink
127:      *         $this for chaining
128:      */
129:     public function setTargetFrame($target) {
130:         return $this->updateAttribute('target', $target);
131:     }
132: 
133:     /**
134:      * Sets a CONTENIDO link (area, frame, action)
135:      *
136:      * @param string $targetarea
137:      *         Target backend area
138:      * @param string $targetframe
139:      *         Target frame (1-4)
140:      * @param string $targetaction [optional]
141:      *         Target action
142:      * @return cHTMLLink
143:      *         $this for chaining
144:      */
145:     public function setCLink($targetarea, $targetframe, $targetaction = '') {
146:         $this->_targetarea = $targetarea;
147:         $this->_targetframe = $targetframe;
148:         $this->_targetaction = $targetaction;
149:         $this->_type = 'clink';
150: 
151:         return $this;
152:     }
153: 
154:     /**
155:      * Sets a multilink
156:      *
157:      * @param string $righttoparea
158:      *         Area (right top)
159:      * @param string $righttopaction
160:      *         Action (right top)
161:      * @param string $rightbottomarea
162:      *         Area (right bottom)
163:      * @param string $rightbottomaction
164:      *         Action (right bottom)
165:      * @return cHTMLLink
166:      *         $this for chaining
167:      */
168:     public function setMultiLink($righttoparea, $righttopaction, $rightbottomarea, $rightbottomaction) {
169:         $this->_targetarea = $righttoparea;
170:         $this->_targetframe = 3;
171:         $this->_targetaction = $righttopaction;
172:         $this->_targetarea2 = $rightbottomarea;
173:         $this->_targetframe2 = 4;
174:         $this->_targetaction2 = $rightbottomaction;
175:         $this->_type = 'multilink';
176: 
177:         return $this;
178:     }
179: 
180:     /**
181:      * Sets a custom attribute to be appended to the link
182:      *
183:      * @param string $key
184:      *         Parameter name
185:      * @param string $value
186:      *         Parameter value
187:      * @return cHTMLLink
188:      *         $this for chaining
189:      */
190:     public function setCustom($key, $value) {
191:         $this->_custom[$key] = $value;
192: 
193:         return $this;
194:     }
195: 
196:     /**
197:      *
198:      * @param unknown_type $src
199:      * @return cHTMLLink
200:      *         $this for chaining
201:      */
202:     public function setImage($src) {
203:         $this->_image = $src;
204: 
205:         return $this;
206:     }
207: 
208:     /**
209:      * Unsets a previous set custom attribute
210:      *
211:      * @param string $key
212:      *         Parameter name
213:      * @return cHTMLLink
214:      *         $this for chaining
215:      */
216:     public function unsetCustom($key) {
217:         if (isset($this->_custom[$key])) {
218:             unset($this->_custom[$key]);
219:         }
220: 
221:         return $this;
222:     }
223: 
224:     /**
225:      *
226:      * @return string
227:      */
228:     public function getHref() {
229:         global $sess;
230: 
231:         if (is_array($this->_custom)) {
232:             $custom = '';
233: 
234:             foreach ($this->_custom as $key => $value) {
235:                 $custom .= "&$key=$value";
236:             }
237:         }
238: 
239:         if ($this->_anchor) {
240:             $anchor = '#' . $this->_anchor;
241:         } else {
242:             $anchor = '';
243:         }
244: 
245:         switch ($this->_type) {
246:             case 'link':
247:                 $custom = '';
248:                 if (is_array($this->_custom)) {
249:                     foreach ($this->_custom as $key => $value) {
250:                         if ($custom == '') {
251:                             $custom .= "?$key=$value";
252:                         } else {
253:                             $custom .= "&$key=$value";
254:                         }
255:                     }
256:                 }
257: 
258:                 return $this->_link . $custom . $anchor;
259:                 break;
260:             case 'clink':
261:                 $this->disableAutomaticParameterAppend();
262:                 return 'main.php?area=' . $this->_targetarea . '&frame=' . $this->_targetframe . '&action=' . $this->_targetaction . $custom . '&contenido=' . $sess->id . $anchor;
263:                 break;
264:             case 'multilink':
265:                 $this->disableAutomaticParameterAppend();
266:                 $tmp_mstr = 'javascript:Con.multiLink(\'%s\',\'%s\',\'%s\',\'%s\');';
267:                 $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));
268:                 return $mstr;
269:                 break;
270:         }
271:     }
272: 
273:     /**
274:      * Sets an anchor
275:      * Only works for the link types Link and cLink.
276:      *
277:      * @param string $content
278:      *         Anchor name
279:      * @return cHTMLLink
280:      *         $this for chaining
281:      */
282:     public function setAnchor($anchor) {
283:         $this->_anchor = $anchor;
284: 
285:         return $this;
286:     }
287: 
288:     /**
289:      * Renders the link
290:      *
291:      * @return string
292:      *         Rendered HTML
293:      */
294:     public function toHTML() {
295:         $this->updateAttribute('href', $this->getHref());
296: 
297:         if ($this->_image != '') {
298:             $image = new cHTMLImage($this->_image);
299:             $this->setContent($image);
300:         }
301: 
302:         return parent::toHTML();
303:     }
304: 
305: }
306: 
CMS CONTENIDO 4.9.8 API documentation generated by ApiGen 2.8.0