public function object_($class = NULL, $pk = NULL) { if (isset($_GET['path'])) { self::$inspector_path = base64_decode($_GET['path']); } else { self::$inspector_path = '$' . $class; } $modelinfo = Model::modelinfo($class); if (Model::_has_complex_primary_key($modelinfo)) { throw new HTTPException("{$class} has complex primary key"); } $pkcol = Model::_simple_primary_key($class); $obj = Model::_find_first($class, array($pk)); if (!is_object($obj)) { throw new HTTPNotFound(); } # WARNING: assumes integer primary keys with the lt and gt checks # need some other way to do navigation in the case of non-integer PKs $prev = Model::_find($class, array(array($pkcol => cond::lt($obj->{$pkcol})), 1, "{$pkcol} desc")); if ($prev) { $prev = array_shift($prev); $this->view->assign("prevobjid", $prev->id); $prev = url($this, 'object', $class, $prev->id); $this->view->assign("prevobjlink", $prev); } $next = Model::_find($class, array(array($pkcol => cond::gt($obj->{$pkcol})), 1, $pkcol)); if ($next) { $next = array_shift($next); $this->view->assign("nextobjid", $next->id); $next = url($this, 'object', $class, $next->id); $this->view->assign("nextobjlink", $next); } $this->view->assign('class', $class); $this->view->assign('obj', $obj); $this->view->assign('pkcol', $pkcol); $this->view->assign('pk', $pk); $f = array_keys($obj->dump()); usort($f, array($this, 'sortfields')); $this->view->assign('fields', $f); $f = $obj->natural_members(); usort($f, array($this, 'sortfields')); $this->view->assign('natmembers', $f); $f = $obj->virtual_members(); usort($f, array($this, 'sortfields')); $this->view->assign('virtmembers', $f); $f = $obj->generated_members(); $this->view->assign('genfields', $f); $this->view->assign('path', self::$inspector_path); $this->viewname = "object.tpl"; }