public function Testimonials() { Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript("silverstripe-testimonials/javascript/jquery.anyslider.min.js"); Requirements::javascript("silverstripe-testimonials/javascript/main.js"); return Testimonial::get("Testimonial", array("Approved" => 1), "RAND()"); }
public static function newInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
function getTestimonial() { if (!$this->testimonial) { $this->testimonial = Testimonial::get()->sort("RAND()")->first(); } return $this->testimonial; }
public function index() { $victories = Victory::orderBy('created_at', 'DESC')->limit(4)->get(); $blogs = Blog::orderBy('created_at', 'DESC')->limit(4)->get(); $images = Post::where('is_carasaul', '=', 1)->get(); $testimonials = Testimonial::orderBy('created_at', 'DESC')->limit(1)->get(); return View::make('pages.index', compact('images', 'testimonials', 'victories', 'blogs')); }
public function post_remove() { $testimonial = Testimonial::Find($this->testimonial_id); // delete Organisation_Testimonial DB::table('organisation_testimonial')->where('testimonial_id', '=', $this->testimonial_id)->delete(); // delete testimonial $testimonial->delete(); return Redirect::to('user/testimonials')->with('success', 'The testimonial has been removed.'); }
public function run() { $replace = \Config::get('laravel-testimonials::seed.replace'); if ($replace) { \DB::table('fbf_testimonials')->delete(); } $faker = \Faker\Factory::create(); $statuses = array(Testimonial::DRAFT, Testimonial::APPROVED); for ($i = 0; $i < 100; $i++) { $testimonial = new Testimonial(); $title = $faker->sentence(rand(1, 10)); $testimonial->title = $title; $youTubeVideoFreq = \Config::get('laravel-testimonials::seed.you_tube_video_freq'); $hasYouTubeVideos = $youTubeVideoFreq > 0 && rand(1, $youTubeVideoFreq) == $youTubeVideoFreq; if ($hasYouTubeVideos) { $testimonial->you_tube_video_id = $faker->randomElement(\Config::get('laravel-testimonials::seed.you_tube_video_ids')); $testimonial->image = $testimonial->image_alt = $testimonial->image_width = $testimonial->image_height = ''; } else { $testimonial->you_tube_video_id = ''; $imageFreq = \Config::get('laravel-testimonials::seed.image_freq'); $hasImage = $imageFreq > 0 && rand(1, $imageFreq) == $imageFreq; if ($hasImage) { $thumbnail = $faker->image(public_path(Testimonial::getImageConfig('thumbnail', 'dir')), Testimonial::getImageConfig('thumbnail', 'width'), Testimonial::getImageConfig('thumbnail', 'height')); $filename = basename($thumbnail); $details = $faker->image(public_path(Testimonial::getImageConfig('resized', 'dir')), rand(200, Testimonial::getImageConfig('resized', 'width')), rand(200, Testimonial::getImageConfig('resized', 'height'))); rename($details, public_path(Testimonial::getImageConfig('resized', 'dir')) . $filename); $testimonial->image = $filename; $testimonial->image_alt = $title; } else { $testimonial->image = $testimonial->image_alt = $testimonial->image_width = $testimonial->image_height = ''; } } $testimonial->content = '<p>' . implode('</p><p>', $faker->paragraphs(rand(1, 10))) . '</p>'; $testimonial->source = $faker->words(rand(1, 2), true); $testimonial->page_title = $title; $testimonial->meta_description = $faker->sentence(); $testimonial->meta_keywords = $faker->words(10, true); $testimonial->status = $faker->randomElement($statuses); $testimonial->published_date = $faker->dateTimeBetween('-3 years', '+1 month'); $testimonial->save(); } echo 'Database seeded' . PHP_EOL; }
public function createFeedback() { $validator = Validator::make(Input::all(), $this->rules); if ($validator->passes()) { $testimonial = new Testimonial(); $count = Testimonial::orderby('ID_Feedback', 'DESC')->first(); $tampID = $count->ID_Feedback; $checkYear = substr(strval($tampID), 3, -5); $incrementID = substr($tampID, 3) + 1; $join = "FED" . $incrementID; date_default_timezone_set('Asia/Jakarta'); $date = date('Y-m-d h:i:s', time()); if ($checkYear == strval(date("y"))) { $testimonial->ID_Feedback = $join; $testimonial->Name = Input::get('feed-fullname'); $testimonial->Email = Input::get('feed-email'); $testimonial->Subject = Input::get('feed-subject'); $testimonial->Message = Input::get('feed-message'); $testimonial->Date = $date; $testimonial->Status = "Pending"; $testimonial->save(); return Redirect::to('/testimonial')->with('message', 'Success'); } else { $testimonial = new Testimonial(); date_default_timezone_set('Asia/Jakarta'); $date = date('Y-m-d h:i:s', time()); $testimonial->ID_Feedback = "FED" . date('y') . "00001"; $testimonial->Name = Input::get('feed-fullname'); $testimonial->Email = Input::get('feed-email'); $testimonial->Subject = Input::get('feed-subject'); $testimonial->Message = Input::get('feed-message'); $testimonial->Date = $date; $testimonial->Status = "Pending"; $testimonial->save(); return Redirect::to('/testimonial')->with('message', 'Success'); } } else { return Redirect::to('/testimonial')->withErrors($validator, 'feedback')->withInput()->with('active', 'active'); } }
public function view($slug) { $testimonial = Testimonial::where('status', '=', Testimonial::APPROVED)->where('published_date', '<=', \Carbon\Carbon::now())->where('slug', '=', $slug)->first(); if (!$testimonial) { \App::abort(404); } $viewData['testimonial'] = $testimonial; // Get the next newest and next oldest testimonial if the config says to show these links on the view page if (\Config::get('laravel-testimonials::show_adjacent_testimonials_on_view')) { $viewData['newer'] = Testimonial::where('status', '=', Testimonial::APPROVED)->where('published_date', '<=', \Carbon\Carbon::now())->where('published_date', '>=', $testimonial->published_date)->where('id', '<>', $testimonial->id)->orderBy('published_date', 'asc')->first(); $viewData['older'] = Testimonial::where('status', '=', Testimonial::APPROVED)->where('published_date', '<=', \Carbon\Carbon::now())->where('published_date', '<=', $testimonial->published_date)->where('id', '<>', $testimonial->id)->orderBy('published_date', 'desc')->first(); } return \View::make(\Config::get('laravel-testimonials::view_view'))->with($viewData); }
public function update($id) { $validator = Testimonial::validate(Input::only('name', 'email', 'location', 'description')); if ($validator->fails()) { return Redirect::to('/createTestimonial')->withErrors($validator)->withInput(Input::all()); } else { $testimonial = $this->testimonailRepo->getById($id); $testimonial->name = Input::get('name'); $testimonial->email = Input::get('email'); $testimonial->location = Input::get('location'); $testimonial->description = Input::get('description'); $testimonial->save(); return Redirect::to('allTestimonials')->with('message', 'Testimonial was successfully updated'); } }
/** * Displays the profile page of a student. * @param integer $id the student id */ public function actionView($id) { $model = $this->loadModel($id); $numItems = Yii::app()->params['itemsPerPage']; $downloads = new CArrayDataProvider($model->downloadInfos, array('pagination' => array('pageSize' => $numItems))); $reviews = new CArrayDataProvider($model->reviews, array('pagination' => array('pageSize' => $numItems))); $sql = Yii::app()->db->createCommand()->select(array('id', 'title', 'value', 'note_id', 'timestamp'))->from(array('bk_note note', 'bk_rate rate'))->where(array('and', 'rate.student_id=:sid', 'rate.note_id=note.id'), array(':sid' => $model->id)); $count = count($model->rates); $rates = new CSqlDataProvider($sql, array('totalItemCount' => $count, 'pagination' => array('pageSize' => $numItems))); $sql = Yii::app()->db->createCommand()->select(array('id', 'title', 'note_id', 'timestamp'))->from(array('bk_note note', 'bk_report report'))->where(array('and', 'report.student_id=:sid', 'report.note_id=note.id'), array(':sid' => $model->id)); $count = count($model->reports); $reports = new CSqlDataProvider($sql, array('totalItemCount' => $count, 'pagination' => array('pageSize' => $numItems))); $uploads = new CArrayDataProvider($model->notes, array('pagination' => array('pageSize' => $numItems))); $badges = new CArrayDataProvider($model->badges, array('pagination' => array('pageSize' => 20))); if (Yii::app()->user->isAdmin) { $finder = Testimonial::model(); } else { $finder = Testimonial::model()->student($model->id); } $testimonials = new CActiveDataProvider($finder, array('pagination' => array('pageSize' => $numItems))); $this->render('view', array('model' => $model, 'downloads' => $downloads, 'reviews' => $reviews, 'rates' => $rates, 'reports' => $reports, 'uploads' => $uploads, 'badges' => $badges, 'testimonials' => $testimonials)); }
public function GetTestimonial() { return $testimonial = Testimonial::get()->sort("Created", "DESC")->First() ? $testimonial : false; }
<?php require '../../inc/admin/config.php'; $session->auth_or_redirect('admin', '/', true); $admin_title = 'Manage Testimonials'; include ROOT . '/inc/admin/header.php'; $testimonials = new Testimonial(); $paginator = new Paginator($testimonials->find()); ?> <p><a href="/admin">Back to Admin Home</a></p> <a href="./new.php"><img src="/images/admin/button_add.jpg" alt="Add New Testimonial" id="button_add" /></a> <div id="testimonials_index"> <table> <tr> <th>Name</th> <th>Company</th> <th>Text</th> </tr> <?php foreach ($paginator->this_page() as $testimonial) { ?> <tr> <td><?php echo $testimonial->name; ?> </td> <td><?php echo $testimonial->company;
public function Testimonials() { return Testimonial::get("Testimonial", array("Approved" => 1))->sort("SortOrder"); }
function getTestimonials() { return Testimonial::get(); }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $this->render('index', array('model' => Testimonial::getCurrentTestimonial())); }
<?php //-- Testimonial:Clear cache if ($command == "cc") { if ($arg1 == "all" || $arg1 == "testimonial") { echo " - Drop table 'testimonial' "; echo Testimonial::dropTable() ? "success\n" : "fail\n"; } } //-- Testimonial:Import DB if ($command == "import" && $arg1 == "db" && (is_null($arg2) || $arg2 == "testimonial")) { //- create tables if not exits echo " - Create table 'testimonial' "; echo Testimonial::createTableIfNotExist() ? "success\n" : "fail\n"; }
<?php $object = new Testimonial(); // handle form submission if (isset($_POST['submit'])) { $error_flag = false; /// validation // validation for $name $name = isset($_POST["name"]) ? strip_tags($_POST["name"]) : null; if (empty($name)) { Message::register(new Message(Message::DANGER, i18n(array("en" => "name is required.", "zh" => "请填写name")))); $error_flag = true; } // validation for $image $image = isset($_POST["image"]) ? strip_tags(trim($_POST["image"])) : null; if (empty($image)) { Message::register(new Message(Message::DANGER, i18n(array("en" => "image is required.", "zh" => "请填写image")))); $error_flag = true; } // validation for $comment $comment = isset($_POST["comment"]) ? $_POST["comment"] : null; if (empty($comment)) { Message::register(new Message(Message::DANGER, i18n(array("en" => "comment is required.", "zh" => "请填写comment")))); $error_flag = true; } // validation for $from $from = isset($_POST["from"]) ? strip_tags($_POST["from"]) : null; /// proceed submission // proceed for $name $object->setName($name); // proceed for $image
/** * Retrieves testimonial of the month. * @return Testimonial the testimonial or null if not found */ public static function getCurrentTestimonial() { $testimonial = Testimonial::model()->find(array('condition' => 'status=:status', 'params' => array(':status' => self::STATUS_APPROVED), 'order' => 'timestamp DESC')); if ($testimonial === null) { return null; } $currentMonth = date('m'); $testimonialMonth = date('m', strtotime($testimonial->timestamp)); if ($currentMonth !== $testimonialMonth) { return null; } else { return $testimonial; } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Testimonial::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php require_once './classes/Testimonial.php'; $tst = new Testimonial(); $list = $tst->get_edit_page(); echo $list;
header('Location:' . osc_admin_render_theme_url($ct_url)); } } ?> <h1>Testimonial Information</h1> <form name="testimonial-form" method="post" action=""> <?php if (Params::getParam('nepcoders_action') == 'edit') { ?> <input type="hidden" name="nep_action" value="edit_testimonial"> <input type="hidden" name="testimonial_id" value="<?php echo Params::getParam('tid'); ?> "> <?php $result = Testimonial::newInstance()->getTestimonial(Params::getParam('tid')); $title = $result['testimonial_title']; $image_url = $result['testimonial_image']; $message = $result['testimonial_message']; ?> <?php } else { ?> <input type="hidden" name="nepcoders_action" value="insert_testimonial"/> <?php } ?> <div class="form-group"> <label for="title">Title</label> <input class="form-control" id="title" name="title" value="<?php echo $title;
<?php $id = isset($vars[1]) ? $vars[1] : null; $object = Testimonial::findById($id); $error_flag = false; if ($object) { if ($object->delete()) { Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'Record deleted', 'zh' => '记录删除成功')))); } else { $error_flag = true; } } else { $error_flag = true; } if ($error_flag) { Message::register(new Message(Message::DANGER, i18n(array('en' => 'Record deletion failed', 'zh' => '记录删除失败')))); } HTML::forwardBackToReferer();
function GetTestimonial() { App::import('Model', 'Testimonial'); $objtestimonial = new Testimonial(); $testimonial = $objtestimonial->find('first', array("fields" => array("Testimonial.testimonial", "Testimonial.id", "Testimonial.name", "Testimonial.image", "Testimonial.created"), "order" => "rand()", 'limit' => '0,1', "conditions" => "status='1'")); return $testimonial; }
exit; } if ($_POST['commit'] == "Save Testimonial") { if ($id == 0) { // add the listing $objTestimonial = new Testimonial(); $objTestimonial->CustomerName = $_REQUEST["customer_name"]; $objTestimonial->CustomerTitle = $_REQUEST["customer_title"]; $objTestimonial->CustomerCompany = $_REQUEST["customer_company"]; $objTestimonial->TestimonialText = $_REQUEST["testimonial_text"]; $objTestimonial->Create(); // redirect to listing list header("Location:testimonial_list.php"); exit; } else { $objTestimonial = new Testimonial($_REQUEST["id"]); $objTestimonial->CustomerName = $_REQUEST["customer_name"]; $objTestimonial->CustomerTitle = $_REQUEST["customer_title"]; $objTestimonial->CustomerCompany = $_REQUEST["customer_company"]; $objTestimonial->TestimonialText = $_REQUEST["testimonial_text"]; $objTestimonial->Update(); // redirect to listing list header("Location:testimonial_list.php"); exit; } } else { if ($_REQUEST['mode'] == 'e') { //listing $objTestimonial = new Testimonial($id); $customer_name = $objTestimonial->CustomerName; $customer_title = $objTestimonial->CustomerTitle;
/** * Tests this month testimonial retrieval. */ public function testCurrentTestimonial() { $this->assertNull(Testimonial::getCurrentTestimonial()); $testi = $this->testimonials('testimonial1'); $currentTimestamp = date('Y-m-d H:i:s'); $testi->status = Testimonial::STATUS_NEW; $testi->timestamp = $currentTimestamp; $this->assertTrue($testi->save()); $this->assertNull(Testimonial::getCurrentTestimonial()); $student = $this->students('student1'); $content = 'Test content.'; $newTesti = new Testimonial(); $newTesti->setAttributes(array('content' => 'Test content.', 'status' => Testimonial::STATUS_APPROVED, 'timestamp' => $currentTimestamp, 'student_id' => $student->id)); $this->assertTrue($newTesti->save()); $testi = Testimonial::getCurrentTestimonial(); $this->assertNotNull($testi); $this->assertTrue($testi instanceof Testimonial); $this->assertEquals($student->id, $testi->student_id); $this->assertEquals($content, $testi->content); $this->assertEquals(Testimonial::STATUS_APPROVED, $testi->status); $this->assertEquals(date('m', strtotime($currentTimestamp)), date('m', strtotime($testi->timestamp))); $this->assertEquals($student->id, $testi->student_id); }
<?php require_once __DIR__ . DS . '..' . DS . '..' . DS . 'bootstrap.php'; $weight = 0; if (is_cli()) { $testimonial = new Testimonial(); $testimonial->setName('Peter Wang'); $testimonial->setFrom('UNSW master student'); $testimonial->setComment('Great service! I got my uni offer in just 20 days. Thumbs up!'); $testimonial->setImage('files/testimonial/1.jpg'); $testimonial->save(); $testimonial = new Testimonial(); $testimonial->setName('Helen White'); $testimonial->setFrom('Staint George College'); $testimonial->setComment('The staff at Century 21 are very open and helpful. Whenever I\'ve got any enquiry, they always respond me promptly. Nice job!'); $testimonial->setImage('files/testimonial/2.jpg'); $testimonial->save(); $testimonial = new Testimonial(); $testimonial->setName('Steven Tan'); $testimonial->setFrom('English course student in UOW'); $testimonial->setComment('I was an oversea student and not so good with my English. Century 21 assisted me finding the right English language instition and I now have got my college offer. All thanks to them!'); $testimonial->setImage('files/testimonial/3.jpg'); $testimonial->save(); $testimonial = new Testimonial(); $testimonial->setName('Mike Nash'); $testimonial->setFrom('High school student at ACIIA'); $testimonial->setComment('Very appreciated for the free consulation. Century 21 provided me all the school details free of charge. I choose their service and got the offer!'); $testimonial->setImage('files/testimonial/4.jpg'); $testimonial->save(); }
public function save_order() { $testimonial_array = $_POST['testimonial_id']; $order_array = $_POST['order']; $testimonial = new Testimonial(); foreach ($testimonial_array as $key => $value) { $testimonial_id = $value; $testimonial_order = $order_array[$key]; $testimonial->update('Testimonial', array('sequence' => $testimonial_order), 'id=' . $testimonial_id); } Flash::set('success', __('This testimonial sequence has been saved.')); redirect(get_url('testimonial')); }
require '../inc/classes/Helpers.php'; // page vars $page_title = ""; $id = $_REQUEST['id']; // id required if ($id == "") { header("Location:mainpage.php"); exit; } // if form was submitted if ($_POST['commit'] == "Cancel") { header("Location:testimonial_list.php"); exit; } if ($_POST['commit'] == "Delete Testimonial") { $objTestimonial = new Testimonial(); $objTestimonial->Delete($id); header("Location:testimonial_list.php"); exit; } $objTestimonial = new Testimonial($id); include "includes/pagetemplate.php"; function PageContent() { global $objTestimonial; global $id; ?> <div class="layout laymidwidth"> <?php
public function getById($id) { return \Testimonial::find($id); }
/** * Displays the login page */ public function actionTestimonial() { $cs = Yii::app()->getclientScript(); //$cs->registerCssFile(Yii::app()->params["baseUrl"].'/css/plugins/owl/owl.carousel.css?a='. Yii::app()->params['assets'],'screen, projection'); $cs->registerCssFile(Yii::app()->params["baseUrl"] . '/css/pages/testimonial.css?a=' . Yii::app()->params['assets'], 'screen, projection'); //$cs->registerScriptFile(Yii::app()->params["baseUrl"].'/js/plugins/freewall/freewall.js?a='. Yii::app()->params['assets'],CClientScript::POS_END); //$cs->registerScriptFile(Yii::app()->params["baseUrl"].'/js/pages/wedding.js?a='. Yii::app()->params['assets'],CClientScript::POS_HEAD); $_test = new Testimonial(); $testimonials = $_test->getTestimonials(); $this->render("testimonial", array('testimonials' => $testimonials)); }