public function upload_image() { $_GET['id'] = $_POST['id']; $sizes = array(array('l_', 800, 600), array('tn_', 200, 200), array('mid_', 468, 5000)); $u = new ImageUpload('blog', true, $sizes); if ($u->error != '') { $this->presenter->assign('error', $u->error); } else { $bi = Model::load('BlogImage'); $bi->filename = $u->getFile(); $bi->blog_id = $_GET['id']; $bi->insert(Model::getTable('BlogImage'), 1, array(), 0); $this->redirect('admin/blog/view/' . $_GET['id']); } /* $b = new SectionItem($this); $section->getItem($_GET['id']); $gallery = strtolower(str_replace(" ", "", $section->label)); $this->setNavigation(); if (isset($_POST['upload'])) { $upload = new ImageUpload(); $upload->upload($gallery, true); if ($upload->error != "") { $this->presenter->assign("error", $upload->error); } else { $this->redirect("admin/sections/$section->id"); } } */ }
public function data_add_data_image() { if (isset($_POST['save'])) { $_GET['id'] = $_POST['id']; $p = Model::load('DataItem'); $p->id = $_GET['id']; $p->load(); if (is_numeric($p->container_id)) { $c = Model::load('ContainerImageSize'); $sizes = $c->getImageSizes($p->container_id); } else { $sizes = array(); } $u = new ImageUpload('data', true, $sizes); if ($u->error != '') { $this->presenter->assign('error', $u->error); } else { $d = Model::load('DataItem'); $d->label = $u->getFileEncoded(); $d->data_item_id = $_GET['id']; $d->image = $u->getFile(); $d->position = 'DEFAULT'; $d->hidden = 'DEFAULT'; $new_id = $d->insert(Model::getTable('DataItem'), 1, array(), 1); $this->update_timestamps($d->data_item_id); $this->redirect('admin/dsection/data_item/' . $new_id); } } elseif (isset($_POST['cancel'])) { $this->redirect('admin/dsection/data_item/' . $_GET['id']); } $this->buildNavData(); $this->assign('class', 'data_item'); $this->assign('event', 'add_data_image'); $this->setTemplate('elib:/admin/section.tpl'); }