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:  * Defines the 'con' related functions in CONTENIDO
   4:  *
   5:  * @package Core
   6:  * @subpackage Backend
   7:  * @version SVN Revision $Rev:$
   8:  *
   9:  * @author Olaf Niemann, Jan Lengowski
  10:  * @author Murat Purc <murat@purc.de>
  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: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
  17: 
  18: // Compatibility: Include new functions.con2.php
  19: cInclude('includes', 'functions.con2.php');
  20: 
  21: /**
  22:  * Create a new article
  23:  *
  24:  * @param int $idcat
  25:  * @param int $idcatnew
  26:  * @param int $idart
  27:  * @param unknown_type $isstart
  28:  * @param int $idtpl
  29:  * @param int $idartlang
  30:  * @param int $idlang
  31:  * @param unknown_type $title
  32:  * @param unknown_type $summary
  33:  * @param unknown_type $artspec
  34:  * @param unknown_type $created
  35:  * @param unknown_type $lastmodified
  36:  * @param unknown_type $author
  37:  * @param unknown_type $online
  38:  * @param unknown_type $datestart
  39:  * @param unknown_type $dateend
  40:  * @param unknown_type $artsort
  41:  * @param unknown_type $keyart
  42:  * @param unknown_type $searchable
  43:  * @param unknown_type $sitemapprio
  44:  * @param unknown_type $changefreq
  45:  * @return int Id of the new article
  46:  */
  47: function conEditFirstTime($idcat, $idcatnew, $idart, $isstart, $idtpl, $idartlang, $idlang, $title, $summary, $artspec, $created, $lastmodified, $author, $online, $datestart, $dateend, $artsort, $keyart = 0, $searchable = 1, $sitemapprio = 0.5, $changefreq = '') {
  48:     global $client, $lang, $auth, $urlname, $page_title;
  49:     // Some stuff for the redirect
  50:     global $redirect, $redirect_url, $external_redirect;
  51:     global $time_move_cat; // Used to indicate "move to cat"
  52:     global $time_target_cat; // Used to indicate the target category
  53:     global $time_online_move; // Used to indicate if the moved article should be
  54:                               // online
  55:     global $timemgmt;
  56: 
  57:     $page_title = addslashes($page_title);
  58:     $title = stripslashes($title);
  59:     $redirect_url = stripslashes($redirect_url);
  60:     $urlname = (trim($urlname) == '')? trim($title) : trim($urlname);
  61: 
  62:     if ($isstart == 1) {
  63:         $timemgmt = 0;
  64:     }
  65: 
  66:     if (!is_array($idcatnew)) {
  67:         $idcatnew[0] = 0;
  68:     }
  69: 
  70:     // Create article entry
  71:     $oArtColl = new cApiArticleCollection();
  72:     $oArt = $oArtColl->create($client);
  73:     $idart = $oArt->get('idart');
  74: 
  75:     $status = 0;
  76: 
  77:     // Create an category article entry
  78:     $oCatArtColl = new cApiCategoryArticleCollection();
  79:     $oCatArt = $oCatArtColl->create($idcat, $idart, $status);
  80:     $idcatart = $oCatArt->get('idcatart');
  81: 
  82:     $aLanguages = array(
  83:         $lang
  84:     );
  85: 
  86:     // Table 'con_art_lang', one entry for every language
  87:     foreach ($aLanguages as $curLang) {
  88:         $lastmodified = ($lang == $curLang)? $lastmodified : '';
  89:         $modifiedby = '';
  90: 
  91:         if ($online == 1) {
  92:             $published_value = date('Y-m-d H:i:s');
  93:             $publishedby_value = $auth->auth['uname'];
  94:         } else {
  95:             $published_value = '';
  96:             $publishedby_value = '';
  97:         }
  98: 
  99:         // Create an stat entry
 100:         $oStatColl = new cApiStatCollection();
 101:         $oStat = $oStatColl->create($idcatart, $curLang, $client, 0);
 102: 
 103:         // Create an article language entry
 104:         $oArtLangColl = new cApiArticleLanguageCollection();
 105:         $oArtLang = $oArtLangColl->create($idart, $curLang, $title, $urlname, $page_title, $summary, $artspec, $created, $auth->auth['uname'], $lastmodified, $modifiedby, $published_value, $publishedby_value, $online, $redirect, $redirect_url, $external_redirect, $artsort, $timemgmt, $datestart, $dateend, $status, $time_move_cat, $time_target_cat, $time_online_move, 0, '', '', '', $searchable, $sitemapprio, $changefreq);
 106: 
 107:         $lastId = $oArtLang->get('idartlang');
 108:         $availableTags = conGetAvailableMetaTagTypes();
 109:         foreach ($availableTags as $key => $value) {
 110:             conSetMetaValue($lastId, $key, $_POST['META' . $value['name']]);
 111:         }
 112:     }
 113: 
 114:     // Get all idcats that contain art
 115:     $oCatArtColl = new cApiCategoryArticleCollection();
 116:     $aCatsForArt = $oCatArtColl->getCategoryIdsByArticleId($idart);
 117:     if (count($aCatsForArt) == 0) {
 118:         $aCatsForArt[0] = 0;
 119:     }
 120: 
 121:     $aLanguages = getLanguagesByClient($client);
 122: 
 123:     foreach ($idcatnew as $value) {
 124:         if (!in_array($value, $aCatsForArt)) {
 125:             // New category article entry
 126:             $oCatArtColl = new cApiCategoryArticleCollection();
 127:             $oCatArt = $oCatArtColl->create($value, $idart);
 128:             $curIdcatart = $oCatArt->get('idcatart');
 129: 
 130:             // New statistics entry for each language
 131:             foreach ($aLanguages as $curLang) {
 132:                 $oStatColl = new cApiStatCollection();
 133:                 $oStatColl->create($curIdcatart, $curLang, $client, 0);
 134:             }
 135:         }
 136:     }
 137: 
 138:     foreach ($aCatsForArt as $value) {
 139:         if (!in_array($value, $idcatnew)) {
 140:             // Delete category article and other related entries that will no
 141:             // longer exist
 142:             conRemoveOldCategoryArticle($value, $idart, $idartlang, $client, $lang);
 143:         }
 144:     }
 145: 
 146:     if (!$title) {
 147:         $title = '--- ' . i18n("Default title") . ' ---';
 148:     }
 149: 
 150:     // Update article language for all languages
 151:     foreach ($aLanguages as $curLang) {
 152:         $curOnline = ($lang == $curLang)? $online : 0;
 153:         $curLastmodified = ($lang == $curLang)? $lastmodified : '';
 154: 
 155:         $oArtLang = new cApiArticleLanguage();
 156:         $oArtLang->loadByArticleAndLanguageId($idart, $curLang);
 157:         if (!$oArtLang->isLoaded()) {
 158:             continue;
 159:         }
 160: 
 161:         $oArtLang->set('title', $title);
 162:         $oArtLang->set('urlname', $urlname);
 163:         $oArtLang->set('pagetitle', $page_title);
 164:         $oArtLang->set('summary', $summary);
 165:         $oArtLang->set('artspec', $artspec);
 166:         $oArtLang->set('created', $created);
 167:         $oArtLang->set('lastmodified', $curLastmodified);
 168:         $oArtLang->set('modifiedby', $author);
 169:         $oArtLang->set('online', $curOnline);
 170:         $oArtLang->set('searchable', $searchable);
 171:         $oArtLang->set('sitemapprio', $sitemapprio);
 172:         $oArtLang->set('changefreq', $changefreq);
 173:         $oArtLang->set('redirect', $redirect);
 174:         $oArtLang->set('redirect_url', $redirect_url);
 175:         $oArtLang->set('external_redirect', $external_redirect);
 176:         $oArtLang->set('artsort', $artsort);
 177:         $oArtLang->set('datestart', $datestart);
 178:         $oArtLang->set('dateend', $dateend);
 179:         $oArtLang->store();
 180:     }
 181: 
 182:     return $idart;
 183: }
 184: 
 185: /**
 186:  * Edit an existing article
 187:  *
 188:  * @param int $idcat
 189:  * @param int $idcatnew
 190:  * @param int $idart
 191:  * @param int $isstart
 192:  * @param int $idtpl
 193:  * @param int $idartlang
 194:  * @param int $idlang
 195:  * @param string $title
 196:  * @param string $summary
 197:  * @param unknown_type $artspec
 198:  * @param unknown_type $created
 199:  * @param unknown_type $lastmodified
 200:  * @param unknown_type $author
 201:  * @param unknown_type $online
 202:  * @param unknown_type $datestart
 203:  * @param unknown_type $dateend
 204:  * @param unknown_type $published
 205:  * @param unknown_type $artsort
 206:  * @param unknown_type $keyart
 207:  * @param unknown_type $searchable
 208:  * @param unknown_type $sitemapprio
 209:  * @param unknown_type $changefreq
 210:  */
 211: function conEditArt($idcat, $idcatnew, $idart, $isstart, $idtpl, $idartlang, $idlang, $title, $summary, $artspec, $created, $lastmodified, $author, $online, $datestart, $dateend, $published, $artsort, $keyart = 0, $searchable = 1, $sitemapprio = -1, $changefreq = 'nothing') {
 212:     global $client, $lang, $redirect, $redirect_url, $external_redirect, $perm;
 213:     global $urlname, $page_title;
 214:     global $time_move_cat, $time_target_cat;
 215:     // Used to indicate if the moved article should be online
 216:     global $time_online_move;
 217:     global $timemgmt;
 218: 
 219:     // CON-2134 check admin permission
 220:     $aAuthPerms = explode(',', $auth->auth['perm']);
 221:     
 222:     $admin = false;
 223:     if (count(preg_grep("/admin.*/", $aAuthPerms)) > 0) {
 224:         $admin = true;
 225:     }
 226:     $oArtLang = new cApiArticleLanguage($idartlang);
 227:     $locked = (int) $oArtLang->get('locked');
 228: 
 229:     // abort editing if article is locked and user user no admin
 230:     if (1 === $locked
 231:     && false === $admin) {
 232:         return $idart;
 233:     }
 234:     
 235:     // Add slashes because single quotes will crash the db
 236:     $page_title = addslashes($page_title);
 237:     $title = stripslashes($title);
 238:     $redirect_url = stripslashes($redirect_url);
 239: 
 240:     $urlname = (trim($urlname) == '')? trim($title) : trim($urlname);
 241:     $usetimemgmt = ((int) $timemgmt == 1)? 1 : 0;
 242:     if ($timemgmt == '1' && (($datestart == '' && $dateend == '') || ($datestart == '0000-00-00 00:00:00' && $dateend == '0000-00-00 00:00:00'))) {
 243:         $usetimemgmt = 0;
 244:     }
 245: 
 246:     if ($isstart == 1) {
 247:         $usetimemgmt = 0;
 248:     }
 249: 
 250:     if (!is_array($idcatnew)) {
 251:         $idcatnew[0] = 0;
 252:     }
 253: 
 254:     $oArtLang = new cApiArticleLanguage((int) $idartlang);
 255:     if (!$oArtLang->isLoaded()) {
 256:         return;
 257:     }
 258: 
 259:     // Get all idcats that contain art
 260:     $oCatArtColl = new cApiCategoryArticleCollection();
 261:     $aCatsForArt = $oCatArtColl->getCategoryIdsByArticleId($idart);
 262:     if (count($aCatsForArt) == 0) {
 263:         $aCatsForArt[0] = 0;
 264:     }
 265: 
 266:     // Get idtplcfg
 267:     $idTplCfg = $oArtLang->get('idtplcfg');
 268: 
 269:     foreach ($idcatnew as $value) {
 270:         if (!in_array($value, $aCatsForArt)) {
 271:             // New category article entry
 272:             $oCatArtColl = new cApiCategoryArticleCollection();
 273:             $oCatArt = $oCatArtColl->create($value, $idart);
 274:             $curIdcatart = $oCatArt->get('idcatart');
 275: 
 276:             // Copy template configuration
 277:             if ($idTplCfg != 0) {
 278:                 $newIdTplCfg = conCopyTemplateConfiguration($idTplCfg);
 279:                 conCopyContainerConf($idTplCfg, $newIdTplCfg);
 280:             }
 281: 
 282:             $aLanguages = getLanguagesByClient($client);
 283: 
 284:             // New statistics entry for each language
 285:             foreach ($aLanguages as $curLang) {
 286:                 $oStatColl = new cApiStatCollection();
 287:                 $oStatColl->create($curIdcatart, $curLang, $client, 0);
 288:             }
 289:         }
 290:     }
 291: 
 292:     foreach ($aCatsForArt as $value) {
 293:         if (!in_array($value, $idcatnew)) {
 294:             // Delete category article and other related entries that will no
 295:             // longer exist
 296:             conRemoveOldCategoryArticle($value, $idart, $idartlang, $client, $lang);
 297:         }
 298:     }
 299: 
 300:     if ($title == '') {
 301:         $title = '--- ' . i18n('Default title') . ' ---';
 302:     }
 303: 
 304:     $oArtLang->set('title', $title);
 305:     $oArtLang->set('urlname', $urlname);
 306:     $oArtLang->set('summary', $summary);
 307:     $oArtLang->set('artspec', $artspec);
 308:     $oArtLang->set('created', $created);
 309:     $oArtLang->set('lastmodified', $lastmodified);
 310:     $oArtLang->set('modifiedby', $author);
 311:     $oArtLang->set('timemgmt', $usetimemgmt);
 312:     $oArtLang->set('redirect', $redirect);
 313:     $oArtLang->set('external_redirect', $external_redirect);
 314:     $oArtLang->set('redirect_url', $redirect_url);
 315:     $oArtLang->set('artsort', $artsort);
 316:     $oArtLang->set('searchable', $searchable);
 317:     if ($sitemapprio != -1) {
 318:         $oArtLang->set('sitemapprio', $sitemapprio);
 319:     }
 320:     if ($changefreq != "nothing") {
 321:         $oArtLang->set('changefreq', $changefreq);
 322:     }
 323: 
 324:     // do not set publishing date if value is false
 325:     // do not set publishing date if article is offline
 326:     if (false !== $published
 327:     && (int) $online === 1) {
 328:         $oArtLang->set('published', date("Y-m-d H:i:s", strtotime($published)));
 329:     }
 330: 
 331:     // If the user has right for makeonline, update some properties.
 332:     if ($perm->have_perm_area_action('con', 'con_makeonline') || $perm->have_perm_area_action_item('con', 'con_makeonline', $idcat)) {
 333:         $oldOnline = $oArtLang->get('online');
 334:         $oArtLang->set('online', $online);
 335: 
 336:         // Check if old online value was 0, update published data if value
 337:         // changed from 0 to 1
 338:         if ((int) $online == 1 && $oldOnline == 0) {
 339:             $oArtLang->set('published', date('Y-m-d H:i:s'));
 340:             $oArtLang->set('publishedby', $author);
 341:         }
 342: 
 343:         $oArtLang->set('datestart', $datestart);
 344:         $oArtLang->set('dateend', $dateend);
 345:         $oArtLang->set('time_move_cat', $time_move_cat);
 346:         $oArtLang->set('time_target_cat', $time_target_cat);
 347:         $oArtLang->set('time_online_move', $time_online_move);
 348:     }
 349: 
 350:     // Update idtplcfg
 351:     if (!empty($newIdTplCfg) && $idTplCfg != $newIdTplCfg) {
 352:         $oArtLang->set('idtplcfg', $newIdTplCfg);
 353:     }
 354: 
 355:     $oArtLang->store();
 356: 
 357:     // article has been saved, so clear the article cache
 358:     $purge = new cSystemPurge();
 359:     $purge->clearArticleCache($idartlang);
 360: }
 361: 
 362: /**
 363:  * Save a content element and generate index
 364:  *
 365:  * @param int $idartlang idartlang of the article
 366:  * @param string $type Type of content element
 367:  * @param int $typeid Serial number of the content element
 368:  * @param string $value Content
 369:  * @param bool $bForce Not used: Was a flag to use existing db instance in
 370:  *        global scope
 371:  */
 372: function conSaveContentEntry($idartlang, $type, $typeid, $value, $bForce = false) {
 373:     global $auth, $cfgClient, $client, $_cecRegistry;
 374: 
 375:     $oType = new cApiType();
 376:     if (!$oType->loadByType($type)) {
 377:         // Couldn't load type...
 378:         return;
 379:     }
 380: 
 381:     $date = date('Y-m-d H:i:s');
 382:     $author = $auth->auth['uname'];
 383:     $value = str_replace(cRegistry::getFrontendUrl(), '', $value);
 384:     $value = stripslashes($value);
 385: 
 386:     $iterator = $_cecRegistry->getIterator('Contenido.Content.SaveContentEntry');
 387:     while (($chainEntry = $iterator->next()) !== false) {
 388:         $value = $chainEntry->execute($idartlang, $type, $typeid, $value);
 389:     }
 390: 
 391:     $idtype = $oType->get('idtype');
 392: 
 393:     $oContent = new cApiContent();
 394:     $oContent->loadByArticleLanguageIdTypeAndTypeId($idartlang, $idtype, $typeid);
 395:     if ($oContent->isLoaded()) {
 396:         // Update existing entry
 397:         $oContent->set('value', $value);
 398:         $oContent->set('author', $author);
 399:         $oContent->set('lastmodified', date('Y-m-d H:i:s'));
 400:         $oContent->store();
 401:     } else {
 402:         // Create new entry
 403:         $oContentColl = new cApiContentCollection();
 404:         $oContent = $oContentColl->create($idartlang, $idtype, $typeid, $value, 0, $author, $date, $date);
 405:     }
 406: 
 407:     // Touch the article to update last modified date
 408:     $lastmodified = date('Y-m-d H:i:s');
 409:     $oArtLang = new cApiArticleLanguage($idartlang);
 410:     $oArtLang->set('lastmodified', $lastmodified);
 411:     $oArtLang->set('modifiedby', $author);
 412:     $oArtLang->store();
 413: 
 414:     // content entry has been saved, so clear the article cache
 415:     $purge = new cSystemPurge();
 416:     $purge->clearArticleCache($idartlang);
 417: }
 418: 
 419: /**
 420:  * Generate index of article content.
 421:  *
 422:  * This is done by calling the hook 'Contenido.Content.AfterStore'.
 423:  *
 424:  * @param int $idartlang of article to index
 425:  * @param int $idart of article to index
 426:  */
 427: function conMakeArticleIndex($idartlang, $idart) {
 428: 
 429:     // get IDs of given article langauge
 430:     if (cRegistry::getArticleLanguageId() == $idartlang) {
 431:         // quite easy if given article is current article
 432:         $idclient = cRegistry::getClientId();
 433:         $idlang = cRegistry::getLanguageId();
 434:         $idcat = cRegistry::getCategoryId();
 435:         $idart = cRegistry::getArticleId();
 436:         $idcatlang = cRegistry::getCategoryLanguageId();
 437:         $idartlang = cRegistry::getArticleLanguageId();
 438:     } else {
 439:         // == for other articles these infos have to be read from DB
 440:         // get idclient by idart
 441:         $article = new cApiArticle($idart);
 442:         if ($article->isLoaded()) {
 443:             $idclient = $article->get('idclient');
 444:         }
 445:         // get idlang by idartlang
 446:         $articleLanguage = new cApiArticleLanguage($idartlang);
 447:         if ($articleLanguage->isLoaded()) {
 448:             $idlang = $articleLanguage->get('idlang');
 449:         }
 450:         // get first idcat by idart
 451:         $coll = new cApiCategoryArticleCollection();
 452:         $idcat = array_shift($coll->getCategoryIdsByArticleId($idart));
 453:         // get idcatlang by idcat & idlang
 454:         $categoryLanguage = new cApiCategoryLanguage();
 455:         $categoryLanguage->loadByCategoryIdAndLanguageId($idcat, $idlang);
 456:         if ($categoryLanguage->isLoaded()) {
 457:             $idcatlang = $articleLanguage->get('idlang');
 458:         }
 459:     }
 460: 
 461:     // build data structure expected by handlers of Contenido.Content.AfterStore
 462:     $articleIds = array(
 463:         'idclient' => $idclient,
 464:         'idlang' => $idlang,
 465:         'idcat' => $idcat,
 466:         'idcatlang' => $idcatlang,
 467:         'idart' => $idart,
 468:         'idartlang' => $idartlang
 469:     );
 470: 
 471:     // iterate chain Contenido.Content.AfterStore
 472:     $iterator = cRegistry::getCecRegistry()->getIterator('Contenido.Content.AfterStore');
 473:     while (false !== $chainEntry = $iterator->next()) {
 474:         $chainEntry->execute($articleIds);
 475:     }
 476: }
 477: 
 478: /**
 479:  * Toggle the online status of an article
 480:  *
 481:  * @param int $idart Article Id
 482:  * @param int $lang Language Id
 483:  * @param int $online optional, if 0 the article will be offline, if 1 article will be online
 484:  */
 485: function conMakeOnline($idart, $lang, $online = -1) {
 486:     $auth = cRegistry::getAuth();
 487: 
 488:     $artLang = new cApiArticleLanguage();
 489:     if (!$artLang->loadByArticleAndLanguageId($idart, $lang)) {
 490:         return;
 491:     }
 492: 
 493:     // Reverse current value
 494:     if($online === -1) {
 495:         $online = ($artLang->get('online') == 0)? 1 : 0;
 496:     }
 497: 
 498:     $artLang->set('online', $online);
 499: 
 500:     if ($online == 1) {
 501:         // Update published date and publisher
 502:         $artLang->set('published', date('Y-m-d H:i:s'));
 503:         $artLang->set('publishedby', $auth->auth['uname']);
 504:     }
 505: 
 506:     $artLang->store();
 507: 
 508:     // Execute cec hook
 509:     cApiCecHook::execute('Contenido.Article.ConMakeOnline', array(
 510:     'idart' => $idart,
 511:     'idlang' => $lang,
 512:     'state' => $online
 513:     ));
 514: }
 515: 
 516: /**
 517:  * Set the status from articles to online or offline.
 518:  *
 519:  * @param array $idarts All articles
 520:  * @param int $idlang
 521:  * @param bool $online
 522:  */
 523: function conMakeOnlineBulkEditing($idarts, $idlang, $online) {
 524:     $auth = cRegistry::getAuth();
 525: 
 526:     // get all articles with the given idart and idlang
 527:     $idartString = implode("','", $idarts);
 528:     $artLangCollection = new cApiArticleLanguageCollection();
 529:     $artLangCollection->select("`idart` IN ('" . $idartString . "') AND `idlang`='" . cSecurity::toInteger($idlang) . "'");
 530: 
 531:     // iterate over articles and set online flag
 532:     while (($artLang = $artLangCollection->next()) !== false) {
 533:         $artLang->set('online', $online);
 534:         if ($online == 1) {
 535:             // update published date and publisher
 536:             $artLang->set('published', date('Y-m-d H:i:s'));
 537:             $artLang->set('publishedby', $auth->auth['uname']);
 538:         }
 539:         $artLang->store();
 540:     }
 541: }
 542: 
 543: /**
 544:  * Toggle the lock status of an article
 545:  *
 546:  * @param int $idart Article Id
 547:  * @param int $lang Language Id
 548:  */
 549: function conLock($idart, $lang) {
 550:     $artLang = new cApiArticleLanguage();
 551:     if (!$artLang->loadByArticleAndLanguageId($idart, $lang)) {
 552:         return;
 553:     }
 554: 
 555:     $locked = ($artLang->get('locked') == 0)? 1 : 0;
 556: 
 557:     $artLang->set('locked', $locked);
 558:     $artLang->store();
 559: }
 560: 
 561: /**
 562:  * Freeze/Lock more articles.
 563:  *
 564:  * @param array $idarts All articles
 565:  * @param int $idlang
 566:  * @param bool $lock
 567:  */
 568: function conLockBulkEditing($idarts, $idlang, $lock) {
 569:     // get all articles with the given idart and idlang
 570:     $idartString = implode("','", $idarts);
 571:     $artLangCollection = new cApiArticleLanguageCollection();
 572:     $artLangCollection->select("`idart` IN ('" . $idartString . "') AND `idlang`='" . cSecurity::toInteger($idlang) . "'");
 573: 
 574:     // iterate over articles and set online flag
 575:     while (($artLang = $artLangCollection->next()) !== false) {
 576:         $artLang->set('locked', $lock);
 577:         $artLang->store();
 578:     }
 579: }
 580: 
 581: /**
 582:  * Checks if a article is locked or not
 583:  *
 584:  * @param int $idart Article Id
 585:  * @param int $lang Language Id
 586:  * @return bool
 587:  */
 588: function conIsLocked($idart, $lang) {
 589:     $artLang = new cApiArticleLanguage();
 590:     if (!$artLang->loadByArticleAndLanguageId($idart, $lang)) {
 591:         return false;
 592:     }
 593:     return (1 == $artLang->get('locked'));
 594: }
 595: 
 596: /**
 597:  * Toggle the online status of a category
 598:  *
 599:  * @param int $idcat Id of the category
 600:  * @param int $lang Id of the language
 601:  * @param int $status Status of the category
 602:  */
 603: function conMakeCatOnline($idcat, $lang, $status) {
 604:     global $cfg;
 605: 
 606:     $catLang = new cApiCategoryLanguage();
 607:     if (!$catLang->loadByCategoryIdAndLanguageId($idcat, $lang)) {
 608:         return;
 609:     }
 610: 
 611:     $status = (1 == $status)? 1 : 0;
 612: 
 613:     $catLang->set('visible', $status);
 614:     $catLang->set('lastmodified', date('Y-m-d H:i:s'));
 615:     $catLang->store();
 616: 
 617:     if ($cfg['pathresolve_heapcache'] == true && !$status = 0) {
 618:         $oPathresolveCacheColl = new cApiPathresolveCacheCollection();
 619:         $oPathresolveCacheColl->deleteByCategoryAndLanguage($idcat, $lang);
 620:     }
 621: 
 622:     // Execute cec hook
 623:     cApiCecHook::execute('Contenido.Article.ConMakeCatOnline', array(
 624:     'idcat' => $idcat,
 625:     'idlang' => $lang,
 626:     ));
 627: }
 628: 
 629: /**
 630:  * Toggle the public status of a category Almost the same function as
 631:  * strMakePublic in functions.str.php (conDeeperCategoriesArray instead of
 632:  * strDeeperCategoriesArray)
 633:  *
 634:  * @param int $idcat Category Id
 635:  * @param int $lang Language Id
 636:  * @param bool $public Public status of the Article
 637:  */
 638: function conMakePublic($idcat, $lang, $public) {
 639:     // $catLang = new cApiCategoryLanguage();
 640:     // if (!$catLang->loadByCategoryIdAndLanguageId($idcat, $lang)) {
 641:     // return;
 642:     // }
 643: 
 644:     // $public = (1 == $public) ? 1 : 0;
 645: 
 646:     // $catLang->set('public', $public);
 647:     // $catLang->set('lastmodified', date('Y-m-d H:i:s'));
 648:     // $catLang->store();
 649:     $categories = conDeeperCategoriesArray($idcat);
 650:     foreach ($categories as $value) {
 651:         $oCatLang = new cApiCategoryLanguage();
 652:         $oCatLang->loadByCategoryIdAndLanguageId($value, $lang);
 653:         $oCatLang->set('public', $public);
 654:         $oCatLang->set('lastmodified', date('Y-m-d H:i:s'));
 655:         $oCatLang->store();
 656:     }
 657: }
 658: 
 659: /**
 660:  * Delete an Article and all other related entries
 661:  *
 662:  * @param int $idart Article Id
 663:  */
 664: function conDeleteart($idart) {
 665:     global $lang, $_cecRegistry, $cfgClient, $client;
 666: 
 667:     // Get article language
 668:     $artLang = new cApiArticleLanguage();
 669:     if (!$artLang->loadByArticleAndLanguageId($idart, $lang)) {
 670:         return;
 671:     }
 672: 
 673:     $idartlang = $artLang->get('idartlang');
 674:     $idtplcfg = $artLang->get('idtplcfg');
 675: 
 676:     $catArtColl = new cApiCategoryArticleCollection();
 677:     $cats = $catArtColl->getIdsByWhereClause("idart = " . (int) $idart);
 678: 
 679:     // Fetch idcat
 680:     foreach ($cats as $idcat) {
 681:         // Reset startidartlang
 682:         if (isStartArticle($idartlang, $idcat, $lang)) {
 683:             $catLang = new cApiCategoryLanguage();
 684:             $catLang->loadByCategoryIdAndLanguageId($idcat, $lang);
 685:             $catLang->set('startidartlang', 0);
 686:             $catLang->store();
 687:         }
 688:     }
 689: 
 690:     $contentColl = new cApiContentCollection();
 691:     $contentColl->deleteBy('idartlang', (int) $idartlang);
 692: 
 693:     $artLangColl = new cApiArticleLanguageCollection();
 694:     $artLangColl->delete((int) $idartlang);
 695: 
 696:     if ($idtplcfg != 0) {
 697:         $containerConfColl = new cApiContainerConfigurationCollection();
 698:         $containerConfColl->deleteBy('idtplcfg', (int) $idtplcfg);
 699: 
 700:         $tplConfColl = new cApiTemplateConfigurationCollection();
 701:         $tplConfColl->delete('idtplcfg', $idtplcfg);
 702:     }
 703: 
 704:     // Check if there are remaining languages
 705:     $artLangColl->resetQuery();
 706:     $artLangColl->select('idart = ' . (int) $idart);
 707:     if ($artLangColl->next()) {
 708:         return;
 709:     }
 710: 
 711:     $catArtColl = new cApiCategoryArticleCollection();
 712:     $catArtColl->select('idart = ' . (int) $idart);
 713:     while (($oCatArtItem = $catArtColl->next()) !== false) {
 714:         // Delete from code cache
 715:         if (cFileHandler::exists($cfgClient[$client]['code']['path'])) {
 716:             /**
 717:              * @var $file SplFileInfo
 718:              */
 719:             foreach (new DirectoryIterator($cfgClient[$client]['code']['path']) as $file) {
 720:                 if ($file->isFile() === false) {
 721:                     continue;
 722:                 }
 723: 
 724:                 $extension = substr($file, strrpos($file->getBasename(), '.') + 1);
 725:                 if ($extension != 'php') {
 726:                     continue;
 727:                 }
 728: 
 729:                 if (preg_match('/[0-9*].[0-9*].' . $oCatArtItem->get('idcatart') . '/s', $file->getBasename())) {
 730:                     cFileHandler::remove($cfgClient[$client]['code']['path'] . '/' . $file->getFilename());
 731:                 }
 732:             }
 733:         }
 734: 
 735:         // Delete from 'stat'-table
 736:         $statColl = new cApiStatCollection();
 737:         $statColl->deleteBy('idcatart', (int) $oCatArtItem->get('idcatart'));
 738:     }
 739: 
 740:     // delete values from con_cat_art only in the correct language
 741:     $catLangColl = new cApiCategoryLanguageCollection();
 742:     $catLangColl->select('`idlang`=' . cSecurity::toInteger($lang));
 743:     $idcats = $catLangColl->getAllIds();
 744:     $idcatsString = "('" . implode('\',\'', $idcats) . "')";
 745:     $catArtColl->resetQuery();
 746:     $catArtColl->deleteByWhereClause('`idart`=' . $idart . ' AND `idcat` IN ' . $idcatsString);
 747: 
 748:     // delete entry from con_art
 749:     $oArtColl = new cApiArticleCollection();
 750:     $oArtColl->delete((int) $idart);
 751: 
 752:     // this will delete all keywords associated with the article
 753:     $search = new cSearchIndex();
 754:     $search->start($idart, array());
 755: 
 756:     // Contenido Extension Chain
 757:     // @see docs/techref/plugins/Contenido Extension Chainer.pdf
 758:     $iterator = $_cecRegistry->getIterator("Contenido.Content.DeleteArticle");
 759:     while (($chainEntry = $iterator->next()) !== false) {
 760:         $chainEntry->execute($idart);
 761:     }
 762: }
 763: 
 764: /**
 765:  * Extract a number from a string
 766:  *
 767:  * @param string $string String var by reference
 768:  */
 769: function extractNumber(&$string) {
 770:     $string = preg_replace('/[^0-9]/', '', $string);
 771: }
 772: 
 773: /**
 774:  * Change the template of a category
 775:  *
 776:  * @param int $idcat Category Id
 777:  * @param int $idtpl Template Id
 778:  */
 779: function conChangeTemplateForCat($idcat, $idtpl) {
 780:     global $lang;
 781: 
 782:     $oCatLang = new cApiCategoryLanguage();
 783:     if (!$oCatLang->loadByCategoryIdAndLanguageId($idcat, $lang)) {
 784:         return;
 785:     }
 786: 
 787:     if ($oCatLang->get('idtplcfg')) {
 788:         // Delete old container configuration
 789:         $oContainerConfColl = new cApiContainerConfigurationCollection();
 790:         $oContainerConfColl->deleteBy('idtplcfg', (int) $oCatLang->get('idtplcfg'));
 791: 
 792:         // Delete old template configuration
 793:         $oTplConfColl = new cApiTemplateConfigurationCollection();
 794:         $oTplConfColl->delete('idtplcfg', (int) $oCatLang->get('idtplcfg'));
 795:     }
 796: 
 797:     // Parameter $idtpl is 0, reset the template
 798:     if (0 == $idtpl) {
 799:         $oCatLang->set('idtplcfg', 0);
 800:         $oCatLang->store();
 801:     } else {
 802:         // Check if a pre-configuration is assigned
 803:         $oTpl = new cApiTemplate();
 804:         $oTpl->loadBy('idtpl', (int) $idtpl);
 805: 
 806:         if (0 != $oTpl->get('idtplcfg')) {
 807:             // Template is pre-configured, create new configuration
 808:             $oTplConfColl = new cApiTemplateConfigurationCollection();
 809:             $oTplConf = $oTplConfColl->create($idtpl);
 810: 
 811:             // If there is a preconfiguration of template, copy its settings
 812:             // into templateconfiguration
 813:             $oTplConfColl->copyTemplatePreconfiguration($idtpl, $oTplConf->get('idtplcfg'));
 814: 
 815:             // Update category language
 816:             $oCatLang->set('idtplcfg', $oTplConf->get('idtplcfg'));
 817:             $oCatLang->store();
 818:         } else {
 819:             // Template is not pre-configured, create a new configuration.
 820:             $oTplConfColl = new cApiTemplateConfigurationCollection();
 821:             $oTplConf = $oTplConfColl->create($idtpl);
 822: 
 823:             // Update category language
 824:             $oCatLang->set('idtplcfg', $oTplConf->get('idtplcfg'));
 825:             $oCatLang->store();
 826:         }
 827:     }
 828: 
 829:     conGenerateCodeForAllartsInCategory($idcat);
 830: }
 831: 
 832: /**
 833:  * Returns category tree structure.
 834:  *
 835:  * @param int $client Uses global set client if not set
 836:  * @param int $lang Uses global set language if not set
 837:  * @return array
 838:  */
 839: function conFetchCategoryTree($client = false, $lang = false) {
 840:     if ($client === false) {
 841:         $client = $GLOBALS['client'];
 842:     }
 843:     if ($lang === false) {
 844:         $lang = $GLOBALS['lang'];
 845:     }
 846: 
 847:     $oCatTreeColl = new cApiCategoryTreeCollection();
 848:     $aCatTree = $oCatTreeColl->getCategoryTreeStructureByClientIdAndLanguageId($client, $lang);
 849: 
 850:     return $aCatTree;
 851: }
 852: 
 853: /**
 854:  * Fetch all deeper categories by a given id
 855:  *
 856:  * @param int $idcat Id of category
 857:  * @return array Array with all deeper categories
 858:  */
 859: function conDeeperCategoriesArray($idcat) {
 860:     global $client;
 861: 
 862:     $oCatColl = new cApiCategoryCollection();
 863:     $aCatIds = $oCatColl->getAllCategoryIdsRecursive($idcat, $client);
 864: 
 865:     return $aCatIds;
 866: }
 867: 
 868: /**
 869:  * Recursive function to create an location string
 870:  *
 871:  * @param int $idcat ID of the starting category
 872:  * @param string $seperator Seperation string
 873:  * @param string $catStr Category location string (by reference)
 874:  * @param bool $makeLink Create location string with links
 875:  * @param string $linkClass Stylesheet class for the links
 876:  * @param int $firstTreeElementToUse First navigation Level location string
 877:  *        should be printed out (first level = 0!!)
 878:  * @param int $uselang Id of language
 879:  * @param bool $final
 880:  * @param bool $usecache
 881:  * @return string Location string
 882:  */
 883: function conCreateLocationString($idcat, $seperator, &$catStr, $makeLink = false, $linkClass = '', $firstTreeElementToUse = 0, $uselang = 0, $final = true, $usecache = false) {
 884:     global $cfg, $client, $cfgClient, $lang, $sess;
 885: 
 886:     if ($idcat == 0) {
 887:         $catStr = i18n("Lost and found");
 888:         return;
 889:     }
 890: 
 891:     if ($uselang == 0) {
 892:         $uselang = $lang;
 893:     }
 894: 
 895:     $locationStringCache = cRegistry::getAppVar('locationStringCache');
 896:     $locationStringCacheFile = $cfgClient[$client]['cache']['path'] . "locationstring-cache-$uselang.txt";
 897: 
 898:     if ($final == true && $usecache == true) {
 899:         if (!is_array($locationStringCache)) {
 900:             if (cFileHandler::exists($locationStringCacheFile)) {
 901:                 $locationStringCache = unserialize(cFileHandler::read($locationStringCacheFile));
 902:             } else {
 903:                 $locationStringCache = array();
 904:             }
 905:             cRegistry::setAppVar('locationStringCache', $locationStringCache);
 906:         }
 907: 
 908:         if (array_key_exists($idcat, $locationStringCache)) {
 909:             if ($locationStringCache[$idcat]['expires'] > time()) {
 910:                 $catStr = $locationStringCache[$idcat]['name'];
 911:                 return;
 912:             }
 913:         }
 914:     }
 915: 
 916:     $db = cRegistry::getDb();
 917: 
 918:     $sql = "SELECT a.name AS name, a.idcat AS idcat, b.parentid AS parentid, c.level as level " . "FROM `:cat_lang` AS a, `:cat` AS b, `:cat_tree` AS c " . "WHERE a.idlang = :idlang AND b.idclient = :idclient AND b.idcat = :idcat AND a.idcat = b.idcat AND c.idcat = b.idcat";
 919: 
 920:     $sql = $db->prepare($sql, array(
 921:         'cat_lang' => $cfg['tab']['cat_lang'],
 922:         'cat' => $cfg['tab']['cat'],
 923:         'cat_tree' => $cfg['tab']['cat_tree'],
 924:         'idlang' => (int) $uselang,
 925:         'idclient' => (int) $client,
 926:         'idcat' => (int) $idcat
 927:     ));
 928:     $db->query($sql);
 929:     $db->nextRecord();
 930: 
 931:     if ($db->f('level') >= $firstTreeElementToUse) {
 932:         $name = $db->f('name');
 933:         $parentid = $db->f('parentid');
 934: 
 935:         // create link
 936:         if ($makeLink == true) {
 937:             $linkUrl = $sess->url("front_content.php?idcat=$idcat");
 938:             $name = '<a href="' . $linkUrl . '" class="' . $linkClass . '">' . $name . '</a>';
 939:         }
 940: 
 941:         $tmp_cat_str = $name . $seperator . $catStr;
 942:         $catStr = $tmp_cat_str;
 943:     }
 944: 
 945:     if ($parentid != 0) {
 946:         conCreateLocationString($parentid, $seperator, $catStr, $makeLink, $linkClass, $firstTreeElementToUse, $uselang, false);
 947:     } else {
 948:         $sep_length = strlen($seperator);
 949:         $str_length = strlen($catStr);
 950:         $tmp_length = $str_length - $sep_length;
 951:         $catStr = substr($catStr, 0, $tmp_length);
 952:     }
 953: 
 954:     if ($final == true && $usecache == true) {
 955:         $locationStringCache[$idcat]['name'] = $catStr;
 956:         $locationStringCache[$idcat]['expires'] = time() + 3600;
 957: 
 958:         if (is_writable($cfgClient[$client]['cache']['path'])) {
 959:             cFileHandler::write($locationStringCacheFile, serialize($locationStringCache));
 960:         }
 961:         cRegistry::setAppVar('locationStringCache', $locationStringCache);
 962:     }
 963: }
 964: 
 965: /**
 966:  * Set a start-article @fixme Do we still need the isstart.
 967:  * The old start
 968:  * compatibility has already been removed...
 969:  *
 970:  * @param int $idcatart Idcatart of the article
 971:  * @param bool $isstart Start article flag
 972:  */
 973: function conMakeStart($idcatart, $isstart) {
 974:     global $lang;
 975: 
 976:     // Load category article
 977:     $oCatArt = new cApiCategoryArticle((int) $idcatart);
 978:     if (!$oCatArt->isLoaded()) {
 979:         return;
 980:     }
 981:     $idart = $oCatArt->get('idart');
 982:     $idcat = $oCatArt->get('idcat');
 983: 
 984:     // Load article language
 985:     $oArtLang = new cApiArticleLanguage();
 986:     if (!$oArtLang->loadByArticleAndLanguageId($idart, $lang)) {
 987:         return;
 988:     }
 989:     $idartlang = $oArtLang->get('idartlang');
 990: 
 991:     // Update startidartlang for category language
 992:     $oCatLang = new cApiCategoryLanguage();
 993:     if ($oCatLang->loadByCategoryIdAndLanguageId($idcat, $lang)) {
 994:         if ($isstart == 1) {
 995:             $oCatLang->set('startidartlang', $idartlang);
 996:         } else {
 997:             $oCatLang->set('startidartlang', 0);
 998:         }
 999:         $oCatLang->store();
1000:     }
1001: 
1002:     if ($isstart == 1) {
1003:         // Deactivate time management if article is a start article
1004:         $oArtLang->set('timemgmt', 0);
1005:         $oArtLang->store();
1006:     }
1007: 
1008:     // Execute cec hook
1009:     cApiCecHook::execute('Contenido.Article.ConMakeStart', array(
1010:     'idart' => $oCatArt->get("idart"),
1011:     'idlang' => $lang,
1012:     ));
1013: }
1014: 
1015: /**
1016:  * Create code for one article in all categories
1017:  *
1018:  * @param int $idart Article ID
1019:  */
1020: function conGenerateCodeForArtInAllCategories($idart) {
1021:     $oCatArtColl = new cApiCategoryArticleCollection();
1022:     $ids = $oCatArtColl->getIdsByWhereClause('idart = ' . (int) $idart);
1023:     conSetCodeFlagBulkEditing($ids);
1024: }
1025: 
1026: /**
1027:  * Generate code for all articles in a category
1028:  *
1029:  * @param int $idcat Category ID
1030:  */
1031: function conGenerateCodeForAllArtsInCategory($idcat) {
1032:     $oCatArtColl = new cApiCategoryArticleCollection();
1033:     $ids = $oCatArtColl->getIdsByWhereClause('idcat = ' . (int) $idcat);
1034:     conSetCodeFlagBulkEditing($ids);
1035: }
1036: 
1037: /**
1038:  * Generate code for the active client
1039:  */
1040: function conGenerateCodeForClient() {
1041:     global $client;
1042:     $oCatArtColl = new cApiCategoryArticleCollection();
1043:     $ids = $oCatArtColl->getAllIdsByClientId($client);
1044:     conSetCodeFlagBulkEditing($ids);
1045: }
1046: 
1047: /**
1048:  * Create code for all arts using the same layout
1049:  *
1050:  * @param int $idlay Layout-ID
1051:  */
1052: function conGenerateCodeForAllartsUsingLayout($idlay) {
1053:     global $cfg;
1054: 
1055:     $db = cRegistry::getDb();
1056: 
1057:     $sql = "SELECT idtpl FROM " . $cfg["tab"]["tpl"] . " WHERE idlay='" . cSecurity::toInteger($idlay) . "'";
1058:     $db->query($sql);
1059:     while ($db->nextRecord()) {
1060:         conGenerateCodeForAllartsUsingTemplate($db->f("idtpl"));
1061:     }
1062: }
1063: 
1064: /**
1065:  * Create code for all articles using the same module
1066:  *
1067:  * @param int $idmod Module id
1068:  */
1069: function conGenerateCodeForAllartsUsingMod($idmod) {
1070:     $oContainerColl = new cApiContainerCollection();
1071:     $rsList = $oContainerColl->getFieldsByWhereClause(array(
1072:         'idtpl'
1073:     ), 'idmod = ' . (int) $idmod);
1074:     foreach ($rsList as $rs) {
1075:         conGenerateCodeForAllArtsUsingTemplate($rs['idtpl']);
1076:     }
1077: }
1078: 
1079: /**
1080:  * Generate code for all articles using one template
1081:  *
1082:  * @param int $idtpl Template-Id
1083:  */
1084: function conGenerateCodeForAllArtsUsingTemplate($idtpl) {
1085:     global $cfg, $client;
1086: 
1087:     $db = cRegistry::getDb();
1088: 
1089:     $oCatArtColl = new cApiCategoryArticleCollection();
1090: 
1091:     // Search all categories
1092:     $sql = "SELECT
1093:                 b.idcat
1094:             FROM
1095:                 " . $cfg['tab']['tpl_conf'] . " AS a,
1096:                 " . $cfg['tab']['cat_lang'] . " AS b,
1097:                 " . $cfg['tab']['cat'] . " AS c
1098:             WHERE
1099:                 a.idtpl     = " . cSecurity::toInteger($idtpl) . " AND
1100:                 b.idtplcfg  = a.idtplcfg AND
1101:                 c.idclient  = " . cSecurity::toInteger($client) . " AND
1102:                 b.idcat     = c.idcat";
1103: 
1104:     $db->query($sql);
1105: 
1106:     while ($db->nextRecord()) {
1107:         $oCatArtColl->resetQuery();
1108:         $ids = $oCatArtColl->getIdsByWhereClause('idcat = ' . cSecurity::toInteger($db->f('idcat')));
1109:         foreach ($ids as $id) {
1110:             conSetCodeFlag($id);
1111:         }
1112:     }
1113: 
1114:     // Search all articles
1115:     $sql = "SELECT
1116:                 b.idart
1117:             FROM
1118:                 " . $cfg['tab']['tpl_conf'] . " AS a,
1119:                 " . $cfg['tab']['art_lang'] . " AS b,
1120:                 " . $cfg['tab']['art'] . " AS c
1121:             WHERE
1122:                 a.idtpl     = " . cSecurity::toInteger($idtpl) . " AND
1123:                 b.idtplcfg  = a.idtplcfg AND
1124:                 c.idclient  = " . cSecurity::toInteger($client) . " AND
1125:                 b.idart     = c.idart";
1126: 
1127:     $db->query($sql);
1128: 
1129:     while ($db->nextRecord()) {
1130:         $oCatArtColl->resetQuery();
1131:         $ids = $oCatArtColl->getIdsByWhereClause('idart = ' . (int) $db->f('idart'));
1132:         foreach ($ids as $id) {
1133:             conSetCodeFlag($id);
1134:         }
1135:     }
1136: }
1137: 
1138: /**
1139:  * Create code for all articles
1140:  */
1141: function conGenerateCodeForAllArts() {
1142:     global $cfg;
1143: 
1144:     $db = cRegistry::getDb();
1145: 
1146:     $sql = "SELECT idcatart FROM " . $cfg['tab']['cat_art'];
1147:     $db->query($sql);
1148:     while ($db->nextRecord()) {
1149:         conSetCodeFlag($db->f("idcatart"));
1150:     }
1151: }
1152: 
1153: /**
1154:  * Set code creation flag for one category article id to true
1155:  *
1156:  * @param int $idcatart Category article id
1157:  */
1158: function conSetCodeFlag($idcatart) {
1159:     global $client, $cfgClient;
1160: 
1161:     // Set 'createcode' flag
1162:     $oCatArtColl = new cApiCategoryArticleCollection();
1163:     $oCatArtColl->setCreateCodeFlag($idcatart);
1164: 
1165:     // Delete also generated code files from file system
1166:     if (cFileHandler::exists($cfgClient[$client]['code']['path'])) {
1167:         /**
1168:          * @var $file SplFileInfo
1169:          */
1170:         foreach (new DirectoryIterator($cfgClient[$client]['code']['path']) as $file) {
1171:             if ($file->isFile() === false) {
1172:                 continue;
1173:             }
1174: 
1175:             $extension = substr($file, strrpos($file->getBasename(), '.') + 1);
1176:             if ($extension != 'php') {
1177:                 continue;
1178:             }
1179: 
1180:             if (preg_match('/[0-9*].[0-9*].' . $idcatart . '/s', $file->getBasename())) {
1181:                 cFileHandler::remove($cfgClient[$client]['code']['path'] . '/' . $file->getFilename());
1182:             }
1183:         }
1184:     }
1185: }
1186: 
1187: /**
1188:  * Set code creation flag for several category article ids to true
1189:  *
1190:  * @param array $idcatarts List of category article ids
1191:  */
1192: function conSetCodeFlagBulkEditing(array $idcatarts) {
1193:     global $client, $cfgClient;
1194: 
1195:     if (count($idcatarts) == 0) {
1196:         return;
1197:     }
1198: 
1199:     // Set 'createcode' flag
1200:     $oCatArtColl = new cApiCategoryArticleCollection();
1201:     $oCatArtColl->setCreateCodeFlag($idcatarts);
1202: 
1203:     if (cFileHandler::exists($cfgClient[$client]['code']['path']) === false) {
1204:         return;
1205:     }
1206: 
1207:     // Delete also generated code files from file system
1208:     foreach ($idcatarts as $id) {
1209:         /**
1210:          * @var $file SplFileInfo
1211:          */
1212:         foreach (new DirectoryIterator($cfgClient[$client]['code']['path']) as $file) {
1213:             if ($file->isFile() === false) {
1214:                 continue;
1215:             }
1216: 
1217:             $extension = substr($file, strrpos($file->getBasename(), '.') + 1);
1218:             if ($extension != 'php') {
1219:                 continue;
1220:             }
1221: 
1222:             if (preg_match('/[0-9*].[0-9*].' . $id . '/s', $file->getBasename())) {
1223:                 cFileHandler::remove($cfgClient[$client]['code']['path'] . '/' . $file->getFilename());
1224:             }
1225:         }
1226:     }
1227: }
1228: 
1229: /**
1230:  * Set articles on/offline for the time management function
1231:  */
1232: function conFlagOnOffline() {
1233:     global $cfg;
1234: 
1235:     $db = cRegistry::getDb();
1236: 
1237:     $oArtLangColl = new cApiArticleLanguageCollection();
1238: 
1239:     // Set all articles which are before our starttime to offline
1240:     $where = "NOW() < datestart AND datestart != '0000-00-00 00:00:00' AND datestart IS NOT NULL AND timemgmt = 1";
1241:     $ids = $oArtLangColl->getIdsByWhereClause($where);
1242:     foreach ($ids as $id) {
1243:         $sql = "UPDATE " . $cfg['tab']['art_lang'] . " SET online = 0 WHERE idartlang = " . (int) $id;
1244:         $db->query($sql);
1245:     }
1246: 
1247:     // Set all articles which are in between of our start/endtime to online
1248:     $where = "NOW() > datestart AND (NOW() < dateend OR dateend = '0000-00-00 00:00:00') AND " . "online = 0 AND timemgmt = 1";
1249:     $oArtLangColl->resetQuery();
1250:     $ids = $oArtLangColl->getIdsByWhereClause($where);
1251:     foreach ($ids as $id) {
1252:         $sql = "UPDATE " . $cfg['tab']['art_lang'] . " SET online = 1, published = datestart WHERE idartlang = " . (int) $id;
1253:         $db->query($sql);
1254:     }
1255: 
1256:     // Set all articles after our endtime to offline
1257:     $where = "NOW() > dateend AND dateend != '0000-00-00 00:00:00' AND timemgmt = 1";
1258:     $oArtLangColl->resetQuery();
1259:     $ids = $oArtLangColl->getIdsByWhereClause($where);
1260:     foreach ($ids as $id) {
1261:         $sql = "UPDATE " . $cfg['tab']['art_lang'] . " SET online = 0 WHERE idartlang = " . (int) $id;
1262:         $db->query($sql);
1263:     }
1264: }
1265: 
1266: /**
1267:  * Move articles for the time management function
1268:  */
1269: function conMoveArticles() {
1270:     global $cfg;
1271: 
1272:     $db = cRegistry::getDb();
1273: 
1274:     // Perform after-end updates
1275:     $fields = array(
1276:         'idartlang',
1277:         'idart',
1278:         'time_move_cat',
1279:         'time_target_cat',
1280:         'time_online_move'
1281:     );
1282:     $where = "NOW() > dateend AND dateend != '0000-00-00 00:00:00' AND timemgmt = 1 AND time_move_cat = 1";
1283:     $oArtLangColl = new cApiArticleLanguageCollection();
1284:     $rsList = $oArtLangColl->getFieldsByWhereClause($fields, $where);
1285: 
1286:     foreach ($rsList as $rs) {
1287:         $online = ($rs['time_online_move'] == '1')? 1 : 0;
1288:         $sql = array();
1289:         $sql[] = 'UPDATE ' . $cfg['tab']['art_lang'] . ' SET timemgmt = 0, online = 0 WHERE idartlang = ' . (int) $rs['idartlang'] . ';';
1290:         $sql[] = 'UPDATE ' . $cfg['tab']['cat_art'] . ' SET idcat = ' . (int) $rs['time_target_cat'] . ', createcode = 1 WHERE idart = ' . (int) $rs['idart'] . ';';
1291:         $sql[] = 'UPDATE ' . $cfg['tab']['art_lang'] . ' SET online = ' . (int) $online . ' WHERE idart = ' . (int) $rs['idart'] . ';';
1292: 
1293:         // $sql = implode("\n", $sql);
1294:         // cDebug::out($sql);
1295:         $db->query($sql[0]);
1296:         $db->query($sql[1]);
1297:         $db->query($sql[2]);
1298: 
1299:         // Execute CEC hook
1300:         cApiCecHook::execute('Contenido.Article.conMoveArticles_Loop', $rs);
1301:     }
1302: }
1303: 
1304: /**
1305:  * Copies template configuration entry from source template configuration.
1306:  *
1307:  * @param int $srcidtplcfg
1308:  */
1309: function conCopyTemplateConfiguration($srcidtplcfg) {
1310:     $oTemplateConf = new cApiTemplateConfiguration((int) $srcidtplcfg);
1311:     if (!$oTemplateConf->isLoaded()) {
1312:         return NULL;
1313:     }
1314: 
1315:     $oTemplateConfColl = new cApiTemplateConfigurationCollection();
1316:     $oNewTemplateConf = $oTemplateConfColl->create($oTemplateConf->get('idtpl'));
1317:     return (is_object($oNewTemplateConf))? $oNewTemplateConf->get('idtplcfg') : NULL;
1318: }
1319: 
1320: /**
1321:  * Copies container configuration entries from source container configuration to
1322:  * destination container configuration.
1323:  *
1324:  * @param int $srcidtplcfg
1325:  * @param int $dstidtplcfg
1326:  */
1327: function conCopyContainerConf($srcidtplcfg, $dstidtplcfg) {
1328:     $counter = 0;
1329:     $oContainerConfColl = new cApiContainerConfigurationCollection();
1330:     $oContainerConfColl->select('idtplcfg = ' . cSecurity::toInteger($srcidtplcfg));
1331:     while (($oContainerConf = $oContainerConfColl->next()) !== false) {
1332:         $oNewContainerConfColl = new cApiContainerConfigurationCollection();
1333:         $oNewContainerConfColl->copyItem($oContainerConf, array(
1334:             'idtplcfg' => cSecurity::toInteger($dstidtplcfg)
1335:         ));
1336:         $counter++;
1337:     }
1338:     return ($counter > 0)? true : false;
1339: }
1340: 
1341: /**
1342:  * Copies content entries from source article language to destination article
1343:  * language.
1344:  *
1345:  * @param int $srcidartlang
1346:  * @param int $dstidartlang
1347:  */
1348: function conCopyContent($srcidartlang, $dstidartlang) {
1349:     $oContentColl = new cApiContentCollection();
1350:     $oContentColl->select('idartlang = ' . cSecurity::toInteger($srcidartlang));
1351:     while (($oContent = $oContentColl->next()) !== false) {
1352:         $oNewContentColl = new cApiContentCollection();
1353:         $oNewContentColl->copyItem($oContent, array(
1354:             'idartlang' => cSecurity::toInteger($dstidartlang)
1355:         ));
1356:     }
1357: }
1358: 
1359: /**
1360:  * Copies meta tag entries from source article language to destination article
1361:  * language.
1362:  *
1363:  * @param int $srcidartlang
1364:  * @param int $dstidartlang
1365:  */
1366: function conCopyMetaTags($srcidartlang, $dstidartlang) {
1367:     $oMetaTagColl = new cApiMetaTagCollection();
1368:     $oMetaTagColl->select('idartlang = ' . cSecurity::toInteger($srcidartlang));
1369:     while (($oMetaTag = $oMetaTagColl->next()) !== false) {
1370:         $oNewMetaTagColl = new cApiMetaTagCollection();
1371:         $oNewMetaTagColl->copyItem($oMetaTag, array(
1372:             'idartlang' => cSecurity::toInteger($dstidartlang)
1373:         ));
1374:     }
1375: }
1376: 
1377: /**
1378:  * Copy article language entry.
1379:  *
1380:  * @global array $cfg
1381:  * @global int $lang
1382:  * @param int $srcidart
1383:  * @param int $dstidart
1384:  * @param int $newtitle
1385:  * @param int $useCopyLabel
1386:  */
1387: function conCopyArtLang($srcidart, $dstidart, $newtitle, $useCopyLabel = true) {
1388:     global $auth, $lang;
1389: 
1390:     $oSrcArtLang = new cApiArticleLanguage();
1391:     if (!$oSrcArtLang->loadByArticleAndLanguageId($srcidart, $lang)) {
1392:         return;
1393:     }
1394: 
1395:     // Copy the template configuration
1396:     if ($oSrcArtLang->get('idtplcfg') != 0) {
1397:         $newidtplcfg = conCopyTemplateConfiguration($oSrcArtLang->get('idtplcfg'));
1398:         conCopyContainerConf($oSrcArtLang->get('idtplcfg'), $newidtplcfg);
1399:     }
1400: 
1401:     $idart = $dstidart;
1402:     $idlang = $oSrcArtLang->get('idlang');
1403:     $idtplcfg = $newidtplcfg;
1404: 
1405:     if ($newtitle != '') {
1406:         $title = sprintf($newtitle, $oSrcArtLang->get('title'));
1407:     } else if ($useCopyLabel == true) {
1408:         $title = sprintf(i18n('%s (Copy)'), $oSrcArtLang->get('title'));
1409:     } else {
1410:         $title = $oSrcArtLang->get('title');
1411:     }
1412: 
1413:     // Create an article language entry
1414:     $oArtLangColl = new cApiArticleLanguageCollection();
1415:     $fieldsToOverwrite = array(
1416:         'idart' => $idart,
1417:         'idlang' => $idlang,
1418:         'idtplcfg' => cSecurity::toInteger($idtplcfg),
1419:         'online' => 0,
1420:         'title' => $title,
1421:         'created' => date('Y-m-d H:i:s'),
1422:         'lastmodified' => date('Y-m-d H:i:s'),
1423:         'modifiedby' => $auth->auth['uname'],
1424:         'published' => '',
1425:         'publishedby' => ''
1426:     );
1427:     $oNewArtLang = $oArtLangColl->copyItem($oSrcArtLang, $fieldsToOverwrite);
1428: 
1429:     if (!is_object($oNewArtLang)) {
1430:         return;
1431:     }
1432: 
1433:     // Copy content
1434:     conCopyContent($oSrcArtLang->get('idartlang'), $oNewArtLang->get('idartlang'));
1435: 
1436:     // Copy meta tags
1437:     conCopyMetaTags($oSrcArtLang->get('idartlang'), $oNewArtLang->get('idartlang'));
1438: 
1439:     // Execute CEC hook
1440:     cApiCecHook::execute('Contenido.Article.conCopyArtLang_AfterInsert', array(
1441:         'idartlang' => cSecurity::toInteger($oNewArtLang->get('idartlang')),
1442:         'idart' => cSecurity::toInteger($idart),
1443:         'idlang' => cSecurity::toInteger($idlang),
1444:         'idtplcfg' => cSecurity::toInteger($idtplcfg),
1445:         'title' => $title
1446:     ));
1447: 
1448:     // Update keyword list for new article
1449:     conMakeArticleIndex($oNewArtLang->get('idartlang'), $idart);
1450: }
1451: 
1452: /**
1453:  * Copy article entry.
1454:  *
1455:  * @global object $auth
1456:  * @param int $srcidart
1457:  * @param int $targetcat
1458:  * @param string $newtitle
1459:  * @param bool $useCopyLabel
1460:  * @return bool
1461:  */
1462: function conCopyArticle($srcidart, $targetcat = 0, $newtitle = '', $useCopyLabel = true) {
1463:     // Get source article
1464:     $oSrcArt = new cApiArticle((int) $srcidart);
1465:     if (!$oSrcArt->isLoaded()) {
1466:         return false;
1467:     }
1468:     $idclient = $oSrcArt->get('idclient');
1469: 
1470:     // Create destination article
1471:     $oArtCollection = new cApiArticleCollection();
1472:     $oNewArt = $oArtCollection->create($idclient);
1473:     if (!is_object($oNewArt)) {
1474:         return false;
1475:     }
1476:     $dstidart = $oNewArt->get('idart');
1477: 
1478:     conCopyArtLang($srcidart, $dstidart, $newtitle, $useCopyLabel);
1479: 
1480:     // Get source category article entries
1481:     $oCatArtColl = new cApiCategoryArticleCollection();
1482:     $oCatArtColl->select('idart = ' . (int) $srcidart);
1483:     while (($oCatArt = $oCatArtColl->next()) !== false) {
1484:         // Insert destination category article entry
1485:         $oCatArtColl2 = new cApiCategoryArticleCollection();
1486:         $fieldsToOverwrite = array(
1487:             'idcat' => ($targetcat != 0)? $targetcat : $oCatArt->get('idcat'),
1488:             'idart' => $dstidart,
1489:             'status' => ($oCatArt->get('status') !== '')? $oCatArt->get('status') : 0,
1490:             'createcode' => 1,
1491:             'is_start' => 0
1492:         );
1493:         $oCatArtColl2->copyItem($oCatArt, $fieldsToOverwrite);
1494: 
1495:         // If true, exit while routine, only one category entry is needed
1496:         if ($targetcat != 0) {
1497:             break;
1498:         }
1499:     }
1500: 
1501:     // Contenido Extension Chain
1502:     // @see docs/techref/plugins/Contenido Extension Chainer.pdf
1503:     $_cecRegistry = cApiCecRegistry::getInstance();
1504:     $iterator = $_cecRegistry->getIterator('Contenido.Content.CopyArticle');
1505:     while (($chainEntry = $iterator->next()) !== false) {
1506:         $chainEntry->execute($srcidart, $dstidart);
1507:     }
1508: 
1509:     return $dstidart;
1510: }
1511: 
1512: /**
1513:  *
1514:  * @todo Returns something....
1515:  * @global array $cfg
1516:  * @global int $client
1517:  * @global int $lang
1518:  * @param int $idcat
1519:  * @param int $minLevel
1520:  * @return int
1521:  */
1522: function conGetTopmostCat($idcat, $minLevel = 0) {
1523:     global $cfg, $client, $lang;
1524: 
1525:     $db = cRegistry::getDb();
1526: 
1527:     $sql = "SELECT a.name AS name, a.idcat AS idcat, b.parentid AS parentid, c.level AS level
1528:             FROM `:cat_lang` AS a, `:cat` AS b, `:cat_tree` AS c
1529:             WHERE a.idlang = :idlang AND b.idclient = :idclient AND b.idcat = :idcat
1530:             AND c.idcat = b.idcat AND a.idcat = b.idcat";
1531: 
1532:     $sql = $db->prepare($sql, array(
1533:         'cat_lang' => $cfg['tab']['cat_lang'],
1534:         'cat' => $cfg['tab']['cat'],
1535:         'cat_tree' => $cfg['tab']['cat_tree'],
1536:         'idlang' => (int) $lang,
1537:         'idclient' => (int) $client,
1538:         'idcat' => (int) $idcat
1539:     ));
1540:     $db->query($sql);
1541:     $db->nextRecord();
1542: 
1543:     $name = $db->f('name');
1544:     $parentid = $db->f('parentid');
1545:     $thislevel = $db->f('level');
1546: 
1547:     if ($parentid != 0 && $thislevel >= $minLevel) {
1548:         return conGetTopmostCat($parentid, $minLevel);
1549:     } else {
1550:         return $idcat;
1551:     }
1552: }
1553: 
1554: /**
1555:  * Synchronizes an article from source language to destination language.
1556:  *
1557:  * @param int $idart Article id
1558:  * @param int $srclang Source language id
1559:  * @param int $dstlang Destination language id
1560:  */
1561: function conSyncArticle($idart, $srclang, $dstlang) {
1562:     $auth = cRegistry::getAuth();
1563: 
1564:     // Check if article has already been synced to target language
1565:     $dstArtLang = new cApiArticleLanguage();
1566:     $dstArtLang->loadByArticleAndLanguageId($idart, $dstlang);
1567:     if ($dstArtLang->isLoaded()) {
1568:         // Article already exists in detination language
1569:         return;
1570:     }
1571: 
1572:     $srcArtLang = new cApiArticleLanguage();
1573:     $srcArtLang->loadByArticleAndLanguageId($idart, $srclang);
1574:     if (!$srcArtLang->isLoaded()) {
1575:         // Couldn't load article in source language
1576:         return;
1577:     }
1578:     $srcidartlang = $srcArtLang->get('idartlang');
1579: 
1580:     if ($srcArtLang->get('idtplcfg') != 0) {
1581:         $newidtplcfg = tplcfgDuplicate($srcArtLang->get('idtplcfg'));
1582:     } else {
1583:         $newidtplcfg = 0;
1584:     }
1585: 
1586:     // Create an article language entry for destination language
1587:     $artLangColl = new cApiArticleLanguageCollection();
1588:     $fieldsToOverwrite = array(
1589:         'idart' => $idart,
1590:         'idlang' => $dstlang,
1591:         'artspec' => 0,
1592:         'online' => 0,
1593:         'created' => date('Y-m-d H:i:s'),
1594:         'lastmodified' => date('Y-m-d H:i:s'),
1595:         'modifiedby' => $auth->auth['uname'],
1596:         'published' => '',
1597:         'publishedby' => '',
1598:         'timemgmt' => 0,
1599:         'datestart' => '',
1600:         'dateend' => '',
1601:         'status' => 0,
1602:         'time_move_cat' => 0,
1603:         'time_target_cat' => 0,
1604:         'time_online_move' => 0,
1605:         'free_use_01' => '',
1606:         'free_use_02' => '',
1607:         'free_use_03' => ''
1608:     );
1609:     $artLang = $artLangColl->copyItem($srcArtLang, $fieldsToOverwrite);
1610:     if (!is_object($artLang)) {
1611:         return;
1612:     }
1613: 
1614:     $newidartlang = $artLang->get('idartlang');
1615: 
1616:     // Execute CEC hook
1617:     $param = array();
1618:     $param['src_art_lang'] = $srcArtLang->toArray();
1619:     $param['dest_art_lang'] = $dstArtLang->toArray();
1620:     $param['dest_art_lang']['idartlang'] = cSecurity::toInteger($newidartlang);
1621:     $param['dest_art_lang']['idlang'] = cSecurity::toInteger($dstlang);
1622:     $param['dest_art_lang']['idtplcfg'] = cSecurity::toInteger($newidtplcfg);
1623:     cApiCecHook::execute('Contenido.Article.conSyncArticle_AfterInsert', $param);
1624: 
1625:     // Copy content
1626:     conCopyContent($srcidartlang, $newidartlang);
1627: 
1628:     // Copy meta tags
1629:     conCopyMetaTags($srcidartlang, $newidartlang);
1630: }
1631: 
1632: /**
1633:  * Checks if an article is a start article of a category.
1634:  *
1635:  * @param int $idartlang
1636:  * @param int $idcat
1637:  * @param int $idlang
1638:  * @param cDb|NULL $db (NOT used)
1639:  * @return bool
1640:  */
1641: function isStartArticle($idartlang, $idcat, $idlang, $db = NULL) {
1642:     $oCatLangColl = new cApiCategoryLanguageCollection();
1643:     return $oCatLangColl->isStartArticle($idartlang, $idcat, $idlang);
1644: }
1645: 
1646: /**
1647:  * Returns all categories in which the given article is in.
1648:  *
1649:  * @param int $idart Article ID
1650:  * @param cDb|NULL $db If specified, uses the given db object (NOT used)
1651:  * @return array Flat array which contains all category id's
1652:  */
1653: function conGetCategoryAssignments($idart, $db = NULL) {
1654: 
1655:     // Return empty array if idart is null (or empty)
1656:     if (empty($idart)) {
1657:         return array();
1658:     }
1659: 
1660:     $categories = array();
1661:     $oCatArtColl = new cApiCategoryArticleCollection();
1662:     $entries = $oCatArtColl->getFieldsByWhereClause(array(
1663:         'idcat'
1664:     ), 'idart = ' . (int) $idart);
1665:     foreach ($entries as $entry) {
1666:         $categories[] = $entry['idcat'];
1667:     }
1668:     return $categories;
1669: }
1670: 
1671: /**
1672:  * Deletes old category article entries and other related entries from other
1673:  * tables.
1674:  *
1675:  * @global array $cfgClient
1676:  * @param int $idcat
1677:  * @param int $idart
1678:  * @param int $idartlang
1679:  * @param int $client
1680:  * @param int $lang
1681:  */
1682: function conRemoveOldCategoryArticle($idcat, $idart, $idartlang, $client, $lang) {
1683:     global $cfgClient;
1684: 
1685:     // Get category article that will no longer exist
1686:     $oCatArtColl = new cApiCategoryArticleCollection();
1687:     $oCatArt = $oCatArtColl->fetchByCategoryIdAndArticleId($idcat, $idart);
1688:     if (!is_object($oCatArt)) {
1689:         return;
1690:     }
1691: 
1692:     $idcatart = $oCatArt->get('idcatart');
1693: 
1694:     // Delete from code cache and delete corresponding code
1695:     /**
1696:      * @var $file SplFileInfo
1697:      */
1698:     foreach (new DirectoryIterator($cfgClient[$client]['code']['path']) as $file) {
1699:         if ($file->isFile() === false) {
1700:             continue;
1701:         }
1702: 
1703:         $extension = substr($file, strrpos($file->getBasename(), '.') + 1);
1704:         if ($extension != 'php') {
1705:             continue;
1706:         }
1707: 
1708:         if (preg_match('/[0-9*].[0-9*].' . $idcatart . '/s', $file->getBasename())) {
1709:             cFileHandler::remove($cfgClient[$client]['code']['path'] . '/' . $file->getFilename());
1710:         }
1711:     }
1712: 
1713:     // Delete statistics
1714:     $oStatColl = new cApiStatCollection();
1715:     $oStatColl->deleteByCategoryArticleAndLanguage($idcatart, $lang);
1716: 
1717:     // Delete category article
1718:     $oCatArtColl->delete($idcatart);
1719: 
1720:     // Remove startidartlang
1721:     if (isStartArticle($idartlang, $idcat, $lang)) {
1722:         $oCatLang = new cApiCategoryLanguage();
1723:         $oCatLang->loadByCategoryIdAndLanguageId($idcat, $lang);
1724:         if ($oCatLang->isLoaded()) {
1725:             $oCatLang->set('startidartlang', 0);
1726:             $oCatLang->store();
1727:         }
1728:     }
1729: 
1730:     // Delete template configuration
1731:     $oArtLang = new cApiArticleLanguage();
1732:     $oArtLang->loadByArticleAndLanguageId($idart, $lang);
1733:     if ($oArtLang->isLoaded() && $oArtLang->get('idtplcfg') > 0) {
1734:         $oTplCfgColl = new cApiTemplateConfigurationCollection();
1735:         $oTplCfgColl->delete($oArtLang->get('idtplcfg'));
1736:     }
1737: }
1738: 
1739: ?>
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen