Changeset 6894
- Timestamp:
- Sep 13, 2010, 8:54:21 PM (14 years ago)
- Location:
- extensions/GrumPluginClasses
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php
r6213 r6894 2 2 /* ----------------------------------------------------------------------------- 3 3 class name: GCPRequestBuilder 4 class version : 1. 0.04 class version : 1.1.0 5 5 plugin version : 3.1.0 6 date : 2010-0 4-296 date : 2010-09-08 7 7 8 8 ------------------------------------------------------------------------------ … … 14 14 << May the Little SpaceFrog be with you ! >> 15 15 ------------------------------------------------------------------------------ 16 16 * 17 17 * theses classes provides base functions to manage search pictures in the 18 18 * database 19 19 * 20 21 20 * 21 * HOW TO USE IT ? 22 * =============== 23 * 24 * when installing the plugin, you have to register the usage of the request 25 * builder 26 * 27 * 1/ Create a RBCallback class 28 * - extends the GPCSearchCallback class ; the name of the extended class must 29 * be "RBCallBack%" => replace the "%" by the plugin name 30 * for example : 'ThePlugin' => 'RBCallBackThePlugin' 31 * 32 * 2/ In the plugin 'maintain.inc.php' file : 33 * - function plugin_install, add : 34 * GPCRequestBuilder::register('plugin name', 'path to the RBCallback classe'); 35 * for example : GPCRequestBuilder::register('ThePlugin', $piwigo_path.'plugins/ThePlugin/rbcallback_file_name.php'); 36 * 37 * 38 * - function plugin_uninstall, add : 39 * GPCRequestBuilder::unregister('plugin name'); 40 * for example : GPCRequestBuilder::unregister('ThePlugin'); 41 * 42 * 3/ In the plugin code, put somewhere 43 * GPCRequestBuilder::loadJSandCSS(); 44 * => this will load specific JS and CSS in the page, by adding url in the 45 * the header, so try to put this where you're used to prepare the header 46 * 47 * 4/ to display the request builder, just add the returned string in the html 48 * page 49 * $stringForTheTemplate=GPCRequestBuilder::displaySearchPage(); 50 * 51 * 52 * 53 * HOW DOES THE REQUEST BUILDER WORKS ? 54 * ==================================== 55 * 56 * the request builder works in 2 steps : 57 * - first step : build a cache, to associate all image id corresponding to 58 * the search criterion 59 * the cache is an association of request ID/image id 60 * - second step : use the cache to retrieve images informations 61 * 22 62 ------------------------------------------------------------------------------ 23 63 :: HISTORY … … 25 65 | release | date | 26 66 | 1.0.0 | 2010/04/30 | * start coding 67 | | | 68 | 1.1.0 | 2010/09/08 | * add functionnalities to manage complex requests 27 69 | | | 28 70 | | | … … 34 76 | | | 35 77 | | | 36 | | |37 | | |38 78 39 79 --------------------------------------------------------------------------- */ … … 42 82 include_once('GPCTables.class.inc.php'); 43 83 44 84 /** 85 * 86 * Preparing the cache 87 * ------------------- 88 * To prepare the cache, the request builder use the following functions : 89 * - getFrom 90 * - getWhere 91 * - getJoin 92 * - getImageId (used for multirecord requests only) 93 * 94 * Retrieving the results 95 * ---------------------- 96 * To retrieve the image informations, the request builder uses the following 97 * functions : 98 * - getSelect 99 * - getFrom 100 * - getJoin 101 * - getFilter (in fact, the result of this function is stored while the cache 102 * is builded, but it is used only when retrieving the results for 103 * multirecord tables) 104 * 105 * 106 * Example 1 : single record request 107 * --------------------------------- 108 * Consider the table "tableA" like this 109 * 110 * - (*) imageId 111 * - att1 112 * - att2 113 * The primary key is the 'imageId' attribute 114 * => for one imageId, you can only have ZERO or ONE record 115 * 116 * getSelect returns : "tableA.att1, tableA.att2" 117 * getFrom returns : "tableA" 118 * getWhere returns : "tableA.att1 = zzzz" 119 * getJoin returns : "tableA.imageId = pit.id" 120 * getFilter returns : "" 121 * 122 * 123 * Example 2 : multi records request 124 * --------------------------------- 125 * Consider the table "tableA" like this 126 * 127 * - (*) imageId 128 * - (*) localId 129 * - att1 130 * - att2 131 * The primary key is the 'imageId'+'localId' attributes 132 * => for one imageId, you can have ZERO or more than ONE record 133 * when you register the class, you have to set the $multiRecord parameter 134 * to 'y' 135 * 136 * gatImageId returns : "tableA.imageId" 137 * getSelect returns : "tableA.att1, tableA.att2" 138 * getFrom returns : "tableA" 139 * getWhere returns : "tableA.att1 = zzzz AND tableA.att1 = xxxx" 140 * getJoin returns : "tableA.id = pit.id" 141 * getFilter returns : "" 142 * 143 */ 45 144 class GPCSearchCallback { 46 145 47 146 /** 147 * the getImageId returns the name of the image id attribute 148 * return String 149 */ 150 static public function getImageId() 151 { 152 return(""); 153 } 154 155 /** 48 156 * the getSelect function must return an attribute list separated with a comma 49 157 * 50 158 * "att1, att2, att3, att4" 159 * 160 * you can specifie tables names and aliases 161 * 162 * "table1.att1 AS alias1, table1.att2 AS alias2, table2.att3 AS alias3" 51 163 */ 52 164 static public function getSelect($param="") … … 76 188 77 189 /** 78 * the getJoin function must return a ready to use where allowing to join the79 * IMAGES table (key : pit.id) with given conditions190 * the getJoin function must return a ready to use sql statement allowing to 191 * join the IMAGES table (key : pit.id) with given conditions 80 192 * 81 193 * "att3 = pit.id " … … 86 198 } 87 199 200 201 /** 202 * the getFilter function must return a ready to use where clause 203 * this where clause is used to filter the cache when the used tables can 204 * return more than one result 205 * 206 * the filter can be empty, can be equal to the where clause, or can be equal 207 * to a sub part of the where clause 208 * 209 */ 210 static public function getFilter($param="") 211 { 212 return(self::getWhere($param)); 213 } 88 214 89 215 /** … … 152 278 153 279 static public $pluginName = 'GPCRequestBuilder'; 154 static public $version = '1. 0.0';280 static public $version = '1.1.0'; 155 281 156 282 static private $tables = Array(); 283 static protected $tGlobalId=0; 157 284 158 285 /** … … 173 300 'fileName' => $fileName, 174 301 'date' => date("Y-m-d H:i:s"), 175 'version' => self::$version ,302 'version' => self::$version 176 303 ); 177 304 return(GPCCore::saveConfig(self::$pluginName, $config)); … … 232 359 static public function init($prefixeTable, $pluginNameFile) 233 360 { 234 $list=Array('request', 'result_cache' );361 $list=Array('request', 'result_cache', 'temp'); 235 362 236 363 for($i=0;$i<count($list);$i++) … … 253 380 `execution_time` float unsigned NOT NULL default '0', 254 381 `connected_plugin` char(255) NOT NULL, 382 `filter` text NOT NULL, 255 383 PRIMARY KEY (`id`) 256 384 ) … … 263 391 ) 264 392 CHARACTER SET utf8 COLLATE utf8_general_ci", 393 394 "CREATE TABLE `".self::$tables['temp']."` ( 395 `requestId` char(30) NOT NULL, 396 `imageId` mediumint(8) unsigned NOT NULL, 397 PRIMARY KEY (`request`,`id`) 398 ) 399 CHARACTER SET utf8 COLLATE utf8_general_ci", 265 400 ); 266 401 … … 277 412 { 278 413 $tablef= new GPCTables(self::$tables); 279 $tablef->drop( $tables_def);414 $tablef->drop(); 280 415 return(true); 281 416 } … … 378 513 379 514 /** 515 * prepare the temporary table used for multirecord requests 516 * 517 * @param Integer $requestNumber : id of request 518 * @return String : name of the request key temporary table 519 */ 520 static private function prepareTempTable($requestNumber) 521 { 522 //$tableName=call_user_func(Array('RBCallBack'.$plugin, 'getFrom')); 523 //$imageIdName=call_user_func(Array('RBCallBack'.$plugin, 'getImageId')); 524 525 $tempWHERE=array(); 526 foreach($_REQUEST['extraData'] as $key => $extraData) 527 { 528 $tmpWHERE[$key]=array( 529 'plugin' => $extraData['owner'], 530 'where' => call_user_func(Array('RBCallBack'.$extraData['owner'], 'getWhere'), $extraData['param']) 531 ); 532 } 533 534 $sql="INSERT INTO ".self::$tables['temp']." ".self::buildGroupRequest($_REQUEST[$_REQUEST['requestName']], $tmpWHERE, $_REQUEST['operator'], ' AND ', $requestNumber); 535 //echo $sql; 536 $result=pwg_query($sql); 537 538 return($requestNumber); 539 } 540 541 /** 542 * clear the temporary table used for multirecord requests 543 * 544 * @param Array $requestNumber : the requestNumber to delete 545 */ 546 static private function clearTempTable($requestNumber) 547 { 548 $sql="DELETE FROM ".self::$tables['temp']." WHERE requestId = '$requestNumber';"; 549 pwg_query($sql); 550 } 551 552 553 /** 380 554 * execute a query, and place result in cache 381 555 * … … 390 564 391 565 $registeredPlugin=self::getRegistered(); 566 $requestNumber=self::getNewRequest($user['id']); 392 567 393 568 $build=Array( … … 396 571 'WHERE' => '', 397 572 'GROUPBY' => '', 573 'FILTER' => '', 398 574 ); 399 575 $tmpBuild=Array( … … 407 583 'GROUPBY' => Array( 408 584 'pit.id' 409 ) 585 ), 586 'FILTER' => Array(), 410 587 ); 411 588 … … 429 606 $pluginNeeded=Array(); 430 607 $pluginList=Array(); 608 $tempName=Array(); 431 609 foreach($_REQUEST['extraData'] as $key => $val) 432 610 { … … 435 613 } 436 614 437 /* for each needed plugin : 438 * - include the file 439 * - call the static public function getWhere 440 */ 615 /* for each plugin, include the rb callback class file */ 616 foreach($pluginList as $val) 617 { 618 if(file_exists($registeredPlugin[$val]['fileName'])) 619 { 620 include_once($registeredPlugin[$val]['fileName']); 621 } 622 } 623 624 /* prepare the temp table for the request */ 625 self::prepareTempTable($requestNumber); 626 $tmpBuild['FROM'][]=self::$tables['temp']; 627 $tmpBuild['JOIN'][]=self::$tables['temp'].".requestId = '".$requestNumber."' 628 AND ".self::$tables['temp'].".imageId = pit.id"; 629 630 /* for each needed plugin, prepare the filter */ 441 631 foreach($pluginNeeded as $key => $val) 442 632 { 443 if(array_key_exists($key, $registeredPlugin)) 444 { 445 if(file_exists($registeredPlugin[$key]['fileName'])) 446 { 447 include_once($registeredPlugin[$key]['fileName']); 448 449 $tmpBuild['FROM'][]=call_user_func(Array('RBCallBack'.$key, 'getFrom')); 450 $tmpBuild['JOIN'][]=call_user_func(Array('RBCallBack'.$key, 'getJoin')); 451 452 foreach($val as $itemNumber => $param) 453 { 454 $tmpBuild['WHERE'][$itemNumber]=call_user_func(Array('RBCallBack'.$key, 'getWhere'), $param); 455 } 456 } 633 foreach($val as $itemNumber => $param) 634 { 635 $tmpBuild['FILTER'][$key][]='('.call_user_func(Array('RBCallBack'.$key, 'getFilter'), $param).')'; 457 636 } 458 637 } … … 475 654 476 655 656 /* build FILTER 657 */ 658 self::cleanArray($tmpBuild['FILTER']); 659 if(count($tmpBuild['FILTER'])>0) 660 { 661 $tmp=array(); 662 foreach($tmpBuild['FILTER'] as $key=>$val) 663 { 664 $tmp[$key]='('.implode(' OR ', $val).')'; 665 } 666 $build['FILTER']=' ('.implode(' AND ', $tmp).') '; 667 // array_flip twice => simply remove identical values... 668 //$build['FILTER']=' ('.implode(' AND ', array_flip(array_flip($tmpBuild['FILTER']))).') '; 669 } 670 unset($tmpBuild['FILTER']); 671 672 477 673 /* for each plugin, adds jointure with the IMAGE table 478 674 */ … … 480 676 if(count($tmpBuild['JOIN'])>0) 481 677 { 482 $build['WHERE'].=' AND ('.implode(' AND ', $tmpBuild['JOIN']).') '; 678 if($build['WHERE']!='') $build['WHERE'].=' AND '; 679 $build['WHERE'].=' ('.implode(' AND ', $tmpBuild['JOIN']).') '; 483 680 } 484 681 unset($tmpBuild['JOIN']); … … 505 702 $sql.=" ORDER BY pit.id "; 506 703 507 $requestNumber=self::getNewRequest($user['id']);508 509 704 $sql="INSERT INTO ".self::$tables['result_cache']." (SELECT DISTINCT $requestNumber, ".$build['SELECT']." $sql)"; 705 706 //echo $sql; 707 708 $returned="0;0"; 510 709 511 710 $result=pwg_query($sql); … … 513 712 { 514 713 $numberItems=pwg_db_changes($result); 515 self::updateRequest($requestNumber, $numberItems, 0, implode(',', $pluginList)); 516 517 518 return("$requestNumber;".$numberItems); 519 } 520 521 return("0;0"); 714 self::updateRequest($requestNumber, $numberItems, 0, implode(',', $pluginList), $build['FILTER']); 715 716 $returned="$requestNumber;".$numberItems; 717 } 718 719 self::clearTempTable($requestNumber); 720 721 return($returned); 522 722 } 523 723 … … 554 754 'SELECT' => Array( 555 755 'RB_PIT' => "pit.id AS imageId, pit.name AS imageName, pit.path AS imagePath", // from the piwigo's image table 556 'RB_PIC' => "GROUP_CONCAT( pic.category_id SEPARATOR ',') AS imageCategoriesId", // from the piwigo's image_category table557 '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 table756 'RB_PIC' => "GROUP_CONCAT(DISTINCT pic.category_id SEPARATOR ',') AS imageCategoriesId", // from the piwigo's image_category table 757 'RB_PCT' => "GROUP_CONCAT(DISTINCT CASE WHEN pct.name IS NULL THEN '' ELSE pct.name END SEPARATOR '#sep#') AS imageCategoriesNames, 758 GROUP_CONCAT(DISTINCT CASE WHEN pct.permalink IS NULL THEN '' ELSE pct.permalink END SEPARATOR '#sep#') AS imageCategoriesPLink, 759 GROUP_CONCAT(DISTINCT CASE WHEN pct.dir IS NULL THEN 'V' ELSE 'P' END) AS imageCategoriesDir", //from the piwigo's categories table 560 760 ), 561 761 'FROM' => Array( … … 591 791 { 592 792 include_once($registeredPlugin[$val]['fileName']); 593 $tmpBuild['SELECT'][$val]=call_user_func(Array('RBCallBack'.$val, 'getSelect')); 793 794 $tmp=explode(',', call_user_func(Array('RBCallBack'.$val, 'getSelect'))); 795 foreach($tmp as $key2=>$val2) 796 { 797 $tmp[$key2]=self::groupConcatAlias($val2, '#sep#'); 798 } 799 $tmpBuild['SELECT'][$val]=implode(',', $tmp); 594 800 $tmpBuild['FROM'][$val]=call_user_func(Array('RBCallBack'.$val, 'getFrom')); 595 801 $tmpBuild['JOIN'][$val]=call_user_func(Array('RBCallBack'.$val, 'getJoin')); … … 612 818 /* build WHERE 613 819 */ 820 if($request['filter']!='') $tmpBuild['WHERE'][]=$request['filter']; 614 821 $build['WHERE']=implode(' AND ', $tmpBuild['WHERE']); 615 822 unset($tmpBuild['WHERE']); … … 641 848 .' ORDER BY pit.id ' 642 849 .' LIMIT '.$limitFrom.', '.$numPerPage; 643 850 //echo $sql; 644 851 $result=pwg_query($sql); 645 852 if($result) … … 737 944 foreach($array as $key => $val) 738 945 { 739 if(trim($val)=='') unset($array[$key]); 946 if(is_array($val)) 947 { 948 self::cleanArray($val); 949 if(count($val)==0) unset($array[$key]); 950 } 951 elseif(trim($val)=='') unset($array[$key]); 740 952 } 741 953 } … … 744 956 * returns the alias for an attribute 745 957 * 746 * item1 => returns item1 747 * table1.item1 => returns item1 748 * table1.item1 AS alias1 => returns alias1 749 * item1 AS alias1 => returns alias1 750 * 751 * @param String $var : value ti examine 958 * item1 => returns item1 959 * table1.item1 => returns item1 960 * table1.item1 AS alias1 => returns alias1 961 * item1 AS alias1 => returns alias1 962 * GROUP_CONCAT( .... ) AS alias1 => returns alias1 963 * 964 * @param String $var : value to examine 752 965 * @return String : the attribute name 753 966 */ 754 967 static private function getAttribute($val) 755 968 { 756 preg_match('/(?: (?:[A-Z0-9_]*)\.)?([A-Z0-9_]*)(?:\s+AS\s+([A-Z0-9_]*))?/i', trim($val), $result);969 preg_match('/(?:GROUP_CONCAT\(.*\)|(?:[A-Z0-9_]*)\.)?([A-Z0-9_]*)(?:\s+AS\s+([A-Z0-9_]*))?/i', trim($val), $result); 757 970 if(array_key_exists(2, $result)) 758 971 { … … 766 979 { 767 980 return($val); 981 } 982 } 983 984 985 /** 986 * returns a a sql statement GROUP_CONCAT for an alias 987 * 988 * item1 => returns GROUP_CONCAT(item1 SEPARATOR $sep) AS item1 989 * table1.item1 => returns GROUP_CONCAT(table1.item1 SEPARATOR $sep) AS item1 990 * table1.item1 AS alias1 => returns GROUP_CONCAT(table1.item1 SEPARATOR $sep) AS alias1 991 * item1 AS alias1 => returns GROUP_CONCAT(item1 SEPARATOR $sep) AS alias1 992 * 993 * @param String $val : value to examine 994 * @param String $sep : the separator 995 * @return String : the attribute name 996 */ 997 static private function groupConcatAlias($val, $sep=',') 998 { 999 /* 1000 * table1.item1 AS alias1 1001 * 1002 * $result[3] = alias1 1003 * $result[2] = item1 1004 * $result[1] = table1.item1 1005 */ 1006 preg_match('/((?:(?:[A-Z0-9_]*)\.)?([A-Z0-9_]*))(?:\s+AS\s+([A-Z0-9_]*))?/i', trim($val), $result); 1007 if(array_key_exists(3, $result)) 1008 { 1009 return("GROUP_CONCAT(".$result[1]." SEPARATOR '$sep') AS ".$result[3]); 1010 } 1011 elseif(array_key_exists(2, $result)) 1012 { 1013 return("GROUP_CONCAT(".$result[1]." SEPARATOR '$sep') AS ".$result[2]); 1014 } 1015 else 1016 { 1017 return("GROUP_CONCAT($val SEPARATOR '$sep') AS ".$val); 768 1018 } 769 1019 } … … 778 1028 static private function getNewRequest($userId) 779 1029 { 780 $sql="INSERT INTO ".self::$tables['request']." VALUES('', '$userId', '".date('Y-m-d H:i:s')."', 0, 0, '' )";1030 $sql="INSERT INTO ".self::$tables['request']." VALUES('', '$userId', '".date('Y-m-d H:i:s')."', 0, 0, '', '')"; 781 1031 $result=pwg_query($sql); 782 1032 if($result) … … 796 1046 * @return Boolean : true if request was updated, otherwise false 797 1047 */ 798 static private function updateRequest($requestId, $numItems, $executionTime, $pluginList )1048 static private function updateRequest($requestId, $numItems, $executionTime, $pluginList, $additionalFilter) 799 1049 { 800 1050 $sql="UPDATE ".self::$tables['request']." 801 1051 SET num_items = $numItems, 802 1052 execution_time = $executionTime, 803 connected_plugin = '$pluginList' 1053 connected_plugin = '$pluginList', 1054 filter = '".mysql_escape_string($additionalFilter)."' 804 1055 WHERE id = $requestId"; 805 1056 $result=pwg_query($sql); … … 820 1071 { 821 1072 $returned=false; 822 $sql="SELECT user_id, date, num_items, execution_time, connected_plugin 1073 $sql="SELECT user_id, date, num_items, execution_time, connected_plugin, filter 823 1074 FROM ".self::$tables['request']." 824 1075 WHERE id = $requestId"; … … 836 1087 837 1088 /** 838 * internal function used by the executeRequest function 1089 * internal function used by the executeRequest function for single record 1090 * requests 839 1091 * 840 1092 * this function is called recursively … … 861 1113 } 862 1114 return('('.implode($operator, $returned).')'); 1115 } 1116 1117 1118 /** 1119 * internal function used by the executeRequest function for multi records 1120 * requests 1121 * 1122 * this function is called recursively 1123 * 1124 * @param Array $groupContent : 1125 * @param Array $items : 1126 * @return String : a SQL request 1127 */ 1128 static private function buildGroupRequest($groupContent, $whereItems, $groups, $operator, $requestNumber) 1129 { 1130 $returnedS=''; 1131 $returned=Array(); 1132 foreach($groupContent as $key => $val) 1133 { 1134 if(strpos($val['id'], 'iCbGroup')!==false) 1135 { 1136 preg_match('/[0-9]*$/i', $val['id'], $groupNumber); 1137 1138 $groupValue=self::buildGroupRequest($val['children'], $whereItems, $groups, $groups[$groupNumber[0]], $requestNumber); 1139 1140 if($groupValue!='') 1141 $returned[]=array( 1142 'mode' => 'group', 1143 'value' => $groupValue 1144 ); 1145 } 1146 else 1147 { 1148 preg_match('/[0-9]*$/i', $val['id'], $itemNumber); 1149 1150 $returned[]=array( 1151 'mode' => 'item', 1152 'plugin' => $whereItems[$itemNumber[0]]['plugin'], 1153 'value' => " (".$whereItems[$itemNumber[0]]['where'].") " 1154 ); 1155 } 1156 } 1157 1158 if(count($returned)>0) 1159 { 1160 if(strtolower(trim($operator))=='and') 1161 { 1162 $tId=0; 1163 foreach($returned as $key=>$val) 1164 { 1165 if($tId>0) $returnedS.=" JOIN "; 1166 1167 if($val['mode']=='item') 1168 { 1169 $returnedS.="(SELECT ".call_user_func(Array('RBCallBack'.$val['plugin'], 'getImageId'))." AS imageId 1170 FROM ".call_user_func(Array('RBCallBack'.$val['plugin'], 'getFrom'))." 1171 WHERE ".$val['value'].") t".self::$tGlobalId." "; 1172 } 1173 else 1174 { 1175 $returnedS.="(".$val['value'].") t".self::$tGlobalId." "; 1176 } 1177 1178 if($tId>0) $returnedS.=" ON t".(self::$tGlobalId-1).".imageId = t".self::$tGlobalId.".imageId "; 1179 $tId++; 1180 self::$tGlobalId++; 1181 } 1182 $returnedS="SELECT '$requestNumber', t".(self::$tGlobalId-$tId).".imageId FROM ".$returnedS; 1183 } 1184 else 1185 { 1186 foreach($returned as $key=>$val) 1187 { 1188 if($returnedS!='') $returnedS.=" UNION DISTINCT "; 1189 1190 if($val['mode']=='item') 1191 { 1192 $returnedS.="SELECT '$requestNumber', t".self::$tGlobalId.".imageId 1193 FROM (SELECT ".call_user_func(Array('RBCallBack'.$val['plugin'], 'getImageId'))." AS imageId 1194 FROM ".call_user_func(Array('RBCallBack'.$val['plugin'], 'getFrom'))." 1195 WHERE ".$val['value'].") t".self::$tGlobalId." "; 1196 } 1197 else 1198 { 1199 $returnedS.="SELECT '$requestNumber', t".self::$tGlobalId.".imageId FROM (".$val['value'].") t".self::$tGlobalId; 1200 } 1201 1202 self::$tGlobalId++; 1203 } 1204 } 1205 } 1206 1207 return($returnedS); 863 1208 } 864 1209 … … 957 1302 /** 958 1303 * display search page 959 */ 960 static public function displaySearchPage() 1304 * 1305 * @param Array $filter : an array of string ; each item is the name of a 1306 * registered plugin 1307 * if no parameters are given, no filter is applied 1308 * otherwise only plugin wich name is given are 1309 * accessible 1310 */ 1311 static public function displaySearchPage($filter=array()) 961 1312 { 962 1313 global $template, $lang; 963 1314 964 1315 load_language('rbuilder.lang', GPC_PATH); 1316 1317 if(is_string($filter)) $filter=array($filter); 1318 $filter=array_flip($filter); 965 1319 966 1320 $template->set_filename('gpc_search_page', … … 971 1325 foreach($registeredPlugin as $key=>$val) 972 1326 { 973 if(array_key_exists($key, $registeredPlugin)) 1327 if(array_key_exists($key, $registeredPlugin) and 1328 (count($filter)==0 or array_key_exists($key, $filter))) 974 1329 { 975 1330 if(file_exists($registeredPlugin[$key]['fileName'])) -
extensions/GrumPluginClasses/css/rbuilder.css
r6174 r6894 112 112 { 113 113 margin-bottom:3px; 114 cursor:default; 115 } 116 117 div#iMenuCaddieBar { 118 margin-left:8px; 119 padding-left:8px; 120 border-left:1px solid; 121 cursor:default; 122 } 123 124 125 div#iMenuCaddieBar div#iMenuCaddieItems { 126 display:none; 127 list-style-type:none; 128 max-height:30px; 129 position:absolute; 130 padding:0px; 131 } 132 133 div#iMenuCaddieBar ul { 134 margin:4px 0 4px -8px; 135 padding-bottom:2px; 136 padding-left:16px; 137 padding-right:2px; 138 } 139 140 div#iMenuCaddieBar ul li { 141 list-style-type:none; 142 padding:4px; 143 } 144 145 div#iMenuCaddieBar:hover div#iMenuCaddieItems 146 { 147 cursor:pointer; 148 display:block; 149 } -
extensions/GrumPluginClasses/language/fr_FR/rbuilder.lang.php
r6174 r6894 11 11 $lang['gpc_rb_textOR']='Au moins un critère doit être vérifié'; 12 12 13 $lang['gpc_manage_caddie'] = 'Gestion du panier'; 14 $lang['gpc_add_caddie'] = 'Le résultat viens s\'ajouter au panier'; 15 $lang['gpc_replace_caddie'] = 'Le résultat viens remplacer le panier'; 16 $lang['gpc_the_caddie_is_updated'] = 'Le panier a été mis à jour'; 17 $lang['gpc_something_is_wrong_on_the_server_side'] = 'Une anomalie est survenue lors de la connexion avec le serveur'; 18 19 13 20 ?> -
extensions/GrumPluginClasses/main.inc.php
r6702 r6894 53 53 | | | included) 54 54 | | | 55 | 3.2.0 | 2010/0 6/20| * Enhance GPCTabSheet functionnalities55 | 3.2.0 | 2010/09/12 | * Enhance GPCTabSheet functionnalities 56 56 | | | - possibility to choose tab classes 57 57 | | | * Add the simpleTip.js 58 | | | 59 | | | 58 | | | * Enhance GPCRequestBuilder functionnalities 59 | | | - now abble to manage complex request with multi-record 60 60 | | | 61 61 | | | -
extensions/GrumPluginClasses/templates/GPCRequestBuilder_search.tpl
r6208 r6894 68 68 } 69 69 break; 70 case 'fillCaddie': 71 /* function 'fillCaddie' : allows to fill the caddie with the search result 72 * 73 */ 74 if(arguments.length==2) 75 { 76 fillCaddie(arguments[1], this.getRequestNumber()); 77 } 78 break; 70 79 } 71 80 } … … 132 141 //$('#'+options.requestResultContent).html(""); 133 142 show('buildQuery'); 134 alert(' Something is wrong on the server-side !');143 alert('{/literal}{"gpc_something_is_wrong_on_the_server_side"|@translate}{literal}'); 135 144 } 136 145 } … … 160 169 else 161 170 { 162 alert(' Something is wrong on the server-side !');171 alert('{/literal}{"gpc_something_is_wrong_on_the_server_side"|@translate}{literal}'); 163 172 } 164 173 } … … 203 212 } 204 213 214 /** 215 * fill the caddie with the search results 216 * @param String mode : 'add' or 'fill' 217 */ 218 var fillCaddie = function (mode, requestNumber) 219 { 220 $('#iMenuCaddieImg').css('display', 'inline-block'); 221 $('#iMenuCaddieItems ul').css('display', 'none'); 222 223 $.ajax( 224 { 225 type: "POST", 226 url: "plugins/GrumPluginClasses/gpc_ajax.php", 227 async: true, 228 data: { ajaxfct:"admin.rbuilder.fillCaddie", fillMode:mode, requestNumber:requestNumber }, 229 success: 230 function(msg) 231 { 232 $('#iMenuCaddieImg').css('display', 'none'); 233 $('#iMenuCaddieItems ul').css('display', 'block'); 234 alert('{/literal}{"gpc_the_caddie_is_updated"|@translate}{literal}'); 235 }, 236 error: 237 function(msg) 238 { 239 $('#iMenuCaddieImg').css('display', 'none'); 240 $('#iMenuCaddieItems ul').css('display', 'block'); 241 alert('{/literal}{"gpc_something_is_wrong_on_the_server_side"|@translate}{literal}'); 242 }, 243 } 244 ); 245 } 246 205 247 init(optionsToSet); 206 248 } … … 252 294 {$dialogBox.content} 253 295 {/foreach} 296 <div id='iRBCaddieNfo'></div> 254 297 255 298 <form> … … 264 307 265 308 <div id='iMenuCriterions' > 266 <div id='iMenuCTitle' class='gcLink gcBgInput cbButtons'>{'gpc_rb_add_criterions'|@translate} </div>309 <div id='iMenuCTitle' class='gcLink gcBgInput cbButtons'>{'gpc_rb_add_criterions'|@translate} ⇓</div> 267 310 <div id='iMenuCItems'> 268 311 <ul class='gcBgInput'> … … 292 335 <div class='gcBgInput gcTextInput'> 293 336 <div id='iPagesNavigator' style='float:right;'></div> 294 <div style='text-align:left;padding:4px;'>{'gpc_rb_number_of_item_found'|@translate} : <span id='iResultQueryNfo'></span></div> 337 <div style='text-align:left;padding:4px;'> 338 {'gpc_rb_number_of_item_found'|@translate} : <span id='iResultQueryNfo'></span> 339 <div id='iMenuCaddie' style='display:inline-block;'> 340 <div id='iMenuCaddieBar'> 341 <div id='iMenuCaddieText' class='gcLink gcBgInput'>{'gpc_manage_caddie'|@translate}⇓ 342 <div id='iMenuCaddieImg' style='display:none;width:16px;height:16px;background:url(./plugins/GrumPluginClasses/icons/processing.gif) no-repeat 0 0 transparent;'> </div> 343 <div id='iMenuCaddieItems'> 344 <ul class='gcBgInput'> 345 <li class='gcBgInput'><a onclick="im.doAction('fillCaddie', 'add');">{'gpc_add_caddie'|@translate}</a></li> 346 <li class='gcBgInput'><a onclick="im.doAction('fillCaddie', 'replace');">{'gpc_replace_caddie'|@translate}</a></li> 347 </ul> 348 </div> 349 </div> 350 351 </span> 352 </div> 295 353 </div> 296 354
Note: See TracChangeset
for help on using the changeset viewer.