[ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/e107_plugins/content/content_update.php,v $ 14 | $Revision: 1.17 $ 15 | $Date: 2006/07/28 14:07:14 $ 16 | $Author: lisa_ $ 17 +----------------------------------------------------------------------------+ 18 */ 19 if (!defined('e107_INIT')) { exit; } 20 21 require_once(e_HANDLER."form_handler.php"); 22 $rs = new form; 23 24 global $ns, $sql, $pref; 25 26 $plugindir = e_PLUGIN."content/"; 27 $plugintable = "pcontent"; //name of the table used in this plugin (never remove this, as it's being used throughout the plugin !!) 28 29 require_once ($plugindir."handlers/content_defines.php"); 30 require_once ($plugindir."handlers/content_class.php"); 31 $aa = new content; 32 require_once ($plugindir."handlers/content_convert_class.php"); 33 $ac = new content_convert; 34 35 $lan_file = $plugindir.'languages/'.e_LANGUAGE.'/lan_content_admin.php'; 36 include_once(file_exists($lan_file) ? $lan_file : $plugindir.'languages/English/lan_content_admin.php'); 37 38 if($sql->db_Select("plugin", "plugin_version", "plugin_path = 'content'")) 39 { 40 $row = $sql->db_Fetch(); 41 $content_version = $row['plugin_version']; 42 } 43 44 //create table if it doesn't exist 45 if(!$sql->db_Query("SHOW COLUMNS FROM ".MPREFIX."pcontent")) { 46 $query = "CREATE TABLE ".MPREFIX."pcontent ( 47 content_id int(10) unsigned NOT NULL auto_increment, 48 content_heading varchar(255) NOT NULL default '', 49 content_subheading varchar(255) NOT NULL default '', 50 content_summary text NOT NULL, 51 content_text longtext NOT NULL, 52 content_author varchar(255) NOT NULL default '', 53 content_icon varchar(255) NOT NULL default '', 54 content_file text NOT NULL, 55 content_image text NOT NULL, 56 content_parent varchar(50) NOT NULL default '', 57 content_comment tinyint(1) unsigned NOT NULL default '0', 58 content_rate tinyint(1) unsigned NOT NULL default '0', 59 content_pe tinyint(1) unsigned NOT NULL default '0', 60 content_refer text NOT NULL, 61 content_datestamp int(10) unsigned NOT NULL default '0', 62 content_enddate int(10) unsigned NOT NULL default '0', 63 content_class varchar(255) NOT NULL default '', 64 content_pref text NOT NULL, 65 content_order varchar(10) NOT NULL default '0', 66 content_score tinyint(3) unsigned NOT NULL default '0', 67 content_meta text NOT NULL, 68 content_layout varchar(255) NOT NULL default '', 69 PRIMARY KEY (content_id) 70 ) TYPE=MyISAM;"; 71 72 $sql->db_Select_gen($query); 73 } 74 75 $text = ""; 76 $main_convert = ""; 77 //main convert 78 79 $newcontent = $sql -> db_Count($plugintable, "(*)", ""); 80 if($newcontent == 0){ 81 82 unset($text); 83 84 //possible database values 85 //content page: $content_parent == "1" && $content_type == "1" //added at 20051031 86 //content page: $content_parent == "0" && $content_type == "1" 87 //review category: $content_parent == "0" && $content_type == "10" 88 //article category: $content_parent == "0" && $content_type == "6" 89 //review: $content_type == "3" || $content_type == "16" 90 //article: $content_type == "0" || $content_type == "15" 91 92 // ##### STAGE 1 : ANALYSE OLD CONTENT -------------------------------------------------------- 93 $sql = new db; 94 $totaloldcontentrows = $sql -> db_Count("content"); 95 $totaloldrowscat_article = $sql -> db_Count("content", "(*)", "WHERE content_parent = '0' AND content_type = '6'"); 96 $totaloldrowscat_review = $sql -> db_Count("content", "(*)", "WHERE content_parent = '0' AND content_type = '10'"); 97 $totaloldrowsitem_content = $sql -> db_Count("content", "(*)", "WHERE (content_parent = '0' || content_parent = '1') AND content_type = '1'"); 98 $totaloldrowsitem_review = $sql -> db_Count("content", "(*)", "WHERE content_type = '3' || content_type = '16'"); 99 $totaloldrowsitem_article = $sql -> db_Count("content", "(*)", "WHERE content_type = '0' || content_type = '15'"); 100 101 if($totaloldrowsitem_content == 0 && $totaloldrowsitem_article == 0 && $totaloldrowsitem_review == 0){ 102 $totaloldrowsitem_content = "1"; 103 $totaloldrowsitem_article = "1"; 104 $totaloldrowsitem_review = "1"; 105 106 //if no old records exist, create a few default categories 107 $main_convert = create_defaults(); 108 }else{ 109 110 //analyse unknown rows 111 $unknown_array = $ac -> analyse_unknown(); 112 113 if($totaloldcontentrows == 0){ 114 $totaloldrowsitem_content = "1"; 115 $totaloldrowsitem_article = "1"; 116 $totaloldrowsitem_review = "1"; 117 } 118 119 //create mainparent 120 $content_mainarray = $ac -> create_mainparent("content", $totaloldrowsitem_content, "1"); 121 $article_mainarray = $ac -> create_mainparent("article", $totaloldrowsitem_article, "2"); 122 $review_mainarray = $ac -> create_mainparent("review", $totaloldrowsitem_review, "3"); 123 124 //convert categories 125 $article_cat_array = $ac -> convert_category("article", "content_parent = '0' AND content_type = '6'", "2"); 126 $review_cat_array = $ac -> convert_category("review", "content_parent = '0' AND content_type = '10'", "3"); 127 128 //convert rows 129 $content_array = $ac -> convert_row("content", "(content_parent = '0' || content_parent = '1') AND content_type = '1'", "1"); 130 $article_array = $ac -> convert_row("article", "content_type = '0' || content_type = '15'", "2"); 131 $review_array = $ac -> convert_row("review", "content_type = '3' || content_type = '16'", "3"); 132 133 //convert comments 134 $ac -> convert_comments(); 135 136 //convert rating 137 $ac -> convert_rating(); 138 139 $conversion_analyses_rows_total = $totaloldcontentrows; 140 141 $conversion_analyses_rows_converted = (count($article_cat_array[1]) + count($review_cat_array[1]) + count($content_array[2]) + count($article_array[2]) + count($review_array[2])); 142 143 $conversion_analyses_rows_warning = (count($content_array[4]) + count($content_array[5]) + count($article_array[4]) + count($article_array[5]) + count($review_array[4]) + count($review_array[5])); 144 145 $conversion_analyses_rows_failed = (count($article_cat_array[2]) + count($review_cat_array[2]) + count($content_array[3]) + count($article_array[3]) + count($review_array[3]) + count($unknown_array[1])); 146 147 148 //only output detailed information if developer mode is set 149 if ($pref['developer']) { 150 showlink(); 151 $SPACER = "<tr><td $stylespacer colspan='2'> </td></tr>"; 152 $text = " 153 <table class='fborder' style='width:95%; padding:0px;'>"; 154 155 //conversion analysis 156 $text .= " 157 <tr> 158 <td class='forumheader' style='width:5%; white-space:nowrap; vertical-align:top;'>".CONTENT_ADMIN_CONVERSION_LAN_11."</td> 159 <td class='forumheader3'> 160 <a style='cursor: pointer; cursor: hand' onclick=\"expandit('analysisconvert');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a> 161 <div id='analysisconvert' style='display: none;'> 162 ".CONTENT_ADMIN_CONVERSION_LAN_12.": ".$conversion_analyses_rows_total."<br /> 163 ".CONTENT_ADMIN_CONVERSION_LAN_13.": ".$conversion_analyses_rows_converted."<br /> 164 ".CONTENT_ADMIN_CONVERSION_LAN_14.": ".$conversion_analyses_rows_warning."<br /> 165 ".CONTENT_ADMIN_CONVERSION_LAN_15.": ".$conversion_analyses_rows_failed."<br /> 166 </div> 167 </td> 168 </tr>"; 169 170 $text .= $SPACER; 171 172 //old content table : analysis 173 $text .= " 174 <tr> 175 <td class='forumheader' style='width:5%; white-space:nowrap; vertical-align:top;'>".CONTENT_ADMIN_CONVERSION_LAN_16."</td> 176 <td class='forumheader3'> 177 <a style='cursor: pointer; cursor: hand' onclick=\"expandit('analysisold');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a> 178 <div id='analysisold' style='display: none;'> 179 ".CONTENT_ADMIN_CONVERSION_LAN_17.": ".$totaloldcontentrows."<br /> 180 ".CONTENT_ADMIN_CONVERSION_LAN_0." ".CONTENT_ADMIN_CONVERSION_LAN_6.": ".$totaloldrowsitem_content."<br /> 181 ".CONTENT_ADMIN_CONVERSION_LAN_1." ".CONTENT_ADMIN_CONVERSION_LAN_4.": ".$totaloldrowscat_review."<br /> 182 ".CONTENT_ADMIN_CONVERSION_LAN_1." ".CONTENT_ADMIN_CONVERSION_LAN_6.": ".$totaloldrowsitem_review."<br /> 183 ".CONTENT_ADMIN_CONVERSION_LAN_2." ".CONTENT_ADMIN_CONVERSION_LAN_4.": ".$totaloldrowscat_article."<br /> 184 ".CONTENT_ADMIN_CONVERSION_LAN_2." ".CONTENT_ADMIN_CONVERSION_LAN_6.": ".$totaloldrowsitem_article."<br />"; 185 186 $knownrows = $totaloldrowscat_article + $totaloldrowscat_review + $totaloldrowsitem_content + $totaloldrowsitem_review + $totaloldrowsitem_article; 187 if($totaloldcontentrows > $knownrows ){ 188 $text .= CONTENT_ADMIN_CONVERSION_LAN_18.": ".($totaloldcontentrows - $knownrows)."<br />"; 189 }else{ 190 $text .= CONTENT_ADMIN_CONVERSION_LAN_19."<br />"; 191 } 192 193 $text .= " 194 </div> 195 </td> 196 </tr>"; 197 198 $text .= $SPACER; 199 200 //unknown rows 201 if(count($unknown_array[0]) > 0){ 202 $text .= "<tr><td class='fcaption' colspan='2'>".CONTENT_ADMIN_CONVERSION_LAN_51."</td></tr>"; 203 $text .= " 204 <tr> 205 <td class='forumheader3' style='width:5%; white-space:nowrap; vertical-align:top;'>".CONTENT_ICON_ERROR." ".count($unknown_array[0])." ".CONTENT_ADMIN_CONVERSION_LAN_51."</td> 206 <td class='forumheader3'> 207 <a style='cursor: pointer; cursor: hand' onclick=\"expandit('unknownrows');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a> 208 <div id='unknownrows' style='display: none;'> 209 <table style='width:100%; border:0;'>"; 210 for($i=0;$i<count($unknown_array[0]);$i++){ 211 $text .= "<tr><td style='width:25%; white-space:nowrap;'>".CONTENT_ICON_ERROR." ".$unknown_array[0][$i]."</td><td>".$unknown_array[2][$i]." ".$rs -> form_hidden("unknownrows[]", $unknown_array[1][$i])."</td></tr>"; 212 } 213 $text .= " 214 </table> 215 </div> 216 </td> 217 </tr>"; 218 } 219 220 $text .= " 221 222 ".$SPACER." 223 224 ".$ac -> results_conversion_mainparent($content_mainarray, $review_mainarray, $article_mainarray)." 225 226 ".$SPACER." 227 228 <tr><td class='fcaption' colspan='2'>content : ".CONTENT_ADMIN_CONVERSION_LAN_27."</td></tr> 229 ".$ac -> results_conversion_row("content", $content_array, $totaloldrowsitem_content)." 230 231 ".$SPACER." 232 233 <tr><td class='fcaption' colspan='2'>review : ".CONTENT_ADMIN_CONVERSION_LAN_27."</td></tr> 234 ".$ac -> results_conversion_category("review", $review_cat_array, $totaloldrowscat_review)." 235 ".$ac -> results_conversion_row("review", $review_array, $totaloldrowsitem_review)." 236 237 ".$SPACER." 238 239 <tr><td class='fcaption' colspan='2'>article : ".CONTENT_ADMIN_CONVERSION_LAN_27."</td></tr> 240 ".$ac -> results_conversion_category("article", $article_cat_array, $totaloldrowscat_article)." 241 ".$ac -> results_conversion_row("article", $article_array, $totaloldrowsitem_article)." 242 243 ".$SPACER." 244 245 </table>"; 246 247 $main_convert = array($caption, $text); 248 } 249 250 } 251 } 252 253 $text = ""; 254 //update to 1.1 parent values to new style 255 $upgrade_1_1 = FALSE; 256 if($thiscount = $sql -> db_Select("pcontent", "*", "ORDER BY content_id ", "mode=no_where" )){ 257 while($row = $sql -> db_Fetch()){ 258 if( strpos($row['content_parent'], ".") && substr($row['content_parent'],0,1) != "0"){ 259 //if item with old parent value exists, you need to upgrade to 1.1 260 $upgrade_1_1 = TRUE; 261 } 262 } 263 } 264 if($upgrade_1_1 === TRUE){ 265 $text .= $ac -> upgrade_1_1(); 266 } 267 268 //upgrade to 1.2 table structure (add score, meta, layout fields) 269 $text .= $ac -> upgrade_1_2(); 270 271 //upgrade to 1.21 (update content_author fields) 272 $text .= $ac -> upgrade_1_21(); 273 274 //upgrade to 1.22 (update preference storage method) 275 $text .= $ac -> upgrade_1_22(); 276 277 //upgrade to 1.23 (update preference storage method) 278 $text .= $ac -> upgrade_1_23(); 279 280 //upgrade to 1.24 (update custom theme) 281 $text .= $ac -> upgrade_1_24(); 282 283 //render message 284 if(isset($text)){ 285 //only output detailed information if developer mode is set 286 if ($pref['developer']) { 287 $caption = CONTENT_ADMIN_CONVERSION_LAN_63; 288 $ns -> tablerender($caption, $text); 289 } 290 } 291 292 //render primary conversion results 293 if(is_array($main_convert)){ 294 if(isset($main_convert[1])){ 295 //only output detailed information if developer mode is set 296 if ($pref['developer']) { 297 $ns -> tablerender($main_convert[0], $main_convert[1]); 298 } 299 } 300 } 301 302 //finally set the new content plugin version number 303 set_content_version(); 304 305 306 307 308 //create default mainparent category for content, review and article 309 function create_defaults() 310 { 311 global $ns, $ac, $plugindir; 312 313 $plugindir = e_PLUGIN."content/"; 314 315 if(!is_object($ac)){ 316 require_once ($plugindir."handlers/content_convert_class.php"); 317 $ac = new content_convert; 318 } 319 320 $content_mainarray = $ac -> create_mainparent("content", "1", "1"); 321 $article_mainarray = $ac -> create_mainparent("article", "1", "2"); 322 $review_mainarray = $ac -> create_mainparent("review", "1", "3"); 323 324 $main_convert = ''; 325 //only output detailed information if developer mode is set 326 if ($pref['developer']) { 327 showlink(); 328 329 $text = "<table class='fborder' style='width:95%; padding:0px;'>"; 330 $text .= $ac -> results_conversion_mainparent($content_mainarray, $review_mainarray, $article_mainarray); 331 $text .= "</table>"; 332 333 $main_convert = array(CONTENT_ADMIN_CONVERSION_LAN_52, $text); 334 } 335 return $main_convert; 336 } 337 338 339 340 //show link to start managing the content management plugin 341 function showlink() 342 { 343 global $ns, $pref; 344 //only output detailed information if developer mode is set 345 if ($pref['developer']) { 346 $text = "<div style='text-align:center'>".CONTENT_ADMIN_CONVERSION_LAN_46."</div>"; 347 $caption = CONTENT_ADMIN_CONVERSION_LAN_47; 348 $ns -> tablerender($caption, $text); 349 } 350 } 351 352 353 354 //update content plugin version number 355 function set_content_version() 356 { 357 global $sql, $pref; 358 $new_version = "1.24"; 359 $sql->db_Update('plugin',"plugin_version = '{$new_version}' WHERE plugin_path='content'"); 360 $text = ''; 361 //only output detailed information if developer mode is set 362 if ($pref['developer']) { 363 $text = CONTENT_ADMIN_CONVERSION_LAN_62." $new_version <br />"; 364 } 365 return $text; 366 } 367 368 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |