Ejemplo n.º 1
0
 function Index()
 {
     $this->_login();
     // require admin to be logged in
     // add products table and a button to create a new product
     $this->content("<h1>Products</h1>");
     $this->content(new uiDatabaseTable(model_datasource('system'), false, 'products'))->AddPager(10)->AddRowAction('trash', 'Delete', $this, 'DelProduct');
     $this->content(uiButton::Make('Add product'))->onclick = AjaxAction::Post('Admin', 'AddProduct');
     // add orders table
     $this->content("<h1>Orders</h1>");
     $this->content(new uiDatabaseTable(model_datasource('system'), false, 'orders'))->AddPager(10)->OrderBy = 'id DESC';
     // add customers table
     $this->content("<h1>Customers</h1>");
     $this->content(new uiDatabaseTable(model_datasource('system'), false, 'customers'))->AddPager(10)->OrderBy = 'id DESC';
 }
Ejemplo n.º 2
0
 /**
  * High level confirm procedure.
  * 
  * This will return a standard confirmation dialog that will perform the specified action
  * when OK is clicked. Will also set a session variable so that the OK action PHP side code
  * can simply test with <AjaxAction::IsConfirmed>($text_base) if the confirmation was really shown and accepted by the user.
  * @param string $text_base Text constants basename (like CONFIRMATION). Confirmation will need TITLE_$text_base and TXT_$text_base
  * @param mixed $controller Controller for OK action
  * @param string $event Method for OK action
  * @param string|array $data Data for OK action
  * @return uiConfirmation Dialog ready to be shown to the user
  */
 public static function Confirm($text_base, $controller, $event = '', $data = '')
 {
     $dlg = new uiConfirmation($text_base);
     $q = self::Url($controller, $event);
     $data = self::_data($data);
     $data = "var d = " . ($data ? $data : '{}') . "; for(var n in \$('#{$dlg->id}').data()) if( typeof \$('#{$dlg->id}').data(n) == 'string') d[n] = \$('#{$dlg->id}').data(n); ";
     $action = "{$data}" . AjaxAction::Post($controller, $event, 'd', $dlg->CloseButtonAction);
     $dlg->SetOkCallback($action);
     $_SESSION['ajax_confirm'][$text_base] = md5(time());
     $dlg->setData('confirmed', $_SESSION['ajax_confirm'][$text_base]);
     return $dlg;
 }
Ejemplo n.º 3
0
 /**
  * Creates a standard AJAX submit action
  * 
  * Will create everything needed to post this form via AJAX to a PHP-side handler.
  * @param object $controller Handler object
  * @param string $event Handler method name
  * @return Form `$this`
  */
 function AjaxSubmitTo($controller, $event)
 {
     $s = AjaxAction::Post($controller, $event, "\$(this).serializeArray()");
     $this->script("\$('#{self}').submit( function(){ {$s} return false; } );");
     return $this;
 }