Ejemplo n.º 1
0
 /**
  * @desc Optimized shortcut to pkgman_manager::get_instance()->get()
  * @param string $package package name
  * @return pkgman_package
  */
 public static function getp($package)
 {
     if (!empty(self::$instance)) {
         return self::$instance->get($package);
     }
     self::$instance = new self();
     return self::$instance->get($package);
 }
Ejemplo n.º 2
0
 /**
  * @return pkgmanager_package
  */
 public static function get_pkg()
 {
     static $_pkg;
     if (empty($_pkg)) {
         return $_pkg = pkgman_manager::getp('html');
     }
     return $_pkg;
 }
Ejemplo n.º 3
0
 protected function substitute_params($sql)
 {
     $this->_pkg = pkgman_manager::getp('sql');
     if (empty($this->_pkg->config['global_params'])) {
         $this->_pkg = null;
     }
     $sql = preg_replace_callback('#\\${(!?[a-zA-Z0-9_\\-|]+)}#u', array($this, 'substitute_params_callback'), $sql);
     return $sql;
 }
Ejemplo n.º 4
0
 public static function get_default()
 {
     static $inst = null;
     if (!empty($inst)) {
         return $inst;
     }
     $hcal = pkgman_manager::getp('hcal');
     $inst = new hcal_lang_output($hcal->config['lang']);
     return $inst;
 }
Ejemplo n.º 5
0
 /**
  * @param string $loc_name
  * @return hcal_location
  */
 public static function get($loc_name = null)
 {
     if (empty($loc_name)) {
         $hcal = pkgman_manager::getp('hcal');
         $loc_name = $hcal->config['location'];
     }
     if (empty(self::$locations[$loc_name])) {
         return false;
     }
     return new hcal_location(self::$locations[$loc_name], $loc_name);
 }
Ejemplo n.º 6
0
 /**
  * @desc Connect to a mysql using mysqli extention.
  * $con_config common params and default values:
  *   'host' => ini_get("mysqli.default_host"), 'port' => ini_get("mysqli.default_port"),
  *   'user' => ini_get("mysqli.default_user"), 'pass' => ini_get("mysqli.default_pw"),
  *   'db' => '',
  * if $con_config['link'] is set to mysqli object, do not open new connection
  * just wrap already open mysqli connection with this class
  * @param $con_config - connection config
  */
 public function __construct($con_config)
 {
     parent::__construct();
     $pkg = pkgman_manager::getp("sql");
     $default_config = array('host' => ini_get("mysqli.default_host"), 'port' => ini_get("mysqli.default_port"), 'user' => ini_get("mysqli.default_user"), 'pass' => ini_get("mysqli.default_pw"), 'db' => '', 'socket' => ini_get("mysqli.default_socket"), 'charset' => @$pkg->config['charset'], 'buffered' => true, 'throw_on_error' => @$pkg->config['throw_on_error'], 'on_demand' => false);
     // merge all config arrays together
     if (empty($con_config)) {
         $con_config = array();
     }
     $this->config = array_merge($this->config, $default_config, $con_config);
     if (empty($this->config['on_demand'])) {
         $this->set_link();
     }
 }
Ejemplo n.º 7
0
 /**
  * @desc Load model by name, if not found, null will be returned
  * @param string $model_name
  * @return sql_model
  */
 public function get_model($model_name)
 {
     $pkgman = pkgman_manager::get_instance();
     $models = $this->link->config['models'];
     if (is_string($models)) {
         $class_name = "{$models}_{$model_name}";
         if (!$pkgman->load_class($class_name)) {
             return null;
         }
         return new $class_name($this->link, $model_name);
     } else {
         foreach ($models as $pkg) {
             $class_name = "{$models}_{$model_name}";
             if (!$pkgman->load_class($class_name)) {
                 continue;
             }
             return new $class_name($this->link, $model_name);
         }
         return null;
     }
 }
 /**
  * @param string $lang
  * @param string|array $paths A paths to the XML files to load (single string or array)
  * @param bool $glob if true (default) each path is expanded using glob() function
  */
 public function __construct($lang, $paths = null, $glob = true)
 {
     $this->lang = $lang;
     $this->xml_paths = array();
     if (empty($paths)) {
         $hcal_pkg = pkgman_manager::getp('hcal');
         $paths = array($hcal_pkg->path . '/locations/*.xml');
     } elseif (!is_array($paths)) {
         $paths = array($paths);
     }
     foreach ($paths as $path) {
         if ($glob) {
             foreach (glob($path, GLOB_NOSORT | GLOB_BRACE) as $p) {
                 if (file_exists($p)) {
                     $this->xml_paths[] = $p;
                 }
             }
         } elseif (file_exists($path)) {
             $this->xml_paths[] = $path;
         }
     }
 }
Ejemplo n.º 9
0
 /**
  * @desc Must be called by all specific DB driver constructors
  */
 protected function __construct()
 {
     $pkg = pkgman_manager::getp('sql');
     $this->config = array('model_provider' => @$pkg->config['default_model_provider']);
 }
Ejemplo n.º 10
0
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Note: this GNU GPL license disclaimer applies to all files contained
  in this directory and all it's subdirectories
*/
// Main initialization script that is used to initialize the package system
if (version_compare("5.1.0", PHP_VERSION, ">")) {
    die("pkgmanager requires PHP5 or later!");
}
define("_PKGMAN_ROOT", rtrim(dirname(__FILE__), "\\/"));
// if true, will use spl_autoload_register(), else will define __autoload functions
if (!defined('_PKGMAN_USE_SPL_AUTOLOAD')) {
    define("_PKGMAN_USE_SPL_AUTOLOAD", true);
}
require _PKGMAN_ROOT . "/pkgman_manager.class.php";
require _PKGMAN_ROOT . "/pkgman_package.class.php";
/* @var pkgman_manager */
$_pkgman = pkgman_manager::get_instance();
if (_PKGMAN_USE_SPL_AUTOLOAD) {
    function _pkgman_autoload($class)
    {
        pkgman_manager::$instance->load_class($class);
    }
    spl_autoload_register('_pkgman_autoload');
} else {
    // if not using spl_autoload
    function __autoload($class)
    {
        pkgman_manager::$instance->load_class($class);
    }
}
Ejemplo n.º 11
0
 /**
  * @desc Creates a new instance of the appropriate form element. Static version
  * @param string $type - one of <code>config['form_element_map']</code> 
  * @param string $name - name attribute
  * @param array $param - additional parameters (@see appropriate element class for details)
  * @return unknown_type
  */
 public static function create_form_element($type, $name, $param = null)
 {
     $elm_class = pkgman_manager::getp('html')->config['form_element_map'][$type];
     if (empty($elm_class)) {
         throw new Exception("Unmapped element type [{$type}]");
     }
     return new $elm_class($type, $name, $param);
 }