Example #1
0
File: app.php Project: ratiw/petro
 public function action_view($id = null)
 {
     $model = $this->model;
     $data = $model::find($id);
     if (is_null($data)) {
         \Response::redirect($this->app);
     }
     $out = '';
     $out .= Petro::render_panel($this->app_name . ' Information', Petro::render_attr_table($data, $this->view_columns));
     $out .= $this->setup_view($data);
     $routes = Petro::get_routes($id);
     $this->action_items = array(array('title' => 'Edit ' . $this->app_name, 'link' => $routes['edit'], 'visible' => $this->can_edit()), array('title' => 'Delete ' . $this->app_name, 'link' => $routes['delete'], 'attr' => array('data-toggle' => 'modal', 'data-target' => '#petro-confirm', 'class' => 'del-item', 'visible' => $this->can_delete())));
     $this->template->set('content', $out, false);
 }
Example #2
0
File: grid.php Project: ratiw/petro
 public static function default_actions($petro_app = null)
 {
     return array('name' => '_actions_', 'label' => '', 'form' => array(), 'grid' => array('process' => function ($data) use($petro_app) {
         $routes = Petro::get_routes($data->id);
         if (is_null($petro_app)) {
             $str = \Html::anchor($routes['view'], 'View');
             $str .= ' ' . Html::anchor($routes['edit'], 'Edit');
             $str .= ' ' . Html::anchor($routes['delete'], 'Delete', array('data-toggle' => 'modal', 'data-target' => '#petro-confirm', 'class' => 'del-item'));
         } else {
             $str = $petro_app->can_read() ? \Html::anchor($routes['view'], 'View') : '';
             $str .= ' ' . ($petro_app->can_update() ? Html::anchor($routes['edit'], 'Edit') : '');
             $str .= ' ' . ($petro_app->can_delete() ? Html::anchor($routes['delete'], 'Delete', array('data-toggle' => 'modal', 'data-target' => '#petro-confirm', 'class' => 'del-item')) : '');
         }
         return $str;
     }));
 }