Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • 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

  • ArticleForumRightBottom
  • cApiClickableAction
  • cApiClickableQuestionAction
  • cGuiBackendHelpbox
  • cGuiFoldingRow
  • cGuiList
  • cGuiMenu
  • cGuiNavigation
  • cGuiNotification
  • cGuiObjectPager
  • cGuiPage
  • cGuiScrollList
  • cGuiTableForm
  • cGuiTree
  • cPager
  • cTemplate
  • cTree
  • cTreeItem
  • NoteLink
  • NoteList
  • NoteListItem
  • NoteView
  • TODOBackendList
  • TODOLink
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the clickable action and clickable question action widget
  4:  * class.
  5:  *
  6:  * @package Core
  7:  * @subpackage GUI
  8:  * @version SVN Revision $Rev:$
  9:  *
 10:  * @author Unknown
 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:  * cApiClickableAction is a subclass of cApiAction.
 21:  * It provides an image for visual representation. Inherited classes should call
 22:  * the "setNamedAction" operation in their constructors;
 23:  * on-the-fly-implementations should call it directly after creating an object
 24:  * instance.
 25:  *
 26:  * @package Core
 27:  * @subpackage GUI
 28:  */
 29: class cApiClickableAction extends cApiAction {
 30: 
 31:     /**
 32:      * Help text
 33:      *
 34:      * @access private
 35:      */
 36:     private $_helpText;
 37: 
 38:     /**
 39:      * cHTMLLink for rendering the icon
 40:      *
 41:      * @access private
 42:      */
 43:     protected $_link;
 44: 
 45:     /**
 46:      * cHTMLImage for rendering the icon
 47:      *
 48:      * @access private
 49:      */
 50:     private $_img;
 51: 
 52:     /**
 53:      *
 54:      * @var string
 55:      */
 56:     const QUESTIONACTION_PROMPT = 'prompt';
 57: 
 58:     /**
 59:      *
 60:      * @var string
 61:      */
 62:     const QUESTIONACTION_YESNO = 'yesno';
 63: 
 64:     /**
 65:      */
 66:     public function __construct() {
 67:         global $area;
 68: 
 69:         parent::__construct();
 70: 
 71:         $this->_area = $area;
 72:         $this->_frame = 4;
 73:         $this->_target = "right_bottom";
 74: 
 75:         $this->_link = new cHTMLLink();
 76:         $this->_img = new cHTMLImage();
 77:         $this->_img->setBorder(0);
 78:         $this->_img->setStyle("padding-left: 1px; padding-right: 1px;");
 79: 
 80:         $this->_parameters = array();
 81: 
 82:         $this->setEnabled();
 83:     }
 84: 
 85:     /**
 86:      * Sets the action icon for this action.
 87:      *
 88:      * @param string icon Path to the icon. Relative to the backend, if not
 89:      *        passed as absolute path.
 90:      * @return void
 91:      */
 92:     public function setIcon($icon) {
 93:         $this->_img->setSrc($icon);
 94:     }
 95: 
 96:     /**
 97:      *
 98:      * @return cHTMLImage
 99:      */
100:     public function getIcon() {
101:         return $this->_img;
102:     }
103: 
104:     /**
105:      * Sets this class to use a specific action, example "con_makestart".
106:      *
107:      * @param string actionName Name of the action to use. This action must
108:      *        exist in the actions table before
109:      *        using it, otherwise, this method will fail.
110:      * @return void
111:      */
112:     public function setNamedAction($actionName) {
113:         if ($this->loadBy("name", $actionName) !== false) {
114:             $a = new cApiArea();
115:             $a->loadByPrimaryKey($this->get("idarea"));
116: 
117:             $this->_namedAction = $actionName;
118:             $this->_area = $a->get("name");
119: 
120:             $this->_parameters = array();
121:             $this->_wantParameters = array();
122:         }
123:     }
124: 
125:     /**
126:      */
127:     public function setDisabled() {
128:         $this->_enabled = false;
129:         $this->_onDisable();
130:     }
131: 
132:     /**
133:      */
134:     public function setEnabled() {
135:         $this->_enabled = true;
136:         $this->_onEnable();
137:     }
138: 
139:     /**
140:      */
141:     protected function _onDisable() {
142:     }
143: 
144:     /**
145:      */
146:     protected function _onEnable() {
147:     }
148: 
149:     /**
150:      * Change linked area
151:      */
152:     public function changeArea($sArea) {
153:         $this->_area = $sArea;
154:     }
155: 
156:     /**
157:      *
158:      * @param string $parameter
159:      */
160:     public function wantParameter($parameter) {
161:         $this->_wantParameters[] = $parameter;
162: 
163:         $this->_wantParameters = array_unique($this->_wantParameters);
164:     }
165: 
166:     /**
167:      * sets the help text for this action.
168:      *
169:      * @param string helptext The helptext to apply
170:      * @return void
171:      */
172:     public function setHelpText($helptext) {
173:         $this->_helpText = $helptext;
174:     }
175: 
176:     /**
177:      */
178:     public function getHelpText() {
179:         return $this->_helpText;
180:     }
181: 
182:     /**
183:      *
184:      * @param string $name
185:      * @param string $value
186:      */
187:     public function setParameter($name, $value) {
188:         $this->_parameters[$name] = $value;
189:     }
190: 
191:     /**
192:      *
193:      * @param mixed $parameters
194:      * @return boolean
195:      */
196:     public function process($parameters) {
197:         echo "Process should be overridden";
198:         return false;
199:     }
200: 
201:     /**
202:      *
203:      * @return string
204:      */
205:     public function render() {
206:         $this->_img->setAlt($this->_helpText);
207: 
208:         foreach ($this->_parameters as $name => $value) {
209:             $this->_link->setCustom($name, $value);
210:         }
211: 
212:         $this->_link->setAlt($this->_helpText);
213:         $this->_link->setCLink($this->_area, $this->_frame, $this->_namedAction);
214:         $this->_link->setTargetFrame($this->_target);
215:         $this->_link->setContent($this->_img);
216: 
217:         if ($this->_enabled == true) {
218:             return ($this->_link->render());
219:         } else {
220:             return ($this->_img->render());
221:         }
222:     }
223: 
224:     /**
225:      *
226:      * @return string
227:      */
228:     public function renderText() {
229:         foreach ($this->_parameters as $name => $value) {
230:             $this->_link->setCustom($name, $value);
231:         }
232: 
233:         $this->_link->setAlt($this->_helpText);
234:         $this->_link->setCLink($this->_area, $this->_frame, $this->_namedAction);
235:         $this->_link->setTargetFrame($this->_target);
236:         $this->_link->setContent($this->_helpText);
237: 
238:         if ($this->_enabled == true) {
239:             return ($this->_link->render());
240:         } else {
241:             return ($this->_helpText);
242:         }
243:     }
244: }
245: 
246: /**
247:  * Clickable question action class.
248:  *
249:  * @package Core
250:  * @subpackage GUI
251:  */
252: class cApiClickableQuestionAction extends cApiClickableAction {
253: 
254:     /**
255:      */
256:     public function __construct() {
257:         parent::__construct();
258:     }
259: 
260:     /**
261:      *
262:      * @param string $mode
263:      */
264:     public function setQuestionMode($mode) {
265:         $this->_mode = $mode;
266:     }
267: 
268:     /**
269:      *
270:      * @param string $question
271:      */
272:     public function setQuestion($question) {
273:         $this->_question = $question;
274:     }
275: 
276:     /**
277:      *
278:      * @param string $var
279:      */
280:     public function setResultVar($var) {
281:         $this->_resultVar = $var;
282:     }
283: 
284:     /**
285:      * (non-PHPdoc)
286:      *
287:      * @see cApiClickableAction::render()
288:      */
289:     public function render() {
290:         switch ($this->_mode) {
291:             case self::QUESTIONACTION_PROMPT:
292:                 $this->_link->attachEventDefinition("_" . get_class($this) . rand(), "onclick", 'var answer = prompt("' . conHtmlSpecialChars($this->_question) . '");if (answer == null) {return false;} else { this.href = this.href + "&' . $this->_resultVar . '="+answer; return true;}');
293:                 break;
294:             case self::QUESTIONACTION_YESNO:
295:             default:
296:                 $this->_link->attachEventDefinition("_" . get_class($this) . rand(), "onclick", 'var answer = confirm("' . conHtmlSpecialChars($this->_question) . '");if (answer == false) {return false;} else { return true;}');
297:                 break;
298:         }
299: 
300:         return parent::render();
301:     }
302: }
303: 
CMS CONTENIDO 4.9.2 API documentation generated by ApiGen 2.8.0