00001 <?php
00002
00011 class SDRAlignmentList extends SXMLModel {
00012 private static $ATTRIBUTES = array(
00013 'standards' => array('array' => true, 'type' => 'SDRAlignmentObj'),
00014 'textbooks' => array('array' => true, 'type' => 'SDRAlignmentObj'),
00015 'dictionary' => array('array' => true, 'type' => 'SDRAlignmentObj'),
00016 'alignments' => array('array' => true, 'type' => 'SDRAlignmentObj'),
00017 'count' => array('array' => true, 'edit' => false)
00018 );
00019
00028 public function __construct($xml = null) {
00029 parent::__construct();
00030
00031 $this->registerAttributes(self::$ATTRIBUTES);
00032 $this->registerNodeName('alignments');
00033
00034 if($xml)
00035 $this->setXML($xml);
00036 }
00037
00046 protected function setXMLImpl($xml) {
00047 $alignments = array();
00048 $standards = array();
00049 $textbooks = array();
00050 $dictionary = array();
00051
00052 if(!SDRSearchService::$WITH_ANCESTRY) {
00053 $alXML = $xml->xpath('//objective/alignment');
00054 foreach($alXML as $al) {
00055 $obj = new SDRAlignmentObj($al->asXML());
00056 $alignments[] = $obj;
00057 $standards[] = $obj;
00058 }
00059 $alXML = $xml->xpath('//section/alignment');
00060 foreach($alXML as $al) {
00061 $obj = new SDRAlignmentObj($al->asXML());
00062 $alignments[] = $obj;
00063 $standards[] = $obj;
00064 }
00065 $alXML = $xml->xpath('//word/alignment');
00066 foreach($alXML as $al) {
00067 $obj = new SDRAlignmentObj($al->asXML());
00068 $alignments[] = $obj;
00069 $standards[] = $obj;
00070 }
00071 }
00072 else {
00073 foreach($xml->children() as $child) {
00074 switch($child->getName()) {
00075 case 'resourceId':
00076 break;
00077 case 'organization':
00078 $this->processOrganization($child, $alignments, $standards);
00079 break;
00080 case 'book':
00081 $this->processBook($child, $alignments, $textbooks);
00082 break;
00083 case 'word':
00084 $this->processWord($child, $alignments, $dictionary);
00085 break;
00086 }
00087 }
00088 }
00089
00090 $this->standards = $standards;
00091 $this->textbooks = $textbooks;
00092 $this->dictionary = $dictionary;
00093 $this->alignments = $alignments;
00094
00095 return true;
00096 }
00097
00108 private function processOrganization($org, &$alignments, &$standards) {
00109 $ancestry = array();
00110
00111 $ancestry['organizationId'] = $org->id;
00112 $ancestry['organizationName'] = $org->name;
00113
00114 foreach($org->grade as $grade) {
00115 $ancestry['gradeId'] = $grade->id;
00116 $ancestry['gradeName'] = $grade->name;
00117 foreach($grade->category as $cat) {
00118 $ancestry['categoryId'] = $cat->id;
00119 $ancestry['categoryName'] = $cat->name;
00120 foreach($cat->objective as $obj) {
00121 $ancestry['objectiveId'] = $obj->id;
00122 $ancestry['objectiveName'] = $obj->name;
00123 foreach($obj->alignment as $al) {
00124 $ancObj = new SDRAlignmentAncestryObj();
00125 $ancObj->setValues($ancestry);
00126 $alignObj = new SDRAlignmentObj($al->asXML(), $ancObj);
00127 $alignments[] = $alignObj;
00128 $standards[] = $alignObj;
00129 }
00130 }
00131 }
00132 }
00133 }
00134
00145 private function processBook($book, &$alignments, &$textbooks) {
00146 $ancestry = array();
00147
00148 $ancestry['bookId'] = $book->id;
00149 $ancestry['bookTitle'] = $book->title;
00150
00151 foreach($book->chapter as $chapter) {
00152 $ancestry['chapterId'] = $chapter->id;
00153 $ancestry['chapterName'] = $chapter->name;
00154 foreach($chapter->section as $section) {
00155 $ancestry['sectionId'] = $section->id;
00156 $ancestry['sectionName'] = $section->name;
00157 foreach($section->alignment as $al) {
00158 $ancObj = new SDRAlignmentAncestryObj();
00159 $ancObj->setValues($ancestry);
00160 $alignObj = new SDRAlignmentObj($al->asXML(), $ancObj);
00161 $alignments[] = $alignObj;
00162 $textbooks[] = $alignObj;
00163 }
00164 }
00165 }
00166 }
00167
00178 private function processWord($word, &$alignments, &$dictionary) {
00179 foreach($word->alignment as $al) {
00180 $ancObj = new SDRAlignmentAncestryObj();
00181 $ancObj->word = $word->word;
00182 $ancObj->definition = $word->definition;
00183 $obj = new SDRAlignmentObj($al->asXML(), $ancObj);
00184 $alignments[] = $obj;
00185 $dictionary[] = $obj;
00186 }
00187 }
00188
00198 protected function getXMLImpl($root, $forceRegen) {
00199
00200 return '<alignments></alignments>';
00201 }
00202 }
00203
00204 ?>