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