$this->name, "value" => $this->value, ); } static function getAllAssoc($app,$filter=null,$order=null) { $res=array(); $rows=DBObject::getAll($app,"Setting",$filter,$order); if (is_array($rows)) foreach($rows as $r) { $res[$r->name]=$r; } return $res; } static function getSetting($app,$key) { $key=$app->db->escape($key); $res=DBObject::getOne($app,"Setting","`name`='$key'"); if (is_null($res)) { $res=new Setting($app); $res->name=$key; } return $res; } } class SettingItem { var $perm; //Permisos requeridos var $id; var $name; var $description; var $type; //text, textarea, checkbox, var $options=array(); // para los select var $default; function SettingItem($perm,$id,$name,$description,$type,$default,$options=array()) { $this->perm=$perm; $this->id=$id; $this->name=$name; $this->description=$description; $this->type=$type; $this->default=$default; $this->options=$options; } } check($path); if ($score>$bestscore) { $bestscore=$score; $best=$p; } } return $best; } //Devuelve un array con los parámetros a pasar. static function getArgs($path, $pi) { $parray=explode("/",$path); $res=array(); for ($i=count(explode("/",$pi->path));$ipath=$path; $this->visible=$visible; $this->name=$name; $this->owner=$owner; $this->cb_func=$cb_func; $this->perm=$perm; } //Devuelve el numero de pasos que cumplen function check($path) { $patharray=explode("/",$this->path); $requestarray=explode("/",$path); if (count($patharray)>count($requestarray)) return 0; $res=0; $min=min(count($patharray),count($requestarray)); for ($i=0; $i<$min ; $i++) { if ($patharray[$i]==$requestarray[$i]) $res++; else { $res=0; break; } } return $res; } function invoke($args) { //TODO: Chapucilla para mostrar el titulo de página if (is_subclass_of($this->owner,"Module")) $this->owner->setPageTitle($this->name); if (is_array($this->cb_func)) { //$func=$this->cb_func[0]; //$arg=$this->cb_func[1]; $tmp=$this->cb_func; $func=array_shift($tmp); $arg=$tmp; return call_user_func_array(array($this->owner,$func),array_merge((array)$arg,$args)); } else { return call_user_func_array(array($this->owner,$this->cb_func),$args); } } } id=$id; $this->owner=$owner; $this->cb_func=$cb_func; } function invoke($args) { return call_user_func_array(array($this->owner,$this->cb_func),$args); } } app=$app; $this->count=$count; $this->perpage=$perpage; $this->keyword=$keyword; if (is_null($path)) $path=$app->req->path; if (substr($path,0,4)=="http" || substr($path,0,1)=="/") { $this->url=$path; //Eliminamos la variable de la url $this->url=preg_replace("/(\?|\&){$keyword}=\d+/","",$path); } else $this->path=$path; $this->calc(); } function calc() { $this->pages=floor(($this->count+$this->perpage-1)/$this->perpage); if (!isset($_REQUEST[$this->keyword])) $cur=0; else $cur=$_REQUEST[$this->keyword]+0; if ($cur >= $this->pages) $cur=$this->pages-1; if ($cur<0) $cur=0; $this->curpage=$cur; $this->start=$this->getStart(); } function getStart() { return $this->curpage*$this->perpage; } function link($page) { if (!is_null($this->path)) { //Comprobar si hay que conserver el resto de variables GET $getargs=""; foreach($_GET as $k=>$v) { if ($k=="q" || $k==$this->keyword) continue; if ($getargs!="") $getargs.="&"; $getargs.=$k."=".urlencode($v); } if ($page>0) { $getargs="&".$getargs; return $this->app->l($this->path,$this->keyword."=".$page.$getargs); } else return $this->app->l($this->path,$getargs); } else if (!is_null($this->url)) { $separator=strpos($this->url,"?")===0?"?":"&"; if ($page>0) return $this->url.$separator.$this->keyword."=".$page; else return $this->url; } } function has_next() { return $this->curpage+1 < $this->pages; } function has_prev() { return $this->curpage>0; } function link_next() { return $this->has_next()?$this->link($this->curpage+1):null; } function link_prev() { return $this->has_prev()?$this->link($this->curpage-1):null; } function link_first() { return $this->link(0); } function link_last() { return $this->link($this->pages-1); } }