1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16:
17: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
18:
19: cInclude('includes', 'functions.tpl.php');
20: cInclude('includes', 'functions.str.php');
21: cInclude('includes', 'functions.pathresolver.php');
22:
23: $db2 = cRegistry::getDb();
24:
25: $idcat = (isset($_REQUEST['idcat']) && is_numeric($_REQUEST['idcat'])) ? $_REQUEST['idcat'] : -1;
26: $next = (isset($_REQUEST['next']) && is_numeric($_REQUEST['next']) && $_REQUEST['next'] > 0) ? $_REQUEST['next'] : 0;
27:
28: $dateformat = getEffectiveSetting('dateformat', 'date', 'Y-m-d');
29: $templateDescription = '';
30:
31: if (!isset($syncfrom)) {
32: $syncfrom = -1;
33: }
34:
35: $syncoptions = $syncfrom;
36:
37:
38: if (!isset($_SESSION['count_duplicate'])) {
39: $_SESSION['count_duplicate'] = 0;
40: }
41:
42:
43: global $selectedArticleId;
44: $selectedArticleId = NULL;
45:
46: if ($action == 'con_duplicate' && ($perm->have_perm_area_action("con", "con_duplicate") || $perm->have_perm_area_action_item("con", "con_duplicate", $idcat))) {
47:
48: $count = (int) $_SESSION['count_duplicate'];
49:
50:
51: if ($_GET['count_duplicate'] < $count) {
52: } else {
53:
54: $newidartlang = conCopyArticle($duplicate, $idcat);
55: $count++;
56: $_SESSION['count_duplicate'] = $count;
57: }
58: }
59:
60: if ($action == 'con_syncarticle' && ($perm->have_perm_area_action("con", "con_syncarticle") || $perm->have_perm_area_action_item("con", "con_syncarticle", $idcat))) {
61: if ($_POST['idarts']) {
62: $idarts = json_decode($_POST['idarts'], true);
63: } else {
64: $idarts = array(
65: $idart
66: );
67: }
68:
69:
70: $catLang = new cApiCategoryLanguage();
71: foreach ($idarts as $idart) {
72: if (!$catLang->loadByCategoryIdAndLanguageId($idcat, $lang)) {
73: strSyncCategory($idcat, $sourcelanguage, $lang);
74: }
75: conSyncArticle($idart, $sourcelanguage, $lang);
76: }
77: }
78:
79:
80: $listColumns = array(
81: "mark" => i18n("Mark"),
82: "start" => i18n("Article"),
83: "title" => i18n("Title"),
84: "changeddate" => i18n("Changed"),
85: "publisheddate" => i18n("Published"),
86: "sortorder" => i18n("Sort order"),
87: "template" => i18n("Template"),
88: "actions" => i18n("Actions")
89: );
90:
91:
92: $actionList = array(
93: "online",
94: "duplicate",
95: "locked",
96: "todo",
97: "delete",
98: "usetime"
99: );
100:
101:
102: $_cecIterator = $_cecRegistry->getIterator("Contenido.ArticleList.Columns");
103: if ($_cecIterator->count() > 0) {
104: while ($chainEntry = $_cecIterator->next()) {
105: $newColumnList = $chainEntry->execute($listColumns);
106: if (is_array($newColumnList)) {
107: $listColumns = $newColumnList;
108: }
109: }
110: }
111:
112: $_cecIterator = $_cecRegistry->getIterator("Contenido.ArticleList.Actions");
113: if ($_cecIterator->count() > 0) {
114: while ($chainEntry = $_cecIterator->next()) {
115: $newActionList = $chainEntry->execute($actionList);
116: if (is_array($newActionList)) {
117: $actionList = $newActionList;
118: }
119: }
120: }
121:
122: $cat_idtpl = 0;
123:
124: if (is_numeric($idcat) && ($idcat >= 0)) {
125:
126:
127: if (isset($sortby)) {
128: $currentuser->setUserProperty("system", "sortorder-idlang-$lang-idcat-$idcat", $sortby);
129: }
130: if (isset($sortmode)) {
131: $currentuser->setUserProperty("system", "sortmode-idlang-$lang-idcat-$idcat", $sortmode);
132: }
133:
134: if (isset($elemperpage) && is_numeric($elemperpage)) {
135: $currentuser->setUserProperty("system", "elemperpage-idlang-$lang-idcat-$idcat", $elemperpage);
136: } else {
137: $elemperpage = $currentuser->getUserProperty("system", "elemperpage-idlang-$lang-idcat-$idcat");
138: if (!is_numeric($elemperpage)) {
139: $elemperpage = 10;
140: }
141: }
142:
143: $col = new cApiInUseCollection();
144:
145: 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)) {
146:
147: $sortby = $currentuser->getUserProperty("system", "sortorder-idlang-$lang-idcat-$idcat");
148: $sortmode = $currentuser->getUserProperty("system", "sortmode-idlang-$lang-idcat-$idcat");
149:
150: $sql = "SELECT
151: a.idart AS idart,
152: a.idlang AS idlang,
153: a.idartlang AS idartlang,
154: a.title AS title,
155: c.idcat AS idcat,
156: {ISSTART}
157: c.idcatart AS idcatart,
158: a.idtplcfg AS idtplcfg,
159: a.published AS published,
160: a.online AS online,
161: a.created AS created,
162: a.lastmodified AS lastmodified,
163: a.timemgmt AS timemgmt,
164: a.datestart AS datestart,
165: a.dateend AS dateend,
166: a.artsort AS artsort,
167: a.redirect AS redirect,
168: a.locked AS locked
169: FROM
170: " . $cfg["tab"]["art_lang"] . " AS a,
171: " . $cfg["tab"]["art"] . " AS b,
172: " . $cfg["tab"]["cat_art"] . " AS c
173: WHERE
174: (a.idlang = " . $lang . " {SYNCOPTIONS}) AND
175: a.idart = b.idart AND
176: b.idclient = " . $client . " AND
177: b.idart = c.idart AND
178: c.idcat = " . $idcat;
179:
180:
181: $sql_count = "SELECT
182: COUNT(*) AS article_count
183: FROM
184: " . $cfg["tab"]["art_lang"] . " AS a,
185: " . $cfg["tab"]["art"] . " AS b,
186: " . $cfg["tab"]["cat_art"] . " AS c
187: WHERE
188: (a.idlang = " . cSecurity::toInteger($lang) . " {SYNCOPTIONS}) AND
189: a.idart = b.idart AND
190: b.idclient = " . cSecurity::toInteger($client) . " AND
191: b.idart = c.idart AND
192: c.idcat = " . cSecurity::toInteger($idcat);
193:
194: $sql = str_replace("{ISSTART}", '', $sql);
195:
196: if ($syncoptions == -1) {
197: $sql = str_replace("{SYNCOPTIONS}", '', $sql);
198: $sql_count = str_replace("{SYNCOPTIONS}", '', $sql_count);
199: } else {
200: $sql = str_replace("{SYNCOPTIONS}", "OR a.idlang = '" . $syncoptions . "'", $sql);
201: $sql_count = str_replace("{SYNCOPTIONS}", "OR a.idlang = '" . $syncoptions . "'", $sql_count);
202: }
203:
204:
205: if ($sortmode !== 'asc' && $sortmode !== 'desc') {
206: $sortmode = 'asc';
207: }
208: switch ($sortby) {
209: case 2:
210: $sql .= ' ORDER BY a.lastmodified ' . strtoupper($sortmode);
211: break;
212: case 3:
213: $sql .= ' ORDER BY a.published ' . strtoupper($sortmode) . ', a.lastmodified ' . strtoupper($sortmode);
214: break;
215: case 4:
216: $sql .= ' ORDER BY a.artsort ' . strtoupper($sortmode);
217: break;
218: default:
219:
220: $sql .= ' ORDER BY a.title ' . strtoupper($sortmode);
221: $sortby = 1;
222: }
223:
224:
225: if ($elemperpage > 0) {
226: $db->query($sql_count);
227: $db->nextRecord();
228: $iArticleCount = $db->f("article_count");
229:
230:
231: if ($iArticleCount == 0) {
232: $next = 0;
233: } elseif ($next >= $iArticleCount) {
234: $next = (ceil($iArticleCount / $elemperpage) - 1) * $elemperpage;
235: }
236: $sql .= " LIMIT $next, $elemperpage";
237: } else {
238: $iArticleCount = 0;
239: }
240:
241:
242: $db->query($sql);
243:
244:
245: $tpl->reset();
246:
247:
248: $no_article = true;
249:
250: $aArticles = Array();
251:
252: while ($db->nextRecord()) {
253: $sItem = "k" . $db->f("idart");
254:
255: if ($db->f("idlang") == $lang || !array_key_exists($sItem, $aArticles)) {
256: $aArticles[$sItem]["idart"] = $db->f("idart");
257: $aArticles[$sItem]["idlang"] = $db->f("idlang");
258: $aArticles[$sItem]["idartlang"] = $db->f("idartlang");
259: $aArticles[$sItem]["title"] = cSecurity::unFilter($db->f("title"));
260: $aArticles[$sItem]["is_start"] = isStartArticle($db->f("idartlang"), $idcat, $lang);
261: $aArticles[$sItem]["idcatart"] = $db->f("idcatart");
262: $aArticles[$sItem]["idtplcfg"] = $db->f("idtplcfg");
263: $aArticles[$sItem]["published"] = $db->f("published");
264: $aArticles[$sItem]["online"] = $db->f("online");
265: $aArticles[$sItem]["created"] = $db->f("created");
266: $aArticles[$sItem]["idcat"] = $db->f("idcat");
267: $aArticles[$sItem]["lastmodified"] = $db->f("lastmodified");
268: $aArticles[$sItem]["timemgmt"] = $db->f("timemgmt");
269: $aArticles[$sItem]["datestart"] = $db->f("datestart");
270: $aArticles[$sItem]["dateend"] = $db->f("dateend");
271: $aArticles[$sItem]["artsort"] = $db->f("artsort");
272: $aArticles[$sItem]["locked"] = $db->f("locked");
273: $aArticles[$sItem]["redirect"] = $db->f("redirect");
274: }
275: }
276:
277: $artlist = array();
278: $colitem = array();
279: $articlesOnline = 0;
280: $articlesOffline = 0;
281: $articlesLocked = 0;
282: $articlesUnlocked = 0;
283: $articlesToSync = 0;
284: $articlesToRemove = 0;
285:
286: foreach ($aArticles as $sart) {
287: $idart = $sart["idart"];
288: $idlang = $sart["idlang"];
289:
290: $idtplcfg = $sart["idtplcfg"];
291: $idartlang = $sart["idartlang"];
292: $lidcat = $sart["idcat"];
293: $idcatlang = 0;
294: $idart = $sart["idart"];
295: $published = $sart["published"];
296: $online = $sart["online"];
297:
298: $is_start = $sart["is_start"];
299:
300: $idcatart = $sart["idcatart"];
301: $created = $sart["created"];
302: $modified = $sart["lastmodified"];
303:
304: if ($modified === '0000-00-00 00:00:00') {
305: $modified = i18n("not modified yet");
306: } else {
307: $modified = date($dateformat, strtotime($modified));
308: }
309: $title = conHtmlSpecialChars($sart["title"]);
310: $timemgmt = $sart["timemgmt"];
311: $datestart = $sart["datestart"];
312: $dateend = $sart["dateend"];
313: $sortkey = $sart["artsort"];
314: $locked = $sart["locked"];
315: $redirect = $sart["redirect"];
316:
317: $published = ($published != '0000-00-00 00:00:00') ? date($dateformat, strtotime($published)) : i18n("not yet published");
318: $created = date($dateformat, strtotime($created));
319: $alttitle = "idart" . ': ' . $idart . ' ' . "idcatart" . ': ' . $idcatart . ' ' . "idartlang" . ': ' . $idartlang;
320:
321: if ($idlang != $lang) {
322: $articlesToSync++;
323: } else {
324: if ($online == 1) {
325: $articlesOnline++;
326: } else {
327: $articlesOffline++;
328: }
329: if ($locked == 1) {
330: $articlesLocked++;
331: } else {
332: $articlesUnlocked++;
333: }
334: $articlesToRemove++;
335: }
336:
337: if ((($obj = $col->checkMark("article", $idartlang)) === false) || $obj->get("userid") == $auth->auth['uid']) {
338: $inUse = false;
339: } else {
340: $vuser = new cApiUser($obj->get("userid"));
341: $inUseUser = $vuser->getField("username");
342: $inUseUserRealName = $vuser->getField("realname");
343:
344: $inUse = true;
345: $title = $title . " (" . i18n("Article is in use") . ")";
346: $alttitle = sprintf(i18n("Article in use by %s (%s)"), $inUseUser, $inUseUserRealName) . " " . $alttitle;
347: }
348:
349:
350: $tmp_rowid = $idart . "-" . $idartlang . "-" . $lidcat . "-" . $idcatlang . "-" . $idcatart . "-" . $idlang;
351: $tpl->set('d', 'ROWID', $tmp_rowid);
352:
353: if ($idlang != $lang) {
354: $colitem[$tmp_rowid] = 'con_sync';
355: }
356:
357:
358: if ($perm->have_perm_area_action('con_editcontent', 'con_editart') || $perm->have_perm_area_action_item('con_editcontent', 'con_editart', $idcat)) {
359: if ($idlang != $lang) {
360: $tmp_alink = $sess->url("main.php?area=con_editcontent&action=con_editart&changeview=prev&idartlang=$idartlang&idart=$idart&idcat=$idcat&frame=$frame&tmpchangelang=$idlang");
361: $titlelink = '<a href="' . $tmp_alink . '" title="' . $alttitle . '">' . $title . '</a>';
362: } else {
363: $tmp_alink = $sess->url("main.php?area=con_editcontent&action=con_editart&changeview=edit&idartlang=$idartlang&idart=$idart&idcat=$idcat&frame=$frame");
364: $titlelink = '<a href="' . $tmp_alink . '" title="' . $alttitle . '">' . $title . '</a>';
365: }
366: } else {
367: $tmp_alink = '';
368: $titlelink = $title;
369: }
370:
371: if ($timemgmt == "1") {
372: $sql = "SELECT NOW() AS TIME";
373:
374: $db3 = cRegistry::getDb();
375:
376: $db3->query($sql);
377: $db3->nextRecord();
378:
379: $starttimestamp = strtotime($datestart);
380: $endtimestamp = strtotime($dateend);
381: $nowtimestamp = strtotime($db3->f("TIME"));
382:
383: if (($nowtimestamp < $endtimestamp) && ($nowtimestamp > $starttimestamp)) {
384: $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") . '">';
385: } else {
386: $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") . '">';
387: }
388: } else {
389: $usetime = '';
390: }
391:
392:
393: if (($perm->have_perm_area_action('con', 'con_lock') || $perm->have_perm_area_action_item('con', 'con_lock', $idcat)) && $inUse == false) {
394: if ($locked == 1) {
395: $lockimg = 'images/article_locked.gif';
396: $lockalt = i18n("Unfreeze article");
397: } else {
398: $lockimg = 'images/article_unlocked.gif';
399: $lockalt = i18n("Freeze article");
400: }
401: $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>';
402: } else {
403: if ($locked == 1) {
404: $lockimg = 'images/article_locked.gif';
405: $lockalt = i18n("Article is frozen");
406: } else {
407: $lockimg = 'images/article_unlocked.gif';
408: $lockalt = i18n("Article is not frozen");
409: }
410: $tmp_lock = '<img class="vAlignMiddle tableElement" src="' . $lockimg . '" title="' . $lockalt . '" alt="' . $lockalt . '" border="0">';
411: }
412:
413: if ($idlang != $lang) {
414: $lockedlink = '';
415: } else {
416: $lockedlink = $tmp_lock;
417: }
418:
419: if ($sortkey == '') {
420: $sortkey = ' ';
421: }
422:
423: $tmp_articletitle = $titlelink;
424:
425:
426: if ($perm->have_perm_area_action('con_editart', 'con_edit') || $perm->have_perm_area_action_item('con_editart', 'con_edit', $idcat)) {
427: $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>';
428: } else {
429: $tmp_artconf = '';
430: }
431:
432: $tmp_sync = '';
433: if ($idlang != $lang) {
434: $sql = "SELECT idcatlang FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat='" . cSecurity::toInteger($idcat) . "' AND idlang='" . cSecurity::toInteger($lang) . "'";
435: $db->query($sql);
436:
437: if ($db->nextRecord()) {
438: $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>';
439: } else {
440: $tmp_sync = '';
441: $articlesToSync--;
442: $articlesToRemove--;
443: }
444: }
445:
446:
447: if (!is_object($db2)) {
448: $db2 = cRegistry::getDb();
449: }
450:
451: $sql2 = "SELECT
452: b.name AS tplname,
453: b.idtpl AS idtpl,
454: b.description AS description
455: FROM
456: " . $cfg["tab"]["tpl_conf"] . " AS a,
457: " . $cfg["tab"]["tpl"] . " AS b
458: WHERE
459: a.idtplcfg = " . cSecurity::toInteger($idtplcfg) . " AND
460: a.idtpl = b.idtpl";
461:
462: $db2->query($sql2);
463: $db2->nextRecord();
464:
465: $a_tplname = $db2->f("tplname");
466: $a_idtpl = $db2->f("idtpl");
467: $templateDescription = $db2->f("description");
468:
469:
470: if (0 == $idtplcfg) {
471: $sql2 = "SELECT
472: c.idtpl AS idtpl,
473: c.name AS name,
474: c.description,
475: b.idtplcfg AS idtplcfg
476: FROM
477: " . $cfg['tab']['tpl_conf'] . " AS a,
478: " . $cfg['tab']['cat_lang'] . " AS b,
479: " . $cfg['tab']['tpl'] . " AS c
480: WHERE
481: b.idcat = " . cSecurity::toInteger($idcat) . " AND
482: b.idlang = " . cSecurity::toInteger($lang) . " AND
483: b.idtplcfg = a.idtplcfg AND
484: c.idtpl = a.idtpl AND
485: c.idclient = " . cSecurity::toInteger($client);
486: $db2->query($sql2);
487: $db2->nextRecord();
488: $a_tplname = $db2->f("name") ? '<i>' . $db2->f("name") . '</i>' : "--- " . i18n("None") . " ---";
489: }
490:
491:
492: $aAuthPerms = explode(',', $auth->auth['perm']);
493:
494: $admin = false;
495: if (count(preg_grep("/admin.*/", $aAuthPerms)) > 0) {
496: $admin = true;
497: }
498:
499:
500: $imgsrc = "isstart";
501:
502: if ($is_start == false) {
503: $imgsrc .= '0';
504: } else {
505: $imgsrc .= '1';
506: }
507: if (isArtInMultipleUse($idart)) {
508: $imgsrc .= 'm';
509: }
510: if ((int) $redirect == 1) {
511: $imgsrc .= 'r';
512: }
513:
514: $imgsrc .= '.gif';
515:
516: 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)) {
517: if ($is_start == false) {
518: $tmp_link = '<a href="' . $sess->url("main.php?area=con&idcat=$idcat&action=con_makestart&idcatart=$idcatart&frame=4&is_start=1&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>';
519: } else {
520: $tmp_link = '<a href="' . $sess->url("main.php?area=con&idcat=$idcat&action=con_makestart&idcatart=$idcatart&frame=4&is_start=0&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>';
521: }
522: } else {
523: if ($is_start == true) {
524: $sTitle = i18n("Start article");
525: } else {
526: $sTitle = i18n("Normal article");
527: }
528:
529: $tmp_img = '<img class="vAlignMiddle tableElement" src="images/' . $imgsrc . '" border="0" title="' . $sTitle . '" alt="' . $sTitle . '">';
530:
531: $tmp_link = $tmp_img;
532: }
533:
534: $tmp_start = $tmp_link;
535:
536:
537: 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 )) {
538: $imgsrc = "but_copy.gif";
539:
540:
541: $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>';
542: } else {
543: $tmp_link = '';
544: }
545:
546: if ($idlang != $lang) {
547: $duplicatelink = '';
548: } else {
549: $duplicatelink = $tmp_link;
550: }
551:
552:
553: $todolink = '';
554:
555: $subject = urlencode(sprintf(i18n("Reminder for article '%s'"), $title));
556: $mycatname = '';
557: conCreateLocationString($idcat, " / ", $mycatname);
558: $message = urlencode(sprintf(i18n("Reminder for article '%s'\nCategory: %s"), $title, $mycatname));
559:
560: $todolink = new TODOLink("idart", $idart, $subject, $message);
561:
562:
563: if ($online) {
564: 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)) {
565: $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>';
566: } else {
567: $tmp_online = '<img class="vAlignMiddle tableElement" src="images/online.gif" title="' . i18n("Article is online") . '" alt="' . i18n("Article is online") . '" border="0">';
568: }
569: } else {
570: 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)) {
571: $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>';
572: } else {
573: $tmp_online = '<img class="vAlignMiddle tableElement" src="images/offline.gif" title="' . i18n("Article is offline") . '" alt="' . i18n("Article is offline") . '" border="0">';
574: }
575: }
576:
577: if ($idlang != $lang) {
578: $onlinelink = '';
579: } else {
580: $onlinelink = $tmp_online;
581: }
582:
583:
584: 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)) {
585: $tmp_title = $title;
586: if (strlen($tmp_title) > 30) {
587: $tmp_title = substr($tmp_title, 0, 27) . "...";
588: }
589:
590: $confirmString = sprintf(i18n("Are you sure to delete the following article:<br><br><b>%s</b>"), conHtmlSpecialChars($tmp_title));
591: $tmp_del = '<a href="javascript:void(0)" onclick="Con.showConfirmation("' . $confirmString . '", 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>';
592: } else {
593: $tmp_del = '';
594: }
595:
596: if ($idlang != $lang) {
597: $deletelink = '';
598: } else {
599: $deletelink = $tmp_del;
600: }
601:
602:
603: cInclude('includes', 'functions.lang.php');
604: $tpl->set('d', 'DIRECTION', 'dir="' . langGetTextDirection($lang) . '"');
605:
606:
607:
608: $no_article = false;
609: $oArtLang = new cApiArticleLanguage();
610: foreach ($listColumns as $listColumn => $ctitle) {
611: $oArtLang->loadBy($oArtLang->getPrimaryKeyName(), $idartlang);
612:
613: switch ($listColumn) {
614: case "mark":
615: $value = '<input type="checkbox" name="mark" value="' . $idart . '" class="mark_articles">';
616: break;
617: case "start":
618: $value = $tmp_start . $usetime;
619: break;
620: case "title":
621: $value = $tmp_articletitle;
622: break;
623: case "changeddate":
624: $value = $modified;
625: break;
626: case "publisheddate":
627: if ('1' === $oArtLang->get('online')) {
628: $value = $published;
629: } else {
630: $value = i18n("not yet published");
631: }
632: break;
633: case "sortorder":
634: $value = $sortkey;
635: break;
636: case "template":
637: $value = $a_tplname;
638: break;
639: case "actions":
640: $actions = array();
641: foreach ($actionList as $actionItem) {
642: switch ($actionItem) {
643: case "todo":
644: $actionValue = $todolink;
645: break;
646: case "artconf":
647: $actionValue = $tmp_artconf;
648: break;
649: case "online":
650: $actionValue = $onlinelink;
651: break;
652: case "locked":
653: $actionValue = $lockedlink;
654: break;
655: case "duplicate":
656: $actionValue = $duplicatelink;
657: break;
658: case "delete":
659: $actionValue = $deletelink;
660: break;
661: case "usetime":
662: $actionValue = '';
663: break;
664: default:
665:
666: $_cecIterator = $_cecRegistry->getIterator("Contenido.ArticleList.RenderAction");
667: $contents = array();
668: if ($_cecIterator->count() > 0) {
669: while ($chainEntry = $_cecIterator->next()) {
670: $contents[] = $chainEntry->execute($idcat, $idart, $idartlang, $actionItem);
671: }
672: }
673: $actionValue = implode('', $contents);
674: break;
675: }
676:
677: $actions[] = $actionValue;
678: }
679:
680: if ($tmp_sync != '') {
681: $actions[] = $tmp_sync;
682: }
683:
684:
685: if ($tmp_sync != '') {
686: $actions[] = '<a id="properties" href="main.php?area=con_editart&action=con_edit&frame=4&idcat=' . $idcat . '&idart=' . $idart . '&contenido=' . $contenido . '">
687: <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;">
688: </a>';
689: }
690:
691: $value = implode("\n", $actions);
692: break;
693: default:
694: $contents = array();
695:
696: $_cecIterator = $_cecRegistry->getIterator("Contenido.ArticleList.RenderColumn");
697: if ($_cecIterator->count() > 0) {
698: $contents = array();
699: while ($chainEntry = $_cecIterator->next()) {
700: $contents[] = $chainEntry->execute($idcat, $idart, $idartlang, $listColumn);
701: }
702: }
703: $value = implode('', $contents);
704: }
705: $artlist[$tmp_rowid][$listColumn] = $value;
706: $artlist[$tmp_rowid]['templateDescription'] = $templateDescription;
707: }
708: unset($oArtLang);
709: }
710:
711: $headers = array();
712:
713:
714: $sortColumns = array(
715: 'title' => 1,
716: 'changeddate' => 2,
717: 'publisheddate' => 3,
718: 'sortorder' => 4
719: );
720: foreach ($listColumns as $key => $listColumn) {
721:
722: $width = ($key == 'title' || $listColumn == i18n('Title')) ? '100%' : '1%';
723:
724: if (in_array($key, array_keys($sortColumns))) {
725: $newSortmode = 'asc';
726:
727:
728: if ($sortby == $sortColumns[$key] && $sortmode == 'asc') {
729: $newSortmode = 'desc';
730: }
731:
732: if ($sortby == $sortColumns[$key]) {
733: $imageSrc = ($sortmode == 'asc') ? 'images/sort_up.gif' : 'images/sort_down.gif';
734: $sortImage = '<img src="' . $imageSrc . '">';
735: } else {
736: $sortImage = '';
737: }
738: $sortLink = $sess->url("main.php?area=con&frame=4&idcat=$idcat&sortby=$sortColumns[$key]&sortmode=$newSortmode");
739: $col = '<a href="' . $sortLink . '" class="gray">' . $listColumn . $sortImage . '</a>';
740: } else {
741: $col = $listColumn;
742: }
743: $headers[] = '<th width="' . $width . '" nowrap="nowrap">' . $col . '</th>';
744: }
745:
746: $tpl->set('s', 'HEADERS', implode("\n", $headers));
747:
748: if ($elemperpage > 0 && $iArticleCount > 0 && $iArticleCount > $elemperpage) {
749: for ($i = 1; $i <= ceil($iArticleCount / $elemperpage); $i++) {
750: $iNext = ($i - 1) * $elemperpage;
751: if ($sBrowseLinks !== '') {
752: $sBrowseLinks .= ' ';
753: }
754: if ($next == $iNext) {
755: $sBrowseLinks .= $i . "\n";
756:
757: } else {
758: $tmp_alink = $sess->url("main.php?area=con&frame=$frame&idcat=$idcat&next=$iNext");
759: $sBrowseLinks .= '<a href="' . $tmp_alink . '">' . $i . '</a>' . "\n";
760: }
761: }
762: $tpl->set('s', 'NEXT', $next);
763: $tpl->set('s', 'BROWSE', sprintf(i18n("Go to page: %s"), $sBrowseLinks));
764: } else {
765: $tpl->set('s', 'NEXT', "0");
766: $tpl->set('s', 'BROWSE', ' ');
767: }
768: $tpl->set('s', 'CLICK_ROW_NOTIFICATION', i18n("Click on a row to select an article for editing"));
769:
770:
771: $bulkEditingFunctions = '';
772: if ($articlesOffline > 0 && ($perm->have_perm_area_action("con", "con_makeonline") || $perm->have_perm_area_action_item("con", "con_makeonline", $idcat))) {
773: $bulkEditingFunctions .= createBulkEditingFunction('con_makeonline', 'images/online.gif', i18n('Set articles online'));
774: }
775: if ($articlesOnline > 0 && ($perm->have_perm_area_action("con", "con_makeonline") || $perm->have_perm_area_action_item("con", "con_makeonline", $idcat))) {
776: $bulkEditingFunctions .= createBulkEditingFunction('con_makeonline invert', 'images/offline.gif', i18n('Set articles offline'));
777: }
778: if ($articlesUnlocked > 0 && ($perm->have_perm_area_action("con", "con_lock") || $perm->have_perm_area_action_item("con", "con_lock", $idcat))) {
779: $bulkEditingFunctions .= createBulkEditingFunction('con_lock', 'images/article_unlocked.gif', i18n('Freeze articles'));
780: }
781: if ($articlesLocked > 0 && ($perm->have_perm_area_action("con", "con_lock") || $perm->have_perm_area_action_item("con", "con_lock", $idcat))) {
782: $bulkEditingFunctions .= createBulkEditingFunction('con_lock invert', 'images/article_locked.gif', i18n('Unfreeze articles'));
783: }
784: if ($articlesToSync > 0 && ($perm->have_perm_area_action("con", "con_syncarticle") || $perm->have_perm_area_action_item("con", "con_syncarticle", $idcat))) {
785: $bulkEditingFunctions .= createBulkEditingFunction('con_syncarticle', 'images/but_sync_art.gif', i18n('Copy article to the current language'));
786: }
787: if ($articlesToRemove > 0 && ($perm->have_perm_area_action("con", "con_deleteart") || $perm->have_perm_area_action_item("con", "con_deleteart", $idcat))) {
788: $bulkEditingFunctions .= createBulkEditingFunction('con_deleteart', 'images/delete.gif', i18n('Delete articles'), 'Con.showConfirmation("' . i18n('Are you sure to delete the selected articles') . '", deleteArticles)');
789: }
790:
791: if ($bulkEditingFunctions == "") {
792: $bulkEditingFunctions = i18n("Your permissions do not allow any actions here");
793: }
794: $tpl->set('s', 'BULK_EDITING_FUNCTIONS', $bulkEditingFunctions);
795:
796: if (count($artlist) > 0) {
797: foreach ($artlist as $key2 => $artitem) {
798:
799: $cells = array();
800:
801: foreach ($listColumns as $key => $listColumn) {
802:
803: if ($key == 'template') {
804: $templateDescription = $artitem['templateDescription'];
805: $descString = '<b>' . $artitem[$key] . '</b>';
806:
807: $sTemplatename = cString::trimHard($artitem[$key], 20);
808: if (strlen($artitem[$key]) > 20) {
809: $cells[] = '<td nowrap="nowrap" class="bordercell tooltip" title="' . $descString . '">' . $sTemplatename . '</td>';
810: } else {
811: $cells[] = '<td nowrap="nowrap" class="bordercell">' . $artitem[$key] . '</td>';
812: }
813: } else {
814: $cells[] = '<td nowrap="nowrap" class="bordercell">' . $artitem[$key] . '</td>';
815: }
816: }
817: $tpl->set('d', 'CELLS', implode("\n", $cells));
818:
819: if ($colitem[$key2] == 'con_sync') {
820: $tpl->set('d', 'CSS_CLASS', 'class="con_sync"');
821: } else {
822: $tpl->set('d', 'CSS_CLASS', '');
823: }
824:
825: $tpl->set('d', 'ROWID', $key2);
826: $tpl->next();
827: }
828: } else {
829: $emptyCell = '<td nowrap="nowrap" class="bordercell" colspan="' . count($listColumns) . '">' . i18n("No articles found") . '</td>';
830: $tpl->set('d', 'CELLS', $emptyCell);
831: $tpl->set('d', 'CSS_CLASS', '');
832: $tpl->set('d', 'ROWID', '');
833: }
834:
835:
836: $aElemPerPage = array(
837: 0 => i18n("All"),
838: 10 => "10",
839: 25 => "25",
840: 50 => "50",
841: 75 => "75",
842: 100 => "100"
843: );
844:
845: $tpl2 = new cTemplate();
846: $tpl2->set('s', 'NAME', 'sort');
847: $tpl2->set('s', 'CLASS', 'text_medium');
848: $tpl2->set('s', 'OPTIONS', 'onchange="changeElemPerPage(this)"');
849:
850: foreach ($aElemPerPage as $key => $value) {
851: $selected = ($elemperpage == $key) ? 'selected="selected"' : '';
852: $tpl2->set('d', 'VALUE', $key);
853: $tpl2->set('d', 'CAPTION', $value);
854: $tpl2->set('d', 'SELECTED', $selected);
855: $tpl2->next();
856: }
857:
858: $select = (!$no_article) ? $tpl2->generate($cfg["path"]["templates"] . $cfg['templates']['generic_select'], true) : ' ';
859: $caption = (!$no_article) ? i18n("Items per page:") : ' ';
860:
861: $tpl->set('s', 'ELEMPERPAGECAPTION', $caption);
862: $tpl->set('s', 'ELEMPERPAGE', $select);
863:
864: $tpl->set('s', 'IDCAT', $idcat);
865: $tpl->set('s', 'SOURCELANGUAGE', $idlang);
866:
867:
868: $sql = "SELECT
869: b.name AS name,
870: d.idtpl AS idtpl
871: FROM
872: (" . $cfg["tab"]["cat"] . " AS a,
873: " . $cfg["tab"]["cat_lang"] . " AS b,
874: " . $cfg["tab"]["tpl_conf"] . " AS c)
875: LEFT JOIN
876: " . $cfg["tab"]["tpl"] . " AS d
877: ON
878: d.idtpl = c.idtpl
879: WHERE
880: a.idclient = " . cSecurity::toInteger($client) . " AND
881: a.idcat = " . cSecurity::toInteger($idcat) . " AND
882: b.idlang = " . cSecurity::toInteger($lang) . " AND
883: b.idcat = a.idcat AND
884: c.idtplcfg = b.idtplcfg";
885:
886: $db->query($sql);
887:
888: if ($db->nextRecord()) {
889:
890:
891: }
892:
893: $cat_idtpl = $db->f("idtpl");
894:
895: $cat_name = renderBackendBreadcrumb($syncoptions, false, true);
896:
897:
898: if ($no_article) {
899: $tpl->set('d', "START", ' ');
900: $tpl->set('d', "ARTICLE", i18n("No articles found"));
901: $tpl->set('d', "PUBLISHED", ' ');
902: $tpl->set('d', "LASTMODIFIED", ' ');
903: $tpl->set('d', "ARTCONF", ' ');
904: $tpl->set('d', "TPLNAME", ' ');
905: $tpl->set('d', "LOCKED", ' ');
906: $tpl->set('d', "DUPLICATE", ' ');
907: $tpl->set('d', "TPLCONF", ' ');
908: $tpl->set('d', "ONLINE", ' ');
909: $tpl->set('d', "DELETE", ' ');
910: $tpl->set('d', "USETIME", ' ');
911: $tpl->set('d', "TODO", ' ');
912: $tpl->set('d', "SORTKEY", ' ');
913:
914: $tpl->next();
915: }
916:
917:
918: 919: 920: 921: 922: 923:
924:
925: if (($perm->have_perm_area_action_item('con', 'con_tplcfg_edit', $idcat) || $perm->have_perm_area_action('con', 'con_tplcfg_edit')) && $foreignlang == false) {
926: if (0 != $idcat) {
927: $tpl->set('s', 'CATEGORY', $cat_name);
928: $tpl->set('s', 'CATEGORY_CONF', $tmp_img);
929: $tpl->set('s', 'CATEGORY_LINK', $tmp_link);
930: } else {
931: $tpl->set('s', 'CATEGORY', $cat_name);
932: $tpl->set('s', 'CATEGORY_CONF', ' ');
933: $tpl->set('s', 'CATEGORY_LINK', ' ');
934: }
935: } else {
936: $tpl->set('s', 'CATEGORY', $cat_name);
937: $tpl->set('s', 'CATEGORY_CONF', ' ');
938: $tpl->set('s', 'CATEGORY_LINK', ' ');
939: }
940:
941:
942: $tpl->set('s', 'SELF_URL', $sess->url("main.php?area=con&frame=4&idcat=$idcat"));
943:
944:
945: $warningBox = '';
946: if (strHasStartArticle($idcat, $lang) === false) {
947: $warningBox = $notification->returnNotification('warning', i18n('This category does not have a configured start article.'));
948: }
949:
950:
951: if (($perm->have_perm_area_action('con_editart', 'con_newart') || $perm->have_perm_area_action_item('con_editart', 'con_newart', $idcat)) && $foreignlang == false) {
952:
953: if ($idcat != 0 && $cat_idtpl != 0) {
954: $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>');
955: $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>');
956: $tpl->set('s', 'CATTEMPLATE', $warningBox);
957: } else {
958:
959:
960: $oArtLang = new cApiArticleLanguage($idcat);
961: if (0 < $syncoptions && false === $oArtLang->isLoaded()) {
962: $notification_text = $notification->returnNotification("error", i18n("Creation of articles is only possible if the category has is synchronized."));
963: } else {
964: $notification_text = $notification->returnNotification("error", i18n("Creation of articles is only possible if the category has a assigned template."));
965: }
966: $tpl->set('s', 'CATTEMPLATE', $notification_text);
967: $tpl->set('s', 'NEWARTICLE_TEXT', ' ');
968: $tpl->set('s', 'NEWARTICLE_IMG', ' ');
969: }
970: } else {
971: $tpl->set('s', 'NEWARTICLE_TEXT', ' ');
972: $tpl->set('s', 'NEWARTICLE_IMG', ' ');
973: $tpl->set('s', 'CATTEMPLATE', $warningBox);
974: }
975:
976: $str = '';
977:
978: $tpl->set('s', 'NOTIFICATION', $str);
979:
980:
981: if ($no_article) {
982: $tpl->set('s', 'NOARTICLE_CSS', "display: none;");
983: $tpl->set('s', 'NOARTICLE_JS', 'true');
984: } else {
985: $tpl->set('s', 'NOARTICLE_CSS', "");
986: $tpl->set('s', 'NOARTICLE_JS', 'false');
987: }
988:
989:
990: $tpl->set('s', 'IDTPL', $idtpl ? $idtpl : $cat_idtpl);
991: $tpl->set('s', 'SYNCOPTIONS', $syncoptions);
992: $tpl->set('s', 'DISPLAY_MENU', 1);
993:
994:
995: $tpl->generate($cfg['path']['templates'] . $cfg['templates']['con_art_overview']);
996: } else {
997: $notification->displayNotification("error", i18n("Permission denied"));
998: }
999: } else {
1000: $tpl->reset();
1001: $tpl->set('s', 'CONTENTS', '');
1002: $tpl->generate($cfg['path']['templates'] . $cfg['templates']['blank']);
1003: }
1004:
1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018:
1019: function createBulkEditingFunction($class, $imageSrc, $alt, $onclick = '') {
1020: $function = new cHTMLLink();
1021: $function->setClass($class);
1022: if ($onclick !== '') {
1023: $function->setEvent('click', $onclick);
1024: }
1025: $image = new cHTMLImage($imageSrc);
1026: $image->setAlt($alt);
1027: $function->setContent($image);
1028:
1029: return $function->render();
1030: }
1031: