本文主要为广大网友提供“Wordpress 相册插件 NextGEN-Gallery 添加目录将中文转为拼音的解决办法”,希望对需要Wordpress 相册插件 NextGEN-Gallery 添加目录将中文转为拼音的解决办法网友有所帮助,学习一下!
NextGEN Gallery是Wordpress中著名的相册插件,遗憾的是不支持中文等unicode字符,本文将介绍如何将目录转换为拼音(添加图集时)。
以NextGEN 1.6.2为例:
“新增图集/图片”的路径是:admin.php?page=nggallery-add-gallery,我们在nextgen-gallery/admin/admin.php中查找“nggallery-add-gallery”,
复制代码 代码如下:
switch (
Wordpress 相册插件 NextGEN-Gallery 添加目录将中文转为拼音的解决办法_网学
Wordpress 相册插件 NextGEN-Gallery 添加目录将中文转为拼音的解决办法
浏览:
GET[''page'']){
case "nggallery-add-gallery" :
include_once ( dirname (__FILE__) . ''/functions.php'' ); // admin functions
include_once ( dirname (__FILE__) . ''/addgallery.php'' ); // nggallery_admin_add_gallery
$ngg->addgallery_page = new nggAddGallery ();
$ngg->addgallery_page->controller();
break;
类nggAddGallery在addgallery.php中,鼠标悬停在”新增图集“Tab上时从浏览器的状态栏可以看到URL是 admin.php?page=nggallery-add-gallery#addgallery , 在addgallery.php中查找"addgallery"看到其调用了:
nggAdmin::create_gallery($newgallery, $defaultpath);
nggAdmin类位于functions.php中,create_gallery函数修改如下:(红色粗体是新增加的行)
复制代码 代码如下:
require_once(''cn2pinyin.php'');
/**
* nggAdmin - Class for admin operation
*
* @package NextGEN Gallery
* @author Alex Rabe
* @copyright 2007-2010
* @access public
*/
class nggAdmin{
/**
* create a new gallery & folder
*
* 添加中文支持 by:Elf Sundae
*
* @class nggAdmin
* @param string $gallerytitle
* @param string $defaultpath
* @param bool $output if the function should show an error messsage or not
* @return
*/
function create_gallery($gallerytitle, $defaultpath, $output = true) {
global $wpdb, $user_ID;
// get the current user ID
get_currentuserinfo();
//cleanup pathname
$galleryname = sanitize_file_name( $gallerytitle );
// 中文转换为拼音
$galleryname = cn2pinyin($galleryname,1);
$galleryname = apply_filters(''ngg_gallery_name'', $galleryname);
$nggpath = $defaultpath . $galleryname;
$nggRoot = WINABSPATH . $defaultpath;
$txt = '''';
其中cn2pinyin是汉字转换为拼音的函数,位于cn2pinyin.php(新建此文件)中。
cn2pinyin.php
复制代码 代码如下:
<?php
/**
*
* 中文转换为拼音
*
*/
function cn2pinyin(
Wordpress 相册插件 NextGEN-Gallery 添加目录将中文转为拼音的解决办法_网学
Wordpress 相册插件 NextGEN-Gallery 添加目录将中文转为拼音的解决办法
浏览:
String,
Wordpress 相册插件 NextGEN-Gallery 添加目录将中文转为拼音的解决办法_网学
Wordpress 相册插件 NextGEN-Gallery 添加目录将中文转为拼音的解决办法
浏览:
Code=''gb2312'') {
Wordpress 相册插件 NextGEN-Gallery 添加目录将中文转为拼音的解决办法_网学
Wordpress 相册插件 NextGEN-Gallery 添加目录将中文转为拼音的解决办法
浏览:
DataKey = "a|ai|an|ang|ao|ba|bai|ban|bang|bao|bei|ben|beng|bi|bian|biao|bie|bin|bing|bo|bu|ca|cai|can|cang|cao|ce|ceng|cha" .
"|chai|chan|chang|chao|che|chen|cheng|chi|chong|chou|chu|chuai|chuan|chuang|chui|chun|chuo|ci|cong|cou|cu|" .
"cuan|cui|cun|cuo|da|dai|dan|dang|dao|de|deng|di|dian|diao|die|ding|diu|dong|dou|du|duan|dui|dun|duo|e|en|er" .
"|fa|fan|fang|fei|fen|feng|fo|fou|fu|ga|gai|gan|gang|gao|ge|gei|gen|geng|gong|gou|gu|gua|guai|guan|guang|gui" .
"|gun|guo|ha|hai|han|hang|hao|he|hei|hen|heng|hong|hou|hu|hua|huai|huan|huang|hui|hun|huo|ji|jia|jian|jiang" .
"|jiao|jie|jin|jing|jiong|jiu|ju|juan|jue|jun|ka|kai|kan|kang|kao|ke|ken|keng|kong|kou|ku|kua|kuai|kuan|kuang" .
"|kui|kun|kuo|la|lai|lan|lang|lao|le|lei|leng|li|lia|lian|liang|liao|lie|lin|ling|liu|long|lou|lu|lv|luan|lue" .
"|lun|luo|ma|mai|man|mang|mao|me|mei|men|meng|mi|mian|miao|mie|min|ming|miu|mo|mou|mu|na|nai|nan|nang|nao|ne" .
"|nei|nen|neng|ni|nian|niang|niao|nie|nin|ning|niu|nong|nu|nv|nuan|nue|nuo|o|