Пример #1
0
Файл: CRUD.php Проект: atk4/atk4
 /**
  * Adds button to the crud, which opens a new frame and returns page to
  * you. Add anything into the page as you see fit. The ID of the record
  * will be inside $crud->id.
  *
  * The format of $options is the following:
  * array (
  *   'title'=> 'Click Me'     // Header for the column
  *   'label'=> 'Click Me'     // Text to put on the button
  *   'icon' => 'click-me'     // Icon for button
  * )
  *
  * @param string $name    Unique name, also button and title default
  * @param array  $options Options
  *
  * @return Page|bool Returns object if clicked on popup.
  */
 public function addFrame($name, $options = array())
 {
     if (!$this->model) {
         throw $this->exception('Must set CRUD model first');
     }
     if (!is_array($options)) {
         throw $this->exception('Must be array');
     }
     $s = $this->app->normalizeName($name);
     if ($this->isEditing('fr_' . $s)) {
         $n = $this->virtual_page->name . '_' . $s;
         if ($_GET[$n]) {
             $this->id = $_GET[$n];
             $this->app->stickyGET($n);
         }
         return $this->virtual_page->getPage();
     }
     if ($this->isEditing()) {
         return false;
     }
     $this->virtual_page->addColumn('fr_' . $s, $options['title'] ?: $name, array('descr' => $options['label'] ?: null, 'icon' => $options['icon'] ?: null), $this->grid);
 }