/**
  * There really isn't any concept of 'parent' method. An ExtensibleObject
  * instance contains an ordered array of extension classes, which provides
  * the method implementations for the instance to use. Suppose that an
  * ExtensibleObject has two extension, and both have the same methods.The
  * last extension appears to 'override' the first extension. So, instead of calling
  * a 'parent' method, we're actually just calling an extension that was added sooner than
  * the one that is providing the current method implementation.
  */
 function call_parent($method)
 {
     $retval = NULL;
     // To simulate a 'parent' call, we remove the current mixin providing the
     // implementation.
     $klass = $this->object->get_mixin_providing($method);
     // Perform the routine described above...
     $this->object->disable_mixin_for($method, $klass);
     // Get the method map cache
     $orig_method_map = $this->object->_method_map_cache;
     $this->object->_method_map_cache = (array) C_Pope_Cache::get(array($this->object->context, $this->object->_mixin_priorities, $this->object->_disabled_map), $this->object->_method_map_cache);
     // Call anchor
     $args = func_get_args();
     // Remove $method parameter
     array_shift($args);
     // Execute the method
     $retval = $this->object->call_method($method, $args);
     // Cache the method map for this configuration of mixins
     C_Pope_Cache::set(array($this->object->context, $this->object->_mixin_priorities, $this->object->_disabled_map), $this->object->_method_map_cache);
     // Re-enable mixins;
     //		$this->object->add_mixin($klass);
     $this->object->enable_mixin_for($method, $klass);
     // Restore the original method map
     $this->object->_method_map_cache = $orig_method_map;
     return $retval;
 }
示例#2
0
 function flush_pope_cache()
 {
     if (is_user_logged_in() && current_user_can('manage_options') && isset($_REQUEST['ngg_flush_pope_cache'])) {
         C_Pope_Cache::get_instance()->flush();
         print "Flushed pope cache";
         exit;
     }
 }
 function update_cache()
 {
     C_Pope_Cache::set(array($this->context, $this->_mixin_priorities, $this->_disabled_map), $this->_method_map_cache);
 }
 static function update($reset = FALSE)
 {
     $local_settings = C_NextGen_Settings::get_instance();
     $global_settings = C_NextGen_Global_Settings::get_instance();
     // This is a specific hack/work-around/fix and can probably be removed sometime after 2.0.20's release
     //
     // NextGen 2x was not multisite compatible until 2.0.18. Users that upgraded before this
     // will have nearly all of their settings stored globally (network wide) in wp_sitemeta. If
     // pope_module_list (which should always be a local setting) exists site-wide we wipe the current
     // global ngg_options and restore from defaults. This should only ever run once.
     if (is_multisite() && isset($global_settings->pope_module_list)) {
         // Setting this to TRUE will wipe current settings for display types, but also
         // allows the display type installer to run correctly
         $reset = TRUE;
         $settings_installer = new C_NextGen_Settings_Installer();
         $global_defaults = $settings_installer->get_global_defaults();
         // Preserve the network options we honor by restoring them after calling $global_settings->reset()
         $global_settings_to_keep = array();
         foreach ($global_defaults as $key => $val) {
             $global_settings_to_keep[$key] = $global_settings->{$key};
         }
         // Resets internal options to an empty array
         $global_settings->reset();
         // Restore the defaults, then our saved values. This must be done again later because
         // we've set $reset to TRUE.
         $settings_installer->install_global_settings();
         foreach ($global_settings_to_keep as $key => $val) {
             $global_settings->{$key} = $val;
         }
     }
     // Get last module list and current module list. Compare...
     $last_module_list = self::_get_last_module_list($reset);
     $current_module_list = self::_generate_module_info();
     $diff = array_diff($current_module_list, $last_module_list);
     $do_upgrade = count($diff) > 0 || count($last_module_list) != count($current_module_list);
     $can_upgrade = $do_upgrade ? self::can_do_upgrade() : FALSE;
     if ($can_upgrade && !$diff) {
         $diff = $current_module_list;
     }
     if ($can_upgrade) {
         // Clear APC cache
         if (function_exists('apc_clear_cache')) {
             @apc_clear_cache('opcode');
             apc_clear_cache();
         }
         // The cache should be flushed
         C_Photocrati_Cache::flush();
         C_Photocrati_Cache::flush('all');
         if (class_exists('C_Pope_Cache')) {
             C_Pope_Cache::get_instance()->flush();
         }
         // Remove all NGG created cron jobs
         self::refresh_cron();
         // Delete auto-update cache
         update_option('photocrati_auto_update_admin_update_list', null);
         update_option('photocrati_auto_update_admin_check_date', '');
         // Other Pope applications might be loaded, and therefore
         // all singletons should be destroyed, so that they can be
         // adapted as necessary. For now, we'll just assume that the factory
         // is the only singleton that will be used by other Pope applications
         C_Component_Factory::$_instances = array();
         foreach ($diff as $module_name) {
             if ($handler = self::get_handler_instance(array_shift(explode('|', $module_name)))) {
                 if (method_exists($handler, 'install')) {
                     $handler->install($reset);
                 }
             }
         }
         // NOTE & TODO: if the above section that declares $global_settings_to_keep is removed this should also
         // Since a hard-reset of the settings was forced we must again re-apply our previously saved values
         if (isset($global_settings_to_keep)) {
             foreach ($global_settings_to_keep as $key => $val) {
                 $global_settings->{$key} = $val;
             }
         }
         // Save any changes settings
         $global_settings->save();
         $local_settings->save();
     }
     // Another workaround to an issue caused by NextGen's lack of multisite compatibility. It's possible
     // the string substitation wasn't performed, so if a '%' symbol exists in gallerypath we reset it. It's
     // another db call, but again this should only ever run once.
     //
     // Remove this when removing the above reset-global-settings code
     if (strpos($local_settings->gallerypath, '%')) {
         $settings_installer = new C_NextGen_Settings_Installer();
         $local_settings->gallerypath = $settings_installer->gallerypath_replace($global_settings->gallerypath);
         $local_settings->save();
     }
     // Update the module list, and remove the update flag
     if ($can_upgrade) {
         update_option('pope_module_list', $current_module_list);
         self::done_upgrade();
     }
 }
 /**
  * Autoloads any classes, interfaces, or adapters needed by this module
  */
 function _module_autoload($name)
 {
     // Pope classes are always prefixed
     if (strpos($name, 'C_') !== 0 && strpos($name, 'A_') !== 0 && strpos($name, 'Mixin_') !== 0) {
         return;
     }
     if ($this->_module_type_cache == null || count($this->_modules) > $this->_module_type_cache_count) {
         $this->_module_type_cache_count = count($this->_modules);
         $modules = $this->_modules;
         $keys = array();
         foreach ($modules as $mod => $properties) {
             $keys[$mod] = $properties->module_version;
         }
         if (!($this->_module_type_cache = C_Pope_Cache::get($keys, array()))) {
             foreach ($modules as $module_id => $module) {
                 $dir = $this->get_module_dir($module_id);
                 $type_list = $module->get_type_list();
                 foreach ($type_list as $type => $filename) {
                     $this->_module_type_cache[strtolower($type)] = $dir . DIRECTORY_SEPARATOR . $filename;
                 }
             }
             C_Pope_Cache::set($keys, $this->_module_type_cache);
         } elseif (is_object($this->_module_type_cache)) {
             $this->_module_type_cache = get_object_vars($this->_module_type_cache);
         }
     }
     $name = strtolower($name);
     if (isset($this->_module_type_cache[$name])) {
         $module_filename = $this->_module_type_cache[$name];
         if (file_exists($module_filename)) {
             require_once $module_filename;
         }
     }
 }
 public static function set_cache_dir()
 {
     if (defined('POPE_CACHE_DIR')) {
         self::$cache_dir = POPE_CACHE_DIR;
         if (!@file_exists(self::$cache_dir)) {
             @mkdir(self::$cache_dir, 0777, TRUE);
         }
     } else {
         self::$cache_dir = self::join_paths(sys_get_temp_dir());
     }
     $func = function_exists('wp_is_writable') ? 'wp_is_writable' : 'is_writable';
     if (!@$func(self::$cache_dir)) {
         C_Pope_Cache::$enabled = FALSE;
     }
 }