Webman-framework

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

About | Overview | Documentation

 

Documentation > Modules and APIs > webman_calendar_week_list

webman_calendar_week_list

 

Description:

Component-type module that provides interactive navigation on calendar data through browsing operations to a set of lists of weeks.

 

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_key_date_start => "yyyy-mm-dd"
calendar_key_date_end => "yyyy-mm-dd"
calendar_ymd_selected => "yyyy-mm-dd"

By default the week's list sets are generated monthly unless the CGI parameters calendar_key_date_start and calendar_key_date_end are provided (passed to the module via HTTP-GET method). The module could also be used as calendar's date information picker by passing the picked date which is the date of the first day of the selected week to the calendar_ymd_selected CGI parameter. .

 
2. View Template

The main part of view template content for webman_calendar_week_list module is actually a LIST template-element (17-20), passed to process_LIST hook function and processed by TLD_HTML_Map core module. The LIST template-element contains the word patterns $tld_week_date_start_, $tld_week_date_end_, and $tld_week_list_content_ as its main place-holders for calendar's first and last weeks' date and date's content. The word pattern $tld_icon_selection_ is the place-holder for HTTP-GET links objects for users to pick a week to be active (see calendar_ymd_selected CGI parameter in section 1). Other place-holders ($tld_date_column_style_ and $tld_content_column_style_) are used to control week-list's HTML-table columns presentation style using CSS.

  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 border="1">                                                                                                        
 10   <tr style="background-color:#EEEEEE;">                                                                                  
 11     <td colspan="2" align="center">                                                                                       
 12       Week List Title                                                                                                     
 13     </td>                                                                                                                 
 14   </tr>                                                                                                                   
 15                                                                                                                           
 16   <!-- start_list_ //-->                                                                                                  
 17   <tr style="$tld_row_style_">                                                                                            
 18     <td valign="top" style="$tld_date_column_style_">$tld_icon_selection_ $tld_week_date_start_ / $tld_week_date_end_</td>
 19     <td valign="top" style="$tld_content_column_style_">$tld_week_list_content_</td>                                      
 20   </tr>                                                                                                                   
 21   <!-- end_list_ //-->                                                                                                    
 22                                                                                                                           
 23   <tr style="background-color:#EEEEEE;">                                                                                  
 24     <td colspan="2" align="center">                                                                                       
 25       <a href="<!-- dynamic_content_ name=cal_prev_week_set //-->">&lt;&lt;</a>                                           
 26       |                                                                                                                   
 27       <a href="<!-- dynamic_content_ name=cal_next_week_set //-->">&gt;&gt;</a>                                           
 28     </td>                                                                                                                 
 29   </tr>                                                                                                                   
 30 </table>                                                                                                                  
 31 <!-- end_view_ //-->                                                                                                      
 32 </body>                                                                                                                   
 33 </html>                                                                                                                   


 
3. Instantiation and Basic Parameter Setting

The arguments $all, $odd, $even, $current, $selected, $col_date, and $col_content (lines 11-12) are CSS's strings code to control the presentation of week-list's HTML-table rows and columns. HTML objects that act as HTTP-GET links resources for users to select or deselect particular week can be set via $icon_select and $icon_deselect arguments (line 13).

  1 my $component = new webman_calendar_week_list;                             
  2                                                                            
  3 $component->set_CGI($cgi);                                                 
  4 $component->set_DBI_Conn($db_conn);                                        
  5                                                                            
  6 ### if both key date are ignored the default would                         
  7 ### be the the first and end date of current month                         
  8 #$component->set_Key_Date_Start("yyyy-mm-dd");                             
  9 #$component->set_Key_Date_End("yyyy-mm-dd");                               
 10                                                                            
 11 #$component->set_Default_Row_Style($all, $odd, $even, $current, $selected);
 12 #$component->set_Default_Column_Style($col_date, $col_content);            
 13 #$component->set_Week_Selection_Icon($icon_select, $icon_deselect);        
 14                                                                            
 15 #$component->add_Date_Content("yyyy-mm-dd", $content);                     
 16                                                                            
 17 #$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 week-date cell, done inside the overriden run_Task hook function (line 54). 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 105) 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_week_list;                                                                                                
  4                                                                                                                               
  5 @ISA=("webman_calendar_week_list");                                                                                           
  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->SUPER::run_Task();                                                                                                 
 44                                                                                                                               
 45     ### If both key date are ignored the default would                                                                        
 46     ### be the the first and end date of current month.                                                                       
 47     #$this->set_Key_Date_Start("yyyy-mm-dd");                                                                                 
 48     #$this->set_Key_Date_End("yyyy-mm-dd");                                                                                   
 49                                                                                                                               
 50     #$this->set_Default_Row_Style($all, $odd, $even, $current, $selected);                                                    
 51     #$this->set_Default_Column_Style($col_date, $col_content);                                                                
 52     #$this->set_Week_Selection_Icon($icon_select, $icon_deselect);                                                            
 53                                                                                                                               
 54     #$this->add_Date_Content("yyyy-mm-dd", $content);                                                                         
 55 }                                                                                                                             
 56                                                                                                                               
 57 sub process_Content {                                                                                                         
 58     $this = shift @_;                                                                                                         
 59                                                                                                                               
 60     my $cgi = $this->get_CGI;                                                                                                 
 61     my $dbu = $this->get_DBU;                                                                                                 
 62     my $db_conn = $this->get_DB_Conn;                                                                                         
 63                                                                                                                               
 64     $this->set_Template_File($this->{template_default});                                                                      
 65                                                                                                                               
 66     #print "\$this->{template_default} = " . $this->{template_default} . "<br>";                                              
 67                                                                                                                               
 68     $this->SUPER::process_Content;                                                                                            
 69 }                                                                                                                             
 70                                                                                                                               
 71 sub process_so_type_ { ### so_type_ can be: VIEW, DYNAMIC, LIST, MENU, DBHTML, SELECT, DATAHTML                               
 72     my $this = shift @_;                                                                                                      
 73     my $te = shift @_;                                                                                                        
 74                                                                                                                               
 75     my $cgi = $this->get_CGI;                                                                                                 
 76     my $dbu = $this->get_DBU;                                                                                                 
 77     my $db_conn = $this->get_DB_Conn;                                                                                         
 78                                                                                                                               
 79     my $login_name = $this->get_User_Login;                                                                                   
 80     my @groups = $this->get_User_Groups;                                                                                      
 81                                                                                                                               
 82     my $match_group = $this->match_Group($group_name_, @groups);                                                              
 83                                                                                                                               
 84     my $te_content = $te->get_Content;                                                                                        
 85     my $te_type_num = $te->get_Type_Num;                                                                                      
 86     my $te_type_name = $te->get_Name;                                                                                         
 87                                                                                                                               
 88     $this->add_Content($te_content);                                                                                          
 89                                                                                                                               
 90     #if ($this->get_Error eq "") {                                                                                            
 91     #   $this->add_Content($te_content);                                                                                      
 92                                                                                                                               
 93     #} else {                                                                                                                 
 94     #   $this->add_Content($this->get_Error);                                                                                 
 95     #}                                                                                                                        
 96 }                                                                                                                             
 97                                                                                                                               
 98 sub customize_TLD {                                                                                                           
 99     my $this = shift @_;                                                                                                      
100                                                                                                                               
101     ### The $tld instance has the column names and structure as follows:                                                      
102     ### 'row_style', 'date_column_style', 'content_column_style',                                                             
103     ### 'current_week', 'icon_selection', 'selected',                                                                         
104     ### 'week_date_start', 'week_date_end', 'week_list_content'                                                               
105     my $tld = shift @_;                                                                                                       
106                                                                                                                               
107     my $cgi = $this->get_CGI;                                                                                                 
108     my $dbu = $this->get_DBU;                                                                                                 
109     my $db_conn = $this->get_DB_Conn;                                                                                         
110                                                                                                                               
111     my $std_get_data = $cgi->generate_GET_Data("link_id");                                                                    
112                                                                                                                               
113     my $row_color = "#fbfbeb";                                                                                                
114                                                                                                                               
115     ### Add other possible new column.                                                                                        
116     #$tld->add_Column("link");                                                                                                
117                                                                                                                               
118     for (my $i = 0; $i < $tld->get_Row_Num; $i++) {                                                                           
119                                                                                                                               
120         ### Next possible operations on new column.                                                                           
121         #my $week_date_start = $tld->get_Data($i, "week_date_start");                                                         
122                                                                                                                               
123         #$tld->set_Data($i, "link", "Link...?");                                                                              
124         #$tld->set_Data_Get_Link($i, "link", "index.cgi?$std_get_data&calendar_ymd_iso=$week_date_start", "link_properties_");
125                                                                                                                               
126         ### Further customize row for current active week.                                                                    
127         #if ($tld->get_Data($i, "current_week")) {                                                                            
128         #    $tld->set_Data($i, "week_date_start", "<b>" . $tld->get_Data($i, "week_date_start") . "</b>");                   
129         #    $tld->set_Data($i, "week_date_end", "<b>" . $tld->get_Data($i, "week_date_end") . "</b>");                       
130         #}                                                                                                                    
131     }                                                                                                                         
132                                                                                                                               
133     #$cgi->add_Debug_Text($tld->get_Table_List, __FILE__, __LINE__);                                                          
134                                                                                                                               
135     return $tld;                                                                                                              
136 }                                                                                                                             
137                                                                                                                               
138 1;