1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: cInclude("includes", "functions.str.php");
19: cInclude("includes", "functions.tpl.php");
20: cInclude('includes', 'functions.lang.php');
21:
22: $tpl->reset();
23: global $sess, $frame, $area;
24: $idcat = (isset($_GET['idcat']) && is_numeric($_GET['idcat'])) ? $_GET['idcat'] : -1;
25:
26:
27: if (isset($syncoptions)) {
28: $syncfrom = (int) $syncoptions;
29: $remakeCatTable = true;
30: }
31:
32: if (!isset($syncfrom)) {
33: $syncfrom = -1;
34: }
35:
36: $syncoptions = $syncfrom;
37:
38: $tpl->set('s', 'SYNC_LANG', $syncfrom);
39:
40:
41:
42: $bShowArticleSearch = false;
43: if (isset($_GET['delsavedsearch'])) {
44: if (isset($_GET['itemtype']) && sizeof($_GET['itemtype']) > 0 && isset($_GET['itemid']) && sizeof($_GET['itemid']) > 0) {
45: $propertyCollection = new cApiPropertyCollection();
46: $propertyCollection->deleteProperties($_GET['itemtype'], $_GET['itemid']);
47: $bShowArticleSearch = true;
48: }
49: }
50:
51: if (isset($_GET['save_search']) && $_GET['save_search'] == 'true') {
52: $bShowArticleSearch = true;
53: }
54:
55:
56: $arrDays = array();
57:
58: for ($i = 0; $i < 32; $i++) {
59: if ($i == 0) {
60: $arrDays[$i] = '--';
61: } else {
62: $arrDays[$i] = $i;
63: }
64: }
65:
66: $arrMonths = array();
67:
68: for ($i = 0; $i < 13; $i++) {
69: if ($i == 0) {
70: $arrMonths[$i] = '--';
71: } else {
72: $arrMonths[$i] = $i;
73: }
74: }
75:
76: $arrYears = array();
77:
78: $arrYears[0] = '-----';
79: $sActualYear = (int) date("Y");
80:
81: for ($i = $sActualYear - 10; $i < $sActualYear + 30; $i++) {
82: $arrYears[$i] = $i;
83: }
84:
85: $arrUsers = array();
86:
87: $query = "SELECT * FROM " . $cfg['tab']['user'] . " ORDER BY realname";
88:
89: $arrUsers['n/a'] = '-';
90:
91: $db->query($query);
92:
93: while ($db->nextRecord()) {
94: $arrUsers[$db->f('username')] = $db->f('realname');
95: }
96:
97: $arrDateTypes = array();
98:
99: $arrDateTypes['n/a'] = i18n('Ignore');
100: $arrDateTypes['created'] = i18n('Date created');
101: $arrDateTypes['lastmodified'] = i18n('Date modified');
102: $arrDateTypes['published'] = i18n('Date published');
103:
104: $articleLink = "editarticle";
105: $oListOptionRow = new cGuiFoldingRow("3498dbba-ed4a-4618-8e49-3a3635396e22", i18n("Article search"), $articleLink, $bShowArticleSearch);
106: $tpl->set('s', 'ARTICLELINK', $articleLink);
107:
108:
109: $oTextboxArtTitle = new cHTMLTextbox("bs_search_text", $_REQUEST["bs_search_text"], 10);
110: $oTextboxArtTitle->setStyle('width:135px;');
111:
112:
113: $oTextboxArtID = new cHTMLTextbox("bs_search_id", $_REQUEST["bs_search_id"], 10);
114: $oTextboxArtID->setStyle('width:135px;');
115:
116:
117: $oSelectArtDateType = new cHTMLSelectElement("bs_search_date_type", "bs_search_date_type");
118: $oSelectArtDateType->autoFill($arrDateTypes);
119: $oSelectArtDateType->setStyle('width:135px;');
120: $oSelectArtDateType->setEvent("Change", "toggle_tr_visibility('tr_date_from');toggle_tr_visibility('tr_date_to');");
121:
122: if ($_REQUEST["bs_search_date_type"] != '') {
123: $oSelectArtDateType->setDefault($_REQUEST["bs_search_date_type"]);
124: } else {
125: $oSelectArtDateType->setDefault('n/a');
126: }
127:
128:
129: $oSelectArtDateFromDay = new cHTMLSelectElement("bs_search_date_from_day");
130: $oSelectArtDateFromDay->setStyle('width:40px;');
131: $oSelectArtDateFromDay->autoFill($arrDays);
132:
133: $oSelectArtDateFromMonth = new cHTMLSelectElement("bs_search_date_from_month");
134: $oSelectArtDateFromMonth->setStyle('width:40px;');
135: $oSelectArtDateFromMonth->autoFill($arrMonths);
136:
137: $oSelectArtDateFromYear = new cHTMLSelectElement("bs_search_date_from_year");
138: $oSelectArtDateFromYear->setStyle('width:55px;');
139: $oSelectArtDateFromYear->autoFill($arrYears);
140:
141: if ($_REQUEST["bs_search_date_from_day"] > 0) {
142: $oSelectArtDateFromDay->setDefault($_REQUEST["bs_search_date_from_day"]);
143: } else {
144: $oSelectArtDateFromDay->setDefault(0);
145: }
146:
147: if ($_REQUEST["bs_search_date_from_month"] > 0) {
148: $oSelectArtDateFromMonth->setDefault($_REQUEST["bs_search_date_from_month"]);
149: } else {
150: $oSelectArtDateFromMonth->setDefault(0);
151: }
152:
153: if ($_REQUEST["bs_search_date_from_year"] > 0) {
154: $oSelectArtDateFromYear->setDefault($_REQUEST["bs_search_date_from_year"]);
155: } else {
156: $oSelectArtDateFromYear->setDefault(0);
157: }
158:
159:
160: $oSelectArtDateToDay = new cHTMLSelectElement("bs_search_date_to_day");
161: $oSelectArtDateToDay->setStyle('width:40px;');
162: $oSelectArtDateToDay->autoFill($arrDays);
163:
164: $oSelectArtDateToMonth = new cHTMLSelectElement("bs_search_date_to_month");
165: $oSelectArtDateToMonth->setStyle('width:40px;');
166: $oSelectArtDateToMonth->autoFill($arrMonths);
167:
168: $oSelectArtDateToYear = new cHTMLSelectElement("bs_search_date_to_year");
169: $oSelectArtDateToYear->setStyle('width:55px;');
170: $oSelectArtDateToYear->autoFill($arrYears);
171:
172: if ($_REQUEST["bs_search_date_to_day"] > 0) {
173: $oSelectArtDateToDay->setDefault($_REQUEST["bs_search_date_to_day"]);
174: } else {
175: $oSelectArtDateToDay->setDefault(0);
176: }
177:
178: if ($_REQUEST["bs_search_date_to_month"] > 0) {
179: $oSelectArtDateToMonth->setDefault($_REQUEST["bs_search_date_to_month"]);
180: } else {
181: $oSelectArtDateToMonth->setDefault(0);
182: }
183:
184: if ($_REQUEST["bs_search_date_to_year"] > 0) {
185: $oSelectArtDateToYear->setDefault($_REQUEST["bs_search_date_to_year"]);
186: } else {
187: $oSelectArtDateToYear->setDefault(0);
188: }
189:
190:
191: $oSelectArtAuthor = new cHTMLSelectElement("bs_search_author");
192: $oSelectArtAuthor->setStyle('width:135px;');
193: $oSelectArtAuthor->autoFill($arrUsers);
194:
195: if ($_REQUEST["bs_search_author"] != '') {
196: $oSelectArtAuthor->setDefault($_REQUEST["bs_search_author"]);
197: } else {
198: $oSelectArtAuthor->setDefault('n/a');
199: }
200:
201: $oSubmit = new cHTMLButton("submit", i18n("Search"));
202:
203: $tplSearch = new cTemplate();
204: $tplSearch->set("s", "AREA", $area);
205: $tplSearch->set("s", "FRAME", $frame);
206: $tplSearch->set("s", "LANG", $lang);
207: $tplSearch->set("s", "LANGTEXTDIRECTION", langGetTextDirection($lang));
208:
209: $tplSearch->set("s", "TEXTBOX_ARTTITLE", $oTextboxArtTitle->render());
210:
211: $tplSearch->set("s", "TEXTBOX_ARTID", $oTextboxArtID->render());
212:
213: $tplSearch->set("s", "SELECT_ARTDATE", $oSelectArtDateType->render());
214:
215: $tplSearch->set("s", "SELECT_ARTDATEFROM", $oSelectArtDateFromDay->render() . $oSelectArtDateFromMonth->render() . $oSelectArtDateFromYear->render());
216:
217: $tplSearch->set("s", "SELECT_ARTDATETO", $oSelectArtDateToDay->render() . $oSelectArtDateToMonth->render() . $oSelectArtDateToYear->render());
218:
219: $tplSearch->set("s", "SELECT_AUTHOR", $oSelectArtAuthor->render());
220:
221: $tplSearch->set("s", "SUBMIT_BUTTON", $oSubmit->render());
222:
223:
224:
225: $proppy = new cApiPropertyCollection();
226: $savedSearchList = $proppy->getAllValues('type', 'savedsearch', $auth);
227:
228: foreach ($savedSearchList as $value) {
229: if ($value["name"] == "save_name") {
230: $tplSearch->set("d", "SEARCH_NAME", ($value['value'] == "") ? i18n("A saved search") : $value['value']);
231:
232: $tplSearch->set("d", "ITEM_ID", $value['itemid']);
233: $tplSearch->set("d", "ITEM_TYPE", $value['itemtype']);
234: $tplSearch->next();
235: }
236: }
237:
238: $oListOptionRow->setContentData($tplSearch->generate($cfg['path']['templates'] . $cfg["templates"]["con_left_top_art_search"], true));
239:
240: $sSelfLink = 'main.php?area=' . $area . '&frame=2&' . $sess->name . "=" . $sess->id;
241: $tpl->set('s', 'SELFLINK', $sSelfLink);
242:
243: $tpl->set('s', 'SEARCH', $oListOptionRow->render());
244:
245:
246: $sql = "SELECT idtpl, name FROM " . $cfg['tab']['tpl'] . " WHERE idclient = '" . cSecurity::toInteger($client) . "' ORDER BY name";
247: $db->query($sql);
248:
249: $tpl->set('s', 'ID', 'oTplSel');
250: $tpl->set('s', 'CLASS', 'text_medium');
251: $tpl->set('s', 'OPTIONS', '');
252: $tpl->set('s', 'SESSID', $sess->id);
253: $tpl->set('s', 'BELANG', $belang);
254:
255: $tpl->set('d', 'VALUE', '0');
256: $tpl->set('d', 'CAPTION', i18n("Choose template"));
257: $tpl->set('d', 'SELECTED', '');
258: $tpl->next();
259:
260: $tpl->set('d', 'VALUE', '0');
261: $tpl->set('d', 'CAPTION', '--- ' . i18n("none") . ' ---');
262: $tpl->set('d', 'SELECTED', '');
263: $tpl->next();
264:
265: $categoryLink = "editcat";
266: $editCategory = new cGuiFoldingRow("3498dbbb-ed4a-4618-8e49-3a3635396e22", i18n("Edit category"), $categoryLink);
267:
268: while ($db->nextRecord()) {
269: $tplname = $db->f('name');
270:
271: if (strlen($tplname) > 18) {
272: $tplname = substr($tplname, 0, 15) . "...";
273: }
274: $tpl->set('d', 'VALUE', $db->f('idtpl'));
275: $tpl->set('d', 'CAPTION', $tplname);
276: $tpl->set('d', 'SELECTED', '');
277: $tpl->next();
278: }
279:
280: $tplCatConfig = new cTemplate();
281: $tplCatConfig->set("s", "TEMPLATE_SELECT", $tpl->generate($cfg['path']['templates'] . $cfg['templates']['generic_select'], true));
282:
283: $editCategory->setContentData($tplCatConfig->generate($cfg["path"]["templates"] . $cfg['templates']['con_left_top_cat_edit'], true));
284:
285: $tpl->set('s', 'CAT_HREF', $sess->url("main.php?area=con_tplcfg&action=tplcfg_edit&frame=4&mode=art") . '&idcat=');
286: $tpl->set('s', 'IDCAT', $idcat);
287:
288: $tpl->set('s', 'EDIT', $editCategory->render());
289: $tpl->set('s', 'CATEGORYLINK', $categoryLink);
290:
291:
292: $languages = getLanguageNamesByClient($client);
293: if (count($languages) > 1 && $perm->have_perm_area_action($area, "con_synccat")) {
294: $sListId = 'sync';
295: $oListOptionRow = new cGuiFoldingRow("4808dbba-ed4a-4618-8e49-3a3635396e22", i18n("Synchronize from"), $sListId);
296:
297: if (($syncoptions > 0) && ($syncoptions != $lang)) {
298: $oListOptionRow->setExpanded(true);
299: }
300:
301: $selectbox = new cHTMLSelectElement("syncoptions");
302:
303: $option = new cHTMLOptionElement("--- " . i18n("None") . " ---", -1);
304: $selectbox->addOptionElement(-1, $option);
305: foreach ($languages as $languageid => $languagename) {
306: if ($lang != $languageid && $perm->have_perm_client_lang($client, $languageid)) {
307: $option = new cHTMLOptionElement($languagename . " (" . $languageid . ")", $languageid);
308: $selectbox->addOptionElement($languageid, $option);
309: }
310: }
311: $selectbox->setDefault($syncoptions);
312:
313: $tplSync = new cTemplate();
314: $tplSync->set("s", "TEXT_DIRECTION", langGetTextDirection($lang));
315: $tplSync->set("s", "AREA", $area);
316: $tplSync->set("s", "FRAME", $frame);
317: $tplSync->set("s", "SELECTBOX", $selectbox->render());
318:
319: $oListOptionRow->setContentData($tplSync->generate($cfg["path"]["templates"] . $cfg["templates"]["con_left_top_sync"], true));
320:
321: $link = $sess->url("main.php?area=" . $area . "&frame=2") . '&syncoptions=';
322: $sJsLink = 'conMultiLink(\'left_bottom\', \'' . $link . '\'+document.getElementsByName(\'syncoptions\')[0].value+\'&refresh_syncoptions=true\');';
323: $tpl->set('s', 'UPDATE_SYNC_REFRESH_FRAMES', $sJsLink);
324: $tpl->set('s', 'SYNCRONIZATION', $oListOptionRow->render());
325: $tpl->set('s', 'SYNCLINK', $sListId);
326: $sSyncLink = $sess->url("main.php?area=$area&frame=2&action=con_synccat");
327: $tpl->set('s', 'SYNC_HREF', $sSyncLink);
328: } else {
329: $tpl->set('s', 'SYNCRONIZATION', '');
330: $tpl->set('s', 'SYNCLINK', $sListId);
331: $tpl->set('s', 'SYNC_HREF', '');
332: }
333:
334:
335: $selflink = "main.php";
336: $expandlink = $sess->url($selflink . "?area=$area&frame=2&expand=all");
337: $collapselink = $sess->url($selflink . "?area=$area&frame=2&collapse=all");
338: $tpl->set('s', 'COLLAPSE_LINK', $collapselink);
339: $tpl->set('s', 'EXPAND_LINK', $expandlink);
340:
341:
342: $tpl->set('s', 'AREA', $area);
343: $tpl->set('s', 'SESSION', $contenido);
344: $tpl->set('s', 'AJAXURL', cRegistry::getBackendUrl() . 'ajaxmain.php');
345:
346:
347: $legendlink = 'legend';
348: $editCategory = new cGuiFoldingRow("31f52be2-7499-4d21-8175-3917129e6014", i18n("Legend"), $legendlink);
349:
350: $divLegend = new cHTMLDiv("", "", "legend");
351:
352: $aInformation = array('imgsrc', 'description');
353: $aData = xmlFileToArray($cfg['path']['xml'] . "legend.xml", $aData, $aInformation);
354:
355: foreach ($aData as $key => $item) {
356: $divKey = new cHTMLDiv("", $key);
357: foreach ($item as $data) {
358: $image = new cHTMLImage((string) $data['imgsrc'], "vAlignMiddle");
359: $description = new cHTMLSpan(i18n((string) $data['description']), "tableElement");
360: $divItem = new cHTMLDiv($image->render() . $description->render());
361: $divKey->appendContent($divItem->render());
362: }
363: $divLegend->appendContent($divKey->render());
364: }
365:
366: $editCategory->setContentData($divLegend->render());
367: $tpl->set('s', 'LEGEND', $editCategory->render());
368: $tpl->set('s', 'LEGENDLINK', $legendlink);
369:
370:
371: $tpl->set('s', 'HELPSCRIPT', getJsHelpContext("con"));
372: $tpl->generate($cfg['path']['templates'] . $cfg['templates']['con_left_top']);
373:
374: function xmlFileToArray($filename, $aData = array(), $aInformation) {
375: $_dom = simplexml_load_file($filename);
376: for ($i = 0, $size = count($_dom); $i < $size; $i++) {
377: foreach ($aInformation as $sInfoName) {
378: if ($_dom->article[$i]->$sInfoName != '') {
379: $aData['article'][$i][$sInfoName] = $_dom->article[$i]->$sInfoName;
380: }
381: if ($_dom->category[$i]->$sInfoName != '') {
382: $aData['category'][$i][$sInfoName] = $_dom->category[$i]->$sInfoName;
383: }
384: }
385: }
386: return $aData;
387: }
388:
389: ?>