Skip to content

Commit

Permalink
初始化
Browse files Browse the repository at this point in the history
修改了上一个版本的一些错误,第一次提交
  • Loading branch information
joyqi committed Jul 17, 2013
0 parents commit 55379c9
Show file tree
Hide file tree
Showing 531 changed files with 80,105 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.*.swp
.*.swo
._*
.DS_Store
/Debug/
/ImgCache/
/Backup_rar/
/Debug/
/debug/
/upload/
/avatar/
/.idea/
.svn/
*.orig
*.aps
*.APS
*.chm
*.exp
*.pdb
*.rar
.smbdelete*
*.sublime*
.sass-cache
config.rb
/config.inc.php
111 changes: 111 additions & 0 deletions admin/common-js.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php if(!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<script type="text/javascript" src="<?php $options->adminUrl('javascript/mootools.js?v=' . $suffixVersion); ?>"></script>
<script type="text/javascript" src="<?php $options->adminUrl('javascript/typecho.js?v=' . $suffixVersion); ?>"></script>
<script type="text/javascript">
(function () {
window.addEvent('domready', function() {
var _d = $(document);
var handle = new Typecho.guid('typecho:guid', {offset: 1, type: 'mouse'});

//增加高亮效果
(function () {
var _hlId = '<?php echo $notice->highlight; ?>';

if (_hlId) {
var _hl = _d.getElement('#' + _hlId);

if (_hl) {
_hl.set('tween', {duration: 1500});

var _bg = _hl.getStyle('background-color');
if (!_bg || 'transparent' == _bg) {
_bg = '#F7FBE9';
}

_hl.tween('background-color', '#AACB36', _bg);
}
}
})();

//增加淡出效果
(function () {
var _msg = _d.getElement('.popup');

if (_msg) {
(function () {

var _messageEffect = new Fx.Morph(this, {
duration: 'short',
transition: Fx.Transitions.Sine.easeOut
});

_messageEffect.addEvent('complete', function () {
this.element.setStyle('display', 'none');
});

_messageEffect.start({'margin-top': [30, 0], 'height': [21, 0], 'opacity': [1, 0]});

}).delay(5000, _msg);
}
})();

//增加滚动效果,滚动到上面的一条error
(function () {
var _firstError = _d.getElement('.typecho-option .error');

if (_firstError) {
var _errorFx = new Fx.Scroll(window).toElement(_firstError.getParent('.typecho-option'));
}
})();

//禁用重复提交
(function () {
_d.getElements('input[type=submit]').removeProperty('disabled');
_d.getElements('button[type=submit]').removeProperty('disabled');

var _disable = function (e) {
e.stopPropagation();

this.setProperty('disabled', true);
this.getParent('form').submit();

return false;
};

_d.getElements('input[type=submit]').addEvent('click', _disable);
_d.getElements('button[type=submit]').addEvent('click', _disable);
})();

//打开链接
(function () {

_d.getElements('a').each(function (item) {
var _href = item.href;

if (_href && 0 != _href.indexOf('#')) {
//确认框
item.addEvent('click', function (event) {
var _lang = this.get('lang');
var _c = _lang ? confirm(_lang) : true;

if (!_c) {
event.stop();
}
});

/** 如果匹配则继续 */
if (/^<?php echo preg_quote($options->adminUrl, '/'); ?>.*$/.exec(_href)
|| /^<?php echo substr(preg_quote(Typecho_Common::url('s', $options->index), '/'), 0, -1); ?>action\/[_a-zA-Z0-9\/]+.*$/.exec(_href)) {
return;
}

item.set('target', '_blank');
}
});
})();

Typecho.Table.init('.typecho-list-table');
Typecho.Table.init('.typecho-list-notable');
});
})();
</script>
57 changes: 57 additions & 0 deletions admin/common.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
if (!defined('__DIR__')) {
define('__DIR__', dirname(__FILE__));
}

/** 载入配置文件 */
if (!@include_once __DIR__ . '/../config.inc.php') {
file_exists(__DIR__ . '/../install.php') ? header('Location: ../install.php') : print('Missing Config File');
exit;
}

/** 初始化组件 */
Typecho_Widget::widget('Widget_Init');

/** 注册一个初始化插件 */
Typecho_Plugin::factory('admin/common.php')->begin();

Typecho_Widget::widget('Widget_Options')->to($options);
Typecho_Widget::widget('Widget_User')->to($user);
Typecho_Widget::widget('Widget_Notice')->to($notice);
Typecho_Widget::widget('Widget_Menu')->to($menu);

/** 初始化上下文 */
$request = $options->request;
$response = $options->response;

/** 检测是否是第一次登录 */
$currentMenu = $menu->getCurrentMenu();
list($prefixVersion, $suffixVersion) = explode('/', $options->version);
$params = parse_url($currentMenu[2]);
$adminFile = basename($params['path']);

if (!$user->logged && !Typecho_Cookie::get('__typecho_first_run') && !empty($currentMenu)) {

if ('welcome.php' != $adminFile) {
$response->redirect(Typecho_Common::url('welcome.php', $options->adminUrl));
} else {
Typecho_Cookie::set('__typecho_first_run', 1);
}

} else {

/** 检测版本是否升级 */
if ($user->pass('administrator', true) && !empty($currentMenu)) {
$mustUpgrade = (!defined('Typecho_Common::VERSION') || version_compare(str_replace('/', '.', Typecho_Common::VERSION),
str_replace('/', '.', $options->version), '>'));

if ($mustUpgrade && 'upgrade.php' != $currentMenu[2]) {
$response->redirect(Typecho_Common::url('upgrade.php', $options->adminUrl));
} else if (!$mustUpgrade && 'upgrade.php' == $currentMenu[2]) {
$response->redirect(Typecho_Common::url('index.php', $options->adminUrl));
} else if (!$mustUpgrade && 'welcome.php' == $currentMenu[2] && $user->logged) {
$response->redirect(Typecho_Common::url('index.php', $options->adminUrl));
}
}

}
13 changes: 13 additions & 0 deletions admin/copyright.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php if(!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<div class="typecho-foot">
<h4><a href="http://typecho.org" class="logo-dark">typecho</a></h4>
<div class="copyright"><?php _e('基于 <em>%s %s</em> <small> | %s</small> 构建', $options->software, $prefixVersion, $suffixVersion); ?></div>
<div class="resource">
<ul>
<li><a href="http://docs.typecho.org"><?php _e('文档'); ?></a></li>
<li><a href="http://forum.typecho.org"><?php _e('支持论坛'); ?></a></li>
<li><a href="http://code.google.com/p/typecho/issues/entry"><?php _e('报告错误'); ?></a></li>
<li><a href="http://extends.typecho.org"><?php _e('其他资源'); ?></a></li>
</ul>
</div>
</div>
Loading

0 comments on commit 55379c9

Please sign in to comment.