乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      走馬觀花SHOPNC [原創(chuàng)]

       sumi2005 2013-10-21
      本帖最后由 kakashilw 于 2009-7-1 12:39 編輯

      因為工作原因,最近又走馬觀花了幾套開源產(chǎn)品。。。

      在這里分享下走馬觀花shopnc時的筆記吧。。。

      其實shopnc是半開源的產(chǎn)品,它的核心代碼是加密的。。不過開源的部分還不少,而且還有注釋,嘻嘻~~

      ready?go!

      --------------------------------------------------------------------------------------------------------------------------

      1、index.php和index.html   之首頁靜態(tài)化生成

      分析代碼當(dāng)然是從index.php開始嘍,貼下代碼

      [php]
      require ("global.inc.php");
      //判斷是否有安裝文件
      if (file_exists("install/index.php")){
      // if (!is_writable("templates/install/templates_c")){
      //  echo BasePath."/templates/install/templates_c have no permissions! Please Determine this Folder's  write permissions!";
      //  exit;
      // }
      header("location:install/index.php");
      exit;
      }
      class ShowIndex extends CommonFrameWork{
      function main(){
        /**
         * 執(zhí)行操作
         */
        switch($this->_input['action']){
         default:
          $this->_showindex();
        }
      }
      /**
        * 首頁顯示
        *
        */
      function _showindex(){
        @header("location:home/index.php");
      }
      }
      $index = new ShowIndex();
      $index->main();
      unset($index);
      [/php]

      很簡單,通過global.inc.php載入核心類庫,包括框架的核心代碼(個人猜測應(yīng)該是大白菜心的php框架吧)

      然后跳轉(zhuǎn)到home/index.php中去了。。

      index.php中執(zhí)行了

      [php]
      function main(){

        /**
         * 創(chuàng)建首頁和頻道靜態(tài)頁面對象
         */
        if (!is_object($this->obj_html_channel)){
        
         require_once("../home/html.channel.php"); //dump("eee");
         $this->obj_html_channel = new HtmlChannelManage();
        }

        /**
         * 創(chuàng)建商品分類對象
         */
        if (!is_object($this->objProductCate)){
         require_once ("productclass.class.php");
         $this->objProductCate = new ProductCategoryClass();
        }
         //return;
        /**
         * 創(chuàng)建商鋪分類對象
         */
        if (!is_object($this->obj_shop_category)){
         require_once("shopcategory.class.php");
         $this->obj_shop_category = new ShopCategoryClass();
        }

        
        /**
         * 設(shè)置模板路徑
         */
        $this->setsubtemplates("home");
        /**
         * 語言包
         */
        $this->getlang("index_show");
        /**
         * 執(zhí)行操作
         */

        switch($this->_input['action']){
         case "aj_get_class":
          $this->_aj_get_class();
          break;
         case "getQuickLinks":
          $this->_getQuickLinks();
          break;
         case "index_html":
          $this->_index_html();
          break;
         default:
          $this->_showindex();
        }
      }
      [/php]

      有注釋,看看流程就可以了,具體代碼就不細(xì)究了。。。

      然后執(zhí)行到了$this->_index_html();

      這個是關(guān)鍵,就是傳說中的【首頁靜態(tài)化】了。??纯慈思沂钦懙?br>
      這個函數(shù)中輾轉(zhuǎn)反側(cè)后到了最后這個方法了。。

      [php]
      function _make_language_html($language){
        //重新加載語言包
        unset($this->_lang);
        $this->_langType = $language['language_path'];
        $this->getlang("common");
        $this->getlang("index_show");
        $this->getlang("channel");
        //頻道頁面需要加載的內(nèi)容
        //搜索中的商品類別
        require(BasePath."/cache/ProductClass_show.php");
        if (is_array($node_cache)){
         foreach ($node_cache as $k => $v){
          if ($v[4] == '0') {
           $v['id'] = $v[0];
           $v['name'] = $v[2];
           $SearchProductCateArray[] = $v;
          }
         }
        }
        /*取所有頻道*/
        $condition["order_by"] = "channel_sort";
        $condition["state"] = "0";
        $condition["order_sort"] = "asc";
        $channel_all = $this->obj_channel->listChannel($condition,$page);
        unset($condition);
        //取模塊參數(shù)配置文件 default
        $path = BasePath."/share/indexparam/";
        //模板參數(shù)
        $tpl_path = BasePath."/templates/".$this->_configinfo['websit']['templatesname'].'/home/index_tpl/';
        //判斷改文件夾是否存在,如果不存在,則報錯
        if (!is_dir($path)){
         return $this->_lang['langChannelIndexTempDirWrong'];
        }
        //通過LOCK標(biāo)識,取模板文件名
        require_once("fileoperate.class.php");
        $file_array = FileOperate::listDir($tpl_path);
        //如果有LOCK后綴的文件,則表示文件名為模板當(dāng)前使用名稱
        if (is_array($file_array)){
         foreach ($file_array as $k => $v){
          if (strstr($v['name'],'.LOCK')){
           $template_name = substr($v['name'],0,strlen($v['name'])-5);
           if (!file_exists($tpl_path.$template_name)) {
            return $this->_lang['langChannelIndexHmtlTempIsNotExists'];
           }
           $template_name = substr($template_name,0,strlen($template_name)-5);
           break;
          }
         }
        }
        //判斷是否為空,如果為空,則默認(rèn)
        if($template_name == ''){
         $template_name = 'default';
        }
        if (file_exists($path.$this->_configinfo['websit']['templatesname'].".php")){
         require($path.$this->_configinfo['websit']['templatesname'].".php");
         //參數(shù)數(shù)組 $ChannelParamArray
         if (is_array($ChannelParamArray)){
          $module = array();/*模塊頁面代碼*/
          //取各模塊的參數(shù) $k 為模塊名稱 下劃線前兩個單詞為模塊類型
          foreach ($ChannelParamArray as $k => $v){
           //判斷模塊類型
           $line = @explode("_",$k);
           $module_name = $line[0].'_'.$line[1];
           switch ($module_name){
            case "adv_module"://廣告模塊
            //如果是安裝時,則判斷是否安裝演示數(shù)據(jù),如果不安裝的話,則不執(zhí)行廣告模塊程序
            if (INSTALL_ISDATA == 'no'){//不安裝
             break;
            }
            //判斷是否是flash廣告,如果不是則調(diào)用JS文件,是則調(diào)用模塊模板
            //創(chuàng)建廣告對象
            if (!is_object($this->obj_adv)){
             require_once ("advertisement.class.php");
             $this->obj_adv = new AdvertisementClass();
            }
            $condition_adv['code'] = $v['code'];
            $condition_adv['start_date'] = time();
            $condition_adv['end_date'] = time();
            $condition_adv['state'] = 0;
            $adv_list = $this->obj_adv->listAdv($condition_adv,$page);
            if ($adv_list[0]['adv_type'] == 2){//如果是flash
             $module[$k] = $this->advFlashHtmlCode($v['code']);
            }else {//其他廣告類型,調(diào)用的是JS文件
             //判斷廣告的JS文件是否存在
             if (file_exists(BasePath."/html/js/".$v['code'].'.js')){
              $module[$k] = "<script src='".$this->_configinfo['websit']['site_url'].'/html/js/'.$v['code'].'.js'."'></script>";
             }else {
              return $this->_lang['langChannelAdvCreaLostPleaseAdvManageCreateFile'];
             }
            }
            break;
            case "vote_module"://投票模塊
            $module[$k] = $this->voteHtmlCode($v);
            break;
            case "product_module"://商品模塊
            $module[$k] = $this->productHtmlCode($v);
            break;
            case "shop_module"://商鋪模塊
            $module[$k] = $this->shopHtmlCode($v);
            break;
            case "pclass_module"://商品類別模塊
            $module[$k] = $this->pclassHtmlCode($v);
            break;
            case "shopclass_module"://商鋪類別模塊
            $module[$k] = $this->shopclassHtmlCode($v);
            break;
           }
          }
          //關(guān)鍵詞模板名稱
          $keyword_html_name = BasePath.'/html/keyword/index.html';
          /**
           * 取得最新成交訂單列表
           */
          if (!is_object($this->obj_product_order)){
           require_once("order.class.php");
           $this->obj_product_order = new ProductOrderClass();
          }
          $obj_order_condition[order] = "1";
          $this->obj_page_channel->pagebarnum(10);
          $product_order_array = $this->obj_product_order->getProductOrderList($obj_order_condition, $this->obj_page);
         
          //重新設(shè)置模板路徑和語言包
          $this->setsubtemplates("home/index_tpl");
         
          /**
           * 頁面輸出
           */
          /*頁頭導(dǎo)航的樣式判斷*/
          $this->output('search_header_sign','1');
          //對模板上的模塊標(biāo)識符進(jìn)行替換
          $this->output("product_order_array",$product_order_array);
          $this->output("keyword_html_name",$keyword_html_name);
          $this->output("search_cate",$SearchProductCateArray);//搜索中的商品類別
          $this->output('channel_all',   $channel_all);   //導(dǎo)航菜單頻道
          $this->output('language_array',   $language);   //該語言種類
          $default_code = $this->fetchpage($template_name);//取輸出到模板上的內(nèi)容
          if (is_array($module)){
           foreach ($module as $k => $v){
            $line = "";
            $line = '<module>'.$k.'</module>';
            $replacements = $v;
            $default_code = @str_replace($line,$replacements,$default_code);
           }
          }
          $this_my_file = @preg_replace('/<module>.*?<[url=]\\/module>/is',"",$default_code[/url]);
          require_once("makehtml.class.php");
          /*根目錄下生成文件*/
          //判斷是否是默認(rèn)語言,如果是則用
          if ($language['language_state'] == '1'){
           if (file_exists('../index.html')){
            @unlink('../index.html');
           }
           $file_name = '../index.html';
          }else {
           if (file_exists('../index_'.$language['language_path'].'.html')){
            @unlink('../index_'.$language['language_path'].'.html');
           }
           $file_name = '../index_'.$language['language_path'].'.html';
          }
          $this_my_file = str_replace("../","",$this_my_file);
          $patterns = array (
          '/home\\/home\\/category.php/is',
          '/href=\\"category.php/is',
          '/home\\/home\\/member.php/is',
          '/href=\\"member.php/is',
          '/home\\/home\\/channel.php/is',
          '/href=\\"channel.php/is',
          '/home\\/home\\/shop.php/is',
          '/href=\\"shop.php/is',
          '/home\\/home\\/shop_brand.php/is',
          '/href=\\"shop_brand.php/is',
          '/home\\/home\\/vote.php/is',
          '/=\\"vote.php/is',
          "/\\('vote.php/is",
          '/home\\/home\\/product.php/is',
          '/href=\\"product.php/is',
          '/home\\/home\\/productmessage.php/is',
          '/href=\\"productmessage.php/is',
          '/switcher.swf/is',
          '/js_statics_sign=1/is',
          "/\\'shop.php/is",
          "/\\'product.php/is",
          );
          $replacements = array (
          'home/category.php',
          'href="home/category.php',
          'home/member.php',
          'href="home/member.php',
          'home/channel.php',
          'href="home/channel.php',
          'home/shop.php',
          'href="home/shop.php',
          'home/shop_brand.php',
          'href="home/shop_brand.php',
          'home/vote.php',
          '="home/vote.php',
          "('home/vote.php",
          'home/product.php',
          'href="home/product.php',
          'home/productmessage.php',
          'href="home/productmessage.php',
          'switcher_html.swf',
          'js_statics_sign=3',
          "'home/shop.php",
          "'home/product.php",
          );
          $this_my_file = preg_replace($patterns,$replacements,$this_my_file);
         
          //如果使用動態(tài)訪問,則不生成靜態(tài)頁
          if ($this->_configinfo['websit']['index_html'] == '0'){
           echo $this_my_file;exit;
          }
         
          if (!MakeHtml::tohtmlfile($file_name, $this_my_file)){
           return $this->_lang['langChannelIndexCreateLostFile'];
          }else {
           return true;
          }
         }
        }else {
         return $this->_lang['langChannelIndexCreateLostParamFile'];
        }
      }
      [/php]

      很復(fù)雜,因為包含了多語言,欄目緩存等,不過就靜態(tài)化的話,關(guān)鍵就是這句了

      [php]MakeHtml::tohtmlfile($file_name, $this_my_file)[/php]

      這個類他加密了,不過據(jù)我的猜測應(yīng)該是fwrite之類的吧,這樣就生成了index.html了。。

      以后先判斷根目錄下有無這個文件,有就跳過去,沒有則生成。。。

      好了,先寫這么多了。。。困了。。睡覺去了。。。

      以后有空再寫吧。。。。

      694

      主題

      36

      好友

      1萬

      積分

      千象

      叫我K兄好了

      Rank: 16Rank: 16Rank: 16Rank: 16

      威望
      5514
      開源幣
      293
      注冊時間
      2007-12-7
      積分
      11786
      帖子
      3015
      主題
      694
      UID
      52443

      第一顆象牙 第二顆象牙 第三顆象牙 第四顆象牙

      2#
      發(fā)表于 2009-7-1 04:24:41 |只看該作者

      2、SHOPNC的MVC

      本帖最后由 kakashilw 于 2009-7-1 13:58 編輯

      SHOPNC的MVC和現(xiàn)在主流框架的MVC還是有些區(qū)別的。。。

      最大的不同在于,SHOPNC是多入口的,不同功能一個入口文件,然后再在main()函數(shù)中分發(fā)。。。

      拿一個商品的展示頁為例。。。。

      [php]
      require ("../global.inc.php");   //載入核心類庫,這個上面提到過了
      class ShowProduct extends CommonFrameWork{       //都集成CommonFrameWork這個類
          ...................

        function main(){
                ..............
         }

         .................
      }

      $product = new ShowProduct();
      $product->main();
      unset($product);
      [/php]

      每個入口文件大致是 這樣的結(jié)構(gòu)了。。。

      OK,看著還是蠻簡潔明了的。。。。

      ------------------------------------------------------------------------------------------------------------------------

      好了,下面著重分析下main函數(shù),因為這里面包含的是  初始化(類似構(gòu)造函數(shù)的功能) , 路由轉(zhuǎn)發(fā)  這幾步內(nèi)容

      基本相當(dāng)于MVC眾的"C"了


      (1)初始化,一般都是這種風(fēng)格的。。。  

      (PS:這里插一句,很佩服大白菜產(chǎn)品的代碼風(fēng)格,非常一致,看來之前他所說的一個員工拿到另一個的代碼,最多半小時就能上手果真不是吹的,呵呵)

      [php]
        /**
         * 創(chuàng)建商品對象
         */
        if (!is_object($this->obj_product)){
         require_once("product.class.php");
         $this->obj_product = new ProductClass();
        }
        /**
         * 創(chuàng)建驗證對象
         */
        if (!is_object($this->objvalidate)){
         require_once("commonvalidate.class.php");
         $this->objvalidate = new CommonValidate();
        }
        /**
         * 網(wǎng)站提醒操作
         */
        if (!is_object($this->obj_remind)){
         require_once('remind.class.php');
         $this->obj_remind = new RemindClass();
        }
        /**
         * 創(chuàng)建會員對象
         */
        if (!is_object($this->obj_member)){
         require_once("member.class.php");
         $this->obj_member = new MemberClass();
        }
        /**
         * 初始化商品品牌類
         */
        if (!is_object($this->obj_product_brand)){
         require_once("product_brand.class.php");
         $this->obj_product_brand = new ProductBrandClass();
        }

        /**
         * 設(shè)置模板路徑
         */
        $this->setsubtemplates("home");
        /**
         * 語言包
         */
        $this->getlang("product");
      [/php]

      (2)路由轉(zhuǎn)發(fā)

      [php]
        switch ($this->_input['action']){
         case "list":
          $this->_listproduct();
          break;
         case "textlist":
          $this->_listproduct();
          break;
         case "view":
          $this->_viewproduct();
          break;
         case "search":
          $this->output('InfoSelectorTarget',Common::getTargetMenu("search"));
          $this->_searchproduct();
          break;
         case "compare":
          $this->_compareproduct();
          break;
         case "compareresult":
          $this->_compareproductresult();
          break;
         case "compare_remove":
          $this->_compareremove();
          break;
         case "clean_reviewed":
          $this->_cleanreviewedproduct();
          break;
         case "check_code":
          $this->_check_code();
          break;
         case 'all':
          $this->_listproduct();
          break;
         case "setReview":
          $p_code = $this->_input['p_code'];
          $this->setReviewed($p_code);
          break;
         case "ajax_get_attribute":
          $this->_ajax_get_attribute();
          break;
         default:
          $this->_listproduct();
          break;
        }
      [/php]

      呵呵,有注釋,看著就簡單多了吧。。。
      ------------------------------------------------------------------------------------------------------------------


      好了,下面看看MVC鐘的"V"是怎樣的。。。

      拿_viewproduct()這個舉例,可以看到函數(shù)的最下端有
      [php]
         $this->output('pURL',$pURL);
         $this->output('pic_array',$pic_array);//商品圖片列表
         $this->output('class_level',$class_level);
         $this->output("title_message"  , $title_p_name);     //TITLE內(nèi)容
         $this->output("keyword_message", $keyword_p_name);     //關(guān)鍵字內(nèi)容
         $this->output("ses_login", $_SESSION['s_login']);   //登陸信息
         $this->output("page_list", $page_list);
         $this->output("shop_info", $shop_info);
         $this->output("product_row", $product_row);
         $this->output("PathLinks", $cate_path);
         $this->output("ses_login", $_SESSION['s_login']);   //登陸信息
         $this->output("message_array", $message_array);   //商品留言
         $this->output("seller_info", $seller_info);  //商家信息
         $this->output("have_attribute", $have_attribute);
         $this->output("product_attribute", $product_attribute);
         $this->output("product_attribute_content", $product_attribute_content);
         $this->output("product_have_attribute", $pac_attribute);
         $this->output("payment_array", $payment_array);
         $this->output("currency_array", $currency_array);
         $this->output("product_order_array", $product_order_array);
         $this->output("lefttime", $text_left_time);
         $this->output("exchange_remark", $exchange_remark);
         $this->output("sel_area", $sel_area);
         $this->output("sel_brand", $sel_brand);
         $this->showpage("product.view");
      [/php]

      哈哈,用過smarty或框架的童鞋是不是很熟悉啊,對了,這個就是shopnc的模板引擎了。。。 對應(yīng)的是home目錄下的product.view.html了。。。


      1.             <p><tpl>$langUserStore</tpl>:<tpl> $shop_info.shop_name </tpl></p>
      2.             <p><tpl>$langMerchant</tpl>:<tpl> $seller_info.login_name </tpl></p>
      3.             <p><tpl>$langUserArea</tpl>:<tpl> $shop_info.shop_province </tpl></p>
      復(fù)制代碼


      類似這種東東,用<tpl></tpl>標(biāo)簽類輸出變量等。。。。

      ------------------------------------------------------------------------------------------------------------

      C和V都講了,只剩"M"了。。

      [php]
        /**
         * 創(chuàng)建商品對象
         */
        if (!is_object($this->obj_product)){
         require_once("product.class.php");
         $this->obj_product = new ProductClass();
        }

      ...............................

         /**
          * 取得商品信息
          */
         $product_row = $this->obj_product->getProductRow($p_id);
      [/php]

      哈哈,看明白了吧。。這個“ProductClass”類就可以理解成M了。。它里面封裝了很多product相關(guān)的業(yè)務(wù)邏輯。。。

      好了,就簡單寫這么多吧。。。發(fā)帖子比看代碼累多了。。。

      最后贊一句,大白菜的產(chǎn)品的代碼質(zhì)量,規(guī)范等是看了這麼多產(chǎn)品中最好的一款了。。。

      其中的權(quán)限控制,多語言,多模板都運(yùn)用的相當(dāng)不錯。。。

      特別是靜態(tài)化方面,承載一定負(fù)載還是沒問題的。。。

      694

      主題

      36

      好友

      1萬

      積分

      千象

      叫我K兄好了

      Rank: 16Rank: 16Rank: 16Rank: 16

      威望
      5514
      開源幣
      293
      注冊時間
      2007-12-7
      積分
      11786
      帖子
      3015
      主題
      694
      UID
      52443

      第一顆象牙 第二顆象牙 第三顆象牙 第四顆象牙

      3#
      發(fā)表于 2009-7-1 04:24:44 |只看該作者

      3、用戶輸入之檢測

      本帖最后由 kakashilw 于 2009-7-2 13:38 編輯

      (1)前端

      1. <script language="JavaScript" type="text/javascript" src="<tpl> $site_url </tpl>/js/jquery/jquery.validate.js"></script>

      2. $(function(){
      3. $("#ownaddproduct").validate({
      4.   errorClass: "wrong",
      5.   rules: {
      6.    txtPname: {required:true},
      7.    txtPstorage: {
      8.     required:true,
      9.     number:true,
      10.     min: function(){
      11.       if($("#radioSelltype2").attr('checked')==true){
      12.        return 5;
      13.       }else{
      14.        return 1;
      15.       }
      16.      }
      17.    },
      18.    minimumBid: {
      19.     required: "#radioSelltype0:checked",
      20.     number: true,
      21.     min: function(){
      22.       if($("#radioSelltype0").attr('checked')==true){
      23.        return 0.01;
      24.       }else{
      25.        return 0;
      26.       }
      27.      }
      28.    },
      29.    price_step: {
      30.     required: "#radioSelltype0:checked",
      31.     number: true,
      32.     min: function(){
      33.      if($("#radioSelltype0").attr('checked')==true && $("#inc2").attr('checked')==true){
      34.       return 1;
      35.      }else{
      36.       return 0;
      37.      }
      38.     }
      39.    },
      40.    txtPprice: {required: "#radioSelltype1:checked",number: true,min: 0.01},
      41.    txtGroupprice: {required:"#radioSelltype2:checked",number:true,min: 0.01},
      42.    txtPoldprice: {required: "#radioSelltype2:checked",number: true,min: function(){return $("#txtGroupprice").val();}},
      43.    txtGroupmincount: {
      44.     required: "#radioSelltype2:checked",
      45.     number: true,
      46.     min: function(){
      47.      if($("#radioSelltype2").attr('checked')==true){
      48.       return 5;
      49.      }else{
      50.       return 0;
      51.      }
      52.     },
      53.     max:function(){
      54.      if($("#radioSelltype2").attr('checked')==true){
      55.       if($("#txtPstorage").val() >= 100){
      56.        return 100;
      57.       }else{
      58.        return $("#txtPstorage").val();
      59.       }
      60.      }else{
      61.       return 10000000;
      62.      }
      63.     }
      64.    },
      65.    area_id: {required: true},
      66.    pyTF: {
      67.     required: "#whopsBuyer:checked",
      68.     number: true,
      69.     min: function(){
      70.      if($("#whopsBuyer").attr('checked')==true){
      71.       return 1;
      72.      }else{
      73.       return 0;
      74.      }
      75.     }
      76.    },
      77.    kdTF: {
      78.     required: "#whopsBuyer:checked",
      79.     number: true,
      80.     min: function(){
      81.      if($("#whopsBuyer").attr('checked')==true){
      82.       return 1;
      83.      }else{
      84.       return 0;
      85.      }
      86.     }
      87.    },
      88.    emsTF: {
      89.     required: "#whopsBuyer:checked",
      90.     number: true,
      91.     min: function(){
      92.      if($("#whopsBuyer").attr('checked')==true){
      93.       return 1;
      94.      }else{
      95.       return 0;
      96.      }
      97.     }
      98.    },
      99.    slValiddays: {
      100.     required: true,
      101.     number: true,
      102.     min: 1,
      103.     max: 30
      104.    }
      105.   },
      106.   messages: {
      107.    txtPname: {required: "<tpl> $errProductNameEmpty </tpl>"},
      108.    txtPstorage: {
      109.     required: "<tpl> $errPstorage </tpl>",
      110.     number: "<tpl> $errPstorage </tpl>",
      111.     min: function(){
      112.      if($("#radioSelltype2").attr('checked')==true){
      113.       return "<tpl> $errPstorageByGroup </tpl>";
      114.      }else{
      115.       return "<tpl> $errPstorage </tpl>";
      116.      }
      117.     }
      118.    },
      119.    minimumBid: {required: "<tpl> $errMinimumbidWrong </tpl>",number: "<tpl> $errMinimumbidWrong </tpl>",min: "<tpl> $errMinimumbidWrong </tpl>"},
      120.    price_step: {required: "<tpl> $langProductAUserDefinedUppriceIsEmpty </tpl>",number: "<tpl> $langProductAUserDefinedUppriceIsEmpty </tpl>",min: "<tpl> $langProductAUserDefinedUppriceIsEmpty </tpl>"},
      121.    txtPprice: {required: "<tpl> $errPprice </tpl>",number: "<tpl> $errPprice </tpl>",min: "<tpl> $errPprice </tpl>"},
      122.    txtGroupprice: {required: "<tpl> $errGroupprice </tpl>",number: "<tpl> $errGroupprice </tpl>",min: "<tpl> $errGroupprice </tpl>"},
      123.    txtPoldprice: {required: "<tpl> $errPoldprice </tpl>",number: "<tpl> $errPoldprice </tpl>",min: "<tpl> $errPoldprice </tpl>"},
      124.    txtGroupmincount: {required: "<tpl> $errGroupmincount </tpl>",number: "<tpl> $errGroupmincount </tpl>",min:"<tpl> $errGroupmincount </tpl>",max:"<tpl> $errGroupmincount </tpl>"},
      125.    area_id: {required:"<tpl> $errProvince </tpl>"},
      126.    pyTF: {required: "<tpl> $langProductPyTFIsEmpty </tpl>",number: "<tpl> $langProductPyTFIsEmpty </tpl>",min: "<tpl> $langProductPyTFIsEmpty </tpl>"},
      127.    kdTF: {required: "<tpl> $langProductKdTFIsEmpty </tpl>",number: "<tpl> $langProductKdTFIsEmpty </tpl>",min: "<tpl> $langProductKdTFIsEmpty </tpl>"},
      128.    emsTF: {required: "<tpl> $langProductEMSTFIsEmpty </tpl>",number: "<tpl> $langProductEMSTFIsEmpty </tpl>",min: "<tpl> $langProductEMSTFIsEmpty </tpl>"},
      129.    slValiddays: {required: "<tpl> $errPSValiddays </tpl>",number: "<tpl> $errPSValiddays </tpl>",min: "<tpl> $errPSValiddays </tpl>",max: "<tpl> $errPSValiddays </tpl>"}
      130.   },
      131.   submitHandler: function() {
      132.    var check_sign = false;//貨幣選擇狀態(tài)標(biāo)識
      133.    var payment_check = false;//支付方式選擇狀態(tài)標(biāo)識
      134.    var predeposit_check = false;//預(yù)存款選擇狀態(tài)標(biāo)識
      135.    var payment_alert_sign = false;//支付方式是否拋出錯誤信息標(biāo)識
      136.    
      137.    //判斷預(yù)存款選擇狀態(tài)
      138.    if($('#pay_predeposit').attr('checked') == true){
      139.     predeposit_check = true;
      140.    }
      141.    //驗證支付方式的復(fù)選驗證,是否全選,選中的支付方式是否選擇了支付貨幣種類
      142.    $("#ownaddproduct input[@type=hidden]").each(function(){
      143.     if(this.name.indexOf('payment_cur_') == 0){
      144.      //判斷支付方式是否被選擇
      145.      str = this.name.split('payment_cur_');//取支付方式名稱 str[1]
      146.      if($('#txtPayment_'+str[1]).attr('checked') == true){
      147.       //取該支付方式的貨幣種類字符串
      148.       str2 = $('#payment_cur_'+str[1]).val().split('|');
      149.       payment_check = true;//標(biāo)識有選擇的支付方式
      150.       //判斷該選中的支付方式起碼有一個支持的貨幣種類被選擇
      151.       for(i=0;i<str2.length;i++){
      152.        if($('#currency_'+str2[i]).attr('checked') == true){
      153.         check_sign = true;
      154.         break;
      155.        }
      156.       }
      157.       if(check_sign == false){//沒有選擇貨幣
      158.        payment_alert_sign = true;
      159.       }
      160.      }
      161.     }
      162.     check_sign = false;
      163.    });
      164.    
      165.    if(predeposit_check == true){//選擇預(yù)付款
      166.     if(payment_alert_sign == false){//判斷是否有錯誤拋出:沒有
      167.      var oEditor = FCKeditorAPI.GetInstance('txtPinfo');
      168.      $('#txtPinfo').val(oEditor.GetXHTML(true));
      169.      if($('#txtPinfo').val() != ''){
      170.       document.getElementById('ownaddproduct').submit();
      171.      }else{
      172.       alert('<tpl> $errPSInfoEmpty </tpl>');
      173.       return false;
      174.      }
      175.     }else{
      176.      alert('<tpl> $errPaymentSelCur </tpl>');
      177.      return false;
      178.     }
      179.    }else{//沒有選擇預(yù)存款
      180.     if(payment_alert_sign == false && payment_check == true){//判斷是否有錯誤拋出并且選擇了起碼一種支付方式:沒有
      181.      var oEditor = FCKeditorAPI.GetInstance('txtPinfo');
      182.      $('#txtPinfo').val(oEditor.GetXHTML(true));
      183.      if($('#txtPinfo').val() != ''){
      184.       document.getElementById('ownaddproduct').submit();
      185.      }else{
      186.       alert('<tpl> $errPSInfoEmpty </tpl>');
      187.       return false;
      188.      }
      189.     }else{
      190.      alert('<tpl> $errPaymentSelCur </tpl>');
      191.      return false;
      192.     }
      193.    }
      194.   }
      195. });
      196. });
      復(fù)制代碼


      (2)后端
      [php]
        $this->objvalidate->validateparam = array(
        array("input"=>$this->_input["txtPname"],"require"=>"true","message"=>$this->_lang['errPSNameEmpty']),
        array("input"=>$this->_input["slPCId"],"require"=>"true","message"=>$this->_lang['errPcidEmpty']),
        array("input"=>$this->_input["txtPinfo"],"require"=>"true","message"=>$this->_lang['errPSInfoEmpty']),
        array("input"=>$this->_input["radioSelltype"],"require"=>"true","validator"=>"Number","message"=>$this->_lang['errPSSelltype']),
        array("input"=>$this->_input["radioType"],"require"=>"true","validator"=>"Number","message"=>$this->_lang['errPSType']),
        array("input"=>$this->_input["txtPstorage"],"require"=>"true","validator"=>"Number","message"=>$this->_lang['errPSstorage']),
        //array("input"=>$this->_input["txtPprice"],"validator"=>"Currency","message"=>$this->_lang['errPSprice']),
        array("input"=>$this->_input["txtGroupprice"],"validator"=>"Currency","message"=>$this->_lang['errPSGroupprice']),
        array("input"=>$this->_input["txtPoldprice"],"validator"=>"Currency","message"=>$this->_lang['errPsPoldprice']),
        array("input"=>$this->_input["txtPoldprice"],"validator"=>"Compare","operator"=>">=","to"=>$this->_input["txtGroupprice"],"message"=>$this->_lang['errPSPriceNoGroupPrice']),
        array("input"=>$this->_input["txtGroupmincount"],"validator"=>"Number","message"=>$this->_lang['errPSGroupmincount']),
        array("input"=>$this->_input["area_id"],"require"=>"true","message"=>$this->_lang['errPProductAreaIsEmpty']),
        array("input"=>$this->_input["radioTransfee"],"require"=>"true","validator"=>"Number","message"=>$this->_lang['errPSTransfee']),
        array("input"=>$this->_input["radioInvoices"],"require"=>"true","validator"=>"Number","message"=>$this->_lang['errPSInvoices']),
        array("input"=>$this->_input["radioWarranty"],"require"=>"true","validator"=>"Number","message"=>$this->_lang['errPSWarranty']),
        array("input"=>$this->_input["slValiddays"],"require"=>"true","validator"=>"Number","message"=>$this->_lang['errPSValiddays']),
        array("input"=>$this->_input["chxAutopublish"],"validator"=>"Integer","message"=>$this->_lang['errPSAutopublish']),
        array("input"=>$this->_input["chxRecommended"],"validator"=>"Integer","message"=>$this->_lang['errPSRecommended']));
        $error = $this->objvalidate->validate();
        
        if($error != ""){
         $this->redirectPath("error","",$error);
        }
      [/php]

      694

      主題

      36

      好友

      1萬

      積分

      千象

      叫我K兄好了

      Rank: 16Rank: 16Rank: 16Rank: 16

      威望
      5514
      開源幣
      293
      注冊時間
      2007-12-7
      積分
      11786
      帖子
      3015
      主題
      694
      UID
      52443

      第一顆象牙 第二顆象牙 第三顆象牙 第四顆象牙

      4#
      發(fā)表于 2009-7-1 04:24:46 |只看該作者

      SHOPNC的模板語言

      本帖最后由 kakashilw 于 2009-7-3 01:06 編輯

      這里就不研究原理了,看看用法吧

      (1)if

      1. <tpl> if $search_header_sign eq '1' </tpl> class="current" <tpl> /if </tpl>
      復(fù)制代碼


      (2)loop

      1.   <tpl> section name=i loop=$app </tpl>
      2.   <li><a href="<tpl> $app[i].url </tpl>"><tpl> $app[i].name </tpl></a></li>
      3.         <tpl> /section </tpl>
      復(fù)制代碼


      (3)var
      1. <tpl> $site_url </tpl>
      復(fù)制代碼

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多