Browse Source

增加item的个性域名显示

star7th 9 years ago
parent
commit
3a79dcaab9

+ 2 - 0
Application/Common/Conf/config.php

@@ -18,9 +18,11 @@ return array(
     'URL_MODEL' => 3 ,//URL兼容模式
     'URL_ROUTER_ON'   => true, 
     'URL_ROUTE_RULES'=>array(
+        ':domain\s$'               => 'Home/Item/Show?item_domain=:1',//item的个性域名
         ':id\d'               => 'Home/Item/Show?item_id=:1',
         'uid/:id\d'               => 'Home/Item/showByUid?uid=:1',
     ),
     'URL_CASE_INSENSITIVE'=>true,
     'SHOW_ERROR_MSG'        =>  true,    // 显示错误信息,这样在部署模式下也能显示错误
+
 );

+ 11 - 1
Application/Home/Controller/ItemController.class.php

@@ -39,12 +39,21 @@ class ItemController extends BaseController {
 		  $this->display ();
 
 		}else{
-			$item_name = I("item_name");
+            $item_name = I("item_name");
+			$item_domain = I("item_domain");
+
+            if(!ctype_alnum($item_domain)){
+                //echo '个性域名只能是字母或数字的组合';exit;
+                $this->message(L('item_domain_illegal'));
+                return false;
+            }
+
             $password = I("password");
 			$item_description = I("item_description");
             if ($item_id > 0 ) {
                 $data = array(
                     "item_name" => $item_name ,
+                    "item_domain" => $item_domain ,
                     "password" => $password ,
                     "item_description" => $item_description ,
                     );
@@ -56,6 +65,7 @@ class ItemController extends BaseController {
                     "item_name" => $item_name ,
                     "password" => $password ,
                     "item_description" => $item_description ,
+                    "item_domain" => $item_domain ,
                     "addtime" =>time()
                     );
                 $ret = D("Item")->add($insert);

+ 31 - 1
Application/Home/Controller/UpdateController.class.php

@@ -169,6 +169,20 @@ class UpdateController extends BaseController {
                 D("catalog")->execute($sql);
             }
         }
+        //item表增加item_domain字段
+        $columns = M("item")->getDbFields();
+        if ($columns) {
+            $has_it = 0 ;//是否存在该字段
+            foreach ($columns as $key => $value) {
+                if ($value == 'item_domain') {
+                    $has_it = 1 ;
+                }
+            }
+            if ($has_it === 0) {
+                $sql = "ALTER TABLE ".C('DB_PREFIX')."item ADD item_domain varchar( 50 ) NOT NULL DEFAULT '' COMMENT 'item的个性域名';";
+                D("item")->execute($sql);
+            }
+        }
 
         echo "OK!";
     }
@@ -202,7 +216,23 @@ class UpdateController extends BaseController {
                 $sql = "ALTER TABLE ".C('DB_PREFIX')."catalog ADD level INT( 10 ) NOT NULL DEFAULT '2'  ;";
                 D("catalog")->execute($sql);
             }
-        }    
+        }
+
+        //item表增加item_domain字段
+        $columns = M("item")->getDbFields();
+        if ($columns) {
+            $has_it = 0 ;//是否存在该字段
+            foreach ($columns as $key => $value) {
+                if ($value == 'item_domain') {
+                    $has_it = 1 ;
+                }
+            }
+            if ($has_it === 0) {
+                $sql = "ALTER TABLE ".C('DB_PREFIX')."item ADD item_domain text NOT NULL DEFAULT '';";
+                D("item")->execute($sql);
+            }
+        }
+
         echo 'OK!';
     }
 

+ 2 - 0
Application/Home/Lang/en-us.php

@@ -36,6 +36,8 @@ return array(
     //item/add
     'item_name' => "Item's name",
     'item_description' => "Item's description",
+    'item_domain' => '(Optional)domain hack',
+    'item_domain_illegal' => 'domain hack must be a combination of letters and numbers',
     'visit_password_placeholder' => 'Access password(Optional: private project required)',
     'submit' => 'Submit',
     'goback' => 'Goback',

+ 2 - 0
Application/Home/Lang/zh-cn.php

@@ -36,6 +36,8 @@ return array(
     //item/add
     'item_name' => '项目名',
     'item_description' => '项目描述',
+    'item_domain' => '(可选)个性域名',
+    'item_domain_illegal' => '个性域名只能是字母或数字的组合',
     'visit_password_placeholder' => '访问密码(可选,私密项目请设置密码)',
     'submit' => '提交',
     'goback' => '返回',

+ 1 - 0
Application/Home/View/Item/add.html

@@ -8,6 +8,7 @@
         <!-- <h3 class="form-signin-heading">新建项目</h3> -->
         <input type="text" class="input-block-level"  name="item_name" placeholder="{$Think.Lang.item_name}" autocomplete="off" value="{$item.item_name}" >
         <input type="text" class="input-block-level"  name="item_description" placeholder="{$Think.Lang.item_description}" autocomplete="off" value="{$item.item_description}">
+        <input type="text" class="input-block-level"  name="item_domain" placeholder="{$Think.Lang.item_domain}" autocomplete="off" value="{$item.item_domain}" >
         <input style="display:none"><!-- for disable autocomplete on chrome -->
         <input style="display:none"><!-- for disable autocomplete on chrome -->
         <input type="password" class="input-block-level" name="password" placeholder="{$Think.Lang.visit_password_placeholder}" title="{$Think.Lang.visit_password_placeholder}" autocomplete="off" value="{$item.password}">

BIN
Sqlite/showdoc.db.php