00001 <?php
00008 class STransStdXML3 extends STransXML
00009 {
00014 const XML_UNKNOWN = 0;
00015 const XML_RESOURCE = 1;
00016 const XML_LIST = 2;
00017 const XML_ALBUM = 3;
00018
00022 protected $transHelperClass = "STransStdXML3Helper";
00023
00031 public function doc() {
00032 return "STransStdXML translates the standard Shodor content"
00033 . " XML 2.0 format into viewable content HTML";
00034 }
00035
00036
00037
00038
00039
00045 public function getInFormat() {
00046 return 'xml';
00047 }
00048
00054 public function getOutFormat() {
00055 return 'html';
00056 }
00057
00065 public function translate ($si)
00066 {
00067 $src = $si->getSource();
00068 if($src instanceof SnapContent) {
00069 $src = $si->getSource()->getXML();
00070 $si->setSource($src);
00071 }
00072
00073 if(parent::translate($si) === false ) return false;
00074
00075 $eval = $this->getInputOption('eval');
00076
00077 $doc = SXMLHelper::parse($si->getSource(), true);
00078 if(!$doc)
00079 return false;
00080
00081 $xmlResource = $doc->documentElement;
00082
00083
00084
00085 switch ($xmlResource->tagName) {
00086 case 'XMLResource':
00087 $this->setOption('xmlRootType', STransStdXML3::XML_RESOURCE);
00088 $collect = $this->translateResource($xmlResource);
00089 if($eval) {
00090 $collect = str_replace(array('"'), array("\\\""), $collect);
00091 eval("\$collect = \"{$collect}\";");
00092 }
00093 $this->sendToTarget($si, $collect);
00094 break;
00095 case 'XMLList':
00096 $this->setOption('xmlRootType', STransStdXML3::XML_LIST);
00097 $this->translateList($xmlResource, $si);
00098 break;
00099 case 'XMLAlbum':
00100 $this->setOption('xmlRootType', STransStdXML3::XML_ALBUM);
00101 $this->translateAlbum($xmlResource, $si);
00102 break;
00103 default:
00104 $this->setOption('xmlRootType', STransStdXML3::XML_UNKNOWN);
00105 break;
00106 }
00107
00108 }
00109
00116 protected function translateAlbum($xmlAlbum, $si) {
00117 return $this->transHelper->translateAlbum($xmlAlbum, $this, $si);
00118 }
00119
00126 protected function translateList($xmlList, $si) {
00127 return $this->transHelper->translateList($xmlList, $this, $si);
00128 }
00129
00134 protected function translateResource($xmlResource) {
00135 return $this->transHelper->translateResource($xmlResource);
00136 }
00137
00141 public function getPage() {
00142 return $this->page;
00143 }
00144 }
00145
00146 ?>