Example #1
0
function plugin_links_action()
{
    global $post, $vars, $foot_explain;
    global $_links_messages, $_string;
    // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits this');
    if (Auth::check_role('readonly')) {
        Utility::dieMessage($_string['error_prohibit']);
    }
    $msg = $_links_messages['title_update'];
    $admin_pass = empty($post['adminpass']) ? null : $post['adminpass'];
    if (isset($vars['execute']) && $vars['execute'] === 'true') {
        if (!Auth::check_role('role_contents_admin') || Auth::login($admin_pass)) {
            //	$force = (isset($post['force']) && $post['force'] === 'on') ? true : false;
            $links = new Relational('');
            $links->init();
            return array('msg' => $msg, 'body' => $_links_messages['msg_done']);
        } else {
            $msg = $_links_messages['msg_error'];
        }
    }
    $body = RendererFactory::factory(sprintf($_links_messages['msg_usage1']));
    $script = Router::get_script_uri();
    if (Auth::check_role('role_contents_admin')) {
        $body .= RendererFactory::factory(sprintf($_links_messages['msg_usage2']));
    }
    $body .= <<<EOD
<form method="post" action="{$script}" class="form-inline plugin-links-form">
\t<input type="hidden" name="cmd" value="links" />
\t<input type="hidden" name="execute" value="true" />
EOD;
    if (Auth::check_role('role_contents_admin')) {
        $body .= <<<EOD
\t<div class="form-group">
\t\t<label for="_p_links_adminpass" class="sr-only">{$_links_messages['msg_adminpass']}</label>
\t\t<input type="password" name="adminpass" id="_p_links_adminpass" class="form-control" size="20" value="" placeholder="{$_links_messages['msg_adminpass']}" />
\t</div>
EOD;
    }
    $body .= <<<EOD
\t<!--div class="checkbox">
\t\t<input type="checkbox" name="force" id="_c_force" />
\t\t<label for="_c_force">{$_links_messages['btn_force']}</label>
\t</div-->
\t<input type="submit" class="btn btn-primary" value="{$_links_messages['btn_submit']}" />
</form>
EOD;
    return array('msg' => $msg, 'body' => $body);
}
Example #2
0
function plugin_related_action()
{
    global $vars, $defaultpage, $_related_messages;
    $_page = isset($vars['page']) ? $vars['page'] : null;
    if (empty($_page)) {
        $_page = $defaultpage;
    }
    if (!IS_AJAX) {
        // Result
        $retval[] = '<a href="' . get_page_uri($_page) . '">' . sprintf($_related_messages['msg_return'], Utility::htmlsc($_page)) . '</a><br />' . "\n";
    }
    // Get related from cache
    $links = new Relational($_page);
    $data = $links->getRelated();
    if (empty($data)) {
        $retval[] = '<ul><li>' . $_related_messages['msg_nomatch'] . '</li></ul>' . "\n";
    } else {
        // Hide by array keys (not values)
        foreach (array_keys($data) as $page) {
            $wiki = Factory::Wiki($page);
            if (!$wiki->isEditable() || $wiki->isHidden()) {
                unset($data[$page]);
            }
        }
        unset($wiki);
        // Show count($data)?
        ksort($data, SORT_STRING);
        $retval[] = '<ul class="list_pages">' . "\n";
        foreach ($data as $page => $time) {
            $wiki = Factory::Wiki($page);
            $retval[] = ' <li><a href="' . $wiki->uri() . '">' . Utility::htmlsc($page) . '</a> ' . $wiki->passage(true, true) . '</li>';
        }
        $retval[] .= '</ul>' . "\n";
    }
    return array('msg' => sprintf($_related_messages['msg'], Utility::htmlsc($_page)), 'body' => join("\n", $retval));
}
Example #3
0
function plugin_rename_phase4($pages, $files, $exists)
{
    global $now, $_rename_messages;
    if (plugin_rename_getvar('exist') == '') {
        foreach ($exists as $key => $arr) {
            unset($files[$key]);
        }
    }
    set_time_limit(0);
    foreach ($files as $page => $arr) {
        foreach ($arr as $old => $new) {
            if (isset($exists[$page][$old]) && $exists[$page][$old]) {
                unlink($new);
            }
            rename($old, $new);
            // Update link database (BugTrack/327) arino
            //links_update($old);
            //links_update($new);
            $links = new Relational();
            $links->update($old);
            $links->update($new);
        }
    }
    $wiki = Factory::Wiki(PLUGIN_RENAME_LOGPAGE);
    $postdata = $wiki->get();
    $postdata[] = '*' . $now . "\n";
    if (plugin_rename_getvar('method') == 'regex') {
        $postdata[] = '-' . $_rename_messages['msg_regex'] . "\n";
        $postdata[] = '--From:[[' . plugin_rename_getvar('src') . ']]' . "\n";
        $postdata[] = '--To:[[' . plugin_rename_getvar('dst') . ']]' . "\n";
    } else {
        $postdata[] = '-' . $_rename_messages['msg_page'] . "\n";
        $postdata[] = '--From:[[' . plugin_rename_getvar('refer') . ']]' . "\n";
        $postdata[] = '--To:[[' . plugin_rename_getvar('page') . ']]' . "\n";
    }
    if (!empty($exists)) {
        $postdata[] = "\n" . $_rename_messages['msg_result'] . "\n";
        foreach ($exists as $page => $arr) {
            $postdata[] = '-' . decode($page) . $_rename_messages['msg_arrow'] . decode($pages[$page]) . "\n";
            foreach ($arr as $ofile => $nfile) {
                $postdata[] = '--' . $ofile . $_rename_messages['msg_arrow'] . $nfile . "\n";
            }
        }
        $postdata[] = '----' . "\n";
    }
    foreach ($pages as $old => $new) {
        $postdata[] = '-' . decode($old) . $_rename_messages['msg_arrow'] . decode($new) . "\n";
    }
    // At this time, collision detection is not implemented
    $wiki->set($postdata);
    //未定義
    //	cache_timestamp_touch();
    $page = plugin_rename_getvar('page');
    if ($page == '') {
        $page = PLUGIN_RENAME_LOGPAGE;
    }
    // Redirection
    if (!pkwk_headers_sent()) {
        header('Location: ' . get_page_location_uri($page));
    }
    exit;
}
Example #4
0
 /**
  * 関連リンクを取得
  * @return array
  */
 public function related()
 {
     global $related;
     // Get repated pages from DB
     $link = new Relational($this->page);
     $ret = $related + $link->getRelated();
     ksort($ret, SORT_NATURAL);
     return $ret;
 }
Example #5
0
 /**
  * Returns a list of backlinks of a Wiki page.
  * このページにリンクしているページの配列を返す。
  * @param string $pagename ページ名
  * @return array
  */
 public function getBackLinks($pagename)
 {
     $links = new Relational($pagename);
     return $links->getRelated();
 }