public function index() { $db = new Database(); // clean up old orders that are a week or older and are 'Pending' $dat = time(); $lastweek = $dat - 604800; $result = $db->query('DELETE FROM orders WHERE date_modified < ' . $lastweek . ' AND statusID = 1'); // In Kohana, all views are loaded and treated as objects. $this->template->content = new View('homepage'); $this->template->metaDescription = $this->description; $this->template->metaKeywords = $this->keywords; $this->template->metaTitle = $this->title; // getOccasions and getOccasion($id) is a method defined in Occasion_Model $occasions = new Occasion_Model(); $this->template->content->occasionresults = $occasions->getOccasions(); // getProducts is a method defined in Product_Model $products = new Product_Model(); $this->template->content->productresults = $products->getHomepageProducts(); // getLatestTestimonial is a method defined in Testimonial_Model $testimonial = new Testimonial_Model(); $this->template->content->testimonialresult = $testimonial->getLatestTestimonial(); // get the most recently created hearts of each product type $result = $db->query('SELECT orders.id, orders.can_share, orders_baskets.id, orders_baskets.product_id, orders_baskets.designpath, orders_baskets.msg_text1, orders_baskets.msg_text2, fc.name FROM orders INNER JOIN orders_baskets ON orders.id = orders_baskets.order_id LEFT JOIN foil_colors fc ON fc.id = orders_baskets.foil_id WHERE orders.can_share = 1 AND orders_baskets.designpath != "" AND orders_baskets.img_approved = 1 AND orders.statusID IN (2,4,5) AND orders.site_id = ' . My_Template_Controller::getCurrentSite()->id . ' ORDER BY order_date DESC LIMIT 4'); $recentForward = array(); $recentBack = array(); $i = 0; foreach ($result as $recent) { if ($i < 10) { $recentForward[$i] = $recent; } else { $recentBack[$i - 10] = $recent; } $i++; } $this->template->content->recentHearts = $recentForward; $this->template->content->recentHeartsBack = $recentBack; //$result = $db->query('SELECT orders.id, orders.can_share, orders_baskets.id, orders_baskets.product_id, orders_baskets.designpath FROM orders INNER JOIN orders_baskets ON orders.id = orders_baskets.order_id WHERE orders.can_share = 1 AND orders_baskets.designpath != "" AND orders_baskets.img_approved = 1 AND orders.statusID IN (2,4,5) ORDER BY order_date ASC LIMIT 10'); // You can assign anything variable to a view by using standard OOP // methods. In my welcome view, the $title variable will be assigned // the value I give it here. $this->template->title = $this->title; $result = $db->query("SELECT * FROM slides WHERE site_id = '" . My_Template_Controller::getCurrentSite()->id . "'"); $this->template->content->slides = $result; }
public function index() { // In Kohana, all views are loaded and treated as objects. $this->template->content = new View('testimonials'); $this->template->metaDescription = $this->description; $this->template->metaKeywords = $this->keywords; $this->template->metaTitle = $this->title; // You can assign anything variable to a view by using standard OOP // methods. In my welcome view, the $title variable will be assigned // the value I give it here. $this->template->title = $this->title; $db = new Database(); $resultall = $db->query('SELECT t.* ' . 'FROM testimonials t ' . 'INNER JOIN sites_testimonials st ON t.id = st.testimonial_id ' . 'WHERE st.site_id = ' . self::getCurrentSite()->id . ' ORDER BY t.id DESC'); $this->template->content->testimonialresults = $resultall; // getProducts is a method defined in Product_Model $products = new Product_Model(); $this->template->content->productresults = $products->getProductsForSite(TRUE); // getOccasions and getOccasion($id) is a method defined in Occasion_Model $occasions = new Occasion_Model(); $this->template->content->occasionresults = $occasions->getOccasions(); $this->template->content->message = ""; }
public function show() { // In Kohana, all views are loaded and treated as objects. $this->template->content = new View('occasions'); $occasionarray = Router::$arguments; $occasionname = $occasionarray[0]; // getOccasions and getOccasion($id) is a method defined in Occasion_Model $occasions = new Occasion_Model(); $this->template->content->occasionresults = $occasions->getOccasions(); $occasion = $occasions->getOccasionByName($occasionname); $this->template->content->occasion = $occasion; $this->template->metaDescription = $occasion->meta_description; $this->template->metaKeywords = $occasion->meta_keywords; $this->template->metaTitle = $occasion->meta_title; // You can assign anything variable to a view by using standard OOP // methods. In my welcome view, the $title variable will be assigned // the value I give it here. $this->template->title = $occasion->meta_title; // getProducts is a method defined in Product_Model $products = new Product_Model(); $this->template->content->productresults = $products->getProductsForSite(TRUE); }
public function add() { $argumentarray = Router::$arguments; $occasions = new Occasion_Model(); $id = $occasions->getNextID(); if (isset($_POST['save'])) { $post = new Validation(array_merge($_POST, $_FILES)); $post->pre_filter('trim', 'occasionName', 'occasionHeadline', 'occasionDescription'); $post->add_rules('occasionName', 'required'); $post->add_rules('occasionHeadline', 'required'); if (!$post->validate()) { $errors = $post->errors('form_errors'); foreach ($errors as $error) { echo '<p class="error">' . $error . '</p>'; } } else { //$id = $argumentarray[0]; $occasions = new Occasion_Model(); $occasion = ORM::factory('occasion'); $occasion->name = $post->occasionName; $occasion->headline = $post->occasionHeadline; //$occasion->description = $post->occasionDescription; if ($occasion->occasions_description_id) { $desc = ORM::factory('occasions_description')->find($occasion->occasions_description_id); } else { $desc = ORM::factory('occasions_description'); } $desc->description = $post->occasionDescription; $desc->title_url = $post->metaUrl; $desc->short_description = $post->occasionShortDescription; $desc->meta_description = $post->metaDescription; $desc->meta_keywords = $post->metaKeywords; $desc->meta_title = $post->metaTitle; $desc->image_alt = $post->image_alt; $desc->save(); $occasion->occasions_description_id = $desc->id; if (!empty($_FILES['image']['name'])) { // uses Kohana upload helper $_FILES = Validation::factory($_FILES)->add_rules('image', 'upload::valid', 'upload::type[gif,jpg,jpeg,png]', 'upload::size[2M]'); if ($_FILES->validate()) { // Temporary file name $filename = upload::save('image', basename($_FILES['image']['tmp_name'])); $file = basename($_FILES['image']['name']); // Resize, sharpen, and save the image Image::factory($filename)->save(DOCROOT . '../../env/product_images/' . $file); // Remove the temporary file unlink($filename); $desc->image = $file; $desc->save(); } else { $errors = $_FILES->errors('form_user'); } } $occasion->save(); if (!empty($post->occasionSites)) { foreach ($post->occasionSites as $site_id) { $sc = ORM::factory('sites_occasion')->where('occasion_id', $occasion->id)->where('site_id', $site_id)->find(); if ($sc->id == 0) { $sc->occasion_id = $occasion->id; $sc->site_id = $site_id; $sc->save(); } } } url::redirect('/occasions/edit/' . $occasion->id); } } $this->_renderView(); }
oFCKeditor.BasePath = sBasePath ; oFCKeditor.ReplaceTextarea() ; var oFCKeditor = new FCKeditor( 'occasionShortDescription' ) ; oFCKeditor.Width = '100%' ; oFCKeditor.Height = '300' ; oFCKeditor.BasePath = sBasePath ; oFCKeditor.ReplaceTextarea() ; } </script> <?php $id = $this->uri->segment(3); $argumentarray = Router::$arguments; $occasions = new Occasion_Model(); if (isset($argumentarray[0])) { $id = $argumentarray[0]; //$occasion = $occasions->getOccasionByID($id); $occasion = $occasions->find($id); } else { $id = $occasions->getNextID(); //$occasion = ORM::factory('occasion'); $occasion = $occasions; //$descs = new Occasions_description_Model; //$occasion->occasions_description = $descs; } //var_dump($occasion); //$desc = ORM::factory('occasions_description')->find($occasion->occasions_description_id); //$occasions_description = ORM::factory('occasions_description')->find($occasion->occasions_description_id); $i = 0;