c2ephp

agents/PRAY/DSAGBlock.php

Go to the documentation of this file.
00001 <?php
00002 require_once(dirname(__FILE__).'/AGNTBlock.php');
00003 require_once(dirname(__FILE__).'/TagBlock.php');
00004 
00006 
00009 class DSAGBlock extends AGNTBlock {
00011 
00019     public function DSAGBlock($prayfile,$name,$content,$flags) {
00020         parent::TagBlock($prayfile,$name,$content,$flags,PRAY_BLOCK_DSAG);
00021     }
00023     public function GetWebLabel() {
00024         return $this->GetTag('Web Label');
00025     }
00027     public function GetWebURL() {
00028         return $this->GetTag('Web URL');
00029     }
00030 
00032     public function GetWebIcon() {
00033         return $this->GetTag('Web Icon');
00034     }
00037 
00040     public function GetWebIconBase() {
00041         return $this->GetTag('Web Icon Base');
00042     }
00044 
00049     public function GetWebIconAnimationString() {
00050         return $this->GetTag('Web Icon Animation String');
00051     }
00053 
00056     public function GetWebIconAsSpriteFrame() {
00057         $webIcon = $this->GetWebIcon();
00058         if($webIcon == '') {
00059             throw new Exception('No web icon!');
00060         }
00061         $webIconBase = $this->GetWebIconBase();
00062         $webIconAnimationString = $this->GetWebIconAnimationString();
00063         if($webIconBase == '') {
00064             $webIconBase = 0;
00065         }
00066         if($webIconAnimationString == '') {
00067             $webIconAnimationString = 0;
00068         }
00069         if(($position = strpos($webIconAnimationString,' ')) !== false) {
00070             $webIconAnimationString = substr($webIconAnimationString,0,$position);
00071         }
00072         $prayfile = $this->GetPrayFile();
00073         if($prayfile == null) {
00074             throw new Exception('No PRAY file to get the icon from!');
00075         }
00076         $iconBlock = $prayfile->GetBlockByName($webIcon);
00077         if($iconBlock->GetType() != 'FILE') {
00078             throw new Exception('The block with the web icon\'s filename is not a file block!');
00079         }
00080         $type = strtolower(substr($webIcon,-3));
00081         $icon = null;
00082         if($type == 'c16') {
00083             $icon = new C16File(new StringReader($iconBlock->GetData()));
00084         } else if($type == 's16') {
00085             $icon = new S16File(new StringReader($iconBlock->GetData()));
00086         }
00087         if($icon == null) {
00088             throw new Exception('For one reason or another, couldn\'t make a sprite file for the web icon.');
00089         }
00090         return $icon->GetFrame($webIconBase+$webIconAnimationString);
00091         
00092     }
00093     
00094 }
00095 ?>
 All Classes Files Functions Variables Enumerations