Ignore:
Timestamp:
Mar 18, 2010, 11:47:11 PM (14 years ago)
Author:
grum
Message:

database is partially filled during the install process, and fill database picture per picture each time a page is displayed (and until all the database is filled)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/AMetaData/amd_install.class.inc.php

    r5040 r5183  
    2727    private $tablef;
    2828
    29     public function AMD_install($prefixeTable, $filelocation)
     29    public function __construct($prefixeTable, $filelocation)
    3030    {
    3131      parent::__construct($prefixeTable, $filelocation);
    3232      $this->tablef= new manage_tables($this->tables);
     33    }
     34
     35    public function __destruct()
     36    {
     37      unset($this->tablef);
     38      parent::__destruct();
    3339    }
    3440
     
    126132      pwg_query("DELETE FROM ".$this->tables['images_tags']);
    127133      pwg_query("UPDATE ".$this->tables['images']." SET analyzed='n', nbTags=0;");
     134      pwg_query("INSERT INTO ".$this->tables['images']."
     135                  SELECT id, 'n', 0
     136                    FROM ".IMAGES_TABLE."
     137                    WHERE id NOT IN (SELECT imageId FROM ".$this->tables['images'].")");
    128138      /*
    129139       * fill the 'used_tags' table with default values
     
    133143        $sql="INSERT INTO ".$this->tables['used_tags']." VALUES('', '".$key."', '".(($val['translatable'])?'y':'n')."', '".$val['name']."', 0);";
    134144        pwg_query($sql);
     145      }
     146
     147      $listToAnalyze=Array(Array(), Array());
     148      /*
     149       * select 25 pictures into the caddie
     150       */
     151      $sql="SELECT ti.id, ti.path
     152            FROM ".CADDIE_TABLE." tc
     153              LEFT JOIN ".IMAGES_TABLE." ti ON ti.id = tc.element_id
     154            ORDER BY RAND() LIMIT 25;";
     155      $result=pwg_query($sql);
     156      if($result)
     157      {
     158        while($row=mysql_fetch_assoc($result))
     159        {
     160          $listToAnalyze[0][]=$row;
     161          $listToAnalyze[1][]=$row['id'];
     162        }
     163      }
     164      /*
     165       * if caddie is empty, of is have less than 25 pictures, select other
     166       * pictures from the gallery
     167       */
     168      if(count($listToAnalyze[0])<25)
     169      {
     170        if(count($listToAnalyze[0])>0)
     171        {
     172          $excludeList="WHERE ti.id NOT IN(".implode(",", $listToAnalyze[1]).") ";
     173        }
     174        else
     175        {
     176          $excludeList="";
     177        }
     178        $sql="SELECT ti.id, ti.path
     179              FROM ".IMAGES_TABLE." ti ".$excludeList."
     180              ORDER BY RAND() LIMIT ".(25-count($listToAnalyze[0])).";";
     181        $result=pwg_query($sql);
     182        if($result)
     183        {
     184          while($row=mysql_fetch_assoc($result))
     185          {
     186            $listToAnalyze[0][]=$row;
     187          }
     188        }
     189      }
     190
     191      /*
     192       * analyze the 25 selected pictures
     193       */
     194      if(count($listToAnalyze[0])>0)
     195      {
     196        // $path = path of piwigo's on the server filesystem
     197        $path=dirname(dirname(dirname(__FILE__)));
     198
     199        foreach($listToAnalyze[0] as $val)
     200        {
     201          $this->analyzeImageFile($path."/".$val['path'], $val['id']);
     202        }
     203
     204        $this->makeStatsConsolidation();
    135205      }
    136206
Note: See TracChangeset for help on using the changeset viewer.