This commit is contained in:
fen
2013-10-19 12:04:46 +08:00
10 changed files with 55 additions and 46 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/**
* 件管理列表
* 件管理列表
*
* @category typecho
* @package Widget
@@ -10,7 +10,7 @@
*/
/**
* 件管理列表组件
* 件管理列表组件
*
* @category typecho
* @package Widget
@@ -78,7 +78,7 @@ class Widget_Contents_Attachment_Admin extends Widget_Abstract_Contents
/** 构建基础查询 */
$select = $this->select()->where('table.contents.type = ?', 'attachment');
/** 如果具有编辑以上权限,可以查看所有件,反之只能查看自己的件 */
/** 如果具有编辑以上权限,可以查看所有件,反之只能查看自己的件 */
if (!$this->user->pass('editor', true)) {
$select->where('table.contents.authorId = ?', $this->user->uid);
}
+20 -20
View File
@@ -24,7 +24,7 @@ class Widget_Contents_Attachment_Edit extends Widget_Contents_Post_Edit implemen
* 获取页面偏移的URL Query
*
* @access protected
* @param integer $cid 件id
* @param integer $cid 件id
* @param string $status 状态
* @return string
*/
@@ -54,7 +54,7 @@ class Widget_Contents_Attachment_Edit extends Widget_Contents_Post_Edit implemen
->limit(1), array($this, 'push'));
if (!$this->have()) {
throw new Typecho_Widget_Exception(_t('件不存在'), 404);
throw new Typecho_Widget_Exception(_t('件不存在'), 404);
} else if ($this->have() && !$this->allow('edit')) {
throw new Typecho_Widget_Exception(_t('没有编辑权限'), 403);
}
@@ -62,10 +62,10 @@ class Widget_Contents_Attachment_Edit extends Widget_Contents_Post_Edit implemen
}
/**
* 判断件名转换到缩略名后是否合法
* 判断件名转换到缩略名后是否合法
*
* @access public
* @param string $name 件名
* @param string $name 件名
* @return boolean
*/
public function nameToSlug($name)
@@ -81,7 +81,7 @@ class Widget_Contents_Attachment_Edit extends Widget_Contents_Post_Edit implemen
}
/**
* 判断件缩略名是否存在
* 判断件缩略名是否存在
*
* @access public
* @param string $slug 缩略名
@@ -116,18 +116,18 @@ class Widget_Contents_Attachment_Edit extends Widget_Contents_Post_Edit implemen
$form = new Typecho_Widget_Helper_Form(Typecho_Common::url('/action/contents-attachment-edit', $this->options->index),
Typecho_Widget_Helper_Form::POST_METHOD);
/** 件名称 */
/** 件名称 */
$name = new Typecho_Widget_Helper_Form_Element_Text('name', NULL, $this->title, _t('标题 *'));
$form->addInput($name);
/** 件缩略名 */
/** 件缩略名 */
$slug = new Typecho_Widget_Helper_Form_Element_Text('slug', NULL, $this->slug, _t('缩略名'),
_t('件缩略名用于创建友好的链接形式,建议使用字母,数字,下划线和横杠.'));
_t('件缩略名用于创建友好的链接形式,建议使用字母,数字,下划线和横杠.'));
$form->addInput($slug);
/** 件描述 */
/** 件描述 */
$description = new Typecho_Widget_Helper_Form_Element_Textarea('description', NULL, $this->attachment->description,
_t('描述'), _t('此文字用于描述件,在有的主题中它会被显示.'));
_t('描述'), _t('此文字用于描述件,在有的主题中它会被显示.'));
$form->addInput($description);
/** 分类动作 */
@@ -144,19 +144,19 @@ class Widget_Contents_Attachment_Edit extends Widget_Contents_Post_Edit implemen
$delete = new Typecho_Widget_Helper_Layout('a', array('href' =>
Typecho_Common::url('/action/contents-attachment-edit?do=delete&cid=' . $this->cid, $this->options->index),
'class' => 'operate-delete',
'lang' => _t('你确认删除件 %s 吗?', $this->attachment->name)));
$submit->container($delete->html(_t('删除件')));
'lang' => _t('你确认删除件 %s 吗?', $this->attachment->name)));
$submit->container($delete->html(_t('删除件')));
$form->addItem($submit);
$name->addRule('required', _t('必须填写件标题'));
$name->addRule(array($this, 'nameToSlug'), _t('件标题无法被转换为缩略名'));
$name->addRule('required', _t('必须填写件标题'));
$name->addRule(array($this, 'nameToSlug'), _t('件标题无法被转换为缩略名'));
$slug->addRule(array($this, 'slugExists'), _t('缩略名已经存在'));
return $form;
}
/**
* 更新
* 更新
*
* @access public
* @return void
@@ -195,8 +195,8 @@ class Widget_Contents_Attachment_Edit extends Widget_Contents_Post_Edit implemen
/** 提示信息 */
$this->widget('Widget_Notice')->set('publish' == $this->status ?
_t('件 <a href="%s">%s</a> 已经被更新', $this->permalink, $this->title) :
_t('未归档件 %s 已经被更新', $this->title), NULL, 'success');
_t('件 <a href="%s">%s</a> 已经被更新', $this->permalink, $this->title) :
_t('未归档件 %s 已经被更新', $this->title), NULL, 'success');
}
@@ -246,11 +246,11 @@ class Widget_Contents_Attachment_Edit extends Widget_Contents_Post_Edit implemen
}
if ($this->request->isAjax()) {
$this->response->throwJson($deleteCount > 0 ? array('code' => 200, 'message' => _t('件已经被删除'))
: array('code' => 500, 'message' => _t('没有件被删除')));
$this->response->throwJson($deleteCount > 0 ? array('code' => 200, 'message' => _t('件已经被删除'))
: array('code' => 500, 'message' => _t('没有件被删除')));
} else {
/** 设置提示信息 */
$this->widget('Widget_Notice')->set($deleteCount > 0 ? _t('件已经被删除') : _t('没有件被删除'), NULL,
$this->widget('Widget_Notice')->set($deleteCount > 0 ? _t('件已经被删除') : _t('没有件被删除'), NULL,
$deleteCount > 0 ? 'success' : 'notice');
/** 返回原网页 */
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/**
* 文章相关
* 文章相关
*
* @category typecho
* @package Widget
@@ -10,7 +10,7 @@
*/
/**
* 文章相关件组件
* 文章相关件组件
*
* @category typecho
* @package Widget
@@ -37,7 +37,7 @@ class Widget_Contents_Attachment_Related extends Widget_Abstract_Contents
/** 构建基础查询 */
$select = $this->select()->where('table.contents.type = ?', 'attachment');
//order字段在件里代表所属文章
//order字段在件里代表所属文章
$select->where('table.contents.parent = ?', $this->parameter->parentId);
/** 提交查询 */
@@ -1,6 +1,6 @@
<?php
/**
* 没有关联的
* 没有关联的
*
* @category typecho
* @package Widget
@@ -10,7 +10,7 @@
*/
/**
* 没有关联的件组件
* 没有关联的件组件
*
* @category typecho
* @package Widget