Webman-framework

Lightweight, Component-based, and Database-oriented Web Application Framework

About | Overview | Documentation

 

Documentation > Modules and APIs > webman_calendar_interactive

webman_calendar_interactive

 

Description:

Component-type module that provides interactive navigation (monthly) on calendar data.

 

Dependencies:

Webman-framework's Core Modules:

  • Calendar (Composition)
  • Table_List_Data (Composition)
  • TLD_HTML_Map (Composition)

Webman-framework's Component-type Modules:
  • CGI_Component::webman_CGI_component (Inheritance)

 

1. CGI Parameters

Below are CGI parameters that provide control to and passed by webman_calendar_interactive instance at application run-time.

calendar_year => "yyyy-mm-dd"
calendar_month => "Jan", "Feb", ... , "Dec"
calendar_date => 1, 2, ... , 31
calendar_day => 1, 2, ... , 7
calendar_ymd_selected => "yyyy-mm-dd"

The CGI parameters calendar_ymd_selected and calendar_day (passed over HTTP-GET method) are used by the module to provide calendar's date information picker facility.

 
2. View Template

The main part of view template content for webman_calendar_interactive module is actually a LIST template-element (33-41), passed to process_LIST hook function and processed by TLD_HTML_Map core module. The LIST template-element contains the formation of word patterns $tld_date1_, ..., $tld_date7_ and $tld_date1_content_, ..., $tld_date1_content_ as place-holders for calendar's date and date's content.

  1 <html>                                                                                               
  2 <head>                                                                                               
  3 <title>Untitled Document</title>                                                                     
  4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">                             
  5 </head>                                                                                              
  6                                                                                                      
  7 <body>                                                                                               
  8 <!-- start_view_ //-->                                                                               
  9 <table width="315" border="1">                                                                       
 10   <tr>                                                                                               
 11     <td width="45" colspan="7" align="center">                                                       
 12       <a href="<!-- dynamic_content_ name=cal_prev_month_link //-->">&lt;&lt;</a>                    
 13       $active_month_                                                                                 
 14       <a href="<!-- dynamic_content_ name=cal_next_month_link //-->">&gt;&gt;</a>                    
 15       &nbsp;&nbsp;                                                                                   
 16       $active_year_                                                                                  
 17     </td>                                                                                            
 18   </tr>                                                                                              
 19   <tr>                                                                                               
 20     <td align="center" width="45">Mon</td>                                                           
 21     <td align="center" width="45">Tue</td>                                                           
 22     <td align="center" width="45">Wed</td>                                                           
 23     <td align="center" width="45">Thu</td>                                                           
 24     <td align="center" width="45">Fri</td>                                                           
 25     <td align="center" width="45">Sat</td>                                                           
 26     <td align="center" width="45">Sun</td>                                                           
 27   </tr>                                                                                              
 28   <!--                                                                                               
 29   $tld_d1_ ... $tld_d7_ are used to display date                                                     
 30   $tld_dc1_ ... $tld_dc7_ are used to display content on particular yyyy-mm-dd                       
 31   -->                                                                                                
 32   <!-- start_list_ //-->                                                                             
 33   <tr>                                                                                               
 34     <td align="center" valign="top" width="45" $tld_cell1_color_>$tld_date1_ $tld_date1_content_</td>
 35     <td align="center" valign="top" width="45" $tld_cell2_color_>$tld_date2_ $tld_date2_content_</td>
 36     <td align="center" valign="top" width="45" $tld_cell3_color_>$tld_date3_ $tld_date3_content_</td>
 37     <td align="center" valign="top" width="45" $tld_cell4_color_>$tld_date4_ $tld_date4_content_</td>
 38     <td align="center" valign="top" width="45" $tld_cell5_color_>$tld_date5_ $tld_date5_content_</td>
 39     <td align="center" valign="top" width="45" $tld_cell6_color_>$tld_date6_ $tld_date6_content_</td>
 40     <td align="center" valign="top" width="45" $tld_cell7_color_>$tld_date7_ $tld_date7_content_</td>
 41   </tr>                                                                                              
 42   <!-- end_list_ //-->                                                                               
 43 </table>                                                                                             
 44 <!-- end_view_ //-->                                                                                 
 45 </body>                                                                                              
 46 </html>                                                                                              


 
3. Instantiation and Basic Parameter Setting

The arguments $normal, $current, $selected, $odd, $even, and $color_cell (lines 06-14) are strings represent HTML-color codes in hexadecimal fromat number ("#RRGGBB").

  1 my $component = new webman_calendar_interactive;                   
  2                                                                    
  3 $component->set_CGI($cgi);                                         
  4 $component->set_DBI_Conn($db_conn);                                
  5                                                                    
  6 #$component->set_Default_Text_Colors($normal, $current, $selected);
  7                                                                    
  8 #$component->set_Default_Cell_Colors($normal, $current, $selected);
  9                                                                    
 10 #$component->set_Default_Column_Color($odd, $even);                
 11 #$component->set_Default_Row_Color($odd, $even);                   
 12                                                                    
 13 #$component->set_Date_Cell_Color("yyyy-mm-dd", $color_cell);       
 14 #$component->set_Date_Text_Color("yyyy-mm-dd", $color_cell);       
 15                                                                    
 16 #$component->add_Date_Content("yyyy-mm-dd", $content);             
 17                                                                    
 18 #$component->set_Template_Default($template_file);                 


 
4. Component-type Generic Function Calls

$component->run_Task;
$component->process_Content;
$component->end_Task;

my $content = $component->get_Content;



 
5. Child Module for Customization

Most basic customization is to add content into specific calendar's date-cell, done inside the overriden run_Task hook function (line 57). Other more advanced and complex customization tasks are involving calendar's data-structure manipulations inside customize_TLD function.

Calendar's data-structure instance ($tld) passed to customize_TLD function (line 110) is actually Table_List_Data core module instance. Read the comments included inside the skeleton code to get more detailed explanations for all possible customizations that could be made.

  1 package child_module_name;                                                   
  2                                                                                                
  3 use webman_calendar_interactive;                                                               
  4                                                                                                
  5 @ISA=("webman_calendar_interactive");                                                          
  6                                                                                                
  7 sub new {                                                                                      
  8     my $class = shift;                                                                         
  9                                                                                                
 10     my $this = $class->SUPER::new();                                                           
 11                                                                                                
 12     #$this->set_Debug_Mode(1, 1);                                                              
 13                                                                                                
 14     bless $this, $class;                                                                       
 15                                                                                                
 16     return $this;                                                                              
 17 }                                                                                              
 18                                                                                                
 19 sub get_Name {                                                                                 
 20     my $this = shift @_;                                                                       
 21                                                                                                
 22     return __PACKAGE__;                                                                        
 23 }                                                                                              
 24                                                                                                
 25 sub get_Name_Full {                                                                            
 26     my $this = shift @_;                                                                       
 27                                                                                                
 28     return $this->SUPER::get_Name_Full . "::" . __PACKAGE__;                                   
 29 }                                                                                              
 30                                                                                                
 31 sub run_Task {                                                                                 
 32     my $this = shift @_;                                                                       
 33                                                                                                
 34     my $cgi = $this->get_CGI;                                                                  
 35     my $dbu = $this->get_DBU;                                                                  
 36     my $db_conn = $this->get_DB_Conn;                                                          
 37                                                                                                
 38     my $login_name = $this->get_User_Login;                                                    
 39     my @groups = $this->get_User_Groups;                                                       
 40                                                                                                
 41     my $match_group = $this->match_Group($group_name_, @groups);                               
 42                                                                                                
 43     #$this->set_Error("???");                                                                  
 44                                                                                                
 45     $this->SUPER::run_Task();                                                                  
 46                                                                                                
 47     #$this->set_Default_Text_Colors("#all_", "#current_", "#selected_");                       
 48                                                                                                
 49     #$this->set_Default_Cell_Colors("#all_", "#current_", "#selected_");                       
 50                                                                                                
 51     #$this->set_Default_Column_Color(#odd_, #even_");                                          
 52     #$this->set_Default_Row_Color(#odd_, #even_");                                             
 53                                                                                                
 54     #$this->set_Date_Cell_Color("yyyy-mm-dd", "#color_");                                      
 55     #$this->set_Date_Text_Color("yyyy-mm-dd", "#color_");                                      
 56                                                                                                
 57     #$this->add_Date_Content("yyyy-mm-dd", "content_");                                        
 58 }                                                                                              
 59                                                                                                
 60 sub process_Content {                                                                          
 61     $this = shift @_;                                                                          
 62                                                                                                
 63     my $cgi = $this->get_CGI;                                                                  
 64     my $dbu = $this->get_DBU;                                                                  
 65     my $db_conn = $this->get_DB_Conn;                                                          
 66                                                                                                
 67     $this->set_Template_File($this->{template_default});                                       
 68                                                                                                
 69     #print "\$this->{template_default} = " . $this->{template_default} . "<br>";               
 70                                                                                                
 71     $this->SUPER::process_Content;                                                             
 72 }                                                                                              
 73                                                                                                
 74 sub process_so_type_ { ### so_type_ can be: VIEW, DYNAMIC, LIST, MENU, DBHTML, SELECT, DATAHTML
 75     my $this = shift @_;                                                                       
 76     my $te = shift @_;                                                                         
 77                                                                                                
 78     my $cgi = $this->get_CGI;                                                                  
 79     my $dbu = $this->get_DBU;                                                                  
 80     my $db_conn = $this->get_DB_Conn;                                                          
 81                                                                                                
 82     my $login_name = $this->get_User_Login;                                                    
 83     my @groups = $this->get_User_Groups;                                                       
 84                                                                                                
 85     my $match_group = $this->match_Group($group_name_, @groups);                               
 86                                                                                                
 87     my $te_content = $te->get_Content;                                                         
 88     my $te_type_num = $te->get_Type_Num;                                                       
 89                                                                                                
 90     #my $te_type_name = $te->get_Name;                                                         
 91                                                                                                
 92     $this->add_Content($te_content);                                                           
 93                                                                                                
 94     #if ($this->get_Error eq "") {                                                             
 95     #   $this->add_Content($te_content);                                                       
 96                                                                                                
 97     #} else {                                                                                  
 98     #   $this->add_Content($this->get_Error);                                                  
 99     #}                                                                                         
100 }                                                                                              
101                                                                                                
102 sub customize_TLD {                                                                            
103     my $this = shift @_;                                                                       
104                                                                                                
105     ### The $tld instance has the column names and structure as follows:                       
106     ### 'date1', ..., 'date7',                                                                 
107     ### 'cell1_color', ..., 'cell7_color',                                                     
108     ### 'date1_iso', ..., 'date7_iso',                                                         
109     ### 'date1_content', ..., 'date7_content'                                                  
110     my $tld = shift @_;                                                                        
111                                                                                                
112     my $cgi = $this->get_CGI;                                                                  
113     my $dbu = $this->get_DBU;                                                                  
114     my $db_conn = $this->get_DB_Conn;                                                          
115                                                                                                
116     my $std_get_data = $cgi->generate_GET_Data("link_id");                                     
117                                                                                                
118     ### Add other possible new columns (link_1, ..., link_7).                                  
119     #for (my $cell_num = 1; $cell_num <= 7; $cell_num++) {                                     
120     #    $tld->add_Column("link" . $cell_num);                                                 
121     #}                                                                                         
122                                                                                                
123     for (my $i = 0; $i < $tld->get_Row_Num; $i++) {                                            
124         ### Next possible operations on new columns (link_1, ..., link_7).                     
125         #for (my $cell_num = 1; $cell_num <= 7; $cell_num++) {                                 
126         #    my $date_iso = $tld->get_Data($i, "date" . $cell_num . "_iso");                   
127         #    my $link_properties = "title=\"Click to do something...\"";                       
128         #                                                                                      
129         #    if ($date_iso ne "") {                                                            
130         #        $tld->set_Data($i, "link" . $cell_num, "Link...?");                           
131         #        $tld->set_Data_Get_Link($i, "link" . $cell_num,                               
132         #                                    "index.cgi?$std_get_data&calendar_ymd=$date_iso", 
133         #                                    "$link_properties");                              
134         #    }                                                                                 
135         #}                                                                                     
136     }                                                                                          
137                                                                                                
138     $cgi->add_Debug_Text($tld->get_Table_List, __FILE__, __LINE__);                            
139                                                                                                
140     return $tld;                                                                               
141 }                                                                                              
142                                                                                                
143 1;