コード例 #1
0
ファイル: uploader.php プロジェクト: glensc/cjax
 /**
  * Right handler routed
  * 
  * handles chain call $ajax->someApi->uploader();
  * 
  * @param unknown_type $value
  */
 function callbackHandler($sender, $receiver, $setting)
 {
     switch ($setting) {
         case 'postCallback':
             $event = CoreEvents::$cache[$receiver->id];
             $callback = CoreEvents::$cache[$sender->id];
             $event['postCallback'][$sender->id] = $callback;
             $sender->delete();
             $callbacks = CoreEvents::processScache($event['postCallback']);
             $callbacks = CoreEvents::mkArray($callbacks, 'json', true);
             $event['postCallback'] = "<cjax>{$callbacks}</cjax>";
             CoreEvents::$cache[$receiver->id] = $event;
             CoreEvents::simpleCommit();
             break;
     }
 }
コード例 #2
0
ファイル: xmlItem.class.php プロジェクト: glensc/cjax
 function __set($setting, $value)
 {
     if (is_a($value, __CLASS__) || is_a($value, 'plugin')) {
         if (is_a($value, 'plugin')) {
             if (method_exists($value, 'callbackHandler')) {
                 if ($value->callbackHandler($value->xml, $this, $setting)) {
                     return $value;
                 }
             }
         }
         switch ($setting) {
             case 'waitFor':
                 $value = $value->id;
                 break;
             case 'callback':
                 if (isset(CoreEvents::$callbacks[$value->id])) {
                     $cb = CoreEvents::$callbacks[$value->id];
                     $cb = CoreEvents::processScache($cb);
                     //die("s<Pre>".print_r($cb,1));
                     CoreEvents::$cache[$value->id]['callback'] = CoreEvents::mkArray($cb, 'json', true);
                     CoreEvents::$callbacks[$this->id][$value->id] = CoreEvents::$cache[$value->id];
                     $value->delete();
                 } else {
                     CoreEvents::$callbacks[$this->id][$value->id] = CoreEvents::$cache[$value->id];
                     $value->delete();
                 }
                 //die('sss<pre>'.print_r(CoreEvents::$cache,1) . "ddd<pre".print_r(CoreEvents::$callbacks,1));
                 return;
                 break;
             default:
                 //nothing to handle
                 return;
         }
     }
     $event = CoreEvents::$cache[$this->id];
     $event[$setting] = $value;
     CoreEvents::$cache[$this->id] = $event;
     if ($setting == 'waitFor') {
         CoreEvents::$cache[$value]['onwait'][$this->id] = $this->xml();
         $this->delete();
     }
     CoreEvents::simpleCommit();
 }
コード例 #3
0
ファイル: core.class.php プロジェクト: glensc/cjax
 function UpdateCache($instance_id, $data)
 {
     self::$cache[$instance_id] = $data;
     CoreEvents::simpleCommit();
 }
コード例 #4
0
ファイル: plugin.class.php プロジェクト: glensc/cjax
 function waitFor($file)
 {
     ajax()->xmlObjects($this->_id)->waitfor = $file;
     CoreEvents::simpleCommit();
 }
コード例 #5
0
ファイル: ExamplePlugin.php プロジェクト: glensc/cjax
 /**
  * Advanced Callback Handler
  * 
  * Pushes an API to be a part of another API or Plugin instead of running on its own,
  * then you may access that other callback in plugins through this.callback
  * 
  * If your rightHandler is a callback, you may create a custom handler for that callback,
  * mainly micmic the functionality in core/classes/xmlItem.php on function __set() case 'callback'
  * 
  * 
  */
 function callbackHandler($xmlObj_from, $xmlObj_to, $setting)
 {
     $event = CoreEvents::$cache[$xmlObj_from->id];
     $callback = CoreEvents::$cache[$xmlObj_to->id];
     //pusha a copy of the API as callback
     $event['callback'][$xmlObj_from->id] = $callback;
     //deletes the API
     $xmlObj_from->delete();
     //process
     //do changes to $event
     //push changes
     CoreEvents::$cache[$xmlObj_to->id] = $event;
     //commit changes
     CoreEvents::simpleCommit();
     return true;
 }