示例#1
0
 public function before($obj = null)
 {
     // 推荐商户设置   add by t-btei 2015/05/04
     $companyId = Req::args('companyId');
     if (isset($companyId)) {
         // 保存推荐ID
         setcookie('company_affiliate_uid', $companyId);
     }
     //测试平板或者手机端主题
     $clientType = Chips::clientType();
     if ($clientType == 'tablet' || $clientType == 'mobile') {
         $config_path = APP_CODE_ROOT . 'config/config.php';
         $config = (require $config_path);
         if (isset($config['themes_mobile'])) {
             $themes_mobile = Tiny::app()->setTheme($config['themes_mobile']);
         } else {
             Tiny::app()->setTheme("default");
         }
     }
     $config = Config::getInstance();
     $site = $config->get('globals');
     $other = $config->get('other');
     $currency_symbol = isset($other['other_currency_symbol']) ? $other['other_currency_symbol'] : '¥';
     $site_logo = isset($site['site_logo']) && $site['site_logo'] != '' ? $site['site_logo'] : 'static/images/logo.png';
     $site_qr = isset($site['site_qr']) && $site['site_qr'] != '' ? $site['site_qr'] : 'static/images/qr-app.png';
     $site_name = isset($site['site_name']) ? $site['site_name'] : 'TinyShop商城';
     $site_icp = isset($site['site_icp']) ? $site['site_icp'] : '鲁ICP备00000100号';
     $obj->assign('currency_symbol', $currency_symbol);
     $obj->assign('site_logo', $site_logo);
     $obj->assign('site_qr', $site_qr);
     $obj->assign('site_name', $site_name);
     $obj->assign('site_icp', $site_icp);
 }
示例#2
0
 /**
  * 取得数据库信息
  * 
  * @access public
  * @return mixed
  */
 public static function getDbInfo()
 {
     if (self::$dbinfo == null) {
         self::$dbinfo = Tiny::app()->db;
     }
     return self::$dbinfo;
 }
示例#3
0
 /**
  * 构造函数
  * 
  * @access public
  * @param mixed $tpl
  */
 public function __construct($tpl)
 {
     $this->tplfile = Tiny::app()->getRuntimePath() . $tpl . '.php';
     if (!file_exists($this->tplfile) || filemtime($this->tplfile) < filemtime($tpl)) {
         $file = new File($this->tplfile, 'w+');
         $template = $file->getContents($tpl);
         $t = new Tag();
         $tem = $t->resolve($template);
         $file->write($tem);
     }
 }
示例#4
0
 public static function getInstance($type = 'session')
 {
     if (!self::$obj instanceof self) {
         $type = strtolower($type);
         if ($type == 'session') {
             self::$box = new Session();
         } else {
             self::$box = new Cookie();
             self::$box->setSafeCode(Tiny::app()->getSafeCode());
         }
         self::$obj = new self();
     }
     return self::$box;
 }
示例#5
0
 /**
  * 引入css文件有调用方法
  * 
  * @access public
  * @param mixed $package 框架包名
  * @param mixed $name 
  * @return String
  */
 public static function import($package, $name = null)
 {
     if (isset(self::$CSSPackages[$package])) {
         $file = null;
         $is_file = false;
         if (is_string(self::$CSSPackages[$package])) {
             $is_file = true;
             $file = self::$CSSPackages[$package];
         } else {
             $csspackage = self::$CSSPackages[$package];
             reset($csspackage);
             $file = current($csspackage);
         }
         if (!isset(self::$createfiles[$package])) {
             $file_path = $file;
             if (!$is_file) {
                 $file_path = dirname($file);
             }
             if (!file_exists(Tiny::app()->getRuntimePath() . '/systemcss/' . $file_path)) {
                 File::xcopy(TINY_ROOT . '/web/css/source/' . $file_path, Tiny::app()->getRuntimePath() . '/systemcss/' . $file_path);
             }
             self::$createfiles[$package] = true;
         }
         $webcsspath = Tiny::app()->getRuntimeUrl() . '/systemcss/';
         if ($is_file || $name !== null) {
             if (isset(self::$CSSPackages[$package][$name])) {
                 return '<link rel="stylesheet" type="text/css" href="' . $webcsspath . self::$CSSPackages[$package][$name] . '"/>';
             } else {
                 return '';
             }
         } else {
             $tmp = '';
             foreach (self::$CSSPackages[$package] as $file) {
                 $tmp .= '<link rel="stylesheet" type="text/css" href="' . $webcsspath . $file . '"/>';
             }
             return $tmp;
         }
     } else {
         return '';
     }
 }
示例#6
0
 /**
  *路径格式化处理
  */
 static function urlFormat($path)
 {
     if ($path == '') {
         return self::baseDir();
     }
     if (preg_match('@[/\\@#*!]?(http://.+)$@i', $path, $matches)) {
         return $matches[1];
     }
     switch (substr($path, 0, 1)) {
         case '/':
             $path = self::createUrl($path);
             return rtrim(self::baseUri(), '/') . $path;
             //解释成绝对路由地址
         case '@':
             return self::baseDir() . substr($path, 1);
             //解析成绝对路径
         //解析成绝对路径
         case '#':
             if (Tiny::app()->getTheme() !== null) {
                 return Tiny::app()->getTheme()->getBaseUrl() . '/' . substr($path, 1);
             } else {
                 return self::baseDir() . substr($path, 1);
             }
         case '*':
             if (Tiny::app()->getTheme() !== null && Tiny::app()->getSkin() !== null) {
                 $theme = Tiny::app()->getTheme();
                 return $theme->getBaseUrl() . '/skins/' . Tiny::app()->getSkin() . '/' . substr($path, 1);
             } else {
                 if (Tiny::app()->getSkin() !== null) {
                     return self::baseDir() . 'skins/' . Tiny::app()->getSkin() . '/' . substr($path, 1);
                 } else {
                     return self::urlFormat('#' . substr($path, 1));
                 }
             }
         case '!':
             return Tiny::app()->getRuntimeUrl() . '/' . substr($path, 1);
         default:
             $q = Req::get();
             $url = '/' . $q['con'] . '/' . $q['act'];
             unset($q['con'], $q['act']);
             $query = explode('/', trim($path, '/'));
             $new_q = array();
             $len = count($query);
             for ($i = 0; $i < $len; $i++) {
                 if ($i % 2 == 1) {
                     $new_q[$query[$i - 1]] = $query[$i];
                 }
             }
             $q = array_merge($q, $new_q);
             foreach ($q as $k => $v) {
                 if (is_string($k)) {
                     $url .= '/' . $k . '/' . $v;
                 }
             }
             $path = self::createUrl($url);
             return rtrim(self::baseUri(), '/') . $path;
             //解释成绝对路由地址
     }
 }
 /**
  * 重新定位
  * 
  * @access public
  * @param string $operator 操作path
  * @param bool $jump 真假跳转方式
  * @param array $args 需要传送的数据
  * @return void
  */
 public function redirect($operator = '', $jump = true, $args = array())
 {
     //初始化 $con $act
     $old_args_num = count($args);
     $con = $this->getId();
     $act = Req::get('act') == null ? $this->defaultAction : Req::get('act');
     $controllerId = $con;
     if (stripos($operator, "http://") === false) {
         if ($operator != '') {
             $operator = trim($operator, '/');
             $operator = explode('/', $operator);
             $args_num = count($operator);
             if ($args_num >= 2) {
                 $con = $operator[0];
                 //$controllerName = ucfirst($operator[0]).'Controller';
                 //if(class_exists($controllerName))$controller = new $controllerName($operator[1],$this->module);
                 //else if($con != $this->getId()) $controller = new Controller($operator[1],$this->module);
                 if ($args_num > 2) {
                     for ($i = 2; $i < $args_num; $i = $i + 2) {
                         $args[$operator[$i]] = isset($operator[$i + 1]) ? $operator[$i + 1] : '';
                     }
                 }
                 $operator = $operator[1];
             } else {
                 $operator = $operator[0];
             }
         } else {
             $operator = $act;
         }
     }
     //如果请求的action 和新的跳转是同一action则进入到对应的视图Action
     if ($act == $operator && $controllerId == $con) {
         $this->action = new ViewAction($this, $act);
         $this->action->setData($args);
         $this->action->run();
     } else {
         if ($jump == false) {
             if ($controllerId == $con) {
                 $_GET['act'] = $operator;
                 $this->setDatas($args);
                 $this->run();
             } else {
                 $_GET['act'] = $operator;
                 $_GET['con'] = $con;
                 $controller = $this->module->createController();
                 $controller->setDatas($args);
                 $this->module->setController($controller);
                 $this->module->getController()->run();
             }
         } else {
             if ($old_args_num != 0 && is_array($args) && !empty($args)) {
                 $args['tiny_token_redirect'] = Tiny::app()->getToken('redirect');
                 //var_dump($args);exit();
                 header("Content-type: text/html; charset=" . $this->encoding);
                 $str = '<!doctype html><html lang="zh"><head></head><body>';
                 if (stripos($operator, "http://") !== false) {
                     $str .= '<form id="hiddenForm" name="hiddenForm" action="' . $operator . '" method="post">';
                 } else {
                     $str .= '<form id="hiddenForm" name="hiddenForm" action="' . Url::urlFormat('/' . $con . '/' . $operator) . '" method="post">';
                 }
                 foreach ($args as $key => $value) {
                     if (is_array($value)) {
                         foreach ($value as $k => $v) {
                             $str .= '<input type="hidden" name="' . $key . '[' . $k . ']" value="' . $v . '" />';
                         }
                     } else {
                         $str .= '<input type="hidden" name="' . $key . '" value="' . $value . '" />';
                     }
                 }
                 $str .= '</form><script type="text/javascript">document.forms["hiddenForm"].submit();</script></body></html>';
                 echo $str;
                 exit;
             } else {
                 $urlargs = '';
                 if (is_array($args) && !empty($args)) {
                     $urlargs = '?' . http_build_query($args);
                 }
                 header('Location:' . Url::urlFormat('/' . $con . '/' . $operator . $urlargs));
             }
         }
     }
 }
示例#8
0
 public function voucher_activated()
 {
     if (!Tiny::app()->checkToken()) {
         $this->redirect("voucher");
     }
     $rules = array('account:required:账号不能为空!', 'password:required:密码不能为空!');
     $info = Validator::check($rules);
     if (!is_array($info) && $info == true) {
         Filter::form(array('sql' => 'account'));
         $account = Filter::sql(Req::args("account"));
         $voucher = $this->model->table("voucher")->where("account='{$account}'")->find();
         if ($voucher && $voucher['password'] == Req::args("password")) {
             if (strtotime($voucher['end_time']) > time()) {
                 if ($voucher['status'] == 0) {
                     $this->model->table("voucher")->data(array('user_id' => $this->user['id'], 'is_send' => 1, 'status' => 0))->where("account='{$account}'")->update();
                     $this->redirect("voucher", false, array('msg' => array("success", "优惠券成功激活!")));
                 } else {
                     $this->redirect("voucher", false, array('msg' => array("warning", "此优惠券已使用过!")));
                 }
             } else {
                 //过期
                 $this->redirect("voucher", false, array('msg' => array("warning", "优惠券已过期!")));
             }
         } else {
             //不存在此优惠券
             $this->redirect("voucher", false, array('msg' => array("error", "优惠券账号或密码错误!")));
         }
     } else {
         //输入信息有误
         $this->redirect("voucher", false, array('msg' => array("info", "输入的信息不格式不正确")));
     }
 }
 /**
  *  取得编译后的运行路径
  * 
  * @access public
  * @return mixed
  */
 public function getRuntimePath()
 {
     if ($this->runtimePath !== null) {
         return $this->runtimePath;
     } else {
         if (($theme = Tiny::app()->getTheme()) !== null) {
             $this->setRuntimePath('runtime' . DIRECTORY_SEPARATOR . $theme->getName());
         } else {
             $this->setRuntimePath('runtime');
         }
         return $this->runtimePath;
     }
 }
示例#10
0
 /**
  * Encodes an arbitrary variable into JSON format
  *
  * @param	mixed   $var	any number, boolean, string, array, or object to be encoded.
  *						   see argument 1 to JSON() above for array-parsing behavior.
  *						   if var is a strng, note that encode() always expects it
  *						   to be in ASCII or UTF-8 format!
  *
  * @return   string  JSON string representation of input var
  */
 public static function encode($var)
 {
     switch (gettype($var)) {
         case 'boolean':
             return $var ? 'true' : 'false';
         case 'NULL':
             return 'null';
         case 'integer':
             return (int) $var;
         case 'double':
         case 'float':
             return (double) $var;
         case 'string':
             if (function_exists('json_encode')) {
                 return json_encode($var);
             }
             if (($enc = strtoupper(Tiny::app()->charset)) !== 'UTF-8') {
                 $var = iconv($enc, 'UTF-8', $var);
             }
             // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
             $ascii = '';
             $strlen_var = strlen($var);
             /*
              * Iterate over every character in the string,
              * escaping with a slash or encoding to UTF-8 where necessary
              */
             for ($c = 0; $c < $strlen_var; ++$c) {
                 $ord_var_c = ord($var[$c]);
                 switch (true) {
                     case $ord_var_c == 0x8:
                         $ascii .= '\\b';
                         break;
                     case $ord_var_c == 0x9:
                         $ascii .= '\\t';
                         break;
                     case $ord_var_c == 0xa:
                         $ascii .= '\\n';
                         break;
                     case $ord_var_c == 0xc:
                         $ascii .= '\\f';
                         break;
                     case $ord_var_c == 0xd:
                         $ascii .= '\\r';
                         break;
                     case $ord_var_c == 0x22:
                     case $ord_var_c == 0x2f:
                     case $ord_var_c == 0x5c:
                         // double quote, slash, slosh
                         $ascii .= '\\' . $var[$c];
                         break;
                     case $ord_var_c >= 0x20 && $ord_var_c <= 0x7f:
                         // characters U-00000000 - U-0000007F (same as ASCII)
                         $ascii .= $var[$c];
                         break;
                     case ($ord_var_c & 0xe0) == 0xc0:
                         // characters U-00000080 - U-000007FF, mask 110XXXXX
                         // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                         $char = pack('C*', $ord_var_c, ord($var[$c + 1]));
                         $c += 1;
                         $utf16 = self::utf8ToUTF16BE($char);
                         $ascii .= sprintf('\\u%04s', bin2hex($utf16));
                         break;
                     case ($ord_var_c & 0xf0) == 0xe0:
                         // characters U-00000800 - U-0000FFFF, mask 1110XXXX
                         // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                         $char = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]));
                         $c += 2;
                         $utf16 = self::utf8ToUTF16BE($char);
                         $ascii .= sprintf('\\u%04s', bin2hex($utf16));
                         break;
                     case ($ord_var_c & 0xf8) == 0xf0:
                         // characters U-00010000 - U-001FFFFF, mask 11110XXX
                         // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                         $char = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]));
                         $c += 3;
                         $utf16 = self::utf8ToUTF16BE($char);
                         $ascii .= sprintf('\\u%04s', bin2hex($utf16));
                         break;
                     case ($ord_var_c & 0xfc) == 0xf8:
                         // characters U-00200000 - U-03FFFFFF, mask 111110XX
                         // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                         $char = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]), ord($var[$c + 4]));
                         $c += 4;
                         $utf16 = self::utf8ToUTF16BE($char);
                         $ascii .= sprintf('\\u%04s', bin2hex($utf16));
                         break;
                     case ($ord_var_c & 0xfe) == 0xfc:
                         // characters U-04000000 - U-7FFFFFFF, mask 1111110X
                         // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                         $char = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]), ord($var[$c + 4]), ord($var[$c + 5]));
                         $c += 5;
                         $utf16 = self::utf8ToUTF16BE($char);
                         $ascii .= sprintf('\\u%04s', bin2hex($utf16));
                         break;
                 }
             }
             return '"' . $ascii . '"';
         case 'array':
             /*
              * As per JSON spec if any array key is not an integer
              * we must treat the the whole array as an object. We
              * also try to catch a sparsely populated associative
              * array with numeric keys here because some JS engines
              * will create an array with empty indexes up to
              * max_index which can cause memory issues and because
              * the keys, which may be relevant, will be remapped
              * otherwise.
              *
              * As per the ECMA and JSON specification an object may
              * have any string as a property. Unfortunately due to
              * a hole in the ECMA specification if the key is a
              * ECMA reserved word or starts with a digit the
              * parameter is only accessible using ECMAScript's
              * bracket notation.
              */
             // treat as a JSON object
             if (is_array($var) && count($var) && array_keys($var) !== range(0, sizeof($var) - 1)) {
                 return '{' . join(',', array_map(array('JSON', 'nameValue'), array_keys($var), array_values($var))) . '}';
             }
             // treat it like a regular array
             return '[' . join(',', array_map(array('JSON', 'encode'), $var)) . ']';
         case 'object':
             if ($var instanceof Traversable) {
                 $vars = array();
                 foreach ($var as $k => $v) {
                     $vars[$k] = $v;
                 }
             } else {
                 $vars = get_object_vars($var);
             }
             return '{' . join(',', array_map(array('JSON', 'nameValue'), array_keys($vars), array_values($vars))) . '}';
         default:
             return '';
     }
 }
示例#11
0
 public function __construct()
 {
     $nodes = array('/admin/index' => array('name' => '管理首页', 'parent' => 'config'), '/admin/theme_list' => array('name' => '主题设置', 'parent' => 'config'), '/admin/config_globals' => array('name' => '站点设置', 'parent' => 'config'), '/admin/config_other' => array('name' => '其它配置', 'parent' => 'config'), '/admin/config_email' => array('name' => '邮箱配置', 'parent' => 'config'), '/admin/msg_template_list' => array('name' => '信息模板', 'parent' => 'config'), '/admin/msg_template_edit' => array('name' => '信息模板编辑', 'parent' => 'config'), '/admin/oauth_list' => array('name' => '开放登录', 'parent' => 'config'), '/admin/oauth_edit' => array('name' => '开放登录编辑', 'parent' => 'config'), '/admin/payment_list' => array('name' => '支付方式', 'parent' => 'delivery'), '/admin/payment_edit' => array('name' => '编辑支付方式', 'parent' => 'delivery'), '/admin/zoning_list' => array('name' => '区域划分', 'parent' => 'delivery'), '/admin/ext_params_list' => array('name' => '海关对接', 'parent' => 'delivery'), '/admin/area_list' => array('name' => '地区管理', 'parent' => 'delivery'), '/admin/fare_list' => array('name' => '运费模板', 'parent' => 'delivery'), '/admin/fare_edit' => array('name' => '运费模板编辑', 'parent' => 'delivery'), '/admin/express_company_list' => array('name' => '快递公司', 'parent' => 'delivery'), '/admin/express_company_edit' => array('name' => '快递公司编辑', 'parent' => 'delivery'), '/admin/manager_list' => array('name' => '管理员', 'parent' => 'safe'), '/admin/manager_edit' => array('name' => '编辑管理员', 'parent' => 'safe'), '/admin/roles_list' => array('name' => '角色管理', 'parent' => 'safe'), '/admin/roles_edit' => array('name' => '角色编辑', 'parent' => 'safe'), '/admin/resources_list' => array('name' => '权限列表', 'parent' => 'safe'), '/admin/resources_edit' => array('name' => '编辑权限资源', 'parent' => 'safe'), '/admin/log_operation_list' => array('name' => '操作日志', 'parent' => 'safe'), '/admin/update' => array('name' => '版本升级', 'parent' => 'safe'), '/admin/clear' => array('name' => '清除缓存', 'parent' => 'safe'), '/content/article_list' => array('name' => '全部文章', 'parent' => 'article'), '/content/article_edit' => array('name' => '文章编辑', 'parent' => 'article'), '/content/category_list' => array('name' => '分类管理', 'parent' => 'article'), '/content/category_edit' => array('name' => '编辑分类', 'parent' => 'article'), '/content/help_list' => array('name' => '全部帮助', 'parent' => 'help'), '/content/help_edit' => array('name' => '帮助编辑', 'parent' => 'help'), '/content/help_category_list' => array('name' => '帮助分类管理', 'parent' => 'help'), '/content/help_category_edit' => array('name' => '编辑帮助分类', 'parent' => 'help'), '/content/ad_list' => array('name' => '广告管理', 'parent' => 'banner'), '/content/wel_list' => array('name' => '欢迎页面', 'parent' => 'banner'), '/content/ad_edit' => array('name' => '编辑广告', 'parent' => 'banner'), '/content/wel_edit' => array('name' => '编辑欢迎页面', 'parent' => 'banner'), '/content/tags_list' => array('name' => '标签管理', 'parent' => 'banner'), '/content/nav_list' => array('name' => '导航管理', 'parent' => 'banner'), '/content/nav_edit' => array('name' => '导航管理', 'parent' => 'banner'), '/admin/tables_list' => array('name' => '数据库备份', 'parent' => 'database'), '/admin/back_list' => array('name' => '数据库还原', 'parent' => 'database'), '/goods/goods_category_list' => array('name' => '分类管理', 'parent' => 'goods_config'), '/goods/goods_category_edit' => array('name' => '编辑分类', 'parent' => 'goods_config'), '/goods/goods_type_list' => array('name' => '类型管理', 'parent' => 'goods_config'), '/goods/goods_type_edit' => array('name' => '类型编辑', 'parent' => 'goods_config'), '/goods/tax_type_list' => array('name' => '税种管理', 'parent' => 'goods_config'), '/goods/tax_type_edit' => array('name' => '税种编辑', 'parent' => 'goods_config'), '/goods/theme_list' => array('name' => '主题管理', 'parent' => 'goods_config'), '/goods/theme_edit' => array('name' => '主题编辑', 'parent' => 'goods_config'), '/goods/tax_country_list' => array('name' => '国别管理', 'parent' => 'goods_config'), '/goods/tax_country_edit' => array('name' => '国别编辑', 'parent' => 'goods_config'), '/goods/goods_spec_list' => array('name' => '规格管理', 'parent' => 'goods_config'), '/goods/goods_spec_edit' => array('name' => '规格编辑', 'parent' => 'goods_config'), '/goods/brand_list' => array('name' => '品牌管理', 'parent' => 'goods_config'), '/goods/brand_edit' => array('name' => '品牌编辑', 'parent' => 'goods_config'), '/goods/series_list' => array('name' => '系列管理', 'parent' => 'goods_config'), '/goods/series_edit' => array('name' => '系列编辑', 'parent' => 'goods_config'), '/goods/goods_list' => array('name' => '商品管理', 'parent' => 'goods'), '/goods/goods_edit' => array('name' => '商品编辑', 'parent' => 'goods'), '/customer/customer_list' => array('name' => '会员管理', 'parent' => 'customer'), '/customer/customer_edit' => array('name' => '添加会员', 'parent' => 'customer'), '/customer/grade_list' => array('name' => '会员等级管理', 'parent' => 'customer'), '/customer/grade_edit' => array('name' => '添加会员等级', 'parent' => 'customer'), '/customer/withdraw_list' => array('name' => '提现申请', 'parent' => 'balance'), '/customer/balance_list' => array('name' => '资金日志', 'parent' => 'balance'), '/customer/review_list' => array('name' => '商品评价', 'parent' => 'ask_reviews'), '/customer/ask_list' => array('name' => '商品咨询', 'parent' => 'ask_reviews'), '/customer/ask_edit' => array('name' => '咨询回复', 'parent' => 'ask_reviews'), '/customer/message_list' => array('name' => '信息管理', 'parent' => 'ask_reviews'), '/customer/message_edit' => array('name' => '信息发送', 'parent' => 'ask_reviews'), '/customer/notify_list' => array('name' => '到货通知', 'parent' => 'ask_reviews'), '/customer/company_list' => array('name' => '商户管理', 'parent' => 'company'), '/customer/company_edit' => array('name' => '添加商户', 'parent' => 'company'), '/order/order_list' => array('name' => '商品订单', 'parent' => 'order'), '/order/email_message_list' => array('name' => '订单通知', 'parent' => 'order'), '/order/result_list' => array('name' => '回执信息', 'parent' => 'order'), '/order/examine_list' => array('name' => '审批结果', 'parent' => 'order'), '/order/email_message_edit' => array('name' => '订单通知编辑', 'parent' => 'order'), '/order/express_template_list' => array('name' => '快递单模板', 'parent' => 'express'), '/order/express_template_edit' => array('name' => '快递单模板编辑', 'parent' => 'express'), '/order/ship_list' => array('name' => '发货点管理', 'parent' => 'express'), '/order/ship_edit' => array('name' => '发货点编辑', 'parent' => 'express'), '/order/doc_receiving_list' => array('name' => '收款单', 'parent' => 'receipt'), '/order/doc_invoice_list' => array('name' => '发货单', 'parent' => 'receipt'), '/order/doc_refund_list' => array('name' => '退款单', 'parent' => 'receipt'), '/count/index' => array('name' => '订单统计', 'parent' => 'count'), '/count/hot' => array('name' => '热销统计', 'parent' => 'count'), '/count/area_buy' => array('name' => '地区统计', 'parent' => 'count'), '/count/user_reg' => array('name' => '会员分布统计', 'parent' => 'customer_count'), '/marketing/voucher_template_list' => array('name' => '代金券模板', 'parent' => 'voucher'), '/marketing/voucher_template_edit' => array('name' => '代金券模板编辑', 'parent' => 'voucher'), '/marketing/voucher_list' => array('name' => '代金券管理', 'parent' => 'voucher'), '/marketing/voucher_edit' => array('name' => '代金券编辑', 'parent' => 'voucher'), '/marketing/prom_goods_list' => array('name' => '商品促销', 'parent' => 'promotions'), '/marketing/prom_goods_edit' => array('name' => '编辑商品促销', 'parent' => 'promotions'), '/marketing/prom_order_list' => array('name' => '订单促销', 'parent' => 'promotions'), '/marketing/prom_order_edit' => array('name' => '编辑订单促销', 'parent' => 'promotions'), '/marketing/prom_series_list' => array('name' => '系列促销', 'parent' => 'promotions'), '/marketing/prom_series_edit' => array('name' => '编辑系列促销', 'parent' => 'promotions'), '/marketing/bundling_list' => array('name' => '捆绑促销', 'parent' => 'promotions'), '/marketing/bundling_edit' => array('name' => '编辑捆绑促销', 'parent' => 'promotions'), '/marketing/groupbuy_list' => array('name' => '团购', 'parent' => 'promotions'), '/marketing/groupbuy_edit' => array('name' => '团购', 'parent' => 'promotions'), '/marketing/flash_sale_list' => array('name' => '限时抢购', 'parent' => 'promotions'), '/marketing/flash_sale_edit' => array('name' => '编辑限时抢购', 'parent' => 'promotions'));
     //分组菜单
     $subMenu = array('config' => array('name' => '参数设定', 'parent' => 'system'), 'delivery' => array('name' => '支付与配送', 'parent' => 'system'), 'safe' => array('name' => '安全管理', 'parent' => 'system'), 'database' => array('name' => '数据库管理', 'parent' => 'system'), 'article' => array('name' => '文章管理', 'parent' => 'content'), 'help' => array('name' => '帮助中心', 'parent' => 'content'), 'banner' => array('name' => '内容管理', 'parent' => 'content'), 'goods' => array('name' => '产品管理', 'parent' => 'goods'), 'goods_config' => array('name' => '商品配置', 'parent' => 'goods'), 'company' => array('name' => '商户管理', 'parent' => 'customer'), 'customer' => array('name' => '会员管理', 'parent' => 'customer'), 'balance' => array('name' => '会员资金', 'parent' => 'customer'), 'ask_reviews' => array('name' => '咨询与评价', 'parent' => 'customer'), 'order' => array('name' => '订单管理', 'parent' => 'order'), 'receipt' => array('name' => '单据管理', 'parent' => 'order'), 'express' => array('name' => '快递单配置', 'parent' => 'order'), 'count' => array('name' => '销售统计', 'parent' => 'count'), 'customer_count' => array('name' => '客户统计', 'parent' => 'count'), 'promotions' => array('name' => '促销活动', 'parent' => 'marketing'), 'voucher' => array('name' => '代金券管理', 'parent' => 'marketing'));
     //主菜单
     $menu = array('goods' => array('link' => '/goods/goods_list', 'name' => '商品中心'), 'order' => array('link' => '/order/order_list', 'name' => '订单中心'), 'customer' => array('link' => '/customer/company_list', 'name' => '客户中心'), 'marketing' => array('link' => '/marketing/prom_goods_list', 'name' => '营销推广'), 'count' => array('link' => '/count/index', 'name' => '统计报表'), 'content' => array('link' => '/content/article_list', 'name' => '内容管理'), 'system' => array('link' => '/admin/index', 'name' => '系统设置'));
     $safebox = Safebox::getInstance();
     $manager = $safebox->get('manager');
     if (isset($manager['roles']) && $manager['roles'] != 'administrator') {
         $roles = new Roles($manager['roles']);
         $result = $roles->getRoles();
         if (isset($result['rights'])) {
             $rights = $result['rights'];
         } else {
             $rights = '';
         }
         if (is_array($nodes)) {
             $subMenuKey = array();
             foreach ($nodes as $key => $value) {
                 $_key = trim(strtr($key, '/', '@'), '@');
                 if (stripos($rights, $_key) === false) {
                     unset($nodes[$key]);
                 } else {
                     if (!isset($subMenuKey[$value['parent']])) {
                         $subMenuKey[$value['parent']] = $key;
                     } else {
                         if (stristr($key, '_list')) {
                             $subMenuKey[$value['parent']] = $key;
                         }
                     }
                 }
             }
             $menuKey = array();
             foreach ($subMenu as $key => $value) {
                 if (isset($subMenuKey[$key])) {
                     $menuKey[$value['parent']] = $key;
                 } else {
                     unset($subMenu[$key]);
                 }
             }
             foreach ($menu as $key => $value) {
                 if (!isset($menuKey[$key])) {
                     unset($menu[$key]);
                 } else {
                     $menu[$key]['link'] = $subMenuKey[$menuKey[$key]];
                 }
             }
         }
     }
     //var_dump($subMenuKey,$menuKey,$menu);exit;
     if (is_array($nodes)) {
         $this->nodes = $nodes;
     } else {
         $this->nodes = array();
     }
     if (is_array($subMenu)) {
         $this->subMenu = $subMenu;
     } else {
         $this->subMenu = array();
     }
     if (is_array($menu)) {
         $this->menu = $menu;
     } else {
         $this->menu = array();
     }
     foreach ($this->nodes as $key => $nodes) {
         $this->_subMenu[$nodes['parent']][] = array('link' => $key, 'name' => $nodes['name'], 'display' => isset($nodes['name']) ? $nodes['name'] : true);
     }
     foreach ($this->subMenu as $key => $subMenu) {
         $this->_menu[$subMenu['parent']][] = array('link' => $key, 'name' => $subMenu['name']);
     }
     $this->link_key = '/' . (Req::get('con') == null ? strtolower(Tiny::app()->defaultController) : Req::get('con')) . '/' . (Req::get('act') == null ? Tiny::app()->getController()->defaultAction : Req::get('act'));
 }
示例#12
0
 /**
  * @brief 获取订单中的支付信息
  * @type         信息获取方式 order:订单支付;recharge:在线充值;
  * @argument     参数
  * @return array 支付提交信息
  * R表示店铺 ; P表示用户;
  */
 public function getPaymentInfo($type, $argument)
 {
     $controller = Tiny::app()->getController();
     //支付信息
     $payment = array();
     //取的支付商户的ID与密钥
     $paymentObj = $this->getPayment();
     $payment['M_PartnerId'] = $paymentObj['partner_id'];
     $payment['M_PartnerKey'] = $paymentObj['partner_key'];
     $model = new Model("order");
     if ($type == 'order') {
         $order_id = $argument;
         //获取订单信息
         $order = $model->where('id = ' . $order_id . ' and status = 2')->find();
         if (empty($order)) {
             $msg = array('type' => 'fail', 'msg' => '订单信息不正确,不能进行支付!');
             $controller->redirect('/index/msg', false, $msg);
             exit;
         }
         //商品名称
         $model2 = new Model("order_goods");
         $model3 = new Model("goods");
         $order_goods = $model2->where('order_id = ' . $order_id . '')->findAll();
         $goods_name = '';
         foreach ($order_goods as $order_item) {
             // 如果订单详细表中行是由于捆绑促销
             if (isset($order_item['prom_type']) && $order_item['prom_type'] === 'bundling') {
                 $goods_name .= $order_item['title'] . ', ';
             } else {
                 $goods_id = $order_item['goods_id'];
                 $goods = $model3->where('id = ' . $goods_id . '')->find();
                 $goods_name .= $goods['name'] . ', ';
             }
         }
         $payment['M_Name'] = trim($goods_name, ', ');
         $payment['M_Remark'] = $order['user_remark'];
         $payment['M_OrderId'] = $order['id'];
         $payment['M_OrderNO'] = $order['order_no'];
         $payment['M_Amount'] = $order['order_amount'];
         //用户信息
         $payment['P_Mobile'] = $order['mobile'];
         $payment['P_Name'] = $order['accept_name'];
         $payment['P_PostCode'] = $order['zip'];
         $payment['P_Telephone'] = $order['phone'];
         $payment['P_Address'] = $order['addr'];
         $payment['P_Email'] = '';
     } else {
         if ($type == 'recharge') {
             if (!isset($argument['account']) || $argument['account'] <= 0) {
                 $msg = array('type' => 'fail', 'msg' => '请填入正确的充值金额!');
                 $controller->redirect('/index/msg', false, $msg);
                 exit;
             }
             $safebox = Safebox::getInstance();
             $user = $safebox->get('user');
             $recharge = new Model('recharge');
             $data = array('user_id' => $user['id'], 'recharge_no' => Common::createOrderNo(), 'account' => $argument['account'], 'time' => date('Y-m-d H:i:s'), 'payment_name' => $argument['paymentName'], 'status' => 0);
             $r_id = $recharge->data($data)->insert();
             //充值时用户id跟随交易号一起发送,以"_"分割
             $payment['M_OrderNO'] = 'recharge_' . $data['recharge_no'];
             $payment['M_OrderId'] = $r_id;
             $payment['M_Amount'] = $data['account'];
         }
     }
     $config = Config::getInstance();
     $site_config = $config->get("globals");
     //交易信息
     $payment['M_Def_Amount'] = 0.01;
     $payment['M_Time'] = time();
     $payment['M_Goods'] = '';
     $payment['M_Language'] = "zh_CN";
     $payment['M_Paymentid'] = $this->payment_id;
     //商城信息
     $payment['R_Address'] = isset($site_config['site_addr']) ? $site_config['site_addr'] : '';
     $payment['R_Name'] = isset($site_config['site_name']) ? $site_config['site_name'] : '';
     $payment['R_Mobile'] = isset($site_config['site_mobile']) ? $site_config['site_mobile'] : '';
     $payment['R_Telephone'] = isset($site_config['site_phone']) ? $site_config['site_phone'] : '';
     $payment['R_Postcode'] = isset($site_config['site_zip']) ? $site_config['site_zip'] : '';
     $payment['R_Email'] = isset($site_config['site_email']) ? $site_config['site_email'] : '';
     return $payment;
 }
示例#13
0
 static function autoLoginUserInfo()
 {
     $cookie = new Cookie();
     $cookie->setSafeCode(Tiny::app()->getSafeCode());
     $autologin = $cookie->get('autologin');
     $obj = null;
     if ($autologin != null) {
         $email = Filter::sql($autologin['email']);
         $password = $autologin['password'];
         $model = new Model("user as us");
         //$obj = $model->join("left join customer as cu on us.id = cu.user_id")->fields("us.*,cu.group_id,cu.login_time")->where("us.mobile='$mobile'")->find();
         $obj = $model->join("left join customer as cu on us.id = cu.user_id")->fields("us.*,cu.group_id,cu.login_time")->where("us.email='{$email}'")->find();
         if ($obj['password'] != $password) {
             $obj = null;
         }
     }
     return $obj;
 }
示例#14
0
 /**
  * 处理错误机制
  * 
  * @access public
  * @param mixed $code 错误代码 
  * @param mixed $message 错误信息
  * @param mixed $file 错误文件
  * @param mixed $line 行号
  * @param mixed $errContext 错误内容
  * @return void
  */
 public static function handleError($code, $message, $file, $line, $errContext)
 {
     //页面中正确运行的部分
     if (ob_get_length() > 0) {
         ob_end_clean();
     }
     $errorStack = null;
     if ($code & error_reporting()) {
         restore_error_handler();
         restore_exception_handler();
         $log = "{$message} (" . str_replace(TINY_ROOT, "", $file) . ":{$line})\r\nStack trace:\r\n";
         $trace = debug_backtrace();
         self::paseErrorTrace($trace, $log);
         $errorStack = $trace;
     }
     try {
         $errorType;
         switch ($code) {
             case E_ERROR:
                 $errorType = 'ERROR';
                 break;
             case E_WARNING:
                 $errorType = 'WARNING';
                 break;
             case E_NOTICE:
                 $errorType = 'NOTICE';
                 break;
             case E_USER_ERROR:
                 $errorType = 'USER_ERROR';
                 break;
             case E_USER_WARNING:
                 $errorType = 'USER_WARNING';
                 break;
             case E_USER_NOTICE:
                 $errorType = 'USER_NOTICE';
                 break;
             case E_PARSE:
                 $errorType = 'PARSE_ERROR';
                 break;
             default:
                 $errorType = 'UNKNOWN';
                 break;
         }
         if (isset($log)) {
             Tiny::log($log, $errorType);
         }
         $error_file = new File($file);
         $codes = $error_file->gets($line);
         if (defined("APP_ROOT")) {
             $file = str_replace(APP_ROOT, "", $file);
         }
         $file = str_replace(TINY_ROOT, "", $file);
         $datas = array('errorType' => $errorType, 'file' => $file, 'line' => $line, 'codes' => htmlspecialchars($codes), 'errorStack' => $errorStack, 'errorContent' => $errContext);
         $error = new Error(Tiny::app(), $message, null, $datas);
         if ($error) {
             $error->handle();
             exit;
         } else {
             self::displayError($code, $message, $file, $line);
         }
     } catch (Exception $e) {
         self::displayException($e);
     }
     exit;
 }
示例#15
0
 public function logout()
 {
     $this->safebox->clear('user');
     $cookie = new Cookie();
     $cookie->setSafeCode(Tiny::app()->getSafeCode());
     $cookie->set('autologin', null, 0);
     $this->redirect('login');
 }
示例#16
0
 /**
  * 处理设定的每一个标签
  * 
  * @access public
  * @param mixed $matches
  * @return mixed
  */
 public function translate($matches)
 {
     $suffix = '_' . self::$num++;
     if ($matches[1] !== '/') {
         switch ($matches[2] . $matches[3]) {
             case '$':
                 $str = trim($matches[4]);
                 $data = explode('|', $str);
                 if ($str[0] == '.' || $str[0] == '(') {
                     return $matches[0];
                 }
                 $len = count($data);
                 if ($len == 1) {
                     return '<?php echo isset($' . $matches[4] . ')?$' . $matches[4] . ':"";?>';
                 } else {
                     if ($len == 2) {
                         return '<?php echo isset($' . $data[0] . ')?$' . $data[0] . ':' . $data[1] . ';?>';
                     } else {
                         if ($len > 2) {
                             $filter = strtolower($data[$len - 1]);
                             switch ($filter) {
                                 case 'encode':
                                     return '<?php echo isset($' . $data[0] . ')?htmlspecialchars($' . $data[0] . '):' . $data[1] . ';?>';
                                 case 'int':
                                 case 'str':
                                 case 'float':
                                 case 'txt':
                                 case 'sql':
                                 case 'text':
                                     return '<?php echo isset($' . $data[0] . ')?Filter::' . $filter . '($' . $data[0] . '):' . $data[1] . ';?>';
                                 default:
                                     return '<?php echo isset($' . $data[0] . ') && $' . $data[0] . '?' . $data[1] . ':' . $data[2] . ';?>';
                             }
                         }
                     }
                 }
             case 'echo:':
                 return '<?php echo ' . rtrim($matches[4], ';/') . ';?>';
             case 'url:':
                 return '<?php echo urldecode(Url::urlFormat("' . trim($matches[4]) . '"));?>';
             case 'if:':
                 return '<?php if(' . $matches[4] . '){?>';
             case 'elseif:':
                 return '<?php }elseif(' . $matches[4] . '){?>';
             case 'else:':
                 return '<?php }else{' . $matches[4] . '?>';
             case 'set:':
                 return '<?php ' . rtrim($matches[4], ';/') . ';?>';
             case 'while:':
                 return '<?php while(' . $matches[4] . '){?>';
             case 'dump:':
                 return '<pre><?php var_dump(' . $matches[4] . '); ?></pre>';
             case 'list:':
             case 'foreach:':
                 $attr = $this->getAttrs($matches[4]);
                 if (!isset($attr['items'])) {
                     $attr['items'] = '$items';
                 } else {
                     $attr['items'] = $attr['items'];
                 }
                 if (!isset($attr['key'])) {
                     $attr['key'] = '$key';
                 } else {
                     $attr['key'] = $attr['key'];
                 }
                 if (!isset($attr['item'])) {
                     $attr['item'] = '$item';
                 } else {
                     $attr['item'] = $attr['item'];
                 }
                 return '<?php foreach(' . $attr['items'] . ' as ' . $attr['key'] . ' => ' . $attr['item'] . '){?>';
             case 'for:':
                 $attr = $this->getAttrs($matches[4]);
                 if (!isset($attr['item'])) {
                     $attr['item'] = '$i';
                 } else {
                     $attr['item'] = $attr['item'];
                 }
                 if (!isset($attr['from'])) {
                     $attr['from'] = 0;
                 }
                 if (!isset($attr['to'])) {
                     $attr['to'] = 10;
                 }
                 if (!isset($attr['step'])) {
                     $attr['step'] = 1;
                 }
                 return '<?php for($total' . $suffix . ' = (int) ceil((' . $attr['step'] . ' > 0 ? ' . $attr['to'] . '+1 - (' . $attr['from'] . ') : ' . $attr['from'] . '-(' . $attr['to'] . ')+1)/abs(' . $attr['step'] . ')),' . $attr['item'] . ' = ' . $attr['from'] . ',$start' . $suffix . '=1 ; $total' . $suffix . '>0 && $start' . $suffix . '<=$total' . $suffix . ' ; ' . $attr['item'] . ' += ' . $attr['step'] . ',$start' . $suffix . ' += 1){?>';
             case 'widget:':
                 $attr = $this->getAttrs($matches[4]);
                 $className = isset($attr['name']) ? $attr['name'] : null;
                 $method = isset($attr['method']) ? $attr['method'] : 'init';
                 $args = isset($attr['args']) ? $attr['args'] : null;
                 $attr['cache'] = isset($attr['cache']) ? "true" : "false";
                 //$cacheTime = isset($attr['cachetime'])?intval($attr['cachetime']):30;
                 $old_char = array(' ne ', ' eq ', ' lt ', ' gt ', ' le ', ' ge ');
                 $new_char = array(' != ', ' = ', ' < ', ' > ', ' <= ', ' >= ');
                 $tem = "<div id='widget_{$className}'><?php \$widget = Widget::createWidget('{$className}');";
                 foreach ($attr as $k => $v) {
                     if ($k != 'name') {
                         $v = str_replace($old_char, $new_char, $v);
                         if (substr($v, 0, 1) == '$') {
                             $tem .= '$widget->' . $k . ' = ' . $v . ';';
                         } else {
                             $tem .= '$widget->' . $k . ' = "' . $v . '";';
                         }
                     }
                 }
                 $tem .= "\$widget->run();?></div>";
                 return $tem;
             case 'query:':
                 $endchart = substr(trim($matches[4]), -1);
                 $attrs = $this->getAttrs(rtrim($matches[4], '/'));
                 if (!isset($attrs['id'])) {
                     $id = '$query';
                 } else {
                     $id = $attrs['id'];
                 }
                 if (!isset($attrs['items'])) {
                     $items = '$items';
                 } else {
                     $items = $attrs['items'];
                 }
                 $tem = $id . ' = new Query("' . $attrs['name'] . '");';
                 //实现属性中符号表达式的问题
                 $old_char = array(' ne ', ' eq ', ' lt ', ' gt ', ' le ', ' ge ');
                 $new_char = array(' != ', ' = ', ' < ', ' > ', ' <= ', ' >= ');
                 foreach ($attrs as $k => $v) {
                     if ($k != 'name' && $k != 'id' && $k != 'items') {
                         $tem .= $id . '->' . $k . ' = "' . str_replace($old_char, $new_char, $v) . '";';
                     }
                 }
                 $tem .= $items . ' = ' . $id . '->find();';
                 if (!isset($attrs['key'])) {
                     $attrs['key'] = '$key';
                 } else {
                     $attrs['key'] = $attrs['key'];
                 }
                 if (!isset($attrs['item'])) {
                     $attrs['item'] = '$item';
                 } else {
                     $attrs['item'] = $attrs['item'];
                 }
                 if ($endchart == '/') {
                     return '<?php ' . $tem . '?>';
                 } else {
                     return '<?php ' . $attrs['item'] . '=null; ' . $tem . ' foreach(' . $items . ' as ' . $attrs['key'] . ' => ' . $attrs['item'] . '){?>';
                 }
             case 'token:':
                 $attr = $this->getAttrs(rtrim($matches[4], '/'));
                 if (isset($attr['key']) && is_string($attr['key'])) {
                     $key = $attr['key'];
                 } else {
                     $key = '';
                 }
                 return "<input type='hidden' name='tiny_token_" . $key . "' value='<?php echo Tiny::app()->getToken(\"" . $key . "\");?>'/>";
             case 'debug:':
                 $matches[4] = rtrim($matches[4], ';/');
                 if ($matches[4] != '') {
                     return '<pre>' . $matches[4] . ' = <?php var_dump(' . $matches[4] . ');?></pre>';
                 } else {
                     return '<?php $debug = new Debug(); $out = get_defined_vars(); $debug->out($out); $debug->display();?>';
                 }
             case 'code:':
                 return '<?php ' . $matches[4];
             case 'require:':
             case 'include:':
                 $fileName = trim($matches[4]);
                 $viewfile = Tiny::app()->getViewPath() . DIRECTORY_SEPARATOR . $this->viewPath . DIRECTORY_SEPARATOR . $fileName;
                 $runfile = Tiny::app()->getRuntimePath() . DIRECTORY_SEPARATOR . $this->viewPath . DIRECTORY_SEPARATOR . $fileName;
                 if (!file_exists($runfile) || filemtime($runfile) < filemtime($viewfile)) {
                     $file = new File($runfile, 'w+');
                     $template = $file->getContents($viewfile);
                     $t = new Tag();
                     $tem = $t->resolve($template, dirname($viewfile));
                     $file->write($tem);
                 }
                 return '<?php include("' . trim($matches[4]) . '")?>';
             default:
                 return $matches[0];
         }
     } else {
         if ($matches[2] == 'code') {
             return '?>';
         } else {
             if ($matches[2] != 'widget') {
                 return '<?php }?>';
             }
         }
     }
 }
示例#17
0
 /**
  * 引用方法
  * 
  * @access public
  * @param mixed $name
  * @param string $charset
  * @return String
  */
 public static function import($name, $charset = 'UTF-8')
 {
     $parames = explode('?', $name);
     $name = $parames[0];
     if (isset($parames[1])) {
         $parames = '?' . $parames[1];
     } else {
         $parames = '';
     }
     if (isset(self::$JSPackages[$name])) {
         if (!isset(self::$createfiles[$name])) {
             $is_file = false;
             $file = null;
             if (is_string(self::$JSPackages[$name])) {
                 if (stripos(self::$JSPackages[$name], '/') === false) {
                     $is_file = true;
                     $file = self::$JSPackages[$name];
                 } else {
                     $file = dirname(self::$JSPackages[$name]);
                 }
             } else {
                 if (is_array(self::$JSPackages[$name]['js'])) {
                     $file = dirname(self::$JSPackages[$name]['js'][0]);
                 } else {
                     $file = dirname(self::$JSPackages[$name]['js']);
                 }
             }
             if (!file_exists(APP_ROOT . 'runtime/systemjs/' . $file)) {
                 self::$createfiles[$name] = true;
                 File::xcopy(TINY_ROOT . '/web/js/source/' . $file, APP_ROOT . 'runtime/systemjs/' . $file);
             }
         }
         $webjspath = Tiny::app()->getRuntimeUrl() . '/systemjs/';
         if (is_string(self::$JSPackages[$name])) {
             return '<script type="text/javascript" charset="' . $charset . '" src="' . $webjspath . self::$JSPackages[$name] . $parames . '"></script>';
         } else {
             if (is_array(self::$JSPackages[$name])) {
                 $str = '';
                 if (isset(self::$JSPackages[$name]['css'])) {
                     if (is_string(self::$JSPackages[$name]['css'])) {
                         $str .= '<link rel="stylesheet" type="text/css" href="' . $webjspath . self::$JSPackages[$name]['css'] . '"/>';
                     } else {
                         if (is_array(self::$JSPackages[$name]['css'])) {
                             foreach (self::$JSPackages[$name]['css'] as $css) {
                                 $str .= '<link rel="stylesheet" type="text/css" href="' . $webjspath . $css . '"/>';
                             }
                         }
                     }
                 }
                 if (isset(self::$JSPackages[$name]['js'])) {
                     if (is_array(self::$JSPackages[$name]['js'])) {
                         foreach (self::$JSPackages[$name]['js'] as $js) {
                             $str .= '<script type="text/javascript" charset="' . $charset . '" src="' . $webjspath . $js . $parames . '"></script>';
                         }
                     } else {
                         $str .= '<script type="text/javascript" charset="' . $charset . '" src="' . $webjspath . self::$JSPackages[$name]['js'] . $parames . '"></script>';
                     }
                 }
                 return $str;
             }
         }
     } else {
         return '';
     }
 }
示例#18
0
 /**
  * 取得对应的错误处理文件
  * 
  * @access protected
  * @param mixed $code
  * @return mixed
  */
 protected function getViewFile($code)
 {
     $viewPaths = array(Tiny::app() == null ? null : Tiny::app()->getLayoutPath(), TINY_ROOT . 'views');
     foreach ($viewPaths as $i => $viewPath) {
         if ($viewPath !== null) {
             $viewFile = $viewPath . DIRECTORY_SEPARATOR . 'error_' . $code . '.php';
             if (is_file($viewFile)) {
                 return $viewFile;
             }
             $viewFile = $viewPath . DIRECTORY_SEPARATOR . 'error.php';
             if (is_file($viewFile)) {
                 return $viewFile;
             }
         }
     }
 }
示例#19
0
 /**
  * 渲染
  * 
  * @access public
  * @param mixed $viewFile
  * @param bool $return
  * @return mixed
  */
 public function renderInternal($viewFile, $return = false)
 {
     $data = $this->properties;
     if (is_array($data)) {
         extract($data, EXTR_PREFIX_SAME, 'data');
     }
     $tplfile = $this->getViewFile($viewFile);
     if (file_exists($tplfile)) {
         $runfile = Tiny::app()->getRuntimePath() . DIRECTORY_SEPARATOR . 'widgets/' . $viewFile . '.php';
         if (!file_exists($runfile) || filemtime($runfile) < filemtime($tplfile)) {
             $file = new File($runfile, 'w+');
             $template = $file->getContents($tplfile);
             $t = new Tag();
             $tem = $t->resolve($template);
             $file->write($tem);
         }
         header("Content-type: text/html; charset=" . $this->encoding);
         if ($return) {
             ob_start();
             ob_implicit_flush(false);
             require $runfile;
             return ob_get_clean();
         } else {
             require $runfile;
         }
     } else {
         if ($this->id != Tiny::app()->getId()) {
             trigger_error("{$this->id}Widget->{$this->getAction()}() not exists", E_USER_ERROR);
         } else {
             Tiny::msg('', '无法找到请求的页面', 404);
         }
     }
 }