Esempio n. 1
0
 /**
  * Register Features
  * 
  * A very customised version of this normally simple function
  * 
  */
 public function RegisterFeatures()
 {
     $ad_blocks =& OnePanelConfig::GetAdBlocks();
     // Dont do anything if they havent added any adblocks to the config
     if (is_array($ad_blocks)) {
         foreach ($ad_blocks as $key => &$block) {
             if (!isset($this->features[self::GetBlockKey($block->GetName())])) {
                 $new_block = new AdBlockFeature();
                 $new_block_key = self::GetBlockKey($block->GetName());
                 $new_block->SetTitle($block->GetName());
                 $new_block->Enable();
                 $new_block->SetAlternateKey($new_block_key);
                 /*
                  * We don't use a refrence here as the source object will be replaced 
                  * after this iteration.
                  */
                 $this->features[$new_block_key] = $new_block;
                 // We now refrence the permanent object previously created.
                 $this->registered_features[] =& $this->features[$new_block_key];
                 $this->enabled_features[] = $new_block_key;
             } else {
                 $the_block_key = self::GetBlockKey($block->GetName());
                 $the_block =& $this->features[$the_block_key];
                 // Make sure its enabled
                 $the_block->Enable();
                 // Garbage collection and enabled state
                 $this->registered_features[] =& $the_block;
                 $this->enabled_features[] = $the_block_key;
             }
             // Set up ajax for it
             add_action('wp_ajax_opcp_' . self::GetBlockKey($block->GetName()) . 'Activate', array($this->features[self::GetBlockKey($block->GetName())], 'Activate'));
             add_action('wp_ajax_opcp_' . self::GetBlockKey($block->GetName()) . 'Deactivate', array($this->features[self::GetBlockKey($block->GetName())], 'Deactivate'));
         }
     }
 }