r4292 popup.php: turn into a pure library file
authorDenis Ovsienko <infrastation@yandex.ru>
Sat, 5 Mar 2011 13:32:50 +0000 (13:32 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Sat, 5 Mar 2011 13:32:50 +0000 (13:32 +0000)
renderPopupHTML(): new function to wrap existing code
makeHrefForHelper(): update for dispatched popup URI
index.php: add "popup" case to module dispatcher

wwwroot/inc/functions.php
wwwroot/inc/popup.php [moved from wwwroot/popup.php with 92% similarity]
wwwroot/index.php

index 84e9063..63f540a 100644 (file)
@@ -2415,7 +2415,7 @@ function makeHrefProcess($params = array())
 
 function makeHrefForHelper ($helper_name, $params = array())
 {
-       $ret = 'popup.php?helper=' . $helper_name;
+       $ret = '?module=popup&helper=' . $helper_name;
        foreach($params as $key=>$value)
                $ret .= '&'.urlencode($key).'='.urlencode($value);
        return $ret;
similarity index 92%
rename from wwwroot/popup.php
rename to wwwroot/inc/popup.php
index 0f14777..e1bc730 100644 (file)
@@ -1,9 +1,4 @@
 <?php
-ob_start();
-try {
-
-       require 'inc/interface.php';
-       require 'inc/init.php';
 
 // Return a list of rack IDs, which are P or less positions
 // far from the given rack in its row.
@@ -115,9 +110,11 @@ function sortObjectAddressesAndNames ($a, $b)
        return $objname_cmp;
 }
 
+function renderPopupHTML()
+{
+       global $pageno, $tabno;
 header ('Content-Type: text/html; charset=UTF-8');
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" style="height: 100%;">
 <head>
 <?php
@@ -132,9 +129,11 @@ header ('Content-Type: text/html; charset=UTF-8');
                        $tabno = 'default';
                        fixContext();
                        if (!permitted())
-                               renderAccessDenied();
-                       assertUIntArg ('object_id');
-                       $object_id = $_REQUEST['object_id'];
+                       {
+                               renderAccessDenied (FALSE);
+                               return;
+                       }
+                       $object_id = getBypassValue();
                        echo '<div style="background-color: #f0f0f0; border: 1px solid #3c78b5; padding: 10px; height: 100%; text-align: center; margin: 5px;">';
                        echo '<h2>Choose a container:</h2>';
                        echo '<form action="javascript:;">';
@@ -159,8 +158,8 @@ header ('Content-Type: text/html; charset=UTF-8');
                        $port_id = $_REQUEST['port'];
                        echo '<div style="background-color: #f0f0f0; border: 1px solid #3c78b5; padding: 10px; height: 100%; text-align: center; margin: 5px;"><h2>';
                        echo $localchoice ?
-                               ('Nearest spare ports (<a href="popup.php?helper=portlist&port=' . $port_id . '&in_rack=n">show all</a>)') :
-                               ('All spare ports (<a href="popup.php?helper=portlist&port=' . $port_id . '&in_rack=y">show nearest</a>)');
+                               ('Nearest spare ports (<a href="?module=popup&helper=portlist&port=' . $port_id . '&in_rack=n">show all</a>)') :
+                               ('All spare ports (<a href="?module=popup&helper=portlist&port=' . $port_id . '&in_rack=y">show nearest</a>)');
                        echo '</h2><form action="javascript:;" id="portform">';
                        $only_racks = array();
                        global $sic;
@@ -213,11 +212,5 @@ header ('Content-Type: text/html; charset=UTF-8');
 </body>
 </html>
 <?php
-ob_end_flush();
-}
-catch (Exception $e)
-{
-        ob_end_clean();
-        printException($e);
 }
 ?>
index 451cc8e..57ea0a6 100644 (file)
@@ -149,6 +149,12 @@ try {
                }
                // any other error requires no special handling and will be caught outside
                break;
+       case 'popup' == $_REQUEST['module']:
+               require_once 'inc/popup.php';
+               require_once 'inc/interface.php';
+               require_once 'inc/init.php';
+               renderPopupHTML();
+               break;
        default:
                throw new InvalidRequestArgException ('module', $_REQUEST['module']);
        }