private function make_form() { $testimonial = $this->get_testimonial(); # get form questions $questions = ORM::factory('question')->where('owner_id', $this->owner->id)->find_all(); $form = new View('testimonials/edit'); $form->questions = $questions; $form->locked = 1 == $testimonial->lock ? true : false; $form->tags = ORM::factory('tag')->where('owner_id', $this->owner->id)->find_all(); $form->info = json_decode($testimonial->body_edit, TRUE); $form->testimonial = $testimonial; $form->image_url = t_paths::image($this->owner->apikey, 'url'); $form->url = $this->form_url; return $form; }
public function save_crop($apikey, $params) { if (!isset($params[1])) { return 'Invalid Parameters'; } $img_path = t_paths::image($apikey) . "/full_{$this->image}"; $image = new Image($img_path); $width = $image->__get('width'); $height = $image->__get('height'); # Make thumbnail from supplied post params. $size = 125; $thumb_path = t_paths::image($apikey) . "/{$this->image}"; $image->crop($params[0], $params[1], $params[2], $params[3])->resize($size, $size)->save($thumb_path); return 'Image saved!'; }
public function edit() { $testimonial = $this->get_testimonial(); # get questions $questions = ORM::factory('question')->where('owner_id', $this->owner->id)->find_all(); $view = new View('admin/testimonials/edit'); $view->testimonial = $testimonial; $view->info = json_decode($testimonial->body_edit, TRUE); $view->questions = $questions; $view->tags = $this->tags; $view->image_url = t_paths::image($this->owner->apikey, 'url'); die($view); }
public static function crop_view($apikey, $action_url = NULL) { if (empty($_GET['image'])) { return 'image not available'; } $filename = $_GET['image']; $image_dir = t_paths::image($apikey); if (!file_exists("{$image_dir}/full_{$filename}")) { return 'image not available'; } #hack $id = explode('.', $filename); $view = new View('admin/testimonials/crop'); $view->img_src = t_paths::image($apikey, 'url') . "/full_{$filename}?r=" . text::random('alnum', 6); $view->thmb_src = t_paths::image($apikey, 'url') . "/{$filename}?r=" . text::random('alnum', 6); $view->action_url = empty($action_url) ? '/admin/testimonials/manage/crop?id=' . $id[0] : $action_url; return $view; }