PageRenderTime 195ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/FBCOM_WCM/production/defalut/main/www/????/WORKAREA/WA/templatedata/????_??/????/presentation/hot_product.tpl

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