Example #1
0
/**
 *  需要加载Widget.YDM.js挂件一起使用
 */
function smarty_function_YMD($params, $smarty)
{
    $GUID = K::GUID(microtime());
    $class = $params['class'] ? ' ' . $params['class'] : '';
    $YMD = $params['YMD'] ? $params['YMD'] : date('Y-n-j');
    list($Y, $M, $D) = explode('-', $YMD);
    $Y = isset($params['Y']) ? $params['Y'] : $Y;
    $M = isset($params['M']) ? $params['M'] : $M;
    $D = isset($params['D']) ? $params['D'] : $D;
    $start = $params['start'] ? $params['start_year'] : 1970;
    $end = $params['end'] ? $params['end_year'] : date('Y');
    $name = $params['name'] ? $params['name'] : 'YMD';
    $yy = $mm = $dd = '';
    $yy .= '<select name="' . $name . '[Y]" Y="' . $Y . '" class="w-100' . $class . '">';
    for ($i = $end; $i >= $start; $i--) {
        $selected = $Y == $i ? ' selected="selected"' : '';
        $yy .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
    }
    $yy .= '</select>';
    $mm .= '<select name="' . $name . '[M]" M="' . $M . '" class="w-50' . $class . '">';
    for ($i = 1; $i <= 12; $i++) {
        $selected = $M == $i ? ' selected="selected"' : '';
        $mm .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
    }
    $mm .= '</select>';
    $dd .= '<select name="' . $name . '[D]" D="' . $D . '" class="w-50' . $class . '">';
    for ($i = 1; $i <= 31; $i++) {
        $selected = $D == $i ? ' selected="selected"' : '';
        $dd .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
    }
    $dd .= '</select>';
    $html = "<span id='{$GUID}'>{$yy}&nbsp;年&nbsp;&nbsp;{$mm}&nbsp;月&nbsp;&nbsp;{$dd}&nbsp;日</span>";
    $html .= "<script>(function(K, \$){Widget.YMD.init('#{$GUID}');})(window.KT, window.jQuery);</script>";
    return $html;
}
Example #2
0
/**
 *  需要加载Widget.YDM.js挂件一起使用
 */
function smarty_function_area($params, $smarty)
{
    $GUID = K::GUID(microtime());
    $YMD = $params['YMD'] ? $params['YMD'] : date('Y-n-j');
    list($Y, $M, $D) = explode('-', $YMD);
    $Y = isset($params['Y']) ? isset($params['Y']) : $Y;
    $M = isset($params['M']) ? isset($params['M']) : $M;
    $D = isset($params['D']) ? isset($params['D']) : $D;
    $start = $params['start'] ? $params['start_year'] : 1970;
    $end = $params['end'] ? $params['end_year'] : date('Y');
    $name = $params['name'] ? $params['name'] : 'YMD';
    $yy = $mm = $dd = '';
    $yy .= '<select name="' . $name . '[Y]" Y="' . $Y . '">';
    for ($i = $start; $i <= $end; $i++) {
        $yy .= '<option value="' . $i . '">' . $i . '</option>';
    }
    $yy .= '</select>';
    $mm .= '<select name="' . $name . '[M]" M="' . $M . '">';
    for ($i = 1; $i <= 12; $i++) {
        $mm .= '<option value="' . $i . '">' . $i . '</option>';
    }
    $mm .= '</select>';
    $dd .= '<select name="' . $name . '[D]" D="' . $D . '">';
    for ($i = 1; $i <= 31; $i++) {
        $dd .= '<option value="' . $i . '">' . $i . '</option>';
    }
    $dd .= '</select>';
    $html = "<span id='{$GUID}''>{$yy}年{$mm}月{$dd}日</span>";
    $html .= "<script>(function(T, \$){Widget.YMD.init('#{$GUID}');})(window.TP, window.jQuery);</script>";
    return $html;
}
Example #3
0
 public function fetch($widget, &$smarty)
 {
     $file = __CFG::DIR . "plugins/widgets/" . $widget['widget'] . '/widget.php';
     if (!$widget['method']) {
         $widget['method'] = 'index';
     }
     $wdt = K::W($widget['widget']);
     $wdt->smarty =& $smarty;
     if (!method_exists($wdt, $widget['method'])) {
         $widget['act'] = $widget['method'];
         $widget['method'] = 'index';
     }
     if (!($data = $wdt->{$widget}['method']($widget))) {
         return '';
     }
     $smarty->assign('data', $data);
     $widget['GUID'] = K::GUID('widget');
     $smarty->assign('widget', $widget);
     if (!$widget['tpl']) {
         $widget['tpl'] = 'widget:/default/default.html';
     }
     if (strpos($widget['tpl'], ':') === false && strpos($widget['tpl'], '/') === false) {
         $tmpl = "widget:{$widget['widget']}/{$widget['tpl']}";
     } else {
         $tmpl = $widget['tpl'];
     }
     return $smarty->fetch($tmpl);
 }
Example #4
0
 public function Instance()
 {
     $_clen = strlen(__CFG::C_PREFIX);
     $filter = K::M('content/filter');
     foreach ($_COOKIE as $k => $v) {
         if (substr($k, 0, $_clen) == __CFG::C_PREFIX) {
             $this->_COOKIE[substr($k, $_clen)] = $filter->addslashes($v);
         }
     }
     if (!($this->GUID = $this->_COOKIE['GUID'])) {
         $this->GUID = 'KT-' . K::GUID('cookie');
         $this->set('GUID', $this->GUID);
     }
 }
Example #5
0
/**
 *  需要加载Widget.YDM.js挂件一起使用
 */
function smarty_function_region($params, $smarty)
{
    $GUID = K::GUID(microtime());
    $name = $params['name'] ? $params['name'] : 'region';
    $regionId = $params['region'] ? $params['region'] : 0;
    $oRegion = K::M('data/region');
    $pid = 0;
    $region = null;
    if ($regionId && ($region = $oRegion->region($regionId))) {
        if ($region['region_typ'] == 2) {
            $pid = $region['parent_id'];
        } else {
            if ($region['region_type'] == 1) {
                $pid = $region['region_id'];
            }
        }
    }
    $provinces = $oRegion->provice_list();
    $html .= '<span id="' . $GUID . '"><select name="area[province]" val="' . $pid . '">';
    foreach ($provinces as $k => $v) {
        $html .= "<option value=\"{$v['region_id']}\">{$v['region_name']}</option>";
    }
    $html .= '</select>';
    $html .= '<select name="area[city]" val="' . $regionId . '">';
    if ($pid) {
        $city_list = $oRegion->city_list($pid);
        foreach ($city_list as $v) {
            $html .= "<option value=\"{$v['region_id']}\">{$v['region_name']}</option>";
        }
    } else {
        $html .= "<option value=''>请选择</option>";
    }
    $html .= '</select></span>';
    $html .= "<script>(function(T, \$){Widget.Area.init('#{$GUID}');})(window.TP, window.jQuery);</script>";
    return $html;
}