<?php
/**
*
* @author Benjamin Gillissen <hide@address.com>
*
* **************************************************************
Copyright (C) 2009 Benjamin Gillissen
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details at:
http://www.gnu.org/copyleft/gpl.html
* **************************************************************
*/
class pfeat_resultbp {
private static $CC;
private static $conf;
const PROFILE = TRUE;
const dft = 250;
const max = 2000;
const min = 1;
public static function implent($pid, $conf){ self::$conf[$pid] = $conf; }
public static function genpart($part, $of=FALSE){ return ''; }
public static function genform($pids){
foreach($pids as $pid => &$conf){
foreach($conf as $ref => &$data ){
list($max,$dft ) = split(':', $data);
if ( !isset($b['pages'][$ref]) ){
$o['bp'] = self::get_client_conf($ref, $max, $dft);
$o['max'] = $max;
$o['min'] = self::min;
$o['pname'] = pages::get_title($pid);
$b['pages'][$ref] = $o;
unset($o);
}
}
}
return $b;
}
public static function get_client_conf($ref, $max=NULL, $dft=25){
if ( ! isset(self::$CC) ){
$run = Array(client_configs::SESSION=>'profile');
$store = Array(client_configs::PROFILE=>'site_profile');
$run_update = Array(client_configs::POST=>'');
$store_update= Array(client_configs::POST=>'');
self::$CC = new client_configs($run, $store, $run_update, $store_update);
unset($run, $store, $run_update, $store_update);
}
$k = 'resultbp_'.$ref;
if ( self::$CC->is_updated($k) ){
$new = self::$CC->get_updated($k);
if ( $max !== NULL AND $new > $max ){
$new=$dft;
} elseif ( $new < self::min ){
$new=$dft;
} else {
self::$CC->store_updated($k);
}
self::$CC->del_updated($k);
} elseif ( self::$CC->is_stored($k) ){ //check storage
$new = self::$CC->get_stored($k);
}
if ( isset($new) ){ return $new; }
return $dft;
}
}
return TRUE;