cfanwzl 的blog

php正则表达式匹配tweet中的话题

     /**

     * @desc 匹配话题  

     * array

          '#PHP#' => string 'PHP' (length=3)

          '#正则表达式#' => string '正则表达式' (length=15)

          '#a#' => string 'a' (length=1)

php正则表达式匹配tweet中的提及(@用户名)

     /**

     * @desc 匹配 @用户名

     * @param String $text 

     * @return Array array

     * */

    function matchMentions($text = '') {

        $return = null;

php正则表达式匹配tweet中的URL

     /**

     * @desc 获得匹配到的 url,只匹配http,https开头的url

     * @return Array urls

     * */

    function matchUrls($text = '') {

        $URL_VALID_PRECEEDING_CHARS = "(?:[^/\"':!=]|^|\\:)";

产生和验证$_GET参数函数

在项目中我们经常要用到$_GET方式来进行传参,为了保证数据的正确和完整性我们还要再传递一个key来加以验证.

产生token函数:

Pathauto 自动生成路径别名

         Pathauto 模块自动生成各种内容的路径别名(节点,分类,用户),而不需要用户手动指定路径的别名。这使您可以得到/分类别名/节点名称,而不是/node/11。别名是基于一个 "模式"系统管理员可以控制的。

FileField Paths

         FileField Paths 模块扩展了Drupals默认功能核心上传模块,FileField模块和其他多种文件上传加入能够使用目标路径和文件名中的节点标记模块。

User Read-Only

        User Read-Only  模块允许管理员禁止用户帐户/个人资料字段修改。管理员可以选择哪些字段将被禁止,或将被允许字段。

js获得页面高度

javascript获得页面的可视宽高和页面自身宽高,兼容浏览器.
function GetPageSize() {
    var scrW, scrH;
    if(window.innerHeight && window.scrollMaxY) {
        // Mozilla
        scrW = window.innerWidth + window.scrollMaxX;

javascript 判断页面是否在iframe下

当iframe不在父窗口打开时,跳转到父窗口

var parent_url = 'http://www.pecloud.cn';
if(parent.document.URL== document.URL) {
 window.location.href = parent_url;
} else {
 //...
}
if(window.top == window) {
 window.top.location = parent_url;
} else {
 //...
}

jquery 元素居中间

 $(document).ready(function() {

  jQuery.fn.center = function() {

    this.css("position","absolute");

    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");

同步内容