改変履歴

plugin やら template やらの php を直接いじった履歴。いわゆる俺環用。

ちなみに、オリジナルを DocumentRoot 以下に残す場合は(残すのあんまり好きじゃないけど……)せめて permission を外しておくのがいいかと思います。

# cd /path/to/dokuwikiRoot/
# find ./* -name '*orig' -exec ls -l {} \;
---------- 1 root root 16732 Mar 20 18:31 ./lib/plugins/captcha/helper.php.orig
---------- 1 root root 62549 Mar 20 13:31 ./lib/plugins/discussion/action.php.orig
---------- 1 root root 2440 Mar 20 16:05 ./lib/plugins/discussion/script.js.orig
---------- 1 root root 5250 Mar 19 18:38 ./lib/tpl/bootstrap3/tpl_navbar.php.orig

もし permission が ---------- じゃないファイルがあるなら……

# chmod 0 ./path/to/file

まず action.php から。

<code diff> — lib/plugins/discussion/action.php.orig 2017-03-20 13:31:58.248000000 +0900 +++ lib/plugins/discussion/action.php 2017-03-20 16:26:02.110000000 +0900 @@ -280,8 +280,8 @@ class action_plugin_discussion extends D

                     $comment['user']['name'] = $INFO['userinfo']['name'];
                     $comment['user']['mail'] = $INFO['userinfo']['mail'];
                 } elseif((isset($_SERVER['REMOTE_USER']) && $this->getConf('adminimport') && $this->helper->isDiscussionMod()) || !isset($_SERVER['REMOTE_USER'])) {
  •                    if(empty($_REQUEST['name']) or empty($_REQUEST['mail'])) return; // don't add anonymous comments
  •                    if(!mail_isvalid($_REQUEST['mail'])) {
  •                    if(empty($_REQUEST['name'])) return; // don't add anonymous comments
  •                    if(!empty($_REQUEST['mail']) && !mail_isvalid($_REQUEST['mail'])) {
                           msg($lang['regbadmail'], -1);
                           return;
                       } else {

</code> メールアドレスを省略可能にするための変更を入れています。

<code diff> @@ -976,14 +976,14 @@ class action_plugin_discussion extends D

           <input type="hidden" name="user" value="<?php echo clientIP() ?>" />
           <div class="comment_name">
             <label class="block" for="discussion__comment_name">
  •              <span><?php echo $lang['fullname'] ?>:</span>
  •              <input type="text" class="edit<?php if($_REQUEST['comment'] == 'add' && empty($_REQUEST['name'])) echo ' error'?>" name="name" id="discussion__comment_name" size="50" tabindex="1" value="<?php echo hsc($_REQUEST['name'])?>" />
  •              <i class="fa fa-fw fa-lg fa-user" aria-hidden="true"></i>
  •              <input type="text" class="edit<?php if($_REQUEST['comment'] == 'add' && empty($_REQUEST['name'])) echo ' error'?>" name="name" id="discussion__comment_name" size="50" tabindex="1" placeholder="Your name (Required)" value="<?php echo hsc($_REQUEST['name'])?>" />
               </label>
             </div>
             <div class="comment_mail">
               <label class="block" for="discussion__comment_mail">
  •              <span><?php echo $lang['email'] ?>:</span>
  •              <input type="text" class="edit<?php if($_REQUEST['comment'] == 'add' && empty($_REQUEST['mail'])) echo ' error'?>" name="mail" id="discussion__comment_mail" size="50" tabindex="2" value="<?php echo hsc($_REQUEST['mail'])?>" />
  •              <i class="fa fa-fw fa-lg fa-envelope" aria-hidden="true"></i>
  •              <input type="text" class="edit<?php if($_REQUEST['comment'] == 'add' && empty($_REQUEST['mail'])) echo ' error'?>" name="mail" id="discussion__comment_mail" size="50" tabindex="2" placeholder="Your mail address (Optional)" value="<?php echo hsc($_REQUEST['mail'])?>" />
               </label>
             </div>
       <?php

@@ -994,8 +994,8 @@ class action_plugin_discussion extends D

     ?>
           <div class="comment_url">
             <label class="block" for="discussion__comment_url">
  •              <span><?php echo $this->getLang('url') ?>:</span>
  •              <input type="text" class="edit" name="url" id="discussion__comment_url" size="50" tabindex="3" value="<?php echo hsc($_REQUEST['url'])?>" />
  •              <i class="fa fa-fw fa-lg fa-link" aria-hidden="true"></i>
  •              <input type="text" class="edit" name="url" id="discussion__comment_url" size="50" tabindex="3" placeholder="Your URL (Optional)" value="<?php echo hsc($_REQUEST['url'])?>" />
               </label>
             </div>
       <?php

@@ -1018,7 +1018,7 @@ class action_plugin_discussion extends D

     ?>
           <div class="comment_date">
             <label class="block" for="discussion__comment_date">
  •              <span><?php echo $this->getLang('date') ?>:</span>
  •              <i class="fa fa-fw fa-lg fa-calendar" aria-hidden="true"></i>
                 <input type="text" class="edit" name="date" id="discussion__comment_date" size="50" />
               </label>
             </div>

@@ -1033,8 +1033,9 @@ class action_plugin_discussion extends D

     }
     ?>
             <div class="comment_text">
  •              <?php echo $this->getLang('entercomment'); echo ($this->getConf('wikisyntaxok') ? "" : ":");
  •                    if($this->getConf('wikisyntaxok')) echo '. ' . $this->getLang('wikisyntax') . ':'; ?>
  •              <i class="fa fa-fw fa-lg fa-comment" aria-hidden="true"></i>
  •              <?php
  •                  if($this->getConf('wikisyntaxok')) echo '. ' . $this->getLang('wikisyntax') . ':'; ?>
                 <!-- Fix for disable the toolbar when wikisyntaxok is set to false. See discussion's script.jss -->
                 <?php if($this->getConf('wikisyntaxok')) { ?>

@@ -1043,7 +1044,7 @@ class action_plugin_discussion extends D

                 <div id="discussion__comment_toolbar_disabled">
               <?php } ?>
             </div>
  •            <textarea class="edit<?php if($_REQUEST['comment'] == 'add' && empty($_REQUEST['text'])) echo ' error'?>" name="text" cols="80" rows="10" id="discussion__comment_text" tabindex="5"><?php
  •            <textarea class="edit<?php if($_REQUEST['comment'] == 'add' && empty($_REQUEST['text'])) echo ' error'?>" name="text" cols="80" rows="3" id="discussion__comment_text" tabindex="5" placeholder="Enter comments."><?php
                 if($raw) {
                     echo formText($raw);
                 } else {

</code> ……いじりすぎたかな。主にフォームの見た目を変更してます。

  1. 「フルネーム」とか「メールアドレス」とかのラベルを FontAwesome のアイコンで置き換え
  2. 各フィールドに placeholder 属性を付ける
  3. コメント入力用の textarea を小さくする

そこらじゅうに出てくる「ふぁ! ふぁ~ふぅ!」 1) ってなにかと思ってたんですけど [[http://fontawesome.io/icons/|Font Awesome]] FixedWidth って意味だったんですねw 初めて知りました。そしてこれめちゃくちゃ便利!

あとは script.js にもちょいちょい変更を。

<code diff> — lib/plugins/discussion/script.js.orig 2017-03-20 16:05:38.264000000 +0900 +++ lib/plugins/discussion/script.js 2017-03-20 16:30:05.492000000 +0900 @@ -32,16 +32,9 @@ function validate(form){

 } else {
     form.name.style.backgroundColor = '#fff';
 }
  • if (isBlank(form.mail.value) || form.mail.value.indexOf(“@”) == -1){
  •    form.mail.focus();
  •    form.mail.style.backgroundColor = '#fcc';
  •    return false;
  • } else {
  •    form.mail.style.backgroundColor = '#fff';
  • } if (isBlank(form.text.value)){

       form.text.focus();
  •    form.text.style.borderColor = '#fcc';
  •    form.text.style.backgroundColor = '#fcc';
       return false;

    }

} </code> 前半はメールアドレスを省略可能にするための変更。後半は、コメント本文が未入力だった場合に警告するためのスタイル変更がなぜか textarea の borderColor に対して行われていたので backgroundColor に変更しました。(バグ?)

Discussion プラグインにも関連。

<code diff> — lib/plugins/captcha/helper.php.orig 2017-03-20 18:31:19.849000000 +0900 +++ lib/plugins/captcha/helper.php 2017-03-20 19:56:10.961000000 +0900 @@ -63,7 +63,7 @@ class helper_plugin_captcha extends Doku

     $out = '';
     $out .= '<div id="plugin__captcha_wrapper">';
     $out .= '<input type="hidden" name="'.$this->field_sec.'" value="'.hsc($secret).'" />';
  •    $out .= '<label for="plugin__captcha">'.$text.'</label> ';
  •    $out .= '<label for="plugin__captcha"><i class="fa fa-fw fa-lg fa-key" aria-hidden="true"></i></label> ';
       switch($this->getConf('mode')) {
           case 'math':

@@ -111,7 +111,7 @@ class helper_plugin_captcha extends Doku

             }
             break;
     }
  •    $out .= ' <input type="text" size="'.$txtlen.'" name="'.$this->field_in.'" class="edit" /> ';
  •    $out .= ' <input type="text" size="'.$txtlen.'" name="'.$this->field_in.'" class="edit" tabindex="6" /> ';
       // add honeypot field
       $out .= '<label class="no">'.$this->getLang('honeypot').'<input type="text" name="'.$this->field_hp.'" /></label>'

</code>

前半は「ニンゲンの証明をしてください」みたいなムダに重たい文言を FontAwesome のアイコンに置き換えるための変更です。後半は、要は名前入れてコメント入れて CAPTCHA 入れて SUBMIT ボタン押すって言う流れをキーボードでストレスなくやりたいための変更です。

固定で tabindex 付けちゃうとあとでフィールドが増えたときに困る気もするんですけどまぁ……

<code diff> — ./lib/tpl/bootstrap3/tpl_navbar.php.orig 2017-03-19 18:38:17.132000000 +0900 +++ ./lib/tpl/bootstrap3/tpl_navbar.php 2017-04-01 12:53:58.697000000 +0900 @@ -46,7 +46,11 @@ $navbar_classes[] = (bootstrap3_conf('in

     // display logo and wiki title in a link to the home page
     tpl_link(
         wl(),
  •        '<img src="'.$logo.'" alt="'.$title.'" class="pull-left'.(($tagline) ? ' dw-logo-tagline' : '').'" id="dw__logo" '.$logo_size.' /> <span id="dw__title" '.($tagline ? 'style="margin-top:-5px"': '').'>'. $title . $tagline .'</span>',
  •       '<span id="dw__title" '. ($tagline ? 'style="margin-top:-5px"': '') .'>'.
  •       '<img class="pull-left" style="vertical-align:bottom" src="' .
  •       DOKU_URL . 'lib/images/manimani.png" alt="'.  $title. '" width="310" height="64">'.
  •       $tagline .
  •       '</span>',
           'accesskey="h" title="[H]" class="navbar-brand"'
       );

</code>

DOKU_URL を使っておくと、いろいろ便利かもですね。

<code diff> — display.php.orig 2017-03-30 22:43:53.505000000 +0900 +++ display.php 2017-04-15 17:26:52.971294260 +0900 @@ -115,10 +115,10 @@ class action_plugin_linkback_display ext

     // section title
     $title = $this->getLang('linkbacks');
     echo '<div class="linkback_wrapper">';
  •    echo '<h2><a name="linkback__section" id="linkback__section">' . $title . '</a></h2>';
  •    echo '<h2><i class="fa fa-fw fa-external-link" area-hidden="true"></i><a name="linkback__section" id="linkback__section">' . $title . '</a></h2>';
       if ($this->getConf('show_trackback_url') && $data['receive']) {
           echo '<div class="level2 hfeed linkback_trackbackurl">';
  •        echo $this->getLang('trackback_url');
  •        echo '<i class="fa fa-fw fa-share-square-o" area-hidden="true"></i>';
           echo '<span class="linkback_trackbackurl">' . DOKU_URL . 'lib/plugins/linkback/exe/trackback.php/' . $ID . '</span>';
           echo '</div>';
       }

</code>

例によって「ふぁ!ふぁ~ふぅ!」してます。

それから /lib/plugins/linkback/lang/ 下の en/ を ja/ として丸ごとコピーして、こんな変更を入れました。

--- en/lang.php 2017-04-15 17:34:38.485448624 +0900
+++ ja/lang.php 2017-04-15 17:48:42.932085625 +0900
@@ -8,7 +8,7 @@
  */

 $lang['linkback_enabledisable'] = 'Send linkbacks for external links';
-$lang['linkbacks'] = 'Linkbacks';
+$lang['linkbacks'] = '&#x30EA;&#x30F3;&#x30AF;&#x30D0;&#x30C3;&#x30AF;';

 $lang['linkback_type_pingback'] = 'Pingback';
 $lang['linkback_type_trackback'] = 'Trackback';

そのまま “リンクバック” と utf8 で書いてもダメだったので html文字実体参照で “リンクバック” と書いています。

実際のところは、これだけじゃなくて userstyle.css に色々書き込んでます。イメージ使おうとするとどうしても px 指定を乱発しなきゃいけないのが悩みどころ。


1)
これ <i class="fa fa-fw fa-comment"></i>
  • wiki/dokuwiki/change_log
  • 最終更新: 2019/02/17 15:59