/**
  * Broadcast a message, it's data, and who sent it.
  * 
  * @see Container::receiveMessage
  * 
  * @param string $inMessage
  * @param mixed $inData
  * @param Container $sender
  * 
  * @return void
  */
 public static function broadcastMessage($inMessage, $inData, $sender = null)
 {
     if (self::canSendMessage($inMessage)) {
         self::$sending++;
         $page = self::$page;
         if ($sender) {
             // if the sender is a container and it doesn't yet have a page (constructor) we need to not send the message since thats
             // the behavior that the old system used.
             if ($sender instanceof Container) {
                 $page = $sender->getPage();
             }
         } else {
             $sender = self::$page;
         }
         if ($page) {
             $page->broadcastMessageToTree($inMessage, $inData, $sender);
         }
         foreach (self::$page->_mcReceivers as $thisReceiver) {
             if (!in_array($thisReceiver, self::$toRemove)) {
                 $thisReceiver->messageReceived($inMessage, $inData, $sender);
             }
         }
         self::$sending--;
         if (self::$sending == 0) {
             if (count(self::$toRemove)) {
                 foreach (self::$toRemove as $removeThis) {
                     self::$page->mcRemoveReceiver($removeThis);
                 }
                 self::$toRemove = array();
             }
         }
     }
 }
Exemple #2
0
 /**
  * Resolve the file system path of a template
  * 
  * @param Page $page
  * @param string $class
  * @param string $path
  * @param array $inParams
  * @param boolean $showMissingTemplate
  * 
  * @return string
  */
 public static function resolveTemplatePath($page, $class, $path, &$inParams, $showMissingTemplate = true)
 {
     // if starts with a slash, then its a full path from the contextRoot
     // that means there is no wayt to do a file system full path...  thats probably ok
     if (preg_match("/^\\//", $path)) {
         $result = Application::getInstance()->getActiveModule()->resolveResourcePath($path, $page->getRequest()->getAttribute("contextPath"));
         if ($result) {
             return $result;
         } else {
             $inParams['templatePath'] = $path;
             $a = array();
             return Container::resolveTemplatePath($page, $class, "missing_template.php", $a);
         }
     }
     /* First search for overridden namespace paths in the root directory of the namespace */
     $override_path = str_replace("\\", DIRECTORY_SEPARATOR, $class) . DIRECTORY_SEPARATOR . $path;
     $reflector = new \ReflectionClass(get_class(Application::getInstance()));
     $start_path = str_replace(str_replace("\\", DIRECTORY_SEPARATOR, $reflector->getName()) . ".php", '', $reflector->getFileName());
     $override_path = $start_path . $override_path;
     if (file_exists($override_path)) {
         return $override_path;
     }
     $iter = new SearchPathIterator($class);
     while ($iter->hasNext()) {
         $testPath = $iter->next() . DIRECTORY_SEPARATOR . $path;
         if (file_exists($testPath)) {
             return $testPath;
         }
     }
     // if didn't find it and we aren't the Page class, then allow the page to be involved
     if ($class != get_class($page)) {
         return self::resolveTemplatePath($page, get_class($page), $path, $inParams, $showMissingTemplate);
     } else {
         if ($showMissingTemplate) {
             $inParams['templatePath'] = $path;
             return Container::resolveTemplatePath($page, $class, "missing_template.php", $a);
         } else {
             return null;
         }
     }
 }
 /**
  * No longer needed -- instance id embded into url
  * 
  * @return string
  */
 public function form_instance_id()
 {
     return "<input type='hidden' name='_CRICKET_PAGE_INSTANCE_' value='" . $this->page->getInstanceID() . "'>";
 }