Ignore:
Timestamp:
May 17, 2010, 7:46:39 PM (14 years ago)
Author:
grum
Message:

Fix some bugs on the request builder and improve results display

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php

    r6174 r6208  
    366366    if($clearAll)
    367367    {
    368       $sql="DELETE FROM ".$this->tables['result_cache'];
     368      $sql="DELETE FROM ".self::$tables['result_cache'];
    369369    }
    370370    else
    371371    {
    372       $sql="DELETE FROM ".$this->tables['result_cache']." pgrc, ".$this->tables['request']." pgr
    373             WHERE pgrc.id = pgr.id
    374               AND pgr.date < '".date('Y-m-d H:i:s', strtotime("-2 hour"))."'";
     372      $sql="DELETE pgrc FROM ".self::$tables['result_cache']." pgrc
     373              LEFT JOIN ".self::$tables['request']." pgr
     374                ON pgrc.id = pgr.id
     375              WHERE pgr.date < '".date('Y-m-d H:i:s', strtotime("-2 hour"))."'";
    375376    }
    376377    pwg_query($sql);
     
    386387  {
    387388    global $user;
     389
     390    self::clearCache();
    388391
    389392    $registeredPlugin=self::getRegistered();
     
    428431    {
    429432      $pluginNeeded[$val['owner']][$key]=$_REQUEST['extraData'][$key]['param'];
    430       $pluginList[]=$val['owner'];
     433      $pluginList[$val['owner']]=$val['owner'];
    431434    }
    432435
     
    512515      self::updateRequest($requestNumber, $numberItems, 0, implode(',', $pluginList));
    513516
     517
    514518      return("$requestNumber;".$numberItems);
    515519    }
    516520
    517     self::clearCache();
    518 
    519     return($sql);
     521    return("0;0");
    520522  }
    521523
     
    538540    }
    539541
    540     $limitFrom=$numPerPage*($pageNumber-1)+1;
    541     $limitTo=$numPerPage*$pageNumber;
     542    $limitFrom=$numPerPage*($pageNumber-1);
    542543
    543544    $pluginNeeded=explode(',', $request['connected_plugin']);
     
    554555        'RB_PIT' => "pit.id AS imageId, pit.name AS imageName, pit.path AS imagePath", // from the piwigo's image table
    555556        'RB_PIC' => "GROUP_CONCAT(pic.category_id SEPARATOR ',') AS imageCategoriesId",     // from the piwigo's image_category table
    556         'RB_PCT' => "GROUP_CONCAT(pct.name SEPARATOR '#sep#') AS imageCategoriesNames",   //from the piwigo's categories table
     557        'RB_PCT' => "GROUP_CONCAT(CASE WHEN pct.name IS NULL THEN '' ELSE pct.name END SEPARATOR '#sep#') AS imageCategoriesNames,
     558                     GROUP_CONCAT(CASE WHEN pct.permalink IS NULL THEN '' ELSE pct.permalink END SEPARATOR '#sep#') AS imageCategoriesPLink,
     559                     GROUP_CONCAT(CASE WHEN pct.dir IS NULL THEN 'V' ELSE 'P' END) AS imageCategoriesDir",   //from the piwigo's categories table
    557560      ),
    558561      'FROM' => Array(
     
    635638        .' GROUP BY '.$build['GROUPBY']
    636639        .' ORDER BY pit.id '
    637         .' LIMIT '.$limitFrom.', '.$limitTo;
     640        .' LIMIT '.$limitFrom.', '.$numPerPage;
    638641
    639642    $result=pwg_query($sql);
     
    647650        $datas['imagePath']=$row['imagePath'];
    648651        $datas['imageName']=$row['imageName'];
     652
    649653        $datas['imageCategoriesId']=explode(',', $row['imageCategoriesId']);
    650654        $datas['imageCategoriesNames']=explode('#sep#', $row['imageCategoriesNames']);
     655        $datas['imageCategoriesPLink']=explode('#sep#', $row['imageCategoriesPLink']);
     656        $datas['imageCategoriesDir']=explode(',', $row['imageCategoriesDir']);
     657
     658
     659        $datas['imageCategories']=Array();
     660        for($i=0;$i<count($datas['imageCategoriesId']);$i++)
     661        {
     662          $datas['imageCategories'][]=array(
     663            'id' => $datas['imageCategoriesId'][$i],
     664            'name' => $datas['imageCategoriesNames'][$i],
     665            'dirType' => $datas['imageCategoriesDir'][$i],
     666            'pLinks' => $datas['imageCategoriesPLink'][$i],
     667            'link'=> make_index_url(
     668                              array(
     669                                'category' => array(
     670                                  'id' => $datas['imageCategoriesId'][$i],
     671                                  'name' => $datas['imageCategoriesNames'][$i],
     672                                  'permalink' => $datas['imageCategoriesPLink'][$i])
     673                              )
     674                            )
     675          );
     676        }
    651677
    652678        /* affect datas for each plugin
Note: See TracChangeset for help on using the changeset viewer.