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

  • SIWECOS
  • SIWECOSCollection
  • SIWECOSLeftBottomPage
  • SIWECOSRightBottomPage

Exceptions

  • SIWECOSException
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  *
  5:  * @package    Plugin
  6:  * @subpackage SIWECOS
  7:  * @author     Fulai Zhang <fulai.zhang@4fb.de>
  8:  * @copyright  four for business AG
  9:  * @link       http://www.4fb.de
 10:  */
 11: 
 12: // assert CONTENIDO framework
 13: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 14: 
 15: /**
 16:  * SIWECOS form item collection class.
 17:  * It's a kind of a model.
 18:  *
 19:  * @author Fulai Zhang <fulai.zhang@4fb.de>
 20:  */
 21: class SIWECOSCollection extends ItemCollection
 22: {
 23:     /**
 24:      * SIWECOSCollection constructor.
 25:      *
 26:      * @param bool $where
 27:      *
 28:      * @throws cDbException
 29:      * @throws cInvalidArgumentException
 30:      */
 31:     public function __construct($where = false)
 32:     {
 33:         parent::__construct('con_pi_siwecos', 'idsiwecos');
 34:         $this->_setItemClass('SIWECOS');
 35:         if (false !== $where) {
 36:             $this->select($where);
 37:         }
 38:     }
 39: 
 40:     /**
 41:      * Get forms of given client in given language.
 42:      *
 43:      * @param $client
 44:      * @param $lang
 45:      *
 46:      * @return array
 47:      * @throws SIWECOSException
 48:      * @throws cDbException
 49:      * @throws cException
 50:      */
 51:     public static function getByClientAndLang($client, $lang)
 52:     {
 53:         if (0 >= cSecurity::toInteger($client)) {
 54:             $msg = i18n('ERR_MISSING_CLIENT', 'siwecos');
 55:             throw new SIWECOSException($msg);
 56:         }
 57: 
 58:         if (0 >= cSecurity::toInteger($lang)) {
 59:             $msg = i18n('ERR_MISSING_LANG', 'siwecos');
 60:             throw new SIWECOSException($msg);
 61:         }
 62: 
 63:         return self::_getBy($client, $lang);
 64:     }
 65: 
 66:     /**
 67:      * Get forms according to given params.
 68:      *
 69:      * @param $client
 70:      * @param $lang
 71:      *
 72:      * @return array
 73:      * @throws cDbException
 74:      */
 75:     private static function _getBy($client, $lang)
 76:     {
 77:         global $idsiwecos;
 78: 
 79:         if ($idsiwecos) {
 80:             $str = "AND idsiwecos = " . cSecurity::toInteger($idsiwecos);
 81:         } else {
 82:             $str = '';
 83:         }
 84: 
 85:         $db = cRegistry::getDb();
 86:         $db->query(
 87:             "SELECT *
 88:             FROM `con_pi_siwecos`
 89:             WHERE 
 90:                 idclient = " . cSecurity::toInteger($client) . "
 91:                 AND idlang = " . cSecurity::toInteger($lang) . "
 92:                 " . $str . "
 93:             ;"
 94:         );
 95: 
 96:         $forms = [];
 97:         while ($db->nextRecord()) {
 98:             $forms[$db->f('idsiwecos')]['idsiwecos']   = $db->f('idsiwecos');
 99:             $forms[$db->f('idsiwecos')]['domain']      = $db->f('domain');
100:             $forms[$db->f('idsiwecos')]['email']       = $db->f('email');
101:             $forms[$db->f('idsiwecos')]['userToken']   = $db->f('userToken');
102:             $forms[$db->f('idsiwecos')]['domainToken'] = $db->f('domainToken');
103:             $forms[$db->f('idsiwecos')]['dangerLevel'] = $db->f('dangerLevel');
104:             $forms[$db->f('idsiwecos')]['author']      = $db->f('author');
105:             $forms[$db->f('idsiwecos')]['created']     = $db->f('created');
106:         }
107: 
108:         return $forms;
109:     }
110: }
111: 
112: /**
113:  * Class SIWECOS
114:  */
115: class SIWECOS extends Item
116: {
117:     /**
118:      * name of this plugin
119:      *
120:      * @var string
121:      */
122:     private static $_name = 'siwecos';
123: 
124:     /**
125:      * SIWECOS constructor.
126:      *
127:      * @param bool $id
128:      *
129:      * @throws cDbException
130:      * @throws cException
131:      */
132:     public function __construct($id = false)
133:     {
134:         parent::__construct('con_pi_siwecos', 'idsiwecos');
135:         $this->setFilters([], []);
136:         if (false !== $id) {
137:             $this->loadByPrimaryKey($id);
138:         }
139:     }
140: 
141:     /**
142:      * get pluginsname
143:      *
144:      * @return string
145:      */
146:     public static function getName()
147:     {
148:         return self::$_name;
149:     }
150: 
151:     /**
152:      * @param Exception $e
153:      *
154:      * @throws cDbException
155:      * @throws cException
156:      * @throws cInvalidArgumentException
157:      */
158:     public static function logException(Exception $e)
159:     {
160:         if (getSystemProperty('debug', 'debug_for_plugins') == 'true') {
161:             $cfg         = cRegistry::getConfig();
162:             $destination = $cfg['path']['contenido_logs'] . 'errorlog.txt';
163:             $writer      = cLogWriter::factory('file', ['destination' => $destination]);
164:             $log         = new cLog($writer);
165:             $log->err($e->getMessage());
166:             $log->err($e->getTraceAsString());
167:         }
168:     }
169: 
170:     /**
171:      * Creates a notification widget in order to display an exception message in
172:      * backend.
173:      *
174:      * @param Exception $e
175:      *
176:      * @return string
177:      */
178:     public static function notifyException(Exception $e)
179:     {
180:         $cGuiNotification = new cGuiNotification();
181:         $level            = cGuiNotification::LEVEL_ERROR;
182:         $message          = $e->getMessage();
183: 
184:         return $cGuiNotification->returnNotification($level, $message);
185:     }
186: 
187:     /**
188:      * Deletes this form with all its fields and stored data.
189:      * The forms data table is also dropped.
190:      *
191:      * @throws SIWECOSException
192:      * @throws cDbException
193:      * @throws cException
194:      */
195:     public function delete()
196:     {
197:         global $idsiwecos;
198:         $db = cRegistry::getDb();
199: 
200:         // delete form
201:         $succ = $db->query(
202:             "
203:             DELETE
204:             FROM con_pi_siwecos
205:             WHERE
206:                 idsiwecos = " . cSecurity::toInteger($idsiwecos) . "
207:             ;"
208:         );
209: 
210:         if (false === $succ) {
211:             $msg = i18n('ERR_DELETE_ENTITY', 'siwecos');
212:             throw new SIWECOSException($msg);
213:         }
214:     }
215: }
216: 
217: /**
218:  * Base class for all SIWECOS related exceptions.
219:  *
220:  * @author fulai zhang <fulai.zhang@4fb.de>
221:  */
222: class SIWECOSException extends cException
223: {
224: }
225: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0