本文整理汇总了PHP中ItemList::__toString方法的典型用法代码示例。如果您正苦于以下问题:PHP ItemList::__toString方法的具体用法?PHP ItemList::__toString怎么用?PHP ItemList::__toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemList
的用法示例。
在下文中一共展示了ItemList::__toString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listKeys
/**
* Display the list of the translation keys
*
* @param array $filters The filters to display the list
*/
public function listKeys($filters = array())
{
if (empty($filters)) {
$filters = $this->getFilters();
}
// Find all files in main-plugin, plugins dans userfiles
$files = array();
$dirs = array(MAIN_PLUGINS_DIR, PLUGINS_DIR, USERFILES_PLUGINS_DIR . Lang::TRANSLATIONS_DIR);
foreach ($dirs as $dir) {
if (is_dir($dir)) {
$result = App::fs()->find($dir, '*.*.lang', FileSystem::FIND_FILE_ONLY);
}
foreach ($result as $file) {
list($plugin, $language, $ext) = explode('.', basename($file));
if (empty($files[$plugin])) {
$files[$plugin] = array();
}
if (empty($files[$plugin][$language])) {
$files[$plugin][$language] = array();
}
$files[$plugin][$language][$dir == USERFILES_PLUGINS_DIR . Lang::TRANSLATIONS_DIR ? 'translation' : 'origin'] = $file;
}
}
$keys = array();
foreach ($files as $plugin => $languages) {
foreach ($languages as $tag => $paths) {
foreach ($paths as $name => $file) {
$translations = parse_ini_file($file);
foreach ($translations as $key => $value) {
if (!is_array($value)) {
// This is a single key
$langKey = "{$plugin}.{$key}";
if (empty($keys[$langKey])) {
$keys[$langKey] = array();
}
$keys[$langKey][$tag] = $value;
} else {
// This is a multiple key
foreach ($value as $multiplier => $val) {
$langKey = $plugin . '.' . $key . '[' . $multiplier . ']';
if (empty($keys[$langKey])) {
$keys[$langKey] = array();
}
$keys[$langKey][$tag] = $val;
}
}
}
}
}
}
$data = array();
foreach ($keys as $langKey => $values) {
if ($filters['keys'] != 'missing' || empty($values[$filters['tag']])) {
$data[] = (object) array('langKey' => $langKey, 'origin' => isset($values[Lang::DEFAULT_LANGUAGE]) ? $values[Lang::DEFAULT_LANGUAGE] : '', 'translation' => isset($values[$filters['tag']]) ? $values[$filters['tag']] : '');
}
}
$param = array('id' => 'language-key-list', 'action' => App::router()->getUri('language-keys-list'), 'data' => $data, 'controls' => array(array('type' => 'submit', 'icon' => 'save', 'label' => Lang::get('main.valid-button'), 'class' => 'btn-primary'), array('icon' => 'plus', 'label' => Lang::get('language.new-lang'), 'href' => App::router()->getUri('edit-language', array('tag' => 'new')), 'target' => 'dialog', 'class' => 'btn-success'), array('href' => App::router()->getUri('import-language-keys'), 'target' => 'dialog', 'icon' => 'download', 'label' => Lang::get('language.import-btn'), 'class' => 'btn-info')), 'fields' => array('langKey' => array('label' => Lang::get('language.key-list-key-label')), 'origin' => array('label' => Lang::get('language.key-list-default-translation-label', array('tag' => Lang::DEFAULT_LANGUAGE))), 'translation' => array('label' => Lang::get('language.key-list-default-translation-label', array('tag' => $filters['tag'])), 'display' => function ($value, $field, $line) use($filters) {
$key = str_replace(array('[', ']'), array('{', '}'), $line->langKey);
return "<textarea name='translation[{$filters['tag']}][{$key}]' cols='40' rows='5'>{$value}</textarea>";
}), 'clean' => array('search' => false, 'sort' => false, 'display' => function ($value, $field, $line) {
return Icon::make(array('icon' => 'undo', 'class' => 'text-danger delete-translation', 'title' => Lang::get('language.delete-translation-btn'), 'data-key' => $line->langKey));
})));
$list = new ItemList($param);
return $list->__toString();
}