[ Index ]
 

Code source de e107 0.7.8

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/e107_plugins/content/handlers/ -> content_convert_class.php (source)

   1  <?php
   2  /*
   3  +---------------------------------------------------------------+
   4  |        e107 website system
   5  |        content_convert_class.php
   6  |
   7  |        ©Steve Dunstan 2001-2002
   8  |        http://e107.org
   9  |        jalist@e107.org
  10  |
  11  |        Released under the terms and conditions of the
  12  |        GNU General Public License (http://gnu.org).
  13  |
  14  |        $Source: /cvsroot/e107/e107_0.7/e107_plugins/content/handlers/content_convert_class.php,v $
  15  |        $Revision: 1.21 $
  16  |        $Date: 2006/07/28 14:07:15 $
  17  |        $Author: lisa_ $
  18  +---------------------------------------------------------------+
  19  */
  20  
  21  if (!defined('e107_INIT')) { exit; }
  22  
  23  $plugindir        = e_PLUGIN."content/";
  24  $plugintable    = "pcontent";        //name of the table used in this plugin (never remove this, as it's being used throughout the plugin !!)
  25  $datequery        = " AND content_datestamp < ".time()." AND (content_enddate=0 || content_enddate>".time().") ";
  26  
  27  $lan_file = $plugindir.'languages/'.e_LANGUAGE.'/lan_content.php';
  28  include_once(file_exists($lan_file) ? $lan_file : $plugindir.'languages/English/lan_content.php');
  29  $lan_file = $plugindir.'languages/'.e_LANGUAGE.'/lan_content_admin.php';
  30  include_once(file_exists($lan_file) ? $lan_file : $plugindir.'languages/English/lan_content_admin.php');
  31  
  32  require_once ($plugindir."handlers/content_class.php");
  33  $aa = new content;
  34  
  35  class content_convert{
  36  
  37  
  38          //update content_author
  39  		function upgrade_1_2(){
  40              global $sql;
  41  
  42              $text = "";
  43              $field1 = $sql->db_Field("pcontent",19);
  44              $field2 = $sql->db_Field("pcontent",20);
  45              $field3 = $sql->db_Field("pcontent",21);
  46              if($field1 != "content_score" && $field2 != "content_meta" && $field3 != "content_layout"){
  47                  mysql_query("ALTER TABLE ".MPREFIX."pcontent ADD content_score TINYINT ( 3 ) UNSIGNED NOT NULL DEFAULT '0';");
  48                  mysql_query("ALTER TABLE ".MPREFIX."pcontent ADD content_meta TEXT NOT NULL;");
  49                  mysql_query("ALTER TABLE ".MPREFIX."pcontent ADD content_layout VARCHAR ( 255 ) NOT NULL DEFAULT '';");
  50                  $text = CONTENT_ADMIN_CONVERSION_LAN_64."<br />";
  51              }
  52              return $text;
  53          }
  54  
  55          //update content_author
  56  		function upgrade_1_21(){
  57              global $sql;
  58              $sql = new db; $sql1 = new db;
  59              $upgrade = FALSE;
  60              if($sql -> db_Select("pcontent", "content_id, content_author", "content_author != '' ")){
  61                  while($row = $sql -> db_Fetch()){
  62                      if(is_numeric($row['content_author'])){
  63                      }else{
  64                          $tmp = explode("^", $row['content_author']);
  65                          if($tmp[0] == "0"){
  66                              $upgrade = TRUE;
  67                              $newauthor = $tmp[1].($tmp[2] ? "^".$tmp[2] : "");
  68                              $sql1 -> db_Update("pcontent", " content_author = '".$newauthor."' WHERE content_id='".$row['content_id']."' ");
  69                          }
  70                      }
  71                  }
  72              }
  73              if($upgrade){
  74                  return CONTENT_ADMIN_CONVERSION_LAN_65."<br />";
  75              }else{
  76                  return FALSE;
  77              }
  78          }
  79  
  80          //update preferences storage method
  81  		function upgrade_1_22(){
  82              global $sql, $sql2, $eArrayStorage, $tp, $aa;
  83  
  84              $upgrade = TRUE;
  85  
  86              $sqlc = new db;
  87              $sqld = new db;
  88  
  89              //convert preferences for core default preferences
  90              if($sqlc -> db_Select("core", "*", "e107_name='pcontent' ")){
  91                  $row = $sqlc -> db_Fetch();
  92  
  93                  $tmp = $eArrayStorage->ReadArray($row['e107_value']);
  94  
  95                  //replace the id value for the content_pref
  96                  $content_pref = array();
  97                  foreach($tmp as $k=>$v){
  98                      if(substr($k,-2) == "_0"){
  99                          $k = str_replace("_0", "", $k);
 100                      }
 101                      if(strpos($k, "content_") === 0){
 102                          $content_pref[$k] = $tp->toDB($v);
 103                      }
 104                  }
 105                  if(!isset($content_pref['content_admin_subheading'])){
 106                      //add new options to the preferences
 107                      $content_pref = $this->upgrade_1_22_prefs($content_pref);
 108  
 109                      $tmp1 = $eArrayStorage->WriteArray($content_pref);
 110                      $sqld -> db_Update("core", "e107_value = '{$tmp1}' WHERE e107_name = 'pcontent' ");
 111                  }else{
 112                      $upgrade=FALSE;
 113                  }
 114              }
 115  
 116              //convert preferences for all main parents
 117              if($sqlc -> db_Select("pcontent", "content_id, content_heading, content_pref", "LEFT(content_parent, 1) = '0' ")){
 118                  while($row=$sqlc->db_Fetch()){
 119  
 120                      $id = $row['content_id'];
 121                      $tmp = $eArrayStorage->ReadArray($row['content_pref']);
 122  
 123                      //replace the id value for the content_pref
 124                      $l = strlen($id);
 125                      $content_pref = array();
 126                      foreach($tmp as $k=>$v){
 127                          if(substr($k,-($l+1)) == "_".$id){
 128                              $k = str_replace("_".$id, "", $k);
 129                          }
 130                          if(strpos($k, "content_") === 0){
 131                              $content_pref[$k] = $tp->toDB($v);
 132                          }
 133                      }
 134                      //add new options to the preferences
 135                      if(!isset($content_pref['content_admin_subheading'])){
 136                          $content_pref = $this->upgrade_1_22_prefs($content_pref);
 137  
 138                          $tmp1 = $eArrayStorage->WriteArray($content_pref);
 139                          $sqld -> db_Update("pcontent", "content_pref='{$tmp1}' WHERE content_id='$id' ");
 140                      }else{
 141                          $upgrade=FALSE;
 142                      }
 143  
 144                      //update menus
 145                      $plugintable    = "pcontent";
 146                      $plugindir        = e_PLUGIN."content/";
 147                      if(!is_object($aa)){
 148                          require_once ($plugindir."handlers/content_class.php");
 149                          $aa = new content;
 150                      }
 151                      if($row['content_parent']==0){
 152                          //remove menu
 153                          @unlink(e_PLUGIN."content/menus/content_".$row['content_heading']."_menu.php");
 154                          //create menu
 155                          $aa -> CreateParentMenu($id);
 156                      }
 157                  }
 158              }
 159  
 160              if($upgrade===TRUE){
 161                  return CONTENT_ADMIN_CONVERSION_LAN_66."<br />";
 162              }
 163          }
 164  
 165          //add new preferences that come with this upgrade
 166  		function upgrade_1_22_prefs($content_pref){
 167  
 168              //create : item page
 169              $content_pref['content_admin_subheading'] = '1';
 170              $content_pref['content_admin_summary'] = '1';
 171              $content_pref['content_admin_startdate'] = '1';
 172              $content_pref['content_admin_enddate'] = '1';
 173  
 174              //create : category page
 175              $content_pref['content_admincat_subheading'] = '1';
 176              $content_pref['content_admincat_comment'] = '1';
 177              $content_pref['content_admincat_rating'] = '1';
 178              $content_pref['content_admincat_pe'] = '1';
 179              $content_pref['content_admincat_visibility'] = '1';
 180              $content_pref['content_admincat_startdate'] = '1';
 181              $content_pref['content_admincat_enddate'] = '1';
 182              $content_pref['content_admincat_uploadicon'] = '1';
 183              $content_pref['content_admincat_selecticon'] = '1';
 184  
 185              //create : submit page
 186              $content_pref['content_submit_subheading'] = '1';
 187              $content_pref['content_submit_summary'] = '1';
 188              $content_pref['content_submit_startdate'] = '1';
 189              $content_pref['content_submit_enddate'] = '1';
 190  
 191              //content manager
 192              $content_pref['content_manager_approve'] = '255';
 193              $content_pref['content_manager_personal'] = '255';
 194              $content_pref['content_manager_category'] = '255';
 195  
 196              return $content_pref;
 197          }
 198  
 199  
 200          //update preferences storage method
 201  		function upgrade_1_23(){
 202              global $sql, $sql2, $eArrayStorage, $tp, $aa;
 203  
 204              $upgrade = TRUE;
 205  
 206              $sqlc = new db;
 207              $sqld = new db;
 208              //add new preferences in core
 209              if($sqlc -> db_Select("core", "*", "e107_name='pcontent' ")){
 210                  $row = $sqlc -> db_Fetch();
 211  
 212                  $content_pref = $eArrayStorage->ReadArray($row['e107_value']);
 213  
 214                  //add new options to the preferences
 215                  if(!isset($content_pref['content_admin_subheading'])){
 216                      $content_pref = $this->upgrade_1_23_prefs($content_pref);
 217  
 218                      $tmp1 = $eArrayStorage->WriteArray($content_pref);
 219                      $sqld -> db_Update("core", "e107_value = '{$tmp1}' WHERE e107_name = 'pcontent' ");
 220                  }else{
 221                      $upgrade=FALSE;
 222                  }
 223              }
 224  
 225              //add new preferences for each main parent
 226              if($sqlc -> db_Select("pcontent", "content_id, content_heading, content_pref", "content_parent = '0' ")){
 227                  while($row=$sqlc->db_Fetch()){
 228  
 229                      $id = $row['content_id'];
 230                      $content_pref = $eArrayStorage->ReadArray($row['content_pref']);
 231  
 232                      if(!isset($content_pref['content_admin_subheading'])){
 233                          //add new options to the preferences
 234                          $content_pref = $this->upgrade_1_23_prefs($content_pref);
 235  
 236                          $tmp1 = $eArrayStorage->WriteArray($content_pref);
 237                          $sqld -> db_Update("pcontent", "content_pref='{$tmp1}' WHERE content_id='$id' ");
 238                      }else{
 239                          $upgrade=FALSE;
 240                      }
 241                  }
 242              }
 243              if($upgrade===TRUE){
 244                  return CONTENT_ADMIN_CONVERSION_LAN_67."<br />";
 245              }
 246          }
 247          //add new preferences that come with this upgrade
 248  		function upgrade_1_23_prefs($content_pref){
 249  
 250              $content_pref['content_list_caption'] = CONTENT_LAN_23;            //caption for recent list
 251              $content_pref['content_list_caption_append_name'] = '1';        //append category heading to caption
 252              $content_pref['content_catall_caption'] = CONTENT_LAN_25;        //caption for all categories page
 253              $content_pref['content_cat_caption'] = CONTENT_LAN_26;            //caption for single category page
 254              $content_pref['content_cat_caption_append_name'] = '1';            //append category heading to caption
 255              $content_pref['content_cat_sub_caption'] = CONTENT_LAN_28;        //caption for subcategories
 256              $content_pref['content_cat_item_caption'] = CONTENT_LAN_31;        //caption for items in category
 257              $content_pref['content_author_index_caption'] = CONTENT_LAN_32;    //caption for author index page
 258              $content_pref['content_author_caption'] = CONTENT_LAN_32;        //caption for single author page
 259              $content_pref['content_author_caption_append_name'] = '1';        //append author name to caption
 260              $content_pref['content_archive_caption'] = CONTENT_LAN_84;        //caption for archive page
 261              $content_pref['content_top_icon_width'] = '';                    //use this size for icon
 262              $content_pref['content_top_caption'] = CONTENT_LAN_38;            //caption for top rated page
 263              $content_pref['content_top_caption_append_name'] = '1';            //append category heading to caption
 264              $content_pref['content_score_icon_width'] = '';                    //use this size for icon
 265              $content_pref['content_score_caption'] = CONTENT_LAN_87;        //caption for top score page
 266              $content_pref['content_score_caption_append_name'] = '1';        //append category heading to caption
 267  
 268              return $content_pref;
 269          }
 270  
 271          //update custom theme
 272  		function upgrade_1_24(){
 273              global $sql, $sql2, $eArrayStorage, $tp, $aa;
 274  
 275              $upgrade = TRUE;
 276  
 277              $sqlc = new db;
 278              $sqld = new db;
 279              //add new preferences in core
 280              if($sqlc -> db_Select("core", "*", "e107_name='pcontent' ")){
 281                  $row = $sqlc -> db_Fetch();
 282  
 283                  $content_pref = $eArrayStorage->ReadArray($row['e107_value']);
 284  
 285                  //update theme
 286                  if(strpos($content_pref['content_theme'], "{e_")!==FALSE){
 287                  }else{
 288                      $content_pref['content_theme'] = "{e_PLUGIN}content/templates/".$content_pref['content_theme']."/";
 289                  }
 290  
 291                  $tmp1 = $eArrayStorage->WriteArray($content_pref);
 292                  $sqld -> db_Update("core", "e107_value = '{$tmp1}' WHERE e107_name = 'pcontent' ");
 293              }
 294  
 295              //add new preferences for each main parent
 296              if($sqlc -> db_Select("pcontent", "content_id, content_heading, content_pref", "content_parent = '0' ")){
 297                  while($row=$sqlc->db_Fetch()){
 298  
 299                      $id = $row['content_id'];
 300                      $content_pref = $eArrayStorage->ReadArray($row['content_pref']);
 301  
 302                      //update theme
 303                      if(strpos($content_pref['content_theme'], "{e_")!==FALSE){
 304                      }else{
 305                          $content_pref['content_theme'] = "{e_PLUGIN}content/templates/".$content_pref['content_theme']."/";
 306                      }
 307  
 308                      $tmp1 = $eArrayStorage->WriteArray($content_pref);
 309                      $sqld -> db_Update("pcontent", "content_pref='{$tmp1}' WHERE content_id='$id' ");
 310                  }
 311              }
 312              return CONTENT_ADMIN_CONVERSION_LAN_68."<br />";
 313          }
 314  
 315          //convert rows
 316  		function upgrade_1_1(){
 317                  global $sql, $sql2, $tp, $plugintable, $eArrayStorage;
 318                  $plugintable    = "pcontent";
 319  
 320                  $count = "0";
 321                  $sql = new db;
 322                  $thiscount = $sql -> db_Select("pcontent", "*", "ORDER BY content_id ", "mode=no_where" );
 323                  if($thiscount > 0){
 324                      while($row = $sql -> db_Fetch()){
 325  
 326                          //main parent
 327                          if($row['content_parent'] == "0"){
 328                              $newparent = "0";
 329  
 330                          //subcat
 331                          }elseif(substr($row['content_parent'],0,2) == "0."){
 332                              $newparent = "0".strrchr($row['content_parent'], ".");
 333  
 334                          //item
 335                          }elseif( strpos($row['content_parent'], ".") && substr($row['content_parent'],0,1) != "0"){
 336                              $newparent = substr(strrchr($row['content_parent'], "."),1);
 337                          }
 338  
 339                          $sql2 -> db_Update("pcontent", " content_parent = '".$newparent."', content_pref='' WHERE content_id='".$row['content_id']."' ");
 340                      }
 341                  }
 342                  return CONTENT_ADMIN_CONVERSION_LAN_58."<br /><br />".CONTENT_ADMIN_CONVERSION_LAN_46."<br />";
 343          }
 344  
 345  
 346  
 347  
 348  		function show_main_intro(){
 349                          global $sql, $ns, $rs, $type, $type_id, $action, $sub_action, $id, $plugintable;
 350                          $plugintable    = "pcontent";
 351  
 352                          if(!is_object($sql)){ $sql = new db; }
 353                          $newcontent = $sql -> db_Count($plugintable, "(*)", "");
 354                          if($newcontent > 0){
 355                              return false;
 356                          }else{
 357  
 358                              $text .= "
 359                              <div style='text-align:center'>
 360                              <div style='width:70%; text-align:left'>
 361                              ".$rs -> form_open("post", e_SELF, "dataform")."
 362                              <table class='fborder'>";
 363                              
 364                              $oldcontent = $sql -> db_Count("content", "(*)", "");
 365                              if($oldcontent > 0){
 366                                  $text .= "<tr><td class='forumheader3' colspan='2'>".CONTENT_ADMIN_MAIN_LAN_8." ".CONTENT_ADMIN_MAIN_LAN_9." ".CONTENT_ADMIN_MAIN_LAN_11."</td></tr>";
 367  
 368                                  $text .= "<tr><td style='height:20px; border:0;' colspan='2'></td></tr>";
 369                                  $text .= "<tr><td class='fcaption' colspan='2'>".CONTENT_ADMIN_MAIN_LAN_18."</td></tr>";
 370                                  $text .= "<tr><td class='forumheader3' colspan='2'>".CONTENT_ADMIN_MAIN_LAN_19."</td></tr>";
 371                                  $text .= "
 372                                  <tr>
 373                                      <td class='forumheader3' style='width:50%; white-space:nowrap;'>".CONTENT_ADMIN_CONVERSION_LAN_43."</td>
 374                                      <td class='forumheader3' style='width:50%; white-space:nowrap;'>".$rs -> form_button("submit", "convert_table", CONTENT_ADMIN_CONVERSION_LAN_59)."</td>
 375                                  </tr>";
 376  
 377                                  $text .= "<tr><td style='height:20px; border:0;' colspan='2'></td></tr>";
 378                                  $text .= "<tr><td class='fcaption' colspan='2'>".CONTENT_ADMIN_MAIN_LAN_22."</td></tr>";
 379                                  $text .= "<tr><td class='forumheader3' colspan='2'>".CONTENT_ADMIN_MAIN_LAN_23."</td></tr>";
 380                                  $text .= "
 381                                  <tr>
 382                                      <td class='forumheader3' style='width:50%; white-space:nowrap;'>".CONTENT_ADMIN_CONVERSION_LAN_54."</td>
 383                                      <td class='forumheader3' style='width:50%; white-space:nowrap;'>".$rs -> form_button("submit", "create_default", CONTENT_ADMIN_CONVERSION_LAN_60)."</td>
 384                                  </tr>";
 385  
 386                                  $text .= "<tr><td style='height:20px; border:0;' colspan='2'></td></tr>";
 387                                  $text .= "<tr><td class='fcaption' colspan='2'>".CONTENT_ADMIN_MAIN_LAN_20."</td></tr>";
 388                                  $text .= "<tr><td class='forumheader3' colspan='2'>".CONTENT_ADMIN_MAIN_LAN_21."</td></tr>";
 389                                  $text .= "
 390                                  <tr>
 391                                      <td class='forumheader3' style='width:50%; white-space:nowrap;'>".CONTENT_ADMIN_CONVERSION_LAN_56."</td>
 392                                      <td class='forumheader3' style='width:50%; white-space:nowrap;'>".$rs -> form_button("button", "fresh", CONTENT_ADMIN_CONVERSION_LAN_61, "onclick=\"document.location='".e_PLUGIN."content/admin_content_config.php?type.0.cat.create'\"
 393                                  ")."</td>
 394                                  </tr>";
 395  
 396                              }else{
 397                                  $text .= "<tr><td class='fcaption' colspan='2'>".CONTENT_ADMIN_MAIN_LAN_8." ".CONTENT_ADMIN_MAIN_LAN_9." ".CONTENT_ADMIN_MAIN_LAN_24."</td></tr>";
 398                                  $text .= "<tr><td class='forumheader3' colspan='2'>".CONTENT_ADMIN_MAIN_LAN_25."</td></tr>";
 399                                  $text .= "
 400                                  <tr>
 401                                      <td class='forumheader3' style='width:50%; white-space:nowrap;'>".CONTENT_ADMIN_CONVERSION_LAN_54."</td>
 402                                      <td class='forumheader3' style='width:50%; white-space:nowrap;'>".$rs -> form_button("submit", "create_default", CONTENT_ADMIN_CONVERSION_LAN_60)."</td>
 403                                  </tr>";
 404                              }
 405  
 406                              $text .= "</table>".$rs -> form_close()."
 407                              </div>
 408                              </div>";
 409  
 410                              $ns -> tablerender(CONTENT_ADMIN_MAIN_LAN_7, $text);
 411                              return true;
 412                          }
 413          }
 414  
 415          //function to insert default preferences for a main parent
 416  		function insert_default_prefs($id){
 417                  global $sql, $aa, $plugintable, $eArrayStorage;
 418                  $plugintable    = "pcontent";
 419                  $plugindir        = e_PLUGIN."content/";
 420                  unset($content_pref, $tmp);
 421                  
 422                  if(!is_object($aa)){
 423                      require_once ($plugindir."handlers/content_class.php");
 424                      $aa = new content;
 425                  }
 426  
 427                  $content_pref = $aa -> ContentDefaultPrefs($id);
 428                  $tmp = $eArrayStorage->WriteArray($content_pref);
 429  
 430                  $sql -> db_Update($plugintable, "content_pref='$tmp' WHERE content_id='$id' ");
 431          }
 432  
 433  
 434          //function to convert comments
 435  		function convert_comments(){
 436                  global $plugintable;
 437                  $plugintable    = "pcontent";
 438  
 439                  if(!is_object($sqlcc)){ $sqlcc = new db; }
 440                  $numc = $sqlcc -> db_Count("comments", "(*)", "WHERE comment_type = '1' ");
 441                  if($numc > 0){
 442                      $sqlcc -> db_Update("comments", "comment_type = '".$plugintable."' WHERE comment_type = '1' ");
 443                  }
 444          }
 445  
 446  
 447          //function to convert rating
 448  		function convert_rating(){
 449                  global $plugintable;
 450                  $plugintable    = "pcontent";
 451  
 452                  if(!is_object($sqlcr)){ $sqlcr = new db; }
 453                  $numr = $sqlcr -> db_Count("rate", "(*)", "WHERE (rate_table = 'article' || rate_table = 'review' || rate_table = 'content') ");
 454                  if($numr > 0){
 455                      $sqlcr -> db_Update("rate", "rate_table = '".$plugintable."' WHERE (rate_table = 'article' || rate_table = 'review' || rate_table = 'content') ");
 456                  }
 457          }
 458  
 459  
 460          //create main parent
 461  		function create_mainparent($name, $tot, $order){
 462                  global $sql, $aa, $plugintable, $tp;
 463                  $plugintable    = "pcontent";
 464  
 465                  $sql = new db;
 466                  $sql -> db_Select("content", "MAX(content_id) as maxcid", "", "mode=no_where");
 467                  list($maxcid) = $sql -> db_Fetch();
 468                  $newid = $maxcid + $order;
 469  
 470                  // ##### STAGE 4 : INSERT MAIN PARENT FOR ARTICLE ---------------------------------------------
 471                  $checkinsert = FALSE;
 472                  if($tot > 0){
 473                      //if(!is_object($sql)){ $sql = new db; }
 474                      $sql = new db;
 475                      if(!$sql -> db_Select($plugintable, "content_heading", "content_heading = '".$name."' AND content_parent = '0' ")){
 476                          $name = $tp -> toDB($name);
 477  
 478                          $sql -> db_Insert($plugintable, "'".$newid."', '".$name."', '', '', '', '1', '', '', '', '0', '0', '0', '0', '', '".time()."', '0', '0', '', '".$order."', '0', '', '' ");
 479  
 480                          //check if row is present in the db (is it a valid insert)
 481                          //if(!is_object($sql2)){ $sql2 = new db; }
 482                          $sql2 = new db;
 483                          if(!$sql2 -> db_Select($plugintable, "content_id", "content_heading = '".$name."' ")){
 484                              $message = CONTENT_ADMIN_CONVERSION_LAN_45;
 485                          }else{
 486                              $message = $name." ".CONTENT_ADMIN_CONVERSION_LAN_7."<br />";
 487                              $checkinsert = TRUE;
 488  
 489                              //select main parent id
 490                              $sql3 = new db;
 491                              //if(!is_object($sql3)){ $sql3 = new db; }
 492                              $sql3 -> db_Select($plugintable, "content_id", "content_heading = '".$name."' AND content_parent = '0' ");
 493                              list($main_id) = $sql3 -> db_Fetch();
 494  
 495                              //insert default preferences
 496                              $this -> insert_default_prefs($main_id);
 497  
 498                              //create menu
 499                              $aa -> CreateParentMenu($main_id);
 500  
 501                              $message .= $name." ".CONTENT_ADMIN_CONVERSION_LAN_8."<br />";
 502                          }
 503                      }else{
 504                          $message = CONTENT_ADMIN_CONVERSION_LAN_9." ".$name." ".CONTENT_ADMIN_CONVERSION_LAN_10." : ".CONTENT_ADMIN_CONVERSION_LAN_53."<br />";
 505                      }
 506                  }else{
 507                      $message = CONTENT_ADMIN_CONVERSION_LAN_9." ".$name." ".CONTENT_ADMIN_CONVERSION_LAN_10."<br />";
 508                  }
 509                  $create_mainparent = array($checkinsert, $message);        
 510                  return $create_mainparent;
 511          }
 512  
 513  
 514          //analayse unknown rows
 515  		function analyse_unknown(){
 516                  global $sql;
 517  
 518                  if(!is_object($sql)){ $sql = new db; }
 519                  $totaloldrowsunknown = $sql -> db_Select("content", "*", " NOT ( (content_parent = '1' AND content_type = '1') || (content_parent = '0' AND content_type = '1') || (content_parent = '0' AND content_type = '6') || (content_parent = '0' AND content_type = '10') || (content_type = '3' || content_type = '16') || (content_type = '0' || content_type = '15') ) ");
 520  
 521                  while($row = $sql -> db_Fetch()){
 522                      $unknown_bug[]        = $row['content_id']." ".$row['content_heading'];
 523                      $unknown_bug_id[]    = $row['content_id'];
 524                      $unknown_bug_type[]    = "parent=".$row['content_parent']." - type=".$row['content_type'];
 525                  }
 526                  $analyse_unknown = array($unknown_bug, $unknown_bug_id);
 527                  return $analyse_unknown;
 528          }
 529  
 530  
 531          //convert categories
 532  		function convert_category($name, $query, $ordernr){
 533                  global $sql, $plugintable, $tp;
 534                  $plugintable    = "pcontent";
 535  
 536                  // ##### STAGE 7 : INSERT CATEGORY ----------------------------------------------------
 537                  if(!is_object($sql)){ $sql = new db; }
 538                  if(!$sql -> db_Select("content", "*", " ".$query." ORDER BY content_id " )){
 539                      $cat_present = false;
 540                  }else{
 541                      $count = $ordernr;
 542                      $cat_present = true;
 543                      while($row = $sql -> db_Fetch()){
 544  
 545                          //select main parent id
 546                          if(!is_object($sql2)){ $sql2 = new db; }
 547                          $sql2 -> db_Select($plugintable, "content_id", "content_heading = '".$name."' AND content_parent = '0' ");
 548                          list($main_id) = $sql2 -> db_Fetch();
 549  
 550                          //summary can contain link to image in e107_images/link_icons/".$summary." THIS STILL NEEDS TO BE CHECKED
 551                          $newcontent_heading        = $tp -> toDB($row['content_heading']);
 552                          $newcontent_subheading    = ($row['content_subheading'] ? $tp -> toDB($row['content_subheading']) : "");
 553                          $newcontent_summary        = ($row['content_summary'] ? $tp -> toDB($row['content_summary']) : "");
 554                          $newcontent_text        = $tp -> toDB($row['content_content']);
 555                          $newcontent_author        = (is_numeric($row['content_author']) ? $row['content_author'] : "0^".$row['content_author']);
 556                          $newcontent_icon        = "";
 557                          $newcontent_attach        = "";
 558                          $newcontent_images        = "";
 559                          $newcontent_parent        = "0.".$main_id;            //make each category a first level subcat of the main parent
 560                          $newcontent_comment        = $row['content_comment'];
 561                          $newcontent_rate        = "0";
 562                          $newcontent_pe            = $row['content_pe_icon'];
 563                          $newcontent_refer        = "";
 564                          $newcontent_starttime    = $row['content_datestamp'];
 565                          $newcontent_endtime        = "0";
 566                          $newcontent_class        = $row['content_class'];
 567                          $newcontent_pref        = "";
 568                          $newcontent_score        = "0";
 569                          $newcontent_meta        = "";
 570                          $newcontent_layout        = "";
 571  
 572                          if(!is_object($sql3)){ $sql3 = new db; }
 573                          $sql3 -> db_Insert($plugintable, "'".$row['content_id']."', '".$newcontent_heading."', '".$newcontent_subheading."', '".$newcontent_summary."', '".$newcontent_text."', '".$newcontent_author."', '".$newcontent_icon."', '".$newcontent_attach."', '".$newcontent_images."', '".$newcontent_parent."', '".$newcontent_comment."', '".$newcontent_rate."', '".$newcontent_pe."', '".$newcontent_refer."', '".$newcontent_starttime."', '".$newcontent_endtime."', '".$newcontent_class."', '".$newcontent_pref."', '".$count."', '".$newcontent_score."', '".$newcontent_meta."', '".$newcontent_layout."' ");
 574  
 575                          if(!$sql3 -> db_Select($plugintable, "content_id, content_heading", "content_heading = '".$newcontent_heading."' ")){
 576                              $bug_cat_insert[]    = $row['content_id']." ".$row['content_heading'];
 577                          }else{
 578                              $valid_cat_insert[]    = $row['content_id']." ".$row['content_heading'];
 579                              $count = $count + 1;
 580                          }
 581                      }
 582                  }
 583                  $convert_category = array($cat_present, $valid_cat_insert, $bug_cat_insert, $count);
 584                  return $convert_category;
 585          }
 586  
 587  
 588          //convert rows
 589  		function convert_row($name, $query, $startorder){
 590                  global $sql, $tp, $plugintable, $eArrayStorage;
 591                  $plugintable    = "pcontent";
 592  
 593                  // ##### STAGE 8 : INSERT ROW -------------------------------------------------------------
 594                  if(!is_object($sql)){ $sql = new db; }
 595                  if(!$thiscount = $sql -> db_Select("content", "*", " ".$query." ORDER BY content_id " )){
 596                      $check_present = false;
 597                  }else{
 598                      $count = $startorder;
 599                      $check_present = true;
 600                      while($row = $sql -> db_Fetch()){
 601  
 602                          $oldcontentid = $row['content_id'];
 603  
 604                          //select main parent id
 605                          if(!is_object($sql2)){ $sql2 = new db; }
 606                          $sql2 -> db_Select($plugintable, "content_id", "content_heading = '".$name."' AND content_parent = '0' ");
 607                          list($main_id) = $sql2 -> db_Fetch();
 608  
 609                          //item is in main cat
 610                          if($row['content_parent'] == "0"){
 611                              $newcontent_parent = $main_id;
 612  
 613                          //item is in sub cat
 614                          }else{
 615                              //select old review cat heading
 616                              if(!is_object($sql3)){ $sql3 = new db; }
 617                              if(!$sql3 -> db_Select("content", "content_id, content_heading", "content_id = '".$row['content_parent']."' ")){
 618                                  $bug_oldcat[]            = $row['content_id']." ".$row['content_heading'];
 619                                  $newcontent_parent        = $main_id;
 620                              }else{
 621                                  list($old_cat_id, $old_cat_heading) = $sql3 -> db_Fetch();
 622  
 623                                  //select new cat id from the cat with the old_cat_heading
 624                                  if(!is_object($sql4)){ $sql4 = new db; }
 625                                  if(!$sql4 -> db_Select($plugintable, "content_id", "content_heading = '".$old_cat_heading."' AND content_parent = '0.".$main_id."' ")){
 626                                      $bug_newcat[]        = $row['content_id']." ".$row['content_heading'];
 627                                      $newcontent_parent    = $main_id;
 628                                  }else{
 629                                      list($new_cat_id) = $sql4 -> db_Fetch();
 630                                      $newcontent_parent    = $new_cat_id;
 631                                  }
 632                              }
 633                          }
 634                          
 635                          if (strstr($row['content_content'], "{EMAILPRINT}")) {
 636                              $row['content_content'] = str_replace("{EMAILPRINT}", "", $row['content_content']);
 637                          }
 638  
 639                          $newcontent_heading        = $tp -> toDB($row['content_heading']);
 640                          $newcontent_subheading    = ($row['content_subheading'] ? $tp -> toDB($row['content_subheading']) : "");
 641                          //summary can contain link to image in e107_images/link_icons/".$summary." THIS STILL NEEDS TO BE CHECKED
 642                          $newcontent_summary        = ($row['content_summary'] ? $tp -> toDB($row['content_summary']) : "");
 643                          $newcontent_text        = $tp -> toDB($row['content_content']);
 644                          //$newcontent_author    = (is_numeric($row['content_author']) ? $row['content_author'] : "0^".$row['content_author']);
 645                          $newcontent_author        = $row['content_author'];
 646                          $newcontent_icon        = "";
 647                          $newcontent_attach        = "";
 648                          $newcontent_images        = "";
 649                          $newcontent_comment        = $row['content_comment'];
 650                          $newcontent_rate        = "0";
 651                          $newcontent_pe            = $row['content_pe_icon'];
 652                          $newcontent_refer        = ($row['content_type'] == "15" || $row['content_type'] == "16" ? "sa" : "");
 653                          $newcontent_starttime    = $row['content_datestamp'];
 654                          $newcontent_endtime        = "0";
 655                          $newcontent_class        = $row['content_class'];
 656                          $newcontent_pref        = "";
 657                          $newcontent_score        = ($row['content_review_score'] && $row['content_review_score'] != "none" ? $row['content_review_score'] : "0");
 658                          $newcontent_meta        = "";
 659                          $newcontent_layout        = "";
 660  
 661                          if(!is_object($sql5)){ $sql5 = new db; }
 662                          $sql5 -> db_Insert($plugintable, "'".$row['content_id']."', '".$newcontent_heading."', '".$newcontent_subheading."', '".$newcontent_summary."', '".$newcontent_text."', '".$newcontent_author."', '".$newcontent_icon."', '".$newcontent_attach."', '".$newcontent_images."', '".$newcontent_parent."', '".$newcontent_comment."', '".$newcontent_rate."', '".$newcontent_pe."', '".$newcontent_refer."', '".$newcontent_starttime."', '".$newcontent_endtime."', '".$newcontent_class."', '".$newcontent_pref."', '1.".$count."', '".$newcontent_score."', '".$newcontent_meta."', '".$newcontent_layout."' ");
 663  
 664                          if(!is_object($sql6)){ $sql6 = new db; }
 665                          if(!$sql6 -> db_Select($plugintable, "content_id, content_heading", "content_heading = '".$newcontent_heading."' ")){
 666                              $bug_insert[] = $row['content_id']." ".$row['content_heading'];
 667                          }else{
 668                              $valid_insert[] = $row['content_id']." ".$row['content_heading'];
 669                              $count = $count + 1;
 670                          }
 671                      }
 672                  }
 673                  $convert_row = array($check_present, $count, $valid_insert, $bug_insert, $bug_oldcat, $bug_newcat);
 674                  return $convert_row;
 675          }
 676  
 677  
 678          //show output of the category conversion
 679  		function results_conversion_category($name, $array, $oldrows){
 680  
 681                  //no pages present
 682                  if($array[0] === false){
 683                      if( !(count($array[1]) > 0 || count($array[2]) > 0) ){
 684                          $text .= "<tr><td class='forumheader' colspan='2'>".CONTENT_ADMIN_CONVERSION_LAN_34." ".$name." ".CONTENT_ADMIN_CONVERSION_LAN_35."</td></tr>";
 685                      }
 686                  
 687                  //pages present
 688                  }else{
 689                  
 690                      //valid inserts
 691                      if(count($array[1]) > 0 ){
 692                          $text .= "
 693                          <tr>
 694                              <td class='forumheader3' style='width:5%; white-space:nowrap; vertical-align:top;'>".CONTENT_ADMIN_CONVERSION_LAN_3." : ".count($array[1])." ".CONTENT_ADMIN_CONVERSION_LAN_38."</td>
 695                              <td class='forumheader3'><a style='cursor:pointer;' onclick=\"expandit('validcat_{$name}');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a>
 696                                  <div id='validcat_{$name}' style='display: none;'>
 697                                      <table style='width:100%; border:0;'>";
 698                                      for($i=0;$i<count($array[1]);$i++){
 699                                          $text .= "
 700                                          <tr>
 701                                              <td style='width:25%; white-space:nowrap;'>".CONTENT_ICON_OK." ".$array[1][$i]."</td>
 702                                              <td>".$name." ".CONTENT_ADMIN_CONVERSION_LAN_3." ".CONTENT_ADMIN_CONVERSION_LAN_26."</td>
 703                                          </tr>";
 704                                      }
 705                                      $text .= "
 706                                      </table>
 707                                  </div>
 708                              </td>
 709                          </tr>";
 710                      }
 711  
 712                      //bug inserts
 713                      if(count($array[2]) > 0 ){
 714                          $text .= "
 715                          <tr>
 716                              <td class='forumheader3' style='width:5%; white-space:nowrap; vertical-align:top;'>".CONTENT_ADMIN_CONVERSION_LAN_3." : ".count($array[2])." ".CONTENT_ADMIN_CONVERSION_LAN_39."</td>
 717                              <td class='forumheader3'><a style='cursor:pointer;' onclick=\"expandit('failedcat_{$name}');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a>
 718                                  <div id='failedcat_{$name}' style='display: none;'>
 719                                      <table style='width:100%; border:0;'>";
 720                                      for($i=0;$i<count($array[2]);$i++){
 721                                          $text .= "
 722                                          <tr>
 723                                              <td style='width:25%; white-space:nowrap;'>".CONTENT_ICON_ERROR." ".$array[2][$i]."</td>
 724                                              <td>".CONTENT_ADMIN_CONVERSION_LAN_23."</td>
 725                                          </tr>";
 726                                      }
 727                                      $text .= "
 728                                      </table>
 729                                  </div>
 730                              </td>
 731                          </tr>";
 732                      }
 733                      $text .= "
 734                      <tr>
 735                          <td class='forumheader3' style='width:5%; white-space:nowrap; vertical-align:top;'>".CONTENT_ADMIN_CONVERSION_LAN_3." : ".CONTENT_ADMIN_CONVERSION_LAN_27."</td>
 736                          <td class='forumheader3'>
 737                              <a style='cursor: pointer; cursor: hand' onclick=\"expandit('analysecat_{$name}');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a>
 738                              <div id='analysecat_{$name}' style='display: none;'>
 739                                  <table style='width:100%; border:0;'>
 740                                  <tr><td style='width:25%; white-space:nowrap;'>".CONTENT_ADMIN_CONVERSION_LAN_28."</td><td>".$oldrows."</td></tr>
 741                                  <tr><td style='width:25%; white-space:nowrap;'>".CONTENT_ADMIN_CONVERSION_LAN_29."</td><td>".count($array[1])."</td></tr>
 742                                  <tr><td style='width:25%; white-space:nowrap;'>".CONTENT_ADMIN_CONVERSION_LAN_30."</td><td>".count($array[2])."</td></tr>
 743                                  </table>
 744                              </div>
 745                          </td>
 746                      </tr>";
 747                  }
 748                  return $text;
 749          }
 750  
 751  
 752          //show output of the item conversion
 753  		function results_conversion_row($name, $array, $oldrows){
 754  
 755                  //no rows present
 756                  if($array[0] === false){
 757                      $text .= "<tr><td class='forumheader' colspan='2'>".CONTENT_ADMIN_CONVERSION_LAN_34." ".$name." ".CONTENT_ADMIN_CONVERSION_LAN_36."</td></tr>";
 758                  
 759                  //rows present
 760                  }else{
 761                  
 762                      //valid insert
 763                      if(count($array[2]) > 0 ){
 764                          $text .= "
 765                          <tr>
 766                              <td class='forumheader3' style='width:5%; white-space:nowrap; vertical-align:top;'>".CONTENT_ADMIN_CONVERSION_LAN_6." : ".count($array[2])." ".CONTENT_ADMIN_CONVERSION_LAN_38."</td>
 767                              <td class='forumheader3'>
 768                                  <a style='cursor:pointer;' onclick=\"expandit('valid_{$name}');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a>
 769                                  <div id='valid_{$name}' style='display: none;'>
 770                                      <table style='width:100%; border:0;'>";
 771                                      for($i=0;$i<count($array[2]);$i++){
 772                                          $text .= "
 773                                          <tr>
 774                                              <td style='width:25%; white-space:nowrap;'>".CONTENT_ICON_OK." ".$array[2][$i]."</td>
 775                                              <td>".$name." ".CONTENT_ADMIN_CONVERSION_LAN_6." ".CONTENT_ADMIN_CONVERSION_LAN_26."</td>
 776                                          </tr>";
 777                                      }
 778                                      $text .= "
 779                                      </table>
 780                                  </div>
 781                              </td>
 782                          </tr>";
 783                      }
 784                      //bugs : old category
 785                      if(count($array[4]) > 0 ){
 786                          $text .= "
 787                          <tr>
 788                              <td class='forumheader3' style='width:5%; white-space:nowrap; vertical-align:top;'>".CONTENT_ADMIN_CONVERSION_LAN_6." : ".count($array[4])." ".CONTENT_ADMIN_CONVERSION_LAN_31."</td>
 789                              <td class='forumheader3'>
 790                                  <a style='cursor:pointer;' onclick=\"expandit('oldcat_{$name}');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a>
 791                                  <div id='oldcat_{$name}' style='display: none;'>
 792                                      <table style='width:100%; border:0;'>";
 793                                      for($i=0;$i<count($array[4]);$i++){
 794                                          $text .= "
 795                                          <tr>
 796                                              <td style='width:25%; white-space:nowrap;'>".CONTENT_ICON_WARNING." ".$array[4][$i]."</td>
 797                                              <td>".CONTENT_ADMIN_CONVERSION_LAN_32."</td>
 798                                          </tr>";
 799                                      }
 800                                      $text .= "
 801                                      </table>
 802                                  </div>
 803                              </td>
 804                          </tr>";
 805                      }
 806                      //bugs : new category
 807                      if(count($array[5]) > 0 ){
 808                          $text .= "
 809                          <tr>
 810                              <td class='forumheader3' style='width:5%; white-space:nowrap; vertical-align:top;'>".CONTENT_ADMIN_CONVERSION_LAN_6." : ".count($array[5])." ".CONTENT_ADMIN_CONVERSION_LAN_31."</td>
 811                              <td class='forumheader3'>
 812                                  <a style='cursor:pointer;' onclick=\"expandit('newcat_{$name}');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a>
 813                                  <div id='newcat_{$name}' style='display: none;'>
 814                                      <table style='width:100%; border:0;'>";
 815                                      for($i=0;$i<count($array[5]);$i++){
 816                                          $text .= "
 817                                          <tr>
 818                                              <td style='width:25%; white-space:nowrap;'>".CONTENT_ICON_WARNING." ".$array[5][$i]."</td>
 819                                              <td>".CONTENT_ADMIN_CONVERSION_LAN_33."</td>
 820                                          </tr>";
 821                                      }
 822                                      $text .= "
 823                                      </table>
 824                                  </div>
 825                              </td>
 826                          </tr>";
 827                      }
 828                      //bugs : insertion failed
 829                      if(count($array[3]) > 0 ){
 830                          $text .= "
 831                          <tr>
 832                              <td class='forumheader3' style='width:5%; white-space:nowrap; vertical-align:top;'>".CONTENT_ADMIN_CONVERSION_LAN_6." : ".count($array[3])." ".CONTENT_ADMIN_CONVERSION_LAN_39."</td>
 833                              <td class='forumheader3'>
 834                                  <a style='cursor: pointer; cursor: hand' onclick=\"expandit('failed_{$name}');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a>
 835                                  <div id='failed_{$name}' style='display: none;'>
 836                                      <table style='width:100%; border:0;'>";
 837                                      for($i=0;$i<count($array[3]);$i++){
 838                                          $text .= "
 839                                          <tr>
 840                                              <td style='width:25%; white-space:nowrap;'>".CONTENT_ICON_ERROR." ".$array[3][$i]."</td>
 841                                              <td>".CONTENT_ADMIN_CONVERSION_LAN_23."</td>
 842                                          </tr>";
 843                                      }
 844                                      $text .= "
 845                                      </table>
 846                                  </div>
 847                              </td>
 848                          </tr>";
 849                      }
 850                      
 851                      //analyses
 852                      $text .= "
 853                      <tr>
 854                          <td class='forumheader3' style='width:5%; white-space:nowrap; vertical-align:top;'>".CONTENT_ADMIN_CONVERSION_LAN_6." : ".CONTENT_ADMIN_CONVERSION_LAN_27."</td>
 855                          <td class='forumheader3'>
 856                              <a style='cursor: pointer; cursor: hand' onclick=\"expandit('analyse_{$name}');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a>
 857                              <div id='analyse_{$name}' style='display: none;'>
 858                                  <table style='width:100%; border:0;'>
 859                                  <tr><td style='width:25%; white-space:nowrap;'>".CONTENT_ADMIN_CONVERSION_LAN_28."</td><td>".$oldrows."</td></tr>
 860                                  <tr><td style='width:25%; white-space:nowrap;'>".CONTENT_ADMIN_CONVERSION_LAN_29."</td><td>".count($array[2])."</td></tr>
 861                                  <tr><td style='width:25%; white-space:nowrap;'>".CONTENT_ADMIN_CONVERSION_LAN_30."</td><td>".count($array[3])."</td></tr>
 862                                  <tr><td style='width:25%; white-space:nowrap;'>".CONTENT_ADMIN_CONVERSION_LAN_31."</td><td>".count($array[4])."</td></tr>
 863                                  <tr><td style='width:25%; white-space:nowrap;'>".CONTENT_ADMIN_CONVERSION_LAN_31."</td><td>".count($array[5])."</td></tr>
 864                                  </table>
 865                              </div>
 866                          </td>
 867                      </tr>";
 868                  }
 869  
 870  
 871                  return $text;
 872          }
 873  
 874  
 875          //show output of the mainparent conversion
 876  		function results_conversion_mainparent($content, $review, $article){
 877                  $text = "<tr><td class='fcaption' colspan='2'>".CONTENT_ADMIN_CONVERSION_LAN_50."</td></tr>";
 878                  $text .= "
 879                  <tr>
 880                      <td class='forumheader3' style='width:5%; white-space:nowrap; vertical-align:top;'>".($content[0] == "1" ? CONTENT_ICON_OK : CONTENT_ICON_ERROR)." ".CONTENT_ADMIN_CONVERSION_LAN_20."</td>
 881                      <td class='forumheader3'>
 882                          <a style='cursor: pointer; cursor: hand' onclick=\"expandit('contentmain');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a>
 883                          <div id='contentmain' style='display: none;'>
 884                              ".$content[1]."
 885                          </div>
 886                      </td>
 887                  </tr>
 888                  <tr>
 889                      <td class='forumheader3' style='width:5%; white-space:nowrap; vertical-align:top;'>".($review[0] == "1" ? CONTENT_ICON_OK : CONTENT_ICON_ERROR)." ".CONTENT_ADMIN_CONVERSION_LAN_21."</td>
 890                      <td class='forumheader3'>
 891                          <a style='cursor: pointer; cursor: hand' onclick=\"expandit('reviewmain');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a>
 892                          <div id='reviewmain' style='display: none;'>
 893                              ".$review[1]."
 894                          </div>
 895                      </td>
 896                  </tr>
 897                  <tr>
 898                      <td class='forumheader3' style='width:5%; white-space:nowrap; vertical-align:top;'>".($article[0] == "1" ? CONTENT_ICON_OK : CONTENT_ICON_ERROR)." ".CONTENT_ADMIN_CONVERSION_LAN_22."</td>
 899                      <td class='forumheader3'>
 900                          <a style='cursor: pointer; cursor: hand' onclick=\"expandit('articlemain');\">".CONTENT_ADMIN_CONVERSION_LAN_48."</a>
 901                          <div id='articlemain' style='display: none;'>
 902                              ".$article[1]."
 903                          </div>
 904                      </td>
 905                  </tr>";
 906  
 907                              
 908  
 909                  return $text;
 910          }
 911  
 912  }
 913  
 914  ?>


Généré le : Sun Apr 1 01:23:32 2007 par Balluche grâce à PHPXref 0.7