当前位置: 首页>>代码示例>>PHP>>正文


PHP Typecho_Widget类代码示例

本文整理汇总了PHP中Typecho_Widget的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Widget类的具体用法?PHP Typecho_Widget怎么用?PHP Typecho_Widget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Typecho_Widget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
     }
 }
开发者ID:Jsechoo,项目名称:sisome,代码行数:32,代码来源:Mail.php

示例2: 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 
    }
开发者ID:gischuck,项目名称:BaiduSlug,代码行数:42,代码来源:Plugin.php

示例3: 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>';
 }
开发者ID:luobenyu,项目名称:plugins,代码行数:14,代码来源:Plugin.php

示例4: 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>';
 }
开发者ID:duxiangfei,项目名称:plugins,代码行数:27,代码来源:Plugin.php

示例5: __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;
     }
 }
开发者ID:ClayMoreBoy,项目名称:typecho-plugin-Access,代码行数:26,代码来源:Access.php

示例6: 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>";
     }
 }
开发者ID:kokororin,项目名称:typecho-plugin-ymplayer,代码行数:7,代码来源:Plugin.php

示例7: 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;
 }
开发者ID:duxiangfei,项目名称:plugins,代码行数:30,代码来源:Action.php

示例8: 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 = "&nbsp;&nbsp;" . $os_img . "&nbsp;" . $wb_img;
             break;
         case 2:
             $ua = "&nbsp;&nbsp;(" . $os_title . "&nbsp;/&nbsp;" . $wb_title . ")";
             break;
         case 3:
             $ua = "&nbsp;&nbsp;" . $os_img . "(" . $os_title . ")&nbsp;/&nbsp;" . $wb_img . "(" . $wb_title . ")";
             break;
         default:
             $ua = "&nbsp;&nbsp;" . $os_img . $wb_img;
             break;
     }
     echo $ua;
 }
开发者ID:ennnnny,项目名称:typecho,代码行数:39,代码来源:Plugin.php

示例9: 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;
}
开发者ID:m4html,项目名称:typecho-theme-Twentyfifteen,代码行数:28,代码来源:functions.php

示例10: __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');
 }
开发者ID:duxiangfei,项目名称:plugins,代码行数:7,代码来源:Action.php

示例11: 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' => '你已经点赞过了!'));
 }
开发者ID:jiangmuzi,项目名称:TeStat,代码行数:26,代码来源:Action.php

示例12: 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);
}
开发者ID:jiangmuzi,项目名称:jiang,代码行数:32,代码来源:functions.php

示例13: 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);
     }
 }
开发者ID:hongweipeng,项目名称:cool_blog,代码行数:12,代码来源:Action.php

示例14: Snowstorm

 /**
  * 设置参数,并加入脚部
  * 
  * @access public
  * @return void
  */
 public static function Snowstorm()
 {
     $options = Typecho_Widget::widget('Widget_Options')->plugin('Snowstorm');
     $color = preg_match('/^#[0-9a-f]{3,6}$/is', $options->snowColor);
     //判断是否为颜色代码
     $color = $color ? $options->snowColor : '#fff';
     echo '<script>snowColor = "' . $color . '";freezeOnBlur = ' . $options->freezeOnBlur . ';followMouse = ' . $options->followMouse . ';animationInterval = ' . $options->animationInterval . ';snowColorRand=' . $options->snowColorRand . ';</script>' . "\n\r" . '<script type="text/javascript" src="/usr/plugins/Snowstorm/res/snowstorm.min.js"></script>';
 }
开发者ID:duxiangfei,项目名称:plugins,代码行数:14,代码来源:Plugin.php

示例15: setTheme

 /**
  * 插件实现方法
  *
  * @access public
  * @return void
  */
 public static function setTheme($widget)
 {
     $cookie = array('name' => '__typecho_theme', 'expire' => 86400);
     $options = Typecho_Widget::widget('Widget_Options');
     if (isset($widget->request->theme) && $widget->request->isGet()) {
         if ($widget->request->theme) {
             $theme = $widget->request->theme;
             if (static::check($theme)) {
                 Typecho_Cookie::set($cookie['name'], $widget->request->theme, $options->gmtTime + $cookie['expire'], $options->siteUrl);
             } else {
                 $widget->response->redirect(Typecho_Common::url($widget->request->getPathInfo(), $options->siteUrl));
             }
         } else {
             Typecho_Cookie::delete($cookie['name']);
             //直接提交?theme将删除cookie,恢复默认主题
             return;
         }
     } else {
         $theme = Typecho_Cookie::get($cookie['name']);
         if (!$theme) {
             return;
         }
         if (!static::check($theme)) {
             Typecho_Cookie::delete($cookie['name']);
             return;
         }
     }
     /** 删除旧主题的相关设置 */
     $themeRow = 'theme:' . $options->theme;
     if (isset($options->{$themeRow})) {
         $config = unserialize($options->{$themeRow});
         $options->{$themeRow} = '';
         foreach ($config as $row => $value) {
             $options->{$row} = '';
         }
     }
     /** 载入新主题的相关设置 参考var/Widget/Themes/Edit.php */
     $themeDir = __TYPECHO_ROOT_DIR__ . __TYPECHO_THEME_DIR__ . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR;
     $configFile = $themeDir . 'functions.php';
     if (file_exists($configFile)) {
         require_once $configFile;
         if (function_exists('themeConfig')) {
             $form = new Typecho_Widget_Helper_Form();
             themeConfig($form);
             $config = $form->getValues();
             if ($config) {
                 $options->{'theme:' . $theme} = serialize($config);
                 foreach ($config as $row => $value) {
                     $options->{$row} = $value;
                 }
             }
         }
     }
     /** 修改$this->options->theme */
     $options->theme = $theme;
     /** 修改$this->_themeDir */
     $widget->setThemeDir($themeDir);
 }
开发者ID:duxiangfei,项目名称:plugins,代码行数:64,代码来源:Plugin.php


注:本文中的Typecho_Widget类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。