configure_homepage.php 52 KB

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