Changeset 3579

Show
Ignore:
Timestamp:
01/18/07 14:51:44 (2 years ago)
Author:
gregmac
Message:

Implement views system: move html out of header/config files. Add showview() and loadview() API functions.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/quickform/amp_conf/htdocs/admin/common/mainstyle.css

    r3573 r3579  
    200200} 
    201201 
     202/***** report nav *****/ 
     203#reportnav {  
     204        position:absolute;  
     205        top:55px;  
     206        left:10px;  
     207        border:1; 
     208        padding: 0 0 0 0; 
     209        list-style-type: none; 
     210        font-size:12px; 
     211        border-right:1px solid black; 
     212} 
     213#reportnav ul { 
     214        margin:0; 
     215        padding:0; 
     216} 
     217#reportnav  li { 
     218        display: inline; 
     219        border-left:1px solid black; 
     220        padding-left:6px; 
     221        padding-right:6px; 
     222} 
    202223/***** footer *****/ 
    203224#footer { 
  • freepbx/branches/quickform/amp_conf/htdocs/admin/config.php

    r3575 r3579  
    4444} 
    4545 
    46 include 'header_auth.php'
     46include('header.php')
    4747 
    4848// get all enabled modules 
     
    127127} 
    128128 
    129 if (!$quietmode) { 
    130         if (is_array($fpbx_menu)) { 
    131                 $category = Array(); 
    132                 $sort = Array(); 
    133                 $name = Array(); 
    134                 // Sorting menu by category and name 
    135                 foreach ($fpbx_menu as $key => $row) { 
    136                         $category[$key] = $row['category']; 
    137                         $sort[$key] = $row['sort']; 
    138                         $name[$key] = $row['name']; 
    139                 } 
    140                  
    141                 if ($amp_conf['USECATEGORIES']) { 
    142                         array_multisort( 
    143                                 $category, SORT_ASC,  
    144                                 $sort, SORT_ASC, SORT_NUMERIC,  
    145                                 $name, SORT_ASC,  
    146                                 $fpbx_menu 
    147                         ); 
    148                 } else { 
    149                         array_multisort( 
    150                                 $sort, SORT_ASC, SORT_NUMERIC,  
    151                                 $name, SORT_ASC,  
    152                                 $fpbx_menu 
    153                         ); 
    154                 } 
    155                  
    156                 // Printing menu 
    157                 echo "<div id=\"nav\"><ul>\n"; 
    158                  
    159                 $prev_category = ''; 
    160                  
    161                 foreach ($fpbx_menu as $key => $row) { 
    162                         if ($amp_conf['USECATEGORIES'] && ($row['category'] != $prev_category)) { 
    163                                 echo "\t\t<li>"._($row['category'])."</li>\n"; 
    164                                 $prev_category = $row['category']; 
    165                         } 
    166                          
    167                         $href = isset($row['href']) ? $row['href'] : "config.php?type=".$type."&amp;display=".$key; 
    168                         $extra_attributes = ''; 
    169                         if (isset($row['target'])) { 
    170                                 $extra_attributes .= ' target="'.$row['target'].'"'; 
    171                         } 
    172                          
    173                         echo "\t<li" . 
    174                                 (($display==$key) ? ' class="current"':'') . 
    175                                 '><a href="'.$href.'" '.$extra_attributes.' >'._($row['name'])."</a></li>\n"; 
    176                          
    177                 } 
    178                 echo "</ul></div>\n\n"; 
    179         } 
    180  
    181         echo "<div id=\"wrapper\"><div id=\"background-wrapper\">\n"; 
    182          
    183         echo "<div id=\"left-corner\"></div>\n"; 
    184         echo "<div id=\"right-corner\"></div>\n"; 
    185          
    186         echo "<div class=\"content\">\n"; 
    187  
    188  
    189         echo "<noscript><div class=\"attention\">"._("WARNING: Javascript is disabled in your browser. The freePBX administration interface requires Javascript to run properly. Please enable javascript or switch to another  browser that supports it.")."</div></noscript>"; 
    190 } 
    191  
    192  
    193  
    194129// check access 
    195130if ( ($display != '') && !isset($fpbx_menu[$display]) ) { 
     
    213148        $currentcomponent->buildconfigpage(); 
    214149} 
     150 
     151//  note: we buffer all the output from the 'page' being loaded.. 
     152// This may change in the future, with proper returns, but for now, it's a simple  
     153// way to support the old page.item.php include module format. 
     154ob_start(); 
    215155 
    216156// show the appropriate page 
     
    425365} 
    426366 
    427 if (!$quietmode) { 
    428         echo "\t</div> <!-- /content -->\n"; 
    429          
    430         include('footer.php'); 
    431         echo "</div></div> <!-- /background-wrapper, /wrapper -->\n"; 
    432  
    433         echo "</div> <!-- /page -->\n"; 
    434         echo "</body>\n"; 
    435         echo "</html>\n"; 
    436 
     367$admin_template['content'] = ob_get_contents(); 
     368ob_end_clean(); 
     369 
     370// build the admin interface (with menu) 
     371$admin_template['fpbx_menu'] = $fpbx_menu; 
     372$admin_template['fpbx_usecategories'] = $amp_conf['USECATEGORIES']; 
     373$admin_template['fpbx_type'] = $type; 
     374 
     375// then load it and put it into the main freepbx interface 
     376$template['content'] = loadview('freepbx_admin', $admin_template); 
     377showview('freepbx', $template); 
     378 
    437379?> 
  • freepbx/branches/quickform/amp_conf/htdocs/admin/header.php

    r3300 r3579  
    1212//GNU General Public License for more details. 
    1313 
    14 // helper function, to draw the upper links 
    15 function print_sub_tool( $name, $page, $is_current, $href=NULL, $new_window=false ) 
    16 
    17         if (!is_file($page)) 
    18                 return; 
    19  
    20         $html = "<li"; 
     14/** Loads a view (from the views/ directory) with a number of named parameters created as local variables. 
     15 * @param  string   The name of the view. 
     16 * @param  array    The parameters to pass. Note that the key will be turned into a variable name for use by the view. 
     17 *                  For example, passing array('foo'=>'bar'); will create a variable $foo that can be used by 
     18 *                  the code in the view. 
     19 */ 
     20function loadview($viewname, $parameters = false) { 
     21        ob_start(); 
     22        showview($viewname, $parameters); 
     23        $contents = ob_get_contents(); 
     24        ob_end_clean(); 
     25        return $contents; 
     26
     27/** Outputs the contents of a view. 
     28 * @param  string   The name of the view. 
     29 * @param  array    The parameters to pass. Note that the key will be turned into a variable name for use by the view. 
     30 *                  For example, passing array('foo'=>'bar'); will create a variable $foo that can be used by 
     31 *                  the code in the view. 
     32 */ 
     33function showview($viewname, $parameters = false) { 
     34        if (is_array($parameters)) { 
     35                extract($parameters); 
     36        } 
    2137         
    22         if ($is_current) 
    23                 $html .= " class=\"current\""; 
    24                  
    25         $html .= "><a "; 
    26         if ($href == NULL) 
    27                 $href .= $page; 
    28  
    29         if ($new_window != NULL) 
    30                 $html .= "target=\"_blank\" "; 
    31  
    32         $html .= "href=\"$href\">$name</a></li>"; 
    33  
    34         print("\t\t$html\n"); 
     38        $viewname = str_replace('..','.',$viewname); // protect against going to subdirectories 
     39        if (file_exists('views/'.$viewname.'.php')) { 
     40                include('views/'.$viewname.'.php'); 
     41        } 
    3542} 
    36  
    37  
    38 // start output buffering 
    39 ob_start(); 
    4043 
    4144//get the current file name 
     
    7578} 
    7679 
    77 if (!$quietmode) { 
     80// do authentication - header_auth exits if unauthorized 
     81include('header_auth.php'); 
     82 
    7883?> 
    79 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    80  
    81 <html> 
    82  
    83 <head> 
    84         <title><?php  echo _($title) ?></title> 
    85         <meta http-equiv="Content-Type" content="text/html"> 
    86         <link href="common/mainstyle.css" rel="stylesheet" type="text/css"> 
    87         <!--[if IE]> 
    88         <link href="common/ie.css" rel="stylesheet" type="text/css"> 
    89         <![endif]-->     
    90         <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > 
    91 <?php  
    92         // check if in the amp configuration the user has set that 
    93         // he wants to use an alternative style-sheet. 
    94         // on Xorcom's TS1, it's used when the system is in rescue mode. 
    95         if (isset($amp_conf["ALTERNATIVE_CSS"])) 
    96         { 
    97                 if (($amp_conf["ALTERNATIVE_CSS"] == "1") || 
    98                         ($amp_conf["ALTERNATIVE_CSS"] == "yes") || 
    99                         ($amp_conf["ALTERNATIVE_CSS"] == "true")) 
    100                         echo "\t<link href=\"common/mainstyle-alternative.css\" rel=\"stylesheet\" type=\"text/css\">"; 
    101         } 
    102  
    103         if (isset($display) && is_file("modules/{$display}/{$display}.css")) { 
    104                 echo "\t<link href=\"modules/{$display}/{$display}.css\" rel=\"stylesheet\" type=\"text/css\">\n"; 
    105         } 
    106 ?> 
    107          
    108         <script type="text/javascript" src="common/script.js.php"></script> 
    109 <!--[if IE]> 
    110     <style type="text/css">div.inyourface a{position:absolute;}</style> 
    111 <![endif]--> 
    112 </head> 
    113  
    114 <body onload="body_loaded();"  <? 
    115 // Check if it's a RIGHT TO LEFT character set (eg, hebrew, arabic, whatever) 
    116 //$_COOKIE['lang']="he_IL"; 
    117 if (isset($_COOKIE['lang']) && $_COOKIE['lang']==="he_IL")  
    118         echo "dir=\"rtl\""; 
    119  
    120 ?> > 
    121 <div id="page"> 
    122         <div id="header"> 
    123 <?php 
    124                          
    125         echo "\t\t<div id=\"version\">"; 
    126         echo sprintf(_("%s %s on %s"),  
    127                 "<a href=\"index.php\">"._("freePBX")."</a>", 
    128                 getversion(), 
    129                 "<a href=\"http".(isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']!=''?'s':'')."://".$_SERVER['HTTP_HOST']."\">".$_SERVER["SERVER_NAME"]."</a>" 
    130                  ); 
    131         echo "</div>\n"; 
    132  
    133         echo "\t\t<ul id=\"metanav\">\n"; 
    134         print_sub_tool( _("Management"), "manage.php" , $currentFile=='manage.php' ); 
    135         print_sub_tool( _("Setup")     , "config.php" , $currentFile=='config.php' && isset($_REQUEST['type']) && ($_REQUEST['type']=='setup' || $_REQUEST['type'] == ""), "config.php?type=setup", false ); 
    136         print_sub_tool( _("Tools")     , "config.php" , $currentFile=='config.php' && isset($_REQUEST['type']) && $_REQUEST['type']=='tool' , "config.php?type=tool", false ); 
    137         print_sub_tool( _("Reports")   , "reports.php", $currentFile=='reports.php' ); 
    138         print_sub_tool( _("Panel")     , "panel.php"  , $currentFile=='panel.php' ); 
    139         print_sub_tool( _("Recordings"), "../recordings/index.php"  ,0, NULL, true ); 
    140         echo "\t\t</ul>\n"; 
    141  
    142         $freepbx_alt = _("freePBX"); 
    143         $freepbx_logo = (isset($amp_conf["AMPADMINLOGO"]) && is_file($amp_conf["AMPWEBROOT"]."/admin/images/".$amp_conf["AMPADMINLOGO"])) ? $amp_conf["AMPADMINLOGO"] : 'freepbx_small.png'; 
    144         echo "\t\t<div id=\"logo\"><a href=\"http://www.freepbx.org\" target=\"_blank\" title=\"".$freepbx_alt."\"><img src=\"images/".$freepbx_logo."\" alt=\"".$freepbx_alt."\" /></a></div>\n"; 
    145  
    146         echo "\t</div>"; 
    147  
    148         // need reload bar - hidden by default 
    149         echo "\n\t\t<div class=\"attention\" id=\"need_reload_block\" style=\"display:none;\"><a href=\"javascript:void(null);\" onclick=\"amp_apply_changes();\" class=\"info\">"; 
    150         echo _("Apply Configuration Changes"); 
    151         echo "<span>".sprintf(_("You have made changes to the configuration that have not yet been applied. When you are ". 
    152                                    "finished making all changes, click on %s to put them into effect."), "<strong>"._("Apply Configuration Changes")."</strong>"); 
    153         echo "</span></a></div>\n\n"; 
    154  
    155  
    156         echo "\t<div id=\"message\">"; 
    157  
    158 // TODO: this is ugly, need to code this better! 
    159 //       mixing php + html is bad! 
    160         if (extension_loaded('gettext')) { 
    161                 if (!isset($_COOKIE['lang'])) { 
    162                         $_COOKIE['lang'] = "en_US"; 
    163                 }  
    164 ?> 
    165 &nbsp;&nbsp;&nbsp;<?php echo _("Language:") ?> 
    166 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    167                 <select onchange="javascript:changeLang(this.value)"> 
    168                 <option value="en_US" <? echo ($_COOKIE['lang']=="en_US" ? "selected" : "") ?> >English</option> 
    169                 <option value="fr_FR" <? echo ($_COOKIE['lang']=="fr_FR" ? "selected" : "") ?> >Fran&ccedil;ais</option> 
    170                 <option value="de_DE" <? echo ($_COOKIE['lang']=="de_DE" ? "selected" : "") ?> >Deutsch</option> 
    171                 <option value="it_IT" <? echo ($_COOKIE['lang']=="it_IT" ? "selected" : "") ?> >Italiano</option> 
    172                 <option value="es_ES" <? echo ($_COOKIE['lang']=="es_ES" ? "selected" : "") ?> >Espa&ntilde;ol</option> 
    173                 <option value="ru_RU" <? echo ($_COOKIE['lang']=="ru_RU" ? "selected" : "") ?> >Russki</option> 
    174                 <option value="pt_PT" <? echo ($_COOKIE['lang']=="pt_PT" ? "selected" : "") ?> >Portuguese</option> 
    175                 <option value="he_IL" <? echo ($_COOKIE['lang']=="he_IL" ? "selected" : "") ?> >Hebrew</option> 
    176                 </select> 
    177 <?php 
    178         } 
    179 ?> 
    180  
    181 <script type="text/javascript"> 
    182 <!-- 
    183 function changeLang(lang) { 
    184         document.cookie='lang='+lang; 
    185         window.location.reload(); 
    186 } 
    187 //--> 
    188 </script> 
    189  
    190 <?php 
    191         if ( isset($_SESSION['AMP_user']) &&  $amp_conf['AUTHTYPE'] != 'none' ) { 
    192                 echo _('Logged in: ').$_SESSION['AMP_user']->username; 
    193                 echo ' (<a href="http'.(isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']!=''?'s':'').'://'; 
    194  
    195                 if (!ereg('MSIE', $_SERVER['HTTP_USER_AGENT'])) { 
    196                         // use other logout for Firefox and other browsers  
    197                         echo 'logout:logout@'; 
    198                 } 
    199  
    200                 $pathLength = strrpos($_SERVER['PHP_SELF'],'/'); 
    201                 $logoutPath = ($pathLength === false) ? '' : substr($_SERVER['PHP_SELF'],0,$pathLength); 
    202  
    203                 echo $_SERVER['HTTP_HOST'].$logoutPath.'/logout.php">Logout</a>)&nbsp;::&nbsp;'; 
    204         } 
    205         echo _($message); 
    206 ?></div> 
    207  
    208 <?php 
    209 } // End 'quietmode' check 
    210 ?> 
  • freepbx/branches/quickform/amp_conf/htdocs/admin/header_auth.php

    r3263 r3579  
    110110} 
    111111 
    112 include 'header.php'; 
     112//todo .. delete  // include 'header.php'; 
    113113 
    114114if ( !(isset($result) ? $result : false) ) { 
    115         echo "\t<br><br><br><br><center><h2>"; 
    116         echo _("You must log in first before you can access this page."); 
    117         echo "</h2></center><br><br><br><br>\n";  
    118         include 'footer.php'; 
     115        showview("noaccess"); 
    119116        exit; 
    120117} 
  • freepbx/branches/quickform/amp_conf/htdocs/admin/panel.php

    r2856 r3579  
    2222$amp_conf = parse_amportal_conf("/etc/amportal.conf"); 
    2323 
    24 include 'header_auth.php'; 
     24include 'header.php'; 
     25 
     26showview('panel', array('deptname' => $_SESSION["AMP_user"]->_deptname)); 
    2527?> 
    26 </div> 
    27 <iframe width="97%" height="600" frameborder="0" align="top" src="../panel/index_amp.php?context=<?php echo $_SESSION["AMP_user"]->_deptname?>"></iframe> 
    28  
    29 </body> 
    30 </html> 
  • freepbx/branches/quickform/amp_conf/htdocs/admin/reports.php

    r2855 r3579  
    3535} 
    3636 
    37 include 'header_auth.php'; 
     37include 'header.php'; 
    3838 
    3939$display=1; 
     
    4343 
    4444// setup menu  
    45 $amp_sections = array( 
     45$menu = array( 
    4646                1=>_("Call Logs"), 
    4747                2=>_("Compare Calls"), 
     
    5050        ); 
    5151 
    52 foreach ($amp_sections as $key=>$value) { 
    53         echo "<div class=\"nav\" style=\"width=25%;text-align:center;\">"; 
    54         echo "<li><nobr><a id=\"".(($display==$key) ? 'current':'')."\" href=\"reports.php?display=".$key."\">".$value."</a><nobr></li>"; 
    55         echo "</div>"; 
    56 } 
    57  
    5852// CDR viewer from www.areski.net.   
    5953// Changes for -- AMP -- commented in: 
    6054// cdr.php, defines.php, call-log.php, call-comp.php, graph_hourdetail.php, graph_statbar.php, graph_pie.php 
     55 
     56showview('reports', array('display'=>$display, 'menu' => $menu)); 
    6157?> 
    62 <br><br> 
    63 </div> 
    6458 
    65 <iframe width="97%" height="600" frameborder="0" align="top" src="cdr/cdr.php?s=<?php echo $display; echo ($display=='1' ? '&posted=1' : '');?>"></iframe> 
    6659 
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads