mirror of
https://github.com/typecho/typecho.git
synced 2025-04-21 02:01:52 +02:00
parent
d520a556cf
commit
81ad2232bf
@ -176,14 +176,13 @@ $isAllPosts = ('on' == $request->get('__typecho_all_posts') || 'on' == \Typecho\
|
||||
<td class="kit-hidden-mb"><a
|
||||
href="<?php $options->adminUrl('manage-posts.php?__typecho_all_posts=off&uid=' . $posts->author->uid); ?>"><?php $posts->author(); ?></a>
|
||||
</td>
|
||||
<td class="kit-hidden-mb"><?php $categories = $posts->categories;
|
||||
while ($categories->next()): ?>
|
||||
<?php echo '<a href="';
|
||||
$options->adminUrl('manage-posts.php?category=' . $categories->mid
|
||||
<td class="kit-hidden-mb"><?php foreach($posts->categories as $index => $category): ?><!--
|
||||
--><?php echo ($index > 0 ? ', ' : '') . '<a href="';
|
||||
$options->adminUrl('manage-posts.php?category=' . $category['mid']
|
||||
. (isset($request->uid) ? '&uid=' . $request->filter('encode')->uid : '')
|
||||
. (isset($request->status) ? '&status=' . $request->filter('encode')->status : ''));
|
||||
echo '">' . $categories->name . '</a>' . ($categories->sequence < $categories->length - 1 ? ', ' : ''); ?>
|
||||
<?php endwhile; ?>
|
||||
echo '">' . $category['name'] . '</a>'; ?><!--
|
||||
--><?php endforeach; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ('post_draft' == $posts->type || $posts->revision): ?>
|
||||
|
@ -98,7 +98,7 @@ $post = \Widget\Contents\Post\Edit::alloc()->prepare();
|
||||
<label class="typecho-label"><?php _e('分类'); ?></label>
|
||||
<?php \Widget\Metas\Category\Rows::alloc()->to($category); ?>
|
||||
<ul>
|
||||
<?php $categories = $post->categories->toArray('mid'); ?>
|
||||
<?php $categories = array_column($post->categories, 'mid'); ?>
|
||||
<?php while ($category->next()): ?>
|
||||
<li><?php echo str_repeat(' ', $category->levels); ?><input
|
||||
type="checkbox" id="category-<?php $category->mid(); ?>"
|
||||
|
@ -365,6 +365,18 @@ abstract class Widget
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将所有行的值压入堆栈
|
||||
*
|
||||
* @param array $values 所有行的值
|
||||
*/
|
||||
public function pushAll(array $values)
|
||||
{
|
||||
foreach ($values as $value) {
|
||||
$this->push($value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据余数输出
|
||||
*
|
||||
@ -471,7 +483,10 @@ abstract class Widget
|
||||
*/
|
||||
public function __isSet(string $name)
|
||||
{
|
||||
return isset($this->row[$name]);
|
||||
$method = '___' . $name;
|
||||
$key = '#' . $name;
|
||||
|
||||
return isset($this->row[$key]) || method_exists($this, $method) || isset($this->row[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1624,7 +1624,7 @@ class Archive extends Contents
|
||||
$this->archiveTitle = $this->title;
|
||||
|
||||
/** 设置关键词 */
|
||||
$this->archiveKeywords = implode(',', $this->tags->toArray('name'));
|
||||
$this->archiveKeywords = implode(',', array_column($this->tags, 'name'));
|
||||
|
||||
/** 设置描述 */
|
||||
$this->archiveDescription = $this->plainExcerpt;
|
||||
|
@ -57,8 +57,8 @@ if (!defined('__TYPECHO_ROOT_DIR__')) {
|
||||
* @property-read Date $date
|
||||
* @property-read string $dateWord
|
||||
* @property-read string[] $directory
|
||||
* @property-read Metas $tags
|
||||
* @property-read Metas $categories
|
||||
* @property-read array[] $tags
|
||||
* @property-read array[] $categories
|
||||
* @property-read string $excerpt
|
||||
* @property-read string $plainExcerpt
|
||||
* @property-read string $summary
|
||||
@ -95,7 +95,7 @@ class Contents extends Base implements QueryInterface, RowFilterInterface, Prima
|
||||
case 'directory':
|
||||
return implode('/', array_map('urlencode', $this->directory));
|
||||
case 'category':
|
||||
return urlencode($this->categories->slug);
|
||||
return empty($this->categories) ? '' : urlencode($this->categories[0]['slug']);
|
||||
case 'year':
|
||||
return $this->date->year;
|
||||
case 'month':
|
||||
@ -461,13 +461,11 @@ class Contents extends Base implements QueryInterface, RowFilterInterface, Prima
|
||||
*/
|
||||
public function category(string $split = ',', bool $link = true, ?string $default = null)
|
||||
{
|
||||
$categories = $this->categories;
|
||||
|
||||
if ($categories->have()) {
|
||||
if (!empty($this->categories)) {
|
||||
$result = [];
|
||||
|
||||
while ($categories->next()) {
|
||||
$result[] = $link ? $categories->template('<a href="{permalink}">{name}</a>') : $categories->name;
|
||||
foreach ($this->categories as $category) {
|
||||
$result[] = $link ? "<a href=\"{$category['permalink']}\">{$category['name']}</a>" : $category['name'];
|
||||
}
|
||||
|
||||
echo implode($split, $result);
|
||||
@ -513,13 +511,11 @@ class Contents extends Base implements QueryInterface, RowFilterInterface, Prima
|
||||
*/
|
||||
public function tags(string $split = ',', bool $link = true, ?string $default = null)
|
||||
{
|
||||
$tags = $this->tags;
|
||||
|
||||
if ($tags->have()) {
|
||||
if (!empty($this->tags)) {
|
||||
$result = [];
|
||||
|
||||
while ($tags->next()) {
|
||||
$result[] = $link ? $tags->template('<a href="{permalink}">{name}</a>') : $tags->name;
|
||||
foreach ($this->tags as $tag) {
|
||||
$result[] = $link ? "<a href=\"{$tag['permalink']}\">{$tag['name']}</a>" : $tag['name'];
|
||||
}
|
||||
|
||||
echo implode($split, $result);
|
||||
@ -658,32 +654,32 @@ class Contents extends Base implements QueryInterface, RowFilterInterface, Prima
|
||||
{
|
||||
$directory = [];
|
||||
|
||||
$category = $this->categories;
|
||||
|
||||
if ($category->have()) {
|
||||
$directory = Rows::alloc()->getAllParentsSlug($category->mid);
|
||||
$directory[] = $category->slug;
|
||||
if (!empty($this->categories)) {
|
||||
$directory = Rows::alloc()->getAllParentsSlug($this->categories[0]['mid']);
|
||||
$directory[] = $this->categories[0]['slug'];
|
||||
}
|
||||
|
||||
return $directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Metas
|
||||
* @return array
|
||||
*/
|
||||
protected function ___categories(): Metas
|
||||
protected function ___categories(): array
|
||||
{
|
||||
return CategoryRelated::allocWithAlias($this->cid, ['cid' => $this->cid]);
|
||||
return CategoryRelated::allocWithAlias($this->cid, ['cid' => $this->cid])
|
||||
->toArray(['mid', 'name', 'slug', 'description', 'order', 'parent', 'count', 'permalink']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将tags取出
|
||||
*
|
||||
* @return Metas
|
||||
* @return array
|
||||
*/
|
||||
protected function ___tags(): Metas
|
||||
protected function ___tags(): array
|
||||
{
|
||||
return TagRelated::allocWithAlias($this->cid, ['cid' => $this->cid]);
|
||||
return TagRelated::allocWithAlias($this->cid, ['cid' => $this->cid])
|
||||
->toArray(['mid', 'name', 'slug', 'description', 'count', 'permalink']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,20 +44,18 @@ class Admin extends Contents
|
||||
$this->parameter->setDefault('ignoreRequest=0');
|
||||
|
||||
if ($this->parameter->ignoreRequest) {
|
||||
$this->stack = $this->getRows($this->orders, $this->parameter->ignore);
|
||||
$this->pushAll($this->getRows($this->orders, $this->parameter->ignore));
|
||||
} elseif ($this->request->is('keywords')) {
|
||||
$select = $this->select('table.contents.cid')
|
||||
->where('table.contents.type = ? OR table.contents.type = ?', 'page', 'page_draft');
|
||||
$this->searchQuery($select);
|
||||
|
||||
$ids = array_column($this->db->fetchAll($select), 'cid');
|
||||
$this->stack = $this->getRows($ids);
|
||||
$this->pushAll($this->getRows($ids));
|
||||
} else {
|
||||
$this->parentId = $this->request->filter('int')->get('parent', 0);
|
||||
$this->stack = $this->getRows($this->getChildIds($this->parentId));
|
||||
$this->pushAll($this->getRows($this->getChildIds($this->parentId)));
|
||||
}
|
||||
|
||||
$this->row = reset($this->stack);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,8 +32,7 @@ class Rows extends Contents
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$this->stack = $this->getRows($this->orders, $this->parameter->ignore);
|
||||
$this->row = reset($this->stack);
|
||||
$this->pushAll($this->getRows($this->orders, $this->parameter->ignore));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,14 +126,14 @@ trait PrepareEditTrait
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Metas
|
||||
* @return array
|
||||
*/
|
||||
protected function ___categories(): Metas
|
||||
protected function ___categories(): array
|
||||
{
|
||||
return $this->have() ? parent::___categories()
|
||||
: MetasFrom::allocWithAlias(
|
||||
'category:' . $this->options->defaultCategory,
|
||||
['mid' => $this->options->defaultCategory]
|
||||
);
|
||||
)->toArray(['mid', 'name', 'slug']);
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ class Feed extends Contents
|
||||
'link' => $archive->permalink,
|
||||
'author' => $archive->author,
|
||||
'excerpt' => $archive->plainExcerpt,
|
||||
'category' => $archive->categories->toArray(['name', 'permalink']),
|
||||
'category' => $archive->categories,
|
||||
'comments' => $archive->commentsNum,
|
||||
'commentsFeedUrl' => Common::url($archive->path, $feed->getFeedUrl()),
|
||||
'suffix' => $suffix
|
||||
|
@ -31,8 +31,7 @@ class Admin extends Metas
|
||||
public function execute()
|
||||
{
|
||||
$this->parentId = $this->request->filter('int')->get('parent', 0);
|
||||
$this->stack = $this->getRows($this->getChildIds($this->parentId));
|
||||
$this->row = reset($this->stack);
|
||||
$this->pushAll($this->getRows($this->getChildIds($this->parentId)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,6 @@ class Related extends Metas
|
||||
return $orderA <=> $orderB;
|
||||
});
|
||||
|
||||
$this->stack = $this->getRows($ids);
|
||||
$this->row = reset($this->stack);
|
||||
$this->pushAll($this->getRows($ids));
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,7 @@ class Rows extends Metas
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$this->stack = $this->getRows($this->orders, $this->parameter->ignore);
|
||||
$this->row = reset($this->stack);
|
||||
$this->pushAll($this->getRows($this->orders, $this->parameter->ignore));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user