プラグイン管理でプラグインの先頭・最後への移動を追加する Ver3.2X版
- 2005.09.07
- Nucleus
さくっと消しちゃってた旧記事をGoogleから探し出して、Ver3.2X用に修正して無事プラグインの先頭・最後ができるようになったので、健忘録としてココに書いておくことにする という個人的なメモ。
目次
修正箇所
修正箇所は、nucleus/libs/ADMIN.phpとnucleus/languageの自分が使っているLANGファイルです。
ADMIN.PHP
STEP1.action_plugindown()関数の下に以下を追加します
-
// 指定のプラグインを最上位にする
-
function action_plugintop() {
-
global $member, $manager;
-
// check if allowed
-
$member->isAdmin() or $this->disallow();
-
$plugid = intGetVar(‘plugid’);
-
if (!$manager->pidInstalled($plugid))
-
$this->error(_ERROR_NOSUCHPLUGIN);
-
// 指定されたプラグインのオーダーを取得する
-
$o = mysql_fetch_object(sql_query(‘SELECT porder FROM ‘.sql_table(‘plugin’).’ WHERE pid=’.$plugid));
-
$oldOrder = $o->porder;
-
// オーダー昇順に取得していく
-
$query = ‘SELECT pid,porder FROM ‘.sql_table(‘plugin’).’ WHERE porder < ‘.$oldOrder.’ ORDER BY porder ASC’;
-
$aPIDs = array();
-
$r = sql_query($query);
-
while ($o = mysql_fetch_object($r)) {
-
array_push($aPIDs, array(
-
‘pid’ => $o->pid,
-
‘porder’ => $o->porder
-
));
-
}
-
if (count($aPIDs) > 0) {
-
$newOrder = 2;
-
foreach ($aPIDs as $aPID)
-
{ sql_query(‘UPDATE ‘.sql_table(‘plugin’).’ SET porder=’.$newOrder.’ WHERE pid=’.$aPID[‘pid’]);
-
$newOrder++;
-
}
-
// 指定したプラグインをトップに持ってくる
-
sql_query(‘UPDATE ‘.sql_table(‘plugin’).’ SET porder=1 WHERE pid=’.$plugid);
-
}
-
$this->action_pluginlist();
-
}
-
// 指定のプラグインを最下位にする
-
function action_pluginbottom() {
-
global $member, $manager;
-
// check if allowed
-
$member->isAdmin() or $this->disallow();
-
$plugid = intGetVar(‘plugid’);
-
if (!$manager->pidInstalled($plugid))
-
$this->error(_ERROR_NOSUCHPLUGIN);
-
// 指定されたプラグインのオーダーを取得する
-
$o = mysql_fetch_object(sql_query(‘SELECT porder FROM ‘.sql_table(‘plugin’).’ WHERE pid=’.$plugid));
-
$oldOrder = $o->porder;
-
// プラグイン総数を取得する
-
$maxOrder = mysql_num_rows(sql_query(‘SELECT * FROM ‘.sql_table(‘plugin’)));
-
// オーダー降順に取得していく
-
$query = ‘SELECT pid,porder FROM ‘.sql_table(‘plugin’).’ WHERE porder > ‘.$oldOrder.’ ORDER BY porder ‘;
-
$aPIDs = array();
-
$r = sql_query($query);
-
while ($o = mysql_fetch_object($r)) {
-
array_push($aPIDs, array(
-
‘pid’ => $o->pid,
-
‘porder’ => $o->porder
-
));
-
}
-
if (count($aPIDs) > 0) {
-
$newOrder = $oldOrder;
-
foreach ($aPIDs as $aPID)
-
{ sql_query(‘UPDATE ‘.sql_table(‘plugin’).’ SET porder=’.$newOrder.’ WHERE pid=’.$aPID[‘pid’]);
-
$newOrder++;
-
}
-
// 指定したプラグインをトップに持ってくる
-
sql_query(‘UPDATE ‘.sql_table(‘plugin’).’ SET porder=’.$maxOrder.’ WHERE pid=’.$plugid);
-
}
-
$this->action_pluginlist();
-
}
STEP2.listplug_table_pluginlist()関数のUP/DOWNのechoの記述付近に以下を追記(echoの順番が表示順になるので好きなように)
-
$url = $manager->addTicketToUrl($baseUrl . ‘plugintop’);
-
echo “<a href='”,htmlspecialchars($url),”‘ tabindex='”.$template[‘tabindex’].”‘>”,_LIST_PLUGS_TOP,”</a>”;
-
$url = $manager->addTicketToUrl($baseUrl . ‘pluginbottom’);
-
echo “<br /><a href='”,htmlspecialchars($url),”‘ tabindex='”.$template[‘tabindex’].”‘>”,_LIST_PLUGS_BOTTOM,”</a>”;
STEP3.言語ファイルに先頭・最後の定義を追加する(_LIST_PLUGS_DOWNの定義のある付近で)
修正したファイルをアップロードして、プラグイン一覧にアクセスして無事「先頭へ」と「最後へ」が表示されていればOKです。
プッシュ通知を
-
前の記事
NP_TextWikiにGeshiを組み込む 2005.09.06
-
次の記事
帰宅直前に生きてるムシキング?と遭遇してみた 2005.09.08
コメントを残す コメントをキャンセル