Adds a bit to a preference

@param string $id_usr_opt The preference's ID
@param array $cfg The bit's values
@return string|null
964501
public function add_bit(string $id_usr_opt, array $cfg): ?string
  {
    if (
      ($id_usr_opt = $this->_get_id_option($id_usr_opt)) &&
      ($c = $this->class_cfg['arch']['user_options_bits'])
    ){
      $to_cfg = $this->get_bit_cfg(null, $cfg);
      if ( isset($to_cfg['items']) ){
        unset($to_cfg['items']);
      }
      if ( !empty($to_cfg) ){
        if ( !empty($cfg[$c['cfg']]) ){
          if (  \bbn\str::is_json($cfg[$c['cfg']]) ){
            $cfg[$c['cfg']] = json_decode($cfg[$c['cfg']], true);
          }
          if ( \is_array($cfg[$c['cfg']]) ){
            $cfg[$c['cfg']] = array_merge($cfg[$c['cfg']], $to_cfg);
          }
          else {
            $cfg[$c['cfg']] = $to_cfg;
          }
        }
        else {
          $cfg[$c['cfg']] = $to_cfg;
        }
        $cfg[$c['cfg']] = json_encode($cfg[$c['cfg']]);
      }
      if ( $this->db->insert($this->class_cfg['tables']['user_options_bits'], [
        $c['id_user_option'] => $id_usr_opt,
        $c['id_parent'] => $cfg[$c['id_parent']] ?? NULL,
        $c['id_option'] => $cfg[$c['id_option']] ?? NULL,
        $c['num'] => $cfg[$c['num']] ?? NULL,
        $c['text'] => $cfg[$c['text']] ?? '',
        $c['cfg'] => $cfg[$c['cfg']] ?? '',
      ]) ){
        return $this->db->last_id();
      }
    }
    return null;
  }
600941
def add_ini_opts(self, cp, section):
    
    for opt in cp.options(section):
      arg = string.strip(cp.get(section,opt))
      self.__options[opt] = arg
1021510
public function get_cfg_by_option(string $id_option, string $id_user = null): ?array
  {
    if (
      ($cfg = $this->db->select_one(
        $this->class_cfg['table'],
        $this->fields['cfg'],
        [
          $this->fields['id_option'] => $id_option,
          $this->fields['id_user'] => $id_user ?: $this->id_user,
        ]
      ))
    ){
      if ( bbn\str::is_json($cfg) ){
        $cfg = json_decode($cfg, 1);
      }
      return $this->get_cfg(false, $cfg);
    }
    return null;
  }
811836
public static function create($id,$guid,$context_id,$debug=false) {
        global $CFG;
        $pt = $CFG->cookiepad.'::'.$id.'::'.$guid.'::'.$context_id;
        if ( $debug ) echo("PT1: $pt\n");
        $ct = \Tsugi\Crypt\AesCtr::encrypt($pt, $CFG->cookiesecret, 256) ;
        return $ct;
    }
745893
public static function retrieve($id, $opts = null)
    {
        $list = self::all(array('id' => $id), $opts);
        $ch = new Charge();
        $ch->install($list->data[0]->values, $list->opts);
        return $ch;
    }
825442
public void configure(Object obj, Element cfg, int startIdx)
			throws Exception {
		String id = getAttribute(cfg, "id");
		if (id != null) {
			_idMap.put(id, obj);
		}

		Element[] children = getChildren(cfg);

		for (int i = startIdx; i < children.length; i++) {
			Element node = children[i];
			//CHECKSTYLE:OFF
			try {
				// TODO: in case switching to jdk 7, this could be a switch!
				String tag = node.getTagName();
				if ("Set".equals(tag)) {
					set(obj, node);
				} else if ("Put".equals(tag)) {
					put(obj, node);
				} else if ("Call".equals(tag)) {
					call(obj, node);
				} else if ("Get".equals(tag)) {
					get(obj, node);
				} else if ("New".equals(tag)) {
					newObj(obj, node);
				} else if ("Array".equals(tag)) {
					newArray(obj, node);
				} else if ("Ref".equals(tag)) {
					refObj(obj, node);
				} else if ("Property".equals(tag)) {
					propertyObj(obj, node);
				} else {
					throw new IllegalStateException("Unknown tag: " + tag);
				}
			} catch (Exception e) {
				LOG.warn("Config error at " + node, e.toString());
				throw e;
			}
			//CHECKSTYLE:ON
		}
	}
680133
public function set_preferences($id_user, $id_file, $md5, array $cfg = null, bbn\user\preferences $pref = null){
    if ( !empty($id_user) && !empty($id_file) && !empty($pref) ){
      $change['md5'] = $md5;
      if ( !empty($cfg['selections']) ){
        $change['selections'] = $cfg['selections'];
      }
      if ( isset($cfg, $cfg['marks']) ){
        $change['marks'] = $cfg['marks'];
      }
      if ( !empty($change) ){
        $id_option = $this->option_id($id_file);
        if ( $pref->set($id_option, $change, $id_user) ){
          return true;
        }
      }
    }
    return false;
  }
319402
private function _add_primary(array &$cfg): void
  {
    // Inserting a row without primary when primary is needed and no auto-increment
    if (
      !empty($cfg['primary']) &&
      empty($cfg['auto_increment']) &&
      (($idx = array_search($cfg['primary'], $cfg['fields'], true)) > -1) &&
      (count($cfg['values']) === (count($cfg['fields']) - 1))
    ){
      $val = false;
      switch ( $cfg['primary_type'] ){
        case 'int':
          $val = random_int(
            ceil(10 ** ($cfg['primary_length'] > 3 ? $cfg['primary_length'] - 3 : 1) / 2),
            ceil(10 ** ($cfg['primary_length'] > 3 ? $cfg['primary_length'] : 1) / 2)
          );
          break;
        case 'binary':
          if ( $cfg['primary_length'] === 16 ){
            x::log($cfg['tables'], 'add_options');
            $val = $this->get_uid();
            x::log($val, 'add_options');
          }
          break;
      }
      if ( $val ){
        array_splice($cfg['values'], $idx, 0, $val);
        $this->set_last_insert_id($val);
        x::log(['v' => $cfg['values'], 'f' => $cfg['fields']], 'add_options');
      }
    }
  }
1027426
public function add_link(string $id_option, string $id_link): ?string
  {
    $id = $this->db->select_one($this->class_cfg['table'], $this->fields['id'], [
      $this->fields['id_user'] => $this->id_user,
      $this->fields['id_option'] => $id_option
    ]);
    if ( $id ){
      if ( $this->db->update($this->class_cfg['table'], [
        $this->fields['id_link'] => $id_link
      ], ['id' => $id]) ){
        return $id;
      }
    }
    else if ( $this->db->insert($this->class_cfg['table'], [
      $this->fields['id_user'] => $this->id_user,
      $this->fields['id_option'] => $id_option,
      $this->fields['id_link'] => $id_link
    ]) ){
      return $this->db->last_id();
    }
    return null;
  }
1055309
public static function update_registry( $new_value, $id ) {
		$registry = self::get_registry();
		$registry[ $id ] = $new_value;

		return update_option( self::$registry_option_name, $registry );

	}
791795
public static function add_config( $config_id, $args = [] ) {
		$config                             = Config::get_instance( $config_id, $args );
		$config_args                        = $config->get_config();
		self::$config[ $config_args['id'] ] = $config_args;
	}
736800
public static function build($pollId, $userId, $optionId)
    {
        $vote = new static();

        $vote->poll_id = $pollId;
        $vote->user_id = $userId;
        $vote->option_id = $optionId;

        return $vote;
    }
788561
public function input($cname, $name, $cfg, $value = NULL, $id = 0) 
	{
		$cfg['validate']['tips'] = isset($cfg['validate']['tips']) ? $cfg['validate']['tips'] : "";
		$text = (isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1 ? '<font color="red">*</font>' : '').$cname;
		// 表单附加参数
		$attr = isset($cfg['validate']['formattr']) && $cfg['validate']['formattr'] ? $cfg['validate']['formattr'] : '';
		// 表单宽度设置
		$width = isset($cfg['option']['width']) && $cfg['option']['width'] ? $cfg['option']['width'] : '200';
		$ispass = isset($cfg['option']['ispass']) && $cfg['option']['ispass'] ? $cfg['option']['ispass'] : 0;
		$width = 'style="width:'.$width.(is_numeric($width) ? 'px' : '').';"';
		// 字段提示信息
		$tips = ($name == 'title') || (isset($cfg['validate']['tips']) && $cfg['validate']['tips']) ? ''.$cfg['validate']['tips'].'' : '';
		// 字段默认值
		if(!$value) {
			$value = isset($cfg['option']['value']) && $cfg['option']['value'] ? htmlspecialchars_decode($cfg['option']['value']) : "";
		} else {
			$value = isset($value) && $value ? htmlspecialchars_decode($value) : "";
		}
		//修改
		$disabled = !$this->isadmin && $id && $value && isset($cfg['validate']['isedit']) && !$cfg['validate']['isedit'] ? ' disabled' : ' ';
		$_type = $ispass ? 'password' : 'text';
		// 当字段必填时，加入html5验证标签
		$required = isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1 ? ' required="required"' : '';
		return $this->input_format($name, $text, '<input class="hstui-input" type="'.$_type.'" name="'.$name.'" id="hstcms_'.$name.'" value="'.$value.'" '.$width . $disabled . $required . $attr .' >', $tips);
	}
224053
public function move_bit(string $id, string $id_parent = null): ?bool
  { 
    if ( 
      \bbn\str::is_uid($id) && 
      (
        (\bbn\str::is_uid($id_parent) && $this->get_bit($id_parent)) || 
        \is_null($id_parent)
      ) &&
      ($bit = $this->get_bit($id)) &&
      ($cf = $this->get_class_cfg()) &&
      ($cfg =  $cf['arch']['user_options_bits'])
    ){
      $upd = [
        $cfg['id_parent'] => $id_parent,
        $cfg['num'] => $this->get_max_bit_num($bit[$cfg['id_user_option']], $id_parent, true)
      ];
      return !!$this->db->update($cf['tables']['user_options_bits'], $upd, [$cfg['id'] => $id]);
    }
    return null;
  }
896870
public function addOption(Option $option, $group = null)
    {
        if ($group) {
            $content = $this->content[$group];

            array_push($content, $option);

            $this->content[$group] = $content;
        } else {
            $this->content[] = $option;
        }

        return $this;
    }
322361
static JCTree.Tag optag(TokenKind token) {
        switch (token) {
        case BARBAR:
            return OR;
        case AMPAMP:
            return AND;
        case BAR:
            return BITOR;
        case BAREQ:
            return BITOR_ASG;
        case CARET:
            return BITXOR;
        case CARETEQ:
            return BITXOR_ASG;
        case AMP:
            return BITAND;
        case AMPEQ:
            return BITAND_ASG;
        case EQEQ:
            return JCTree.Tag.EQ;
        case BANGEQ:
            return NE;
        case LT:
            return JCTree.Tag.LT;
        case GT:
            return JCTree.Tag.GT;
        case LTEQ:
            return LE;
        case GTEQ:
            return GE;
        case LTLT:
            return SL;
        case LTLTEQ:
            return SL_ASG;
        case GTGT:
            return SR;
        case GTGTEQ:
            return SR_ASG;
        case GTGTGT:
            return USR;
        case GTGTGTEQ:
            return USR_ASG;
        case PLUS:
            return JCTree.Tag.PLUS;
        case PLUSEQ:
            return PLUS_ASG;
        case SUB:
            return MINUS;
        case SUBEQ:
            return MINUS_ASG;
        case STAR:
            return MUL;
        case STAREQ:
            return MUL_ASG;
        case SLASH:
            return DIV;
        case SLASHEQ:
            return DIV_ASG;
        case PERCENT:
            return MOD;
        case PERCENTEQ:
            return MOD_ASG;
        case INSTANCEOF:
            return TYPETEST;
        default:
            return NO_TAG;
        }
    }
685129
public function addOption(Option $option, string $optgroup = ''): Select
    {
        if (empty($optgroup)) {
            $this->options[] = $option;
        }
        else {
            $this->options[$optgroup][] = $option;
        }

        return $this;
    }