Ejemplo n.º 1
0
 public function deserialize($xml)
 {
     $extra = (string) $xml['extra_info'];
     if ($extra === '0') {
         echo "invalid extra info for Growth10K \n";
         return;
     }
     $class_name = 'class_' . str_replace('-', '_', strtolower($extra));
     //ENGLISH
     $current = $this->en->{$class_name} = new stdClass();
     $current->datatype = (string) $xml['Name'];
     $current->date_stamp = (string) $xml['as_of_date'];
     $mi = MerInception::get((string) $xml['fund_id'], $class_name);
     $current->inception_date = $mi['inception_date'];
     $current->mer = $mi['mer'];
     /**
     * the table elements for the GROWTH table
     */
     $current->labels['title'] = (string) $xml->matrix1->matrix1_QuarterEnd_Collection->matrix1_QuarterEnd->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2['textbox11'];
     $current->labels['fund'] = (string) $xml->matrix1->matrix1_QuarterEnd_Collection->matrix1_QuarterEnd->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2->matrix1_FundName_Collection->matrix1_FundName->{0}['FundName_2'];
     $current->labels['benchmark_0'] = (string) $xml->matrix1->matrix1_QuarterEnd_Collection->matrix1_QuarterEnd->{0}->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2->matrix1_FundName_Collection->matrix1_FundName->{1}['FundName_2'];
     //2nd benchmark
     $current->labels['benchmark_1'] = (string) $xml->matrix1->matrix1_QuarterEnd_Collection->matrix1_QuarterEnd->{0}->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2->matrix1_FundName_Collection->matrix1_FundName->{2}['FundName_2'];
     /**
      * loop through the table data
      */
     $y = $xml->matrix1->matrix1_QuarterEnd_Collection->matrix1_QuarterEnd;
     foreach ($y as $row) {
         $current->data[substr_replace((string) $row['QuarterEnd_2'], '', -9)]['fund'] = (string) $row->{0}->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2->matrix1_FundName_Collection->matrix1_FundName->{0}->Cell['ValueOfInvestment_1'];
         $current->data[substr_replace((string) $row['QuarterEnd_2'], '', -9)]['benchmark_0'] = (string) $row->{0}->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2->matrix1_FundName_Collection->matrix1_FundName->{1}->Cell['ValueOfInvestment_1'];
         //2nd benchmark
         $current->data[substr_replace((string) $row['QuarterEnd_2'], '', -9)]['benchmark_1'] = (string) $row->{0}->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2->matrix1_FundName_Collection->matrix1_FundName->{2}->Cell['ValueOfInvestment_1'];
     }
     //FRENCH
     $current = $this->fr->{$class_name} = new stdClass();
     $current->datatype = (string) $xml['Name'];
     $current->date_stamp = (string) $xml['as_of_date'];
     $mi = MerInception::get((string) $xml['fund_id'], $class_name);
     $current->inception_date = $mi['inception_date'];
     $current->mer = $mi['mer'];
     /**
     * the table elements for the GROWTH table
     */
     $current->labels['title'] = (string) $xml->matrix1->matrix1_QuarterEnd_Collection->matrix1_QuarterEnd->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2['textbox11'];
     $current->labels['fund'] = (string) $xml->matrix1->matrix1_QuarterEnd_Collection->matrix1_QuarterEnd->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2->matrix1_FundName_Collection->matrix1_FundName->{0}['FundName_2'];
     $current->labels['benchmark_0'] = (string) $xml->matrix1->matrix1_QuarterEnd_Collection->matrix1_QuarterEnd->{0}->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2->matrix1_FundName_Collection->matrix1_FundName->{1}['FundName_2'];
     //2nd benchmark
     $current->labels['benchmark_1'] = (string) $xml->matrix1->matrix1_QuarterEnd_Collection->matrix1_QuarterEnd->{0}->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2->matrix1_FundName_Collection->matrix1_FundName->{2}['FundName_2'];
     /**
      * loop through the table data
      */
     $y = $xml->matrix1->matrix1_QuarterEnd_Collection->matrix1_QuarterEnd;
     foreach ($y as $row) {
         $current->data[substr_replace((string) $row['QuarterEnd_2'], '', -9)]['fund'] = (string) $row->{0}->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2->matrix1_FundName_Collection->matrix1_FundName->{0}->Cell['ValueOfInvestment_1'];
         $current->data[substr_replace((string) $row['QuarterEnd_2'], '', -9)]['benchmark_0'] = (string) $row->{0}->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2->matrix1_FundName_Collection->matrix1_FundName->{1}->Cell['ValueOfInvestment_1'];
         //2nd benchmark
         $current->data[substr_replace((string) $row['QuarterEnd_2'], '', -9)]['benchmark_1'] = (string) $row->{0}->matrix1_ColumnGroup2_Collection->matrix1_ColumnGroup2->matrix1_FundName_Collection->matrix1_FundName->{2}->Cell['ValueOfInvestment_1'];
     }
 }
Ejemplo n.º 2
0
 public function deserialize($xml)
 {
     $extra = (string) $xml['extra_info'];
     if ($extra === '0') {
         echo "invalid extra info for Performance \n";
         return;
     }
     $class_name = 'class_' . str_replace('-', '_', strtolower($extra));
     // ENGLISH VERSION which is a duplicate of french - we need both of them for
     // the final filter
     $current = $this->en->{$class_name} = new stdClass();
     $current->name = (string) $xml['FundName'];
     $current->currency = (string) $xml['currency'];
     $current->class_label = (string) $xml->tblAP['textbox14'];
     $current->report_date = (string) $xml['as_of_date'];
     $mi = MerInception::get((string) $xml['fund_id'], $class_name);
     $current->inception_date = $mi['inception_date'];
     $current->mer = $mi['mer'];
     /**
     * the table elements for the ANNUAL PERFORMANCE table
     * may use some of these values if the xml ever gets valid info
     */
     // count the number of elements within the Detail Collection
     $details_ap = $xml->tblAP->Detail_Collection->Detail;
     $element_count_ap = count($details_ap);
     //create the label name for the funds: $current->annual_labels['label name here']
     $label_names = array('fund', 'benchmark0');
     if ($element_count_ap > 2) {
         $xx = $element_count_ap - 2;
         array_push($label_names, 'benchmark' . $xx);
     }
     $current->annual_labels['title'] = (string) $xml->tblAP_BCFB['textbox81'];
     //$current->annual_labels['title_2?'] = (string)$xml->tblCYP_BCFB['txtCYP_BCFB_FundName'];
     //$current->annual_labels['fund'] = (string)$xml->tblAP->Detail_Collection->Detail->{0}['AP_FundName'];
     //$current->annual_labels['benchmark'] = (string)$xml->tblAP->Detail_Collection->Detail->{1}['AP_FundName'];
     for ($xap = 0; $xap < $element_count_ap; $xap++) {
         $current->annual_labels[$label_names[$xap]] = (string) $xml->tblAP->Detail_Collection->Detail->{$xap}['AP_FundName'];
     }
     // loop through the ANNUAL PERFORMANCE table data
     $y = $xml->tblAP->Detail_Collection;
     $current->annual_data = array();
     foreach ($y as $row) {
         $current->annual_data['1_month'] = array();
         $current->annual_data['1_month']['label'] = '1-Mth';
         $current->annual_data['3_months'] = array();
         $current->annual_data['3_months']['label'] = '3-Mth';
         $current->annual_data['6_months'] = array();
         $current->annual_data['6_months']['label'] = '6-Mth';
         $current->annual_data['ytd'] = array();
         $current->annual_data['ytd']['label'] = 'YTD';
         $current->annual_data['1_year'] = array();
         $current->annual_data['1_year']['label'] = '1-Yr';
         $current->annual_data['3_year'] = array();
         $current->annual_data['3_year']['label'] = '3-Yr';
         $current->annual_data['5_year'] = array();
         $current->annual_data['5_year']['label'] = '5-Yr';
         $current->annual_data['7_year'] = array();
         $current->annual_data['7_year']['label'] = '7-Yr';
         $current->annual_data['10_year'] = array();
         $current->annual_data['10_year']['label'] = '10-Yr';
         $current->annual_data['since_inception'] = array();
         $current->annual_data['since_inception']['label'] = 'Since Incept.';
         for ($yap = 0; $yap < $element_count_ap; $yap++) {
             $current->annual_data['1_month'][$label_names[$yap]] = (string) $row->Detail->{$yap}['AP_1Month'];
             $current->annual_data['3_months'][$label_names[$yap]] = (string) $row->Detail->{$yap}['AP_3Months'];
             $current->annual_data['6_months'][$label_names[$yap]] = (string) $row->Detail->{$yap}['AP_6Months'];
             $current->annual_data['ytd'][$label_names[$yap]] = (string) $row->Detail->{$yap}['AP_YTD'];
             $current->annual_data['1_year'][$label_names[$yap]] = (string) $row->Detail->{$yap}['AP_1Year'];
             $current->annual_data['3_year'][$label_names[$yap]] = (string) $row->Detail->{$yap}['AP_3Years'];
             $current->annual_data['5_year'][$label_names[$yap]] = (string) $row->Detail->{$yap}['AP_5Years'];
             $current->annual_data['7_year'][$label_names[$yap]] = (string) $row->Detail->{$yap}['AP_7Years'];
             $current->annual_data['10_year'][$label_names[$yap]] = (string) $row->Detail->{$yap}['AP_10Years'];
             $current->annual_data['since_inception'][$label_names[$yap]] = (string) $row->Detail->{$yap}['AP_SinceInception'];
         }
         /*
         $current->annual_data['3_months']['fund'] = (string)$row->Detail->{0}['AP_3Months'];
         $current->annual_data['3_months']['benchmark'] = (string)$row->Detail->{1}['AP_3Months'];
         
         
         $current->annual_data['6_months']['fund'] = (string)$row->Detail->{0}['AP_6Months'];
         $current->annual_data['6_months']['benchmark'] = (string)$row->Detail->{1}['AP_6Months'];
         
         
         
         $current->annual_data['ytd']['fund'] = (string)$row->Detail->{0}['AP_YTD'];
         $current->annual_data['ytd']['benchmark'] = (string)$row->Detail->{1}['AP_YTD'];
         
         
         
         $current->annual_data['1_year']['fund'] = (string)$row->Detail->{0}['AP_1Year'];
         $current->annual_data['1_year']['benchmark'] = (string)$row->Detail->{1}['AP_1Year'];
         $current->annual_data['1_year']['benchmark2'] = (string)$row->Detail->{2}['AP_1Year'];
         
         $current->annual_data['3_year']['fund'] = (string)$row->Detail->{0}['AP_3Years'];
         $current->annual_data['3_year']['benchmark'] = (string)$row->Detail->{1}['AP_3Years'];
         
         $current->annual_data['5_year']['fund'] = (string)$row->Detail->{0}['AP_5Years'];
         $current->annual_data['5_year']['benchmark'] = (string)$row->Detail->{1}['AP_5Years'];
         
         $current->annual_data['7_year']['fund'] = (string)$row->Detail->{0}['AP_7Years'];
         $current->annual_data['7_year']['benchmark'] = (string)$row->Detail->{1}['AP_7Years'];
         
         $current->annual_data['10_year']['fund'] = (string)$row->Detail->{0}['AP_10Years'];
         $current->annual_data['10_year']['benchmark'] = (string)$row->Detail->{1}['AP_10Years'];
         
         
         $current->annual_data['since_inception']['fund'] = (string)$row->Detail->{0}['AP_SinceInception'];
         $current->annual_data['since_inception']['benchmark'] = (string)$row->Detail->{1}['AP_SinceInception'];
         
         if ($element_count_ap >= 3) {
         	$current->annual_data['3_months']['benchmark2'] = (string)$row->Detail->{2}['AP_3Months'];
         	$current->annual_data['6_months']['benchmark2'] = (string)$row->Detail->{2}['AP_6Months'];
         	$current->annual_data['ytd']['benchmark2'] = (string)$row->Detail->{2}['AP_YTD'];
         	$current->annual_data['3_year']['benchmark2'] = (string)$row->Detail->{2}['AP_3Years'];
         	$current->annual_data['5_year']['benchmark2'] = (string)$row->Detail->{2}['AP_5Years'];
         	$current->annual_data['7_year']['benchmark2'] = (string)$row->Detail->{2}['AP_7Years'];
         	$current->annual_data['10_year']['benchmark2'] = (string)$row->Detail->{2}['AP_10Years'];
         	$current->annual_data['since_inception']['benchmark2'] = (string)$row->Detail->{2}['AP_SinceInception'];
         }
         */
     }
     /**
     * the table elements for the CALENDAR YEAR PERFORMANCE table
     */
     // count the number of elements within the Detail Collection
     $details_cp = $xml->tblCYP->Detail_Collection->Detail;
     $element_count_cp = count($details_cp);
     //create the label name for the funds: $current->annual_labels['label name here']
     $label_names_cp = array('fund', 'benchmark0');
     if ($element_count_cp > 2) {
         $yy = $element_count_cp - 2;
         array_push($label_names_cp, 'benchmark' . $yy);
     }
     $current->calendar_labels['title'] = (string) $xml->tblCYP['textbox1'];
     $current->calendar_labels['footnote'] = (string) $xml->tblCYP['CYP_footer'];
     /*
                 $current->calendar_labels['fund'] = (string)$xml->tblCYP->Detail_Collection->Detail->{0}['CYP_FundName'];
                 $current->calendar_labels['benchmark'] = (string)$xml->tblCYP->Detail_Collection->Detail->{1}['CYP_FundName'];
     */
     for ($xcp = 0; $xcp < $element_count_cp; $xcp++) {
         $current->calendar_labels[$label_names_cp[$xcp]] = (string) $xml->tblCYP->Detail_Collection->Detail->{$xcp}['CYP_FundName'];
     }
     //loop through the CALENDAR YEAR PERFORMANCE table data
     $y = $xml->tblCYP->Detail_Collection;
     $current->calendar_data = array();
     foreach ($y as $row) {
         $current->calendar_data['1_year'] = array();
         $current->calendar_data['1_year']['label'] = (string) $xml->tblCYP['textbox181'];
         $current->calendar_data['2_year'] = array();
         $current->calendar_data['2_year']['label'] = (string) $xml->tblCYP['textbox135'];
         $current->calendar_data['3_year'] = array();
         $current->calendar_data['3_year']['label'] = (string) $xml->tblCYP['textbox106'];
         $current->calendar_data['4_year'] = array();
         $current->calendar_data['4_year']['label'] = (string) $xml->tblCYP['textbox275'];
         $current->calendar_data['5_year'] = array();
         $current->calendar_data['5_year']['label'] = (string) $xml->tblCYP['textbox268'];
         $current->calendar_data['6_year'] = array();
         $current->calendar_data['6_year']['label'] = (string) $xml->tblCYP['textbox244'];
         $current->calendar_data['7_year'] = array();
         $current->calendar_data['7_year']['label'] = (string) $xml->tblCYP['textbox245'];
         $current->calendar_data['8_year'] = array();
         $current->calendar_data['8_year']['label'] = (string) $xml->tblCYP['textbox246'];
         $current->calendar_data['9_year'] = array();
         $current->calendar_data['9_year']['label'] = (string) $xml->tblCYP['textbox247'];
         $current->calendar_data['10_year'] = array();
         $current->calendar_data['10_year']['label'] = (string) $xml->tblCYP['textbox248'];
         for ($ycp = 0; $ycp < $element_count_cp; $ycp++) {
             $current->calendar_data['1_year'][$label_names_cp[$ycp]] = (string) $row->Detail->{$ycp}['CYP_Year1'];
             $current->calendar_data['2_year'][$label_names_cp[$ycp]] = (string) $row->Detail->{$ycp}['CYP_Year2'];
             $current->calendar_data['3_year'][$label_names_cp[$ycp]] = (string) $row->Detail->{$ycp}['CYP_Year3'];
             $current->calendar_data['4_year'][$label_names_cp[$ycp]] = (string) $row->Detail->{$ycp}['CYP_Year4'];
             $current->calendar_data['5_year'][$label_names_cp[$ycp]] = (string) $row->Detail->{$ycp}['CYP_Year5'];
             $current->calendar_data['6_year'][$label_names_cp[$ycp]] = (string) $row->Detail->{$ycp}['CYP_Year6'];
             $current->calendar_data['7_year'][$label_names_cp[$ycp]] = (string) $row->Detail->{$ycp}['CYP_Year7'];
             $current->calendar_data['8_year'][$label_names_cp[$ycp]] = (string) $row->Detail->{$ycp}['CYP_Year8'];
             $current->calendar_data['9_year'][$label_names_cp[$ycp]] = (string) $row->Detail->{$ycp}['CYP_Year9'];
             $current->calendar_data['10_year'][$label_names_cp[$ycp]] = (string) $row->Detail->{$ycp}['CYP_Year10'];
         }
         /*
                         
                         $current->calendar_data['1_year']['fund'] = (string)$row->Detail->{0}['CYP_Year1'];
                         $current->calendar_data['1_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year1'];
         
                        
                         $current->calendar_data['2_year']['fund'] = (string)$row->Detail->{0}['CYP_Year2'];
                         $current->calendar_data['2_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year2'];
         
                        
                         $current->calendar_data['3_year']['fund'] = (string)$row->Detail->{0}['CYP_Year3'];
                         $current->calendar_data['3_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year3'];
         
                         
                         $current->calendar_data['4_year']['fund'] = (string)$row->Detail->{0}['CYP_Year4'];
                         $current->calendar_data['4_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year4'];
         
                         
                         $current->calendar_data['5_year']['fund'] = (string)$row->Detail->{0}['CYP_Year5'];
                         $current->calendar_data['5_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year5'];
         
                         
                         $current->calendar_data['6_year']['fund'] = (string)$row->Detail->{0}['CYP_Year6'];
                         $current->calendar_data['6_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year6'];
         
                         
                         $current->calendar_data['7_year']['fund'] = (string)$row->Detail->{0}['CYP_Year7'];
                         $current->calendar_data['7_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year7'];
         
                         
                         $current->calendar_data['8_year']['fund'] = (string)$row->Detail->{0}['CYP_Year8'];
                         $current->calendar_data['8_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year8'];
         
                         
                         $current->calendar_data['9_year']['fund'] = (string)$row->Detail->{0}['CYP_Year9'];
                         $current->calendar_data['9_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year9'];
         
                         
                         $current->calendar_data['10_year']['fund'] = (string)$row->Detail->{0}['CYP_Year10'];
                         $current->calendar_data['10_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year10'];
         */
     }
     // FRENCH VERSION - a duplicate of english which we need for the final filter
     $current = $this->fr->{$class_name} = new stdClass();
     $current->name = (string) $xml['FundName'];
     $current->currency = (string) $xml['currency'];
     $current->class_label = (string) $xml->tblAP['textbox14'];
     $current->report_date = (string) $xml['as_of_date'];
     $mi = MerInception::get((string) $xml['fund_id'], $class_name);
     $current->inception_date = $mi['inception_date'];
     $current->mer = $mi['mer'];
     /**
     * the table elements for the ANNUAL PERFORMANCE table
     * may use some of these values if the xml ever gets valid info
     */
     // count the number of elements within the Detail Collection
     $details_ap_fr = $xml->tblAP->Detail_Collection->Detail;
     $element_count_ap_fr = count($details_ap_fr);
     //create the label name for the funds: $current->annual_labels['label name here']
     $label_names_fr = array('fund', 'benchmark0');
     if ($element_count_ap_fr > 2) {
         $xx_fr = $element_count_ap_fr - 2;
         array_push($label_names_fr, 'benchmark' . $xx_fr);
     }
     $current->annual_labels['title'] = (string) $xml->tblAP_BCFB['textbox81'];
     //$current->annual_labels['title_2?'] = (string)$xml->tblCYP_BCFB['txtCYP_BCFB_FundName'];
     /*
     $current->annual_labels['fund'] = (string)$xml->tblAP->Detail_Collection->Detail->{0}['AP_FundName'];
     $current->annual_labels['benchmark'] = (string)$xml->tblAP->Detail_Collection->Detail->{1}['AP_FundName'];
     */
     for ($xap_fr = 0; $xap_fr < $element_count_ap_fr; $xap_fr++) {
         $current->annual_labels[$label_names_fr[$xap_fr]] = (string) $xml->tblAP->Detail_Collection->Detail->{$xap_fr}['AP_FundName'];
     }
     // loop through the ANNUAL PERFORMANCE table data
     $y = $xml->tblAP->Detail_Collection;
     $current->annual_data = array();
     foreach ($y as $row) {
         $current->annual_data['1_month'] = array();
         $current->annual_data['1_month']['label'] = '1-Mth';
         $current->annual_data['3_months'] = array();
         $current->annual_data['3_months']['label'] = '3-Mth';
         $current->annual_data['6_months'] = array();
         $current->annual_data['6_months']['label'] = '6-Mth';
         $current->annual_data['ytd'] = array();
         $current->annual_data['ytd']['label'] = 'YTD';
         $current->annual_data['1_year'] = array();
         $current->annual_data['1_year']['label'] = '1-Yr';
         $current->annual_data['3_year'] = array();
         $current->annual_data['3_year']['label'] = '3-Yr';
         $current->annual_data['5_year'] = array();
         $current->annual_data['5_year']['label'] = '5-Yr';
         $current->annual_data['7_year'] = array();
         $current->annual_data['7_year']['label'] = '7-Yr';
         $current->annual_data['10_year'] = array();
         $current->annual_data['10_year']['label'] = '10-Yr';
         $current->annual_data['since_inception'] = array();
         $current->annual_data['since_inception']['label'] = 'Since Incept.';
         for ($yap_fr = 0; $yap_fr < $element_count_ap_fr; $yap_fr++) {
             $current->annual_data['1_month'][$label_names_fr[$yap_fr]] = (string) $row->Detail->{$yap_fr}['AP_1Month'];
             $current->annual_data['3_months'][$label_names_fr[$yap_fr]] = (string) $row->Detail->{$yap_fr}['AP_3Months'];
             $current->annual_data['6_months'][$label_names_fr[$yap_fr]] = (string) $row->Detail->{$yap_fr}['AP_6Months'];
             $current->annual_data['ytd'][$label_names_fr[$yap_fr]] = (string) $row->Detail->{$yap_fr}['AP_YTD'];
             $current->annual_data['1_year'][$label_names_fr[$yap_fr]] = (string) $row->Detail->{$yap_fr}['AP_1Year'];
             $current->annual_data['3_year'][$label_names_fr[$yap_fr]] = (string) $row->Detail->{$yap_fr}['AP_3Years'];
             $current->annual_data['5_year'][$label_names_fr[$yap_fr]] = (string) $row->Detail->{$yap_fr}['AP_5Years'];
             $current->annual_data['7_year'][$label_names_fr[$yap_fr]] = (string) $row->Detail->{$yap_fr}['AP_7Years'];
             $current->annual_data['10_year'][$label_names_fr[$yap_fr]] = (string) $row->Detail->{$yap_fr}['AP_10Years'];
             $current->annual_data['since_inception'][$label_names_fr[$yap_fr]] = (string) $row->Detail->{$yap_fr}['AP_SinceInception'];
         }
         /*
         $current->annual_data['3_months'] = array();
         $current->annual_data['3_months']['label'] = '3-mois';
         $current->annual_data['3_months']['fund'] = (string)$row->Detail->{0}['AP_3Months'];
         $current->annual_data['3_months']['benchmark'] = (string)$row->Detail->{1}['AP_3Months'];
         
         $current->annual_data['6_months'] = array();
         $current->annual_data['6_months']['label'] = '6-mois';
         $current->annual_data['6_months']['fund'] = (string)$row->Detail->{0}['AP_6Months'];
         $current->annual_data['6_months']['benchmark'] = (string)$row->Detail->{1}['AP_6Months'];
         
         
         $current->annual_data['ytd'] = array();
         $current->annual_data['ytd']['label'] = 'YTD';
         $current->annual_data['ytd']['fund'] = (string)$row->Detail->{0}['AP_YTD'];
         $current->annual_data['ytd']['benchmark'] = (string)$row->Detail->{1}['AP_YTD'];
         
         
         $current->annual_data['1_year'] = array();
         $current->annual_data['1_year']['label'] = '1-Yr';
         $current->annual_data['1_year']['fund'] = (string)$row->Detail->{0}['AP_1Year'];
         $current->annual_data['1_year']['benchmark'] = (string)$row->Detail->{1}['AP_1Year'];
         $current->annual_data['3_year'] = array();
         $current->annual_data['3_year']['label'] = '3-Yr';
         $current->annual_data['3_year']['fund'] = (string)$row->Detail->{0}['AP_3Years'];
         $current->annual_data['3_year']['benchmark'] = (string)$row->Detail->{1}['AP_3Years'];
         $current->annual_data['5_year'] = array();
         $current->annual_data['5_year']['label'] = '5-Yr';
         $current->annual_data['5_year']['fund'] = (string)$row->Detail->{0}['AP_5Years'];
         $current->annual_data['5_year']['benchmark'] = (string)$row->Detail->{1}['AP_5Years'];
         $current->annual_data['7_year'] = array();
         $current->annual_data['7_year']['label'] = '7-Yr';
         $current->annual_data['7_year']['fund'] = (string)$row->Detail->{0}['AP_7Years'];
         $current->annual_data['7_year']['benchmark'] = (string)$row->Detail->{1}['AP_7Years'];
         $current->annual_data['10_year'] = array();
         $current->annual_data['10_year']['label'] = '10-Yr';
         $current->annual_data['10_year']['fund'] = (string)$row->Detail->{0}['AP_10Years'];
         $current->annual_data['10_year']['benchmark'] = (string)$row->Detail->{1}['AP_10Years'];
         
         $current->annual_data['since_inception'] = array();
         $current->annual_data['since_inception']['label'] = 'Since Incept.';
         $current->annual_data['since_inception']['fund'] = (string)$row->Detail->{0}['AP_SinceInception'];
         $current->annual_data['since_inception']['benchmark'] = (string)$row->Detail->{1}['AP_SinceInception'];
         */
     }
     /**
     * the table elements for the CALENDAR YEAR PERFORMANCE table
     */
     // count the number of elements within the Detail Collection
     $details_cp_fr = $xml->tblCYP->Detail_Collection->Detail;
     $element_count_cp_fr = count($details_cp_fr);
     //create the label name for the funds: $current->annual_labels['label name here']
     $label_names_cp_fr = array('fund', 'benchmark0');
     if ($element_count_cp_fr > 2) {
         $yy_fr = $element_count_cp_fr - 2;
         array_push($label_names_cp_fr, 'benchmark' . $yy_fr);
     }
     $current->calendar_labels['title'] = (string) $xml->tblCYP['textbox1'];
     $current->calendar_labels['footnote'] = (string) $xml->tblCYP['CYP_footer'];
     /*
                 $current->calendar_labels['fund'] = (string)$xml->tblCYP->Detail_Collection->Detail->{0}['CYP_FundName'];
                 $current->calendar_labels['benchmark'] = (string)$xml->tblCYP->Detail_Collection->Detail->{1}['CYP_FundName'];
     */
     for ($xcp_fr = 0; $xcp_fr < $element_count_cp_fr; $xcp_fr++) {
         $current->calendar_labels[$label_names_cp_fr[$xcp_fr]] = (string) $xml->tblCYP->Detail_Collection->Detail->{$xcp_fr}['CYP_FundName'];
         echo 'current=' . $current->calendar_labels[$label_names_cp_fr[$xcp_fr]];
     }
     //loop through the CALENDAR YEAR PERFORMANCE table data
     $y = $xml->tblCYP->Detail_Collection;
     $current->calendar_data = array();
     foreach ($y as $row) {
         $current->calendar_data['1_year'] = array();
         $current->calendar_data['1_year']['label'] = (string) $xml->tblCYP['textbox181'];
         $current->calendar_data['2_year'] = array();
         $current->calendar_data['2_year']['label'] = (string) $xml->tblCYP['textbox135'];
         $current->calendar_data['3_year'] = array();
         $current->calendar_data['3_year']['label'] = (string) $xml->tblCYP['textbox106'];
         $current->calendar_data['4_year'] = array();
         $current->calendar_data['4_year']['label'] = (string) $xml->tblCYP['textbox275'];
         $current->calendar_data['5_year'] = array();
         $current->calendar_data['5_year']['label'] = (string) $xml->tblCYP['textbox268'];
         $current->calendar_data['6_year'] = array();
         $current->calendar_data['6_year']['label'] = (string) $xml->tblCYP['textbox244'];
         $current->calendar_data['7_year'] = array();
         $current->calendar_data['7_year']['label'] = (string) $xml->tblCYP['textbox245'];
         $current->calendar_data['8_year'] = array();
         $current->calendar_data['8_year']['label'] = (string) $xml->tblCYP['textbox246'];
         $current->calendar_data['9_year'] = array();
         $current->calendar_data['9_year']['label'] = (string) $xml->tblCYP['textbox247'];
         $current->calendar_data['10_year'] = array();
         $current->calendar_data['10_year']['label'] = (string) $xml->tblCYP['textbox248'];
         for ($ycp_fr = 0; $ycp_fr < $element_count_cp_fr; $ycp_fr++) {
             $current->calendar_data['1_year'][$label_names_cp_fr[$ycp_fr]] = (string) $row->Detail->{$ycp_fr}['CYP_Year1'];
             $current->calendar_data['2_year'][$label_names_cp_fr[$ycp_fr]] = (string) $row->Detail->{$ycp_fr}['CYP_Year2'];
             $current->calendar_data['3_year'][$label_names_cp_fr[$ycp_fr]] = (string) $row->Detail->{$ycp_fr}['CYP_Year3'];
             $current->calendar_data['4_year'][$label_names_cp_fr[$ycp_fr]] = (string) $row->Detail->{$ycp_fr}['CYP_Year4'];
             $current->calendar_data['5_year'][$label_names_cp_fr[$ycp_fr]] = (string) $row->Detail->{$ycp_fr}['CYP_Year5'];
             $current->calendar_data['6_year'][$label_names_cp_fr[$ycp_fr]] = (string) $row->Detail->{$ycp_fr}['CYP_Year6'];
             $current->calendar_data['7_year'][$label_names_cp_fr[$ycp_fr]] = (string) $row->Detail->{$ycp_fr}['CYP_Year7'];
             $current->calendar_data['8_year'][$label_names_cp_fr[$ycp_fr]] = (string) $row->Detail->{$ycp_fr}['CYP_Year8'];
             $current->calendar_data['9_year'][$label_names_cp_fr[$ycp_fr]] = (string) $row->Detail->{$ycp_fr}['CYP_Year9'];
             $current->calendar_data['10_year'][$label_names_cp_fr[$ycp_fr]] = (string) $row->Detail->{$ycp_fr}['CYP_Year10'];
         }
         /*
                         $current->calendar_data['1_year'] = array();
                         $current->calendar_data['1_year']['label'] = (string)$xml->tblCYP['textbox181'];
                         $current->calendar_data['1_year']['fund'] = (string)$row->Detail->{0}['CYP_Year1'];
                         $current->calendar_data['1_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year1'];
         
                         $current->calendar_data['2_year'] = array();
                         $current->calendar_data['2_year']['label'] = (string)$xml->tblCYP['textbox135'];
                         $current->calendar_data['2_year']['fund'] = (string)$row->Detail->{0}['CYP_Year2'];
                         $current->calendar_data['2_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year2'];
         
                         $current->calendar_data['3_year'] = array();
                         $current->calendar_data['3_year']['label'] = (string)$xml->tblCYP['textbox106'];
                         $current->calendar_data['3_year']['fund'] = (string)$row->Detail->{0}['CYP_Year3'];
                         $current->calendar_data['3_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year3'];
         
                         $current->calendar_data['4_year'] = array();
                         $current->calendar_data['4_year']['label'] = (string)$xml->tblCYP['textbox275'];
                         $current->calendar_data['4_year']['fund'] = (string)$row->Detail->{0}['CYP_Year4'];
                         $current->calendar_data['4_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year4'];
         
                         $current->calendar_data['5_year'] = array();
                         $current->calendar_data['5_year']['label'] = (string)$xml->tblCYP['textbox268'];
                         $current->calendar_data['5_year']['fund'] = (string)$row->Detail->{0}['CYP_Year5'];
                         $current->calendar_data['5_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year5'];
         
                         $current->calendar_data['6_year'] = array();
                         $current->calendar_data['6_year']['label'] =  (string)$xml->tblCYP['textbox244'];
                         $current->calendar_data['6_year']['fund'] = (string)$row->Detail->{0}['CYP_Year6'];
                         $current->calendar_data['6_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year6'];
         
                         $current->calendar_data['7_year'] = array();
                         $current->calendar_data['7_year']['label'] = (string)$xml->tblCYP['textbox245'];
                         $current->calendar_data['7_year']['fund'] = (string)$row->Detail->{0}['CYP_Year7'];
                         $current->calendar_data['7_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year7'];
         
                         $current->calendar_data['8_year'] = array();
                         $current->calendar_data['8_year']['label'] = (string)$xml->tblCYP['textbox246'];
                         $current->calendar_data['8_year']['fund'] = (string)$row->Detail->{0}['CYP_Year8'];
                         $current->calendar_data['8_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year8'];
         
                         $current->calendar_data['9_year'] = array();
                         $current->calendar_data['9_year']['label'] = (string)$xml->tblCYP['textbox247'];
                         $current->calendar_data['9_year']['fund'] = (string)$row->Detail->{0}['CYP_Year9'];
                         $current->calendar_data['9_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year9'];
         
                         $current->calendar_data['10_year'] = array();
                         $current->calendar_data['10_year']['label'] = (string)$xml->tblCYP['textbox248'];
                         $current->calendar_data['10_year']['fund'] = (string)$row->Detail->{0}['CYP_Year10'];
                         $current->calendar_data['10_year']['benchmark'] = (string)$row->Detail->{1}['CYP_Year10'];
         */
     }
 }
Ejemplo n.º 3
0
 /**
  *  here we do most of the work of loading the files, instantiating the funds,
  *  deserializing their components
  */
 function __construct($path)
 {
     // make path safe for concatenation
     if (substr($path, -1) !== '/') {
         $path = $path . '/';
     }
     $files = scandir($path . '/monthly/');
     //~ var_dump($files);
     echo count($files) . ' Files in Directory' . "<hr>";
     MerInception::load_from_file($path);
     foreach ($files as $filename) {
         // ignore files that don't match the pattern:  DATATYPE - ID.xml
         // for now ignoring classes - will need to add that in later subroutine
         // only care for XML files
         if (!preg_match('/([^.]+)\\.xml/', $filename, $m)) {
             continue;
         }
         $parts = explode('-', $m[1]);
         // only care for filenames w/ at least datatype and id
         //~ print_r( $parts );
         $n = count($parts);
         if ($n < 2) {
             continue;
         }
         $datatype = strtolower(trim($parts[0]));
         $id = trim($parts[$n - 1]);
         $extra = $n == 2 ? 0 : implode('-', array_slice($parts, 1, $n - 2));
         $lang = '_en';
         //echo "$datatype -- $id \n";
         //~ echo "$filename \n";
         if (!$this->validate_id($id)) {
             echo "Unrecognized ID: {$id}. \n";
             continue;
         }
         if (!$this->validate_datatype($datatype)) {
             echo "Unrecognized datatype: {$datatype}. \n";
             continue;
         }
         // get the xml contents of the files
         $file_contents = file_get_contents($path . '/monthly/' . $filename);
         $file_contents = str_replace(array("\n", "\r", "\t"), '', $file_contents);
         // $file_contents = trim(str_replace( '"', "'", $file_contents));
         //~ print_r( $file_contents );
         libxml_use_internal_errors(true);
         $simpleXML = simplexml_load_string($file_contents);
         $simpleXML['fund_id'] = $id;
         $simpleXML['extra_info'] = $extra;
         //~ print_r( $simpleXML );
         // get known fund by ID or create a new one
         if (array_key_exists($id, $this->items)) {
             $fund = $this->items[$id];
         } else {
             $fund = new Fund($id);
             $this->items[$id] = $fund;
         }
         // get fund_component
         $component_info = $this->fund_components[$datatype];
         // this test not required if all the fund_components class_name are defined
         if ($component_info['class_name']) {
             // instantiate or find the component in the fund
             extract($component_info);
             if (array_key_exists($output_key, $fund->components)) {
                 $fund_component = $fund->components[$output_key];
             } else {
                 $fund->components[$output_key] = $fund_component = new $class_name();
             }
             // parse the data
             $fund_component->deserialize($simpleXML);
         }
     }
 }