Changeset 16681

Show
Ignore:
Timestamp:
06/23/08 17:33:34 (4 months ago)
Author:
rambo
Message:

allow use of callback functions in XML filters for more advanced setups

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/MidCOM_2_8/midcom.helper.replicator/exporter.php

    r15773 r16681  
    541541    } 
    542542 
     543    function filter_callback(&$serializations, &$pluginargs) 
     544    { 
     545        foreach($pluginargs as $k => $intanceargs) 
     546        { 
     547            unset($intanceargs); 
     548            $this->_filter_callback_real(&$serializations, &$pluginargs[$k]); 
     549        } 
     550    } 
     551 
     552    function _filter_callback_real(&$serializations, &$pluginargs) 
     553    { 
     554        debug_push_class(__CLASS__, __FUNCTION__); 
     555        debug_print_r("Called with \$pluginargs", $pluginargs); 
     556        debug_pop(); 
     557        if (   !isset($pluginargs['callback']) 
     558            && empty($pluginargs['callback'])) 
     559        { 
     560            debug_push_class(__CLASS__, __FUNCTION__); 
     561            debug_add("Plugin subscription #{$this->subscription->id} ({$this->subscription->title}) callback plugin callback not defined", MIDCOM_LOG_WARN); 
     562            debug_print_r("\$pluginargs", $pluginargs); 
     563            debug_pop(); 
     564            return false; 
     565        } 
     566        if (   !isset($pluginargs['component']) 
     567            && empty($pluginargs['component'])) 
     568        { 
     569            debug_push_class(__CLASS__, __FUNCTION__); 
     570            debug_add("Plugin subscription #{$this->subscription->id} ({$this->subscription->title}) callback plugin component not defined", MIDCOM_LOG_WARN); 
     571            debug_print_r("\$pluginargs", $pluginargs); 
     572            debug_pop(); 
     573            return false; 
     574        } 
     575        if (!$_MIDCOM->componentloader->load_graceful($pluginargs['component'])) 
     576        { 
     577            debug_push_class(__CLASS__, __FUNCTION__); 
     578            debug_add("Plugin subscription #{$this->subscription->id} ({$this->subscription->title}) callback plugin could not load component {$pluginargs['component']}", MIDCOM_LOG_WARN); 
     579            debug_pop(); 
     580            return false; 
     581        } 
     582        if (!is_callable($pluginargs['callback'])) 
     583        { 
     584            debug_push_class(__CLASS__, __FUNCTION__); 
     585            debug_add("Plugin subscription #{$this->subscription->id} ({$this->subscription->title}) callback plugin callback is not callable", MIDCOM_LOG_WARN); 
     586            debug_print_r("\$pluginargs['callback']", $pluginargs['callback']); 
     587            debug_pop(); 
     588            return false; 
     589        } 
     590        if (!isset($pluginargs['callback_extra_arguments'])) 
     591        { 
     592            $pluginargs['callback_extra_arguments'] = array(); 
     593        } 
     594        debug_pop(); 
     595        return call_user_func_array($pluginargs['callback'], array(&$serializations, &$pluginargs['callback_extra_arguments'])); 
     596    } 
     597 
    543598    /** 
    544599     * This runs the given array of serializations through filters defined for