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
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cAjaxRequest
  • cAutoload
  • cBackend
  • cEffectiveSetting
  • cGuiScrollListAlltranslations
  • cHTMLValidator
  • cMailer
  • cModuleFileTranslation
  • cModuleHandler
  • cModuleSearch
  • cModuleSynchronizer
  • cModuleTemplateHandler
  • CodeMirror
  • cPasswordRequest
  • cPermission
  • cRegistry
  • cSystemPurge
  • cSystemtest
  • cTinymce4Configuration
  • cTinyMCE4Editor
  • cTinyMCEEditor
  • cWYSIWYGEditor
  • FrontendList
  • HtmlParser
  • TODOBackendList
  • TreeItem
  • UploadList
  • UploadSearchResultList

Functions

  • addArtspec
  • addSortImages
  • backToMainArea
  • buildArticleSelect
  • buildCategorySelect
  • buildCategorySelectRights
  • buildHeapTable
  • buildStackString
  • buildTree
  • buildUserOrGroupPermsFromRequest
  • callPluginStore
  • cApiCatGetLevelNode
  • cApiImageCheckCachedImageValidity
  • cApiImageCheckImageEditingPosibility
  • cApiImageCheckImageEditingPossibility
  • cApiImageGetCacheFileName
  • cApiImageGetTargetDimensions
  • cApiImageIsAnimGif
  • cApiImgScale
  • cApiImgScaleGetMD5CacheFile
  • cApiImgScaleHQ
  • cApiImgScaleImageMagick
  • cApiImgScaleLQ
  • cApiIsImageMagickAvailable
  • cApiStrCleanURLCharacters
  • cApiStrNormalizeLineEndings
  • cApiStrRecodeString
  • cApiStrReplaceDiacritics
  • cApiStrTrimAfterWord
  • cApiStrTrimHard
  • cApiStrTrimSentence
  • cDeprecated
  • cDie
  • cError
  • checkLangInClients
  • checkPathInformation
  • cInclude
  • compareUrlStrings
  • conChangeTemplateForCat
  • conCopyArticle
  • conCopyArtLang
  • conCopyContainerConf
  • conCopyContent
  • conCopyMetaTags
  • conCopyTemplateConfiguration
  • conCreateLocationString
  • conDeeperCategoriesArray
  • conDeleteart
  • conEditArt
  • conEditFirstTime
  • conFetchCategoryTree
  • conFlagOnOffline
  • conGenerateCode
  • conGenerateCodeForAllArts
  • conGenerateCodeForAllArtsInCategory
  • conGenerateCodeForAllartsUsingLayout
  • conGenerateCodeForAllartsUsingMod
  • conGenerateCodeForAllArtsUsingTemplate
  • conGenerateCodeForArtInAllCategories
  • conGenerateCodeForClient
  • conGenerateKeywords
  • conGetAvailableMetaTagTypes
  • conGetCategoryArticleId
  • conGetCategoryAssignments
  • conGetContainerConfiguration
  • conGetContentFromArticle
  • conGetHtmlTranslationTable
  • conGetMetaValue
  • conGetTemplateConfigurationIdForArticle
  • conGetTemplateConfigurationIdForCategory
  • conGetTopmostCat
  • conGetUniqueArticleUrlname
  • conGetUsedModules
  • conHtmlentities
  • conHtmlEntityDecode
  • conHtmlSpecialChars
  • conIsArticleUrlnameUnique
  • conIsLocked
  • conLock
  • conLockBulkEditing
  • conMakeArticleIndex
  • conMakeCatOnline
  • conMakeInlineScript
  • conMakeOnline
  • conMakeOnlineBulkEditing
  • conMakePublic
  • conMakeStart
  • conMoveArticles
  • conPhp54Check
  • conRemoveOldCategoryArticle
  • conSaveContentEntry
  • conSetCodeFlag
  • conSetCodeFlagBulkEditing
  • conSetMetaValue
  • conSetStartArticle
  • consoleLog
  • conSyncArticle
  • copyRightsForElement
  • createBulkEditingFunction
  • createRandomName
  • createRightsForElement
  • cWarning
  • dbGetColumns
  • dbGetIndexes
  • dbGetPrimaryKeyName
  • dbTableExists
  • dbUpgradeTable
  • defineIfNotDefined
  • deleteArtspec
  • deleteRightsForElement
  • deleteSystemProperty
  • displayDatetime
  • emptyLogFile
  • endAndLogTiming
  • extractNumber
  • generateDisplayFilePath
  • generateJs
  • getAllClientsAndLanguages
  • getArtLang
  • getArtspec
  • getAvailableContentTypes
  • getCanonicalDay
  • getCanonicalMonth
  • getDirectorySize
  • getEffectiveSetting
  • getEffectiveSettingsByType
  • getEncodingByLanguage
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getJsHelpContext
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParentAreaId
  • getRightsList
  • getSearchResults
  • getStrExpandCollapseButton
  • getSystemProperties
  • getSystemPropertiesByType
  • getSystemProperty
  • getTemplateSelect
  • getUplExpandCollapseButton
  • htmldecode
  • htmlentities_iso88592
  • humanReadableSize
  • includePlugins
  • insertEmptyStrRow
  • ipMatch
  • isAlphanumeric
  • isArchive
  • isArtInMultipleUse
  • isFunctionDisabled
  • isGroup
  • isIPv4
  • isRunningFromWeb
  • isStartArticle
  • isUtf8
  • isValidMail
  • langActivateDeactivateLanguage
  • langDeleteLanguage
  • langEditLanguage
  • langGetTextDirection
  • langNewLanguage
  • langRenameLanguage
  • layDeleteLayout
  • layEditLayout
  • machineReadableSize
  • mailLogBulkEditingFunctions
  • mailLogDecodeAddresses
  • markSubMenuItem
  • mask
  • modDeleteModule
  • modEditModule
  • phpInfoToHtml
  • plugin_include
  • prCreateURLNameLocationString
  • prDeleteCacheFileContent
  • prGetCacheFileContent
  • prResolvePathViaCategoryNames
  • prResolvePathViaURLNames
  • prWriteCacheFileContent
  • recursiveCopy
  • removeFileInformation
  • renderBackendBreadcrumb
  • renderLabel
  • renderSelectProperty
  • renderTextProperty
  • saveGroupRights
  • saveRights
  • scanDirectory
  • scanPlugins
  • sendEncodingHeader
  • set_magic_quotes_gpc
  • setArtspecDefault
  • setArtspecOnline
  • setSystemProperty
  • showTree
  • startTiming
  • statCreateLocationString
  • statDisplayTopChooser
  • statDisplayYearlyTopChooser
  • statGetAvailableMonths
  • statGetAvailableYears
  • statResetStatistic
  • statsArchive
  • statsDisplayInfo
  • statsOverviewAll
  • statsOverviewTop
  • statsOverviewTopYear
  • statsOverviewYear
  • strAssignTemplate
  • strBuildSqlValues
  • strCheckAlias
  • strCheckTreeForErrors
  • strCopyCategory
  • strCopyTree
  • strDeeperCategoriesArray
  • strDeleteCategory
  • strHasArticles
  • strHasStartArticle
  • strMakePublic
  • strMakeVisible
  • strMoveCatTargetallowed
  • strMoveDownCategory
  • strMoveSubtree
  • strMoveUpCategory
  • strNewCategory
  • strNewTree
  • strNextBackwards
  • strNextDeeper
  • strNextDeeperAll
  • strNextPost
  • strOrderedPostTreeList
  • strRemakeTreeTable
  • strRenameCategory
  • strRenameCategoryAlias
  • strSortPrePost
  • strSyncCategory
  • systemHavePerm
  • tplAutoFillModules
  • tplBrowseLayoutForContainers
  • tplcfgDuplicate
  • tplDeleteTemplate
  • tplDuplicateTemplate
  • tplEditTemplate
  • tplGetContainerDefault
  • tplGetContainerMode
  • tplGetContainerName
  • tplGetContainerNumbersInLayout
  • tplGetContainerTypes
  • tplGetInUsedData
  • tplIsTemplateInUse
  • tplPreparseLayout
  • tplProcessSendContainerConfiguration
  • updateClientCache
  • updateFileInformation
  • uplCreateFriendlyName
  • uplDirectoryListRecursive
  • uplGetDirectoriesToExclude
  • uplGetFileExtension
  • uplGetFileIcon
  • uplGetFileTypeDescription
  • uplGetThumbnail
  • uplHasFiles
  • uplHasSubdirs
  • uplmkdir
  • uplRecursiveDBDirectoryList
  • uplRecursiveDirectoryList
  • uplRenameDirectory
  • uplSearch
  • uplSyncDirectory
  • uplSyncDirectoryDBFS
  • Overview
  • Package
  • Function
  • Tree
  • Deprecated
  • Todo
   1: <?php
   2: 
   3: /**
   4:  * This file contains the backend page for displaying articles of a category.
   5:  *
   6:  * @package Core
   7:  * @subpackage Backend
   8:  * @author Jan Lengowski
   9:  * @copyright four for business AG <www.4fb.de>
  10:  * @license http://www.contenido.org/license/LIZENZ.txt
  11:  * @link http://www.4fb.de
  12:  * @link http://www.contenido.org
  13:  */
  14: 
  15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
  16: 
  17: cInclude('includes', 'functions.tpl.php');
  18: cInclude('includes', 'functions.str.php');
  19: cInclude('includes', 'functions.pathresolver.php');
  20: 
  21: $db2 = cRegistry::getDb();
  22: 
  23: $idcat = (isset($_REQUEST['idcat']) && is_numeric($_REQUEST['idcat'])) ? $_REQUEST['idcat'] : -1;
  24: $next = (isset($_REQUEST['next']) && is_numeric($_REQUEST['next']) && $_REQUEST['next'] > 0) ? $_REQUEST['next'] : 0;
  25: 
  26: $dateformat = getEffectiveSetting('dateformat', 'date', 'Y-m-d');
  27: $templateDescription = '';
  28: 
  29: if (!isset($syncfrom)) {
  30:     $syncfrom = -1;
  31: }
  32: 
  33: $syncoptions = $syncfrom;
  34: // CON-1752
  35: // init duplicate counter in session
  36: if (!isset($_SESSION['count_duplicate'])) {
  37:     $_SESSION['count_duplicate'] = 0;
  38: }
  39: 
  40: // New Article Selected: Unset Selected Article Id
  41: global $selectedArticleId;
  42: $selectedArticleId = NULL;
  43: 
  44: if ($action == 'con_duplicate' && ($perm->have_perm_area_action("con", "con_duplicate") || $perm->have_perm_area_action_item("con", "con_duplicate", $idcat))) {
  45: 
  46:     $count = (int) $_SESSION['count_duplicate'];
  47: 
  48:     // check if duplicate action was called from click or from back button
  49:     if ($_GET['count_duplicate'] < $count) {
  50:     } else {
  51:         // perfom action only when duplicate action is called from link
  52:         $newidartlang = conCopyArticle($duplicate, $idcat);
  53:         $count++;
  54:         $_SESSION['count_duplicate'] = $count;
  55:     }
  56: }
  57: 
  58: if ($action == 'con_syncarticle' && ($perm->have_perm_area_action("con", "con_syncarticle") || $perm->have_perm_area_action_item("con", "con_syncarticle", $idcat))) {
  59:     if ($_POST['idarts']) {
  60:         $idarts = json_decode($_POST['idarts'], true);
  61:     } else {
  62:         $idarts = array(
  63:             $idart
  64:         );
  65:     }
  66: 
  67:     // Verify that the category is available in this language
  68:     $catLang = new cApiCategoryLanguage();
  69:     foreach ($idarts as $idart) {
  70:         if (!$catLang->loadByCategoryIdAndLanguageId($idcat, $lang)) {
  71:             strSyncCategory($idcat, $sourcelanguage, $lang);
  72:         }
  73:         conSyncArticle($idart, $sourcelanguage, $lang);
  74:     }
  75: }
  76: 
  77: // Which columns to display?
  78: $listColumns = array(
  79:     "mark" => i18n("Mark"),
  80:     "start" => i18n("Article"),
  81:     "title" => i18n("Title"),
  82:     "changeddate" => i18n("Changed"),
  83:     "publisheddate" => i18n("Published"),
  84:     "sortorder" => i18n("Sort order"),
  85:     "template" => i18n("Template"),
  86:     "actions" => i18n("Actions")
  87: );
  88: 
  89: // Which actions to display?
  90: $actionList = array(
  91:     "online",
  92:     "duplicate",
  93:     "locked",
  94:     "todo",
  95:     "delete",
  96:     "usetime"
  97: );
  98: 
  99: // Call chains to process the columns and the action list
 100: $_cecIterator = $_cecRegistry->getIterator("Contenido.ArticleList.Columns");
 101: if ($_cecIterator->count() > 0) {
 102:     while ($chainEntry = $_cecIterator->next()) {
 103:         $newColumnList = $chainEntry->execute($listColumns);
 104:         if (is_array($newColumnList)) {
 105:             $listColumns = $newColumnList;
 106:         }
 107:     }
 108: }
 109: 
 110: $_cecIterator = $_cecRegistry->getIterator("Contenido.ArticleList.Actions");
 111: if ($_cecIterator->count() > 0) {
 112:     while ($chainEntry = $_cecIterator->next()) {
 113:         $newActionList = $chainEntry->execute($actionList);
 114:         if (is_array($newActionList)) {
 115:             $actionList = $newActionList;
 116:         }
 117:     }
 118: }
 119: 
 120: $cat_idtpl = 0;
 121: 
 122: if (is_numeric($idcat) && ($idcat >= 0)) {
 123:     // Saving sort and elements per page user settings (if specified)
 124:     // Should be changed to User->setProperty... someday
 125:     if (isset($sortby)) {
 126:         $currentuser->setUserProperty("system", "sortorder-idlang-$lang-idcat-$idcat", $sortby);
 127:     }
 128:     if (isset($sortmode)) {
 129:         $currentuser->setUserProperty("system", "sortmode-idlang-$lang-idcat-$idcat", $sortmode);
 130:     }
 131: 
 132:     if (isset($elemperpage) && is_numeric($elemperpage)) {
 133:         $currentuser->setUserProperty("system", "elemperpage-idlang-$lang-idcat-$idcat", $elemperpage);
 134:     } else {
 135:         $elemperpage = $currentuser->getUserProperty("system", "elemperpage-idlang-$lang-idcat-$idcat");
 136:         if (!is_numeric($elemperpage)) {
 137:             $elemperpage = 10;
 138:         }
 139:     }
 140: 
 141:     $col = new cApiInUseCollection();
 142: 
 143:     if ((($idcat == 0 || $perm->have_perm_area_action('con')) && $perm->have_perm_item('str', $idcat)) || $perm->have_perm_area_action('con', 'con_makestart') || $perm->have_perm_area_action('con', 'con_makeonline') || $perm->have_perm_area_action('con', 'con_deleteart') || $perm->have_perm_area_action('con', 'con_tplcfg_edit') || $perm->have_perm_area_action('con', 'con_lock') || $perm->have_perm_area_action('con', 'con_makecatonline') || $perm->have_perm_area_action('con', 'con_changetemplate') || $perm->have_perm_area_action('con_editcontent', 'con_editart') || $perm->have_perm_area_action('con_editart', 'con_edit') || $perm->have_perm_area_action('con_editart', 'con_newart') || $perm->have_perm_area_action('con_editart', 'con_saveart') || $perm->have_perm_area_action('con_tplcfg', 'con_tplcfg_edit') || $perm->have_perm_area_action_item('con', 'con_makestart', $idcat) || $perm->have_perm_area_action_item('con', 'con_makeonline', $idcat) || $perm->have_perm_area_action_item('con', 'con_deleteart', $idcat) || $perm->have_perm_area_action_item('con', 'con_tplcfg_edit', $idcat) || $perm->have_perm_area_action_item('con', 'con_lock', $idcat) || $perm->have_perm_area_action_item('con', 'con_makecatonline', $idcat) || $perm->have_perm_area_action_item('con', 'con_changetemplate', $idcat) || $perm->have_perm_area_action_item('con_editcontent', 'con_editart', $idcat) || $perm->have_perm_area_action_item('con_editart', 'con_edit', $idcat) || $perm->have_perm_area_action_item('con_editart', 'con_newart', $idcat) || $perm->have_perm_area_action_item('con_tplcfg', 'con_tplcfg_edit', $idcat) || $perm->have_perm_area_action_item('con_editart', 'con_saveart', $idcat)) {
 144: 
 145:         // Simple SQL statement to get the number of articles in selected language
 146:         $sql_count_in_selected_language = "SELECT
 147:                     COUNT(*) AS article_count
 148:                  FROM
 149:                     " . $cfg["tab"]["art_lang"] . " AS a,
 150:                     " . $cfg["tab"]["art"] . " AS b,
 151:                     " . $cfg["tab"]["cat_art"] . " AS c
 152:                  WHERE
 153:                     a.idlang   = " . cSecurity::toInteger($lang) . "  AND
 154:                     a.idart     = b.idart AND
 155:                     b.idclient  = " . cSecurity::toInteger($client) . " AND
 156:                     b.idart     = c.idart AND
 157:                     c.idcat     = " . cSecurity::toInteger($idcat);
 158: 
 159:         $db->query($sql_count_in_selected_language);
 160:         $db->nextRecord();
 161:         $articles_in_selected_language = $db->f("article_count");
 162: 
 163:         // Sortby and sortmode
 164:         $sortby = $currentuser->getUserProperty("system", "sortorder-idlang-$lang-idcat-$idcat");
 165:         $sortmode = $currentuser->getUserProperty("system", "sortmode-idlang-$lang-idcat-$idcat");
 166: 
 167:         // Main SQL statement
 168:         $sql = "SELECT
 169:                     a.idart AS idart,
 170:                     a.idlang AS idlang,
 171:                     a.idartlang AS idartlang,
 172:                     a.title AS title,
 173:                     c.idcat AS idcat,
 174:                     c.idcatart AS idcatart,
 175:                     a.idtplcfg AS idtplcfg,
 176:                     a.published AS published,
 177:                     a.online AS online,
 178:                     a.created AS created,
 179:                     a.lastmodified AS lastmodified,
 180:                     a.timemgmt AS timemgmt,
 181:                     a.datestart AS datestart,
 182:                     a.dateend AS dateend,
 183:                     a.artsort AS artsort,
 184:                     a.redirect AS redirect,
 185:                     a.locked AS locked
 186:                  FROM
 187:                     " . $cfg["tab"]["art_lang"] . " AS a,
 188:                     " . $cfg["tab"]["art"] . " AS b,
 189:                     " . $cfg["tab"]["cat_art"] . " AS c
 190:                  WHERE
 191:                     (a.idlang   = " . $lang . " {SYNCOPTIONS}) AND
 192:                     a.idart     = b.idart AND
 193:                     b.idclient  = " . $client . " AND
 194:                     b.idart     = c.idart AND
 195:                     c.idcat     = " . $idcat;
 196: 
 197:         // Simple SQL statement to get the number of articles
 198:         // Only with activated synchonization mode
 199:         if ($syncoptions != -1) {
 200:             $sql_count = "SELECT
 201:                         COUNT(*) AS article_count
 202:                      FROM
 203:                         " . $cfg["tab"]["art_lang"] . " AS a,
 204:                         " . $cfg["tab"]["art"] . " AS b,
 205:                         " . $cfg["tab"]["cat_art"] . " AS c
 206:                      WHERE
 207:                         (a.idlang   = " . cSecurity::toInteger($lang) . " {SYNCOPTIONS}) AND
 208:                         a.idart     = b.idart AND
 209:                         b.idclient  = " . cSecurity::toInteger($client) . " AND
 210:                         b.idart     = c.idart AND
 211:                         c.idcat     = " . cSecurity::toInteger($idcat);
 212: 
 213:             $sql = str_replace("{SYNCOPTIONS}", "OR a.idlang = '" . $syncoptions . "'", $sql);
 214:             $sql_count = str_replace("{SYNCOPTIONS}", "OR a.idlang = '" . $syncoptions . "'", $sql_count);
 215: 
 216:             if ($elemperpage > 1) {
 217:                 $db->query($sql_count);
 218:                 $db->nextRecord();
 219:                 $iArticleCount = $db->f("article_count");
 220:             }
 221:         } else {
 222:             $sql = str_replace("{SYNCOPTIONS}", '', $sql);
 223:             $iArticleCount = $articles_in_selected_language;
 224:         }
 225: 
 226:         // Article sort
 227:         if ($sortmode !== 'asc' && $sortmode !== 'desc') {
 228:             $sortmode = 'asc';
 229:         }
 230:         switch ($sortby) {
 231:             case 2:
 232:                 $sql .= ' ORDER BY a.lastmodified ' . cString::toUpperCase($sortmode);
 233:                 break;
 234:             case 3:
 235:                 $sql .= ' ORDER BY a.published ' . cString::toUpperCase($sortmode) . ', a.lastmodified ' . cString::toUpperCase($sortmode);
 236:                 break;
 237:             case 4:
 238:                 $sql .= ' ORDER BY a.artsort ' . cString::toUpperCase($sortmode);
 239:                 break;
 240:             default:
 241:                 // Default sort order
 242:                 $sql .= ' ORDER BY a.title ' . cString::toUpperCase($sortmode);
 243:                 $sortby = 1;
 244:         }
 245: 
 246:         // Getting article count, if necessary
 247:         if ($elemperpage > 0) {
 248: 
 249:             // If the synchronized mode is on, perhaps we must increase the limit
 250:             if ($elemperpage < $iArticleCount) {
 251:                 $add = $iArticleCount - $articles_in_selected_language;
 252:                 $elemperpage = $elemperpage + $add;
 253:             }
 254: 
 255:             // If not beyond scope, limit
 256:             if ($iArticleCount == 0) {
 257:                 $next = 0;
 258:             } elseif ($next >= $iArticleCount) {
 259:                 $next = (ceil($iArticleCount / $elemperpage) - 1) * $elemperpage;
 260:             }
 261:             $sql .= " LIMIT $next, $elemperpage";
 262:         } else {
 263:             $iArticleCount = 0; // Will be used to "hide" the browsing area
 264:         }
 265: 
 266:         // Getting data
 267:         $db->query($sql);
 268: 
 269:         // Reset Template
 270:         $tpl->reset();
 271: 
 272:         // No article
 273:         $no_article = true;
 274: 
 275:         $aArticles = array();
 276: 
 277:         while ($db->nextRecord()) {
 278:             $sItem = "k" . $db->f("idart");
 279: 
 280:             if ($db->f("idlang") == $lang || !array_key_exists($sItem, $aArticles)) {
 281:                 $aArticles[$sItem]["idart"] = $db->f("idart");
 282:                 $aArticles[$sItem]["idlang"] = $db->f("idlang");
 283:                 $aArticles[$sItem]["idartlang"] = $db->f("idartlang");
 284:                 $aArticles[$sItem]["title"] = cSecurity::unFilter($db->f("title"));
 285:                 $aArticles[$sItem]["is_start"] = isStartArticle($db->f("idartlang"), $idcat, $lang);
 286:                 $aArticles[$sItem]["idcatart"] = $db->f("idcatart");
 287:                 $aArticles[$sItem]["idtplcfg"] = $db->f("idtplcfg");
 288:                 $aArticles[$sItem]["published"] = $db->f("published");
 289:                 $aArticles[$sItem]["online"] = $db->f("online");
 290:                 $aArticles[$sItem]["created"] = $db->f("created");
 291:                 $aArticles[$sItem]["idcat"] = $db->f("idcat");
 292:                 $aArticles[$sItem]["lastmodified"] = $db->f("lastmodified");
 293:                 $aArticles[$sItem]["timemgmt"] = $db->f("timemgmt");
 294:                 $aArticles[$sItem]["datestart"] = $db->f("datestart");
 295:                 $aArticles[$sItem]["dateend"] = $db->f("dateend");
 296:                 $aArticles[$sItem]["artsort"] = $db->f("artsort");
 297:                 $aArticles[$sItem]["locked"] = $db->f("locked");
 298:                 $aArticles[$sItem]["redirect"] = $db->f("redirect");
 299:             }
 300:         }
 301: 
 302:         $artlist = array();
 303:         $colitem = array();
 304:         $articlesOnline = 0;
 305:         $articlesOffline = 0;
 306:         $articlesLocked = 0;
 307:         $articlesUnlocked = 0;
 308:         $articlesToSync = 0;
 309:         $articlesToRemove = 0;
 310:         $articlesToEdit = 0;
 311: 
 312:         foreach ($aArticles as $sart) {
 313:             $idart = $sart["idart"];
 314:             $idlang = $sart["idlang"];
 315: 
 316:             $idtplcfg = $sart["idtplcfg"];
 317:             $idartlang = $sart["idartlang"];
 318:             $lidcat = $sart["idcat"];
 319:             $idcatlang = 0;
 320:             $idart = $sart["idart"];
 321:             $published = $sart["published"];
 322:             $online = $sart["online"];
 323: 
 324:             $is_start = $sart["is_start"];
 325: 
 326:             $idcatart = $sart["idcatart"];
 327:             $created = $sart["created"];
 328:             $modified = $sart["lastmodified"];
 329: 
 330:             if ($modified === '0000-00-00 00:00:00') {
 331:                 $modified = i18n("not modified yet");
 332:             } else {
 333:                 $modified = date($dateformat, strtotime($modified));
 334:             }
 335:             $title = conHtmlSpecialChars($sart["title"]);
 336:             $timemgmt = $sart["timemgmt"];
 337:             $datestart = $sart["datestart"];
 338:             $dateend = $sart["dateend"];
 339:             $sortkey = $sart["artsort"];
 340:             $locked = $sart["locked"];
 341:             $redirect = $sart["redirect"];
 342: 
 343:             $published = ($published != '0000-00-00 00:00:00') ? date($dateformat, strtotime($published)) : i18n("not yet published");
 344:             $created = date($dateformat, strtotime($created));
 345:             $alttitle = "idart" . '&#58; ' . $idart . ' ' . "idcatart" . '&#58; ' . $idcatart . ' ' . "idartlang" . '&#58; ' . $idartlang;
 346: 
 347:             $articlesToEdit++;
 348: 
 349:             if ($idlang != $lang) {
 350:                 $articlesToSync++;
 351:             } else {
 352:                 if ($online == 1) {
 353:                     $articlesOnline++;
 354:                 } else {
 355:                     $articlesOffline++;
 356:                 }
 357:                 if ($locked == 1) {
 358:                     $articlesLocked++;
 359:                 } else {
 360:                     $articlesUnlocked++;
 361:                 }
 362:                 $articlesToRemove++;
 363:             }
 364: 
 365:             if ((($obj = $col->checkMark("article", $idartlang)) === false) || $obj->get("userid") == $auth->auth['uid']) {
 366:                 $inUse = false;
 367:             } else {
 368:                 $vuser = new cApiUser($obj->get("userid"));
 369:                 $inUseUser = $vuser->getField("username");
 370:                 $inUseUserRealName = $vuser->getField("realname");
 371: 
 372:                 $inUse = true;
 373:                 $title = $title . " (" . i18n("Article is in use") . ")";
 374:                 $alttitle = sprintf(i18n("Article in use by %s (%s)"), $inUseUser, $inUseUserRealName) . " " . $alttitle;
 375:             }
 376: 
 377:             // Id of the row, stores informations about the article and category
 378:             $tmp_rowid = $idart . "-" . $idartlang . "-" . $lidcat . "-" . $idcatlang . "-" . $idcatart . "-" . $idlang;
 379:             $tpl->set('d', 'ROWID', $tmp_rowid);
 380: 
 381:             if ($idlang != $lang) {
 382:                 $colitem[$tmp_rowid] = 'con_sync';
 383:             }
 384: 
 385:             // Article Title
 386:             if ($perm->have_perm_area_action('con_editcontent', 'con_editart') || $perm->have_perm_area_action_item('con_editcontent', 'con_editart', $idcat)) {
 387:                 if ($idlang != $lang) {
 388:                     $tmp_alink = $sess->url("main.php?area=con_editcontent&action=con_editart&changeview=prev&idartlang=$idartlang&idart=$idart&idcat=$idcat&frame=$frame&tmpchangelang=$idlang");
 389:                     $titlelink = '<a href="' . $tmp_alink . '" title="' . $alttitle . '">' . $title . '</a>';
 390:                 } else {
 391:                     $tmp_alink = $sess->url("main.php?area=con_editcontent&action=con_editart&changeview=edit&idartlang=$idartlang&idart=$idart&idcat=$idcat&frame=$frame");
 392:                     $titlelink = '<a href="' . $tmp_alink . '" title="' . $alttitle . '">' . $title . '</a>';
 393:                 }
 394:             } else {
 395:                 $tmp_alink = '';
 396:                 $titlelink = $title;
 397:             }
 398: 
 399:             if ($timemgmt == "1") {
 400:                 $sql = "SELECT NOW() AS TIME";
 401: 
 402:                 $db3 = cRegistry::getDb();
 403: 
 404:                 $db3->query($sql);
 405:                 $db3->nextRecord();
 406: 
 407:                 $starttimestamp = strtotime($datestart);
 408:                 $endtimestamp = strtotime($dateend);
 409:                 $nowtimestamp = strtotime($db3->f("TIME"));
 410: 
 411:                 if (($nowtimestamp < $endtimestamp) && ($nowtimestamp > $starttimestamp)) {
 412:                     $usetime = '<img class="vAlignMiddle tableElement" src="images/but_time_2.gif" alt="' . i18n("Article with time control online") . '" title="' . i18n("Article with time control online") . '">';
 413:                 } else {
 414:                     $usetime = '<img class="vAlignMiddle tableElement" src="images/but_time_1.gif" alt="' . i18n("Article with time control offline") . '" title="' . i18n("Article with time control offline") . '">';
 415:                 }
 416:             } else {
 417:                 $usetime = '';
 418:             }
 419: 
 420:             // Article Title
 421:             if (($perm->have_perm_area_action('con', 'con_lock') || $perm->have_perm_area_action_item('con', 'con_lock', $idcat)) && $inUse == false) {
 422:                 if ($locked == 1) {
 423:                     $lockimg = 'images/article_locked.gif';
 424:                     $lockalt = i18n("Unfreeze article");
 425:                 } else {
 426:                     $lockimg = 'images/article_unlocked.gif';
 427:                     $lockalt = i18n("Freeze article");
 428:                 }
 429:                 $tmp_lock = '<a href="' . $sess->url("main.php?area=con&idcat=$idcat&action=con_lock&frame=4&idart=$idart&next=$next") . '" title="' . $lockalt . '"><img class="vAlignMiddle tableElement" src="' . $lockimg . '" title="' . $lockalt . '" alt="' . $lockalt . '" border="0"></a>';
 430:             } else {
 431:                 if ($locked == 1) {
 432:                     $lockimg = 'images/article_locked.gif';
 433:                     $lockalt = i18n("Article is frozen");
 434:                 } else {
 435:                     $lockimg = 'images/article_unlocked.gif';
 436:                     $lockalt = i18n("Article is not frozen");
 437:                 }
 438:                 $tmp_lock = '<img class="vAlignMiddle tableElement" src="' . $lockimg . '" title="' . $lockalt . '" alt="' . $lockalt . '" border="0">';
 439:             }
 440: 
 441:             if ($idlang != $lang) {
 442:                 $lockedlink = '';
 443:             } else {
 444:                 $lockedlink = $tmp_lock;
 445:             }
 446: 
 447:             if ($sortkey == '') {
 448:                 $sortkey = '&nbsp;';
 449:             }
 450: 
 451:             $tmp_articletitle = $titlelink;
 452: 
 453:             // Article conf button
 454:             if ($perm->have_perm_area_action('con_editart', 'con_edit') || $perm->have_perm_area_action_item('con_editart', 'con_edit', $idcat)) {
 455:                 $tmp_artconf = '<a href="' . $sess->url("main.php?area=con_editart&action=con_edit&frame=4&idart=$idart&idcat=$idcat") . '" title="' . i18n("Article properties") . '"><img class="vAlignMiddle tableElement" src="' . $cfg["path"]["images"] . 'but_art_conf2.gif" alt="' . i18n("Article properties") . '" title="' . i18n("Article properties") . '" border="0"></a>';
 456:             } else {
 457:                 $tmp_artconf = '';
 458:             }
 459: 
 460:             $tmp_sync = '';
 461:             if ($idlang != $lang) {
 462:                 $sql = "SELECT idcatlang FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat='" . cSecurity::toInteger($idcat) . "' AND idlang='" . cSecurity::toInteger($lang) . "'";
 463:                 $db->query($sql);
 464: 
 465:                 if ($db->nextRecord()) {
 466:                     $tmp_sync = '<a href="' . $sess->url("main.php?area=con&action=con_syncarticle&idart=$idart&sourcelanguage=$idlang&frame=4&idcat=$idcat&next=$next") . '" title="' . i18n("Copy article to the current language") . '"><img class="vAlignMiddle tableElement" src="' . $cfg["path"]["images"] . 'but_sync_art.gif" alt="' . i18n("Copy article to the current language") . '" title="' . i18n("Copy article to the current language") . '" border="0"></a>';
 467:                 } else {
 468:                     $tmp_sync = '';
 469:                     $articlesToSync--;
 470:                     $articlesToRemove--;
 471:                 }
 472:             }
 473: 
 474:             // Article Template
 475:             if (!is_object($db2)) {
 476:                 $db2 = cRegistry::getDb();
 477:             }
 478: 
 479:             $sql2 = "SELECT
 480:                         b.name AS tplname,
 481:                         b.idtpl AS idtpl,
 482:                         b.description AS description
 483:                      FROM
 484:                         " . $cfg["tab"]["tpl_conf"] . " AS a,
 485:                         " . $cfg["tab"]["tpl"] . " AS b
 486:                      WHERE
 487:                         a.idtplcfg = " . cSecurity::toInteger($idtplcfg) . " AND
 488:                         a.idtpl = b.idtpl";
 489: 
 490:             $db2->query($sql2);
 491:             $db2->nextRecord();
 492: 
 493:             $a_tplname = $db2->f("tplname");
 494:             $a_idtpl = $db2->f("idtpl");
 495:             $templateDescription = $db2->f("description");
 496: 
 497:             // Uses Category Template
 498:             if (0 == $idtplcfg) {
 499:                 $sql2 = "SELECT
 500:                     c.idtpl AS idtpl,
 501:                     c.name AS name,
 502:                     c.description,
 503:                     b.idtplcfg AS idtplcfg
 504:                 FROM
 505:                     " . $cfg['tab']['tpl_conf'] . " AS a,
 506:                     " . $cfg['tab']['cat_lang'] . " AS b,
 507:                     " . $cfg['tab']['tpl'] . " AS c
 508:                 WHERE
 509:                     b.idcat     = " . cSecurity::toInteger($idcat) . " AND
 510:                     b.idlang    = " . cSecurity::toInteger($lang) . " AND
 511:                     b.idtplcfg  = a.idtplcfg AND
 512:                     c.idtpl     = a.idtpl AND
 513:                     c.idclient  = " . cSecurity::toInteger($client);
 514:                 $db2->query($sql2);
 515:                 $db2->nextRecord();
 516:                 $a_tplname = $db2->f("name") ? '<i>' . $db2->f("name") . '</i>' : "--- " . i18n("None") . " ---";
 517:             }
 518: 
 519:             // CON-2137 check admin permission
 520:             $aAuthPerms = explode(',', $auth->auth['perm']);
 521: 
 522:             $admin = false;
 523:             if (count(preg_grep("/admin.*/", $aAuthPerms)) > 0) {
 524:                 $admin = true;
 525:             }
 526: 
 527:             // Make Startarticle button
 528:             $imgsrc = "isstart";
 529: 
 530:             if ($is_start == false) {
 531:                 $imgsrc .= '0';
 532:             } else {
 533:                 $imgsrc .= '1';
 534:             }
 535:             if (isArtInMultipleUse($idart)) {
 536:                 $imgsrc .= 'm';
 537:             }
 538:             if ((int) $redirect == 1) {
 539:                 $imgsrc .= 'r';
 540:             }
 541: 
 542:             $imgsrc .= '.gif';
 543: 
 544:             if ($idlang == $lang && ($perm->have_perm_area_action('con', 'con_makestart') || $perm->have_perm_area_action_item('con', 'con_makestart', $idcat)) && $idcat != 0 && ((int) $locked === 0 || $admin)) {
 545:                 if ($is_start == false) {
 546:                     $tmp_link = '<a href="' . $sess->url("main.php?area=con&amp;idcat=$idcat&amp;action=con_makestart&amp;idcatart=$idcatart&amp;frame=4&is_start=1&amp;next=$next") . '" title="' . i18n("Flag as start article") . '"><img class="vAlignMiddle tableElement" src="images/' . $imgsrc . '" border="0" title="' . i18n("Flag as start article") . '" alt="' . i18n("Flag as start article") . '"></a>';
 547:                 } else {
 548:                     $tmp_link = '<a href="' . $sess->url("main.php?area=con&amp;idcat=$idcat&amp;action=con_makestart&amp;idcatart=$idcatart&amp;frame=4&amp;is_start=0&amp;next=$next") . '" title="' . i18n("Flag as normal article") . '"><img class="vAlignMiddle tableElement" src="images/' . $imgsrc . '" border="0" title="' . i18n("Flag as normal article") . '" alt="' . i18n("Flag as normal article") . '"></a>';
 549:                 }
 550:             } else {
 551:                 if ($is_start == true) {
 552:                     $sTitle = i18n("Start article");
 553:                 } else {
 554:                     $sTitle = i18n("Normal article");
 555:                 }
 556: 
 557:                 $tmp_img = '<img class="vAlignMiddle tableElement" src="images/' . $imgsrc . '" border="0" title="' . $sTitle . '" alt="' . $sTitle . '">';
 558: 
 559:                 $tmp_link = $tmp_img;
 560:             }
 561: 
 562:             $tmp_start = $tmp_link;
 563: 
 564:             // Make copy button
 565:             if (($perm->have_perm_area_action('con', 'con_duplicate') || $perm->have_perm_area_action_item('con', 'con_duplicate', $idcat)) && $idcat != 0 && ((int) $locked === 0 || $admin )) {
 566:                 $imgsrc = "but_copy.gif";
 567:                 // add count_duplicate param to identify if the duplicate action
 568:                 // is called from click or back button.
 569:                 $tmp_link = '<a href="' . $sess->url("main.php?area=con&idcat=$idcat&action=con_duplicate&duplicate=$idart&frame=4&next=$next") . "&count_duplicate=" . $_SESSION['count_duplicate'] . '" title="' . i18n("Duplicate article") . '"><img class="vAlignMiddle tableElement" src="images/' . $imgsrc . '" border="0" title="' . i18n("Duplicate article") . '" alt="' . i18n("Duplicate article") . '"></a>';
 570:             } else {
 571:                 $tmp_link = '';
 572:             }
 573: 
 574:             if ($idlang != $lang) {
 575:                 $duplicatelink = '';
 576:             } else {
 577:                 $duplicatelink = $tmp_link;
 578:             }
 579: 
 580:             // Make todo link
 581:             $todolink = '';
 582: 
 583:             $subject = urlencode(sprintf(i18n("Reminder for article '%s'"), $title));
 584:             $mycatname = '';
 585:             conCreateLocationString($idcat, "&nbsp;/&nbsp;", $mycatname);
 586:             $message = urlencode(sprintf(i18n("Reminder for article '%s'\nCategory: %s"), $title, $mycatname));
 587: 
 588:             $todolink = new TODOLink("idart", $idart, $subject, $message);
 589: 
 590:             // Make On-/Offline button
 591:             if ($online) {
 592:                 if (($perm->have_perm_area_action('con', 'con_makeonline') || $perm->have_perm_area_action_item('con', 'con_makeonline', $idcat)) && ($idcat != 0) && ((int) $locked === 0 || $admin)) {
 593:                     $tmp_online = '<a href="' . $sess->url("main.php?area=con&idcat=$idcat&action=con_makeonline&frame=4&idart=$idart&next=$next") . '" title="' . i18n("Make offline") . '"><img class="vAlignMiddle tableElement" src="images/online.gif" title="' . i18n("Make offline") . '" alt="' . i18n("Make offline") . '" border="0"></a>';
 594:                 } else {
 595:                     $tmp_online = '<img class="vAlignMiddle tableElement" src="images/online.gif" title="' . i18n("Article is online") . '" alt="' . i18n("Article is online") . '" border="0">';
 596:                 }
 597:             } else {
 598:                 if (($perm->have_perm_area_action('con', 'con_makeonline') || $perm->have_perm_area_action_item('con', 'con_makeonline', $idcat)) && ($idcat != 0) && ((int) $locked === 0 || $admin)) {
 599:                     $tmp_online = '<a href="' . $sess->url("main.php?area=con&idcat=$idcat&action=con_makeonline&frame=4&idart=$idart&next=$next") . '" title="' . i18n("Make online") . '"><img class="vAlignMiddle tableElement" src="images/offline.gif" title="' . i18n("Make online") . '" alt="' . i18n("Make online") . '" border="0"></a>';
 600:                 } else {
 601:                     $tmp_online = '<img class="vAlignMiddle tableElement" src="images/offline.gif" title="' . i18n("Article is offline") . '" alt="' . i18n("Article is offline") . '" border="0">';
 602:                 }
 603:             }
 604: 
 605:             if ($idlang != $lang) {
 606:                 $onlinelink = '';
 607:             } else {
 608:                 $onlinelink = $tmp_online;
 609:             }
 610: 
 611:             // Delete button
 612:             if (($perm->have_perm_area_action('con', 'con_deleteart') || $perm->have_perm_area_action_item('con', 'con_deleteart', $idcat)) && $inUse == false && ((int) $locked === 0  || $admin)) {
 613:                 $tmp_title = $title;
 614:                 if (cString::getStringLength($tmp_title) > 30) {
 615:                     $tmp_title = cString::getPartOfString($tmp_title, 0, 27) . "...";
 616:                 }
 617: 
 618:                 $confirmString = sprintf(i18n("Are you sure to delete the following article:<br><br><b>%s</b>"), conHtmlSpecialChars($tmp_title));
 619:                 $tmp_del = '<a href="javascript:void(0)" onclick="Con.showConfirmation(&quot;' . $confirmString . '&quot;, function() { deleteArticle(' . $idart . ', ' . $idcat . ', ' . $next . '); });return false;" title="' . i18n("Delete article") . '"><img class="vAlignMiddle tableElement" src="images/delete.gif" title="' . i18n("Delete article") . '" alt="' . i18n("Delete article") . '"></a>';
 620:             } else {
 621:                 $tmp_del = '';
 622:             }
 623: 
 624:             if ($idlang != $lang) {
 625:                 $deletelink = '';
 626:             } else {
 627:                 $deletelink = $tmp_del;
 628:             }
 629: 
 630:             // DIRECTION
 631:             cInclude('includes', 'functions.lang.php');
 632:             $tpl->set('d', 'DIRECTION', 'dir="' . langGetTextDirection($lang) . '"');
 633: 
 634:             // Next iteration
 635:             // Articles found
 636:             $no_article = false;
 637:             $oArtLang = new cApiArticleLanguage();
 638:             foreach ($listColumns as $listColumn => $ctitle) {
 639:                 $oArtLang->loadBy($oArtLang->getPrimaryKeyName(), $idartlang);
 640: 
 641:                 switch ($listColumn) {
 642:                     case "mark":
 643:                         $value = '<input type="checkbox" name="mark" value="' . $idart . '" class="mark_articles">';
 644:                         break;
 645:                     case "start":
 646:                         $value = $tmp_start . $usetime;
 647:                         break;
 648:                     case "title":
 649:                         $value = $tmp_articletitle;
 650:                         break;
 651:                     case "changeddate":
 652:                         $value = $modified;
 653:                         break;
 654:                     case "publisheddate":
 655:                         if ('1' === $oArtLang->get('online')) {
 656:                             $value = $published;
 657:                         } else {
 658:                             $value = i18n("not yet published");
 659:                         }
 660:                         break;
 661:                     case "sortorder":
 662:                         $value = $sortkey;
 663:                         break;
 664:                     case "template":
 665:                         $value = $a_tplname;
 666:                         break;
 667:                     case "actions":
 668:                         $actions = array();
 669:                         foreach ($actionList as $actionItem) {
 670:                             switch ($actionItem) {
 671:                                 case "todo":
 672:                                     $actionValue = $todolink;
 673:                                     break;
 674:                                 case "artconf":
 675:                                     $actionValue = $tmp_artconf;
 676:                                     break;
 677:                                 case "online":
 678:                                     $actionValue = $onlinelink;
 679:                                     break;
 680:                                 case "locked":
 681:                                     $actionValue = $lockedlink;
 682:                                     break;
 683:                                 case "duplicate":
 684:                                     $actionValue = $duplicatelink;
 685:                                     break;
 686:                                 case "delete":
 687:                                     $actionValue = $deletelink;
 688:                                     break;
 689:                                 case "usetime":
 690:                                     $actionValue = '';
 691:                                     break;
 692:                                 default:
 693:                                     // Ask chain about the entry
 694:                                     $_cecIterator = $_cecRegistry->getIterator("Contenido.ArticleList.RenderAction");
 695:                                     $contents = array();
 696:                                     if ($_cecIterator->count() > 0) {
 697:                                         while ($chainEntry = $_cecIterator->next()) {
 698:                                             $contents[] = $chainEntry->execute($idcat, $idart, $idartlang, $actionItem);
 699:                                         }
 700:                                     }
 701:                                     $actionValue = implode('', $contents);
 702:                                     break;
 703:                             }
 704: 
 705:                             $actions[] = $actionValue;
 706:                         }
 707: 
 708:                         if ($tmp_sync != '') {
 709:                             $actions[] = $tmp_sync;
 710:                         }
 711: 
 712:                         // add properties button
 713:                         if ($tmp_sync != '') {
 714:                             $actions[] = '<a id="properties" href="main.php?area=con_editart&action=con_edit&frame=4&idcat=' . $idcat . '&idart=' . $idart . '&contenido=' . $contenido . '">
 715:                                 <img class="vAlignMiddle tableElement" onmouseover="this.style.cursor=\'pointer\'" src="images/but_art_conf2.gif" title="' . i18n("Display properties") . '" alt="' . i18n("Display properties") . '" style="cursor: pointer;">
 716:                             </a>';
 717:                         }
 718: 
 719:                         $value = implode("\n", $actions);
 720:                         break;
 721:                     default:
 722:                         $contents = array();
 723:                         // Call chain to retrieve value
 724:                         $_cecIterator = $_cecRegistry->getIterator("Contenido.ArticleList.RenderColumn");
 725:                         if ($_cecIterator->count() > 0) {
 726:                             $contents = array();
 727:                             while ($chainEntry = $_cecIterator->next()) {
 728:                                 $contents[] = $chainEntry->execute($idcat, $idart, $idartlang, $listColumn);
 729:                             }
 730:                         }
 731:                         $value = implode('', $contents);
 732:                 }
 733:                 $artlist[$tmp_rowid][$listColumn] = $value;
 734:                 $artlist[$tmp_rowid]['templateDescription'] = $templateDescription;
 735:             }
 736:             unset($oArtLang);
 737:         }
 738: 
 739:         $headers = array();
 740: 
 741:         // keep old keys so that saved user properties still work
 742:         $sortColumns = array(
 743:             'title' => 1,
 744:             'changeddate' => 2,
 745:             'publisheddate' => 3,
 746:             'sortorder' => 4
 747:         );
 748:         foreach ($listColumns as $key => $listColumn) {
 749:             // Dirty hack to force column widths
 750:             $width = ($key == 'title' || $listColumn == i18n('Title')) ? '100%' : '1%';
 751:             // if it should be possible to sort by this column, add a link
 752:             if (in_array($key, array_keys($sortColumns))) {
 753:                 $newSortmode = 'asc';
 754:                 // revert the sorting if it already has been sorted by this
 755:                 // column
 756:                 if ($sortby == $sortColumns[$key] && $sortmode == 'asc') {
 757:                     $newSortmode = 'desc';
 758:                 }
 759:                 // add the appropriate sorting image if necessary
 760:                 if ($sortby == $sortColumns[$key]) {
 761:                     $imageSrc = ($sortmode == 'asc') ? 'images/sort_up.gif' : 'images/sort_down.gif';
 762:                     $sortImage = '<img src="' . $imageSrc . '">';
 763:                 } else {
 764:                     $sortImage = '';
 765:                 }
 766:                 $sortLink = $sess->url("main.php?area=con&frame=4&idcat=$idcat&sortby=$sortColumns[$key]&sortmode=$newSortmode");
 767:                 $col = '<a href="' . $sortLink . '" class="gray">' . $listColumn . $sortImage . '</a>';
 768:             } else {
 769:                 $col = $listColumn;
 770:             }
 771:             $headers[] = '<th width="' . $width . '" nowrap="nowrap">' . $col . '</th>';
 772:         }
 773: 
 774:         $tpl->set('s', 'HEADERS', implode("\n", $headers));
 775: 
 776:         if ($elemperpage > 0 && $iArticleCount > 0 && $iArticleCount > $elemperpage) {
 777:             for ($i = 1; $i <= ceil($iArticleCount / $elemperpage); $i++) {
 778:                 $iNext = ($i - 1) * $elemperpage;
 779:                 if ($sBrowseLinks !== '') {
 780:                     $sBrowseLinks .= '&nbsp;';
 781:                 }
 782:                 if ($next == $iNext) {
 783:                     $sBrowseLinks .= $i . "\n"; // I'm on the current page, no
 784:                                                     // link
 785:                 } else {
 786:                     $tmp_alink = $sess->url("main.php?area=con&frame=$frame&idcat=$idcat&next=$iNext");
 787:                     $sBrowseLinks .= '<a href="' . $tmp_alink . '">' . $i . '</a>' . "\n";
 788:                 }
 789:             }
 790:             $tpl->set('s', 'NEXT', $next);
 791:             $tpl->set('s', 'BROWSE', sprintf(i18n("Go to page: %s"), $sBrowseLinks));
 792:         } else {
 793:             $tpl->set('s', 'NEXT', "0");
 794:             $tpl->set('s', 'BROWSE', '&nbsp;');
 795:         }
 796:         $tpl->set('s', 'CLICK_ROW_NOTIFICATION', i18n("Click on a row to select an article for editing"));
 797: 
 798:         // construct the bulk editing functions
 799:         $bulkEditingFunctions = '';
 800:         if ($articlesOffline > 0 && ($perm->have_perm_area_action("con", "con_makeonline") || $perm->have_perm_area_action_item("con", "con_makeonline", $idcat))) {
 801:             $bulkEditingFunctions .= createBulkEditingFunction('con_makeonline', 'images/online.gif', i18n('Set articles online'));
 802:         }
 803:         if ($articlesOnline > 0 && ($perm->have_perm_area_action("con", "con_makeonline") || $perm->have_perm_area_action_item("con", "con_makeonline", $idcat))) {
 804:             $bulkEditingFunctions .= createBulkEditingFunction('con_makeonline invert', 'images/offline.gif', i18n('Set articles offline'));
 805:         }
 806:         if ($articlesUnlocked > 0 && ($perm->have_perm_area_action("con", "con_lock") || $perm->have_perm_area_action_item("con", "con_lock", $idcat))) {
 807:             $bulkEditingFunctions .= createBulkEditingFunction('con_lock', 'images/article_unlocked.gif', i18n('Freeze articles'));
 808:         }
 809:         if ($articlesLocked > 0 && ($perm->have_perm_area_action("con", "con_lock") || $perm->have_perm_area_action_item("con", "con_lock", $idcat))) {
 810:             $bulkEditingFunctions .= createBulkEditingFunction('con_lock invert', 'images/article_locked.gif', i18n('Unfreeze articles'));
 811:         }
 812:         if ($articlesToSync > 0 && ($perm->have_perm_area_action("con", "con_syncarticle") || $perm->have_perm_area_action_item("con", "con_syncarticle", $idcat))) {
 813:             $bulkEditingFunctions .= createBulkEditingFunction('con_syncarticle', 'images/but_sync_art.gif', i18n('Copy article to the current language'));
 814:         }
 815:         if ($articlesToRemove > 0 && ($perm->have_perm_area_action("con", "con_deleteart") || $perm->have_perm_area_action_item("con", "con_deleteart", $idcat))) {
 816:             $bulkEditingFunctions .= createBulkEditingFunction('con_deleteart', 'images/delete.gif', i18n('Delete articles'), 'Con.showConfirmation("' . i18n('Are you sure to delete the selected articles') . '", deleteArticles)');
 817:         }
 818:         if ($articlesToEdit > 0 && ($perm->have_perm_area_action("con_editart", "con_edit") || $perm->have_perm_area_action_item("con_editart", "con_edit", $idcat))) {
 819:             $bulkEditingFunctions .= createBulkEditingFunction('con_inlineeditart', 'images/editieren.gif', i18n('Edit articles'));
 820:         }
 821: 
 822:         if ($bulkEditingFunctions == "") {
 823:             $bulkEditingFunctions = i18n("Your permissions do not allow any actions here");
 824:         }
 825: 
 826:         $tpl->set('s', 'BULK_EDITING_FUNCTIONS', $bulkEditingFunctions);
 827:         $tpl->set('s', 'SAVE_ARTICLES', i18n('Save articles'));
 828: 
 829:         if (count($artlist) > 0) {
 830:             foreach ($artlist as $key2 => $artitem) {
 831: 
 832:                 $cells = array();
 833: 
 834:                 foreach ($listColumns as $key => $listColumn) {
 835:                     // Description for hover effect
 836:                     if ($key == 'template') {
 837:                         $templateDescription = $artitem['templateDescription'];
 838:                         $descString = '<b>' . $artitem[$key] . '</b>';
 839: 
 840:                         $sTemplatename = cString::trimHard($artitem[$key], 20);
 841:                         if (cString::getStringLength($artitem[$key]) > 20) {
 842:                             $cells[] = '<td nowrap="nowrap" class="bordercell tooltip" title="' . $descString . '">' . $sTemplatename . '</td>';
 843:                         } else {
 844:                             $cells[] = '<td nowrap="nowrap" class="bordercell">' . $artitem[$key] . '</td>';
 845:                         }
 846:                     } else {
 847:                         $cells[] = '<td nowrap="nowrap" class="bordercell">' . $artitem[$key] . '</td>';
 848:                     }
 849:                 }
 850:                 $tpl->set('d', 'CELLS', implode("\n", $cells));
 851: 
 852:                 if ($colitem[$key2] == 'con_sync') {
 853:                     $tpl->set('d', 'CSS_CLASS', 'class="con_sync"');
 854:                 } else {
 855:                     $tpl->set('d', 'CSS_CLASS', '');
 856:                 }
 857: 
 858:                 $tpl->set('d', 'ROWID', $key2);
 859:                 $tpl->next();
 860:             }
 861:         } else {
 862:             $emptyCell = '<td nowrap="nowrap" class="bordercell" colspan="' . count($listColumns) . '">' . i18n("No articles found") . '</td>';
 863:             $tpl->set('d', 'CELLS', $emptyCell);
 864:             $tpl->set('d', 'CSS_CLASS', '');
 865:             $tpl->set('d', 'ROWID', '');
 866:         }
 867: 
 868:         // Elements per Page select
 869:         $aElemPerPage = array(
 870:             0 => i18n("All"),
 871:             10 => "10",
 872:             25 => "25",
 873:             50 => "50",
 874:             75 => "75",
 875:             100 => "100"
 876:         );
 877: 
 878:         $tpl2 = new cTemplate();
 879:         $tpl2->set('s', 'NAME', 'sort');
 880:         $tpl2->set('s', 'CLASS', 'text_medium');
 881:         $tpl2->set('s', 'OPTIONS', 'onchange="changeElemPerPage(this)"');
 882: 
 883:         foreach ($aElemPerPage as $key => $value) {
 884:             $selected = ($elemperpage == $key) ? 'selected="selected"' : '';
 885:             $tpl2->set('d', 'VALUE', $key);
 886:             $tpl2->set('d', 'CAPTION', $value);
 887:             $tpl2->set('d', 'SELECTED', $selected);
 888:             $tpl2->next();
 889:         }
 890: 
 891:         $select = (!$no_article) ? $tpl2->generate($cfg["path"]["templates"] . $cfg['templates']['generic_select'], true) : '&nbsp;';
 892:         $caption = (!$no_article) ? i18n("Items per page:") : '&nbsp;';
 893: 
 894:         $tpl->set('s', 'ELEMPERPAGECAPTION', $caption);
 895:         $tpl->set('s', 'ELEMPERPAGE', $select);
 896: 
 897:         $tpl->set('s', 'IDCAT', $idcat);
 898:         $tpl->set('s', 'SOURCELANGUAGE', $idlang);
 899: 
 900:         // Extract Category and Catcfg
 901:         $sql = "SELECT
 902:                     b.name AS name,
 903:                     d.idtpl AS idtpl
 904:                 FROM
 905:                     (" . $cfg["tab"]["cat"] . " AS a,
 906:                     " . $cfg["tab"]["cat_lang"] . " AS b,
 907:                     " . $cfg["tab"]["tpl_conf"] . " AS c)
 908:                 LEFT JOIN
 909:                     " . $cfg["tab"]["tpl"] . " AS d
 910:                 ON
 911:                     d.idtpl = c.idtpl
 912:                 WHERE
 913:                     a.idclient = " . cSecurity::toInteger($client) . " AND
 914:                     a.idcat    = " . cSecurity::toInteger($idcat) . " AND
 915:                     b.idlang   = " . cSecurity::toInteger($lang) . " AND
 916:                     b.idcat    = a.idcat AND
 917:                     c.idtplcfg = b.idtplcfg";
 918: 
 919:         $db->query($sql);
 920: 
 921:         if ($db->nextRecord()) {
 922:             // $foreignlang = false;
 923:             // conCreateLocationString($idcat, "&nbsp;/&nbsp;", $cat_name);
 924:         }
 925: 
 926:         $cat_idtpl = $db->f("idtpl");
 927: 
 928:         $cat_name = renderBackendBreadcrumb($syncoptions, false, true);
 929: 
 930:         // Hinweis wenn kein Artikel gefunden wurde
 931:         if ($no_article) {
 932:             $tpl->set('d', "START", '&nbsp;');
 933:             $tpl->set('d', "ARTICLE", i18n("No articles found"));
 934:             $tpl->set('d', "PUBLISHED", '&nbsp;');
 935:             $tpl->set('d', "LASTMODIFIED", '&nbsp;');
 936:             $tpl->set('d', "ARTCONF", '&nbsp;');
 937:             $tpl->set('d', "TPLNAME", '&nbsp;');
 938:             $tpl->set('d', "LOCKED", '&nbsp;');
 939:             $tpl->set('d', "DUPLICATE", '&nbsp;');
 940:             $tpl->set('d', "TPLCONF", '&nbsp;');
 941:             $tpl->set('d', "ONLINE", '&nbsp;');
 942:             $tpl->set('d', "DELETE", '&nbsp;');
 943:             $tpl->set('d', "USETIME", '&nbsp;');
 944:             $tpl->set('d', "TODO", '&nbsp;');
 945:             $tpl->set('d', "SORTKEY", '&nbsp;');
 946: 
 947:             $tpl->next();
 948:         }
 949: 
 950:         // Kategorie anzeigen und Konfigurieren button
 951:         /*
 952:          * JL 23.06.03 Check right from "Content" instead of "Category" if
 953:          * ($perm->have_perm_area_action("str_tplcfg", "str_tplcfg") ||
 954:          * $perm->have_perm_area_action_item("str_tplcfg", "str_tplcfg",
 955:          * $lidcat))
 956:          */
 957: 
 958:         if (($perm->have_perm_area_action_item('con', 'con_tplcfg_edit', $idcat) || $perm->have_perm_area_action('con', 'con_tplcfg_edit')) && $foreignlang == false) {
 959:             if (0 != $idcat) {
 960:                 $tpl->set('s', 'CATEGORY', $cat_name);
 961:                 $tpl->set('s', 'CATEGORY_CONF', $tmp_img);
 962:                 $tpl->set('s', 'CATEGORY_LINK', $tmp_link);
 963:             } else {
 964:                 $tpl->set('s', 'CATEGORY', $cat_name);
 965:                 $tpl->set('s', 'CATEGORY_CONF', '&nbsp;');
 966:                 $tpl->set('s', 'CATEGORY_LINK', '&nbsp;');
 967:             }
 968:         } else {
 969:             $tpl->set('s', 'CATEGORY', $cat_name);
 970:             $tpl->set('s', 'CATEGORY_CONF', '&nbsp;');
 971:             $tpl->set('s', 'CATEGORY_LINK', '&nbsp;');
 972:         }
 973: 
 974:         // SELF_URL (Variable f�r das javascript);
 975:         $tpl->set('s', 'SELF_URL', $sess->url("main.php?area=con&frame=4&idcat=$idcat"));
 976: 
 977:         // Categories without start article
 978:         $warningBox = '';
 979:         if (strHasStartArticle($idcat, $lang) === false) {
 980:             $warningBox = $notification->returnNotification('warning', i18n('This category does not have a configured start article.'));
 981:         }
 982: 
 983:         // New Article link
 984:         if (($perm->have_perm_area_action('con_editart', 'con_newart') || $perm->have_perm_area_action_item('con_editart', 'con_newart', $idcat)) && $foreignlang == false) {
 985:             // check if category has an assigned template
 986:             if ($idcat != 0 && $cat_idtpl != 0) {
 987:                 $tpl->set('s', 'NEWARTICLE_TEXT', '<a id="newArtTxt" href="' . $sess->url("main.php?area=con_editart&frame=$frame&action=con_newart&idcat=$idcat") . '">' . i18n("Create new article") . '</a>');
 988:                 $tpl->set('s', 'NEWARTICLE_IMG', '<a id="newArtImg" href="' . $sess->url("main.php?area=con_editart&frame=$frame&action=con_newart&idcat=$idcat") . '" title="' . i18n("Create new article") . '"><img src="images/but_art_new.gif" border="0" alt="' . i18n("Create new article") . '"></a>');
 989:                 $tpl->set('s', 'CATTEMPLATE', $warningBox);
 990:             } else {
 991:                 // category is either not in sync or does not exist
 992:                 // check if category does not exist for current language if syncoptions is turned on to find out if current category is unsynchronized
 993:                 $oArtLang = new cApiArticleLanguage($idcat);
 994:                 if (0 < $syncoptions && false === $oArtLang->isLoaded()) {
 995:                     $notification_text = $notification->returnNotification("error", i18n("Creation of articles is only possible if the category has is synchronized."));
 996:                 } else {
 997:                     $notification_text = $notification->returnNotification("error", i18n("Creation of articles is only possible if the category has a assigned template."));
 998:                 }
 999:                 $tpl->set('s', 'CATTEMPLATE', $notification_text);
1000:                 $tpl->set('s', 'NEWARTICLE_TEXT', '&nbsp;');
1001:                 $tpl->set('s', 'NEWARTICLE_IMG', '&nbsp;');
1002:             }
1003:         } else {
1004:             $tpl->set('s', 'NEWARTICLE_TEXT', '&nbsp;');
1005:             $tpl->set('s', 'NEWARTICLE_IMG', '&nbsp;');
1006:             $tpl->set('s', 'CATTEMPLATE', $warningBox);
1007:         }
1008: 
1009:         $str = '';
1010: 
1011:         $tpl->set('s', 'NOTIFICATION', $str);
1012:         // modified by fulai.zhang 17.07.2012
1013:         // display if there are articles
1014:         if ($no_article) {
1015:             $tpl->set('s', 'NOARTICLE_CSS', "display: none;");
1016:             $tpl->set('s', 'NOARTICLE_JS', 'true');
1017:         } else {
1018:             $tpl->set('s', 'NOARTICLE_CSS', "");
1019:             $tpl->set('s', 'NOARTICLE_JS', 'false');
1020:         }
1021: 
1022:         // breadcrumb onclick
1023:         $tpl->set('s', 'IDTPL', $idtpl ? $idtpl : $cat_idtpl);
1024:         $tpl->set('s', 'SYNCOPTIONS', $syncoptions);
1025:         $tpl->set('s', 'DISPLAY_MENU', 1);
1026: 
1027:         // Generate template
1028:         $tpl->generate($cfg['path']['templates'] . $cfg['templates']['con_art_overview']);
1029:     } else {
1030:         $notification->displayNotification("error", i18n("Permission denied"));
1031:     }
1032: } else {
1033:     $tpl->reset();
1034:     $tpl->set('s', 'CONTENTS', '');
1035:     $tpl->generate($cfg['path']['templates'] . $cfg['templates']['blank']);
1036: }
1037: 
1038: /**
1039:  * Creates HTML code for the bulk editing functions in the article overview.
1040:  *
1041:  * @param string $class
1042:  *         the class for the link
1043:  * @param string $imageSrc
1044:  *         the path to the image
1045:  * @param string $alt
1046:  *         the alt tag for the image
1047:  * @param string $onclick [optional]
1048:  *         the onlick attribute for the link
1049:  * @return string
1050:  *         rendered HTML code
1051:  */
1052: function createBulkEditingFunction($class, $imageSrc, $alt, $onclick = '') {
1053:     $function = new cHTMLLink();
1054:     $function->setClass($class);
1055:     if ($onclick !== '') {
1056:         $function->setEvent('click', $onclick);
1057:     }
1058:     $image = new cHTMLImage($imageSrc);
1059:     $image->setAlt($alt);
1060:     $function->setContent($image);
1061: 
1062:     return $function->render();
1063: }
1064: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0