From 54447734f22fbf0f47b1156c55ec0422283ed6fc Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Mon, 13 Jul 2009 07:32:58 +0200 Subject: [PATCH] [svn r22018] FS#2867 -Admin tools, home page edition: Elimination of the global variable $fck_attribute. --- main/admin/configure_homepage.php | 187 ++++++------------ main/inc/lib/fckeditor/fckeditor.php | 12 +- main/inc/lib/fckeditor/myconfig.php | 2 +- .../lib/fckeditor/toolbars/edit_home_page.php | 2 +- .../fckeditor/toolbars/links_home_page.php | 2 +- 5 files changed, 63 insertions(+), 142 deletions(-) diff --git a/main/admin/configure_homepage.php b/main/admin/configure_homepage.php index 2f6bca8cee..cb5b61a3fa 100644 --- a/main/admin/configure_homepage.php +++ b/main/admin/configure_homepage.php @@ -1,4 +1,4 @@ - (sizeof($home_menu) - 1)) - { + if($insert_where < -1 || $insert_where > (sizeof($home_menu) - 1)) { $insert_where=sizeof($home_menu) - 1; } // For each line of the file, remove trailing spaces and special chars - foreach($home_menu as $key=>$enreg) - { + foreach($home_menu as $key=>$enreg) { $home_menu[$key]=trim($enreg); } // If the given link url is empty, then replace the link url by a link to the link file created - if(empty($link_url)) - { + if(empty($link_url)) { $link_url=api_get_path(WEB_PATH).'index.php?include='.urlencode($filename); // If the file doesn't exist, then create it and // fill it with default text - if(!file_exists(api_get_path(SYS_PATH).'home/'.$filename)) - { + if(!file_exists(api_get_path(SYS_PATH).'home/'.$filename)) { $fp=@fopen(api_get_path(SYS_PATH).'home/'.$filename,'w'); - if($fp) - { + if($fp) { fputs($fp,get_lang('MyTextHere')); fclose($fp); @@ -377,12 +357,10 @@ if(!empty($action)) } // If the requested action is to edit a link, open the file and // write to it (if the file doesn't exist, create it) - if($action == 'edit_link' && !empty($link_html)) - { + if($action == 'edit_link' && !empty($link_html)) { $fp=@fopen(api_get_path(SYS_PATH).'home/'.$filename,'w'); - if($fp) - { + if($fp) { fputs($fp,$link_html); fclose($fp); } @@ -390,16 +368,11 @@ if(!empty($action)) // If the requested action is to create a link, make some room // for the new link in the home_menu array at the requested place // and insert the new link there - if($action == 'insert_link') - { - for($i=sizeof($home_menu);$i;$i--) - { - if($i > $insert_where) - { + if($action == 'insert_link') { + for($i=sizeof($home_menu);$i;$i--) { + if($i > $insert_where) { $home_menu[$i]=$home_menu[$i-1]; - } - else - { + } else { break; } } @@ -440,8 +413,7 @@ if(!empty($action)) break; } //end of switch($action) - if(empty($errorMsg)) - { + if(empty($errorMsg)) { header('Location: '.api_get_self()); exit(); } @@ -459,14 +431,10 @@ if(!empty($action)) $home_menu=file($homep.$menuf.'_'.$lang.$ext); - foreach($home_menu as $key=>$enreg) - { - if($key == $link_index) - { + foreach($home_menu as $key=>$enreg) { + if($key == $link_index) { unset($home_menu[$key]); - } - else - { + } else { $home_menu[$key]=trim($enreg); } } @@ -577,15 +545,12 @@ if(!empty($action)) $link_url=''; // For each line of the home_menu file - foreach($home_menu as $key=>$enreg) - { + foreach($home_menu as $key=>$enreg) { // Check if the current item is the one we want to update - if($key == $link_index) - { + if($key == $link_index) { // This is the link we want to update // Check if the target should be "_blank" - if(strstr($enreg,'target="_blank"')) - { + if(strstr($enreg,'target="_blank"')) { $target_blank=true; } // Remove dangerous HTML tags from the link itself (this is an @@ -599,21 +564,17 @@ if(!empty($action)) // If the link contains the web root of this portal, then strip // it off and keep only the name of the file that needs edition - if(strstr($link_url,$_configuration['root_web']) && strstr($link_url,'?include=')) - { + if(strstr($link_url,$_configuration['root_web']) && strstr($link_url,'?include=')) { $link_url=explode('?include=',$link_url); $filename=$link_url[sizeof($link_url)-1]; - if(!strstr($filename,'/') && strstr($filename,'.html')) - { + if(!strstr($filename,'/') && strstr($filename,'.html')) { // Get oonly the contents of the link file $link_html=file(api_get_path(SYS_PATH).'home/'.$filename); $link_html=implode('',$link_html); $link_url=''; - } - else - { + } else { $filename=''; } } @@ -654,8 +615,7 @@ switch($action){ '; Display::display_normal_message($errorMsg); //echo ''; @@ -684,15 +644,10 @@ switch($action){ case 'insert_link': case 'edit_link': - if(!empty($errorMsg)) - { + if(!empty($errorMsg)) { Display::display_normal_message($errorMsg); //main API } - $fck_attribute['ToolbarSet'] = "LinksHomePage"; - $fck_attribute['Width'] = '100%'; - $fck_attribute['Height'] = '400'; - $default = array(); $form = new FormValidator('configure_homepage_'.$action, 'post', api_get_self().'?action='.$action, '', array('style' => 'margin: 0px;')); $renderer =& $form->defaultRenderer(); @@ -714,12 +669,10 @@ switch($action){ $form->addElement('text', 'link_url', get_lang('LinkName'), array('size' => '30', 'maxlength' => '100', 'style' => 'width: 350px;')); $form->addElement('html', ''); - if($action == 'insert_link') - { + if($action == 'insert_link') { $form->addElement('html', ''.get_lang('InsertThisLink').' :'); $form->addElement('html', ''); @@ -731,25 +684,19 @@ switch($action){ $form->addElement('html', ''); //if($action == 'edit_link' && empty($link_url)) - if ($action == 'edit_link' && (empty($link_url) || $link_url == 'http://')) - { + if ($action == 'edit_link' && (empty($link_url) || $link_url == 'http://')) { $form->addElement('html', ''); - } - else - { + } else { $form->addElement('html', ''); @@ -758,32 +705,22 @@ switch($action){ $form->setDefaults($default); $form->display(); - $fck_attribute = null; - break; case 'edit_top': case 'edit_news': - if($action == 'edit_top') - { + if($action == 'edit_top') { $name= $topf; $open = $home_top; - } - else - { + } else { $name = $newsf; $open=@file_get_contents($homep.$newsf.'_'.$lang.$ext); } - if(!empty($errorMsg)) - { + if(!empty($errorMsg)) { Display::display_normal_message($errorMsg); //main API } - $fck_attribute['ToolbarSet'] = "EditHomePage"; - $fck_attribute['Width'] = '100%'; - $fck_attribute['Height'] = '400'; - $default = array(); $form = new FormValidator('configure_homepage_'.$action, 'post', api_get_self().'?action='.$action, '', array('style' => 'margin: 0px;')); $renderer =& $form->defaultRenderer(); @@ -809,25 +746,21 @@ switch($action){ $html .= ''; $form->addElement('html', $html); } - if (api_get_setting('wcag_anysurfer_public_pages')=='true') - { + if (api_get_setting('wcag_anysurfer_public_pages')=='true') { //TODO: review these lines // Print WCAG-specific HTML editor $html = '
'); $form->addElement('html', '
'); - if (api_get_setting('wcag_anysurfer_public_pages')=='true') - { + if (api_get_setting('wcag_anysurfer_public_pages')=='true') { $form->addElement('html', WCAG_Rendering::create_xhtml(isset($_POST['link_html'])?$_POST['link_html']:$link_html)); - } - else - { + } else { $default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : $link_html; - $form->add_html_editor('link_html', ''); + $form->add_html_editor('link_html', '', true, false, array('ToolbarSet' => 'LinksHomePage', 'Width' => '100%', 'Height' => '400')); } $form->addElement('html', '
'); $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); $form->addElement('html', '
 '); $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); $form->addElement('html', '
'; - //$html .= '