Load specified (or active) script

@param string $script_name Optional script name

@return int Connection status: 0 on success, >0 on failure
343029
protected function load_script($script_name = null)
    {
        // Get list of scripts
        $list = $this->list_scripts();

        if ($script_name === null || $script_name === '') {
            // get (first) active script
            if (!empty($this->active)) {
               $script_name = $this->active[0];
            }
            else if ($list) {
                $script_name = $list[0];
            }
            // create a new (initial) script
            else {
                // if script not exists build default script contents
                $script_file = $this->rc->config->get('managesieve_default');
                $script_name = $this->rc->config->get('managesieve_script_name');

                if (empty($script_name)) {
                    $script_name = 'roundcube';
                }

                if ($script_file && is_readable($script_file)) {
                    $content = file_get_contents($script_file);
                }

                // add script and set it active
                if ($this->sieve->save_script($script_name, $content)) {
                    $this->activate_script($script_name);
                    $this->list[] = $script_name;
                }
            }
        }

        if ($script_name) {
            $this->sieve->load($script_name);
        }

        return $this->sieve->error();
    }
82662
private function loadConfig($file_name)
    {
        $file_path = $this->getAppPath('config').DIRECTORY_SEPARATOR.$file_name.'.php';

        if (is_readable($file_path)) {
            $configs = require $file_path;
            foreach ($configs as $key => $value) {
                $this->app['config.'.$file_name.'.'.$key] = $value;
            }
        } else {
            throw new Exception("Can't read from config file.");
        }
    }
131104
protected function waitForSiteByName($site_name)
    {
        return $this->retry(50, function () use ($site_name) {
            $this->sites = $this->fetchSites(fp_env('ACACHA_FORGE_SERVER'));
            $site = $this->getSiteByName($this->sites, $site_name);
            return $site ? $site : null;
        });
    }
312259
static function fetch( $http_name )
    {
        if ( !isset( $GLOBALS["eZHTTPFile-$http_name"] ) ||
             !( $GLOBALS["eZHTTPFile-$http_name"] instanceof eZHTTPFile ) )
        {
            $GLOBALS["eZHTTPFile-$http_name"] = null;

            if ( isset( $_FILES[$http_name] ) and
                 $_FILES[$http_name]["name"] != "" )
            {
                $mimeType = eZMimeType::findByURL( $_FILES[$http_name]['name'] );
                $_FILES[$http_name]['type'] = $mimeType['name'];
                $GLOBALS["eZHTTPFile-$http_name"] = new eZHTTPFile( $http_name, $_FILES[$http_name] );
            }
            else
            {
                eZDebug::writeError( "Unknown file for post variable: $http_name",
                                     "eZHTTPFile" );
            }
        }
        return $GLOBALS["eZHTTPFile-$http_name"];
    }
652367
public static function load($class_name = null, $safe = false)
    {
        if (empty($class_name)) {
            $class_name = self::getInternal('assets-config-class');
        }
    
        // init the registry
        if (empty(self::$__registry)) {
            self::$__registry = array_combine(self::$_requires,
                array_pad(array(), count(self::$_requires), null));
        }

        // init the configurator object
        if (empty(self::$__configurator) || $class_name!=get_class(self::$__configurator)) {
            if ($safe && !class_exists($class_name)) {
                $class_name = self::getInternal('assets-config-class');
            }

            if (class_exists($class_name)) {
                $interfaces = class_implements($class_name);
                $config_interface = self::getInternal('assets-config-interface');
                if (in_array($config_interface, $interfaces)) {
                    self::$__configurator = new $class_name;
                    $defaults = self::$__configurator->getDefaults();
                    if (self::_validateConfig($defaults)) {
                        self::$__registry = $defaults;
                    } else {
                        Error::thrower(
                            sprintf('Configuration class "%s" do not define all required values!',
                                $class_name),
                            '\Exception', __CLASS__, __METHOD__, __LINE__
                        );
                    }
                } else {
                    Error::thrower(
                        sprintf('Configuration class "%s" must implement interface "%s"!',
                            $class_name, $config_interface),
                        '\DomainException', __CLASS__, __METHOD__, __LINE__
                    );
                }
            } else {
                Error::thrower(
                    sprintf('Configuration class "%s" not found!', $class_name),
                    '\DomainException', __CLASS__, __METHOD__, __LINE__
                );
            }
        }
    }
1224128
static function getConnection($connection_name = null) {
		if (null === $connection_name) {
			$keys = array_keys(self::$parameters);
			$connection_name = reset($keys);
		}

		if (!@$connection_name) {
			return null;
		}

		return self::connect($connection_name);
	}
1023250
protected function _updateTableStatus ($table_name) {
		$this->_tableStatus = [];
		$stmt = $this->prepare('SHOW TABLE STATUS LIKE ?;');
		$stmt->execute([$table_name]);
		$this->_tableStatus[$table_name] = $stmt->fetchAll(\PDO::FETCH_ASSOC)[0];
	}
957905
public function loadObjectList($class_name = "stdClass")
    {
        if ($this->stmt === null) {
            return null;
        }

        $objectList = array();
        while ($object = $this->stmt->fetchObject($class_name)) {
            $objectList[] = $object;
        }
        return $objectList;
    }
452409
protected static function _cacheQueryResult($cache_key, $value, $table_name = null, $connection_name = self::DEFAULT_CONNECTION)
        {
            if(isset(self::$_config[$connection_name]['cache_query_result']) && is_callable(self::$_config[$connection_name]['cache_query_result'])){
                return call_user_func_array(self::$_config[$connection_name]['cache_query_result'], array($cache_key, $value, $table_name, $connection_name));
            } elseif (!isset(self::$_query_cache[$connection_name])) {
                self::$_query_cache[$connection_name] = [];
            }

            self::$_query_cache[$connection_name][$cache_key] = $value;
        }
48483
public function get_script($name)
    {
        if (!$this->sieve)
            return $this->_set_error(self::ERROR_INTERNAL);

        $content = $this->sieve->getScript($name);

        if (is_a($content, 'PEAR_Error')) {
            return $this->_set_error(self::ERROR_OTHER);
        }

        return $content;
    }
352686
def _load_script(self):
        
        script_text = filesystem.read_file(self.path, self.filename)

        if not script_text:
            raise IOError("Script file could not be opened or was empty: {0}"
                          "".format(os.path.join(self.path, self.filename)))
        self.script = script_text
818138
def fetch_library(name)
      library_script = @server_registry['library', name]
      
      logger.debug {"#{logname}: Tried to fetch script '#{name}' from the registry and it " +
                    "was #{'not ' if library_script.nil?}found."}

      raise NameError, "Server cannot find a script named #{name}" if library_script.nil?

      library_script
    end
410828
def load_script(self, source_name, timeoutMilliseconds=0):
        

        script_path = os.path.join(self.scripts_dir_path,
                                   self._source_to_script_name(source_name))

        if os.path.isfile(script_path):
            return ScriptHook(script_path, timeoutMilliseconds)
        return None
1356181
public function callEvent($event_name)
    {
        $classname = get_called_class();
        if (!isset(static::$callbacks[$classname][$event_name])) {
            return;
        }

        foreach (static::$callbacks[$classname][$event_name] as $callback) {
            $callback($this);
        }
    }
475367
public static function script($name, $callback) 
    {
        if (phpQueryPlugin_Scripts::$scriptMethods[$name]) {
            throw new Exception("Script name conflict - '$name'");
        }
        phpQueryPlugin_Scripts::$scriptMethods[$name] = $callback;
    }
422488
public static function getConnection(string $connection_name = '')
    {
        if (self::$conn_list === null) {
            self::initConnection();
        }

        if (! isset(self::$conn_list[$connection_name])) {
            $debug_msg = "数据库链接 - '$connection_name' 没有定义！" . StackTrace::getCode(3);
            throw new \InvalidArgumentException($debug_msg);
        }

        return self::connect($connection_name);
    }
1344496
static public function connection($name = null)
    {
        if ($name === null) {
            $name = self::$activeConnectionName;
            
            if (!$name) {
                if (self::$defaultConnectionName) {
                    $name = self::$defaultConnectionName;
                    self::setConnection($name);
                    self::$defaultConnectionName = null;
                } else {
                    throw new Exception\RuntimeException("No database connection is active");
                }
            }
        } else {
            self::create_connection($name);
        }
        
        return self::$_connections[$name];
    }