Advertisement
Guest User

Mark

a guest
Aug 1st, 2010
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.85 KB | None | 0 0
  1. class DecidedCase extends DataObject {
  2.  
  3.     static $db = array(
  4.         'Type' => "Enum('Appeal,Complaint,Consent Order,High Court Judgement,Intermediate Merger,Interim Relief,Large Merger,Procedure')",
  5.         'Status' => "Enum('Undecided,Approved,Approved with Conditions,Declined')",
  6.         'Title' => 'Varchar',
  7.         'Number' => 'Varchar(64)',
  8.         'Applicant' => 'Text',
  9.         'Respondent' => 'Text',
  10.         'Rating' => 'Int(2)',
  11.         'Date' => 'Date',
  12.         'Time' => 'Time',
  13.         'Summary' => 'HTMLText',
  14.         'Keywords' => 'Text',
  15.         'Source' => 'Varchar'
  16.     );
  17.  
  18.     static $defaults = array(
  19.         "Status" => 'Undecided',
  20.     );
  21.  
  22.  
  23.     static $has_one = array(
  24.         'Document' => 'File',
  25.         'CaseHolder' => 'DecidedCaseHolder'
  26.     );
  27.  
  28.     static $searchable_fields = array(
  29.             'Number' => 'PartialMatchFilter',
  30.         'Date' => 'ExactMatchFilter',
  31.         'Title' => 'PartialMatchFilter',
  32.         'Type' => 'ExactMatchFilter',
  33.         'Status' => 'ExactMatchFilter',
  34.         'Applicant' => 'PartialMatchFilter',
  35.         'Respondent' => 'PartialMatchFilter',
  36.         'Summary' => 'PartialMatchFilter',
  37.         'Keywords' => 'PartialMatchFilter'
  38.     );
  39.  
  40.     static $summary_fields = array(
  41.             'Number',
  42.             'Date',
  43.         'Title',
  44.         'Applicant',
  45.         'Respondent',
  46.         'Type',
  47.         'Status',
  48.     );
  49.  
  50.     public static $default_sort = "Date DESC";
  51.  
  52.     static $extensions = array(
  53.         'SphinxSearchable'
  54.     );
  55.  
  56.     static $sphinx = array(
  57.         "mode" => "xmlpipe",
  58.         "external_content" => array("file_content" => array("DecidedCase", "getDocumentContent"))
  59.     );
  60.  
  61.     function getDocumentContent($caseID) {
  62.         $case = DataObject::get_by_id("DecidedCase", $caseID);
  63.         if (!$case || !$case->Document()) return "";
  64.         return $case->Document()->extractFileAsText();
  65.     }
  66.  
  67.     function Link(){
  68.         $Holder = $this->CaseHolder();
  69.         $Link = $Holder->Link() . 'cases/' . $Type=strtolower(str_replace( " ", "-", $this->Type)) . '/retrieve_case/' . $this->ID;
  70.         return $Link;
  71.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement