本文整理汇总了PHP中Typecho_Widget::widget方法的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Widget::widget方法的具体用法?PHP Typecho_Widget::widget怎么用?PHP Typecho_Widget::widget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Typecho_Widget
的用法示例。
在下文中一共展示了Typecho_Widget::widget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajax
/**
* ajax执行action
*
* @access public
* @param array $contents 文章输入信息
* @return void
*/
public static function ajax()
{
Typecho_Widget::widget('Widget_Options')->to($options);
?>
<script>
function baiduSlug() {
var title = $('#title');
var slug = $('#slug');
if (slug.val().length > 0 || title.val().length == 0) {
return;
}
$.ajax({
url: '<?php
$options->index('/action/baidu-slug?q=');
?>
' + title.val(),
success: function(data) {
if (data.result.length > 0) {
slug.val(data.result).focus();
slug.siblings('pre').text(data.result);
}
}
});
}
$(function() {
$('#title').blur(baiduSlug);
$('#slug').blur(baiduSlug);
});
</script>
<?php
}
示例2: putAsyncMail
/**
* 异步发送邮件
*/
protected static function putAsyncMail($filename)
{
$options = Typecho_Widget::widget('Widget_Options');
$siteUrl = $options->rewrite ? $options->siteUrl : $options->siteUrl . 'index.php';
$dmpt = parse_url($siteUrl);
$host = $dmpt['host'];
$port = isset($dmpt['port']) ? $dmpt['port'] : 80;
if (substr($dmpt['path'], -1) != '/') {
$dmpt['path'] .= '/';
}
$url = $dmpt['path'] . 'action/forum';
$get = 'do=sendmail&name=' . $filename;
$head = "GET " . $url . "?" . $get . " HTTP/1.0\r\n";
$head .= "Host: " . $host . "\r\n";
$head .= "\r\n";
if (function_exists('fsockopen')) {
$fp = @fsockopen($host, $port, $errno, $errstr, 30);
} elseif (function_exists('pfsockopen')) {
$fp = @pfsockopen($host, $port, $errno, $errstr, 30);
} else {
$fp = stream_socket_client($host . ":{$port}", $errno, $errstr, 30);
}
if ($fp) {
fputs($fp, $head);
fclose($fp);
} else {
file_put_contents('.' . self::getDIr . 'error_log.txt', "SOCKET错误," . $errno . ':' . $errstr);
}
}
示例3: render
/**
* 插件实现方法
*
* @access public
* @return void
*/
public static function render($agent)
{
$options = Typecho_Widget::widget('Widget_Options');
$url_plugin = $options->pluginUrl . '/UserAgent/';
//插件地址 -> http://domain.com/usr/plugins/UserAgent/
global $url_img, $icons;
$url_img = $url_plugin . "img/";
$icons = Typecho_Widget::widget('Widget_Options')->plugin('UserAgent')->icons;
$show = Typecho_Widget::widget('Widget_Options')->plugin('UserAgent')->show;
require_once 'useragent-os.php';
$os = detect_os($agent);
$os_img = self::img($os['code'], "/os/", $os['title']);
$os_title = $os['title'];
require_once 'useragent-webbrowser.php';
$wb = detect_webbrowser($agent);
$wb_img = self::img($wb['code'], "/net/", $wb['title']);
$wb_title = $wb['title'];
switch ($show) {
case 1:
$ua = " " . $os_img . " " . $wb_img;
break;
case 2:
$ua = " (" . $os_title . " / " . $wb_title . ")";
break;
case 3:
$ua = " " . $os_img . "(" . $os_title . ") / " . $wb_img . "(" . $wb_title . ")";
break;
default:
$ua = " " . $os_img . $wb_img;
break;
}
echo $ua;
}
示例4: buildCalendar
public static function buildCalendar()
{
//判断当前插件是否已被启用
$options = Typecho_Widget::widget('Widget_Options');
if (!isset($options->plugins['activated']['Calendar'])) {
return '日历插件未被激活';
}
$mdays = date("t");
//当月总天数
$datenow = date("j");
//当日日期
$monthnow = date("n");
//当月月份
$yearnow = date("Y");
//当年年份
//计算当月第一天是星期几
$wk1st = date("w", mktime(0, 0, 0, $monthnow, 1, $yearnow)) - 1;
$trnum = ceil(($mdays + $wk1st) / 7);
//计算表格行数
$out = <<<HEAD
<div id="cal_switcher" class="list-group-item clearfix">
\t<a href="javascript:move('left')"><i class="fa fa-angle-left"></i></a>
<div id="cal_yearmonth">
\t <span id="cal_year"><b>{$yearnow}</b>年</span>
\t <span id="cal_month"><b>{$monthnow}</b>月</span>
</div>
<a href="javascript:move('right')"><i class="fa fa-angle-right"></i></a>
</div>
HEAD;
//以下是表格字串
$out .= "<table id=cal_plugin class=\"table table-bordered\"><tr class=cal-header><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th><th>日</th></tr>";
for ($i = 0; $i < $trnum; $i++) {
$out .= "<tr class=cal-body>";
for ($k = 0; $k < 7; $k++) {
//每行七个单元格
$tabidx = $i * 7 + $k;
//取得单元格自身序号
//若单元格序号小于当月第一天的星期数($wk1st)或大于(月总数+$wk1st)
//只填写空格,反之,写入日期
($tabidx < $wk1st or $tabidx > $mdays + $wk1st - 1) ? $dayecho = " " : ($dayecho = $tabidx - $wk1st + 1);
//突出标明今日日期
// $dayecho="<span style=\"background-color:red;color:#fff;\">$dayecho</span>";
$todayclass = "";
if ($k > 4) {
$todayclass .= " weekend";
}
if ($dayecho == $datenow) {
$todayclass .= " current";
}
$todaybg = empty($todayclass) ? "" : " class=\"{$todayclass}\"";
$out .= "<td" . $todaybg . ">{$dayecho}</td>";
}
$out .= "</tr>";
}
$out .= "</table>" . PHP_EOL;
return $out;
}
示例5: thumbnail
function thumbnail($obj, $size = null, $link = false, $pattern = '<div class="post-thumb"><a class="thumb" href="{permalink}" title="{title}" style="background-image:url({thumb})"></a></div>')
{
preg_match_all("/<[img|IMG].*?src=[\\'|\"](.*?)[\\'|\"].*?[\\/]?>/", $obj->content, $matches);
$thumb = '';
$options = Typecho_Widget::widget('Widget_Options');
if (isset($matches[1][0])) {
$thumb = $matches[1][0];
if (!empty($options->src_add) && !empty($options->cdn_add)) {
$thumb = str_ireplace($options->src_add, $options->cdn_add, $thumb);
}
if ($size != 'full') {
$thumb_width = $options->thumb_width;
$thumb_height = $options->thumb_height;
if ($size != null) {
$size = explode('x', $size);
if (!empty($size[0]) && !empty($size[1])) {
list($thumb_width, $thumb_height) = $size;
}
}
$thumb .= '?imageView2/4/w/' . $thumb_width . '/h/' . $thumb_height;
}
}
if (empty($thumb) && empty($options->default_thumb)) {
return '';
} else {
$thumb = empty($thumb) ? $options->default_thumb : $thumb;
}
if ($link) {
return $thumb;
}
echo str_replace(array('{title}', '{thumb}', '{permalink}'), array($obj->title, $thumb, $obj->permalink), $pattern);
}
示例6: __construct
public function __construct($request, $response, $params = NULL)
{
parent::__construct($request, $response, $params);
/* 获取数据库对象、配置及用户 */
$this->_db = Typecho_Db::get();
$this->_options = Typecho_Widget::widget('Widget_Options');
}
示例7: __construct
public function __construct()
{
$this->db = Typecho_Db::get();
$this->prefix = $this->db->getPrefix();
$this->table = $this->prefix . 'access';
$this->config = Typecho_Widget::widget('Widget_Options')->plugin('Access');
$this->request = Typecho_Request::getInstance();
$this->pageSize = $this->config->pageSize;
$this->isDrop = $this->config->isDrop;
if ($this->pageSize == null || $this->isDrop == null) {
throw new Typecho_Plugin_Exception('请先设置插件!');
}
switch ($this->request->get('action')) {
case 'logs':
default:
$this->action = 'logs';
$this->title = '访问日志';
$this->parseLogs();
break;
case 'overview':
$this->action = 'overview';
$this->title = '访问概览';
$this->parseOverview();
break;
}
}
示例8: parseCallback
public static function parseCallback($matches)
{
$no_html5 = array('www.letv.com', 'v.yinyuetai.com', 'v.ku6.com');
$providers = array('v.youku.com' => array('#https?://v\\.youku\\.com/v_show/id_(?<video_id>[a-z0-9_=\\-]+)#i', 'http://player.youku.com/player.php/sid/{video_id}/v.swf', 'http://player.youku.com/embed/{video_id}'), 'www.tudou.com' => array('#https?://(?:www\\.)?tudou\\.com/(?:programs/view|listplay/(?<list_id>[a-z0-9_=\\-]+))/(?<video_id>[a-z0-9_=\\-]+)#i', 'http://www.tudou.com/v/{video_id}/&resourceId=0_05_05_99&bid=05/v.swf', 'http://www.tudou.com/programs/view/html5embed.action?type=0&code={video_id}'), 'www.56.com' => array('#https?://(?:www\\.)?56\\.com/[a-z0-9]+/(?:play_album\\-aid\\-[0-9]+_vid\\-(?<video_id>[a-z0-9_=\\-]+)|v_(?<video_id2>[a-z0-9_=\\-]+))#i', 'http://player.56.com/v_{video_id}.swf', 'http://www.56.com/iframe/{video_id}'), 'v.qq.com' => array('#https?://v\\.qq\\.com/(?:[a-z0-9_\\./]+\\?vid=(?<video_id>[a-z0-9_=\\-]+)|(?:[a-z0-9/]+)/(?<video_id2>[a-z0-9_=\\-]+))#i', 'http://static.video.qq.com/TPout.swf?vid={video_id}', 'http://v.qq.com/iframe/player.html?vid={video_id}'), 'my.tv.sohu.com' => array('#https?://my\\.tv\\.sohu\\.com/us/(?:\\d+)/(?<video_id>\\d+)#i', 'http://share.vrs.sohu.com/my/v.swf&topBar=1&id={video_id}&autoplay=false&xuid=&from=page', 'http://tv.sohu.com/upload/static/share/share_play.html#{video_id}_0_0_9001_0'), 'www.wasu.cn' => array('#https?://www\\.wasu\\.cn/play/show/id/(?<video_id>\\d+)#i', 'http://s.wasu.cn/portal/player/20141216/WsPlayer.swf?mode=3&vid={video_id}&auto=0&ad=4228', 'http://www.wasu.cn/Play/iframe/id/{video_id}'), 'www.letv.com' => array('#https?://www\\.letv\\.com/ptv/vplay/(?<video_id>\\d+)#i', 'http://i7.imgs.letv.com/player/swfPlayer.swf?id={video_id}&autoplay=0', ''), 'www.acfun.tv' => array('#https?://www\\.acfun\\.tv/v/ac(?<video_id>\\d+)#i', 'http://static.acfun.mm111.net/player/ACFlashPlayer.out.swf?type=page&url=http://www.acfun.tv/v/ac{video_id}', ''), 'www.bilibili.com' => array('#https?://www\\.bilibili\\.com/video/av(?<video_id>\\d+)#i', 'http://static.hdslb.com/miniloader.swf?aid={video_id}&page=1', ''), 'v.yinyuetai.com' => array('#https?://v\\.yinyuetai\\.com/video/(?<video_id>\\d+)#i', 'http://player.yinyuetai.com/video/player/{video_id}/v_0.swf', ''), 'v.ku6.com' => array('#https?://v\\.ku6\\.com/show/(?<video_id>[a-z0-9\\-_\\.]+).html#i', 'http://player.ku6.com/refer/{video_id}/v.swf', ''));
$parse = parse_url($matches['video_url']);
$site = $parse['host'];
if (!in_array($site, array_keys($providers))) {
return '<p><a href="' . $matches['video_url'] . '">' . $matches['video_url'] . '</a></p>';
}
preg_match_all($providers[$site][0], $matches['video_url'], $match);
$id = $match['video_id'][0] == '' ? $match['video_id2'][0] : $match['video_id'][0];
if (self::isMobile()) {
$width = Typecho_Widget::widget('Widget_Options')->plugin('Typembed')->mobile_width;
$height = Typecho_Widget::widget('Widget_Options')->plugin('Typembed')->mobile_height;
} else {
$width = Typecho_Widget::widget('Widget_Options')->plugin('Typembed')->width;
$height = Typecho_Widget::widget('Widget_Options')->plugin('Typembed')->height;
}
if (self::isMobile() && !in_array($site, $no_html5)) {
$url = str_replace('{video_id}', $id, $providers[$site][2]);
$html = sprintf('<iframe src="%1$s" width="%2$s" height="%3$s" frameborder="0" allowfullscreen="true"></iframe>', $url, $width, $height);
} else {
$url = str_replace('{video_id}', $id, $providers[$site][1]);
$html = sprintf('<embed src="%1$s" allowFullScreen="true" quality="high" width="%2$s" height="%3$s" allowScriptAccess="always" type="application/x-shockwave-flash"></embed>', $url, $width, $height);
}
return '<div id="typembed">' . $html . '</div>';
}
示例9: __construct
/**
* 构造函数
*
* @access public
* @param mixed $request request对象
* @param mixed $response response对象
* @param mixed $params 参数列表
*/
public function __construct($request, $response, $params = NULL)
{
parent::__construct($request, $response, $params);
$this->notice = parent::widget('Widget_Notice');
$this->options = parent::widget('Widget_Options');
$this->config = $this->options->plugin('Passport');
}
示例10: insertStyle
public static function insertStyle()
{
$custom = Typecho_Widget::widget('Widget_Options')->Plugin('ymplayer')->custom;
if ($custom != '') {
echo "<style id=\"ymplayer_custom_style\">\n" . $custom . "\n</style>";
}
}
示例11: info
public static function info()
{
$options = Typecho_Widget::widget('Widget_Options');
$Ukagaka = $options->plugin('Ukagaka');
$wcc['notice'] = stripslashes($Ukagaka->notice);
$db = Typecho_Db::get();
$select = $db->select()->from('table.options')->where('name = ?', 'Ukagaka_starttime');
$lifetime = $db->fetchAll($select);
$lifetime = self::get_wcc_lifetime($lifetime[0]['value']);
$name = Typecho_Widget::widget('Widget_Options')->title;
$wcc['showlifetime'] = '我已经与主人 ' . $name . ' 一起生存了 <font color="red">' . $lifetime["day"] . '</font> 天 <font color="red">' . $lifetime["hours"] . '</font> 小时 <font color="red">' . $lifetime["minutes"] . '</font> 分钟 <font color="red">' . $lifetime["seconds"] . '</font> 秒的快乐时光啦~*^_^*';
$foods = explode("\r\n", $Ukagaka->foods);
foreach ($foods as $key => $value) {
$xx = explode("//", $value);
$wcc['foods'][] = $xx[0];
$wcc['eatsay'][] = $xx[1];
}
if ($Ukagaka->contact) {
$contact = explode("\r\n", $Ukagaka->contact);
foreach ($contact as $key => $value) {
$xx = explode("//", $value);
$wcc['ques'][] = $xx[0];
$wcc['ans'][] = $xx[1];
}
} else {
$wcc['contactapi'] = '1';
}
$wcc = json_encode($wcc);
echo $wcc;
}
示例12: links
function links($slug)
{
$db = Typecho_Db::get();
$Contents = Typecho_Widget::widget('Widget_Abstract_Contents');
$value = $db->fetchRow($db->select()->from('table.contents')->where('table.contents.status = ?', 'publish')->where('table.contents.type = ?', 'page')->where('table.contents.slug = ?', $slug)->where('table.contents.password IS NULL')->limit(1));
$value = $Contents->filter($value);
if (0 === strpos($value['text'], '<!--markdown-->')) {
$value['isMarkdown'] = 0;
} else {
$value['isMarkdown'] = 1;
}
if ($value['isMarkdown'] == 1) {
$text = substr($value['text'], 15);
$text = $Contents->markdown($text);
} else {
$text = $Contents->autoP($value['text']);
}
$search = '/<ul>(.*?)<\\/ul>/is';
preg_match_all($search, $text, $matches);
$result = '';
foreach ($matches[1] as $v) {
$result .= $v;
}
$result = str_replace('<li>', '', $result);
$result = str_replace('</li>', '<br/>', $result);
$result = rtrim($result, '<br/>');
echo $result;
}
示例13: footer
/**
* 输出尾部js
*
* @access public
* @param unknown $footer
* @return unknown
*/
public static function footer()
{
$jsUrl = Helper::options()->pluginUrl . '/LaTex/latex.js';
echo '<script type="text/javascript" src="' . $jsUrl . '"></script>';
$mark = Typecho_Widget::widget('Widget_Options')->plugin('LaTex')->mark;
echo '<script type="text/javascript">latex.parse("' . $mark . '");</script>';
}
示例14: action
public function action()
{
$this->db = Typecho_Db::get();
$this->prefix = $this->db->getPrefix();
$this->options = Typecho_Widget::widget('Widget_Options');
$cid = $this->request->cid;
if (!$cid) {
$this->response->throwJson(array('status' => 0, 'msg' => '请选择喜欢的文章!'));
}
$likes = Typecho_Cookie::get('__post_likes');
if (empty($likes)) {
$likes = array();
} else {
$likes = explode(',', $likes);
}
if (!in_array($cid, $likes)) {
$row = $this->db->fetchRow($this->db->select('likesNum')->from('table.contents')->where('cid = ?', $cid)->limit(1));
$this->db->query($this->db->update('table.contents')->rows(array('likesNum' => (int) $row['likesNum'] + 1))->where('cid = ?', $cid));
array_push($likes, $cid);
$likes = implode(',', $likes);
Typecho_Cookie::set('__post_likes', $likes);
//记录查看cookie
$this->response->throwJson(array('status' => 1, 'msg' => '成功点赞!'));
}
$this->response->throwJson(array('status' => 0, 'msg' => '你已经点赞过了!'));
}
示例15: checkLogin
/**
*判断用户是否已登录,未登录自动跳转到登录页面
*@return void
*/
public function checkLogin()
{
$user = Typecho_Widget::widget('Widget_User');
if (!$user->hasLogin()) {
Typecho_Widget::widget('Widget_Notice')->set(_t("未登录"), 'error');
$this->response->redirect($this->options->adminUrl);
}
}