这几天在弄公司的wiki系统,用的死Mediawiki,感觉还不错,公司把它当作内部资料库在用,每个人都往里面贴东西,mediawiki自带的那个图片上传系统实在是有点简单了,上传少量图片还好,要是图片太多那岂不是不让人活了...
于是想办法,看能不能批量上传,baidu哈,倒是有关于mediawiki的mass upload的字样,英文的,没办法,谁让要用呢,仔细看了看操作也不是太复杂,遂试试,当然不是在正在用的那个wiki系统上,另外建了个测试。
大概就是如下几步:
1.新建个文件夹放需要批量上传的图片,这里c:/ftp,去除其只读属性
2.在mediawiki安装目录下的localsetting.php中增加如下代码:
require_once( "extensions/SpecialUploadLocal.php" );
$wgUploadLocalDirectory = 'c:/ftp';#你设置的文件夹地址,绝对的相对的都行
patch -p0 < Magic_quotes_2.patch3.新建PHP文件extension/SpecialUploadLocal.php(以下都是相对与WIKI安装目录的)<? php
if ( ! defined ( ' MEDIAWIKI ' )) die ();
// Special:Uploadlocal specific config
$wgExtensionFunctions [] = " wfExtensionSpecialUploadLocal " ;
function wfExtensionSpecialUploadLocal() {
global $wgMessageCache ;
// I'd like to try adding these messages on demand, and only have the
// essentials here
$messages = array (
' uploadlocal ' => ' Upload local files '
, ' uploadlocal_directory_readonly ' => ' The local upload directory ($1) is ' .
' not writeable by the webserver. '
, ' uploadlocaltext ' => ' Use this form to mass upload files already on the ' .
' server in the upload local directory. You can find out more ' .
' general information at [[Special:Upload|the regular upload file ' .
' page]]. '
, ' uploadlocalbtn ' => ' Upload local files '
, ' nolocalfiles ' => ' There are no files in the local upload folder. Try ' .
' placing some files in "<code>$1</code>." '
, ' uploadednolocalfiles ' => ' You did not upload any files. '
, ' allfilessuccessful ' => ' All files uploaded successfully '
, ' uploadlocalerrors ' => ' Some files had errors '
, ' allfilessuccessfultext ' => ' All files uploaded successfully. Return to ' .
' [[Main Page]]. '
, ' uploadlocal_descriptions_append ' => ' Append to description: '
, ' uploadlocal_descriptions_prepend ' => ' Prepend to description: '
, ' uploadlocal_dest_file_append ' => ' Append to dest. filename: '
, ' uploadlocal_dest_file_prepend ' => ' Prepend to dest. filename: '
, ' uploadlocal_file_list ' => ' Files ready for upload '
, ' uploadlocal_file_list_explanation ' => ' '''X''' indicates ' .
' whether or not you want the file to be uploaded (uncheck to ' .
' prevent a file from being processed). '''W''' indicates ' .
' whether you want the file added to your watchlist. '
, ' uploadlocal_global_params ' => ' Global parameters '
, ' uploadlocal_global_params_explanation ' => ' What is entered here will ' .
' automatically get added to the entries listed above. This helps ' .
' remove repetitive text such as categories and metadata. To ''' ' .
' append''' is to add to the end of text, while to '''prepend ' .
' ''' means to add to the beginning of text. Especially for ' .
' descriptions, make sure you give a few linebreaks before/after ' .
' the text. '
);
$wgMessageCache -> addMessages( $messages );
SpecialPage :: addPage( new SpecialPage( ' UploadLocal ' , ' uploadlocal ' ) );
}
$wgUploadLocalDirectory = $IP . ' /extensions/uploadlocal ' ;
$wgAvailableRights [] = ' uploadlocal ' ;
$wgGroupPermissions [ ' uploader ' ][ ' uploadlocal ' ] = true ;
$wgGroupPermissions [ ' sysop ' ] [ ' uploadlocal ' ] = true ;
?>4.新建PHP文件includes/SpecialUploadLocal.php5.新建文件Magic_quotes_2.patch 放安装根目录