00001 <?php 00024 class WebBlockHelper extends BaseWebHelper implements HelpableTemplate { 00028 private $blockName = ""; 00029 00035 protected function __construct () { 00036 // Call parent constructor 00037 parent::__construct(__CLASS__); 00038 } 00039 00047 public final static function createWebBlockHelper (CompileableTemplate $templateInstance, $blockName) { 00048 // Get new instance 00049 $helperInstance = new WebBlockHelper(); 00050 00051 // Set template instance 00052 $helperInstance->setTemplateInstance($templateInstance); 00053 00054 // Set block name 00055 $helperInstance->setBlockName($blockName); 00056 00057 // Return the prepared instance 00058 return $helperInstance; 00059 } 00060 00067 protected final function setBlockName ($blockName) { 00068 $this->blockName = (string) $blockName; 00069 } 00070 00076 public final function getBlockName () { 00077 return $this->blockName; 00078 } 00079 00085 public function ifIncludeRegistrationStamp () { 00086 $withRegistration = ($this->getConfigInstance()->readConfig('block_shows_registration') === "Y"); 00087 return $withRegistration; 00088 } 00089 00097 public function assignMessageField ($templateVariable, $messageId) { 00098 // Get message 00099 $message = $this->getLanguageInstance()->getMessage($messageId); 00100 00101 // And assign it 00102 $this->getTemplateInstance()->assignVariable($templateVariable, $message); 00103 } 00104 00112 public function assignLinkFieldWithAction ($linkField, $actionValue) { 00113 $this->getTemplateInstance()->assignVariable($linkField . '_action', $actionValue); 00114 } 00115 00122 protected function doFilterUserStatusTranslator ($userStatus) { 00123 // Generate message id 00124 $messageId = 'user_status_' . strtolower($userStatus); 00125 00126 // Get that message 00127 $translated = $this->getLanguageInstance()->getMessage($messageId); 00128 00129 // Return it 00130 return $translated; 00131 } 00132 00138 public function flushContent () { 00139 // Get template instance 00140 $templateInstance = $this->getTemplateInstance(); 00141 00142 // Get the template named like this block 00143 $templateInstance->loadCodeTemplate("block_" . $this->getBlockName()); 00144 00145 // Transfer it to the template instance 00146 $templateInstance->assignVariable($this->getBlockName(), $templateInstance->getRawTemplateData()); 00147 } 00148 } 00149 00150 // [EOF] 00151 ?>
1.5.6