PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/FBCOM_WCM/testing/default/main/www/????/???/WORKAREA/WA/templatedata/???_??/?????/presentation/activity_list.tpl

http://fubon-wcm.googlecode.com/
Smarty Template | 225 lines | 189 code | 36 blank | 0 comment | 16 complexity | 2efd866e6d53c1753703c28a1720775d MD5 | raw file
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <iw_pt>
  3. <iw_perl><![CDATA[
  4. use TeamSite::Config;
  5. use Custom::Uti;
  6. use File::stat;
  7. use TeamSite::XMLparser;
  8. my $iwhome = TeamSite::Config::iwgethome();
  9. #log????
  10. my $isDebug = 1;
  11. my $debug_output = Custom::Uti::getLogPath("pt.log");
  12. my $dcr_name = iwpt_dcr_value('dcr.root.dcr-name');
  13. #more??,??
  14. #my $moreLink = "$dcr_name" . "_more.htm";
  15. my $moreLink = "http://www.fubon.com/bank/creditcard/inst_discount/inst_discount.htm?show=m2";
  16. #??????(11->??????,12->?????,13->????,14->????)
  17. my $messageType = iwpt_dcr_value('dcr.root.type');
  18. my $messageTitle = "?????";
  19. my $messageTitleClass = "other-info right";
  20. #????
  21. my $messageLimit = 2;
  22. # ????
  23. my @allOtherActivity = iwpt_dcr_list('dcr.root.otherActivity');
  24. my $allOtherActivity = @allOtherActivity;
  25. my $allOtherActivity_detail = "";
  26. # ???????? Modify By Gasper.Huang 20101110
  27. my $pic = iwpt_dcr_value('dcr.root.picContent');
  28. $pic =~ s/^\/htdocs\/.*\/$dcr_name\//\.\/$dcr_name\//;
  29. if ($allOtherActivity eq "0") {
  30. $allOtherActivity_detail = "";
  31. } else {
  32. for ( my $i = 0; $i < $allOtherActivity; $i++ ) {
  33. # ????????,?????
  34. my $publishDate = iwpt_dcr_value('dcr.root.otherActivity[$i].publish-date');
  35. my $endDate = iwpt_dcr_value('dcr.root.otherActivity[$i].off-date');
  36. unless($publishDate){$publishDate = Custom::Uti::getToday()};
  37. unless($endDate){$endDate = "21071231"};
  38. my $today = Custom::Uti::getToday();
  39. if($publishDate <= $today && $endDate >= $today){
  40. if( $i < $messageLimit){
  41. my $title = iwpt_dcr_value('dcr.root.otherActivity[$i].title');
  42. my $url = iwpt_dcr_value('dcr.root.otherActivity[$i].url');
  43. # ????????
  44. my $urlTarget = iwpt_dcr_value('dcr.root.otherActivity[$i].urlTarget');
  45. $urlTarget = ($urlTarget eq "_01") ? "" : " target=\"_blank\"";
  46. $allOtherActivity_detail .= "<li><a href=\"$url\"$urlTarget>$title</a></li>\n";
  47. }
  48. }
  49. else{
  50. $messageLimit++;
  51. }
  52. }
  53. }
  54. #??more????
  55. &genMore1;
  56. #&insertDB;
  57. #============================================================================
  58. # ????(UTF8?????????)
  59. # arg1:pt??????
  60. # arg2:dcr??????
  61. # arg3:??????????
  62. #============================================================================
  63. sub genHtml {
  64. my ( $pt, $dcr, $output ,$args ) = @_;
  65. my $param = $args ? "-iw_pt-arg $args" : "";
  66. my $autoGenCMD = toBig5("$iwhome/iw-perl/bin/iwperl $iwhome/bin/iwpt_compile.ipl -osenc cp950 -pt $pt -iw_pt-dcr $dcr -ofile $output $param 2>&1") ;
  67. debug("iwgen CMD = $autoGenCMD");
  68. my $autoGenRC = `$autoGenCMD`;
  69. debug("iwgen RETURN = $autoGenRC");
  70. $output = toBig5($output);
  71. if ( $autoGenRC =~ /could not create/
  72. || $autoGenRC =~ /does not/
  73. || !-e $output )
  74. {
  75. return 0;
  76. }
  77. return 1;
  78. }
  79. #============================================================================
  80. # ??more???
  81. #============================================================================
  82. sub genMore1{
  83. my $dcrPath = iwpt_dcr_value('dcr.root.dcr-path');
  84. $dcrPath =~ s|\/|\\|g;
  85. my $saveName = "htdocs\\bank\\creditcard\\home\\$dcr_name" . "_more.htm";
  86. my $ptName = "creditcard_more1.tpl";
  87. my $ptPath = $dcrPath;
  88. my $genPath = $dcrPath;
  89. $ptPath =~ s|\\data\\.*|\\presentation\\$ptName|gi;
  90. $genPath =~ s|\\templatedata\\.*|\\$saveName|gi;
  91. $isGenSuccess = genHtml( $ptPath, $dcrPath, $genPath );
  92. if ($isGenSuccess) {
  93. debug("GENERATE PAGE SUCCESS:" . toBig5($genPath) );
  94. }
  95. else {
  96. debug("GENERATE PAGE FAIL:" . toBig5($genPath) );
  97. }
  98. }
  99. sub insertDB{
  100. my $rootNodes = getXmlRootnode( toBig5(iwpt_dcr_value('dcr.root.dcr-path')) );
  101. my $type = $rootNodes->value('type');
  102. my $delSql = "delete from ts_publish_page where type='$type'";
  103. my @sqlAry = ($delSql);
  104. my $today = Custom::Uti::getToday();
  105. my @alist = $rootNodes->get_node_list('otherActivity');
  106. my $i = 1;
  107. foreach my $rec (@alist){
  108. my $title = $rec->get_node('title')->value();
  109. my $linkUrl = $rec->get_node('url')->value();
  110. my $publishDate = $rec->get_node('publish-date')->value();
  111. my $endDate = $rec->get_node('off-date')->value();
  112. my $id = $rec->get_node('pk')->value();
  113. $linkUrl =~ s/^\/htdocs\/.*\/$dcr_name\//\.\/$dcr_name\//;
  114. # my $linkUrl = "http://10.204.241.15/bank/rich/home/$dcr_name.htm";
  115. # ????????,?????
  116. unless($publishDate){$publishDate = Custom::Uti::getToday()};
  117. unless($endDate){$endDate = "21071231"};
  118. debug("title:$title");
  119. debug("url:$linkUrl");
  120. debug("publishDate:$publishDate");
  121. debug("endDate:$endDate");
  122. debug("pk:" . toBig5($id));
  123. $sql = qq{
  124. insert into ts_publish_page (id,title,link_url,type,publish_date,ending_date,modify_date,put_home,orders)
  125. values('$id','$title','$linkUrl','$type','$publishDate','$endDate','$today','y',$i)
  126. };
  127. $sql = toBig5($sql);
  128. push @sqlAry , $sql;
  129. $i++;
  130. }
  131. use Custom::Dao;
  132. my $section = "wcm_datasource";
  133. my $isInsertSuccess = Custom::Dao::processTransaction($section,\@sqlAry);
  134. if($isInsertSuccess){
  135. debug ("INSERT DB SUCCESSFULLY\n");
  136. }
  137. else{
  138. debug("INSERT FAIL\n");
  139. }
  140. }
  141. sub getXmlRootnode {
  142. my ($dcr) = @_;
  143. debug("FILE NOT FOUND -->$dcr") if ( !-e $dcr );
  144. open( DCR, $dcr ) or debug("$! - Cannot open DCR ($dcr)");
  145. local $/ = undef;
  146. my $xml = <DCR>;
  147. close DCR;
  148. use TeamSite::XMLparser;
  149. my $parser = TeamSite::XMLparser->new();
  150. my $rootnode = $parser->parse($xml);
  151. return $rootnode;
  152. }
  153. sub toUTF8 {
  154. my ($in) = @_;
  155. my $out = TeamSite::I18N_utils::utf8_normalize_string( "Big5", $in );
  156. return $out;
  157. }
  158. sub toBig5 {
  159. my ($in) = @_;
  160. my $out = TeamSite::I18N_utils::utf8_to_other_encoding( "Big5", $in );
  161. return $out;
  162. }
  163. sub debug {
  164. if ( $debug_output && $isDebug ) {
  165. my $t = scalar localtime;
  166. open( OUT, ">> $debug_output" ) || return;
  167. print OUT "$t @_\n";
  168. close OUT;
  169. }
  170. }
  171. ]]></iw_perl>
  172. <![CDATA[
  173. <link href="../../../css/base.css" rel="stylesheet" type="text/css" media="screen">
  174. <link href="../../../css/bank/channel-creditcard.css" rel="stylesheet" type="text/css" media="screen">
  175. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  176. <div class="<iw_value name='$messageTitleClass'/>">
  177. <div class="title-other-info">
  178. <h1><iw_value name='$messageTitle'/></h1>
  179. <span class="more">| <a href="<iw_value name='$moreLink'/>">more</a></span>
  180. </div>
  181. <!--???????? Modify By Gasper.Huang 20101110-->
  182. <!--<img src="../../../images/bank/pic-other-info-2.jpg" width="240" height="80">-->
  183. <img src="<iw_value name='$pic'/>" width="240" height="80">
  184. <ul>
  185. <iw_value name='$allOtherActivity_detail'/>
  186. </ul>
  187. </div>
  188. ]]>
  189. </iw_pt>