Exemple #1
0
 function __construct($init, $path)
 {
     $this->issql = 0;
     if (ISWORD($init)) {
         $this->issql = $init->issql;
         $p = $init->path();
         $this->_mgr = $p->mgr();
         $this->map = array_of_size($p->map);
         $this->_word = $init;
         #$path = array_merge($init->df_path_values, $path);
         $this->add2($init->df_path_values);
     } elseif (ISPATH($init)) {
         $this->issql = $init->issql;
         $this->_mgr = $init->mgr();
         $this->map = array_of_size($init->map);
     } else {
         if (!ISDEPATH($init)) {
             _die("bad init object " . var_export($init, 1));
         }
         $this->_mgr =& $init;
         $this->map = array_of_size($init->all_sub_keys);
     }
     if (is_int($path)) {
         $this->_id = $path;
         $path = explode("/", $this->tag());
     }
     $this->add2($path);
     return $this;
 }
Exemple #2
0
 function __construct($init = NULL, $aliases = NULL, $name = NULL)
 {
     $this->key2values = [];
     $this->value2key = [];
     $this->all_sub_keys = [];
     $this->level = [];
     $this->simple_keys = [];
     $this->recursive_keys = [];
     $this->name = $name;
     if ($aliases === NULL) {
         $aliases = [];
     }
     $this->aliases = $aliases;
     #echo "\$init:\n";
     #var_dump($init);
     if ($init !== NULL) {
         foreach ($init as $k => $v) {
             if (!is_array($v)) {
                 _die("bad type, not array");
             }
             if (is_vec($v)) {
                 $this->simple_keys[] = $k;
                 register2($this, $k, $v);
             } else {
                 $this->recursive_keys[] = $k;
                 foreach ($v as $_ => &$v_) {
                     register($this, $k, $_);
                     #echo "\$v_:\n";
                     #var_dump($v_);
                     if (!ISDEPATH($v_)) {
                         $v_ = DEPATH($v_, $aliases);
                     }
                     $this->all_sub_keys = array_merge($this->all_sub_keys, $v_->all_sub_keys);
                     register3($this, $v_->key2values);
                 }
             }
             $this->level[$k] = $v;
         }
     }
     # Sort and remove duplicates
     $this->all_sub_keys = array_values(array_unique($this->all_sub_keys));
     foreach (array_keys($this->key2values) as $k) {
         $this->key2values[$k] = array_unique($this->key2values[$k]);
     }
 }
Exemple #3
0
function WORD()
{
    $db = defaultDB();
    $mgr = NULL;
    $id = NULL;
    $lang = NULL;
    $arg = func_get_args();
    #var_dump($arg);
    foreach ($arg as $a) {
        if (ISDB($a)) {
            $db = $a;
        } elseif (ISDEPATH($a)) {
            $mgr = $a;
        } elseif (ISDB($db) and is_string($a) and $db->is_lang($a)) {
            $lang = $a;
        } else {
            $id = $a;
        }
    }
    unset($arg, $a);
    #var_dump($db, $id, $mgr, $lang);
    return new _WORD($db, $id, $mgr, $lang);
}