orm);
$output = '';
$output .= sprintf(_('This server has %s %s.'),$o->count_all(),$o->table_name());
$output .= '
';
$output .= '
';
$select = array();
$select[NULL] = '';
foreach ($o->find_all() as $oo)
// For some tables, are ID is base_64 encoded.
switch ($this->orm) {
case 'VOLUME': $select[base64_encode($oo->pk())] = $oo->pk();
break;
default:
$select[$oo->pk()] = $oo->pk();
}
$output .= Form::open(sprintf('%s/detail',strtolower($this->request->controller())),array('id'=>'object_detail'));
$output .= sprintf('%s: %s',_('Choose to view'),Form::select('object_name',$select,NULL,array('id'=>'object_name')));
$output .= Form::submit('form_submit',_('Go'));
$output .= Form::close();
Block::add(array(
'title'=>$this->index_title,
'body'=>$output,
));
}
public function action_detail() {
$object_name = $this->request->param('id');
if (is_null($object_name) AND (empty($_POST['object_name']) OR ! $object_name = $_POST['object_name'])) {
SystemMessage::add(array(
'title'=>_('Missing required data'),
'type'=>'error',
'body'=>sprintf(_('The %s is required.'),ORM::factory($this->orm)->primary_key()),
));
HTTP::redirect(strtolower($this->request->controller()));
}
// For some tables, are ID is base_64 encoded.
switch ($this->orm) {
case 'VOLUME': $object_name = base64_decode($object_name);
break;
}
$o = ORM::factory($this->orm,$object_name);
if (! $o->loaded()) {
SystemMessage::add(array(
'title'=>_('Unknown Entry'),
'type'=>'error',
'body'=>sprintf(_('The %s [%s] does not exist?.'),$o->table_name(),$object_name),
));
HTTP::redirect(strtolower($this->request->controller()));
}
Block::add(array(
'title'=>$this->detail_title,
'body'=>View::factory(sprintf('%s/detail',strtolower($this->request->controller())))->set('o',$o),
));
}
}
?>