/FBCOM_WCM/production/defalut/main/www/????/WORKAREA/WA/templatedata/????_??/????/presentation/hot_product.tpl
Smarty Template | 232 lines | 197 code | 35 blank | 0 comment | 16 complexity | e23f5d30f017a2b49f7957b7ec2b81bc MD5 | raw file
- <?xml version="1.0" encoding="UTF-8"?>
- <iw_pt>
- <iw_perl><![CDATA[
-
- use TeamSite::Config;
- use Custom::Uti;
- use File::stat;
- use TeamSite::XMLparser;
-
- my $iwhome = TeamSite::Config::iwgethome();
- #log????
- my $isDebug = 1;
- my $debug_output = Custom::Uti::getLogPath("pt.log");
-
- my $dcr_name = iwpt_dcr_value('dcr.root.dcr-name');
-
- #more??,??
- my $moreLink = "$dcr_name" . "_more.htm";
-
- #????
- my $messageLimit = 15;
-
- # ????
- my @allOtherActivity = iwpt_dcr_list('dcr.root.otherActivity');
- my $allOtherActivity = @allOtherActivity;
- my $allOtherActivity_detail = "";
-
- if ($allOtherActivity eq "0") {
- $allOtherActivity_detail = "";
- } else {
- for ( my $i = 0; $i < $allOtherActivity; $i++ ) {
- # ????????,?????
- my $publishDate = iwpt_dcr_value('dcr.root.otherActivity[$i].publish-date');
- my $endDate = iwpt_dcr_value('dcr.root.otherActivity[$i].off-date');
- unless($publishDate){$publishDate = Custom::Uti::getToday()};
- unless($endDate){$endDate = "21071231"};
- my $today = Custom::Uti::getToday();
- if($publishDate <= $today && $endDate >= $today){
- if( $i < $messageLimit){
- my $pic = iwpt_dcr_value('dcr.root.otherActivity[$i].pic');
- $pic =~ s/^\/htdocs\/.*\/$dcr_name\//\.\/$dcr_name\//;
- my $title = iwpt_dcr_value('dcr.root.otherActivity[$i].title');
- my $desc = iwpt_dcr_value('dcr.root.otherActivity[$i].disc');
- my $url = iwpt_dcr_value('dcr.root.otherActivity[$i].url');
- $allOtherActivity_detail .= qq{
- <table width='95%' border='0' align='center' cellpadding='0' cellspacing='0' class='table-news-5'>
- <tr>
- <td valign='top' align='left' width='70'><img src='$pic' width='70' height='70' class='pic'></td>
- <td valign='top'>
- <h2><a href='$url'>$title</a></h2>
- <a href='$url'>$desc</a>
- </td>
- </tr>
- </table>
- };
- }
- }
- else{
- $messageLimit++;
- }
- }
- }
-
- #??more????
- &genMore2;
-
- #&insertDB;
-
-
- #============================================================================
- # ????(UTF8?????????)
- # arg1:pt??????
- # arg2:dcr??????
- # arg3:??????????
- #============================================================================
- sub genHtml {
- my ( $pt, $dcr, $output ,$args ) = @_;
- my $param = $args ? "-iw_pt-arg $args" : "";
- 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") ;
- debug("iwgen CMD = $autoGenCMD");
- my $autoGenRC = `$autoGenCMD`;
- debug("iwgen RETURN = $autoGenRC");
- $output = toBig5($output);
-
- if ( $autoGenRC =~ /could not create/
- || $autoGenRC =~ /does not/
- || !-e $output )
- {
- return 0;
- }
- return 1;
- }
-
- #============================================================================
- # ??more???
- #============================================================================
-
- sub genMore2{
-
- my $dcrPath = iwpt_dcr_value('dcr.root.dcr-path');
- $dcrPath =~ s|\/|\\|g;
- my $saveName = "htdocs\\bank\\home\\$dcr_name" . "_more.htm";
- my $ptName = "bank_home_more2.tpl";
- my $ptPath = $dcrPath;
- my $genPath = $dcrPath;
- $ptPath =~ s|\\data\\.*|\\presentation\\$ptName|gi;
- $genPath =~ s|\\templatedata\\.*|\\$saveName|gi;
- $isGenSuccess = genHtml( $ptPath, $dcrPath, $genPath );
-
- if ($isGenSuccess) {
- debug("GENERATE PAGE SUCCESS:" . toBig5($genPath) );
- }
- else {
- debug("GENERATE PAGE FAIL:" . toBig5($genPath) );
- }
- }
-
-
-
- sub insertDB{
- my $rootNodes = getXmlRootnode( toBig5(iwpt_dcr_value('dcr.root.dcr-path')) );
-
- my $type = $rootNodes->value('type');
- my $delSql = "delete from ts_publish_page where type='$type'";
- my @sqlAry = ($delSql);
-
- my $today = Custom::Uti::getToday();
- my @alist = $rootNodes->get_node_list('otherActivity');
- my $i = 1;
- foreach my $rec (@alist){
- my $pic = $rec->get_node('pic')->value();
- $pic =~ s/^\/htdocs\/.*\/$dcr_name\//\.\/$dcr_name\//;
- my $desc = $rec->get_node('disc')->value();
- my $title = $rec->get_node('title')->value();
- my $linkUrl = $rec->get_node('url')->value();
- my $publishDate = $rec->get_node('publish-date')->value();
- my $endDate = $rec->get_node('off-date')->value();
- my $id = $rec->get_node('pk')->value();
- $linkUrl =~ s/^\/htdocs\/.*\/$dcr_name\//\.\/$dcr_name\//;
- # my $linkUrl = "http://10.204.241.15/bank/rich/home/$dcr_name.htm";
- # ????????,?????
- unless($publishDate){$publishDate = Custom::Uti::getToday()};
- unless($endDate){$endDate = "21071231"};
-
- debug("pic:$pic");
- debug("title:$title");
- debug("desc:$desc");
- debug("url:$linkUrl");
- debug("publishDate:$publishDate");
- debug("endDate:$endDate");
- debug("pk:" . toBig5($id));
-
- $sql = qq{
- insert into ts_publish_page (id,title,link_url,pic_url,description,type,publish_date,ending_date,modify_date,put_home,orders)
- values('$id','$title','$linkUrl','$pic','$desc','$type','$publishDate','$endDate','$today','y',$i)
- };
- $sql = toBig5($sql);
- push @sqlAry , $sql;
- $i++;
- }
- use Custom::Dao;
- my $section = "wcm_datasource";
- my $isInsertSuccess = Custom::Dao::processTransaction($section,\@sqlAry);
- if($isInsertSuccess){
- debug ("INSERT DB SUCCESSFULLY\n");
- }
- else{
- debug("INSERT FAIL\n");
- }
-
- }
-
- sub getXmlRootnode {
- my ($dcr) = @_;
- debug("FILE NOT FOUND -->$dcr") if ( !-e $dcr );
- open( DCR, $dcr ) or debug("$! - Cannot open DCR ($dcr)");
- local $/ = undef;
- my $xml = <DCR>;
- close DCR;
- use TeamSite::XMLparser;
- my $parser = TeamSite::XMLparser->new();
- my $rootnode = $parser->parse($xml);
- return $rootnode;
- }
-
- sub toUTF8 {
- my ($in) = @_;
- my $out = TeamSite::I18N_utils::utf8_normalize_string( "Big5", $in );
- return $out;
- }
-
- sub toBig5 {
- my ($in) = @_;
- my $out = TeamSite::I18N_utils::utf8_to_other_encoding( "Big5", $in );
- return $out;
- }
-
- sub debug {
- if ( $debug_output && $isDebug ) {
- my $t = scalar localtime;
- open( OUT, ">> $debug_output" ) || return;
- print OUT "$t @_\n";
- close OUT;
- }
- }
-
- ]]></iw_perl>
- <![CDATA[
-
-
- <link href="../../css/base.css" rel="stylesheet" type="text/css" media="screen">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-
- <table width="100%" border="0" cellpadding="0" cellspacing="0" class="title-bar-1">
- <tr>
- <td class="left"></td>
- <td><h1>????</h1><span>| <a href="<iw_value name='$moreLink'/>">more</a></span></td>
- <td class="right"></td>
- </tr>
- </table>
-
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td height="125" valign="top">
- <iw_value name='$allOtherActivity_detail'/>
- </td>
- </tr>
- </table>
-
-
- ]]>
- </iw_pt>