Search:

CWIS Developers Documentation

  • Main Page
  • Classes
  • Files
  • File List
  • File Members

ApplicationFramework.php

Go to the documentation of this file.
00001 <?PHP
00002 
00007 class ApplicationFramework {
00008 
00009     # ---- PUBLIC INTERFACE --------------------------------------------------
00010  /*@(*/
00012 
00020     function __construct($ObjectDirectories = NULL)
00021     {
00022         # save object directory search list
00023         self::$ObjectDirectories = $ObjectDirectories;
00024 
00025         # set up object file autoloader
00026         $this->SetUpObjectAutoloading();
00027 
00028         # set up function to output any buffered text in case of crash
00029         register_shutdown_function(array($this, "OnCrash"));
00030 
00031         # set up our internal environment
00032         $this->DB = new Database();
00033 
00034         # load our settings from database
00035         $this->DB->Query("SELECT * FROM ApplicationFrameworkSettings");
00036         $this->Settings = $this->DB->FetchRow();
00037         if (!$this->Settings)
00038         {
00039             $this->DB->Query("INSERT INTO ApplicationFrameworkSettings"
00040                     ." (LastTaskRunAt) VALUES (NOW())");
00041             $this->DB->Query("SELECT * FROM ApplicationFrameworkSettings");
00042             $this->Settings = $this->DB->FetchRow();
00043         }
00044 
00045         # register events we handle internally
00046         $this->RegisterEvent($this->PeriodicEvents);
00047         $this->RegisterEvent($this->UIEvents);
00048     }
00056     function AddObjectDirectories($Dirs)
00057     {
00058         self::$ObjectDirectories += $Dirs;
00059     }
00060 
00065     function LoadPage($PageName)
00066     {
00067         # buffer any output from includes or PHP file
00068         ob_start();
00069 
00070         # include any files needed to set up execution environment
00071         foreach ($this->EnvIncludes as $IncludeFile)
00072         {
00073             include($IncludeFile);
00074         }
00075 
00076         # signal PHP file load
00077         $SignalResult = $this->SignalEvent("EVENT_PHP_PAGE_LOAD", array(
00078                 "PageName" => $PageName));
00079 
00080         # if signal handler returned new page name value
00081         $NewPageName = $PageName;
00082         if (($SignalResult["PageName"] != $PageName)
00083                 && strlen($SignalResult["PageName"]))
00084         {
00085             # if new page name value is page file
00086             if (file_exists($SignalResult["PageName"]))
00087             {
00088                 # use new value for PHP file name
00089                 $PageFile = $SignalResult["PageName"];
00090             }
00091             else
00092             {
00093                 # use new value for page name
00094                 $NewPageName = $SignalResult["PageName"];
00095             }
00096         }
00097 
00098         # if we do not already have a PHP file
00099         if (!isset($PageFile))
00100         {
00101             # look for PHP file for page
00102             $OurPageFile = "pages/".$NewPageName.".php";
00103             $LocalPageFile = "local/pages/".$NewPageName.".php";
00104             $PageFile = file_exists($LocalPageFile) ? $LocalPageFile
00105                     : (file_exists($OurPageFile) ? $OurPageFile 
00106                     : "pages/".$this->DefaultPage.".php");
00107         }
00108 
00109         # load PHP file
00110         include($PageFile);
00111 
00112         # save buffered output to be displayed later after HTML file loads
00113         $PageOutput = ob_get_contents();
00114         ob_end_clean();
00115 
00116         # set up for possible TSR (Terminate and Stay Resident :))
00117         $ShouldTSR = $this->PrepForTSR();
00118 
00119         # if PHP file indicated we should autorefresh to somewhere else
00120         if ($this->JumpToPage)
00121         {
00122             if (!strlen(trim($PageOutput)))
00123             {
00124                 ?><html>
00125                 <head>
00126                     <meta http-equiv="refresh" content="0; URL=<?PHP  
00127                             print($this->JumpToPage);  ?>">
00128                 </head>
00129                 <body bgcolor="white">
00130                 </body>
00131                 </html><?PHP
00132             }
00133         }
00134         # else if HTML loading is not suppressed
00135         elseif (!$this->SuppressHTML)
00136         {
00137             # load common HTML file if available
00138             $HtmlFile = $this->FindCommonTemplate("Common");
00139             if ($HtmlFile) {  include($HtmlFile);  }
00140 
00141             # begin buffering content
00142             ob_start();
00143 
00144             # signal HTML file load
00145             $SignalResult = $this->SignalEvent("EVENT_HTML_PAGE_LOAD", array(
00146                     "PageName" => $PageName));
00147 
00148             # if signal handler returned new page name value
00149             $NewPageName = $PageName;
00150             $HtmlFile = NULL;
00151             if (($SignalResult["PageName"] != $PageName) 
00152                     && strlen($SignalResult["PageName"]))
00153             {
00154                 # if new page name value is HTML file
00155                 if (file_exists($SignalResult["PageName"]))
00156                 {
00157                     # use new value for HTML file name
00158                     $HtmlFile = $SignalResult["PageName"];
00159                 }
00160                 else
00161                 {
00162                     # use new value for page name
00163                     $NewPageName = $SignalResult["PageName"];
00164                 }
00165             }
00166 
00167             # load page content HTML file if available
00168             if ($HtmlFile === NULL)
00169             {
00170                 $HtmlFile = $this->FindTemplate($this->ContentTemplateList, $NewPageName);
00171             }
00172             if ($HtmlFile)
00173             {  
00174                 include($HtmlFile);  
00175             }
00176             else
00177             {
00178                 print("<h2>ERROR:  No HTML/TPL template found"
00179                         ." for this page.</h2>");
00180             }
00181 
00182             # signal HTML file load complete
00183             $SignalResult = $this->SignalEvent("EVENT_HTML_PAGE_LOAD_COMPLETE");
00184 
00185             # stop buffering and save content
00186             $BufferedContent = ob_get_contents();
00187             ob_end_clean();
00188 
00189             # load page start HTML file if available
00190             $HtmlFile = $this->FindCommonTemplate("Start");
00191             if ($HtmlFile) {  include($HtmlFile);  }
00192 
00193             # write out page content
00194             print($BufferedContent);
00195 
00196             # load page end HTML file if available
00197             $HtmlFile = $this->FindCommonTemplate("End");
00198             if ($HtmlFile) {  include($HtmlFile);  }
00199         }
00200 
00201         # run any post-processing routines
00202         foreach ($this->PostProcessingFuncs as $Func)
00203         {
00204             call_user_func_array($Func["FunctionName"], $Func["Arguments"]);
00205         }
00206 
00207         # write out any output buffered from page code execution
00208         if (strlen($PageOutput))
00209         {
00210             if (!$this->SuppressHTML)
00211             {
00212                 ?><table width="100%" cellpadding="5" 
00213                         style="border: 2px solid #666666;  background: #CCCCCC;  
00214                         font-family: Courier New, Courier, monospace; 
00215                         margin-top: 10px;"><tr><td><?PHP
00216             }
00217             if ($this->JumpToPage)
00218             {
00219                 ?><div style="color: #666666;"><span style="font-size: 150%;">
00220                 <b>Page Jump Aborted</b></span>
00221                 (because of error or other unexpected output)<br />
00222                 <b>Jump Target:</b>
00223                 <i><?PHP  print($this->JumpToPage);  ?></i></div><?PHP
00224             }
00225             print($PageOutput);
00226             if (!$this->SuppressHTML)
00227             {
00228                 ?></td></tr></table><?PHP
00229             }
00230         }
00231 
00232         # terminate and stay resident (TSR!) if indicated
00233         if ($ShouldTSR) {  $this->LaunchTSR();  }
00234     }
00235 
00241     function SetJumpToPage($Page)
00242     {
00243         list($PageRoot) = explode("?", $Page, 2);
00244         if (($Page === NULL) || strpos($PageRoot, ".php") || strpos($PageRoot, ".html"))
00245         {
00246             $this->JumpToPage = $Page;
00247         }
00248         else
00249         {
00250             $this->JumpToPage = "index.php?P=".$Page;
00251         }
00252     }
00253 
00258     function JumpToPageIsSet()
00259     {
00260         return ($this->JumpToPage === NULL) ? FALSE : TRUE;
00261     }
00262 
00269     function SuppressHTMLOutput($NewSetting = TRUE)
00270     {
00271         $this->SuppressHTML = $NewSetting;
00272     }
00273 
00280     function ActiveUserInterface($UIName = NULL)
00281     {
00282         if ($UIName !== NULL)
00283         {
00284             $this->ActiveUI = preg_replace("/^SPTUI--/", "", $UIName);
00285         }
00286         return $this->ActiveUI;
00287     }
00288 
00304     function AddPostProcessingCall($FunctionName, 
00305             &$Arg1 = self::NOVALUE, &$Arg2 = self::NOVALUE, &$Arg3 = self::NOVALUE,
00306             &$Arg4 = self::NOVALUE, &$Arg5 = self::NOVALUE, &$Arg6 = self::NOVALUE,
00307             &$Arg7 = self::NOVALUE, &$Arg8 = self::NOVALUE, &$Arg9 = self::NOVALUE)
00308     {
00309         $FuncIndex = count($this->PostProcessingFuncs);
00310         $this->PostProcessingFuncs[$FuncIndex]["FunctionName"] = $FunctionName;
00311         $this->PostProcessingFuncs[$FuncIndex]["Arguments"] = array();
00312         $Index = 1;
00313         while (isset(${"Arg".$Index}) && (${"Arg".$Index} !== self::NOVALUE))
00314         {
00315             $this->PostProcessingFuncs[$FuncIndex]["Arguments"][$Index] 
00316                     =& ${"Arg".$Index};
00317             $Index++;
00318         }
00319     }
00320 
00326     function AddEnvInclude($FileName)
00327     {
00328         $this->EnvIncludes[] = $FileName;
00329     }
00330 
00336     function GUIFile($FileName)
00337     {
00338         # pull off file name suffix
00339         $NamePieces = explode(".", $FileName);
00340         $Suffix = strtolower(array_pop($NamePieces));
00341 
00342         # determine which location to search based on file suffix
00343         $ImageSuffixes = array("gif", "jpg", "png");
00344         $FileList = in_array($Suffix, $ImageSuffixes) 
00345                 ? $this->ImageFileList : $this->CommonTemplateList;
00346 
00347         # search for file and return result to caller
00348         return $this->FindTemplate($FileList, $FileName);
00349     }
00350 
00360     function PUIFile($FileName)
00361     {
00362         $FullFileName = $this->GUIFile($FileName);
00363         if ($FullFileName) {  print($FullFileName);  }
00364     }
00365 
00370     function FindCommonTemplate($PageName)
00371     {
00372         return $this->FindTemplate(
00373                 array_merge($this->CommonTemplateList, $this->ContentTemplateList), 
00374                 $PageName);;
00375     }
00376 
00377     /*@)*/ /* Application Framework */
00378 
00379     # ---- Event Handling ----------------------------------------------------
00380  /*@(*/
00382 
00386     const EVENTTYPE_DEFAULT = 1;
00392     const EVENTTYPE_CHAIN = 2;
00398     const EVENTTYPE_FIRST = 3;
00406     const EVENTTYPE_NAMED = 4;
00407 
00416     function RegisterEvent($EventsOrEventName, $EventType = NULL)
00417     {
00418         # convert parameters to array if not already in that form
00419         $Events = is_array($EventsOrEventName) ? $EventsOrEventName
00420                 : array($EventsOrEventName => $Type);
00421 
00422         # for each event
00423         foreach ($Events as $Name => $Type)
00424         {
00425             # store event information
00426             $this->RegisteredEvents[$Name]["Type"] = $Type;
00427             $this->RegisteredEvents[$Name]["Callbacks"] = array();
00428         }
00429     }
00430 
00442     function HookEvent($EventsOrEventName, $Callback)
00443     {
00444         # convert parameters to array if not already in that form
00445         $Events = is_array($EventsOrEventName) ? $EventsOrEventName
00446                 : array($EventsOrEventName => $Callback);
00447 
00448         # for each event
00449         $Success = TRUE;
00450         foreach ($Events as $EventName => $EventCallback)
00451         {
00452             # if callback is valid
00453             if (is_callable($EventCallback))
00454             {
00455                 # if this is a periodic event we process internally
00456                 if (isset($this->PeriodicEvents[$EventName]))
00457                 {
00458                     # process event now
00459                     $this->ProcessPeriodicEvent($EventName, $EventCallback);
00460                 }
00461                 # if specified event has been registered
00462                 elseif (isset($this->RegisteredEvents[$EventName]))
00463                 {
00464                     # add callback for event
00465                     $this->RegisteredEvents[$EventName]["Callbacks"][] 
00466                             = $EventCallback;
00467                 }
00468                 else
00469                 {
00470                     $Success = FALSE;
00471                 }
00472             }
00473             else
00474             {
00475                 $Success = FALSE;
00476             }
00477         }
00478 
00479         # report to caller whether all callbacks were hooked
00480         return $Success;
00481     }
00482 
00490     function SignalEvent($EventName, $Parameters = NULL)
00491     {
00492         $ReturnValue = NULL;
00493 
00494         # if event has been registered
00495         if (isset($this->RegisteredEvents[$EventName]))
00496         {
00497             # set up default return value (if not NULL)
00498             switch ($this->RegisteredEvents[$EventName]["Type"])
00499             {
00500                 case self::EVENTTYPE_CHAIN:
00501                     $ReturnValue = $Parameters;
00502                     break;
00503 
00504                 case self::EVENTTYPE_NAMED:
00505                     $ReturnValue = array();
00506                     break;
00507             }
00508 
00509             # for each callback for this event
00510             foreach ($this->RegisteredEvents[$EventName]["Callbacks"] 
00511                     as $Callback)
00512             {
00513                 # invoke callback
00514                 $Result = ($Parameters !== NULL)
00515                         ? call_user_func_array($Callback, $Parameters)
00516                         : call_user_func($Callback);;
00517 
00518                 # process return value based on event type
00519                 switch ($this->RegisteredEvents[$EventName]["Type"])
00520                 {
00521                     case self::EVENTTYPE_CHAIN:
00522                         $ReturnValue = $Result;
00523                         $Parameters = $Result;
00524                         break;
00525 
00526                     case self::EVENTTYPE_FIRST:
00527                         if ($Result !== NULL)
00528                         {
00529                             $ReturnValue = $Result;
00530                             break 2;
00531                         }
00532                         break;
00533 
00534                     case self::EVENTTYPE_NAMED:
00535                         $CallbackName = is_array($Callback)
00536                                 ? (is_object($Callback[0]) 
00537                                         ? get_class($Callback[0]) 
00538                                         : $Callback[0])."::".$Callback[1]
00539                                 : $Callback;
00540                         $ReturnValue[$CallbackName] = $Result; 
00541                         break;
00542 
00543                     default:
00544                         break;
00545                 }
00546             }
00547         }
00548 
00549         # return value if any to caller
00550         return $ReturnValue;
00551     }
00552 
00553     /*@)*/ /* Event Handling */
00554 
00555     # ---- Task Management ---------------------------------------------------
00556  /*@(*/
00558 
00560     const PRIORITY_HIGH = 1;
00562     const PRIORITY_MEDIUM = 2;
00564     const PRIORITY_LOW = 3;
00565 
00574     function QueueTask($Callback, $Parameters, 
00575             $Priority = self::PRIORITY_MEDIUM, $Description = "")
00576     {
00577         # pack task info and write to database
00578         $this->DB->Query("INSERT INTO TaskQueue"
00579                 ." (Callback, Parameters, Priority, Description)"
00580                 ." VALUES ('".addslashes(serialize($Callback))."', '"
00581                 .addslashes(serialize($Parameters))."', ".intval($Priority).", '"
00582                 .addslashes($Description)."')");
00583     }
00584 
00595     function QueueUniqueTask($Callback, $Parameters, 
00596             $Priority = self::PRIORITY_MEDIUM, $Description = "")
00597     {
00598         if ($this->TaskIsInQueue($Callback, $Parameters))
00599         {
00600             return FALSE;
00601         }
00602         else
00603         {
00604             $this->QueueTask($Callback, $Parameters, $Priority, $Description);
00605             return TRUE;
00606         }
00607     }
00608 
00617     function TaskIsInQueue($Callback, $Parameters = NULL)
00618     {
00619         $FoundCount = $this->DB->Query("SELECT COUNT(*) AS FoundCount FROM TaskQueue"
00620                 ." WHERE Callback = '".addslashes(serialize($Callback))."'"
00621                 .($Parameters ? " AND Parameters = '"
00622                         .addslashes(serialize($Parameters))."'" : ""),
00623                 "FoundCount");
00624         return ($FoundCount ? TRUE : FALSE);
00625     }
00626 
00632     function GetTaskQueueSize($Priority = NULL)
00633     {
00634         return $this->DB->Query("SELECT COUNT(*) AS QueueSize FROM TaskQueue"
00635                 .($Priority ? " WHERE Priority = ".intval($Priority) : ""),
00636                 "QueueSize");
00637     }
00638 
00644     function GetTaskList($Count = 100, $Offset = 0)
00645     {
00646         $this->DB->Query("SELECT * FROM TaskQueue LIMIT "
00647                 .intval($Offset).",".intval($Count));
00648         $Tasks = array();
00649         while ($Row = $this->DB->FetchRow())
00650         {
00651             $Tasks[$Row["TaskId"]] = $Row;
00652             if (unserialize($Row["Callback"]) == 
00653                     array("ApplicationFramework", "PeriodicEventWrapper"))
00654             {
00655                 $WrappedCallback = unserialize($Row["Parameters"]);
00656                 $Tasks[$Row["TaskId"]]["Callback"] = $WrappedCallback[1];
00657                 $Tasks[$Row["TaskId"]]["Parameters"] = NULL;
00658             }
00659             else
00660             {
00661                 $Tasks[$Row["TaskId"]]["Callback"] = unserialize($Row["Callback"]);
00662                 $Tasks[$Row["TaskId"]]["Parameters"] = unserialize($Row["Parameters"]);
00663             }
00664         }
00665         return $Tasks;
00666     }
00667 
00671     function RunNextTask()
00672     {
00673         # look for task at head of queue
00674         $this->DB->Query("SELECT * FROM TaskQueue ORDER BY Priority, TaskId LIMIT 1");
00675         $Task = $this->DB->FetchRow();
00676 
00677         # if there was a task available
00678         if ($Task)
00679         {
00680             # remove task from queue
00681             $this->DB->Query("DELETE FROM TaskQueue WHERE TaskId = ".$Task["TaskId"]);
00682 
00683             # unpack stored task info
00684             $Callback = unserialize($Task["Callback"]);
00685             $Parameters = unserialize($Task["Parameters"]);
00686 
00687             # run task
00688             call_user_func_array($Callback, $Parameters);
00689         }
00690     }
00691 
00692     /*@)*/ /* Task Management */
00693 
00694     # ---- PRIVATE INTERFACE -------------------------------------------------
00695 
00696     private $JumpToPage = NULL;
00697     private $SuppressHTML = FALSE;
00698     private $DefaultPage = "Home";
00699     private $ActiveUI = "default";
00700     private $PostProcessingFuncs = array();
00701     private $EnvIncludes = array();
00702     private $DB;
00703     private $Settings;
00704     private static $ObjectDirectories = array();
00705 
00706     private $PeriodicEvents = array(
00707                 "EVENT_HOURLY" => self::EVENTTYPE_DEFAULT,
00708                 "EVENT_DAILY" => self::EVENTTYPE_DEFAULT,
00709                 "EVENT_WEEKLY" => self::EVENTTYPE_DEFAULT,
00710                 "EVENT_MONTHLY" => self::EVENTTYPE_DEFAULT,
00711                 "EVENT_PERIODIC" => self::EVENTTYPE_NAMED,
00712                 );
00713     private $UIEvents = array(
00714                 "EVENT_PHP_PAGE_LOAD" => self::EVENTTYPE_CHAIN,
00715                 "EVENT_HTML_PAGE_LOAD" => self::EVENTTYPE_CHAIN,
00716                 "EVENT_HTML_PAGE_LOAD_COMPLETE" => self::EVENTTYPE_DEFAULT,
00717                 );
00718 
00719     private function FindTemplate($FileList, $PageName)
00720     {
00721         $FileNameFound = NULL;
00722         foreach ($FileList as $FileName)
00723         {
00724             $FileName = str_replace("%ACTIVEUI%", $this->ActiveUI, $FileName);
00725             $FileName = str_replace("%PAGENAME%", $PageName, $FileName);
00726             if (file_exists($FileName)) 
00727             {  
00728                 $FileNameFound = $FileName;  
00729                 break;
00730             }
00731         }
00732         return $FileNameFound;
00733     }
00734 
00735     private function SetUpObjectAutoloading()
00736     {
00737         function __autoload($ClassName)
00738         {
00739             ApplicationFramework::AutoloadObjects($ClassName);
00740         }
00741     }
00742 
00744     static function AutoloadObjects($ClassName)
00745     {
00746         foreach (self::$ObjectDirectories as $Location => $Prefix)
00747         {
00748             $FileName = $Location
00749                     .((substr($Location, -1) != "/") ? "/" : "")
00750                     .$Prefix.$ClassName.".php";
00751             if (file_exists($FileName))
00752             {
00753                 require_once($FileName);
00754             }
00755         }
00756     }
00759     private function ProcessPeriodicEvent($EventName, $Callback)
00760     {
00761         # retrieve last execution time for event if available
00762         $Signature = self::GetCallbackSignature($Callback);
00763         $LastRun = $this->DB->Query("SELECT LastRunAt FROM PeriodicEvents"
00764                 ." WHERE Signature = '".addslashes($Signature)."'", "LastRunAt");
00765 
00766         # determine whether enough time has passed for event to execute
00767         $EventPeriods = array(
00768                 "EVENT_HOURLY" => 60*60,
00769                 "EVENT_DAILY" => 60*60*24,
00770                 "EVENT_WEEKLY" => 60*60*24*7,
00771                 "EVENT_MONTHLY" => 60*60*24*30,
00772                 "EVENT_PERIODIC" => 0,
00773                 );
00774         $ShouldExecute = (($LastRun === NULL) 
00775                 || (time() > (strtotime($LastRun) + $EventPeriods[$EventName])))
00776                 ? TRUE : FALSE;
00777 
00778         # if event should run
00779         if ($ShouldExecute)
00780         {
00781             # if event is not already in task queue
00782             $WrapperCallback = array("ApplicationFramework", "PeriodicEventWrapper");
00783             $WrapperParameters = array(
00784                     $EventName, $Callback, array("LastRunAt" => $LastRun));
00785             if (!$this->TaskIsInQueue($WrapperCallback, $WrapperParameters))
00786             {
00787                 # add event to task queue
00788                 $this->QueueTask($WrapperCallback, $WrapperParameters);
00789             }
00790         }
00791     }
00792 
00793     private static function PeriodicEventWrapper($EventName, $Callback, $Parameters)
00794     {
00795         static $DB;
00796         if (!isset($DB)) {  $DB = new Database();  }
00797 
00798         # run event
00799         $ReturnVal = call_user_func_array($Callback, $Parameters);
00800 
00801         # if event is already in database
00802         $Signature = ApplicationFramework::GetCallbackSignature($Callback);
00803         if ($DB->Query("SELECT COUNT(*) AS EventCount FROM PeriodicEvents"
00804                 ." WHERE Signature = '".addslashes($Signature)."'", "EventCount"))
00805         {
00806             # update last run time for event
00807             $DB->Query("UPDATE PeriodicEvents SET LastRunAt = "
00808                     .(($EventName == "EVENT_PERIODIC")
00809                             ? "'".date("Y-m-d H:i:s", time() + ($ReturnVal * 60))."'" 
00810                             : "NOW()")
00811                     ." WHERE Signature = '".addslashes($Signature)."'");
00812         }
00813         else
00814         {
00815             # add last run time for event to database
00816             $DB->Query("INSERT INTO PeriodicEvents (Signature, LastRunAt) VALUES "
00817                     ."('".addslashes($Signature)."', "
00818                     .(($EventName == "EVENT_PERIODIC")
00819                             ? "'".date("Y-m-d H:i:s", time() + ($ReturnVal * 60))."'" 
00820                             : "NOW()").")");
00821         }
00822     }
00823 
00824     private static function GetCallbackSignature($Callback)
00825     {
00826         return !is_array($Callback) ? $Callback
00827                 : (is_object($Callback[0]) ? md5(serialize($Callback[0])) : $Callback[0])
00828                         ."::".$Callback[1];
00829     }
00830 
00831     private function PrepForTSR()
00832     {
00833         # if it is time to launch another task
00834         if ((time() > (strtotime($this->Settings["LastTaskRunAt"]) 
00835                 + ($this->Settings["MaxTaskTime"] 
00836                         / $this->Settings["MaxTasksRunning"])))
00837                 && $this->GetTaskQueueSize())
00838         {
00839             # begin buffering output for TSR
00840             ob_start();
00841 
00842             # let caller know it is time to launch another task
00843             return TRUE;
00844         }
00845         else
00846         {
00847             # let caller know it is not time to launch another task
00848             return FALSE;
00849         }
00850     }
00851 
00852     private function LaunchTSR()
00853     {
00854         # set needed headers and 
00855         ignore_user_abort(TRUE);
00856         header("Connection: close");
00857         header("Content-Length: ".ob_get_length());
00858 
00859         # output buffered content
00860         ob_end_flush();
00861         flush();
00862 
00863         # write out any outstanding data and end HTTP session
00864         session_write_close();
00865 
00866         # if there is still a task in the queue
00867         if ($this->GetTaskQueueSize())
00868         {
00869             # update the "last run" time
00870             $this->DB->Query("UPDATE ApplicationFrameworkSettings"
00871                     ." SET LastTaskRunAt = NOW()");
00872 
00873             # run the task
00874             $this->RunNextTask();
00875         }
00876     }
00877 
00884     function OnCrash()
00885     {
00886         print("\n");
00887         return;
00888 
00889         if (ob_get_length() !== FALSE)
00890         {
00891             ?>
00892             <table width="100%" cellpadding="5" style="border: 2px solid #666666;  background: #FFCCCC;  font-family: Courier New, Courier, monospace;  margin-top: 10px;  font-weight: bold;"><tr><td>
00893             <div style="font-size: 200%;">CRASH OUTPUT</div><?PHP
00894             ob_end_flush();
00895             ?></td></tr></table><?PHP
00896         }
00897     }
00900     private $CommonTemplateList = array(
00901             "local/interface/%ACTIVEUI%/include/StdPage%PAGENAME%.tpl",
00902             "local/interface/%ACTIVEUI%/include/StdPage%PAGENAME%.html",
00903             "local/interface/%ACTIVEUI%/include/%PAGENAME%.tpl",
00904             "local/interface/%ACTIVEUI%/include/%PAGENAME%.html",
00905             "local/interface/%ACTIVEUI%/include/SPT--StandardPage%PAGENAME%.tpl",
00906             "local/interface/%ACTIVEUI%/include/SPT--StandardPage%PAGENAME%.html",
00907             "local/interface/%ACTIVEUI%/include/SPT--%PAGENAME%.tpl",
00908             "local/interface/%ACTIVEUI%/include/SPT--%PAGENAME%.html",
00909             "local/interface/%ACTIVEUI%/include/%PAGENAME%",
00910             "local/interface/%ACTIVEUI%/include/%PAGENAME%",
00911             "interface/%ACTIVEUI%/include/StdPage%PAGENAME%.tpl",
00912             "interface/%ACTIVEUI%/include/StdPage%PAGENAME%.html",
00913             "interface/%ACTIVEUI%/include/%PAGENAME%.tpl",
00914             "interface/%ACTIVEUI%/include/%PAGENAME%.html",
00915             "interface/%ACTIVEUI%/include/SPT--StandardPage%PAGENAME%.tpl",
00916             "interface/%ACTIVEUI%/include/SPT--StandardPage%PAGENAME%.html",
00917             "interface/%ACTIVEUI%/include/SPT--%PAGENAME%.tpl",
00918             "interface/%ACTIVEUI%/include/SPT--%PAGENAME%.html",
00919             "interface/%ACTIVEUI%/include/%PAGENAME%",
00920             "interface/%ACTIVEUI%/include/%PAGENAME%",
00921             "SPTUI--%ACTIVEUI%/include/StdPage%PAGENAME%.tpl",
00922             "SPTUI--%ACTIVEUI%/include/StdPage%PAGENAME%.html",
00923             "SPTUI--%ACTIVEUI%/include/%PAGENAME%.tpl",
00924             "SPTUI--%ACTIVEUI%/include/%PAGENAME%.html",
00925             "SPTUI--%ACTIVEUI%/include/SPT--StandardPage%PAGENAME%.tpl",
00926             "SPTUI--%ACTIVEUI%/include/SPT--StandardPage%PAGENAME%.html",
00927             "SPTUI--%ACTIVEUI%/include/SPT--%PAGENAME%.tpl",
00928             "SPTUI--%ACTIVEUI%/include/SPT--%PAGENAME%.html",
00929             "SPTUI--%ACTIVEUI%/include/%PAGENAME%",
00930             "SPTUI--%ACTIVEUI%/include/%PAGENAME%",
00931             "%ACTIVEUI%/include/StdPage%PAGENAME%.tpl",
00932             "%ACTIVEUI%/include/StdPage%PAGENAME%.html",
00933             "%ACTIVEUI%/include/%PAGENAME%.tpl",
00934             "%ACTIVEUI%/include/%PAGENAME%.html",
00935             "%ACTIVEUI%/include/SPT--StandardPage%PAGENAME%.tpl",
00936             "%ACTIVEUI%/include/SPT--StandardPage%PAGENAME%.html",
00937             "%ACTIVEUI%/include/SPT--%PAGENAME%.tpl",
00938             "%ACTIVEUI%/include/SPT--%PAGENAME%.html",
00939             "%ACTIVEUI%/include/%PAGENAME%",
00940             "%ACTIVEUI%/include/%PAGENAME%",
00941             "local/interface/default/include/StdPage%PAGENAME%.tpl",
00942             "local/interface/default/include/StdPage%PAGENAME%.html",
00943             "local/interface/default/include/%PAGENAME%.tpl",
00944             "local/interface/default/include/%PAGENAME%.html",
00945             "local/interface/default/include/SPT--StandardPage%PAGENAME%.tpl",
00946             "local/interface/default/include/SPT--StandardPage%PAGENAME%.html",
00947             "local/interface/default/include/SPT--%PAGENAME%.tpl",
00948             "local/interface/default/include/SPT--%PAGENAME%.html",
00949             "local/interface/default/include/%PAGENAME%",
00950             "local/interface/default/include/%PAGENAME%",
00951             "interface/default/include/StdPage%PAGENAME%.tpl",
00952             "interface/default/include/StdPage%PAGENAME%.html",
00953             "interface/default/include/%PAGENAME%.tpl",
00954             "interface/default/include/%PAGENAME%.html",
00955             "interface/default/include/SPT--StandardPage%PAGENAME%.tpl",
00956             "interface/default/include/SPT--StandardPage%PAGENAME%.html",
00957             "interface/default/include/SPT--%PAGENAME%.tpl",
00958             "interface/default/include/SPT--%PAGENAME%.html",
00959             "interface/default/include/%PAGENAME%",
00960             "interface/default/include/%PAGENAME%",
00961             );
00962     private $ContentTemplateList = array(
00963             "local/interface/%ACTIVEUI%/%PAGENAME%.tpl",
00964             "local/interface/%ACTIVEUI%/%PAGENAME%.html",
00965             "local/interface/%ACTIVEUI%/SPT--%PAGENAME%.tpl",
00966             "local/interface/%ACTIVEUI%/SPT--%PAGENAME%.html",
00967             "interface/%ACTIVEUI%/%PAGENAME%.tpl",
00968             "interface/%ACTIVEUI%/%PAGENAME%.html",
00969             "interface/%ACTIVEUI%/SPT--%PAGENAME%.tpl",
00970             "interface/%ACTIVEUI%/SPT--%PAGENAME%.html",
00971             "SPTUI--%ACTIVEUI%/%PAGENAME%.tpl",
00972             "SPTUI--%ACTIVEUI%/%PAGENAME%.html",
00973             "SPTUI--%ACTIVEUI%/SPT--%PAGENAME%.tpl",
00974             "SPTUI--%ACTIVEUI%/SPT--%PAGENAME%.html",
00975             "%ACTIVEUI%/%PAGENAME%.tpl",
00976             "%ACTIVEUI%/%PAGENAME%.html",
00977             "%ACTIVEUI%/SPT--%PAGENAME%.tpl",
00978             "%ACTIVEUI%/SPT--%PAGENAME%.html",
00979             "local/interface/default/%PAGENAME%.tpl",
00980             "local/interface/default/%PAGENAME%.html",
00981             "local/interface/default/SPT--%PAGENAME%.tpl",
00982             "local/interface/default/SPT--%PAGENAME%.html",
00983             "interface/default/%PAGENAME%.tpl",
00984             "interface/default/%PAGENAME%.html",
00985             "interface/default/SPT--%PAGENAME%.tpl",
00986             "interface/default/SPT--%PAGENAME%.html",
00987             );
00988     private $ImageFileList = array(
00989             "local/interface/%ACTIVEUI%/images/%PAGENAME%",
00990             "interface/%ACTIVEUI%/images/%PAGENAME%",
00991             "SPTUI--%ACTIVEUI%/images/%PAGENAME%",
00992             "%ACTIVEUI%/images/%PAGENAME%",
00993             "local/interface/default/images/%PAGENAME%",
00994             "interface/default/images/%PAGENAME%",
00995             );
00996 
00998     const NOVALUE = ".-+-.NO VALUE PASSED IN FOR ARGUMENT.-+-.";
01000 };
01001 
01002 
01003 ?>
CWIS logo doxygen
Copyright 2009 Internet Scout