本文整理匯總了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
}