ZBlogPHP::LoadTagsByIDString PHP Method

LoadTagsByIDString() public method

通过类似'{1}{2}{3}{4}'载入tags
public LoadTagsByIDString ( $s ) : array
$s
return array
    public function LoadTagsByIDString($s)
    {
        $s = trim($s);
        if ($s == '') {
            return array();
        }
        $s = str_replace('}{', '|', $s);
        $s = str_replace('{', '', $s);
        $s = str_replace('}', '', $s);
        $a = explode('|', $s);
        $b = array();
        foreach ($a as &$value) {
            $value = trim($value);
            if ($value) {
                $b[] = $value;
            }
        }
        $t = array_unique($b);
        if (count($t) == 0) {
            return array();
        }
        $a = array();
        $b = array();
        $c = array();
        foreach ($t as $v) {
            if (isset($this->tags[$v]) == false) {
                $a[] = array('tag_ID', $v);
                $c[] = $v;
            } else {
                $b[$v] =& $this->tags[$v];
            }
        }
        if (count($a) == 0) {
            return $b;
        } else {
            $t = array();
            //$array=$this->GetTagList('',array(array('array',$a)),'','','');
            $array = $this->GetTagList('', array(array('IN', 'tag_ID', $c)), '', '', '');
            foreach ($array as $v) {
                $this->tags[$v->ID] = $v;
                $this->tagsbyname[$v->Name] =& $this->tags[$v->ID];
                $t[$v->ID] =& $this->tags[$v->ID];
            }
            return $b + $t;
        }
    }
ZBlogPHP