Esempio n. 1
0
 protected static function actionNewImage()
 {
     $file = self::processImage($_FILES['image']['tmp_name'], isset($_POST['product']) ? ROOT_DIR . '/assets/images/products' : ROOT_DIR . '/assets/images/temp', array('110x110', '255x237', '184x162', '255x128', '329x380', '85x84'));
     if (isset($_POST['product'])) {
         $image = new ProductImageModel();
         $image->file = $file;
         $image->id_product = $_POST['product'];
         $image->position = 1 + Database::getValue("\n                SELECT MAX(`position`)\n                FROM `product_image`\n                WHERE `id_product` = {$_POST['product']}\n            ");
         $image->save();
         $product = new ProductModel($_POST['product']);
         $list = new TemplateList();
         $list->fields = array('file' => array('type' => 'image', 'title' => '', 'directory' => 'products', 'size' => '85x84'));
         $list->itemActions = array('down-image' => array('hint' => 'Опустить', 'icon' => 'down', 'controller' => 'AdminProducts'), 'up-image' => array('hint' => 'Поднять', 'icon' => 'up', 'controller' => 'AdminProducts'), 'delete-image' => array('hint' => 'Удалить', 'icon' => 'delete', 'controller' => 'AdminProducts'));
         $list->items = $product->images;
         return $list->display();
     } else {
         $images = array();
         $_POST['images'] = isset($_POST['images']) ? explode(',', $_POST['images']) : array();
         $_POST['images'][] = $file;
         foreach ($_POST['images'] as $image) {
             $images[] = array('id' => $image);
         }
         $list = new TemplateList();
         $list->fields = array('id' => array('type' => 'image', 'title' => '', 'directory' => 'temp', 'size' => '85x84'));
         $list->items = $images;
         return $list->display() . '<input type="hidden" id="image_post_params" name="image_post_params" value=\'' . json_encode(array('images' => implode(',', $_POST['images']))) . '\' />';
     }
 }
Esempio n. 2
0
 /**
  * Get the fieldset to display in the administration section
  */
 function getCMSFields()
 {
     $group = null;
     if ($this->GroupID) {
         $group = DataObject::get_one("Group", "ID = {$this->GroupID}");
     }
     $fields = new FieldSet(new TextField("Title", _t('NewsletterType.NEWSLETTERTYPE', 'Newsletter Type')), new TextField("FromEmail", _t('NewsletterType.SENDFROM', 'Send newsletters from')), new TabSet("Root", new Tab(_t('NewsletterType.DRAFTS', 'Drafts'), $draftList = new NewsletterList("Draft", $this, _t('NewsletterType.DRAFT', 'Draft'))), new TabSet('Sent', new Tab(_t('NewsletterType.SENT', 'Sent'), $sendList = new NewsletterList("Send", $this, _t('NewsletterType.SEND', 'Send'))), new Tab(_t('NewsletterType.UNSUBSCRIBED', 'Unsubscribed'), $unsubscribedList = new UnsubscribedList("Unsubscribed", $this)), new Tab(_t('NewsletterType.BOUNCED', 'Bounced'), $bouncedList = new BouncedList("Bounced", $this)))));
     if ($this->GroupID) {
         $fields->addFieldToTab('Root', new TabSet("Recipients", new Tab(_t('NewsletterType.RECIPIENTS', 'Recipients'), $recipients = new MemberTableField($this, "Recipients", $group)), new Tab(_t('NewsletterType.IMPORT', 'Import'), $importField = new RecipientImportField("ImportFile", _t('NewsletterType.IMPORTFROM', 'Import from file'), $group))));
         $recipients->setController($this);
         $importField->setController($this);
         $importField->setTypeID($this->ID);
     }
     $fields->addFieldToTab('Root', new Tab(_t('NewsletterType.TEMPLATE', 'Template'), $templates = new TemplateList("Template", "Template", $this->Template, NewsletterAdmin::template_path())));
     $draftList->setController($this);
     $sendList->setController($this);
     $templates->setController($this);
     $unsubscribedList->setController($this);
     $bouncedList->setController($this);
     $fields->push($idField = new HiddenField("ID"));
     $fields->push(new HiddenField("executeForm", "", "TypeEditForm"));
     $idField->setValue($this->ID);
     return $fields;
 }
Esempio n. 3
0
 public static function generateLanguageList()
 {
     global $site;
     $site->requireTemplate('standard/languages/template_list.php');
     return TemplateList::languages($site->getLanguages());
 }
Esempio n. 4
0
 public function getNewsletterTypeEditForm($id)
 {
     if (!is_numeric($id)) {
         $id = Session::get('currentPage');
     }
     if (is_a($id, 'NewsletterType')) {
         $mailType = $id;
         $id = $mailType->ID;
     } else {
         if ($id && is_numeric($id)) {
             $mailType = DataObject::get_by_id('NewsletterType', $id);
         }
     }
     if (isset($mailType) && is_object($mailType) && $mailType->GroupID) {
         $group = DataObject::get_one("Group", "ID = {$mailType->GroupID}");
     }
     if (isset($mailType) && $mailType) {
         $fields = new FieldSet(new TabSet("Root", new Tab(_t('NewsletterAdmin.NLSETTINGS', 'Newsletter Settings'), new TextField("Title", _t('NewsletterAdmin.NEWSLTYPE', 'Newsletter Type')), new TextField("FromEmail", _t('NewsletterAdmin.FROMEM', 'From email address')), $templates = new TemplateList("Template", _t('NewsletterAdmin.TEMPLATE', 'Template'), $mailType->Template, self::template_path()))));
         $templates->setController($this);
         $fields->push($idField = new HiddenField("ID"));
         $fields->push(new HiddenField("executeForm", "", "TypeEditForm"));
         $idField->setValue($id);
         $actions = new FieldSet(new FormAction('save', _t('NewsletterAdmin.SAVE', 'Save')));
         $form = new Form($this, "EditForm", $fields, $actions);
         $form->loadDataFrom(array('Title' => $mailType->Title, 'FromEmail' => $mailType->FromEmail));
     } else {
         $form = false;
     }
     return $form;
 }