/**
  * Returns an array with 2 elements, one with a list of Page on the site (and all subsites if
  * applicable) and another with files.
  *
  * @return array
  */
 public function sourceRecords()
 {
     if (class_exists('Subsite') && Subsite::get()->count() > 0) {
         $origMode = Versioned::get_reading_mode();
         Versioned::set_reading_mode('Stage.Stage');
         $items = array('Pages' => Subsite::get_from_all_subsites('SiteTree'), 'Files' => Subsite::get_from_all_subsites('File'));
         Versioned::set_reading_mode($origMode);
         return $items;
     } else {
         return array('Pages' => Versioned::get_by_stage('SiteTree', 'Stage'), 'Files' => File::get());
     }
 }
 public function parameterFields()
 {
     $fields = new FieldList();
     if (class_exists("Subsite")) {
         $first_order = Subsite::get_from_all_subsites("Order")->sort('Created', 'ASC')->first();
     } else {
         $first_order = Order::get()->sort('Created', 'ASC')->first();
     }
     // Check if any order exist
     if ($first_order) {
         // List all months
         $months = array('All');
         for ($i = 1; $i <= 12; $i++) {
             $months[] = date("F", mktime(0, 0, 0, $i + 1, 0, 0));
         }
         // Get the first order, then count down from current year to that
         $firstyear = new SS_Datetime('FirstDate');
         $firstyear->setValue($first_order->Created);
         $years = array();
         for ($i = date('Y'); $i >= $firstyear->Year(); $i--) {
             $years[$i] = $i;
         }
         // Order Status
         $statuses = Order::config()->statuses;
         array_unshift($statuses, 'All');
         $fields->push(TextField::create('Filter_FirstName', 'Customer First Name'));
         $fields->push(TextField::create('Filter_Surname', 'Customer Surname'));
         $fields->push(TextField::create('Filter_StockID', 'Stock ID'));
         $fields->push(TextField::create('Filter_ProductName', 'Product Name'));
         $fields->push(DropdownField::create('Filter_Month', 'Month', $months));
         $fields->push(DropdownField::create('Filter_Year', 'Year', $years));
         $fields->push(DropdownField::create('Filter_Status', 'Order Status', $statuses));
     }
     return $fields;
 }
Exemple #3
0
 /**
  * Return all virtual pages that link to this page
  */
 function VirtualPages()
 {
     if (!$this->ID) {
         return null;
     }
     if (class_exists('Subsite')) {
         return Subsite::get_from_all_subsites('VirtualPage', "\"CopyContentFromID\" = " . (int) $this->ID);
     } else {
         return DataObject::get('VirtualPage', "\"CopyContentFromID\" = " . (int) $this->ID);
     }
 }
 /**
  * Return all virtual pages that link to this page.
  *
  * @return DataList
  */
 public function VirtualPages()
 {
     // Ignore new records
     if (!$this->ID) {
         return null;
     }
     // Check subsite virtual pages
     // @todo Refactor out subsite module specific code
     if (class_exists('Subsite')) {
         return Subsite::get_from_all_subsites('VirtualPage', array('"VirtualPage"."CopyContentFromID"' => $this->ID));
     }
     // Check existing virtualpages
     if (class_exists('VirtualPage')) {
         return VirtualPage::get()->where(array('"VirtualPage"."CopyContentFromID"' => $this->ID));
     }
     return null;
 }