Changeset 7310 for extensions/GrumPluginClasses/classes
- Timestamp:
- Oct 20, 2010, 11:04:22 PM (14 years ago)
- Location:
- extensions/GrumPluginClasses/classes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GrumPluginClasses/classes/CommonPlugin.class.inc.php
r6975 r7310 125 125 public function __construct($prefixeTable, $filelocation) 126 126 { 127 $this->debug_file= "debug.txt";127 $this->debug_file=GPCCore::getPiwigoSystemPath()."/_data/debug.txt"; 128 128 129 129 $this->fileLocation=$filelocation; -
extensions/GrumPluginClasses/classes/GPCCategorySelector.class.inc.php
r7175 r7310 3 3 * ----------------------------------------------------------------------------- 4 4 * class name : GPCCategorySelector 5 * class version : 1.0. 06 * plugin version : 3.3. 07 * date : 2010-10- 095 * class version : 1.0.1 6 * plugin version : 3.3.3 7 * date : 2010-10-20 8 8 * ----------------------------------------------------------------------------- 9 9 * author: grum at piwigo.org … … 14 14 * 15 15 | release | date | 16 | 1.0.0 | 2010/ 04/18| * create class17 | | | 18 | | |16 | 1.0.0 | 2010/10/09 | * create class 17 | | | 18 | 1.0.1 | 2010/10/20 | * fix bug on the private select methods 19 19 | | | 20 20 | | | … … 242 242 243 243 $sql="SELECT DISTINCT pct.id, pct.name, pct.global_rank AS rank, pct.status 244 FROM (".CATEGORIES_TABLE." pct "; 245 246 if($this->options['userMode']==self::USER_MODE_PUBLIC) 247 { 248 $sql.=" JOIN ".USER_CACHE_CATEGORIES_TABLE." pucc 249 ON (pucc.cat_id = pct.id) AND pucc.user_id='".$user['id']."') "; 250 } 251 else 252 { 253 $sql.=") "; 254 } 244 FROM ".CATEGORIES_TABLE." pct "; 255 245 256 246 switch($this->options['filter']) … … 260 250 break; 261 251 case self::FILTER_ACCESSIBLE : 262 $sql.=" JOIN ( 263 SELECT DISTINCT pgat.cat_id AS catId FROM ".GROUP_ACCESS_TABLE." pgat 264 UNION DISTINCT 265 SELECT DISTINCT puat.cat_id AS catId FROM ".USER_ACCESS_TABLE." puat 266 ) pat 267 ON (pat.catId = pct.id AND pct.status = 'private') OR (pct.status = 'public') "; 252 if(!is_admin()) 253 { 254 $sql.=" JOIN ".USER_CACHE_CATEGORIES_TABLE." pucc 255 ON (pucc.cat_id = pct.id) AND pucc.user_id='".$user['id']."' "; 256 } 257 else 258 { 259 $sql.=" JOIN ( 260 SELECT DISTINCT pgat.cat_id AS catId FROM ".GROUP_ACCESS_TABLE." pgat 261 UNION DISTINCT 262 SELECT DISTINCT puat.cat_id AS catId FROM ".USER_ACCESS_TABLE." puat 263 UNION DISTINCT 264 SELECT DISTINCT pct2.id AS catId FROM ".CATEGORIES_TABLE." pct2 WHERE pct2.status='public' 265 ) pat 266 ON pat.catId = pct.id "; 267 } 268 268 269 break; 269 270 } -
extensions/GrumPluginClasses/classes/GPCCore.class.inc.php
r7175 r7310 3 3 /* ----------------------------------------------------------------------------- 4 4 class name : GPCCore 5 class version : 1.3. 06 plugin version : 3.3. 07 date : 2010- 07-285 class version : 1.3.1 6 plugin version : 3.3.2 7 date : 2010-10-20 8 8 ------------------------------------------------------------------------------ 9 9 author: grum at piwigo.org … … 21 21 | | | 22 22 | 1.3.0 | 2010/10/13 | * add the addHeaderCSS, addHeaderJS functions 23 | | | 24 | 1.3.1 | 2010/10/20 | * applyHeaderItems functions implemented with an 25 | | | higher priority on the 'loc_begin_page_header' event 26 | | | 27 | | | * implement the getUserLanguageDesc() function, using 28 | | | extended description function if present 29 | | | 30 | | | * implement the getPiwigoSystemPath function 23 31 | | | 24 32 | | | … … 37 45 - static function addHeaderCSS 38 46 - static function addHeaderJS 47 - static function getUserLanguageDesc 48 - static function getPiwigoSystemPath 49 - static function formatOctet 39 50 ---------------------------------------------------------------------- */ 40 51 … … 43 54 class GPCCore 44 55 { 56 static private $piwigoSystemPath; 57 45 58 static public $pluginName = "GPCCore"; 46 59 static protected $headerItems = array( … … 48 61 'js' => array() 49 62 ); 63 64 static public function init() 65 { 66 self::$piwigoSystemPath=dirname(dirname(dirname(dirname(__FILE__)))); 67 } 50 68 51 69 /* --------------------------------------------------------------------------- … … 328 346 global $template; 329 347 348 if(!isset($template->known_scripts)) $template->known_scripts=array(); 349 330 350 if(!array_key_exists($id, $template->known_scripts) and !array_key_exists($file, self::$headerItems['js'])) 331 351 { 332 $template->known_scripts[$id]=$ url;352 $template->known_scripts[$id]=$file; 333 353 self::$headerItems['js'][$id]=$file; 334 354 } … … 345 365 foreach(self::$headerItems['css'] as $file) 346 366 { 347 $template-> block_html_head(null, '<link rel="stylesheet" type="text/css" href="'.$file.'"/>', $template->smarty, $false);367 $template->append('head_elements', '<link rel="stylesheet" type="text/css" href="'.$file.'"/>'); 348 368 } 349 369 350 370 foreach(self::$headerItems['js'] as $file) 351 371 { 352 $template->block_html_head(null, '<script type="text/javascript" src="'.$file.'"></script>', $template->smarty, $false); 353 } 354 } 372 $template->append('head_elements', '<script type="text/javascript" src="'.$file.'"></script>'); 373 } 374 } 375 376 /** 377 * use the extended description get_user_language_desc() function if exist 378 * otherwise returns the value 379 * 380 * @param String $value : value to translate 381 * @return String : translated value 382 */ 383 static public function getUserLanguageDesc($value) 384 { 385 if(function_exists('get_user_language_desc')) 386 { 387 return(get_user_language_desc($value)); 388 } 389 else 390 { 391 return($value); 392 } 393 } 394 395 /** 396 * returns the piwigo system path 397 * @return String 398 */ 399 static public function getPiwigoSystemPath() 400 { 401 return(self::$piwigoSystemPath); 402 } 403 404 405 /** 406 * formats a file size into a human readable size 407 * 408 * @param String $format : "A" : auto 409 * "Ai" : auto (io) 410 * "O" : o 411 * "K" : Ko 412 * "M" : Mo 413 * "G" : Go 414 * "Ki" : Kio 415 * "Mi" : Mio 416 * "Gi" : Gio 417 * @param String $thsep : thousand separator 418 * @param Integer $prec : number of decimals 419 * @param Bool $visible : display or not the unit 420 * @return String : a formatted file size 421 */ 422 static public function formatOctet($octets, $format="Ai", $thsep="", $prec=2, $visible=true) 423 { 424 if($format=="Ai") 425 { 426 if($octets<1024) 427 { $format="O"; } 428 elseif($octets<1024000) 429 { $format="Ki"; } 430 elseif($octets<1024000000) 431 { $format="Mi"; } 432 else 433 { $format="Gi"; } 434 } 435 elseif($format=="A") 436 { 437 if($octets<1000) 438 { $format="O"; } 439 elseif($octets<1000000) 440 { $format="Ki"; } 441 elseif($octets<1000000000) 442 { $format="Mi"; } 443 else 444 { $format="Gi"; } 445 } 446 447 switch($format) 448 { 449 case "O": 450 $unit="o"; $div=1; 451 break; 452 case "K": 453 $unit="Ko"; $div=1000; 454 break; 455 case "M": 456 $unit="Mo"; $div=1000000; 457 break; 458 case "G": 459 $unit="Go"; $div=1000000000; 460 break; 461 case "Ki": 462 $unit="Kio"; $div=1024; 463 break; 464 case "Mi": 465 $unit="Mio"; $div=1024000; 466 break; 467 case "Gi": 468 $unit="Gio"; $div=1024000000; 469 break; 470 } 471 472 $returned=number_format($octets/$div, $prec, '.', $thsep); 473 if($visible) $returned.=' '.$unit; 474 return($returned); 475 } //function formatOctet 476 355 477 356 478 } //class 357 479 358 add_event_handler('loc_end_page_header', array('GPCCore', 'applyHeaderItems')); 359 480 add_event_handler('loc_begin_page_header', array('GPCCore', 'applyHeaderItems'), 10); 481 482 GPCCore::init(); 360 483 361 484 ?> -
extensions/GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php
r7200 r7310 71 71 | | | . adding 'DISTINCT' keyword to the SQL requests 72 72 | | | 73 | | | * ajax management moved into the gpc_ajax.php file 74 | | | 75 | | | * fix bug on user level access to picture 73 76 | | | 74 77 | | | … … 79 82 --------------------------------------------------------------------------- */ 80 83 81 include_once('GPCAjax.class.inc.php');82 84 include_once('GPCTables.class.inc.php'); 83 85 … … 397 399 static public function updateTables($pluginPreviousRelease) 398 400 { 401 $tablef=new GPCTables(array(self::$tables['temp'])); 402 399 403 switch($pluginPreviousRelease) 400 404 { … … 415 419 416 420 417 $tablef=new GPCTables(array(self::$tables['temp']));418 421 419 422 $tablef->create($tablesCreate); … … 459 462 static public function loadJSandCSS() 460 463 { 461 add_event_handler('loc_ end_page_header', array('GPCRequestBuilder', 'insertJSandCSSFiles'));464 add_event_handler('loc_begin_page_header', array('GPCRequestBuilder', 'insertJSandCSSFiles'), 9); 462 465 } 463 466 … … 466 469 * insert JS a CSS file in header 467 470 * 468 * the function is declared public because it used by the 'loc_ end_page_header'471 * the function is declared public because it used by the 'loc_begin_page_header' 469 472 * event callback 470 473 * … … 475 478 { 476 479 global $template; 480 477 481 478 482 $baseName=basename(dirname(dirname(__FILE__))).'/css/'; … … 480 484 481 485 $baseName=basename(dirname(dirname(__FILE__))).'/js/'; 482 $template->append('head_elements', '<script type="text/javascript" src="plugins/'.$baseName.'external/interface/interface.js"></script>'); 483 $template->append('head_elements', '<script type="text/javascript" src="plugins/'.$baseName.'external/inestedsortable.pack.js"></script>'); 484 $template->append('head_elements', '<script type="text/javascript" src="plugins/'.$baseName.'criteriaBuilder.packed.js"></script>'); 486 GPCCore::addHeaderJS('jquery', 'themes/default/js/jquery.packed.js'); 487 GPCCore::addHeaderJS('gpc.interface', 'plugins/'.$baseName.'external/interface/interface.js'); 488 GPCCore::addHeaderJS('gpc.inestedsortable', 'plugins/'.$baseName.'external/inestedsortable.pack.js'); 489 GPCCore::addHeaderJS('gpc.criteriaBuilder', 'plugins/'.$baseName.'criteriaBuilder.js'); 490 485 491 $template->append('head_elements', 486 492 "<script type=\"text/javascript\"> … … 490 496 imgEditUrl:'', 491 497 imgDeleteUrl:'', 492 ajaxUrl:' admin.php?page=plugin§ion=".basename(GPC_DIR)."/admin/plugin_admin.php&searchRequest=',498 ajaxUrl:'plugins/GrumPluginClasses/gpc_ajax.php', 493 499 } 494 500 </script>"); … … 501 507 * @return String : a ready to use HTML code 502 508 */ 503 static public function executeRequest() 504 { 505 if(self::checkAjaxRequest()) 506 { 507 switch($_REQUEST['searchRequest']) 508 { 509 case 'execute': 510 $result=self::doCache(); 511 break; 512 case 'getPage': 513 $result=self::getPage($_REQUEST['requestNumber'], $_REQUEST['page'], $_REQUEST['numPerPage']); 514 break; 515 } 516 GPCAjax::returnResult($result); 517 } 518 else 519 { 520 GPCAjax::returnResult(l10n('gpc_rb_invalid_request')); 521 } 509 static public function executeRequest($ajaxfct) 510 { 511 switch($ajaxfct) 512 { 513 case 'admin.rbuilder.searchExecute': 514 $result=self::doCache(); 515 break; 516 case 'admin.rbuilder.searchGetPage': 517 $result=self::getPage($_REQUEST['requestNumber'], $_REQUEST['page'], $_REQUEST['numPerPage']); 518 break; 519 } 520 return($result); 522 521 } 523 522 … … 566 565 567 566 $sql="INSERT INTO ".self::$tables['temp']." ".self::buildGroupRequest($_REQUEST[$_REQUEST['requestName']], $tmpWHERE, $_REQUEST['operator'], ' AND ', $requestNumber); 568 //echo $sql; 567 569 568 $result=pwg_query($sql); 570 569 … … 602 601 'SELECT' => 'pit.id', 603 602 'FROM' => '', 604 'WHERE' => ' ',603 'WHERE' => 'pit.level <= '.$user['level'], 605 604 'GROUPBY' => '', 606 605 'FILTER' => '', … … 1301 1300 1302 1301 /** 1303 * check if this is a valid ajax request1304 *1305 * @return Boolean : true if this is a valide ajax request1306 */1307 static protected function checkAjaxRequest()1308 {1309 if(isset($_REQUEST['searchRequest']))1310 {1311 if($_REQUEST['searchRequest']=='execute')1312 {1313 if(!isset($_REQUEST['requestName'])) return(false);1314 1315 return(true);1316 }1317 1318 if($_REQUEST['searchRequest']=='getPage')1319 {1320 if(!isset($_REQUEST['requestNumber'])) return(false);1321 1322 if(!isset($_REQUEST['page']))1323 {1324 $_REQUEST['page']=0;1325 }1326 if($_REQUEST['page']<0) $_REQUEST['page']=0;1327 1328 if(!isset($_REQUEST['numPerPage']))1329 {1330 $_REQUEST['numPerPage']=25;1331 }1332 1333 if($_REQUEST['numPerPage']>100) $_REQUEST['numPerPage']=100;1334 1335 return(true);1336 }1337 1338 }1339 return(false);1340 }1341 1342 1343 1344 /**1345 1302 * display search page 1346 1303 *
Note: See TracChangeset
for help on using the changeset viewer.