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 CONTENIDO content functions.
  4:  *
  5:  * Please add only stuff which is relevant for the frontend
  6:  * AND the backend. This file should NOT contain any backend editing
  7:  * functions to improve frontend performance:
  8:  *
  9:  * @package          Core
 10:  * @subpackage       Backend
 11:  * @version          SVN Revision $Rev:$
 12:  *
 13:  * @author           Willi Man, Timo Hummel
 14:  * @copyright        four for business AG <www.4fb.de>
 15:  * @license          http://www.contenido.org/license/LIZENZ.txt
 16:  * @link             http://www.4fb.de
 17:  * @link             http://www.contenido.org
 18:  */
 19: 
 20: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 21: 
 22: /**
 23:  * Generates the code for one article
 24:  *
 25:  * @param int $idcat Id of category
 26:  * @param int $idart Id of article
 27:  * @param int $lang Id of language
 28:  * @param int $client Id of client
 29:  * @param int $layout Layout-ID of alternate Layout (if false, use associated layout)
 30:  * @param bool $save  Flag to persist generated code in database
 31:  * @return string The generated code or "0601" if neither article nor category configuration
 32:  *                was found
 33:  */
 34: function conGenerateCode($idcat, $idart, $lang, $client, $layout = false, $save = true, $contype = true) {
 35:     global $cfg, $frontend_debug;
 36: 
 37:     // @todo make generator configurable
 38:     $codeGen = cCodeGeneratorFactory::getInstance($cfg['code_generator']['name']);
 39:     if (isset($frontend_debug) && is_array($frontend_debug)) {
 40:         $codeGen->setFrontendDebugOptions($frontend_debug);
 41:     }
 42: 
 43:     $code = $codeGen->generate($idcat, $idart, $lang, $client, $layout, $save, $contype);
 44: 
 45:     // execute CEC hook
 46:     $code = cApiCecHook::executeAndReturn('Contenido.Content.conGenerateCode', $code);
 47: 
 48:     return $code;
 49: }
 50: 
 51: /**
 52:  * Returns the idartlang for a given article and language
 53:  *
 54:  * @param  int  $idart ID of the article
 55:  * @param  int  $idlang ID of the language
 56:  * @return mixed idartlang of the article or false if nothing was found
 57:  */
 58: function getArtLang($idart, $idlang) {
 59:     $oArtLangColl = new cApiArticleLanguageCollection();
 60:     $idartlang = $oArtLangColl->getIdByArticleIdAndLanguageId($idart, $idlang);
 61:     return ($idartlang) ? $idartlang : false;
 62: }
 63: 
 64: /**
 65:  * Returns all available meta tag types
 66:  *
 67:  * @return  array  Assoziative meta tags list
 68:  */
 69: function conGetAvailableMetaTagTypes() {
 70:     $oMetaTypeColl = new cApiMetaTypeCollection();
 71:     $oMetaTypeColl->select();
 72:     $aMetaTypes = array();
 73: 
 74:     while (($oMetaType = $oMetaTypeColl->next()) !== false) {
 75:         $rs = $oMetaType->toArray();
 76:         $aMetaTypes[$rs['idmetatype']] = array(
 77:             'metatype' => $rs['metatype'],
 78:             'fieldtype' => $rs['fieldtype'],
 79:             'maxlength' => $rs['maxlength'],
 80:             'fieldname' => $rs['fieldname'],
 81:             'idmetatype' => $rs["idmetatype"]
 82:         );
 83:     }
 84: 
 85:     return $aMetaTypes;
 86: }
 87: 
 88: /**
 89:  * Get the meta tag value for a specific article
 90:  *
 91:  * @param int $idartlang ID of the article
 92:  * @param int $idmetatype Metatype-ID
 93:  * @return  string
 94:  */
 95: function conGetMetaValue($idartlang, $idmetatype) {
 96:     static $oMetaTagColl = NULL;
 97:     if (!isset($oMetaTagColl)) {
 98:         $oMetaTagColl = new cApiMetaTagCollection();
 99:     }
100: 
101:     if ((int) $idartlang <= 0) {
102:         return '';
103:     }
104: 
105:     $oMetaTag = $oMetaTagColl->fetchByArtLangAndMetaType($idartlang, $idmetatype);
106:     if (is_object($oMetaTag)) {
107:         return stripslashes($oMetaTag->get('metavalue'));
108:     } else {
109:         return '';
110:     }
111: }
112: 
113: /**
114:  * Set the meta tag value for a specific article.
115:  *
116:  * @param  int  $idartlang ID of the article
117:  * @param  int  $idmetatype Metatype-ID
118:  * @param  string  $value Value of the meta tag
119:  * @return bool whether the meta value has been saved successfully
120:  */
121: function conSetMetaValue($idartlang, $idmetatype, $value) {
122:     static $metaTagColl = NULL;
123:     if (!isset($metaTagColl)) {
124:         $metaTagColl = new cApiMetaTagCollection();
125:     }
126: 
127:     $metaTag = $metaTagColl->fetchByArtLangAndMetaType($idartlang, $idmetatype);
128:     $artLang = new cApiArticleLanguage($idartlang);
129:     $artLang->set('lastmodified', date('Y-m-d H:i:s'));
130:     $artLang->store();
131:     if (is_object($metaTag)) {
132:         return $metaTag->updateMetaValue($value);
133:     } else {
134:         $metaTagColl->create($idartlang, $idmetatype, $value);
135:         return true;
136:     }
137: }
138: 
139: /**
140:  * (re)generate keywords for all articles of a given client (with specified language)
141:  * @param int $client Client
142:  * @param int $lang Language of a client
143:  * @deprecated 2014-07-24 - Not used anymore
144:  */
145: function conGenerateKeywords($client, $lang) {
146:     $cfg = cRegistry::getConfig();
147: 
148:     static $oDB = NULL;
149:     if (!isset($oDB)) {
150:         $oDB = cRegistry::getDb();
151:     }
152: 
153:     // cms types to be excluded from indexing
154:     $options = $cfg['search_index']['excluded_content_types'];
155: 
156:     $sql = 'SELECT a.idart, b.idartlang FROM ' . $cfg['tab']['art'] . ' AS a, ' . $cfg['tab']['art_lang'] . ' AS b
157:             WHERE a.idart=b.idart AND a.idclient=' . (int) $client . ' AND b.idlang=' . (int) $lang;
158: 
159:     $oDB->query($sql);
160: 
161:     $aArticles = array();
162:     while ($oDB->nextRecord()) {
163:         $aArticles[$oDB->f('idart')] = $oDB->f('idartlang');
164:     }
165: 
166:     foreach ($aArticles as $artid => $artlangid) {
167:         $aContent = conGetContentFromArticle($artlangid);
168:         if (count($aContent) > 0) {
169:             $oIndex = new cSearchIndex($oDB);
170:             $oIndex->start($artid, $aContent, 'auto', $options);
171:         }
172:     }
173: }
174: 
175: /**
176:  * Get content from article by article language.
177:  * @param int $iIdArtLang ArticleLanguageId of an article (idartlang)
178:  * @return array Array with content of an article indexed by content-types as follows:
179:  *               - $arr[type][typeid] = value;
180:  */
181: function conGetContentFromArticle($iIdArtLang) {
182:     global $cfg;
183: 
184:     static $oDB = NULL;
185:     if (!isset($oDB)) {
186:         $oDB = cRegistry::getDb();
187:     }
188: 
189:     $aContent = array();
190: 
191:     $sql = 'SELECT * FROM ' . $cfg['tab']['content'] . ' AS A, ' . $cfg['tab']['art_lang'] . ' AS B, ' . $cfg['tab']['type'] . ' AS C
192:             WHERE A.idtype=C.idtype AND A.idartlang=B.idartlang AND A.idartlang=' . (int) $iIdArtLang;
193:     $oDB->query($sql);
194:     while ($oDB->nextRecord()) {
195:         $aContent[$oDB->f('type')][$oDB->f('typeid')] = $oDB->f('value');
196:     }
197: 
198:     return $aContent;
199: }
200: 
201: /**
202:  * Returns list of all container with configured modules by template id
203:  *
204:  * @param  int $idtpl  Template id
205:  * @return  array  Assoziative array where the key is the number and value the module id
206:  */
207: function conGetUsedModules($idtpl) {
208:     $modules = array();
209: 
210:     $oContainerColl = new cApiContainerCollection();
211:     $oContainerColl->select('idtpl = ' . (int) $idtpl, '', 'number ASC');
212:     while (($oContainer = $oContainerColl->next()) !== false) {
213:         $modules[(int) $oContainer->get('number')] = (int) $oContainer->get('idmod');
214:     }
215: 
216:     return $modules;
217: }
218: 
219: /**
220:  * Returns list of all configured container configurations by template configuration id
221:  *
222:  * @param  int  $idtplcfg  Template configuration id
223:  * @return  array  Assoziative array where the key is the number and value the container
224:  *                 configuration
225:  */
226: function conGetContainerConfiguration($idtplcfg) {
227:     $containerConfColl = new cApiContainerConfigurationCollection();
228:     return $containerConfColl->getByTemplateConfiguration($idtplcfg);
229: }
230: 
231: /**
232:  * Returns category article id
233:  *
234:  * @param  int  $idcat
235:  * @param  int  $idart
236:  * @return  int|NULL
237:  */
238: function conGetCategoryArticleId($idcat, $idart) {
239:     global $cfg, $db;
240: 
241:     // Get idcatart, we need this to retrieve the template configuration
242:     $sql = 'SELECT idcatart FROM `%s` WHERE idcat = %d AND idart = %d';
243:     $sql = $db->prepare($sql, $cfg['tab']['cat_art'], $idcat, $idart);
244:     $db->query($sql);
245: 
246:     return ($db->nextRecord()) ? $db->f('idcatart') : NULL;
247: }
248: 
249: /**
250:  * Returns template configuration id for a configured article.
251:  *
252:  * @param  int  $idart
253:  * @param  int  $idcat  NOT used
254:  * @param  int  $lang
255:  * @param  int  $client
256:  * @return  int|NULL
257:  */
258: function conGetTemplateConfigurationIdForArticle($idart, $idcat, $lang, $client) {
259:     global $cfg, $db;
260: 
261:     // Retrieve template configuration id
262:     $sql = "SELECT a.idtplcfg AS idtplcfg FROM `%s` AS a, `%s` AS b WHERE a.idart = %d "
263:          . "AND a.idlang = %d AND b.idart = a.idart AND b.idclient = %d";
264:     $sql = $db->prepare($sql, $cfg['tab']['art_lang'], $cfg['tab']['art'], $idart, $lang, $client);
265:     $db->query($sql);
266: 
267:     return ($db->nextRecord()) ? $db->f('idtplcfg') : NULL;
268: }
269: 
270: /**
271:  * Returns template configuration id for a configured category
272:  *
273:  * @param  int  $idcat
274:  * @param  int  $lang
275:  * @param  int  $client
276:  * @return  int|NULL
277:  */
278: function conGetTemplateConfigurationIdForCategory($idcat, $lang, $client) {
279:     global $cfg, $db;
280: 
281:     // Retrieve template configuration id
282:     $sql = "SELECT a.idtplcfg AS idtplcfg FROM `%s` AS a, `%s` AS b WHERE a.idcat = %d AND "
283:          . "a.idlang = %d AND b.idcat = a.idcat AND b.idclient = %d";
284:     $sql = $db->prepare($sql, $cfg['tab']['cat_lang'], $cfg['tab']['cat'], $idcat, $lang, $client);
285:     $db->query($sql);
286: 
287:     return ($db->nextRecord()) ? $db->f('idtplcfg') : NULL;
288: }
289: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen