Ejemplo n.º 1
0
 function Tracker_list($page, $refer, &$config, $list)
 {
     $this->page = $page;
     $this->config =& $config;
     $this->list = $list;
     $this->fields = plugin_tracker_get_fields($page, $refer, $config);
     $pattern = join('', plugin_tracker_get_source($config->page . '/page'));
     // ブロックプラグインをフィールドに置換
     // #commentなどで前後に文字列の増減があった場合に、[_block_xxx]に吸い込ませるようにする
     $pattern = preg_replace('/^\\#([^\\(\\s]+)(?:\\((.*)\\))?\\s*$/m', '[_block_$1]', $pattern);
     // パターンを生成
     $this->pattern = '';
     $this->pattern_fields = array();
     $pattern = preg_split('/\\\\\\[(\\w+)\\\\\\]/', preg_quote($pattern, '/'), -1, PREG_SPLIT_DELIM_CAPTURE);
     while (count($pattern)) {
         $this->pattern .= preg_replace('/\\s+/', '\\s*', '(?>\\s*' . trim(array_shift($pattern)) . '\\s*)');
         if (count($pattern)) {
             $field = array_shift($pattern);
             $this->pattern_fields[] = $field;
             $this->pattern .= '(.*)';
         }
     }
     // ページの列挙と取り込み
     $this->rows = array();
     $pattern = "{$page}/";
     $pattern_len = strlen($pattern);
     foreach (get_existpages() as $_page) {
         if (strpos($_page, $pattern) === 0) {
             $name = substr($_page, $pattern_len);
             if (preg_match(TRACKER_LIST_EXCLUDE_PATTERN, $name)) {
                 continue;
             }
             $this->add($_page, $name);
         }
     }
 }
Ejemplo n.º 2
0
function plugin_csv2newpage_write($ary, $base, $postdata, $config)
{
    global $vars, $now, $num;
    $name = empty($ary['_name']) ? '' : $ary['_name'];
    if (!empty($ary['_page'])) {
        $page = $real = $ary['_page'];
        $page = $base . '/' . $page;
    } else {
        $real = is_pagename($name) ? $name : ++$num;
        $page = get_fullname('./' . $real, $base);
    }
    if (!Factory::Wiki($page)->isValied()) {
        $page = $base;
    }
    while (Factory::Wiki($page)->isValied()) {
        $real = ++$num;
        $page = $base . '/' . $real;
    }
    // 規定のデータ
    $_post = array_merge($ary, $vars, $_FILES);
    $_post['_date'] = $now;
    $_post['_page'] = $page;
    $_post['_name'] = $name;
    $_post['_real'] = $real;
    // $_post['_refer'] = $_post['refer'];
    if (!exist_plugin('tracker')) {
        return array('msg' => 'plugin not found', 'body' => 'The tracker plugin is not found.');
    }
    $fields = plugin_tracker_get_fields($base, $page, $config);
    foreach ($fields as $key => $class) {
        if (array_key_exists($key, $_post)) {
            $val = $class->format_value($_post[$key]);
        } else {
            $val = $class->default_value;
        }
        $postdata = str_replace('[' . $key . ']', $val, $postdata);
    }
    // 書き込み
    Factory::Wiki($page)->set($postdata);
    return $page;
}