示例#1
0
 function handle_event($ev)
 {
     global $sql;
     $oid = $ev->context[$ev->long_name]['oid'];
     $customid = $ev->context[$ev->parent_name]['htmlid'];
     $io_class = $ev->context[$ev->parent_name]['io_class'];
     $setting_tool = new settings_tool();
     $filter_val = $sql->fetch1($sql->query($setting_tool->single_query($oid, $ev->parent_name . '!filter', $_SESSION['uid'], 0)));
     //function single_query($oid,$setting,$uid,$preset,$flags='')
     //$oid=$ev->context[$io_name]['oid'];
     //print 'oid='.$oid;
     //print $ev->parent_name.','.$ev->name.','.$ev->rem_name.':';
     $this->io = new $io_class();
     $pl = new editor_search_pick_list();
     $pl->io =& $this->io;
     $pl->name = $ev->parent_name;
     $pl->long_name = $ev->parent_name;
     $pl->context =& $ev->context;
     $pl->keys =& $ev->keys;
     $pl->text_inp = $ev->context[$ev->parent_name]['rval_id'];
     $pl->cont_inp = $ev->context[$ev->parent_name]['filter_id'];
     switch ($ev->rem_name) {
         case $ev->name:
             $v = $_POST['val'];
             $hr = $this->io->to_hr($pl, $v);
             print "var mm=\$i('" . js_escape($ev->context[$ev->parent_name]['vval_id']) . "');mm.textContent='" . js_escape($hr . '>') . "';";
             print "mm.setAttribute('title','" . js_escape($hr) . "');";
             print "\$i('" . js_escape($ev->context[$ev->parent_name]['rval_id']) . "').style.backgroundColor='white';";
             return;
             break;
         case 'filter':
             $pl->filter_val = $_POST['val'];
             $sql->query($setting_tool->set_query($oid, $ev->parent_name . '!filter', $_SESSION['uid'], 0, $pl->filter_val));
             $pl->bootstrap();
             print "var sugg=\$i('" . js_escape($ev->context[$ev->parent_name]['suggestions_id']) . "');sugg.innerHTML=";
             reload_object($pl);
             $js = '';
             foreach ($pl->result_array as $v) {
                 if ($js != '') {
                     $js .= ',';
                 }
                 $js .= '{id:\'' . js_escape($v->id) . '\',val:\'' . js_escape($v->val) . '\'}';
             }
             print 'var filter=$i(\'' . js_escape($ev->context[$ev->parent_name]['filter_id']) . '\');';
             print 'filter.as_objects=[' . $js . '];';
             print 'filter.as_id = null;';
             print 'filter.page_offset = 0;';
             //print "alert((findPosY(sugg)+sugg.offsetHeight)+' '+(window.pageYOffset+window.innerHeight));";
             print "if((findPosY(sugg)+sugg.offsetHeight) > (window.pageYOffset+window.innerHeight))window.scroll(0,findPosY(sugg)+sugg.offsetHeight-window.innerHeight);";
             //print 'filter.scrollIntoView();';
             break;
         case 'next_page':
         case 'prev_page':
         case 'first_page':
             $pl->filter_val = $filter_val;
             $pl->io->page_offset = $_POST['val'];
             //print "alert('".$_POST['val']."');";
             $pl->bootstrap();
             print "\$i('" . js_escape($ev->context[$ev->parent_name]['suggestions_id']) . "').innerHTML=";
             reload_object($pl);
             $js = '';
             foreach ($pl->result_array as $v) {
                 if ($js != '') {
                     $js .= ',';
                 }
                 $js .= '{id:\'' . js_escape($v->id) . '\',val:\'' . js_escape($v->val) . '\'}';
             }
             print '$i(\'' . js_escape($ev->context[$ev->parent_name]['filter_id']) . '\').as_objects=[' . $js . '];';
             print '$i(\'' . js_escape($ev->context[$ev->parent_name]['filter_id']) . '\').as_id = null;';
             break;
     }
     editor_generic::handle_event($ev);
 }
示例#2
0
文件: dom.php 项目: vladisslav2011/nb
 function setting_val($oid, $setting, $defval)
 {
     global $sql;
     if (!is_array($this->settings_array)) {
         $qod = true;
     } elseif (!is_array($this->settings_array[$oid])) {
         $qod = true;
     } elseif (!isset($this->settings_array[$oid][$setting])) {
         $qod = true;
     } else {
         return $this->settings_array[$oid][$setting];
     }
     $settings_tool = new settings_tool();
     $res = $sql->q1($settings_tool->single_query($oid, $setting, $_SESSION['uid'], 0));
     if (!isset($res)) {
         return $defval;
     } else {
         return $res;
     }
 }
示例#3
0
 function handle_event($ev)
 {
     global $sql;
     $ev->reload_list = false;
     $this->oid = $ev->context[$ev->parent_name]['oid'];
     $this->long_name = $ev->parent_name;
     $st = new settings_tool();
     $this->args['fltr'] = $sql->qv1($st->single_query($this->oid, $this->long_name . ".fltr", $_SESSION['uid'], ""));
     switch ($ev->rem_name) {
         case 'fltr':
             $sql->query($st->set_query($this->oid, $this->long_name . '.fltr', $_SESSION['uid'], 0, $_POST['val']));
             $this->args['fltr'] = $_POST['val'];
             $ev->reload_list = true;
             break;
     }
     if ($ev->reload_list) {
         $customid = $ev->context[$ev->parent_name]['list_id'];
         //$htmlid=$ev->context[$ev->long_name]['htmlid'];
         $r = new codes_match_list();
         $r->context =& $ev->context;
         $r->keys =& $ev->keys;
         $r->oid = $this->oid;
         $r->args = $this->args;
         $r->name = $ev->parent_name . ".list";
         $r->etype = $ev->parent_type . "." . get_class($r);
         $r->bootstrap();
         print "var nya=\$i('" . js_escape($customid) . "');";
         print "try{nya.innerHTML=";
         reload_object($r, true);
         print "nya.scrollTop=0;}catch(e){ window.location.reload(true);};";
         //common part
     }
     editor_generic::handle_event($ev);
 }
示例#4
0
 function bootstrap()
 {
     global $sql;
     $this->long_name = editor_generic::long_name();
     $st = new settings_tool();
     $sq = $st->single_query($this->oid, $this->long_name . '._mode', $_SESSION['uid'], 0);
     $this->mode = $sql->fetch1($sql->query($sq));
     if (!isset($this->mode)) {
         $this->mode = 0;
     }
     //if(is_array($this->editors))foreach($this->editors as $i => $e)
     //{
     $i = 'e' . $this->mode;
     $e = $this->editors[$i];
     $this->context[$this->long_name . '.' . $i]['var'] = $i;
     $e->context =& $this->context;
     $e->keys =& $this->keys;
     $e->args =& $this->args;
     $e->oid = $this->oid;
     //}
     //if(is_array($this->editors))foreach($this->editors as $e)$e->bootstrap();
     $e->bootstrap();
 }
示例#5
0
 function load()
 {
     global $sql;
     $res = $sql->query(settings_tool::single_query($this->oid, $this->long_name, $_SESSION['uid'], 0));
     $qg = $sql->fetch1($res);
     //print 'oid='.$this->oid;
     //print 'n='.$this->long_name;
     if (!isset($qg)) {
         $qg = serialize($this->make_qg());
     }
     $ret = unserialize($qg);
     if (!is_object($ret)) {
         $ret = $this->make_qg();
     }
     return $ret;
 }
示例#6
0
function get_setting($id)
{
    global $sql, $dbg;
    $s = new settings_tool();
    $q = $s->single_query(-1, $id, 0, 0, '');
    $res = $sql->query($q);
    $dbg[] = $sql->err();
    return $sql->fetch1($res);
}
示例#7
0
 function i_sq($ev, $v, $s)
 {
     global $sql, $ddc_tables;
     $st = new settings_tool();
     $rv = $sql->qv($st->single_query($this->oid, $this->long_name . "." . $s, $_SESSION['uid'], 0));
     $ev->settings->{$v} = $rv[0];
 }
示例#8
0
 function handle_event($ev)
 {
     global $sql;
     $oid = $ev->context[$ev->parent_name]['oid'];
     switch ($ev->rem_name) {
         case 'default_map':
         case 'reset_map':
         case 'direct_map':
             $parent_name = preg_replace('/\\.[^.]+$/', '', $ev->parent_name);
             $setting_tool = new settings_tool();
             $mapping = unserialize($sql->fetch1($sql->query($setting_tool->single_query($oid, $parent_name . '!txlumapping', $_SESSION['uid'], 0))));
             $collist = $ev->context[$ev->long_name]['collist'];
             $self_id = $ev->context[$ev->long_name]['self_id'];
             $src_rows = $ev->context[$ev->long_name]['src_rows'];
             $cnt = 0;
             foreach ($collist as $r => $v) {
                 $c_i[$cnt++] = $r;
             }
             $c2 = 0;
             foreach ($src_rows as $r) {
                 switch ($ev->rem_name) {
                     case 'default_map':
                         $mapping[$c_i[$c2++]] = $r;
                         break;
                     case 'reset_map':
                         unset($mapping[$c_i[$c2++]]);
                         break;
                     case 'direct_map':
                         if (isset($src_rows[$c_i[$c2]])) {
                             $mapping[$c_i[$c2]] = $c_i[$c2];
                         } else {
                             unset($mapping[$c_i[$c2]]);
                         }
                         $c2++;
                         break;
                 }
             }
             unset($mapping['']);
             $sql->query($setting_tool->set_query($oid, $parent_name . '!txlumapping', $_SESSION['uid'], 0, serialize($mapping)));
             break;
     }
     editor_generic::handle_event($ev);
 }
示例#9
0
 function prepare()
 {
     global $sql;
     $st = new settings_tool();
     $r = $sql->q1($st->single_query($this->oid, 'mq', $_SESSION['uid'], 0));
     if ($r != '') {
         $res = unserialize($r);
     } else {
         $res = new meta_query_gen();
     }
     $this->meta_query = $res;
     $r = $sql->q1($st->single_query($this->oid, 'ed_count', $_SESSION['uid'], 0));
     if ($r != '') {
         $res = intval($r);
     } else {
         $res = 10;
     }
     $ed_count = $res;
     $r = $sql->q1($st->single_query($this->oid, 'ed_offset', $_SESSION['uid'], 0));
     if ($r != '') {
         $res = intval($r);
     } else {
         $res = 0;
     }
     $ed_offset = $res;
     $colidx = 0;
     if (is_array($this->meta_query->result_def->children)) {
         foreach ($this->meta_query->result_def->children as $r) {
             if (get_class($r) == 'fm_meta_object') {
                 $hrarr = $sql->qkv("SELECT a.id,coalesce(b.val,a.name) as hr_name FROM `" . TABLE_META_TREE . "` as a LEFT OUTER JOIN `" . TABLE_META_I18N . "` as b ON a.id=b.object AND b.var='name' AND b.loc='" . $_SESSION['lang'] . "' WHERE a.id IN (" . str_replace('.', ',', $r->path) . ")");
                 $hrt = '';
                 $hrm = '';
                 foreach ($hrarr as $kk => $e) {
                     if ($hrt != '') {
                         $hrt .= '.';
                     }
                     $hrt .= $e;
                     if ($hrm != '') {
                         $hrm .= '.';
                     }
                     $hrm .= $kk;
                 }
             } else {
                 $hrt = 'expression ' . $colidx;
                 $hrm = '';
             }
             $td = new dom_td();
             unset($td->id);
             $td->append_child(new dom_statictext($hrt));
             $td->attributes['title'] = $hrm;
             $this->c_c->append_child($td);
             editor_generic::addeditor('cd' . $colidx, new editor_statictext());
             $td = new dom_td();
             unset($td->id);
             $td->append_child($this->editors['cd' . $colidx]);
             $this->c_d->append_child($td);
             $colidx++;
         }
     }
     $this->meta_query->oid = $this->oid;
     $this->sql_obj = $this->meta_query->to_show();
     $this->sql_obj->lim_count = $ed_count;
     $this->sql_obj->lim_offset = $ed_offset;
     $colidx1 = 0;
     if (is_array($this->sql_obj->what->exprs)) {
         foreach ($this->sql_obj->what->exprs as $e) {
             $e->alias = 'cd' . $colidx1;
             $colidx1++;
         }
     }
 }
示例#10
0
 function handle_event($ev)
 {
     global $sql;
     $reload_list = false;
     $oid = $ev->context[$ev->parent_name]['oid'];
     $dbg = $ev->context[$ev->parent_name]['dbg'];
     #$customid=$ev->context[$ev->parent_name]['htmlid'];
     $setting_tool = new settings_tool();
     $file_val = $sql->fetch1($sql->query($setting_tool->single_query($oid, $ev->parent_name . '!file', $_SESSION['uid'], 0)));
     $this->task = $sql->fetch1($sql->query($setting_tool->single_query($oid, $ev->parent_name . '!task', $_SESSION['uid'], 0)));
     switch ($ev->rem_name) {
         case 'task':
             $val = $_POST['val'];
             $sql->query($setting_tool->set_query($oid, $ev->parent_name . '!task', $_SESSION['uid'], 0, intval($val)));
             break;
         case 'file_picker':
             $file_val = $_POST['val'];
             $sql->query($setting_tool->set_query($oid, $ev->parent_name . '!file', $_SESSION['uid'], 0, $file_val));
             #print #'$i(\''.$dbg."').innerHTML='".js_escape(htmlspecialchars($setting_tool->set_query($oid,$ev->parent_name.'!file',$_SESSION['uid'],0,$file_val)))."';";
             $reload_list = true;
             break;
         case 'accept':
             $this->do_accept($file_val, false);
             $reload_list = true;
             break;
         case 'add':
             $this->do_accept($file_val, true);
             $reload_list = true;
             break;
         case 'unmatch':
             $c = $this->dump_unmatch($file_val, preg_replace('/\\.([^.]+)$/', '_u.$1', $file_val));
             print "alert('" . js_escape($c) . "');";
             break;
     }
     if ($reload_list) {
         $this->args['file_picker'] = $file_val;
         $this->args['task'] = $this->task;
         $customid = $ev->context[$ev->parent_name]['file_contents_id'];
         $oid = $ev->context[$ev->parent_name]['oid'];
         //$htmlid=$ev->context[$ev->long_name]['htmlid'];
         $r = new codes_import_xdiv();
         $r->context =& $ev->context;
         $r->keys =& $ev->keys;
         $r->oid = $oid;
         $r->args = $this->args;
         $r->name = $ev->parent_name . ".file_contents";
         $r->etype = $ev->parent_type . ".codes_import_xdiv";
         $r->bootstrap();
         print "var nya=\$i('" . js_escape($customid) . "');";
         print "try{nya.innerHTML=";
         reload_object($r, true);
         print "nya.scrollTop=0;}catch(e){ window.location.reload(true);};";
         //common part
     }
     editor_generic::handle_event($ev);
 }