* finish task #2733.
This commit is contained in:
@@ -81,6 +81,57 @@ class html extends baseHTML
|
||||
global $lang;
|
||||
return "<div class='checkbox $appendClass'><label><input type='checkbox' data-scope='$scope' class='rows-selector'> $lang->select</label></div>";
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成select标签。
|
||||
* Create tags like "<select><option></option></select>"
|
||||
*
|
||||
* @param string $name the name of the select tag.
|
||||
* @param array $options the array to create select tag from.
|
||||
* @param string $selectedItems the item(s) to be selected, can like item1,item2.
|
||||
* @param string $attrib other params such as multiple, size and style.
|
||||
* @param string $append adjust if add options[$selectedItems].
|
||||
* @static
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
static public function select($name = '', $options = array(), $selectedItems = "", $attrib = "", $append = false)
|
||||
{
|
||||
global $app;
|
||||
static $dataKeys = array();
|
||||
|
||||
$options = (array)($options);
|
||||
if($append and !isset($options[$selectedItems])) $options[$selectedItems] = $selectedItems;
|
||||
if(!is_array($options) or empty($options)) return false;
|
||||
|
||||
/* The begin. */
|
||||
$id = $name;
|
||||
if(strpos($name, '[') !== false) $id = trim(str_replace(']', '', str_replace('[', '', $name)));
|
||||
$id = "id='{$id}'";
|
||||
if(strpos($attrib, 'id=') !== false) $id = '';
|
||||
|
||||
$string = "<select name='$name' {$id} $attrib>\n";
|
||||
|
||||
/* The options. */
|
||||
$pinyin = $app->loadClass('pinyin');
|
||||
if(is_array($selectedItems)) $selectedItems = implode(',', $selectedItems);
|
||||
$selectedItems = ",$selectedItems,";
|
||||
foreach($options as $key => $value)
|
||||
{
|
||||
if(!isset($dataKeys[$value]))
|
||||
{
|
||||
$dataKeys[$value] = '';
|
||||
$permalink = $pinyin->permalink($value, '');
|
||||
if($value != $permalink) $dataKeys[$value] = $permalink . ' ' . $pinyin->abbr($value, '');
|
||||
}
|
||||
$key = str_replace('item', '', $key);
|
||||
$selected = strpos($selectedItems, ",$key,") !== false ? " selected='selected'" : '';
|
||||
$string .= "<option value='$key'$selected data-keys='{$dataKeys[$value]}'>$value</option>\n";
|
||||
}
|
||||
|
||||
/* End. */
|
||||
return $string .= "</select>\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
return array (
|
||||
'万俟' => ' mò qí',
|
||||
'尉迟' => ' yù chí',
|
||||
'单于' => ' chán yú',
|
||||
'不' => ' fǒu',
|
||||
'沈' => ' shěn',
|
||||
'称' => ' chēng',
|
||||
'车' => ' chē',
|
||||
'万' => ' wàn',
|
||||
'汤' => ' tāng',
|
||||
'阿' => ' ā',
|
||||
'丁' => ' dīng',
|
||||
'强' => ' qiáng',
|
||||
'仇' => ' qiú',
|
||||
'叶' => ' yè',
|
||||
'阚' => ' kàn',
|
||||
'乐' => ' yuè',
|
||||
'乜' => ' niè',
|
||||
'陆' => ' lù',
|
||||
'殷' => ' yīn',
|
||||
'牟' => ' móu',
|
||||
'区' => ' ōu',
|
||||
'宿' => ' sù',
|
||||
'俞' => ' yú',
|
||||
'余' => ' yú',
|
||||
'齐' => ' qí',
|
||||
'许' => ' xǔ',
|
||||
'信' => ' xìn',
|
||||
'无' => ' wú',
|
||||
'浣' => ' wǎn',
|
||||
'艾' => ' ài',
|
||||
'浅' => ' qiǎn',
|
||||
'烟' => ' yān',
|
||||
'蓝' => ' lán',
|
||||
'於' => ' yú',
|
||||
'寻' => ' xún',
|
||||
'殳' => ' shū',
|
||||
'思' => ' sī',
|
||||
'鸟' => ' niǎo',
|
||||
'卜' => ' bǔ',
|
||||
'单' => ' shàn',
|
||||
'南' => ' nán',
|
||||
'柏' => ' bǎi',
|
||||
'朴' => ' piáo',
|
||||
'繁' => ' pó',
|
||||
'曾' => ' zēng',
|
||||
'瞿' => ' qú',
|
||||
'缪' => ' miào',
|
||||
'石' => ' shí',
|
||||
'冯' => ' féng',
|
||||
'覃' => ' qín',
|
||||
'幺' => ' yāo',
|
||||
'种' => ' chóng',
|
||||
'折' => ' shè',
|
||||
'燕' => ' yān',
|
||||
'纪' => ' jǐ',
|
||||
'过' => ' guō',
|
||||
'华' => ' huà',
|
||||
'冼' => ' xiǎn',
|
||||
'秘' => ' bì',
|
||||
'重' => ' chóng',
|
||||
'解' => ' xiè',
|
||||
'那' => ' nā',
|
||||
'和' => ' hé',
|
||||
'贾' => ' jiǎ',
|
||||
'塔' => ' tǎ',
|
||||
'盛' => ' shèng',
|
||||
'查' => ' zhā',
|
||||
'盖' => ' gě',
|
||||
'居' => ' jū',
|
||||
'哈' => ' hǎ',
|
||||
'的' => ' dē',
|
||||
'薄' => ' bó',
|
||||
'佴' => ' nài',
|
||||
'六' => ' lù',
|
||||
'都' => ' dū',
|
||||
'翟' => ' zhái',
|
||||
'扎' => ' zā',
|
||||
'藏' => ' zàng',
|
||||
'粘' => ' niàn',
|
||||
'难' => ' nàn',
|
||||
'若' => ' ruò',
|
||||
);
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/pinyin.
|
||||
*
|
||||
* (c) 2016 overtrue <i@overtrue.me>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dict loader interface.
|
||||
*/
|
||||
interface DictLoaderInterface
|
||||
{
|
||||
/**
|
||||
* Load dict.
|
||||
*
|
||||
* <pre>
|
||||
* [
|
||||
* '响应时间' => "[\t]xiǎng[\t]yìng[\t]shí[\t]jiān",
|
||||
* '长篇连载' => '[\t]cháng[\t]piān[\t]lián[\t]zǎi',
|
||||
* //...
|
||||
* ]
|
||||
* </pre>
|
||||
*
|
||||
* @param Closure $callback
|
||||
*/
|
||||
public function map(Closure $callback);
|
||||
|
||||
/**
|
||||
* Load surname dict.
|
||||
*
|
||||
* @param Closure $callback
|
||||
*/
|
||||
public function mapSurname(Closure $callback);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/pinyin.
|
||||
*
|
||||
* (c) 2016 overtrue <i@overtrue.me>
|
||||
*/
|
||||
|
||||
helper::import(__DIR__ . '/dictloaderinterface.php');
|
||||
/**
|
||||
* Dict File loader.
|
||||
*/
|
||||
class FileDictLoader implements DictLoaderInterface
|
||||
{
|
||||
/**
|
||||
* Words segment name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $segmentName = 'words_%s';
|
||||
|
||||
/**
|
||||
* Dict path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $path
|
||||
*/
|
||||
public function __construct($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load dict.
|
||||
*
|
||||
* @param Closure $callback
|
||||
*/
|
||||
public function map(Closure $callback)
|
||||
{
|
||||
for ($i = 0; $i < 100; ++$i) {
|
||||
$segment = $this->path.'/'.sprintf($this->segmentName, $i);
|
||||
|
||||
if (file_exists($segment)) {
|
||||
$dictionary = (array) include $segment;
|
||||
$callback($dictionary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load surname dict.
|
||||
*
|
||||
* @param Closure $callback
|
||||
*/
|
||||
public function mapSurname(Closure $callback)
|
||||
{
|
||||
$surnames = $this->path.'/surnames';
|
||||
|
||||
if (file_exists($surnames)) {
|
||||
$dictionary = (array) include $surnames;
|
||||
$callback($dictionary);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/pinyin.
|
||||
*
|
||||
* (c) 2016 overtrue <i@overtrue.me>
|
||||
*/
|
||||
|
||||
helper::import(__DIR__ . '/filedictloader.php');
|
||||
|
||||
define('PINYIN_NONE', 'none');
|
||||
define('PINYIN_ASCII', 'ascii');
|
||||
define('PINYIN_UNICODE', 'unicode');
|
||||
|
||||
/**
|
||||
* Chinese to pinyin translator.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
* @copyright 2015 overtrue <i@overtrue.me>
|
||||
*
|
||||
* @link https://github.com/overtrue/pinyin
|
||||
* @link http://overtrue.me
|
||||
*/
|
||||
class pinyin
|
||||
{
|
||||
const NONE = 'none';
|
||||
const ASCII = 'ascii';
|
||||
const UNICODE = 'unicode';
|
||||
|
||||
/**
|
||||
* Dict loader.
|
||||
*
|
||||
* @var \Overtrue\Pinyin\DictLoaderInterface
|
||||
*/
|
||||
protected $loader;
|
||||
|
||||
/**
|
||||
* Punctuations map.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $punctuations = array(
|
||||
',' => ',',
|
||||
'。' => '.',
|
||||
'!' => '!',
|
||||
'?' => '?',
|
||||
':' => ':',
|
||||
'“' => '"',
|
||||
'”' => '"',
|
||||
'‘' => "'",
|
||||
'’' => "'",
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param \Overtrue\Pinyin\DictLoaderInterface $loader
|
||||
*/
|
||||
public function __construct(DictLoaderInterface $loader = null)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert string to pinyin.
|
||||
*
|
||||
* @param string $string
|
||||
* @param string $option
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function convert($string, $option = self::NONE)
|
||||
{
|
||||
$pinyin = $this->romanize($string);
|
||||
|
||||
return $this->splitWords($pinyin, $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert string (person name) to pinyin.
|
||||
*
|
||||
* @param string $stringName
|
||||
* @param string $option
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function name($stringName, $option = self::NONE)
|
||||
{
|
||||
$pinyin = $this->romanize($stringName, true);
|
||||
|
||||
return $this->splitWords($pinyin, $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pinyin permalink from string.
|
||||
*
|
||||
* @param string $string
|
||||
* @param string $delimiter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permalink($string, $delimiter = '-')
|
||||
{
|
||||
if (!in_array($delimiter, array('_', '-', '.', ''), true)) {
|
||||
throw new InvalidArgumentException("Delimiter must be one of: '_', '-', '', '.'.");
|
||||
}
|
||||
|
||||
return implode($delimiter, $this->convert($string, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return first letters.
|
||||
*
|
||||
* @param string $string
|
||||
* @param string $delimiter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function abbr($string, $delimiter = '')
|
||||
{
|
||||
return implode($delimiter, array_map(function ($pinyin) {
|
||||
return $pinyin[0];
|
||||
}, $this->convert($string, false)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Chinese to pinyin sentense.
|
||||
*
|
||||
* @param string $sentence
|
||||
* @param string $option
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sentence($sentence, $withTone = false)
|
||||
{
|
||||
$marks = array_keys($this->punctuations);
|
||||
$punctuationsRegex = preg_quote(implode(array_merge($marks, $this->punctuations)), '/');
|
||||
$regex = '/[^üāēīōūǖáéíóúǘǎěǐǒǔǚàèìòùǜa-z0-9'.$punctuationsRegex.'\s_]+/iu';
|
||||
|
||||
$pinyin = preg_replace($regex, '', $this->romanize($sentence));
|
||||
|
||||
$punctuations = array_merge($this->punctuations, array("\t" => ' ', ' ' => ' '));
|
||||
$pinyin = trim(str_replace(array_keys($punctuations), $punctuations, $pinyin));
|
||||
|
||||
return $withTone ? $pinyin : $this->format($pinyin, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loader setter.
|
||||
*
|
||||
* @param \Overtrue\Pinyin\DictLoaderInterface $loader
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLoader(DictLoaderInterface $loader)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dict loader,.
|
||||
*
|
||||
* @return \Overtrue\Pinyin\DictLoaderInterface
|
||||
*/
|
||||
public function getLoader()
|
||||
{
|
||||
return $this->loader ?: new FileDictLoader(__DIR__ . '/data/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess.
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function prepare($string)
|
||||
{
|
||||
$string = preg_replace_callback('~[a-z0-9_-]+~i', function ($matches) {
|
||||
return "\t".$matches[0];
|
||||
}, $string);
|
||||
|
||||
return preg_replace("~[^\p{Han}\p{P}\p{Z}\p{M}\p{N}\p{L}\t]~u", '', $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Chinese to pinyin.
|
||||
*
|
||||
* @param string $string
|
||||
* @param bool $isName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function romanize($string, $isName = false)
|
||||
{
|
||||
$string = $this->prepare($string);
|
||||
|
||||
$dictLoader = $this->getLoader();
|
||||
|
||||
if ($isName) {
|
||||
$string = $this->convertSurname($string, $dictLoader);
|
||||
}
|
||||
|
||||
$dictLoader->map(function ($dictionary) use (&$string) {
|
||||
$string = strtr($string, $dictionary);
|
||||
});
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Chinese Surname to pinyin.
|
||||
*
|
||||
* @param string $string
|
||||
* @param \Overtrue\Pinyin\DictLoaderInterface $dictLoader
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function convertSurname($string, $dictLoader)
|
||||
{
|
||||
$dictLoader->mapSurname(function ($dictionary) use (&$string) {
|
||||
foreach ($dictionary as $surname => $pinyin) {
|
||||
if (strpos($string, $surname) === 0) {
|
||||
$string = $pinyin.mb_substr($string, mb_strlen($surname, 'UTF-8'), mb_strlen($string, 'UTF-8') - 1, 'UTF-8');
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split pinyin string to words.
|
||||
*
|
||||
* @param string $pinyin
|
||||
* @param string $option
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function splitWords($pinyin, $option)
|
||||
{
|
||||
$split = array_filter(preg_split('/[^üāēīōūǖáéíóúǘǎěǐǒǔǚàèìòùǜa-z\d]+/iu', $pinyin));
|
||||
|
||||
if ($option !== self::UNICODE) {
|
||||
foreach ($split as $index => $pinyin) {
|
||||
$split[$index] = $this->format($pinyin, $option === self::ASCII);
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($split);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format.
|
||||
*
|
||||
* @param string $pinyin
|
||||
* @param bool $tone
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function format($pinyin, $tone = false)
|
||||
{
|
||||
$replacements = array(
|
||||
'üē' => array('ue', 1), 'üé' => array('ue', 2), 'üě' => array('ue', 3), 'üè' => array('ue', 4),
|
||||
'ā' => array('a', 1), 'ē' => array('e', 1), 'ī' => array('i', 1), 'ō' => array('o', 1), 'ū' => array('u', 1), 'ǖ' => array('v', 1),
|
||||
'á' => array('a', 2), 'é' => array('e', 2), 'í' => array('i', 2), 'ó' => array('o', 2), 'ú' => array('u', 2), 'ǘ' => array('v', 2),
|
||||
'ǎ' => array('a', 3), 'ě' => array('e', 3), 'ǐ' => array('i', 3), 'ǒ' => array('o', 3), 'ǔ' => array('u', 3), 'ǚ' => array('v', 3),
|
||||
'à' => array('a', 4), 'è' => array('e', 4), 'ì' => array('i', 4), 'ò' => array('o', 4), 'ù' => array('u', 4), 'ǜ' => array('v', 4),
|
||||
);
|
||||
|
||||
foreach ($replacements as $unicde => $replacements) {
|
||||
if (false !== strpos($pinyin, $unicde)) {
|
||||
$pinyin = str_replace($unicde, $replacements[0], $pinyin).($tone ? $replacements[1] : '');
|
||||
}
|
||||
}
|
||||
|
||||
return $pinyin;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
.outer .main-side > fieldset {padding-right: 0px;}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
.outer .main-side > fieldset {padding-right: 0px;}
|
||||
|
||||
@@ -53,6 +53,7 @@ foreach(explode(',', $showFields) as $field)
|
||||
<tbody>
|
||||
<?php foreach($storyIDList as $storyID):?>
|
||||
<?php
|
||||
if(!isset($stories[$storyID])) continue;
|
||||
if(!$productID)
|
||||
{
|
||||
$product = $this->product->getByID($stories[$storyID]->product);
|
||||
|
||||
@@ -598,7 +598,7 @@ body {color:#141414; padding-bottom: 40px;}
|
||||
.outer .main ul.list-unstyled li {padding: 2px 0}
|
||||
|
||||
.outer .main .table tr > th:first-child, .outer .main .table tr > td:first-child {padding-left: 0;}
|
||||
.outer .main-side > fieldset {padding: 5px 0px 10px 10px;}
|
||||
.outer .main-side > fieldset {padding: 5px 20px 10px 10px;}
|
||||
.outer .main-side > fieldset > .table {border: none}
|
||||
|
||||
.outer .main .tabs {margin-bottom: 15px;}
|
||||
|
||||
Reference in New Issue
Block a user