示例#1
0
 /**
  * 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();
             }
         }
     }
 }
示例#2
0
 /**
  * Locate a template
  * 
  * @link resolveTemplatePath()
  * 
  * @param string $inTemplatePath
  * @param array $inParamsArray
  * 
  * @return string 
  */
 protected function locateTemplate($inTemplatePath, &$inParamsArray)
 {
     return Container::resolveTemplatePath($this->getPage(), get_class($this), $inTemplatePath, $inParamsArray);
 }
示例#3
0
    /**
     * Add the Page's contributions to the head
     * 
     * @param Page $page
     * 
     * @return string
     */
    public static function contributeToHead($page)
    {
        $cricketJS = Container::resolveResourceUrl($page, get_class($page), "cricket/js/cricket.js");
        $pageID = $page->getInstanceID();
        return <<<END
            <script type="text/javascript" src = "{$cricketJS}"></script>
            <script type="text/javascript">
                _CRICKET_PAGE_INSTANCE_ = '{$pageID}';
            </script>
END;
    }
示例#4
0
 /**
  * Use a a button's onclick to submit its parent form
  * 
  * @param string $inActionID
  * @param string $inIndicatorID
  * @param string $inConfirmation
  * @param string $inFormID
  * @param string $requestChannel
  * @param boolean $failSilent
  * 
  * @todo We can probably remove all jQuery references from these functions
  * 
  * @return string
  */
 public function form_submit($inActionID, $inIndicatorID = null, $inConfirmation = null, $inFormID = null, $requestChannel = null, $failSilent = false)
 {
     $form = "this";
     if ($inFormID) {
         $form = "jQuery('#{$inFormID}').get()[0]";
     }
     $url = $this->component->getActionUrl($inActionID);
     $ind = $inIndicatorID === null ? "null" : "'{$inIndicatorID}'";
     $confirm = $inConfirmation === null ? "null" : "'{$inConfirmation}'";
     $channel = $requestChannel === null ? "null" : "'{$requestChannel}'";
     $failSilent = $failSilent ? "true" : "false";
     return "cricket_ajax_form({$form},'{$url}',{$ind},{$confirm},{$channel},{$failSilent});";
 }