configure_homepage.php 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Configure the portal homepage (manages multi-urls and languages)
  5. * @package chamilo.admin
  6. */
  7. /**
  8. * Creates menu tabs for logged and anonymous users
  9. *
  10. * This function copies the file containing private a public tabs (home_tabs_logged_in_$language.html)
  11. * in to the public tab template (home_tabs_$language.html) but without the private tabs.
  12. * Private tabs are the ones including "?private" string in the end of the url, ex: http://google.com/?private
  13. *
  14. * @param string Name of the file been updated by the administration, ex: home_tabs_logged_in_($language).html
  15. */
  16. function home_tabs($file_logged_in)
  17. {
  18. $post = strpos($file_logged_in, "_logged_in");
  19. if ($post !== false) {
  20. $file_logged_out = str_replace('_logged_in','', $file_logged_in);
  21. //variables initialization
  22. $data_logged_out = array();
  23. $data_logged_in = array();
  24. //we read the file with all links
  25. $file = file($file_logged_in);
  26. foreach ($file as $line) {
  27. $line = str_replace("\n", '',$line);
  28. //not logged user only sees public links
  29. if (!preg_match('/::private/',$line)) {
  30. $data_logged_out[] = $line;
  31. }
  32. //logged user only sees all links
  33. $data_logged_in[] = $line;
  34. }
  35. //tabs file for logged out users
  36. if (file_exists($file_logged_out)) {
  37. $fp = fopen($file_logged_out, 'w');
  38. fputs($fp, implode("\n", $data_logged_out));
  39. fclose($fp);
  40. }
  41. //tabs file for logged in users
  42. $fp = fopen($file_logged_in, 'w');
  43. fputs($fp, implode("\n", $data_logged_in));
  44. fclose($fp);
  45. }
  46. }
  47. $cidReset = true;
  48. require_once '../inc/global.inc.php';
  49. $this_section = SECTION_PLATFORM_ADMIN;
  50. $_SESSION['this_section'] = $this_section;
  51. $this_page = '';
  52. api_protect_admin_script();
  53. $htmlHeadXtra[] = '<script>
  54. $(function() {
  55. $("#all_langs").change(function() {
  56. var checkboxes = $(this).closest("form").find("#table_langs").find(":checkbox");
  57. if($(this).is(":checked")) {
  58. checkboxes.attr("checked", "checked");
  59. } else {
  60. checkboxes.removeAttr("checked");
  61. }
  62. });
  63. });
  64. </script>';
  65. global $_configuration;
  66. $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null;
  67. $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
  68. $tool_name = get_lang('ConfigureHomePage');
  69. $_languages = api_get_languages();
  70. $interbreadcrumb[] = array(
  71. 'url' => 'index.php',
  72. 'name' => get_lang('PlatformAdmin')
  73. );
  74. if (!empty($action)) {
  75. $interbreadcrumb[] = array(
  76. 'url' => 'configure_homepage.php',
  77. 'name' => get_lang('ConfigureHomePage')
  78. );
  79. switch ($action) {
  80. case 'edit_top':
  81. $tool_name = get_lang('EditHomePage');
  82. break;
  83. case 'edit_news':
  84. $tool_name = get_lang('EditNews');
  85. break;
  86. case 'edit_notice':
  87. $tool_name = get_lang('EditNotice');
  88. break;
  89. case 'insert_link':
  90. $tool_name = get_lang('InsertLink');
  91. break;
  92. case 'edit_link':
  93. $tool_name = get_lang('EditLink');
  94. break;
  95. case 'insert_tabs':
  96. $tool_name = get_lang('InsertTabs');
  97. break;
  98. case 'edit_tabs':
  99. $tool_name = get_lang('EditTabs');
  100. break;
  101. }
  102. }
  103. // The global logic for language priorities should be:
  104. // - take language selected when connecting ($_SESSION['user_language_choice'])
  105. // or last language selected (taken from select box into SESSION by global.inc.php)
  106. // or, if unavailable;
  107. // - take default user language ($_SESSION['_user']['language']) - which is taken from
  108. // the database in local.inc.php or, if unavailable;
  109. // - take platform language (taken from the database campus setting 'platformLanguage')
  110. // Then if a language file doesn't exist, it should be created.
  111. // The default language for the homepage should use the default platform language
  112. // (if nothing else is selected), which means the 'no-language' file should be taken
  113. // to fill a new 'language-specified' language file, and then only the latter should be
  114. // modified. The original 'no-language' files should never be modified.
  115. // ----- Language selection -----
  116. // The final language selected and used everywhere in this script follows the rules
  117. // described above and is put into "$lang". Because this script includes
  118. // global.inc.php, the variables used for language purposes below are considered safe.
  119. $lang = ''; //el for "Edit Language"
  120. if (!empty($_SESSION['user_language_choice'])) {
  121. $lang = $_SESSION['user_language_choice'];
  122. } elseif (!empty($_SESSION['_user']['language'])) {
  123. $lang = $_SESSION['_user']['language'];
  124. } else {
  125. $lang = api_get_setting('platformLanguage');
  126. }
  127. $languageGet = isset($_GET['language']) ? Security::remove_XSS($_GET['language']) : $lang;
  128. // Ensuring availability of main files in the corresponding language
  129. if (api_is_multiple_url_enabled()) {
  130. $access_url_id = api_get_current_access_url_id();
  131. if ($access_url_id != -1) {
  132. $url_info = api_get_access_url($access_url_id);
  133. $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
  134. $clean_url = api_replace_dangerous_char($url);
  135. $clean_url = str_replace('/', '-', $clean_url);
  136. $clean_url .= '/';
  137. $homep = api_get_path(SYS_PATH).'home/'; //homep for Home Path
  138. $homep_new = api_get_path(SYS_PATH).'home/'.$clean_url; //homep for Home Path added the url
  139. $new_url_dir = api_get_path(SYS_PATH).'home/'.$clean_url;
  140. //we create the new dir for the new sites
  141. if (!is_dir($new_url_dir)) {
  142. mkdir($new_url_dir, api_get_permissions_for_new_directories());
  143. }
  144. }
  145. } else {
  146. $homep_new = '';
  147. $homep = api_get_path(SYS_PATH).'home/'; //homep for Home Path
  148. }
  149. $menuf = 'home_menu'; //menuf for Menu File
  150. $newsf = 'home_news'; //newsf for News File
  151. $topf = 'home_top'; //topf for Top File
  152. $noticef = 'home_notice'; //noticef for Notice File
  153. $menutabs= 'home_tabs'; //menutabs for tabs Menu
  154. $mtloggedin= 'home_tabs_logged_in'; //menutabs for tabs Menu
  155. $ext = '.html'; //ext for HTML Extension - when used frequently, variables are
  156. // faster than hardcoded strings
  157. $homef = array($menuf, $newsf, $topf, $noticef, $menutabs, $mtloggedin);
  158. // If language-specific file does not exist, create it by copying default file
  159. foreach ($homef as $my_file) {
  160. if (api_is_multiple_url_enabled()) {
  161. if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) {
  162. if (!file_exists($homep.$my_file.$ext)) {
  163. touch($homep.$my_file.$ext);
  164. }
  165. @copy($homep.$my_file.$ext, $homep_new.$my_file.'_'.$lang.$ext);
  166. }
  167. } else {
  168. if (!file_exists($homep.$my_file.'_'.$lang.$ext)) {
  169. if (!file_exists($homep.$my_file.$ext)) {
  170. touch($homep.$my_file.$ext);
  171. }
  172. @copy($homep.$my_file.$ext, $homep.$my_file.'_'.$lang.$ext);
  173. }
  174. }
  175. }
  176. if (api_is_multiple_url_enabled()) {
  177. $homep = $homep_new;
  178. }
  179. // Check WCAG settings and prepare edition using WCAG
  180. $errorMsg = '';
  181. // Filter link param
  182. $link = '';
  183. if (!empty($_GET['link'])) {
  184. $link = $_GET['link'];
  185. // If the link parameter is suspicious, empty it
  186. if (strstr($link, '/') || !strstr($link, '.html') || strstr($link, '\\')) {
  187. $link = '';
  188. $action = '';
  189. }
  190. }
  191. // Start analysing requested actions
  192. if (!empty($action)) {
  193. if (!empty($_POST['formSent'])) {
  194. // Variables used are $homep for home path, $menuf for menu file, $newsf
  195. // for news file, $topf for top file, $noticef for noticefile,
  196. // $ext for '.html'
  197. switch ($action) {
  198. case 'edit_top':
  199. // Filter
  200. $home_top = trim(stripslashes($_POST['home_top']));
  201. // Write
  202. if (is_writable($homep)) {
  203. // Default
  204. if (is_writable($homep.$topf.'_'.$lang.$ext)) {
  205. $fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
  206. fputs($fp, $home_top);
  207. fclose($fp);
  208. // Language
  209. foreach ($_languages['name'] as $key => $value) {
  210. $lang_name = $_languages['folder'][$key];
  211. if (isset($_POST[$lang_name])) {
  212. $fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w');
  213. fputs($fp, $home_top);
  214. fclose($fp);
  215. }
  216. }
  217. } else {
  218. $errorMsg = get_lang('HomePageFilesNotWritable');
  219. }
  220. } else {
  221. //File does not exist
  222. $fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
  223. fputs($fp, $home_top);
  224. fclose($fp);
  225. foreach ($_languages['name'] as $key => $value) {
  226. $lang_name = $_languages['folder'][$key];
  227. if (isset($_POST[$lang_name])) {
  228. if (file_exists($homep.$topf.'_'.$lang_name.$ext)) {
  229. $fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w');
  230. fputs($fp, $home_top);
  231. fclose($fp);
  232. }
  233. }
  234. }
  235. }
  236. if (EventsMail::check_if_using_class('portal_homepage_edited')) {
  237. EventsDispatcher::events('portal_homepage_edited',array('about_user' => api_get_user_id()));
  238. }
  239. Event::addEvent(
  240. LOG_HOMEPAGE_CHANGED,
  241. 'edit_top',
  242. cut(strip_tags($home_top), 254),
  243. api_get_utc_datetime(),
  244. api_get_user_id()
  245. );
  246. break;
  247. case 'edit_notice':
  248. // Filter
  249. $notice_title = trim(strip_tags(stripslashes($_POST['notice_title'])));
  250. $notice_text = trim(str_replace(array("\r", "\n"), array('', '<br />'), strip_tags(stripslashes($_POST['notice_text']), '<a>')));
  251. if (empty($notice_title) || empty($notice_text)) {
  252. $errorMsg = get_lang('NoticeWillBeNotDisplayed');
  253. }
  254. // Write
  255. if (file_exists($homep.$noticef.'_'.$lang.$ext)) {
  256. if (is_writable($homep.$noticef.'_'.$lang.$ext)) {
  257. $fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
  258. if ($errorMsg == '') {
  259. fputs($fp, "<b>$notice_title</b><br />\n$notice_text");
  260. foreach ($_languages['name'] as $key => $value) {
  261. $lang_name = $_languages['folder'][$key];
  262. if (isset($_POST[$lang_name])) {
  263. if (file_exists($homep.$noticef.'_'.$lang_name.$ext)) {
  264. if (is_writable($homep.$noticef.'_'.$lang_name.$ext)) {
  265. $fp = fopen($homep.$noticef.'_'.$lang_name.$ext, 'w');
  266. fputs($fp, "<b>$notice_title</b><br />\n$notice_text");
  267. fclose($fp);
  268. }
  269. }
  270. }
  271. }
  272. } else {
  273. fputs($fp, '');
  274. foreach ($_languages['name'] as $key => $value) {
  275. $lang_name = $_languages['folder'][$key];
  276. if (isset($_POST[$lang_name])) {
  277. if (file_exists($homep.$noticef.'_'.$lang_name.$ext)) {
  278. $fp1 = fopen($homep.$noticef.'_'.$lang_name.$ext, 'w');
  279. fputs($fp1, '');
  280. fclose($fp1);
  281. }
  282. }
  283. }
  284. }
  285. fclose($fp);
  286. } else {
  287. $errorMsg .= "<br/>\n".get_lang('HomePageFilesNotWritable');
  288. }
  289. } else {
  290. //File does not exist
  291. $fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
  292. fputs($fp, "<b>$notice_title</b><br />\n$notice_text");
  293. fclose($fp);
  294. }
  295. Event::addEvent(
  296. LOG_HOMEPAGE_CHANGED,
  297. 'edit_notice',
  298. cut(strip_tags($notice_title), 254),
  299. api_get_utc_datetime(),
  300. api_get_user_id()
  301. );
  302. break;
  303. case 'edit_news':
  304. //Filter
  305. $home_news = trim(stripslashes($_POST['home_news']));
  306. //Write
  307. if ($s_languages_news != 'all') {
  308. if (file_exists($homep.$newsf.'_'.$s_languages_news.$ext)) {
  309. if (is_writable($homep.$newsf.'_'.$s_languages_news.$ext)) {
  310. $fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
  311. fputs($fp, $home_news);
  312. fclose($fp);
  313. } else {
  314. $errorMsg = get_lang('HomePageFilesNotWritable');
  315. }
  316. } else {
  317. // File does not exist
  318. $fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
  319. fputs($fp, $home_news);
  320. fclose($fp);
  321. }
  322. } else {
  323. // We update all the news file
  324. foreach ($_languages['name'] as $key => $value) {
  325. $english_name = $_languages['folder'][$key];
  326. if (file_exists($homep.$newsf.'_'.$english_name.$ext)) {
  327. if (is_writable($homep.$newsf.'_'.$english_name.$ext)) {
  328. $fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
  329. fputs($fp, $home_news);
  330. fclose($fp);
  331. } else {
  332. $errorMsg = get_lang('HomePageFilesNotWritable');
  333. }
  334. } else {
  335. // File does not exist
  336. $fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
  337. fputs($fp, $home_news);
  338. fclose($fp);
  339. }
  340. }
  341. }
  342. Event::addEvent(
  343. LOG_HOMEPAGE_CHANGED,
  344. 'edit_news',
  345. strip_tags(cut($home_news, 254)),
  346. api_get_utc_datetime(),
  347. api_get_user_id()
  348. );
  349. break;
  350. case 'insert_tabs':
  351. case 'edit_tabs':
  352. case 'insert_link':
  353. case 'edit_link':
  354. $link_index = intval($_POST['link_index']);
  355. $insert_where = intval($_POST['insert_where']);
  356. $link_name = trim(stripslashes($_POST['link_name']));
  357. $link_url = trim(stripslashes($_POST['link_url']));
  358. $add_in_tab = intval($_POST['add_in_tab']);
  359. $link_html = trim(stripslashes($_POST['link_html']));
  360. $filename = trim(stripslashes($_POST['filename']));
  361. $target_blank = $_POST['target_blank'] ? true : false;
  362. if ($link_url == 'http://' || $link_url == 'https://') {
  363. $link_url = '';
  364. } elseif (!empty($link_url) && !strstr($link_url, '://')) {
  365. $link_url='http://'.$link_url;
  366. }
  367. $menuf = ($action == 'insert_tabs' || $action == 'edit_tabs')? $mtloggedin : $menuf;
  368. if (!is_writable($homep.$menuf.'_'.$lang.$ext)) {
  369. $errorMsg = get_lang('HomePageFilesNotWritable');
  370. } elseif (empty($link_name)) {
  371. $errorMsg = get_lang('PleaseEnterLinkName');
  372. } else {
  373. // New links are added as new files in the home/ directory
  374. if ($action == 'insert_link' || $action == 'insert_tabs' || empty($filename) || strstr($filename, '/') || !strstr($filename, '.html')) {
  375. $filename = api_replace_dangerous_char($link_name, 'strict').'.html';
  376. }
  377. // "home_" prefix for links are renamed to "user_" prefix (to avoid name clash with existing home page files)
  378. if (!empty($filename)) {
  379. $filename = str_replace('home_', 'user_', $filename);
  380. }
  381. // If the typical language suffix is not found in the file name,
  382. // replace the ".html" suffix by "_en.html" or the active menu language
  383. if (!strstr($filename,'_'.$lang.$ext)) {
  384. $filename = str_replace($ext, '_'.$lang.$ext, $filename);
  385. }
  386. // Get the contents of home_menu_en.html (or active menu language
  387. // version) into $home_menu as an array of one entry per line
  388. $home_menu = file($homep.$menuf.'_'.$lang.$ext);
  389. $home_menu = implode("\n", $home_menu);
  390. $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
  391. $home_menu = explode("\n", $home_menu);
  392. $home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
  393. // Prepare place to insert the new link into (default is end of file)
  394. if ($insert_where < -1 || $insert_where > (sizeof($home_menu) - 1)) {
  395. $insert_where = sizeof($home_menu) - 1;
  396. }
  397. //
  398. // For each line of the file, remove trailing spaces and special chars
  399. //foreach ($home_menu as $key => $enreg) {
  400. // $home_menu[$key] = trim($enreg);
  401. //}
  402. //
  403. // If the given link url is empty, then replace the link url by a link to the link file created
  404. if (empty($link_url) || $link_url == 'http://' || $link_url == 'https://') {
  405. $link_url = api_get_path(WEB_PATH).'index.php?include='.urlencode($filename);
  406. // If the file doesn't exist, then create it and
  407. // fill it with default text
  408. $fp = @fopen($homep.$filename, 'w');
  409. if ($fp) {
  410. if (empty($link_html)) {
  411. fputs($fp, get_lang('MyTextHere'));
  412. home_tabs($homep.$filename);
  413. } else {
  414. fputs($fp, $link_html);
  415. home_tabs($homep.$filename);
  416. }
  417. fclose($fp);
  418. }
  419. }
  420. // If the requested action is to edit a link, open the file and
  421. // write to it (if the file doesn't exist, create it)
  422. if (in_array($action, array('edit_link')) && !empty($link_html)) {
  423. $fp = @fopen($homep.$filename, 'w');
  424. if ($fp) {
  425. fputs($fp, $link_html);
  426. home_tabs($homep.$filename);
  427. fclose($fp);
  428. }
  429. }
  430. $class_add_in_tab = 'class="show_menu"';
  431. if (!$add_in_tab) {
  432. $class_add_in_tab = 'class="hide_menu"';
  433. }
  434. // If the requested action is to create a link, make some room
  435. // for the new link in the home_menu array at the requested place
  436. // and insert the new link there
  437. $icon = '<i class="fa fa-external-link"></i>';
  438. if ($action == 'insert_link' || $action == 'insert_tabs') {
  439. for ($i = sizeof($home_menu); $i; $i--) {
  440. if ($i > $insert_where) {
  441. $home_menu[$i] = $home_menu[$i - 1];
  442. } else {
  443. break;
  444. }
  445. }
  446. $home_menu[$insert_where + 1] = '<li '.$class_add_in_tab.'><a href="'.$link_url.'" target="'.($target_blank ? '_blank' : '_self').'">'.$icon.' '.$link_name.'</a></li>';
  447. } else {
  448. // If the request is about a link edition, change the link
  449. $home_menu[$link_index]='<li '.$class_add_in_tab.'><a href="'.$link_url.'" target="'.($target_blank?'_blank':'_self').'">'.$icon.' '.$link_name.'</a></li>';
  450. }
  451. // Re-build the file from the home_menu array
  452. $home_menu = implode("\n", $home_menu);
  453. // Write
  454. if (file_exists($homep.$menuf.'_'.$lang.$ext)) {
  455. if (is_writable($homep.$menuf.'_'.$lang.$ext)) {
  456. $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
  457. fputs($fp, $home_menu);
  458. home_tabs($homep.$menuf.'_'.$lang.$ext);
  459. fclose($fp);
  460. foreach ($_languages['name'] as $key => $value) {
  461. $lang_name = $_languages['folder'][$key];
  462. if (isset($_POST[$lang_name])) {
  463. $fp = fopen($homep.$menuf.'_'.$lang_name.$ext, 'w');
  464. fputs($fp, $home_menu);
  465. home_tabs($homep.$menuf.'_'.$lang_name.$ext);
  466. fclose($fp);
  467. }
  468. }
  469. if (file_exists($homep.$menuf.$ext)) {
  470. if (is_writable($homep.$menuf.$ext)) {
  471. $fpo = fopen($homep.$menuf.$ext, 'w');
  472. fputs($fpo, $home_menu);
  473. home_tabs($homep.$menuf.$ext);
  474. fclose($fpo);
  475. }
  476. }
  477. } else {
  478. $errorMsg = get_lang('HomePageFilesNotWritable');
  479. }
  480. } else {
  481. //File does not exist
  482. $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
  483. fputs($fp, $home_menu);
  484. home_tabs($homep.$menuf.'_'.$lang.$ext);
  485. fclose($fp);
  486. foreach ($_languages['name'] as $key => $value) {
  487. $lang_name = $_languages['folder'][$key];
  488. if (isset($_POST[$lang_name])) {
  489. $fp = fopen($homep.$menuf.'_'.$lang_name.$ext, 'w');
  490. fputs($fp, $home_menu);
  491. home_tabs($homep.$menuf.'_'.$lang_name.$ext);
  492. fclose($fp);
  493. }
  494. }
  495. }
  496. }
  497. Event::addEvent(
  498. LOG_HOMEPAGE_CHANGED,
  499. $action,
  500. cut($link_name . ':' . $link_url, 254),
  501. api_get_utc_datetime(),
  502. api_get_user_id()
  503. );
  504. break;
  505. } //end of switch($action)
  506. if (empty($errorMsg)) {
  507. header('Location: '.api_get_self().'?language='.$languageGet);
  508. exit();
  509. }
  510. } else {
  511. //if POST[formSent] is not set
  512. switch ($action) {
  513. case 'open_link':
  514. // Previously, filtering of GET['link'] was done here but it left
  515. // a security threat. Filtering has now been moved outside conditions
  516. break;
  517. case 'delete_tabs':
  518. case 'delete_link':
  519. // A link is deleted by getting the file into an array, removing the
  520. // link and re-writing the array to the file
  521. $link_index = intval($_GET['link_index']);
  522. $menuf = ($action == 'delete_tabs')? $mtloggedin : $menuf;
  523. $home_menu = @file($homep.$menuf.'_'.$lang.$ext);
  524. if (empty($home_menu)) {
  525. $home_menu = array();
  526. }
  527. foreach ($home_menu as $key => $enreg) {
  528. if ($key == $link_index) {
  529. unset($home_menu[$key]);
  530. } else {
  531. $home_menu[$key] = trim($enreg);
  532. }
  533. }
  534. $home_menu = implode("\n", $home_menu);
  535. $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
  536. $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
  537. fputs($fp, $home_menu);
  538. home_tabs($homep.$menuf.'_'.$lang.$ext);
  539. fclose($fp);
  540. if (file_exists($homep.$menuf.$ext)) {
  541. if (is_writable($homep.$menuf.$ext)) {
  542. $fpo = fopen($homep.$menuf.$ext,'w');
  543. fputs($fpo, $home_menu);
  544. home_tabs($homep.$menuf.$ext);
  545. fclose($fpo);
  546. }
  547. }
  548. header('Location: '.api_get_self());
  549. exit();
  550. break;
  551. case 'edit_top':
  552. // This request is only the preparation for the update of the home_top
  553. $home_top = '';
  554. if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) {
  555. $home_top = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
  556. } elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) {
  557. $home_top = @(string)file_get_contents($homep.$topf.$lang.$ext);
  558. } else {
  559. $errorMsg = get_lang('HomePageFilesNotReadable');
  560. }
  561. $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
  562. break;
  563. case 'edit_notice':
  564. // This request is only the preparation for the update of the home_notice
  565. $home_notice = '';
  566. if (is_file($homep.$noticef.'_'.$lang.$ext) && is_readable($homep.$noticef.'_'.$lang.$ext)) {
  567. $home_notice = @file($homep.$noticef.'_'.$lang.$ext);
  568. } elseif (is_file($homep.$noticef.$lang.$ext) && is_readable($homep.$noticef.$lang.$ext)) {
  569. $home_notice = @file($homep.$noticef.$lang.$ext);
  570. } else {
  571. $errorMsg = get_lang('HomePageFilesNotReadable');
  572. }
  573. if (empty($home_notice)) {
  574. $home_notice = array();
  575. }
  576. $notice_title = strip_tags($home_notice[0]);
  577. $notice_title = api_to_system_encoding($notice_title, api_detect_encoding($notice_title));
  578. $notice_text = strip_tags(str_replace('<br />', "\n", $home_notice[1]), '<a>');
  579. $notice_text = api_to_system_encoding($notice_text, api_detect_encoding(strip_tags($notice_text)));
  580. break;
  581. case 'edit_news':
  582. // This request is the preparation for the update of the home_news page
  583. $home_news = '';
  584. if (is_file($homep.$newsf.'_'.$lang.$ext) && is_readable($homep.$newsf.'_'.$lang.$ext)) {
  585. $home_news = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
  586. } elseif (is_file($homep.$newsf.$lang.$ext) && is_readable($homep.$newsf.$lang.$ext)) {
  587. $home_news = @(string)file_get_contents($homep.$newsf.$lang.$ext);
  588. } else {
  589. $errorMsg = get_lang('HomePageFilesNotReadable');
  590. }
  591. $home_news = api_to_system_encoding($home_news, api_detect_encoding(strip_tags($home_news)));
  592. break;
  593. case 'insert_link':
  594. // This request is the preparation for the addition of an item in home_menu
  595. $home_menu = '';
  596. $menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
  597. if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
  598. $home_menu = @file($homep.$menuf.'_'.$lang.$ext);
  599. } elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
  600. $home_menu = @file($homep.$menuf.$lang.$ext);
  601. } else {
  602. $errorMsg = get_lang('HomePageFilesNotReadable');
  603. }
  604. if (empty($home_menu)) {
  605. $home_menu = array();
  606. }
  607. if (!empty($home_menu)) {
  608. $home_menu = implode("\n", $home_menu);
  609. $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
  610. $home_menu = explode("\n", $home_menu);
  611. }
  612. $home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
  613. break;
  614. case 'insert_tabs':
  615. // This request is the preparation for the addition of an item in home_menu
  616. $home_menu = '';
  617. if (is_file($homep.$mtloggedin.'_'.$lang.$ext) && is_readable($homep.$mtloggedin.'_'.$lang.$ext)) {
  618. $home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
  619. } elseif (is_file($homep.$mtloggedin.$lang.$ext) && is_readable($homep.$mtloggedin.$lang.$ext)) {
  620. $home_menu = @file($homep.$mtloggedin.$lang.$ext);
  621. } elseif (touch($homep.$mtloggedin.'_'.$lang.$ext)) {
  622. $home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
  623. } else {
  624. $errorMsg = get_lang('HomePageFilesNotReadable');
  625. }
  626. if (empty($home_menu)) {
  627. $home_menu = array();
  628. }
  629. if (!empty($home_menu)) {
  630. $home_menu = implode("\n", $home_menu);
  631. $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
  632. $home_menu = explode("\n", $home_menu);
  633. }
  634. $home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
  635. break;
  636. case 'edit_tabs':
  637. case 'edit_link':
  638. // This request is the preparation for the edition of the links array
  639. $home_menu = '';
  640. $menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
  641. if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
  642. $home_menu = @file($homep.$menuf.'_'.$lang.$ext);
  643. } elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
  644. $home_menu = @file($homep.$menuf.$lang.$ext);
  645. } else {
  646. $errorMsg = get_lang('HomePageFilesNotReadable');
  647. }
  648. if (empty($home_menu)) {
  649. if (file_exists($homep.$menutabs.'_'.$lang.$ext)) {
  650. $home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
  651. }
  652. }
  653. if (empty($home_menu)) {
  654. $home_menu = array();
  655. }
  656. if (!empty($home_menu)) {
  657. $home_menu = implode("\n", $home_menu);
  658. $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
  659. $home_menu = explode("\n", $home_menu);
  660. }
  661. $link_index = intval($_GET['link_index']);
  662. $target_blank = false;
  663. $link_name = '';
  664. $link_url = '';
  665. //$home_menu_new = array();
  666. //
  667. //Cleaning array
  668. //foreach ($home_menu as $item) {
  669. // if(!empty($item)) {
  670. // $home_menu_new[] = $item;
  671. // }
  672. //}
  673. //$home_menu = $home_menu_new;
  674. // Cleaning the array
  675. $home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
  676. // For each line of the home_menu file
  677. foreach ($home_menu as $key => $enreg) {
  678. // Check if the current item is the one we want to update
  679. if ($key == $link_index) {
  680. // This is the link we want to update
  681. // Check if the target should be "_blank"
  682. if (strstr($enreg, 'target="_blank"')) {
  683. $target_blank = true;
  684. }
  685. if (strstr($enreg, 'hide_menu')) {
  686. $add_in_tab = false;
  687. } else {
  688. $add_in_tab = true;
  689. }
  690. // Remove dangerous HTML tags from the link itself (this is an
  691. // additional measure in case a link previously contained
  692. // unsecure tags)
  693. $link_name = strip_tags($enreg);
  694. // Get the contents of "href" attribute in $link_url
  695. $enreg = explode('href="',$enreg);
  696. list($link_url) = explode('"', $enreg[sizeof($enreg) - 1]);
  697. // If the link contains the web root of this portal, then strip
  698. // it off and keep only the name of the file that needs edition
  699. if (strstr($link_url, '?include=')) {
  700. $link_url = explode('?include=', $link_url);
  701. $filename = $link_url[sizeof($link_url) - 1];
  702. if (!strstr($filename, '/') && strstr($filename, '.html')) {
  703. // Get oonly the contents of the link file
  704. $link_html = @file($homep.$filename);
  705. $link_html = implode('', $link_html);
  706. $link_url = '';
  707. } else {
  708. $filename = '';
  709. }
  710. }
  711. break;
  712. }
  713. }
  714. break;
  715. }//end of second switch($action) (when POST['formSent'] was not set, yet)
  716. }// end of "else" in if($_POST['formSent']) condition
  717. } else {
  718. //if $action is empty, then prepare a list of the course categories to display (?)
  719. $Categories = getCategoriesToDisplayInHomePage();
  720. }
  721. // Display section
  722. Display::display_header($tool_name);
  723. switch ($action) {
  724. case 'open_link':
  725. if (!empty($link)) {
  726. // $link is only set in case of action=open_link and is filtered
  727. $open = @(string)file_get_contents($homep.$link);
  728. $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
  729. echo $open;
  730. }
  731. break;
  732. case 'edit_notice':
  733. // Display for edit_notice case
  734. ?>
  735. <form action="<?php echo api_get_self(); ?>?action=<?php echo $action; ?>" method="post" style="margin:0px;">
  736. <legend><?php echo $tool_name; ?></legend>
  737. <input type="hidden" name="formSent" value="1"/>
  738. <?php
  739. if (!empty($errorMsg)) {
  740. Display::display_normal_message($errorMsg);
  741. }
  742. ?>
  743. <table border="0" cellpadding="5" cellspacing="0">
  744. <tr><td colspan="2"><?php echo '<span style="font-style: italic;">'.get_lang('LetThoseFieldsEmptyToHideTheNotice').'</span>'; ?></tr>
  745. <tr>
  746. <td nowrap="nowrap"><?php echo get_lang('NoticeTitle'); ?> :</td>
  747. <td><input type="text" name="notice_title" size="30" maxlength="50" value="<?php echo $notice_title; ?>" style="width: 350px;"/></td>
  748. </tr>
  749. <tr>
  750. <td nowrap="nowrap" valign="top"><?php echo get_lang('NoticeText'); ?> :</td>
  751. <td><textarea name="notice_text" cols="30" rows="5" wrap="virtual" style="width: 350px;"><?php echo $notice_text; ?></textarea></td>
  752. </tr>
  753. <tr>
  754. <td><label><?php echo get_lang('ApplyAllLanguages'); ?></label>
  755. <td><input type="checkbox" name="all_langs" value="<?php echo get_lang('ApplyAllLanguages'); ?>"/></td>
  756. </tr>
  757. <tr>
  758. <td>&nbsp;</td>
  759. <td><button class="save" type="submit" value="<?php echo get_lang('Ok'); ?>"><?php echo get_lang('Ok'); ?></button></td>
  760. </tr>
  761. </table>
  762. </form>
  763. <?php
  764. break;
  765. case 'insert_tabs':
  766. case 'edit_tabs':
  767. case 'insert_link':
  768. case 'edit_link':
  769. $menuf = ($action == 'insert_tabs' || $action == 'edit_tabs') ? $mtloggedin : $menuf;
  770. if (!empty($errorMsg)) {
  771. Display::display_normal_message($errorMsg);
  772. }
  773. $default = array();
  774. $form = new FormValidator('configure_homepage_'.$action, 'post', api_get_self().'?action='.$action, '', array('style' => 'margin: 0px;'));
  775. $renderer =& $form->defaultRenderer();
  776. $form->addElement('header', '', $tool_name);
  777. $form->addElement('hidden', 'formSent', '1');
  778. $form->addElement('hidden', 'link_index', ($action == 'edit_link' || $action == 'edit_tabs') ? $link_index : '0');
  779. $form->addElement('hidden', 'filename', ($action == 'edit_link' || $action == 'edit_tabs') ? (!empty($filename) ? $filename : '') : '');
  780. $form->addElement('text', 'link_name', get_lang('LinkName'), array('size' => '30', 'maxlength' => '50'));
  781. if (!empty($link_name)) {
  782. $default['link_name'] = $link_name;
  783. }
  784. $default['link_url'] = empty($link_url) ? 'http://' : api_htmlentities($link_url, ENT_QUOTES);
  785. $linkUrlComment = ($action == 'insert_tabs') ? get_lang('Optional').'<br />'.get_lang('GlobalLinkUseDoubleColumnPrivateToShowPrivately') : '';
  786. $form->addElement('text', 'link_url', array(get_lang('LinkURL'), $linkUrlComment), array('size' => '30', 'maxlength' => '100', 'style' => 'width: 350px;'));
  787. $options = array('-1' => get_lang('FirstPlace'));
  788. $selected = '';
  789. if ($action == 'insert_link' || $action == 'insert_tabs') {
  790. $add_in_tab = 1;
  791. if (is_array($home_menu)){
  792. foreach ($home_menu as $key => $enreg) {
  793. if (strlen($enreg = trim(strip_tags($enreg))) > 0) {
  794. $options[$key] = get_lang('After').' &quot;'.$enreg.'&quot;';
  795. $formSentCheck = (!empty($_POST['formSent']) ? true : false);
  796. $selected = $formSentCheck && $insert_where == $key ? $key : '';
  797. }
  798. }
  799. }
  800. $default['insert_link'] = $selected;
  801. $form->addElement('select', 'insert_where', get_lang('InsertThisLink') , $options);
  802. }
  803. $target_blank_checkbox = $form->addElement('checkbox', 'target_blank', null, get_lang('OpenInNewWindow'), 1);
  804. if ($action == 'insert_tabs' || $action == 'edit_tabs') {
  805. $form->addElement('checkbox', 'add_in_tab', null, get_lang('AddInMenu'), 1);
  806. $default['add_in_tab'] = $add_in_tab;
  807. }
  808. if (!empty($target_blank)) { $target_blank_checkbox->setChecked(true); }
  809. if ($action == 'edit_link' && (empty($link_url) || $link_url == 'http://' || $link_url == 'https://')) {
  810. $default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : $link_html;
  811. $form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
  812. $form->addButtonSave(get_lang('Save'),'submit');
  813. } else {
  814. if (in_array($action, array('edit_tabs','insert_tabs'))) {
  815. $default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : (!empty($link_html) ? $link_html : '');
  816. $form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
  817. }
  818. $form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'), array('id' => 'all_langs'));
  819. $form->addElement('html','<table id="table_langs" style="margin-left:159px;"><tr>');
  820. $i = 0;
  821. foreach ($_languages['name'] as $key => $value) {
  822. $i++;
  823. $lang_name = $_languages['folder'][$key];
  824. $html_langs = '<td width="300">';
  825. $html_langs .= '<label><input type="checkbox" id="lang" name="'.$lang_name.'" />&nbsp;'.$lang_name.'<label/>';
  826. $html_langs .= '</td>';
  827. if ($i % 5 == 0) {
  828. $html_langs .= '</tr><tr>';
  829. }
  830. $form->addElement('html', $html_langs);
  831. }
  832. $form->addElement('html','</tr></table><br/>');
  833. $form->addButtonSave(get_lang('Save'),'submit');
  834. }
  835. $form->setDefaults($default);
  836. $form->display();
  837. break;
  838. case 'edit_top':
  839. case 'edit_news':
  840. if ($action == 'edit_top') {
  841. $name = $topf;
  842. $open = $home_top;
  843. } else {
  844. $name = $newsf;
  845. $open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
  846. }
  847. $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
  848. if (!empty($errorMsg)) {
  849. Display::display_normal_message($errorMsg); //main API
  850. }
  851. $default = array();
  852. $form = new FormValidator(
  853. 'configure_homepage_'.$action,
  854. 'post',
  855. api_get_self().'?action='.$action,
  856. '',
  857. array('style' => 'margin: 0px;')
  858. );
  859. $renderer =& $form->defaultRenderer();
  860. $renderer->setHeaderTemplate('');
  861. $renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>');
  862. $renderer->setCustomElementTemplate('<tr><td>{element}</td></tr>');
  863. $renderer->setRequiredNoteTemplate('');
  864. $form->addElement('hidden', 'formSent', '1');
  865. if ($action == 'edit_news') {
  866. $_languages = api_get_languages();
  867. $html = '<tr><td>'.get_lang('ChooseNewsLanguage').' : ';
  868. $html .= '<select name="news_languages">';
  869. $html .= '<option value="all">'.get_lang('ApplyAllLanguages').'</option>';
  870. foreach ($_languages['name'] as $key => $value) {
  871. $english_name = $_languages['folder'][$key];
  872. if ($language == $english_name) {
  873. $html .= '<option value="'.$english_name.'" selected="selected">'.$value.'</option>';
  874. } else {
  875. $html .= '<option value="'.$english_name.'">'.$value.'</option>';
  876. }
  877. }
  878. $html .= '</select></td></tr>';
  879. $form->addElement('html', $html);
  880. }
  881. $default[$name] = str_replace('{rel_path}', api_get_path(REL_PATH), $open);
  882. $form->addHtmlEditor($name, '', true, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
  883. $form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'),array('id' => 'all_langs'));
  884. $form->addElement('html','<table id="table_langs" style="margin-left:5px;"><tr>');
  885. $currentLanguage = api_get_interface_language();
  886. $i = 0;
  887. foreach ($_languages['name'] as $key => $value) {
  888. $lang_name = $_languages['folder'][$key];
  889. $i++;
  890. $checked = null;
  891. if ($languageGet == $lang_name) {
  892. $checked = "checked";
  893. }
  894. $html_langs = '<td width="300">';
  895. $html_langs .= '<label><input type="checkbox" '.$checked.' id="lang" name="'.$lang_name.'" />&nbsp;'.$value.'<label/>';
  896. $html_langs .= '</td>';
  897. if ($i % 5 == 0) {
  898. $html_langs .= '</tr><tr>';
  899. }
  900. $form->addElement('html', $html_langs);
  901. }
  902. $form->addElement('html','</tr></table><br/>');
  903. $form->addButtonSave(get_lang('Save'));
  904. $form->setDefaults($default);
  905. $form->display();
  906. break;
  907. default: // When no action applies, default page to update campus homepage
  908. ?>
  909. <table border="0" cellpadding="5" cellspacing="0" width="100%">
  910. <tr>
  911. <td width="70%" valign="top">
  912. <div class="actions">
  913. <a href="<?php echo api_get_self(); ?>?action=edit_top&language=<?php echo $languageGet; ?>">
  914. <?php Display::display_icon('edit.gif', get_lang('EditHomePage')); ?>
  915. </a>
  916. <a href="<?php echo api_get_self(); ?>?action=edit_top&language=<?php echo $languageGet; ?>">
  917. <?php echo get_lang('EditHomePage'); ?>
  918. </a>
  919. </div>
  920. <table border="0" cellpadding="5" cellspacing="0" width="100%">
  921. <tr>
  922. <td colspan="2">
  923. <?php
  924. //print home_top contents
  925. if (file_exists($homep.$topf.'_'.$lang.$ext)) {
  926. $home_top_temp = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
  927. } else {
  928. $home_top_temp = @(string)file_get_contents($homep.$topf.$ext);
  929. }
  930. $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
  931. $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
  932. echo $open;
  933. ?>
  934. </td>
  935. </tr>
  936. <tr>
  937. <?php
  938. $access_url_id = 1;
  939. // we only show the category options for the main chamilo installation
  940. if (api_is_multiple_url_enabled()) {
  941. $access_url_id = api_get_current_access_url_id();
  942. }
  943. echo '<td width="50%">';
  944. if ($access_url_id == 1) {
  945. echo '<div class="actions">';
  946. echo '<a href="course_category.php">'.Display::display_icon('edit.gif', get_lang('Edit')).'</a>
  947. <a href="course_category.php">'.get_lang('EditCategories').'</a>';
  948. echo '</div>';
  949. }
  950. echo '</td>
  951. <td width="50%">
  952. <br />';
  953. /* <!--<a href="<?php echo api_get_self(); ?>?action=edit_news"><?php Display::display_icon('edit.gif', get_lang('Edit')); ?></a> <a href="<?php echo api_get_self(); ?>?action=edit_news"><?php echo get_lang('EditNews'); ?></a>--> */
  954. echo '</td></tr>
  955. <tr>
  956. <td width="50%" valign="top">
  957. <table border="0" cellpadding="5" cellspacing="0" width="100%">';
  958. if ($access_url_id == 1) {
  959. if (sizeof($Categories)) {
  960. foreach ($Categories as $enreg) {
  961. echo '<tr><td>'.Display::return_icon('folder_document.gif', $enreg['name']).'&nbsp;'.$enreg['name'].'</td></tr>';
  962. }
  963. unset($Categories);
  964. } else {
  965. echo get_lang('NoCategories');
  966. }
  967. }
  968. echo '</table>';
  969. ?>
  970. </td>
  971. <!--<td width="50%" valign="top">
  972. <?php
  973. if (file_exists($homep.$newsf.'_'.$lang.$ext)) {
  974. $open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
  975. $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
  976. echo $open;
  977. } else {
  978. $open = @(string)file_get_contents($homep.$newsf.$ext);
  979. $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
  980. echo $open;
  981. }
  982. ?>
  983. </td>-->
  984. </tr>
  985. </table>
  986. <?php
  987. // Add new page
  988. $home_menu = '';
  989. if (file_exists($homep.$mtloggedin.'_'.$lang.$ext)) {
  990. $home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
  991. } else {
  992. $home_menu = @file($homep.$mtloggedin.$ext);
  993. }
  994. if (empty($home_menu)) {
  995. if (file_exists($homep.$menutabs.'_'.$lang.$ext)) {
  996. $home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
  997. }
  998. }
  999. if (empty($home_menu)) {
  1000. $home_menu = array();
  1001. }
  1002. if (!empty($home_menu)) {
  1003. $home_menu = implode("\n", $home_menu);
  1004. $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
  1005. $home_menu = explode("\n", $home_menu);
  1006. }
  1007. $link_list = '';
  1008. $tab_counter = 0;
  1009. foreach ($home_menu as $enreg) {
  1010. $enreg = trim($enreg);
  1011. if (!empty($enreg)) {
  1012. $edit_link = ' <a href="'.api_get_self().'?action=edit_tabs&amp;link_index='.$tab_counter.'" ><span>'.Display::return_icon('edit.gif', get_lang('Edit')).'</span></a>';
  1013. $delete_link = ' <a href="'.api_get_self().'?action=delete_tabs&amp;link_index='.$tab_counter.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)).'\')) return false;"><span>'.Display::return_icon('delete.gif', get_lang('Delete')).'</span></a>';
  1014. $tab_string = str_replace(array('href="'.api_get_path(WEB_PATH).'index.php?include=', '</li>'),
  1015. array('href="'.api_get_path(WEB_CODE_PATH).'admin/'.basename(api_get_self()).'?action=open_link&link=', $edit_link.$delete_link.'</li>'),
  1016. $enreg);
  1017. $tab_string = str_replace(array('<li>', '</li>','class="hide_menu"', 'hide_menu'), '', $tab_string);
  1018. $link_list .= Display::tag('tr', Display::tag('td', $tab_string));
  1019. $tab_counter++;
  1020. }
  1021. }
  1022. ?>
  1023. <div class="actions">
  1024. <a href="<?php echo api_get_self(); ?>?action=insert_tabs"><?php Display::display_icon('addd.gif', get_lang('InsertLink')); echo get_lang('InsertLink'); ?></a>
  1025. </div>
  1026. <?php
  1027. echo '<table class="data_table">';
  1028. echo $link_list;
  1029. echo '</table>';
  1030. ?>
  1031. </td>
  1032. <td width="10%" valign="top"></td>
  1033. <td width="20%" rowspan="3" valign="top">
  1034. <div id="login_block" class="well sidebar-nav">
  1035. <?php echo api_display_language_form(); ?>
  1036. <form id="formLogin">
  1037. <div><label><?php echo get_lang('LoginName'); ?></label></div>
  1038. <div><input type="text" id="login" size="15" value="" disabled="disabled" /></div>
  1039. <div><label><?php echo get_lang('UserPassword'); ?></label></div>
  1040. <div><input type="password" id="password" size="15" value="" disabled="disabled" /></div>
  1041. <div><button class="btn btn-default" type="button" name="submitAuth" value="<?php echo get_lang('Ok'); ?>" disabled="disabled"><?php echo get_lang('Ok'); ?></button></div>
  1042. </form>
  1043. </div>
  1044. <div id="profile_block" class="well sidebar-nav">
  1045. <h4><?php echo get_lang('MenuUser'); ?></h4>
  1046. <ul class="nav nav-list">
  1047. <li><span style="color: #9D9DA1; font-weight: bold;"><?php echo api_ucfirst(get_lang('Registration')); ?></span></li>
  1048. <li><span style="color: #9D9DA1; font-weight: bold;"><?php echo api_ucfirst(get_lang('LostPassword')); ?></span></li>
  1049. </ul>
  1050. </div>
  1051. <div id="notice_block" class="well sidebar-nav">
  1052. <h4><?php echo get_lang('Notice'); ?>
  1053. <a href="<?php echo api_get_self(); ?>?action=edit_notice"><?php Display::display_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL); ?></a>
  1054. </h4>
  1055. <?php
  1056. $home_notice = '';
  1057. if (file_exists($homep.$noticef.'_'.$lang.$ext)) {
  1058. $home_notice = @(string)file_get_contents($homep.$noticef.'_'.$lang.$ext);
  1059. } else {
  1060. $home_notice = @(string)file_get_contents($homep.$noticef.$ext);
  1061. }
  1062. $home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice)));
  1063. echo '<div class="homepage_notice">';
  1064. echo $home_notice;
  1065. echo '</div>';
  1066. ?>
  1067. </div>
  1068. <div class="well sidebar-nav">
  1069. <a href="<?php echo api_get_self(); ?>?action=insert_link"><?php Display::display_icon('addd.gif', get_lang('InsertLink')); ?></a>
  1070. <a href="<?php echo api_get_self(); ?>?action=insert_link"><?php echo get_lang('InsertLink'); ?></a>
  1071. <h4><?php echo api_ucfirst(get_lang('General')); ?></h4>
  1072. <ul class="menulist">
  1073. <?php
  1074. $home_menu = '';
  1075. if (file_exists($homep.$menuf.'_'.$lang.$ext)) {
  1076. $home_menu = @file($homep.$menuf.'_'.$lang.$ext);
  1077. } else {
  1078. $home_menu = @file($homep.$menuf.$ext);
  1079. }
  1080. if (empty($home_menu)) {
  1081. $home_menu = array();
  1082. }
  1083. if (!empty($home_menu)) {
  1084. $home_menu = implode("\n", $home_menu);
  1085. $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
  1086. $home_menu = explode("\n", $home_menu);
  1087. }
  1088. $i = 0;
  1089. foreach ($home_menu as $enreg) {
  1090. $enreg = trim($enreg);
  1091. if (!empty($enreg)) {
  1092. $edit_link = '<a href="'.api_get_self().'?action=edit_link&amp;link_index='.$i.'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  1093. $delete_link = '<a href="'.api_get_self().'?action=delete_link&amp;link_index='.$i.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)).'\')) return false;">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
  1094. echo str_replace(array('href="'.api_get_path(WEB_PATH).'index.php?include=', '</li>'), array('href="'.api_get_path(WEB_CODE_PATH).'admin/'.basename(api_get_self()).'?action=open_link&link=', '<br />'.$edit_link.' '.$delete_link.'</li>'), $enreg);
  1095. $i++;
  1096. }
  1097. }
  1098. ?>
  1099. </ul>
  1100. </div>
  1101. </td>
  1102. </tr>
  1103. </table>
  1104. <?php
  1105. break;
  1106. }
  1107. Display::display_footer();