/**
  * Creates a new uiConfirmation object.
  * 
  * The $text_base argument in fact defines two texts in one (and assumes you are using translations!):
  * It will be prefixed with 'TXT_' and 'TITLE_' and that two constants will be used.
  * Sample: 'CONFIRMATION' will become 'TXT_CONFIRMATION' and 'TITLE_CONFIRMATION'.
  * @param string $text_base base of confirmation text.
  * @param string $ok_callback JS code to be executed when the positive button is clicked (OK, YES)
  * @param int $button_mode uiConfirmation::OK_CANCEL or uiConfirmation::YES_NO
  */
 function __initialize($text_base = 'CONFIRMATION', $ok_callback = false, $button_mode = self::OK_CANCEL)
 {
     $options = array('autoOpen' => true, 'modal' => true, 'width' => 450, 'height' => 300);
     $title = "TITLE_{$text_base}";
     $text = "TXT_{$text_base}";
     parent::__initialize($title, $options);
     switch ($button_mode) {
         case self::OK_CANCEL:
             $this->AddButton(tds('BTN_OK', 'Ok'), $ok_callback);
             $this->AddCloseButton(tds('BTN_CANCEL', 'Cancel'));
             break;
         case self::YES_NO:
             $this->AddButton(tds('BTN_YES', 'Yes'), $ok_callback);
             $this->AddCloseButton(tds('BTN_NO', 'No'));
             break;
         default:
             WdfException::Raise("Wrong button_mode: {$button_mode}");
     }
     $this->Mode = $button_mode;
     $this->content($text);
 }
Exemplo n.º 2
0
 /**
  * @internal Renames a term.
  * 
  * Sometimes you may want to correct a terms name, so use this one.
  * @param string $term The original term
  * @param string $new_term The new term name
  * @return void
  * @attribute[RequestParam('term','string')]
  * @attribute[RequestParam('new_term','string',false)]
  */
 function Rename($term, $new_term)
 {
     if (!$new_term) {
         $dlg = new uiDialog('Rename term');
         $dlg->content("Enter new term: ");
         $ti = $dlg->content(new TextInput($term));
         $dlg->AddButton('Rename', "function(){ wdf.controller.post('Rename',{term:'{$term}',new_term:\$('#{$ti->id}').val()}); }");
         $dlg->AddCloseButton('Cancel');
         return $dlg;
     }
     $this->ds->ExecuteSql("UPDATE wdf_translations SET id=? WHERE id=?", array($new_term, $term));
     return AjaxResponse::Redirect('TranslationAdmin', 'Translate', array('lang' => $_SESSION['trans_admin_lang'], 'offset' => $_SESSION['trans_admin_offset'], 'search' => $_SESSION['trans_admin_search']));
 }
Exemplo n.º 3
0
 /**
  * @attribute[RequestParam('title','string',false)]
  * @attribute[RequestParam('tagline','string',false)]
  * @attribute[RequestParam('body','text',false)]
  * @attribute[RequestParam('price','double',false)]
  */
 function AddProduct($title, $tagline, $body, $price)
 {
     $this->_login();
     // require admin to be logged in
     // This is a quite simple condition: You MUST provide each of the variables
     if ($title && $tagline && $body && $price) {
         // store the uploaded image if present
         if (isset($_FILES['image']) && $_FILES['image']['name']) {
             $i = 1;
             $image = __DIR__ . '/../images/' . $_FILES['image']['name'];
             while (file_exists($image)) {
                 $image = __DIR__ . '/../images/' . $i++ . '_' . $_FILES['image']['name'];
             }
             move_uploaded_file($_FILES['image']['tmp_name'], $image);
             $image = basename($image);
         } else {
             $image = '';
         }
         // store the new product into the database
         $ds = model_datasource('system');
         $ds->ExecuteSql("INSERT INTO products(title,tagline,body,image,price)VALUES(?,?,?,?,?)", array($title, $tagline, $body, $image, $price));
         redirect('Admin');
     }
     // create a dialog and put a template on it.
     $dlg = new uiDialog('Add product', array('width' => 600, 'height' => 450));
     $dlg->content(Template::Make('admin_product_add'));
     $dlg->AddButton('Add product', "\$('#frm_add_product').submit()");
     // frm_add_product is defined in the template
     $dlg->AddCloseButton("Cancel");
     return $dlg;
 }
 /**
  * @param string $title Dialog title
  * @param array $options Options as in <uiDialog>
  */
 function __initialize($title = "TITLE_DIALOG", $options = array())
 {
     parent::__initialize($title, $options);
     $this->_table = $this->content(new Table());
 }