本文整理汇总了PHP中Typecho_Common类的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Common类的具体用法?PHP Typecho_Common怎么用?PHP Typecho_Common使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Typecho_Common类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: theme
public function theme()
{
if ($theme = $this->request->get('theme')) {
$this->db->query($this->db->update('table.options')->rows(array('value' => $theme))->where('name=?', 'Duoshuo_theme'));
$this->response->redirect(Typecho_Common::url('extending.php?panel=Duoshuo/manage-duoshuo.php&do=manage-theme', $this->options->adminUrl));
}
}
示例2: config
/**
* 获取插件配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form 配置面板
* @return void
*/
public static function config(Typecho_Widget_Helper_Form $form)
{
if (isset($_GET['action']) && $_GET['action'] == 'deletefile') {
self::deletefile();
}
$listexpire = new Typecho_Widget_Helper_Form_Element_Text('listexpire', null, '43200', _t('歌单更新周期'), _t('设置歌单的缓存时间(单位:秒),超过设定时间后歌单将自动更新'));
$form->addInput($listexpire);
$maintheme = new Typecho_Widget_Helper_Form_Element_Text('maintheme', null, '#e6d0b2', _t('默认主题颜色'), _t('播放器默认的主题颜色,如 #372e21、#75c、red、blue,该设定会被[player]标签中的theme属性覆盖,默认为 #e6d0b2'));
$form->addInput($maintheme);
$nolyric = new Typecho_Widget_Helper_Form_Element_Text('nolyric', null, '找不到歌词', _t('找不到歌词时显示的文字'), _t('找不到歌词时显示的文字'));
$form->addInput($nolyric);
$mutex = new Typecho_Widget_Helper_Form_Element_Radio('mutex', array('false' => _t('是'), 'true' => _t('否')), 'true', _t('是否允许在一个页面中多个播放器同时播放'), _t('若选择否,当页面中存在多个播放器时,点击其中一个播放器的播放按钮,其它播放器将自动暂停'));
$form->addInput($mutex);
$preload = new Typecho_Widget_Helper_Form_Element_Radio('preload', array('false' => _t('自动'), 'none' => _t('none'), 'metadata' => _t('metadata'), 'auto' => _t('auto')), 'false', _t('音频预加载(preload)属性'), '自动:移动端为none,桌面端为metadata; none:页面加载后不预加载音频; metadata:当页面加载后仅加载音频的元数据; auto:一旦页面加载,则开始加载音频。');
$form->addInput($preload);
$cache = new Typecho_Widget_Helper_Form_Element_Radio('cache', array('false' => _t('否')), 'false', _t('清空缓存'), _t('清空插件生成的缓存文件,必要时可以使用'));
$form->addInput($cache);
$submit = new Typecho_Widget_Helper_Form_Element_Submit();
$submit->value(_t('清空歌词,专辑图片链接,在线歌曲缓存'));
$submit->setAttribute('style', 'position:relative;');
$submit->input->setAttribute('style', 'position:absolute;bottom:37px;');
$submit->input->setAttribute('class', 'btn btn-s btn-warn btn-operate');
$submit->input->setAttribute('formaction', Typecho_Common::url('/options-plugin.php?config=APlayer&action=deletefile', Helper::options()->adminUrl));
$form->addItem($submit);
}
示例3: writePage
/**
* 发布文章
*
* @access public
* @return void
*/
public function writePage()
{
$contents = $this->request->from('text', 'template', 'allowComment', 'allowPing', 'allowFeed', 'slug', 'order');
$contents['type'] = 'page';
$contents['title'] = $this->request->get('title', _t('未命名页面'));
$contents['created'] = $this->getCreated();
$contents = $this->pluginHandle()->write($contents, $this);
if ($this->request->is('do=publish')) {
/** 重新发布已经存在的文章 */
$this->publish($contents);
/** 发送ping */
$this->widget('Widget_Service')->sendPing($this->cid);
/** 设置提示信息 */
$this->widget('Widget_Notice')->set(_t('页面 "<a href="%s">%s</a>" 已经发布', $this->permalink, $this->title), NULL, 'success');
/** 设置高亮 */
$this->widget('Widget_Notice')->highlight($this->theId);
/** 页面跳转 */
$this->response->redirect(Typecho_Common::url('manage-pages.php?', $this->options->adminUrl));
} else {
/** 保存文章 */
$this->save($contents);
if ($this->request->isAjax()) {
$created = new Typecho_Date($this->options->gmtTime);
$this->response->throwJson(array('success' => 1, 'message' => _t('文章保存于 %s', $created->format('H:i A')), 'cid' => $this->cid));
} else {
/** 设置提示信息 */
$this->widget('Widget_Notice')->set(_t('草稿 "%s" 已经被保存', $this->title), NULL, 'success');
/** 返回原页面 */
$this->response->redirect(Typecho_Common::url('write-page.php?cid=' . $this->cid, $this->options->adminUrl));
}
}
}
示例4: getPosts
/**
* 返回所有的文章
* news:
* count:
* articles:
* [
* author:
* title:
* time:
* excerp:
* ]
* @return {}
*/
public function getPosts()
{
$_cats = $this->db->fetchAll($this->db->select('slug, name, mid, count, description')->from('table.metas')->where('type = ?', 'category'));
$_cat_item = array();
$res = array();
foreach ($_cats as $key => $value) {
$_articles_db = $this->db->fetchAll($this->db->select('table.contents.slug, table.contents.cid, table.contents.text, table.contents.title, table.contents.created, table.users.screenName')->from('table.contents')->join('table.relationships', 'table.relationships.cid = table.contents.cid')->join('table.users', 'table.users.uid = table.contents.authorId')->where('table.contents.status = ?', 'publish')->where('table.contents.type = ?', 'post')->where('table.relationships.mid = ?', $value['mid']));
//$_articles = array();
foreach ($_articles_db as $key => $_value_article) {
//$_value_article['slug'] = $_value_article[];
//$_value_article['title'] = $_value_article[];
$_value_article['author'] = $_value_article['screenName'];
unset($_value_article['screenName']);
$_value_article['excerp'] = Typecho_Common::subStr(strip_tags($_value_article['text']), 0, 100, '...');
unset($_value_article['text']);
$_value_article['time'] = $_value_article['created'];
unset($_value_article['created']);
/* 最好在上面内联选择出来 */
$_value_article['banner'] = self::getBanner($_value_article['cid']);
$_articles_db[$key] = $_value_article;
//$_articles[] = $_value_article;
}
$_cat_item['articles'] = $_articles_db;
$_cat_item['count'] = $value['count'];
$_cat_item['name'] = $value['name'];
$_cat_item['description'] = $value['description'];
$res[$value['slug']] = $_cat_item;
}
return $res;
}
示例5: render
/**
* 插件实现方法
*
* @access public
* @return void
*/
public static function render($post)
{
$options = Helper::options();
$js = Typecho_Common::url('TinyMCE/tiny_mce/tiny_mce.js', $options->pluginUrl);
$langs = Typecho_Common::url('extending.php?panel=TinyMCE/tiny_mce/langs.php', $options->adminUrl);
echo "<script type=\"text/javascript\" src=\"{$js}\"></script>\n<script type=\"text/javascript\" src=\"{$langs}\"></script>\n<script type=\"text/javascript\">\n var insertImageToEditor = function (title, url, link) {\n tinyMCE.activeEditor.execCommand('mceInsertContent', false,\n '<a href=\"' + link + '\" title=\"' + title + '\"><img src=\"' + url + '\" alt=\"' + title + '\" /></a>');\n new Fx.Scroll(window).toElement(\$(document).getElement('.mceEditor'));\n };\n \n var insertLinkToEditor = function (title, url, link) {\n tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href=\"' + url + '\" title=\"' + title + '\">' + title + '</a>');\n new Fx.Scroll(window).toElement(\$(document).getElement('.mceEditor'));\n };\n\n //自动保存\n var autoSave;\n \n tinyMCE.init({\n // General options\n mode : 'exact',\n elements : 'text',\n theme : 'advanced',\n skin : 'typecho',\n plugins : 'safari,morebreak,inlinepopups,media,coder',\n extended_valid_elements : 'code[*],pre[*],script[*],iframe[*]',\n \n init_instance_callback : function(ed) {\n \n ed.setContent(\"" . str_replace(array("\n", "\r"), array("\\n", ""), addslashes($post->content)) . "\");\n " . ($options->autoSave ? "autoSave = new Typecho.autoSave(\$('text').getParent('form').getProperty('action'), {\n time: 60,\n getContentHandle: tinyMCE.activeEditor.getContent.bind(ed),\n messageElement: 'auto-save-message',\n leaveMessage: '" . _t('您的内容尚未保存, 是否离开此页面?') . "',\n form: \$('text').getParent('form')\n });" : "") . "\n },\n \n onchange_callback: function (inst) {\n if ('undefined' != typeof(autoSave)) {\n autoSave.onContentChange();\n }\n },\n \n save_callback: function (element_id, html, body) {\n if ('undefined' != typeof(autoSave)) {\n autoSave.saveRev = autoSave.rev;\n }\n \n return html;\n },\n \n // Theme options\n theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,blockquote,|,link,unlink,image,media,|,forecolor,backcolor,|,morebreak,code',\n theme_advanced_buttons2 : '',\n theme_advanced_buttons3 : '',\n theme_advanced_toolbar_location : 'top',\n theme_advanced_toolbar_align : 'left',\n convert_urls : false,\n language : 'typecho'\n});\n</script>";
}
示例6: setBody
private function setBody()
{
if (empty($this->parameter->confirm)) {
throw new Typecho_Widget_Exception(_t('收件人不存在'), 404);
}
$this->parameter->siteTitle = $this->options->title;
$this->parameter->token = strtolower(Typecho_Common::randString(8));
$this->parameter->subject = $this->_type[$this->parameter->type];
switch ($this->parameter->type) {
case 'reset':
$url = '/forgot';
break;
case 'register':
$url = '/activate';
break;
default:
$url = '';
break;
}
if (!empty($url)) {
$this->parameter->url = Typecho_Common::url($url . '?token=' . $this->parameter->token, $this->options->index);
} else {
$this->parameter->url = $this->parameter->token;
}
$this->parameter->body = $this->parseBody();
return $this;
}
示例7: normalizeReference
/**
* Normalize reference label
*
* This enables case-insensitive label matching
*
* @param string $string
*
* @return string
*/
public static function normalizeReference($string)
{
// Collapse internal whitespace to single space and remove
// leading/trailing whitespace
$string = preg_replace('/\\s+/', '', trim($string));
return Typecho_Common::strToUpper($string, 'UTF-8');
}
示例8: execute
/**
* 执行函数
*
* @access public
* @return void
*/
public function execute()
{
$themes = $this->getThemes();
if ($themes) {
$options = $this->widget('Widget_Options');
$siteUrl = $options->siteUrl;
$adminUrl = $options->adminUrl;
$activated = 0;
$result = array();
foreach ($themes as $key => $theme) {
$themeFile = $theme . '/index.php';
if (file_exists($themeFile)) {
$info = Typecho_Plugin::parseInfo($themeFile);
$info['name'] = $this->getTheme($theme, $key);
if ($info['activated'] = $options->theme == $info['name']) {
$activated = $key;
}
$screen = glob($theme . '/screen*.{jpg,png,gif,bmp,jpeg,JPG,PNG,GIF,BMG,JPEG}', GLOB_BRACE);
if ($screen) {
$info['screen'] = $options->themeUrl(basename(current($screen)), $info['name']);
} else {
$info['screen'] = Typecho_Common::url('noscreen.png', $options->adminStaticUrl('img'));
}
$result[$key] = $info;
}
}
$clone = $result[$activated];
unset($result[$activated]);
array_unshift($result, $clone);
array_filter($result, array($this, 'push'));
}
}
示例9: execute
/**
* 执行函数
*
* @access public
* @return void
*/
public function execute()
{
$themes = glob(__TYPECHO_ROOT_DIR__ . __TYPECHO_THEME_DIR__ . '/*');
if ($themes) {
$options = $this->widget('Widget_Options');
$siteUrl = $options->siteUrl;
$adminUrl = $options->adminUrl;
$activated = 0;
$result = array();
foreach ($themes as $key => $theme) {
$themeFile = $theme . '/index.php';
if (file_exists($themeFile)) {
$info = Typecho_Plugin::parseInfo($themeFile);
$info['name'] = basename($theme);
if ($info['activated'] = $options->theme == $info['name']) {
$activated = $key;
}
$screen = glob($theme . '/screen*.{jpg,png,gif,bmp,jpeg,JPG,PNG,GIF,BMG,JPEG}', GLOB_BRACE);
if ($screen) {
$info['screen'] = Typecho_Common::url(trim(__TYPECHO_THEME_DIR__, '/') . '/' . $info['name'] . '/' . basename(current($screen)), $siteUrl);
} else {
$info['screen'] = Typecho_Common::url('/images/noscreen.gif', $adminUrl);
}
$result[$key] = $info;
}
}
$clone = $result[$activated];
unset($result[$activated]);
array_unshift($result, $clone);
array_filter($result, array($this, 'push'));
}
}
示例10: avatar
public function avatar()
{
$uid = $this->request->get('uid');
$size = $this->request->get('s');
if (!is_numeric($uid)) {
Typecho_Common::error(404);
exit;
}
$path = __TYPECHO_ROOT_DIR__ . Widget_Common::getAvatarPath($uid);
$path .= $uid . '.jpg';
if (!is_file($path)) {
$path = __TYPECHO_ROOT_DIR__ . '/usr/avatar/default.jpg';
}
require_once __TYPECHO_ROOT_DIR__ . '/var/Util/Image.php';
$image = new Image();
$image->open($path);
$type = $image->type();
if (is_numeric($size)) {
$image->thumb($size, $size);
}
header('Content-Type:image/' . $type . ';');
//输出图像
if ('jpeg' == $type || 'jpg' == $type) {
// 采用jpeg方式输出
imagejpeg($image->showImg());
} elseif ('gif' == $type) {
imagegif($image->showImg());
} else {
$fun = 'image' . $type;
$fun($image->showImg());
}
}
示例11: execute
/**
* 入口函数,初始化路由器
*
* @access public
* @return void
* @throws Typecho_Widget_Exception
*/
public function execute()
{
/** 验证路由地址 **/
$action = $this->request->action;
//兼容老版本
if (empty($action)) {
$widget = trim($this->request->widget, '/');
$objectName = 'Widget_' . str_replace('/', '_', $widget);
if (Typecho_Common::isAvailableClass($objectName)) {
$widgetName = $objectName;
}
} else {
/** 判断是否为plugin */
$actionTable = array_merge($this->_map, unserialize($this->widget('Widget_Options')->actionTable));
if (isset($actionTable[$action])) {
$widgetName = $actionTable[$action];
}
}
if (isset($widgetName) && class_exists($widgetName)) {
$reflectionWidget = new ReflectionClass($widgetName);
if ($reflectionWidget->implementsInterface('Widget_Interface_Do')) {
$this->widget($widgetName)->action();
return;
}
}
throw new Typecho_Widget_Exception(_t('请求的地址不存在'), 404);
}
示例12: setPrefix
/**
* 设置前缀
*
* @param string $url
* @access public
* @return void
*/
public static function setPrefix($url)
{
self::$_prefix = md5($url);
$parsed = parse_url($url);
/** 在路径后面强制加上斜杠 */
self::$_path = empty($parsed['path']) ? '/' : Typecho_Common::url(NULL, $parsed['path']);
}
示例13: execute
/**
* 入口函数,初始化路由器
*
* @access public
* @return void
*/
public function execute()
{
/** 对变量赋值 */
$options = $this->widget('Widget_Options');
/** 开始会话 */
@session_start();
/** 初始化charset */
Typecho_Common::$charset = $options->charset;
/** 初始化exception */
Typecho_Common::$exceptionHandle = 'Widget_ExceptionHandle';
/** 设置路径 */
if (defined('__TYPECHO_PATHINFO_ENCODING__')) {
$pathInfo = $this->request->getPathInfo(__TYPECHO_PATHINFO_ENCODING__, $options->charset);
} else {
$pathInfo = $this->request->getPathInfo();
}
Typecho_Router::setPathInfo($pathInfo);
/** 初始化路由器 */
Typecho_Router::setRoutes($options->routingTable);
/** 初始化插件 */
Typecho_Plugin::init($options->plugins);
/** 初始化回执 */
$this->response->setCharset($options->charset);
$this->response->setContentType($options->contentType);
/** 默认时区 */
if (!ini_get("date.timezone") && function_exists("date_default_timezone_set")) {
@date_default_timezone_set('UTC');
}
/** 初始化时区 */
Typecho_Date::setTimezoneOffset($options->timezone);
/** 监听缓冲区 */
ob_start();
}
示例14: config
/**
* 获取插件配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form 配置面板
* @return void
*/
public static function config(Typecho_Widget_Helper_Form $form)
{
$mode = new Typecho_Widget_Helper_Form_Element_Radio('mode', array('smtp' => 'smtp', 'mail' => 'mail()', 'sendmail' => 'sendmail()'), 'smtp', '发信方式');
$form->addInput($mode);
$host = new Typecho_Widget_Helper_Form_Element_Text('host', NULL, 'smtp.', _t('SMTP地址'), _t('请填写 SMTP 服务器地址'));
$form->addInput($host->addRule('required', _t('必须填写一个SMTP服务器地址')));
$port = new Typecho_Widget_Helper_Form_Element_Text('port', NULL, '25', _t('SMTP端口'), _t('SMTP服务端口,一般为25。'));
$port->input->setAttribute('class', 'mini');
$form->addInput($port->addRule('required', _t('必须填写SMTP服务端口'))->addRule('isInteger', _t('端口号必须是纯数字')));
$user = new Typecho_Widget_Helper_Form_Element_Text('user', NULL, NULL, _t('SMTP用户'), _t('SMTP服务验证用户名,一般为邮箱名如:youname@domain.com'));
$form->addInput($user->addRule('required', _t('SMTP服务验证用户名')));
$pass = new Typecho_Widget_Helper_Form_Element_Password('pass', NULL, NULL, _t('SMTP密码'));
$form->addInput($pass->addRule('required', _t('SMTP服务验证密码')));
$validate = new Typecho_Widget_Helper_Form_Element_Checkbox('validate', array('validate' => '服务器需要验证', 'ssl' => 'ssl加密'), array('validate'), 'SMTP验证');
$form->addInput($validate);
$token = new Typecho_Widget_Helper_Form_Element_Password('token', NULL, Typecho_Common::randString(7), _t('Token'), _t('请勿泄露'));
$form->addInput($token);
$fromName = new Typecho_Widget_Helper_Form_Element_Text('fromName', NULL, NULL, _t('发件人名称'), _t('发件人名称,留空则使用博客标题'));
$form->addInput($fromName);
$mail = new Typecho_Widget_Helper_Form_Element_Text('mail', NULL, NULL, _t('接收邮件的地址'), _t('接收邮件的地址,如为空则使用文章作者个人设置中的邮件地址!'));
$form->addInput($mail->addRule('email', _t('请填写正确的邮件地址!')));
$contactme = new Typecho_Widget_Helper_Form_Element_Text('contactme', NULL, NULL, _t('模板中“联系我”的邮件地址'), _t('联系我用的邮件地址,如为空则使用文章作者个人设置中的邮件地址!'));
$form->addInput($contactme->addRule('email', _t('请填写正确的邮件地址!')));
$status = new Typecho_Widget_Helper_Form_Element_Checkbox('status', array('approved' => '提醒已通过评论', 'waiting' => '提醒待审核评论', 'spam' => '提醒垃圾评论'), array('approved', 'waiting'), '提醒设置', _t('该选项仅针对博主,访客只发送已通过的评论。'));
$form->addInput($status);
$other = new Typecho_Widget_Helper_Form_Element_Checkbox('other', array('to_owner' => '有评论及回复时,发邮件通知博主。', 'to_guest' => '评论被回复时,发邮件通知评论者。', 'to_me' => '自己回复自己的评论时,发邮件通知。(同时针对博主和访客)', 'to_log' => '记录邮件发送日志。'), array('to_owner', 'to_guest'), '其他设置', _t('选中该选项插件会在log/mailer_log.txt 文件中记录发送日志,需要本地可以写入文件。'));
$form->addInput($other->multiMode());
$titleForOwner = new Typecho_Widget_Helper_Form_Element_Text('titleForOwner', null, "[{title}] 一文有新的评论", _t('博主接收邮件标题'));
$form->addInput($titleForOwner->addRule('required', _t('博主接收邮件标题 不能为空')));
$titleForGuest = new Typecho_Widget_Helper_Form_Element_Text('titleForGuest', null, "您在 [{title}] 的评论有了回复", _t('访客接收邮件标题'));
$form->addInput($titleForGuest->addRule('required', _t('访客接收邮件标题 不能为空')));
}
示例15: Change
public static function Change()
{
$options = Helper::options();
$cssUrl = Typecho_Common::url('LREditor/lr.css', $options->pluginUrl);
$jsUrl = Typecho_Common::url('LREditor/prettify.js', $options->pluginUrl);
echo '<link rel="stylesheet" type="text/css" href="' . $cssUrl . '" />';
echo '<script type="text/javascript" src="' . $jsUrl . '"></script>';
?>
<script>
function prettify() {
$("pre").addClass("prettyprint");
prettyPrint();
}
$(function() {
setInterval("$('#wmd-preview').css('height', (parseInt($('#text').height()) - 5)+'px');", 500);
setInterval("prettify()", 10);
//Typecho.editorResize('wmd-preview', '<?php
$options->index('/action/ajax?do=editorResize');
?>
');
//$('#wmd-preview').remove();
//$('textarea').after('<div id="wmd-preview"></div>');
});
</script>
<?php
}