diff --git a/e107_admin/ad_links.php b/e107_admin/ad_links.php index f94078d91..39b172f5b 100644 --- a/e107_admin/ad_links.php +++ b/e107_admin/ad_links.php @@ -9,8 +9,8 @@ * Admin Navigation * * $Source: /cvs_backup/e107_0.8/e107_admin/ad_links.php,v $ - * $Revision: 1.18 $ - * $Date: 2009-09-18 23:13:59 $ + * $Revision: 1.19 $ + * $Date: 2009-11-07 11:20:25 $ * $Author: e107coders $ */ @@ -558,7 +558,7 @@ $array_functions = array( 8 => array(e_ADMIN.'emoticon.php', ADLAN_58, ADLAN_59, 'F', 1, E_16_EMOTE, E_32_EMOTE), 9 => array(e_ADMIN.'filemanager.php', ADLAN_30, ADLAN_31, '6', 5, E_16_FILE, E_32_FILE), 10 => array(e_ADMIN.'frontpage.php', ADLAN_60, ADLAN_61, 'G', 1, E_16_FRONT, E_32_FRONT), - 11 => array(e_ADMIN.'image.php', ADLAN_105, ADLAN_106, 'A', 1, E_16_IMAGES, E_32_IMAGES), + 11 => array(e_ADMIN.'image.php', LAN_MEDIAMANAGER, ADLAN_106, 'A', 5, E_16_IMAGES, E_32_IMAGES), 12 => array(e_ADMIN.'links.php', ADLAN_138, ADLAN_139, 'I', 1, E_16_LINKS, E_32_LINKS), 13 => array(e_ADMIN.'wmessage.php', ADLAN_28, ADLAN_29, 'M', 3, E_16_WELCOME, E_32_WELCOME), 14 => array(e_ADMIN.'ugflag.php', ADLAN_40, ADLAN_41, '9', 4, E_16_MAINTAIN, E_32_MAINTAIN), diff --git a/e107_admin/comment.php b/e107_admin/comment.php index 06d098cb0..e3b1431d1 100644 --- a/e107_admin/comment.php +++ b/e107_admin/comment.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/comment.php,v $ -| $Revision: 1.13 $ -| $Date: 2009-11-06 18:37:23 $ -| $Author: secretr $ +| $Revision: 1.14 $ +| $Date: 2009-11-07 11:20:26 $ +| $Author: e107coders $ +----------------------------------------------------------------------------+ */ require_once("../class2.php"); @@ -78,20 +78,20 @@ class comments_admin_ui extends e_admin_ui //TODO - finish 'user' type, set 'data' to all editable fields, set 'noedit' for all non-editable fields protected $fields = array( - 'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), - 'comment_id' => array('title'=> ID, 'type' => 'int', 'width' =>'5%', 'forced'=> TRUE), - 'comment_item_id' => array('title'=> "item id", 'type' => 'text', 'width' => 'auto'), - 'comment_subject' => array('title'=> "subject", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first'), // Display name - 'comment_comment' => array('title'=> "comment", 'type' => 'textarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'), // Display name - 'comment_author_id' => array('title'=> "authorID", 'type' => 'user', 'data' => 'int', 'width' => 'auto'), // User id - 'comment_author_name' => array('title'=> "authorName",'type' => 'text', 'width' => 'auto'), // User name - 'user_name' => array('title'=> "System user", 'type' => 'text', 'width' => 'auto', 'table' => 'user', 'noedit' => true), // User name - 'comment_datestamp' => array('title'=> "datestamp", 'type' => 'datestamp', 'width' => 'auto'), // User date - 'comment_blocked' => array('title'=> "blocked", 'type' => 'boolean', 'data'=> 'int', 'filter' => true, 'batch' => true, 'width' => 'auto'), // Photo - 'comment_ip' => array('title'=> "IP", 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), // Real name (no real vetting) - 'comment_type' => array('title'=> "Type", 'type' => 'method', 'width' => '10%', 'thclass' => 'center', 'filter'=>TRUE,'batch'=>TRUE ), // No real vetting - 'comment_lock' => array('title'=> "Lock", 'type' => 'boolean', 'data'=> 'int', 'filter' => true, 'batch' => true, 'width' => 'auto'), - 'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center') + 'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), + 'comment_id' => array('title'=> ID, 'type' => 'int', 'width' =>'5%', 'forced'=> TRUE), + 'comment_item_id' => array('title'=> "item id", 'type' => 'text', 'width' => '5%'), + 'comment_subject' => array('title'=> "subject", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first'), // Display name + 'comment_comment' => array('title'=> "comment", 'type' => 'textarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'), // Display name + 'comment_author_id' => array('title'=> "authorID", 'type' => 'user', 'data' => 'int', 'width' => 'auto'), // User id + 'comment_author_name' => array('title'=> "authorName", 'type' => 'text', 'width' => 'auto'), // User name + 'user_name' => array('title'=> "System user", 'type' => 'text', 'width' => 'auto', 'table' => 'user', 'noedit' => true), // User name + 'comment_datestamp' => array('title'=> "datestamp", 'type' => 'datestamp', 'width' => 'auto'), // User date + 'comment_blocked' => array('title'=> "blocked", 'type' => 'boolean', 'data'=> 'int', 'thclass' => 'center', 'class'=>'center', 'filter' => true, 'batch' => true, 'width' => 'auto'), // Photo + 'comment_ip' => array('title'=> "IP", 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), // Real name (no real vetting) + 'comment_type' => array('title'=> "Type", 'type' => 'method', 'width' => '10%', 'filter'=>TRUE,'batch'=>TRUE ), // No real vetting + 'comment_lock' => array('title'=> "Lock", 'type' => 'boolean', 'data'=> 'int', 'thclass' => 'center', 'class'=>'center', 'filter' => true, 'batch' => true, 'width' => 'auto'), + 'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center') ); //required (but should be optional) - default column user prefs protected $fieldpref = array('checkboxes', 'comment_id', 'comment_item_id', 'comment_author_id', 'comment_author_name', 'comment_subject', 'comment_comment', 'comment_type', 'options'); @@ -132,7 +132,8 @@ class comments_admin_form_ui extends e_admin_form_ui if($mode == 'batch') { $types = e107::getComment()->known_types; - // sort($types); + asort($types); + return $types; } } diff --git a/e107_admin/image.php b/e107_admin/image.php index e829b2c60..1b739381f 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -9,8 +9,8 @@ * Image Administration Area * * $Source: /cvs_backup/e107_0.8/e107_admin/image.php,v $ - * $Revision: 1.25 $ - * $Date: 2009-11-07 02:10:34 $ + * $Revision: 1.26 $ + * $Date: 2009-11-07 11:20:26 $ * $Author: e107coders $ * */ @@ -21,17 +21,6 @@ if (!getperms("A")) exit; } -include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE); - -$e_sub_cat = 'image'; - -require_once("auth.php"); -require_once(e_HANDLER."form_handler.php"); -require_once(e_HANDLER."userclass_class.php"); -require_once(e_HANDLER."message_handler.php"); -$frm = new e_form(); //new form handler -$emessage = &eMessage::getInstance(); - /* * CLOSE - GO TO MAIN SCREEN */ @@ -41,6 +30,127 @@ if(isset($_POST['submit_cancel_show'])) exit(); } +include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE); + +$e_sub_cat = 'image'; + +// require_once("auth.php"); +// require_once(e_HANDLER."form_handler.php"); +require_once(e_HANDLER."userclass_class.php"); +require_once(e_HANDLER."message_handler.php"); +// $frm = new e_form(); //new form handler +$emessage = &eMessage::getInstance(); + +class media_admin extends e_admin_dispatcher +{ + + protected $modes = array( + 'main' => array( + 'controller' => 'media_admin_ui', + 'path' => null, + 'ui' => 'comments_admin_form_ui', + 'uipath' => null + ) + ); + + + protected $adminMenu = array( + 'main/list' => array('caption'=> 'Media Library', 'perm' => 'A'), + 'main/create' => array('caption'=> "Add New Media", 'perm' => 'A'), + 'main/icons' => array('caption'=> IMALAN_71, 'perm' => 'A'), + 'main/settings' => array('caption'=> LAN_PREFS, 'perm' => 'A'), + 'main/avatars' => array('caption'=> IMALAN_23, 'perm' => 'A') + ); + +/* + $var['main']['text'] = IMALAN_7; + $var['main']['link'] = e_SELF; + + $var['icons']['text'] = IMALAN_71; + $var['icons']['link'] = e_SELF."?icons"; + + $var['avatars']['text'] = IMALAN_23; + $var['avatars']['link'] = e_SELF."?avatars"; + + + $var['editor']['text'] = "Image Manipulation (future release)"; + $var['editor']['link'] = e_SELF."?editor";*/ + + protected $adminMenuAliases = array( + 'main/edit' => 'main/list' + ); + + protected $menuTitle = LAN_MEDIAMANAGER; +} + + +class media_admin_ui extends e_admin_ui +{ + + protected $pluginTitle = LAN_MEDIAMANAGER; + protected $pluginName = 'core'; + protected $table = "core_media"; + + protected $listQry = "SELECT * FROM #core_media"; // without any Order or Limit. + + // //protected $editQry = "SELECT * FROM #comments WHERE comment_id = {ID}"; + + protected $pid = "media_id"; + protected $perPage = 10; + protected $batchDelete = true; + + //TODO - finish 'user' type, set 'data' to all editable fields, set 'noedit' for all non-editable fields + protected $fields = array( + 'checkboxes' => array('title'=> '', 'type' => null, 'data'=> null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), + 'media_id' => array('title'=> ID, 'type' => 'int', 'data'=> 'int', 'width' =>'5%', 'forced'=> TRUE), + 'media_preview' => array('title'=> "Preview", 'type' => null, 'data'=> null, 'width' => '10%'), // Generate on the fly. + 'media_upload' => array('title'=> "Upload File", 'type' => 'upload', 'data'=> null, 'readParm' => 'hidden', 'width' => '10%'), // Generate on the fly. + 'media_title' => array('title'=> "Title", 'type' => 'text', 'data'=> 'str', 'width' => '5%'), + 'media_caption' => array('title'=> "Caption", 'type' => 'text', 'data'=> 'str', 'width' => '5%'), + 'media_description' => array('title'=> "Description", 'type' => 'textarea', 'data'=> 'str', 'width' => 'auto', 'thclass' => 'left first'), // Display name + 'media_category' => array('title'=> "Category", 'type' => 'int', 'data'=> 'int', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'), // Display name + 'media_datestamp' => array('title'=> "datestamp", 'type' => 'datestamp', 'data'=> 'int', 'width' => 'auto'), // User date + 'media_url' => array('title'=> "URL", 'type' => 'url', 'data'=> 'str', 'thclass' => 'center', 'class'=>'center', 'filter' => true, 'batch' => true, 'width' => 'auto'), // Photo + 'media_userclass' => array('title'=> "Userclass", 'type' => 'userclass', 'data'=> 'str', 'width' => '10%', 'thclass' => 'center' ), // Real name (no real vetting) + 'media_tags' => array('title'=> "Tags/Keywords", 'type' => 'text', 'data'=> 'str', 'width' => '10%', 'filter'=>TRUE,'batch'=>TRUE ), // No real vetting + 'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'data'=> null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center') + ); + + + protected $fieldpref = array('checkboxes', 'media_id', 'media_thumb', 'media_title', 'media_caption', 'media_description', 'media_category', 'media_datestamp','media_userclass', 'options'); + + + /* + protected $prefs = array( + 'pref_type' => array('title'=> 'type', 'type'=>'text'), + 'pref_folder' => array('title'=> 'folder', 'type' => 'boolean'), + 'pref_name' => array('title'=> 'name', 'type' => 'text') + );*/ + +} + + +new media_admin(); + +require_once(e_ADMIN."auth.php"); + +e107::getAdminUI()->runPage(); + + + + + + + + + + + +// ----------------------------------------------------------------------- + + + + $action = e_QUERY; @@ -49,17 +159,17 @@ if(isset($_POST['delpref']) || (isset($_POST['delpref_checked']) && isset($_POST del_pref_val(); } -if($action == "icons") +if($_GET['action'] == "icons") { icon_editor(); } -if($action == "avatars") +if($_GET['action'] == "avatars") { show_avatars(); } -if($action !='avatars' && $action !='icons') +if($_GET['action'] == 'settings') { main_config(); } @@ -243,9 +353,15 @@ if (isset($_POST['update_options'])) */ function show_avatars() { - global $ns, $sql, $frm, $tp, $emessage, $e107, $pref; + global $e107, $pref; + + $ns = e107::getRender(); + $sql = e107::getDb(); + $frm = e107::getForm(); + $tp = e107::getParser(); + $mes = e107::getMessage(); - $handle = opendir(e_UPLOAD."avatars/"); + $handle = opendir(e_UPLOAD."avatars/"); //TODO replace with $fl $dirlist = array(); while ($file = readdir($handle)) { @@ -348,7 +464,7 @@ function show_avatars() } - $ns->tablerender(LAN_IMAGEMANAGER." :: ".IMALAN_18, $emessage->render().$text); + $ns->tablerender(LAN_IMAGEMANAGER." :: ".IMALAN_18, $mes->render().$text); } /* @@ -531,7 +647,14 @@ if (isset($_POST['check_avatar_sizes'])) */ function main_config() { - global $pref, $frm, $tp, $sql, $ns, $emessage; + global $pref; + + $frm = e107::getForm(); + $tp = e107::getParser(); + $sql = e107::getDb(); + $ns = e107::getRender(); + $mes = e107::getMessage(); + if(function_exists('gd_info')) { $gd_info = gd_info(); @@ -650,7 +773,7 @@ if (isset($_POST['check_avatar_sizes'])) "; - $ns->tablerender(LAN_IMAGEMANAGER." :: ".IMALAN_7, $emessage->render().$text); + $ns->tablerender(LAN_IMAGEMANAGER." :: ".IMALAN_7, $mes->render().$text); } //Just in case... if(!e_AJAX_REQUEST) require_once("footer.php"); @@ -660,10 +783,12 @@ if(!e_AJAX_REQUEST) require_once("footer.php"); function icon_editor() { - global $iconpool, $e107, $emessage, $frm, $tp; + global $iconpool, $e107; $ns = e107::getRender(); $tp = e107::getParser(); + $frm = e107::getForm(); + $mes = e107::getMessage(); ksort($iconpool); @@ -738,7 +863,7 @@ function icon_editor() "; //$text .= "
".DBLAN_13."
\n"; - $ns->tablerender(LAN_IMAGEMANAGER." :: ".IMALAN_71, $emessage->render().$text); + $ns->tablerender(LAN_IMAGEMANAGER." :: ".IMALAN_71, $mes->render().$text); return $text; } @@ -776,29 +901,6 @@ function del_pref_val() } -function image_adminmenu() -{ - global $action; - if($action == "") - { - $action = "main"; - } - $var['main']['text'] = IMALAN_7; - $var['main']['link'] = e_SELF; - - $var['icons']['text'] = IMALAN_71; - $var['icons']['link'] = e_SELF."?icons"; - - $var['avatars']['text'] = IMALAN_23; - $var['avatars']['link'] = e_SELF."?avatars"; - - - $var['editor']['text'] = "Image Manipulation (future release)"; - $var['editor']['link'] = e_SELF."?editor"; - - - e_admin_menu(LAN_IMAGEMANAGER, $action, $var); -} diff --git a/e107_admin/language.php b/e107_admin/language.php index 7005aea52..e4a45b6ce 100644 --- a/e107_admin/language.php +++ b/e107_admin/language.php @@ -9,8 +9,8 @@ * Administration Area - Languages * * $Source: /cvs_backup/e107_0.8/e107_admin/language.php,v $ - * $Revision: 1.23 $ - * $Date: 2009-11-05 08:07:48 $ + * $Revision: 1.24 $ + * $Date: 2009-11-07 11:20:27 $ * $Author: e107coders $ * */ @@ -149,6 +149,13 @@ if (isset($_POST['create_tables']) && $_POST['language']) } */ + + + + + + + unset($text); if (!e_QUERY || $action == 'main' && !$_POST['language'] && !$_POST['edit_existing']) @@ -175,8 +182,56 @@ if (varset($_POST['ziplang']) && varset($_POST['language'])) if (varset($action) == "tools") { show_tools(); - e107::getRender()->tablerender(LANG_LAN_34, available_langpacks()); + if($languagePacks = available_langpacks() ) + { + e107::getRender()->tablerender(LANG_LAN_34,$languagePacks ); + } } + +if(varset($_POST['searchDeprecated']) && varset($_POST['deprecatedLans'])) +{ + $mes = e107::getMessage(); + + $lanfile = $_POST['deprecatedLans']; + + + $scriptname = str_replace("lan_","",basename($lanfile)); + + if(is_readable(e_ADMIN.$script)) + { + $script = e_ADMIN.$scriptname; // matching files. lan_xxxx.php and xxxx.php + } + + // Exceptions - same language loaded by several scripts. + if($lanfile == e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_e107_update.php") + { + $script = e_ADMIN."update_routines.php,".e_ADMIN."e107_update.php"; + } + + if(is_readable($lanfile)) + { + if($res = unused($lanfile,$script)) + { + $ns -> tablerender($res['caption'],$mes->render(). $res['text']); + } + } + else + { + // echo 'PROBLEM'; + } + + +} + + + + + + + + + + //FIX - create or edit check if (isset($_POST['create_edit_existing'])) $_POST['edit_existing'] = true; @@ -495,7 +550,9 @@ function multilang_db() function show_tools() { - global $emessage; + $frm = e107::getForm(); + $mes = e107::getMessage(); + include_lan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_lancheck.php"); $text = "
@@ -564,7 +621,33 @@ function show_tools() Check to share your language-pack with the e107 community. - + "; + + + $text .= " + + Search for Deprecated Lans + + ".$frm->admin_button('searchDeprecated',"Check")." + + "; + + + $text .= " @@ -573,7 +656,7 @@ function show_tools() - e107::getRender()->tablerender(LANG_LAN_PAGE_TITLE.' - '.LANG_LAN_21, $emessage->render().$text); + e107::getRender()->tablerender(LANG_LAN_PAGE_TITLE.' - '.LANG_LAN_21, $mes->render().$text); } @@ -588,6 +671,11 @@ function available_langpacks() if($rawData = $xml -> loadXMLfile($feed, TRUE)) { + if(!varset($rawData['language'])) + { + return FALSE; + } + $text .= "
".LANG_LAN_35."
"; $text .= ""; foreach($rawData['language'] as $val) @@ -754,6 +842,184 @@ function grab_lans($path, $language, $filter = "") } return $pzip; } + + +// ----------------------- + + +/** + * Compare Language File against script and find unused LANs + * @param object $lanfile + * @param object $script + * @return + */ +function unused($lanfile,$script) +{ + $lanDefines = file_get_contents($lanfile); + + $tmp = explode(",",$script); + foreach($tmp as $scr) + { + $compare[$scr] = file_get_contents($scr); + } + + + $mes = e107::getMessage(); + + if(!$compare) + { + $mes = e107::getMessage(); + $mes->add("Couldn't read ".$script, E_MESSAGE_ERROR); + } + + if(!$lanDefines) + { + $mes = e107::getMessage(); + $mes->add("Couldn't read ".$lanfile, E_MESSAGE_ERROR); + } + + + $srch = array(""); + $lanDefines = str_replace($srch,"",$lanDefines); + $lanDefines = explode("\n", $lanDefines); + + if($lanDefines && $compare) + { + + $text = "
+ + + "; + + foreach($compare as $k=>$val) + { + $text .= ""; + } + $text .= " + + + "; + + // for ($i=0; $i$match[1],'value'=>$match[2]); + } + +} + + + +function compareit($needle,$haystack,$value='',$disabled){ + + +// return "Need=".$needle."
hack=".$haystack."
val=".$val; + //TODO Move this into a separate function (use a class for this whole script) + + $commonPhrases = file_get_contents(e_LANGUAGEDIR."English/admin/lan_admin.php"); + $commonLines = explode("\n",$commonPhrases); + + foreach($commonLines as $line) + { + if($match = getDefined($line)) + { + $id = $match['define']; + $ar[$id] = $match['value']; + } + } + + // Check if a common phrases was used. + foreach($ar as $def=>$common) + { + if(strtoupper(trim($value)) == strtoupper($common)) + { + //$text .= "
$common
"; + $foundCommon = TRUE; + break; + } + } + + + + foreach($haystack as $script) + { + $lines = explode("\n",$script); + + $text .= "
"; + + } + + $color = $found ? "" : "background-color:pink"; + + if($foundCommon && $found) + { + $color = "background-color:yellow"; + $disabled .= "
".$common." is a common phrase.
(Use ".$def." instead.)"; + // return ""; + } + + return "".$text.""; +} + + + + + + + /** * Handle page DOM within the page header * @@ -761,6 +1027,17 @@ function grab_lans($path, $language, $filter = "") */ + + + + + + + + + + + function headerjs() { //FIXME breaking functionality. diff --git a/e107_admin/sql/core_sql.php b/e107_admin/sql/core_sql.php index 8ed9272b2..11bf45d3f 100644 --- a/e107_admin/sql/core_sql.php +++ b/e107_admin/sql/core_sql.php @@ -9,8 +9,8 @@ * Core SQL * * $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $ - * $Revision: 1.33 $ - * $Date: 2009-11-06 11:53:20 $ + * $Revision: 1.34 $ + * $Date: 2009-11-07 11:20:28 $ * $Author: e107coders $ */ @@ -119,6 +119,26 @@ CREATE TABLE core ( ) TYPE=MyISAM; # -------------------------------------------------------- +# +# Table structure for table `core_media` - media manager +# + +CREATE TABLE core_media ( + media_id int(10) unsigned NOT NULL auto_increment, + media_caption varchar(255) NOT NULL default '', + media_description varchar(255) NOT NULL default '', + media_category int(10) unsigned NOT NULL default '0', + media_datestamp int(10) unsigned NOT NULL default '0', + media_url varchar(255) NOT NULL default '', + media_userclass varchar(255) NOT NULL default '', + media_tags text NOT NULL, + PRIMARY KEY (media_id) +) TYPE=MyISAM; + + + + + # # Table structure for table `dblog` - db/debug/rolling # diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index 009f01790..3b6a55ce3 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $ -| $Revision: 1.57 $ -| $Date: 2009-11-04 03:37:56 $ +| $Revision: 1.58 $ +| $Date: 2009-11-07 11:20:27 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -254,7 +254,7 @@ function update_706_to_800($type='') // List of DB tables newly required (defined in core_sql.php) (The existing dblog table gets renamed) - $new_tables = array('admin_log','audit_log', 'dblog','news_rewrite'); + $new_tables = array('admin_log','audit_log', 'dblog','news_rewrite', 'core_media'); // List of core prefs that need to be converted from serialized to e107ArrayStorage. $serialized_prefs = array("'emote'", "'menu_pref'", "'search_prefs'", "'emote_default'"); @@ -346,14 +346,9 @@ function update_706_to_800($type='') $s_prefs = $tp -> toDB($notify_prefs); $s_prefs = $eArrayStorage -> WriteArray($s_prefs); // Could we use $sysprefs->set($s_prefs,'notify_prefs') instead - avoids caching problems ???? - if ($sql -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'") === FALSE) - { - $updateMessages[] = LAN_UPDATE_21; // Log error - } - else - { - $updateMessages[] = str_replace('--COUNT--',$nt_changed,LAN_UPDATE_20); // Log success - } + $status = ($sql -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'") === FALSE) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $message = str_replace('--COUNT--',$nt_changed,LAN_UPDATE_20); + $mes->add($message, $status); } @@ -363,7 +358,7 @@ function update_706_to_800($type='') if ($just_check) return update_needed(); $pref['signup_option_customtitle'] = $pref['forum_user_customtitle']; unset($pref['forum_user_customtitle']); - $updateMessages[] = LAN_UPDATE_22; + $mes->add(LAN_UPDATE_20.'customtitle', E_MESSAGE_SUCCESS); $do_save = TRUE; } @@ -375,8 +370,8 @@ function update_706_to_800($type='') if ($just_check) return update_needed(); while ($row = e107::getDb()->db_Fetch(MYSQL_ASSOC)) { - e107::getDb('sql2')->db_Update('core',"e107_value=\"".convert_serialized($row['e107_value'])."\" WHERE e107_name='".$row['e107_name']."'"); - $updateMessages[] = "Converted Serialized prefs [".$row['e107_name']."]"; // LAN_UPDATE_23; + $status = e107::getDb('sql2')->db_Update('core',"e107_value=\"".convert_serialized($row['e107_value'])."\" WHERE e107_name='".$row['e107_name']."'"); + $mes->add(LAN_UPDATE_22.$row['e107_name'], $status); } } @@ -392,8 +387,8 @@ function update_706_to_800($type='') { if ($just_check) return update_needed('Menu path changed required: '.$val['menu'].' '); $updqry = "menu_path='".$val['newpath']."/' WHERE menu_name = '".$val['menu']."' AND (menu_path='".$val['oldpath']."' || menu_path='".$val['oldpath']."/' ) "; - $sql->db_Update("menus", $updqry); - $mes->add('Updating Menu Path for '.$val['menu'].' from '.$val['oldpath'].' => '.$val['newpath'], E_MESSAGE_DEBUG); // LAN_UPDATE_25; + $status = $sql->db_Update("menus", $updqry) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $mes->add(LAN_UPDATE_23.''.$val['menu'].' : '.$val['oldpath'].' => '.$val['newpath'], $status); // LAN_UPDATE_25; // catch_error(); } } @@ -410,14 +405,14 @@ function update_706_to_800($type='') //if online_extended is activated, we need to activate the new 'online' menu, and delete this record if($row['menu_location']!=0) { - $sql->db_Update("menus", "menu_name='online_menu', menu_path='online/' WHERE menu_path='online_extended_menu' || menu_path='online_extended_menu/' "); - $updateMessages[] = LAN_UPDATE_30; + $status = $sql->db_Update("menus", "menu_name='online_menu', menu_path='online/' WHERE menu_path='online_extended_menu' || menu_path='online_extended_menu/' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $mes->add(LAN_UPDATE_23."online_menu : online/", $status); } else { //else if the menu is not active //we need to delete the online_extended menu row, and change the online_menu to online $sql->db_Delete("menus", " menu_path='online_extended_menu' || menu_path='online_extended_menu/' "); - $updateMessages[] = LAN_UPDATE_31; + // $updateMessages[] = LAN_UPXXDATE_31; } catch_error(); } @@ -426,8 +421,8 @@ function update_706_to_800($type='') if($sql->db_Select("menus", "menu_path", "menu_path='online_menu' || menu_path='online_menu/'")) { if ($just_check) return update_needed(); - $sql->db_Update("menus", "menu_path='online/' WHERE menu_path='online_menu' || menu_path='online_menu/' "); - $updateMessages[] = LAN_UPDATE_32; + $status = $sql->db_Update("menus", "menu_path='online/' WHERE menu_path='online_menu' || menu_path='online_menu/' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $mes->add(LAN_UPDATE_23."online_menu : online/", $status); catch_error(); } @@ -438,32 +433,35 @@ function update_706_to_800($type='') if($sql->db_Field("comments","comment_author")) { if ($just_check) return update_needed('Comment table author field update'); - $commentMessage = LAN_UPDATE_33; + if ((!$sql->db_Field("comments","comment_author_id")) // Check to see whether new fields already added - maybe data copy failed part way through && (!$sql->db_Select_gen("ALTER TABLE `#comments` ADD COLUMN comment_author_id int(10) unsigned NOT NULL default '0' AFTER `comment_author`, ADD COLUMN comment_author_name varchar(100) NOT NULL default '' AFTER `comment_author_id`"))) { // Flag error - $commentMessage = LAN_UPDATE_34; + // $commentMessage = LAN_UPDAXXTE_34; + $mes->add(LAN_UPDATE_21."comments", E_MESSAGE_ERROR); } else { if (FALSE ===$sql->db_Update("comments","comment_author_id=SUBSTRING_INDEX(`comment_author`,'.',1), comment_author_name=SUBSTRING(`comment_author` FROM POSITION('.' IN `comment_author`)+1)")) { // Flag error - $commentMessage = LAN_UPDATE_35; + $mes->add(LAN_UPDATE_21."comments", E_MESSAGE_ERROR); } else { // Delete superceded field - comment_author if (!$sql->db_Select_gen("ALTER TABLE `#comments` DROP COLUMN `comment_author`")) { // Flag error - $commentMessage = LAN_UPDATE_36; + $mes->add(LAN_UPDATE_24."comments - comment_author", E_MESSAGE_ERROR); } } } - $updateMessages[] = $commentMessage; // Hopefully this will usually add the 'success' message + + $mes->add(LAN_UPDATE_21."comments", E_MESSAGE_SUCCESS); + } @@ -501,7 +499,8 @@ function update_706_to_800($type='') if ($just_check) return update_needed('Change front page prefs'); $pref['frontpage_force'] = array(e_UC_PUBLIC => ''); $pref['frontpage'] = array(e_UC_PUBLIC => 'news.php'); - $updateMessages[] = LAN_UPDATE_38; + // $_pdateMessages[] = LAN_UPDATE_38; //FIXME + $mes->add(LAN_UPDATE_20."frontpage",E_MESSAGE_SUCCESS); $do_save = TRUE; } @@ -514,14 +513,15 @@ function update_706_to_800($type='') if (str_replace('varchar', 'char', strtolower($row['Type'])) != 'char(250)') { if ($just_check) return update_needed('Update newsfeed field definition'); - $sql->db_Select_gen("ALTER TABLE `".MPREFIX."newsfeed` MODIFY `newsfeed_url` VARCHAR(250) NOT NULL DEFAULT '' "); - $updateMessages[] = LAN_UPDATE_40; - catch_error(); + $status = $sql->db_Select_gen("ALTER TABLE `".MPREFIX."newsfeed` MODIFY `newsfeed_url` VARCHAR(250) NOT NULL DEFAULT '' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $updateMessages[] = LAN_UPDATE_40; //FIXME + $mes->add(LAN_UPDATE_21."newsfeed",$status); + // catch_error(); } } } - + //TODO use generic function for this update. if ($sql->db_Table_exists('download')) { // Need to extend field download_url varchar(255) NOT NULL default '' if ($sql -> db_Query("SHOW FIELDS FROM ".MPREFIX."download LIKE 'download_url'")) @@ -531,12 +531,13 @@ function update_706_to_800($type='') { if ($just_check) return update_needed('Update download table field definition'); $sql->db_Select_gen("ALTER TABLE `".MPREFIX."download` MODIFY `download_url` VARCHAR(255) NOT NULL DEFAULT '' "); - $updateMessages[] = LAN_UPDATE_52; + $updateMessages[] = LAN_UPDATE_52; //FIXME catch_error(); } } } + //TODO use generic function for this update. if ($sql->db_Table_exists('download_mirror')) { // Need to extend field download_url varchar(255) NOT NULL default '' if ($sql->db_Select_gen("SHOW FIELDS FROM ".MPREFIX."download_mirror LIKE 'mirror_url'")) @@ -546,7 +547,7 @@ function update_706_to_800($type='') { if ($just_check) return update_needed('Update download mirror table field definition'); $sql->db_Select_gen("ALTER TABLE `".MPREFIX."download_mirror` MODIFY `mirror_url` VARCHAR(255) NOT NULL DEFAULT '' "); - $updateMessages[] = LAN_UPDATE_53; + $updateMessages[] = LAN_UPDATE_53; //FIXME catch_error(); } } @@ -561,7 +562,7 @@ function update_706_to_800($type='') if ($just_check) return update_needed('Move user timezone info'); if (!copy_user_timezone()) { // Error doing the transfer - $updateMessages[] = LAN_UPDATE_42; + $updateMessages[] = LAN_UPDATE_42; //FIXME return FALSE; } $updateMessages[] = LAN_UPDATE_41; @@ -576,19 +577,19 @@ function update_706_to_800($type='') if ($just_check) return update_needed('Rename dblog to admin_log'); $sql->db_Select_gen('ALTER TABLE `'.MPREFIX.'dblog` RENAME `'.MPREFIX.'admin_log`'); catch_error(); - $updateMessages[] = LAN_UPDATE_43; + $updateMessages[] = LAN_UPDATE_43; //FIXME } + // Next bit will be needed only by the brave souls who used an early CVS - probably delete before release if ($sql->db_Table_exists('rl_history') && !$sql->db_Table_exists('dblog')) { if ($just_check) return update_needed('Rename rl_history to dblog'); $sql->db_Select_gen('ALTER TABLE `'.MPREFIX.'rl_history` RENAME `'.MPREFIX.'dblog`'); - $updateMessages[] = LAN_UPDATE_44; + $updateMessages[] = LAN_UPDATE_44; //FIXME catch_error(); } - - + // New tables required (list at top. Definitions in core_sql.php) foreach ($new_tables as $nt) { @@ -597,15 +598,16 @@ function update_706_to_800($type='') if ($just_check) return update_needed("Add table: ".$nt); // Get the definition $defs = $db_parser->get_table_def($nt,e_ADMIN."sql/core_sql.php"); - if (count($defs)) - { // **** Add in table here - $sql->db_Select_gen('CREATE TABLE `'.MPREFIX.$defs[0][1].'` ('.$defs[0][2].') TYPE='.$defs[0][3]); - $updateMessages[] = LAN_UPDATE_45.$defs[0][1]; - catch_error(); + if (count($defs)) // **** Add in table here + { + $status = $sql->db_Select_gen('CREATE TABLE `'.MPREFIX.$defs[0][1].'` ('.$defs[0][2].') TYPE='.$defs[0][3]) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + // $updateMessages[] = LAN_UPDATE_45.$defs[0][1]; + $mes->add(LAN_UPDATE_27.$defs[0][1], $status); //TODO - all update messages should work like this. + // catch_error(); } else { // error parsing defs file - $updateMessages[] = LAN_UPDATE_46.$defs[0][1]; + $mes->add(LAN_UPDATE_46.$defs[0][1], E_MESSAGE_ERROR); } unset($defs); } @@ -619,29 +621,45 @@ function update_706_to_800($type='') { $req_defs = $db_parser->get_table_def($ct,e_ADMIN."sql/core_sql.php"); $req_fields = $db_parser->parse_field_defs($req_defs[0][2]); // Required definitions - if ($debugLevel) echo "Required table structure:
".$db_parser->make_field_list($req_fields); + if ($debugLevel) + { + $mes->add("Required table structure:
".$db_parser->make_field_list($req_fields), E_MESSAGE_DEBUG); + } if ((($actual_defs = $db_parser->get_current_table($ct)) === FALSE) || !is_array($actual_defs)) // Adds current default prefix { - echo "Couldn't get table structure: {$ct}
"; + $mes->add("Couldn't get table structure: ".$ct, E_MESSAGE_DEBUG); } else { // echo $db_parser->make_table_list($actual_defs); $actual_fields = $db_parser->parse_field_defs($actual_defs[0][2]); - if ($debugLevel) echo "Actual table structure:
".$db_parser->make_field_list($actual_fields); + if ($debugLevel) + { + $mes->add("Actual table structure:
".$db_parser->make_field_list($actual_fields), E_MESSAGE_DEBUG); + } $diffs = $db_parser->compare_field_lists($req_fields,$actual_fields); if (count($diffs[0])) { // Changes needed - if ($just_check) return update_needed("Field changes rqd; table: ".$ct); - // Do the changes here - if ($debugLevel) echo "List of changes found:
".$db_parser->make_changes_list($diffs); - $qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]); - if ($debugLevel) echo "Update Query used: ".$qry."
"; - $sql->db_Select_gen($qry); - $updateMessages[] = LAN_UPDATE_47.$ct; - catch_error(); + if ($just_check) return update_needed("Field changes rqd; table: ".$ct); + + // Do the changes here + if ($debugLevel) + { + $mes->add("List of changes found:
".$db_parser->make_changes_list($diffs), E_MESSAGE_DEBUG); + } + + $qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]); + + if ($debugLevel) + { + $mes->add("Update Query used: ".$qry, E_MESSAGE_DEBUG); + } + + $status = $sql->db_Select_gen($qry) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $mes->add(LAN_UPDATE_21.$ct, $status); + catch_error(); } } } @@ -704,7 +722,7 @@ function update_706_to_800($type='') $mes->add($message, E_MESSAGE_DEBUG); } $sql->db_Select_gen($qry); - $updateMessages[] = LAN_UPDATE_51.$ct; + $updateMessages[] = LAN_UPDATE_51.$ct; //FIXME catch_error(); } } @@ -719,7 +737,7 @@ function update_706_to_800($type='') require_once(e_HANDLER."plugin_class.php"); $ep = new e107plugin; $ep -> update_plugins_table(); - $updateMessages[] = LAN_UPDATE_24; + // $_pdateMessages[] = LAN_UPDATE_XX24; // catch_error(); } @@ -730,8 +748,8 @@ function update_706_to_800($type='') if ($sql->db_Table_exists($ot)) { if ($just_check) return update_needed("Delete table: ".$ot); - $sql->db_Select_gen('DROP TABLE `'.MPREFIX.$ot.'`'); - $updateMessages[] = LAN_UPDATE_48.$ot; + $status = $sql->db_Select_gen('DROP TABLE `'.MPREFIX.$ot.'`') ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $mes->add(LAN_UPDATE_25.$ot, $status); } } @@ -747,9 +765,9 @@ function update_706_to_800($type='') if (strtolower($field_info['Type']) != 'varchar(45)') { if ($just_check) return update_needed('Update IP address field '.$f.' in table '.$t); - $sql->db_Select_gen("ALTER TABLE `".MPREFIX.$t."` MODIFY `{$f}` VARCHAR(45) NOT NULL DEFAULT '';"); - $updateMessages[] = LAN_UPDATE_49.$t.' - '.$f; - catch_error(); + $status = $sql->db_Select_gen("ALTER TABLE `".MPREFIX.$t."` MODIFY `{$f}` VARCHAR(45) NOT NULL DEFAULT '';") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $mes->add(LAN_UPDATE_26.$t.' - '.$f, $status); + // catch_error(); } } else @@ -777,8 +795,10 @@ function update_706_to_800($type='') if ($do_save) { save_prefs(); - $updateMessages[] = LAN_UPDATE_50.implode(', ',$accum); + $updateMessages[] = LAN_UPDATE_50.implode(', ',$accum); // FIXME } + + //FIXME grab message-stack from $mes for the log. if ($just_check) return TRUE; $admin_log->log_event('UPDATE_01',LAN_UPDATE_14.$e107info['e107_version'].'[!br!]'.implode('[!br!]',$updateMessages),E_LOG_INFORMATIVE,''); // Log result of actual update diff --git a/e107_handlers/file_class.php b/e107_handlers/file_class.php index 060ed6eef..b35804158 100644 --- a/e107_handlers/file_class.php +++ b/e107_handlers/file_class.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/file_class.php,v $ -| $Revision: 1.3 $ -| $Date: 2009-11-05 08:07:48 $ +| $Revision: 1.4 $ +| $Date: 2009-11-07 11:20:28 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -56,7 +56,7 @@ class e_file { var $dirFilter; // Array of directory names to ignore (in addition to any set by caller) var $fileFilter; // Array of file names to ignore (in addition to any set by caller) - + var $mode = 'default'; // Constructor function e_file() @@ -141,10 +141,27 @@ class e_file } } if($rejected == FALSE) - { - $finfo['path'] = $path."/"; // important: leave this slash here and update other file instead. - $finfo['fname'] = $file; - $ret[] = $finfo; + { + switch($this->mode) //TODO remove this check from the loop. + { + case 'fname': + $ret[] = $file; + break; + + case 'path': + $ret[] = $path."/"; + break; + + case 'full': + $ret[] = $path."/".$file; + break; + + default: + $finfo['path'] = $path."/"; // important: leave this slash here and update other file instead. + $finfo['fname'] = $file; + $ret[] = $finfo; + break; + } } } } diff --git a/e107_languages/English/admin/lan_admin.php b/e107_languages/English/admin/lan_admin.php index e270a56be..bd085b341 100644 --- a/e107_languages/English/admin/lan_admin.php +++ b/e107_languages/English/admin/lan_admin.php @@ -1,7 +1,7 @@
".$lanfile."".$k."
"; + + $count = 1; + foreach($lines as $ln) + { + if(strpos($ln,$needle.'.')!==FALSE || strpos($ln,$needle.';')!==FALSE || strpos($ln,$needle.';')!==FALSE) + { + $text .= "Line:".$count." "; // "' Found"; + $found = TRUE; + } + $count++; + } + + if(!$found) + { + $text .= "-"; + } + $text .= "
".$needle .$disabled. "
".$needle .$disabled. "