/**
  *
  */
 public function onAfterInit()
 {
     if ($code = PageProoferConfig::get_page_proofer()) {
         $data = ArrayData::create(array('Code' => $code->Code));
         Requirements::customScript($data->renderWith('PageProofer'));
     }
 }
 public function Field($properties = array())
 {
     if ($this->firstActive) {
         $this->makeFirstActive();
     }
     $properties['endCarousel'] = true;
     $properties['outerCarouselNavigation'] = true;
     $properties['carouselNavigationClasses'] = 'carousel-static';
     if (!isset($properties['startCarousel'])) {
         $properties['startCarousel'] = $this->ID();
     }
     if (!isset($properties['carouselParentAttributes'])) {
         $properties['carouselParentAttributes'] = $this->JSONAttributesHTML;
     }
     if (!isset($properties['slides'])) {
         $properties['slides'] = $this->children;
     }
     if (!isset($properties['carouselNavigation']) && $this->children && $this->children->exists()) {
         $properties['carouselName'] = $this->ID();
         $properties['carouselNavigation'] = ArrayList::create();
         foreach ($this->children as $child) {
             $properties['carouselNavigation']->push(ArrayData::create(array('carouselTitle' => $child->Title(), 'carouselActive' => $child->isActive(), 'carouselName' => $this->ID())));
         }
     }
     return parent::Field($properties);
 }
 /**
  * Returns list of categories used in GoogleBase.ss template
  * Override with getGoogleBaseCategoryList on Product defaults to getGoogleBaseCategoryList on GoogleBaseProduct
  * @return ArrayList of categories
  */
 public function getGoogleBaseCategoryList()
 {
     $list = $this->owner->GoogleBaseCategories;
     if ($list) {
         $allCategories = ArrayList::create();
         $categories = explode(' > ', $list);
         $string = '';
         $count = 0;
         $used = array();
         foreach ($categories as $k => $category) {
             if (isset($used[$category])) {
                 continue;
             }
             $used[$category] = $category;
             ++$count;
             if ($count == 1) {
                 $string = trim($category);
             } else {
                 $string .= ' > ' . trim($category);
             }
             $allCategories->push(ArrayData::create(array('Category' => $string)));
         }
         return $allCategories;
     }
     return false;
 }
 /**
  * will ask the target server to return the file list and the data object list
  * @param type $request
  */
 public function run($request)
 {
     if (!$this->config()->target) {
         throw new Exception('Target not found in yml file. See readme.md for installation instructions.');
     }
     if (!$this->config()->key) {
         throw new Exception('Key not found in yml file. See readme.md for installation instructions.');
     }
     $myurl = Director::absoluteURL('/remoteassetdiff') . '/' . urlencode($this->config()->key);
     $downloadurl = Director::absoluteURL('/remoteassetdownload') . '/' . urlencode($this->config()->key) . '?m=' . time();
     // download without javascript
     if (Director::is_cli()) {
         ini_set('memory_limit', '1024M');
         set_time_limit(0);
         echo "Creating list of files to download" . PHP_EOL;
         $listoffiles = RemoteAssetTask::DownloadFile($myurl);
         $fullist = json_decode($listoffiles);
         if (!is_array($fullist->download)) {
             throw new Exception('Failure to download list of files');
         }
         foreach ($fullist->download as $file) {
             echo "Downloading {$file} ... ";
             try {
                 RemoteAssetTask::DownloadFile($downloadurl . '&download=' . $file);
                 echo "Success" . PHP_EOL;
             } catch (Exception $e) {
                 echo "Failure" . PHP_EOL;
             }
         }
         echo "Done" . PHP_EOL;
         return;
     }
     echo ArrayData::create(array('FetchURL' => $myurl, 'DownloadURL' => $downloadurl, 'Target' => $this->config()->target, 'ToMachine' => Director::absoluteURL('/')))->renderWith('RemoteAssetTask');
 }
 /**
  * Requires the necessary JS and sends the required HTML structure to the template
  * for a responsive image set
  *
  * @param array $config The configuration of the responsive image set from the config
  * @param array $args The arguments passed to the responsive image method, e.g. $MyImage.ResponsiveSet1(800x600)
  * @param string $method The method, or responsive image set, to generate
  * @return SSViewer
  */
 protected function createResponsiveSet($config, $args, $method)
 {
     Requirements::javascript(RESPONSIVE_IMAGES_DIR . '/javascript/picturefill/external/matchmedia.js');
     Requirements::javascript(RESPONSIVE_IMAGES_DIR . '/javascript/picturefill/picturefill.js');
     if (!isset($config['sizes']) || !is_array($config['sizes'])) {
         throw new Exception("Responsive set {$method} does not have sizes defined in its config.");
     }
     if (isset($args[0])) {
         $defaultDimensions = $args[0];
     } elseif (isset($config['default_size'])) {
         $defaultDimensions = $config['default_size'];
     } else {
         $defaultDimensions = Config::inst()->forClass("ResponsiveImageExtension")->default_size;
     }
     if (isset($args[1])) {
         $methodName = $args[1];
     } elseif (isset($config['method'])) {
         $methodName = $config['method'];
     } else {
         $methodName = Config::inst()->forClass("ResponsiveImageExtension")->default_method;
     }
     $sizes = ArrayList::create();
     foreach ($config['sizes'] as $i => $arr) {
         if (!isset($arr['query'])) {
             throw new Exception("Responsive set {$method} does not have a 'query' element defined for size index {$i}");
         }
         if (!isset($arr['size'])) {
             throw new Exception("Responsive set {$method} does not have a 'size' element defined for size index {$i}");
         }
         list($width, $height) = $this->parseDimensions($arr['size']);
         $sizes->push(ArrayData::create(array('Image' => $this->owner->getFormattedImage($methodName, $width, $height), 'Query' => $arr['query'])));
     }
     list($default_width, $default_height) = $this->parseDimensions($defaultDimensions);
     return $this->owner->customise(array('Sizes' => $sizes, 'DefaultImage' => $this->owner->getFormattedImage($methodName, $default_width, $default_height)))->renderWith('ResponsiveImageSet');
 }
 protected function renderRows($rows, ArrayIterator $splitcontent, &$pos = -1)
 {
     $output = "";
     $rownumber = 0;
     foreach ($rows as $row) {
         if ($row->cols) {
             $columns = array();
             foreach ($row->cols as $col) {
                 $nextcontent = $splitcontent->current();
                 $isholder = !isset($col->rows);
                 if ($isholder) {
                     $splitcontent->next();
                     //advance iterator if there are no sub-rows
                     $pos++;
                     //wrap split content in a HTMLText object
                     $dbObject = DBField::create_field('HTMLText', $nextcontent, "Content");
                     $dbObject->setOptions(array("shortcodes" => true));
                     $nextcontent = $dbObject;
                 }
                 $width = $col->width ? (int) $col->width : 1;
                 //width is at least 1
                 $columns[] = new ArrayData(array("Width" => $width, "EnglishWidth" => $this->englishWidth($width), "Content" => $isholder ? $nextcontent : $this->renderRows($col->rows, $splitcontent, $pos), "IsHolder" => $isholder, "GridPos" => $pos, "ExtraClasses" => isset($col->extraclasses) ? $col->extraclasses : null));
             }
             $output .= ArrayData::create(array("Columns" => new ArrayList($columns), "RowNumber" => (string) $rownumber++, "ExtraClasses" => isset($row->extraclasses) ? $row->extraclasses : null))->renderWith($this->template);
         } else {
             //every row should have columns!!
         }
     }
     return $output;
 }
 public function ChartData()
 {
     $chartData = array();
     $list = ArrayList::create(array());
     $sqlQuery = new SQLQuery();
     $sqlQuery->setFrom('Addon');
     $sqlQuery->setSelect('Created');
     $sqlQuery->selectField('COUNT(*)', 'CountInOneDay');
     $sqlQuery->addWhere('"Created" >= DATE_SUB(NOW(), INTERVAL 30 DAY)');
     $sqlQuery->addGroupBy('DATE(Created)');
     $result = $sqlQuery->execute();
     if (count($result)) {
         foreach ($result as $row) {
             $date = date('j M Y', strtotime($row['Created']));
             if (!isset($chartData[$date])) {
                 $chartData[$date] = $row['CountInOneDay'];
             }
         }
     }
     if (count($chartData)) {
         foreach ($chartData as $x => $y) {
             $list->push(ArrayData::create(array('XValue' => $x, 'YValue' => $y)));
         }
     }
     return $list;
 }
 public function getInstagramFeedItems()
 {
     $api_url = 'https://api.instagram.com/v1/tags/' . $this->configSettings['DefaultHash'] . '/media/recent?client_id=' . $this->configSettings['ClientID'];
     $ch = curl_init();
     curl_setopt_array($ch, array(CURLOPT_URL => $api_url, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => false));
     $output = curl_exec($ch);
     $instagram_json = json_decode($output);
     $whitelist_fields = array('created_time', 'link', 'images', 'likes');
     $row_array = array();
     foreach ($instagram_json->data as $items) {
         $coloumn_array = array();
         foreach ($items as $key => $value) {
             if (in_array($key, $whitelist_fields)) {
                 if ($key == 'images') {
                     $coloumn_array['LowResImage'] = $value->low_resolution->url;
                     $coloumn_array['StandardResImage'] = $value->standard_resolution->url;
                     $coloumn_array['Thumbnail'] = $value->thumbnail->url;
                 } elseif ($key == 'likes') {
                     $coloumn_array['Likes'] = $value->count;
                 } else {
                     $coloumn_array[$key] = $value;
                 }
             }
         }
         array_push($row_array, ArrayData::create($coloumn_array));
     }
     $instagram_feed_arraylist = ArrayList::create($row_array);
     return $instagram_feed_arraylist->renderWith('InstagramFeed');
 }
 public function Weather()
 {
     if (!$this->Location) {
         return false;
     }
     $rnd = time();
     $url = "http://query.yahooapis.com/v1/public/yql?format=json&rnd={$rnd}&diagnostics=true&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&q=";
     $query = urlencode("select * from weather.forecast where location in (select id from weather.search where query=\"{$this->Location}\") and u=\"{$this->Units}\"");
     $response = file_get_contents($url . $query);
     if ($response) {
         $result = Convert::json2array($response);
         if (!$result["query"]["results"]) {
             return false;
         }
         $days = ArrayList::create(array());
         $channel = isset($result["query"]["results"]["channel"][0]) ? $result["query"]["results"]["channel"][0] : $result["query"]["results"]["channel"];
         $label = $channel["title"];
         $link = $channel["link"];
         $forecast = $channel["item"]["forecast"];
         for ($i = 0; $i < 2; $i++) {
             $item = $forecast[$i];
             $days->push(ArrayData::create(array('High' => $item["high"], 'Low' => $item["low"], 'ImageURL' => "http://l.yimg.com/a/i/us/we/52/" . $item["code"] . ".gif", 'Label' => $i == 0 ? _t('Dashboard.TODAY', 'Today') : _t('Dashboard.TOMORROW', 'Tomorrow'))));
         }
         $html = $this->customise(array('Location' => str_replace("Yahoo! Weather - ", "", $label), 'Link' => $link, 'Days' => $days))->renderWith('DashboardWeatherContent');
         $this->WeatherHTML = $html;
         $this->write();
         return $html;
     }
     return $this->WeatherHTML;
 }
 /**
  * Returns an instance of this class
  *
  * @param Controller $controller
  * @param string $name
  */
 public function __construct($controller, $name)
 {
     $fields = new FieldList(array(new HiddenField('AuthenticationMethod', null, $this->authenticator_class)));
     $loginButtonContent = ArrayData::create(array('Label' => _t('RealMeLoginForm.LOGINBUTTON', 'Login or register with RealMe')))->renderWith('RealMeLoginButton');
     $actions = new FieldList(array(FormAction::create('redirectToRealMe', _t('RealMeLoginForm.LOGINBUTTON', 'LoginAction'))->setUseButtonTag(true)->setButtonContent($loginButtonContent)->setAttribute('class', 'realme_button')));
     // Taken from MemberLoginForm
     if (isset($_REQUEST['BackURL'])) {
         $backURL = $_REQUEST['BackURL'];
     } elseif (Session::get('BackURL')) {
         $backURL = Session::get('BackURL');
     }
     if (isset($backURL)) {
         // Ensure that $backURL isn't redirecting us back to login form or a RealMe authentication page
         if (strpos($backURL, 'Security/login') === false && strpos($backURL, 'Security/realme') === false) {
             $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
         }
     }
     // optionally include requirements {@see /realme/_config/config.yml}
     if ($this->config()->include_jquery) {
         Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
     }
     if ($this->config()->include_javascript) {
         Requirements::javascript(REALME_MODULE_PATH . "/javascript/realme.js");
     }
     if ($this->config()->include_css) {
         Requirements::css(REALME_MODULE_PATH . "/css/realme.css");
     }
     parent::__construct($controller, $name, $fields, $actions);
 }
 public function Inputs()
 {
     if (count($this->linkedFields)) {
         return \ArrayList::create();
     }
     $ranged = is_array($this->settings['start']) && count($this->settings['start']) > 1;
     $minName = $ranged ? 'min' : 'value';
     $fields[$minName] = ['Render' => $this->castedCopy(\NumericField::create($this->Name . '[' . $minName . ']'))];
     $fields[$minName]['Render']->Value = is_array($this->settings['start']) ? $this->settings['start'][0] : $this->settings['start'];
     if ($ranged) {
         $fields['max'] = ['Render' => $this->castedCopy(\NumericField::create($this->Name . '[max]'))];
         $fields['max']['Render']->Value = $this->settings['start'][1];
     }
     $count = 0;
     array_walk($fields, function ($field) use(&$count) {
         if (!isset($field['Handle'])) {
             $field['Handle'] = $count % 2 ? 'upper' : 'lower';
         }
         if (isset($field['Render'])) {
             $field['Render']->removeExtraClass('rangeslider-display')->addExtraClass('rangeslider-linked')->setAttribute('data-rangeslider-handle', $field['Handle']);
         }
         $count++;
     });
     $fields = \ArrayList::create(array_map(function ($field) {
         return \ArrayData::create($field);
     }, $fields));
     if ($this->inputCallback && is_callable($this->inputCallback)) {
         call_user_func_array($this->inputCallback, [$fields]);
     }
     $this->extend('updateInputs', $fields);
     return $fields;
 }
 public function addMessage($message, $type)
 {
     if (!is_a($this->Messages, 'ArrayList')) {
         $this->Messages = ArrayList::create();
     }
     $this->Messages->add(ArrayData::create(array('Message' => $message, 'Type' => $type)));
 }
 public function generateScriptDataFor($type, $file = null)
 {
     if (!class_exists($type)) {
         throw new Exception("Invalid type defined, no data generated");
     }
     $typeConfig = $this->configFor($type);
     $config = isset($typeConfig[$file]) ? $typeConfig[$file] : array();
     // TODO - allow for specifying things like strtotime things for dates in some manner
     $rules = isset($config['filter']) ? $config['filter'] : null;
     $list = $type::get();
     if ($rules) {
         $list = $this->applyRulesToList($list, $rules);
     }
     $template = isset($config['template']) ? $config['template'] : 'JsonSet';
     $setFields = isset($config['fields']) ? $config['fields'] : null;
     if ($setFields) {
         $setFields = explode(',', $setFields);
     }
     $order = isset($config['order']) ? $config['order'] : 'ID DESC';
     $list = $list->sort($order);
     $list = $list->filterByCallback(function ($item) use($setFields) {
         // extension check was done on the type earlier, here we're just being careful
         if ($item->hasExtension('GenieExtension') && $setFields) {
             $item->setJSONFields($setFields);
         }
         return $item->canView();
     });
     $data = ArrayData::create(array('RootObject' => isset($config['rootObject']) ? $config['rootObject'] : 'window', 'Type' => $type, 'Items' => $list));
     $output = $data->renderWith($template);
     return $output;
 }
 public function getOptions()
 {
     $options = ArrayList::create();
     foreach ($this->optionsList as $val => $label) {
         $options->push(ArrayData::create(array('Label' => $label, 'Value' => $val, 'Selected' => $this->Value() == $val)));
     }
     return $options;
 }
Esempio n. 15
0
 public function render($arguments, $caption = null, $parser = null)
 {
     $link = isset($arguments['link']) ? $arguments['link'] : $caption;
     if ($link && !filter_var($link, FILTER_VALIDATE_URL)) {
         $link = \Controller::join_links($this->url, str_replace('@', '', $link));
     }
     return \ArrayData::create(array_merge($this->vars($link, $arguments, $caption, $parser), $arguments))->renderWith($this->template);
 }
 protected function getButtonFragment($grid)
 {
     $field = \DropdownField::create(sprintf('%s[ClassName]', str_replace('\\', '_', __CLASS__)), '', $this->getAllowedClasses($grid))->addExtraClass('no-change-track ss-gridfield-inline-new-extended--class-selector');
     if ($this->showEmptyString) {
         $field->setEmptyString($this->showEmptyString !== true ? $this->showEmptyString : _t('GridFieldExtensions.SELECTTYPETOCREATE', '(Select type to create)'));
     }
     return \ArrayData::create(['Title' => $this->getTitle(), 'Ajax' => true, 'Link' => $this->Link('load'), 'ClassField' => $field])->renderWith($this->buttonTemplate);
 }
 /**
  * Gets all of the items in the relation and provides edit/delete links for the table
  *
  * @return ArrayList
  */
 public function Items()
 {
     $items = ArrayList::create(array());
     $labelField = Config::inst()->get($this->relationClass, "label_field", Config::INHERITED);
     foreach ($this->records as $record) {
         $items->push(ArrayData::create(array('Label' => $record->{$labelField}, 'DeleteLink' => Controller::join_links($this->Link("item"), $record->ID, "delete"), 'EditLink' => $this->Link("item/{$record->ID}"), 'ID' => $record->ID)));
     }
     return $items;
 }
 /**
  * Gets the recent edited pages, limited to a user provided number of records
  *
  * @return ArrayList
  */
 public function RecentEdits()
 {
     $records = SiteTree::get()->sort("LastEdited DESC")->limit($this->Count);
     $set = ArrayList::create(array());
     foreach ($records as $r) {
         $set->push(ArrayData::create(array('EditLink' => Injector::inst()->get("CMSPagesController")->Link("edit/show/{$r->ID}"), 'Title' => $r->Title)));
     }
     return $set;
 }
 /**
  * Gets the recent edited pages, limited to a user provided number of records
  *
  * @return ArrayList
  */
 public function CustomerQuestions()
 {
     $records = CustomerQuestion::get()->sort("LastEdited DESC")->filter(array("Answered" => "0"))->limit($this->Count);
     $set = ArrayList::create(array());
     foreach ($records as $r) {
         $set->push(ArrayData::create(array('AnswerLink' => "admin/customer-questions/CustomerQuestion/EditForm/field/CustomerQuestion/item/{$r->ID}/edit", 'Title' => $r->Question)));
     }
     return $set;
 }
 public function sendEmail()
 {
     $from = "The Hub Event Management <*****@*****.**>";
     $to = $this->getManagerEmail();
     $subject = "New event registration: " . $this->getTitle();
     $email = Email::create();
     $email->setFrom($from)->setTo($to)->setSubject($subject)->setTemplate('EventNotification')->populateTemplate(ArrayData::create(array('Name' => $this->Name, 'Email' => $this->Email, 'Title' => $this->getTitle(), 'StartDate' => $this->Time()->StartDate, 'StartTime' => $this->Time()->StartTime, 'EndDate' => $this->Time()->EndDate, 'EndTime' => $this->Time()->EndTime)));
     $email->send();
 }
 /**
  * Gets a list of the recently uploaded files to the CMS
  *
  * @return ArrayList
  */
 public function RecentFiles()
 {
     $records = File::get()->filter(array('ClassName:not' => 'Folder'))->sort("LastEdited DESC")->limit($this->Count);
     $set = ArrayList::create(array());
     foreach ($records as $r) {
         $set->push(ArrayData::create(array('EditLink' => Injector::inst()->get("AssetAdmin")->Link("EditForm/field/File/item/{$r->ID}/edit"), 'Title' => $r->Title)));
     }
     return $set;
 }
 /**
  * @return HTMLText
  */
 public function getFlashMessage()
 {
     if ((string) ($message = Session::get('FlashMessage'))) {
         Session::clear('FlashMessage');
         /** @var ArrayData $array */
         $array = ArrayData::create($message);
         return $array->renderWith('FlashMessage');
     }
     return false;
 }
Esempio n. 23
0
 public function render($arguments, $caption = null, $parser = null)
 {
     $link = isset($arguments['link']) ? $arguments['link'] : $caption;
     $user = $caption;
     if ($link && !filter_var($link, FILTER_VALIDATE_URL)) {
         $link = '';
         $user = $link;
     }
     return \ArrayData::create(array_merge(array('gpLink' => $link, 'gpUser' => $user, 'gpAnnotation' => isset($arguments['annotation']) ? $arguments['annotation'] : null, 'gpSize' => isset($arguments['size']) ? $arguments['size'] : null), $arguments))->renderWith($this->template);
 }
 /**
  * Get the html/css button and upload field to perform import.
  */
 public function getHTMLFragments($gridField)
 {
     $button = new GridField_FormAction($gridField, 'import', _t('TableListField.CSVIMPORT', 'Import from CSV'), 'import', null);
     $button->setAttribute('data-icon', 'drive-upload');
     $button->addExtraClass('no-ajax');
     $uploadfield = $this->getUploadField($gridField);
     $data = array('Button' => $button, 'UploadField' => $uploadfield);
     $importerHTML = ArrayData::create($data)->renderWith("GridFieldImporter");
     Requirements::javascript('importexport/javascript/GridFieldImporter.js');
     return array($this->targetFragment => $importerHTML);
 }
 public function handleView($grid, $request)
 {
     if ($grid->Form && $grid->Form->Record) {
         $record = $grid->Form->Record;
     } else {
         $record = \ArrayData::create();
     }
     $template = is_array($this->template) ? $this->template : [$this->template];
     array_push($template, 'GridFieldHelpButton_View');
     return $record->customise(array('Content' => $this->content))->renderWith($template);
 }
 public function getRealItem()
 {
     if (!$this->OtherClass || !$this->OtherID) {
         return $this;
     }
     $item = DataObject::get_by_id($this->OtherClass, $this->OtherID);
     if (!$item) {
         $item = ArrayData::create(array('ID' => $this->OtherID, 'ClassName' => $this->OtherClass, 'Title' => 'deleted', 'LastEdited' => 'deleted', 'getChangeType' => 'deleted', 'Version' => 'deleted'));
     }
     return $item;
 }
 public static function MiniCartItemShortCode($arguments, $content = null, $parser = null)
 {
     if (empty($arguments['name']) || empty($arguments['price'])) {
         return;
     }
     $item_name = $arguments['name'];
     $item_number = isset($arguments['sku']) ? $arguments['sku'] : null;
     $item_price = $arguments['price'];
     $button = !empty($content) ? $content : 'Add to cart';
     $data = ArrayData::create(array('FormAction' => MiniCart::get_form_action(), 'ItemName' => $item_name, 'ItemNumber' => $item_number, 'Amount' => $item_price, 'Button' => $button, 'Business' => MiniCart::get_business_email(), 'CurrencyCode' => MiniCart::get_currency_code(), 'Return' => MiniCart::get_return_page(), 'Cancel' => MiniCart::get_cancel_page()));
     return $data->renderWith('MiniCartItem');
 }
 public function Options()
 {
     if ($this->custOptions) {
         return $this->custOptions;
     }
     $custom = $this->CustomOptions->getValues();
     if (count($custom)) {
         $this->custOptions = ArrayData::create($custom);
         return $this->custOptions;
     }
     return parent::Options();
 }
 /**
  *
  * @param \GridField $gridField
  * @param \DataObject $record
  * @param string $columnName
  * @return string|null - the HTML for the column
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     if (!$record instanceof \Payment) {
         return null;
     }
     \Requirements::css('omnipay-ui/css/omnipay-ui-cms.css');
     \Requirements::javascript('omnipay-ui/javascript/omnipay-ui-cms.js');
     if (preg_match('/Pending(Capture|Void|Refund)/', $record->Status)) {
         return \SSViewer::execute_template('PaymentPendingIndicator', \ArrayData::create(array('StatusLink' => \Controller::join_links($gridField->Link('checkPaymentPending')), 'PaymentID' => $record->ID, 'Timeout' => 2000)));
     }
     return null;
 }
Esempio n. 30
-2
 public function index(SS_HTTPRequest $request)
 {
     $properties = Property::get();
     $filters = ArrayList::create();
     if ($search = $request->getVar('Keywords')) {
         $filters->push(ArrayData::create(array('Label' => "Keywords: '{$search}'", 'RemoveLink' => HTTP::setGetVar('Keywords', null))));
         $properties = $properties->filter(array('Title:PartialMatch' => $search));
     }
     if ($arrival = $request->getVar('ArrivalDate')) {
         $arrivalStamp = strtotime($arrival);
         $nightAdder = '+' . $request->getVar('Nights') . ' days';
         $startDate = date('Y-m-d', $arrivalStamp);
         $endDate = date('Y-m-d', strtotime($nightAdder, $arrivalStamp));
         $properties = $properties->filter(array('AvailableStart:GreaterThanOrEqual' => $startDate, 'AvailableEnd:LessThanOrEqual' => $endDate));
     }
     if ($bedrooms = $request->getVar('Bedrooms')) {
         $filters->push(ArrayData::create(array('Label' => "{$bedrooms} bedrooms", 'RemoveLink' => HTTP::setGetVar('Bedrooms', null))));
         $properties = $properties->filter(array('Bedrooms:GreaterThanOrEqual' => $bedrooms));
     }
     if ($bathrooms = $request->getVar('Bathrooms')) {
         $filters->push(ArrayData::create(array('Label' => "{$bathrooms} bathrooms", 'RemoveLink' => HTTP::setGetVar('Bathrooms', null))));
         $properties = $properties->filter(array('Bathrooms:GreaterThanOrEqual' => $bathrooms));
     }
     if ($minPrice = $request->getVar('MinPrice')) {
         $filters->push(ArrayData::create(array('Label' => "Min. \${$minPrice}", 'RemoveLink' => HTTP::setGetVar('MinPrice', null))));
         $properties = $properties->filter(array('PricePerNight:GreaterThanOrEqual' => $minPrice));
     }
     if ($maxPrice = $request->getVar('MaxPrice')) {
         $filters->push(ArrayData::create(array('Label' => "Max. \${$maxPrice}", 'RemoveLink' => HTTP::setGetVar('MaxPrice', null))));
         $properties = $properties->filter(array('PricePerNight:LessThanOrEqual' => $maxPrice));
     }
     $paginatedProperties = PaginatedList::create($properties, $request)->setPageLength(15)->setPaginationGetVar('s');
     return array('Results' => $paginatedProperties, 'ActiveFilters' => $filters);
 }