/** * BOOTSTRAP function used by the main web page to start our framework. */ function WFWebApplicationMain() { $webapp = WFWebApplication::sharedWebApplication(); if (WFWebApplication::isHTTPRequest()) { $webapp->runWebApplication(); } return $webapp; }
/** * Log the passed message to the framework's log folder in the filename specified. * @param string The filename to log the message to. The exact string will be used for the filename; no extension will be appended. * @param mixed string Log message to log. * object WFFunction A WFFunction which will be lazy-evaluated to produce the message to log. This level of decoupling allows the log infrastructure * to be much faster when a message won't be logged as the message creation won't occur at all. */ public static function logToFile($fileName, $message) { $logger = WFWebApplication::sharedWebApplication()->logger($fileName); if (!$logger) { $logFileDir = WFWebApplication::sharedWebApplication()->appDirPath(WFWebApplication::DIR_LOG); $logger = Log::singleton('file', $logFileDir . '/' . $fileName, 'log', array('mode' => 0666)); } $logger->log(self::buildLogMessage($message)); }
function initialize() { // manifest core modules that we want to use -- if you don't want people to access a module, remove it from this list! $webapp = WFWebApplication::sharedWebApplication(); $webapp->addModulePath('login', FRAMEWORK_DIR . '/modules/login'); $webapp->addModulePath('menu', FRAMEWORK_DIR . '/modules/menu'); $webapp->addModulePath('css', FRAMEWORK_DIR . '/modules/css'); $webapp->addModulePath('examples', FRAMEWORK_DIR . '/modules/examples'); // load propel //Propel::init(PROPEL_CONF); }
/** * PHOCOA autload callback. * * This function will load any PHOCOA classes, interfaces, etc. * * NOTE: autoload() will be called automatically for any new classes, interfaces, etc that are not yet in existence. * * @param string The className that needs to be loaded. * @return boolean TRUE if we handled the loading, false otherwise. */ public static function autoload($className) { // I am guessing that using a hashmap will be faster than a big switch statement... no tests yet, but... in any case I'll do it this way first. // other option is to add a bunch of paths to include_path, but that seems like a bad idea... YES that's a VERY BAD IDEA. Searching paths is much more expensive // than including files directly because it hits the filesystem a lot to find the files. static $autoloadClassmapCache = NULL; if ($autoloadClassmapCache == NULL) { $autoloadClassmapCache = array('Smarty' => 'Smarty/Smarty.class.php', 'Horde_Yaml' => 'Horde/Yaml.php', 'Horde_Yaml_Dumper' => 'Horde/Yaml/Dumper.php', 'Horde_Yaml_Loader' => 'Horde/Yaml/Loader.php', 'Horde_Yaml_Node' => 'Horde/Yaml/Node.php', 'Services_JSON' => 'libs/JSON.php', 'Mail_Mailer' => 'framework/Mailer.php', 'WFModel' => 'framework/generator/WFGenerator.php', 'WFFixture' => 'framework/generator/WFFixture.php', 'WFYaml' => 'framework/util/WFYaml.php', 'WFJSON' => 'framework/util/WFJSON.php', 'WFWebApplication' => 'framework/WFWebApplication.php', 'WFMenuTree' => 'framework/WFMenuItem.php', 'WFMenuTreeBuilding' => 'framework/WFMenuItem.php', 'WFMenuItem' => 'framework/WFMenuItem.php', 'WFMenuItemBasic' => 'framework/WFMenuItem.php', 'WFObject' => 'framework/WFObject.php', 'WFDateTime' => 'framework/WFDateTime.php', 'WFDecorator' => 'framework/WFDecorator.php', 'WFKeyValueCoding' => 'framework/WFKeyValueCoding.php', 'WFKeyValueValidators' => 'framework/util/WFKeyValueValidators.php', 'WFRequestController' => 'framework/WFRequestController.php', 'WFRedirectRequestException' => 'framework/WFRequestController.php', 'WFRequestController_RedirectException' => 'framework/WFRequestController.php', 'WFRequestController_InternalRedirectException' => 'framework/WFRequestController.php', 'WFRequestController_NotFoundException' => 'framework/WFRequestController.php', 'WFRequestController_BadRequestException' => 'framework/WFRequestController.php', 'WFRequestController_HTTPException' => 'framework/WFRequestController.php', 'WFSkin' => 'framework/WFSkin.php', 'WFModule' => 'framework/WFModule.php', 'WFModuleInvocation' => 'framework/WFModule.php', 'WFAction' => 'framework/WFRPC.php', 'WFEvent' => 'framework/WFRPC.php', 'WFClickEvent' => 'framework/WFRPC.php', 'WFJSAction' => 'framework/WFRPC.php', 'WFRPC' => 'framework/WFRPC.php', 'WFActionResponse' => 'framework/WFRPC.php', 'WFActionResponsePlain' => 'framework/WFRPC.php', 'WFActionResponseJSON' => 'framework/WFRPC.php', 'WFActionResponseXML' => 'framework/WFRPC.php', 'WFActionResponseJavascript' => 'framework/WFRPC.php', 'WFPage' => 'framework/WFPage.php', 'WFPageRendering' => 'framework/WFPageRendering.php', 'WFView' => 'framework/widgets/WFView.php', 'WFException' => 'framework/WFException.php', 'WFBinding' => 'framework/WFBinding.php', 'WFBindingSetup' => 'framework/WFBinding.php', 'WFSmarty' => 'framework/WFSmarty.php', 'WFAuthorizationDelegate' => 'framework/WFAuthorization.php', 'WFAuthorizationInfo' => 'framework/WFAuthorization.php', 'WFAuthorizationException' => 'framework/WFAuthorization.php', 'WFAuthorizationManager' => 'framework/WFAuthorization.php', 'WFFormatter' => 'framework/widgets/WFFormatter.php', 'WFBooleanFormatter' => 'framework/widgets/WFFormatter.php', 'WFDateTimeFormatter' => 'framework/widgets/WFFormatter.php', 'WFUNIXDateFormatter' => 'framework/widgets/WFFormatter.php', 'WFSQLDateFormatter' => 'framework/widgets/WFFormatter.php', 'WFNumberFormatter' => 'framework/widgets/WFFormatter.php', 'WFSensitiveDataFormatter' => 'framework/widgets/WFFormatter.php', 'WFPaginator' => 'framework/WFPagination.php', 'WFPaginatorException' => 'framework/WFPagination.php', 'WFPagedArray' => 'framework/WFPagination.php', 'WFPagedCreoleQuery' => 'framework/WFPagination.php', 'WFPagedData' => 'framework/WFPagination.php', 'WFDieselSearch' => 'framework/WFDieselpoint.php', 'WFDieselSearchHelper' => 'framework/WFDieselpoint.php', 'WFDieselKeyword' => 'framework/widgets/WFDieselKeyword.php', 'WFDieselNav' => 'framework/widgets/WFDieselNav.php', 'WFDieselSearchHelperStateTracking' => 'framework/WFDieselpoint.php', 'WFDieselFacet' => 'framework/widgets/WFDieselFacet.php', 'WFWidget' => 'framework/widgets/WFWidget.php', 'WFDynarchMenu' => 'framework/widgets/WFDynarchMenu.php', 'WFDynamic' => 'framework/widgets/WFDynamic.php', 'WFSelectionCheckbox' => 'framework/widgets/WFSelectionCheckbox.php', 'WFImage' => 'framework/widgets/WFImage.php', 'WFForm' => 'framework/widgets/WFForm.php', 'WFAutoForm' => 'framework/widgets/WFAutoForm.php', 'WFLabel' => 'framework/widgets/WFLabel.php', 'WFLink' => 'framework/widgets/WFLink.php', 'WFMessageBox' => 'framework/widgets/WFMessageBox.php', 'WFPassword' => 'framework/widgets/WFPassword.php', 'WFTextField' => 'framework/widgets/WFTextField.php', 'WFSearchField' => 'framework/widgets/WFSearchField.php', 'WFTextArea' => 'framework/widgets/WFTextArea.php', 'WFHTMLArea' => 'framework/widgets/WFHTMLArea.php', 'WFSubmit' => 'framework/widgets/WFSubmit.php', 'WFSelect' => 'framework/widgets/WFSelect.php', 'WFJumpSelect' => 'framework/widgets/WFJumpSelect.php', 'WFTimeSelect' => 'framework/widgets/WFTimeSelect.php', 'WFHidden' => 'framework/widgets/WFHidden.php', 'WFSpamHoneypot' => 'framework/widgets/WFSpamHoneypot.php', 'WFCheckbox' => 'framework/widgets/WFCheckbox.php', 'WFCheckboxGroup' => 'framework/widgets/WFCheckboxGroup.php', 'WFRadio' => 'framework/widgets/WFRadio.php', 'WFRadioGroup' => 'framework/widgets/WFRadioGroup.php', 'WFUploadError' => 'framework/widgets/WFUploading.php', 'WFUploaderUtils' => 'framework/widgets/WFUploading.php', 'WFUploadedFile' => 'framework/widgets/WFUploading.php', 'WFUploadedFile_Basic' => 'framework/widgets/WFUploading.php', 'WFUpload' => 'framework/widgets/WFUpload.php', 'WFPostletUpload' => 'framework/widgets/WFPostletUpload.php', 'WFHTML5_Uploader' => 'framework/widgets/WFHTML5_Uploader.php', 'WFBulkUpload' => 'framework/widgets/WFBulkUpload.php', 'WFPaginatorNavigation' => 'framework/widgets/WFPaginatorNavigation.php', 'WFPaginatorSortLink' => 'framework/widgets/WFPaginatorSortLink.php', 'WFPaginatorSortSelect' => 'framework/widgets/WFPaginatorSortSelect.php', 'WFPaginatorState' => 'framework/widgets/WFPaginatorState.php', 'WFModuleView' => 'framework/widgets/WFModuleView.php', 'WFTabView' => 'framework/widgets/WFTabView.php', 'WFTableView' => 'framework/widgets/WFTableView.php', 'WFAppcelerator' => 'framework/widgets/WFAppcelerator.php', 'WFBreadCrumb' => 'framework/widgets/WFBreadCrumb.php', 'WFBreadCrumbSetup' => 'framework/widgets/WFBreadCrumb.php', 'WFYAHOO' => 'framework/widgets/yahoo/WFYAHOO.php', 'WFYAHOO_widget_YahooScript' => 'framework/widgets/yahoo/WFYAHOO_widget_YahooScript.php', 'WFYAHOO_yuiloader' => 'framework/widgets/yahoo/WFYAHOO.php', 'WFYAHOO_widget_TreeView' => 'framework/widgets/yahoo/WFYAHOO_widget_TreeView.php', 'WFYAHOO_widget_TreeViewNode' => 'framework/widgets/yahoo/WFYAHOO_widget_TreeView.php', 'WFYAHOO_widget_Module' => 'framework/widgets/yahoo/WFYAHOO_widget_Module.php', 'WFYAHOO_widget_Overlay' => 'framework/widgets/yahoo/WFYAHOO_widget_Overlay.php', 'WFYAHOO_widget_Panel' => 'framework/widgets/yahoo/WFYAHOO_widget_Panel.php', 'WFYAHOO_widget_Dialog' => 'framework/widgets/yahoo/WFYAHOO_widget_Dialog.php', 'WFYAHOO_widget_PhocoaDialog' => 'framework/widgets/yahoo/WFYAHOO_widget_PhocoaDialog.php', 'WFYAHOO_widget_Logger' => 'framework/widgets/yahoo/WFYAHOO_widget_Logger.php', 'WFYAHOO_widget_Menu' => 'framework/widgets/yahoo/WFYAHOO_widget_Menu.php', 'WFYAHOO_widget_AutoComplete' => 'framework/widgets/yahoo/WFYAHOO_widget_AutoComplete.php', 'WFYAHOO_widget_Tab' => 'framework/widgets/yahoo/WFYAHOO_widget_TabView.php', 'WFYAHOO_widget_TabView' => 'framework/widgets/yahoo/WFYAHOO_widget_TabView.php', 'WFYAHOO_widget_ColorPicker' => 'framework/widgets/yahoo/WFYAHOO_widget_ColorPicker.php', 'WFYAHOO_widget_Calendar' => 'framework/widgets/yahoo/WFYAHOO_widget_Calendar.php', 'WFYAHOO_widget_DateTimePicker' => 'framework/widgets/yahoo/WFYAHOO_widget_DateTimePicker.php', 'WFYAHOO_widget_Uploader' => 'framework/widgets/yahoo/WFYAHOO_widget_Uploader.php', 'WFYAHOO_widget_Carousel' => 'framework/widgets/yahoo/WFYAHOO_widget_Carousel.php', 'WFPaginatorPageInfo' => 'framework/widgets/WFPaginatorPageInfo.php', 'WFValueTransformer' => 'framework/ValueTransformers/WFValueTransformer.php', 'WFNegateBooleanTransformer' => 'framework/ValueTransformers/WFNegateBooleanTransformer.php', 'WFIsEmptyTransformer' => 'framework/ValueTransformers/WFIsEmptyTransformer.php', 'WFEmptyToNullTransformer' => 'framework/ValueTransformers/WFEmptyToNullTransformer.php', 'WFIsNotEmptyTransformer' => 'framework/ValueTransformers/WFIsNotEmptyTransformer.php', 'WFUrlencodeTransformer' => 'framework/ValueTransformers/WFUrlencodeTransformer.php', 'WFObjectController' => 'framework/WFObjectController.php', 'WFArrayController' => 'framework/WFArrayController.php', 'WFArray' => 'framework/WFArray.php', 'WFDictionary' => 'framework/WFDictionary.php', 'WFError' => 'framework/WFError.php', 'WFErrorArray' => 'framework/WFError.php', 'WFErrorsException' => 'framework/WFError.php', 'WFErrorCollection' => 'framework/WFError.php', 'WFExceptionReporting' => 'framework/WFExceptionReporting.php', 'WFFunction' => 'framework/WFFunction.php', 'WFUnixDateFormatter' => 'framework/widgets/WFFormatter.php', 'WFSQLDateFormatter' => 'framework/widgets/WFFormatter.php', 'WFNumberFormatter' => 'framework/widgets/WFFormatter.php', 'FCKEditor' => FRAMEWORK_DIR . '/wwwroot/www/framework/FCKEditor/fckeditor.php', 'WFPagedPropelQuery' => 'framework/WFPagination.php', 'WFPagedPropelModelCriteria' => 'framework/WFPagination.php', 'WFModelBuilderPropel' => 'framework/generator/WFGeneratorPropel12_13.php', 'WFModelBuilderPropel15' => 'framework/generator/WFGeneratorPropel15.php', 'WFPropelException' => 'framework/util/WFPropelIntegration.php', 'WFObject_Propel' => 'framework/util/WFPropelIntegration.php', 'PhocoaControllerTestCase_PHPUnit' => 'phpunit/PhocoaControllerTestCase_PHPUnit.php'); } if (isset($autoloadClassmapCache[$className])) { // including absolute paths is much faster than relative paths to the include_path dirs because one doesn't have to walk the include path. // so, if it's a framework/ dir, then include it absolutely! Otherwise, let require figure it out. if (substr($autoloadClassmapCache[$className], 0, 10) == 'framework/') { $requirePath = FRAMEWORK_DIR . '/' . $autoloadClassmapCache[$className]; } else { $requirePath = $autoloadClassmapCache[$className]; } require $requirePath; return true; } // give appdelegate a shot at it $webapp = WFWebApplication::sharedWebApplication(); return $webapp->autoload($className); }
// This version number should be updated with each release - this version number, among other things, is used to construct version-unique URLs for static resources // thus anytime anything in wwwroot/www/framework changes, this should be bumped. This version string should match [0-9\.]* define('PHOCOA_VERSION', '0.4.2'); // PHOCOA shows all deprecation notices by default in wf.log on non-production hosts. if (!defined('WF_LOG_DEPRECATED')) { define('WF_LOG_DEPRECATED', !IS_PRODUCTION); } if (!defined('WF_LOG_ENABLE_ERROR_REPORTING_AUTOCONFIGURATION') or WF_LOG_ENABLE_ERROR_REPORTING_AUTOCONFIGURATION) { if (IS_PRODUCTION) { error_reporting(E_ALL); ini_set('display_errors', false); } else { error_reporting(E_ALL); ini_set('display_errors', true); } } require 'framework/WFLog.php'; // need this for the PEAR_LOG_* constants below, which can't autoload. if (!defined('WF_LOG_LEVEL')) { define('WF_LOG_LEVEL', IS_PRODUCTION ? PEAR_LOG_ERR : PEAR_LOG_DEBUG); } // load the WFWebApplication so that it is initialized() before __autoload() is called for the first time. // if we don't do this, classes attempted to autoload from WFWebApplication::initialize() will cause a fatal error. require 'framework/WFWebApplication.php'; // WFWebApplicationMain() can't autoload... WFWebApplication::sharedWebApplication(); } catch (Exception $e) { header("HTTP/1.0 500 Uncaught Exception"); print "Uncaught Exception thrown during bootstrap."; throw $e; }
/** * Run the web application for the current request. * * NOTE: Both a module and page must be specified in the URL. If they are not BOTH specified, the server will REDIRECT the request to the full URL. * Therefore, you should be sure that when posting form data to a module/page, you use a full path. {@link WFRequestController::WFURL} * * Will pass control onto the current module for processing. * * Create a WFModuleInvocation based on the current HTTP Request, get the results, and output the completed web page. * * @todo Handle 404 situation better -- need to be able to detect this nicely from WFModuleInvocation.. maybe an Exception subclass? * @todo PATH_INFO with multiple params, where one is blank, isn't working correctly. IE, /url/a//c gets turned into /url/a/c for PATH_INFO thus we skip a "null" param. * NOTE: Partial solution; use /WFNull/ to indicate NULL param instead of // until we figure something out. * NOTE: Recent change to REQUEST_URI instead of PATH_INFO to solve decoding problem seems to have also solved the // => / conversion problem... test more! * WORRY: That the new PATH_INFO calculation will fail when using aliases other than WWW_ROOT. IE: /products/myProduct might break it... * @todo The set_error_handler doesn't seem to work very well. PHP issue? Or am I doing it wrong? For instance, it doesn't catch $obj->nonExistantMethod(). */ function handleHTTPRequest() { // point all error handling to phocoa's internal mechanisms since anything that happens after this line (try) will be routed through the framework's handler $this->registerErrorHandlers(); try { $relativeURI = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); // need to run this to convert absolute URI's to relative ones (sent by SOME http clients) if ($relativeURI === false) { throw new WFRequestController_NotFoundException("Malformed URI: {$_SERVER['REQUEST_URI']}"); } $modInvocationPath = ltrim(substr($relativeURI, strlen(WWW_ROOT)), '/'); $paramsPos = strpos($modInvocationPath, '?'); if ($paramsPos !== false) { $modInvocationPath = substr($modInvocationPath, 0, $paramsPos); } if ($modInvocationPath == '') { $modInvocationPath = WFWebApplication::sharedWebApplication()->defaultInvocationPath(); } // allow routing delegate to munge modInvocationPath $webAppDelegate = WFWebApplication::sharedWebApplication()->delegate(); if (is_object($webAppDelegate) && method_exists($webAppDelegate, 'rerouteInvocationPath')) { $newInvocationPath = $webAppDelegate->rerouteInvocationPath($modInvocationPath); if ($newInvocationPath) { $modInvocationPath = $newInvocationPath; } } // create the root invocation; only skin if we're not in an XHR $this->rootModuleInvocation = new WFModuleInvocation($modInvocationPath, NULL, $this->isAjax() ? NULL : WFWebApplication::sharedWebApplication()->defaultSkinDelegate()); // get HTML result of the module, and output it $html = $this->rootModuleInvocation->execute(); // respond to WFRPC::PARAM_ENABLE_AJAX_IFRAME_RESPONSE_MODE for iframe-targeted XHR. Some XHR requests (ie uploads) must be done by creating an iframe and targeting the form // post to the iframe rather than using XHR (since XHR doesn't support uploads methinks). This WFRPC flag makes these such "ajax" requests need to be wrapped slightly differently // to prevent the HTML returned in the IFRAME from executing in the IFRAME which would cause errors. if (isset($_REQUEST[WFRPC::PARAM_ENABLE_AJAX_IFRAME_RESPONSE_MODE]) && $_REQUEST[WFRPC::PARAM_ENABLE_AJAX_IFRAME_RESPONSE_MODE] == 1) { header('Content-Type: text/xml'); $html = "<" . "?xml version=\"1.0\"?" . "><raw><![CDATA[\n{$html}\n]]></raw>"; } print $html; } catch (WFPaginatorException $e) { // paginator fails by default should "route" to bad request. This keeps bots from going crazy. header("HTTP/1.0 400 Bad Request"); print "Bad Request: " . $e->getMessage(); } catch (WFRequestController_RedirectException $e) { header("HTTP/1.1 {$e->getCode()}"); header("Location: {$e->getRedirectURL()}"); } catch (WFRequestController_HTTPException $e) { header("HTTP/1.0 {$e->getCode()}"); print $e->getMessage(); } catch (WFRequestController_BadRequestException $e) { header("HTTP/1.0 400 Bad Request"); print "Bad Request: " . $e->getMessage(); } catch (WFRequestController_NotFoundException $e) { header("HTTP/1.0 404 Not Found"); print $e->getMessage(); } catch (WFRequestController_InternalRedirectException $e) { // internal redirect are handled without going back to the browser... a little bit of hacking here to process a new invocationPath as a "request" // @todo - not sure what consequences this has on $_REQUEST; seems that they'd probably stay intact which could foul things up? $_SERVER['REQUEST_URI'] = $e->getRedirectURL(); WFLog::log("Internal redirect to: {$_SERVER['REQUEST_URI']}"); self::handleHTTPRequest(); } catch (WFRedirectRequestException $e) { header("Location: " . $e->getRedirectURL()); } catch (Exception $e) { $this->handleException($e); } }
/** * Prepare any declared shared instances for the module. * * Shared Instances are objects that not WFView subclasses. Only WFView subclasses may be instantiated in the <pageName>.instances files. * The Shared Instances mechanism is used to instantiate any other objects that you want to use for your pages. Usually, these are things * like ObjectControllers or Formatters, which are typically "shared" across multiple pages. The Shared Instances mechanism makes it * easy to instantiate and configure the properties of objects without coding, and have these objects accessible for bindings or properties. * Of course, you can instantiate objects yourself and use them programmatically. This is just a best-practice for a common situation. * * The shared instances mechanism simply looks for a shared.instances and a shared.config file in your module's directory. The shared.instances * file should simply have a var $__instances that is an associative array of 'unique id' => 'className'. For each declared instance, the * module's instance var $this->$uniqueID will be set to a new instance of "className". * * <code> * $__instances = array( * 'instanceID' => 'WFObjectController', * 'instanceID2' => 'WFUnixDateFormatter' * ); * </code> * * To bind to a shared instance (or for that matter any object that's an instance var of the module), set the instanceID to "#module#, * leave the controllerKey blank, and set the modelKeyPath to "<instanceVarName>.rest.of.key.path". * * To use a shared instance as a property, .................... NOT YET IMPLEMENTED. * * * @todo Allow properties of page.config files to use shared instances. */ function prepareSharedInstances() { $app = WFWebApplication::sharedWebApplication(); $modDir = $this->invocation()->modulesDir(); $moduleInfo = new ReflectionObject($this); $yamlFile = $modDir . '/' . $this->invocation->modulePath() . '/shared.yaml'; if (file_exists($yamlFile)) { $yamlConfig = WFYaml::load($yamlFile); foreach ($yamlConfig as $id => $instInfo) { try { $moduleInfo->getProperty($id); } catch (Exception $e) { WFLog::log("shared.yaml:: Module '" . get_class($this) . "' does not have property '{$id}' declared.", WFLog::WARN_LOG); } // instantiate, keep reference in shared instances WFLog::log("instantiating shared instance id '{$id}'", WFLog::TRACE_LOG); $this->__sharedInstances[$id] = $this->{$id} = new $instInfo['class'](); WFLog::log("loading config for shared instance id '{$id}'", WFLog::TRACE_LOG); // get the instance to apply config to if (!isset($this->{$id})) { throw new WFException("Couldn't find shared instance with ID '{$id}' to configure."); } $configObject = $this->{$id}; // atrributes if (isset($instInfo['properties'])) { foreach ($instInfo['properties'] as $keyPath => $value) { switch (gettype($value)) { case "boolean": case "integer": case "double": case "string": case "NULL": // these are all OK, fall through break; default: throw new WFException("Config value for shared instance id::property '{$id}::{$keyPath}' is not a vaild type (" . gettype($value) . "). Only boolean, integer, double, string, or NULL allowed."); break; } WFLog::log("SharedConfig:: Setting '{$id}' property, {$keyPath} => {$value}", WFLog::TRACE_LOG); $configObject->setValueForKeyPath($value, $keyPath); } } } } else { $instancesFile = $modDir . '/' . $this->invocation->modulePath() . '/shared.instances'; $configFile = $modDir . '/' . $this->invocation->modulePath() . '/shared.config'; if (file_exists($instancesFile)) { include $instancesFile; foreach ($__instances as $id => $class) { // enforce that the instance variable exists try { $moduleInfo->getProperty($id); } catch (Exception $e) { WFLog::log("shared.instances:: Module '" . get_class($this) . "' does not have property '{$id}' declared.", WFLog::WARN_LOG); } // instantiate, keep reference in shared instances $this->__sharedInstances[$id] = $this->{$id} = new $class(); } // configure the new instances $this->loadConfigPHP($configFile); } } // call the sharedInstancesDidLoad() callback $this->sharedInstancesDidLoad(); }
function __construct() { parent::__construct(); $this->authorizationInfoClass = WFWebApplication::sharedWebApplication()->authorizationInfoClass(); $this->authorizationInfo = NULL; $this->authorizationDelegate = NULL; // is session authorization info initialized? if (empty($_SESSION[WFAuthorizationManager::SESSION_NAMESPACE][WFAuthorizationManager::SESSION_KEY_VERSION]) or $_SESSION[WFAuthorizationManager::SESSION_NAMESPACE][WFAuthorizationManager::SESSION_KEY_VERSION] < WFAuthorizationManager::VERSION) { // SESSION authorization info doesn't exist; initialize to least-privileged state // initialize $this->init(); } else { // SESSION authorization does exist; restore from session $this->authorizationInfo = $_SESSION[WFAuthorizationManager::SESSION_NAMESPACE][WFAuthorizationManager::SESSION_KEY_AUTHORIZATION_INFO]; // update recent-auth time if it's within the window if (time() - $_SESSION[WFAuthorizationManager::SESSION_NAMESPACE][WFAuthorizationManager::SESSION_KEY_RECENT_LOGIN_TIME] < WFAuthorizationManager::RECENT_LOGIN_SECS) { $_SESSION[WFAuthorizationManager::SESSION_NAMESPACE][WFAuthorizationManager::SESSION_KEY_RECENT_LOGIN_TIME] = time(); } } }
public function debug() { return WFWebApplication::sharedWebApplication()->debug(); }
/** * Render the skin. * @param boolean TRUE to display the results to the output buffer, FALSE to return them in a variable. DEFAULT: TRUE. * @return string The rendered view. NULL if displaying. * @todo convert the DIR_SMARTY calls to use a new WFWebApplication::getResource($path) infrastructure that will allow for userland overloads of these templates */ function render($display = true) { $this->loadSkin(); $skinTemplatesDir = $this->getSkinTemplatesDir(); $smarty = new WFSmarty(); $smarty->assign('skin', $this); // add variables to smarty $themeVars = $this->skinManifestDelegate->loadTheme($this->skinThemeName); $smarty->assign('skinThemeVars', $themeVars); $smarty->assign('skinTitle', $this->title); $smarty->assign('skinMetaKeywords', join(',', $this->metaKeywords)); $smarty->assign('skinMetaDescription', $this->metaDescription); $smarty->assign('skinCharset', $this->charset); $smarty->assign('skinBody', $this->body); $smarty->assign('skinHeadStrings', join("\n", array_values($this->headStrings))); $smarty->assign('phocoaDebug', WFWebApplication::sharedWebApplication()->debug()); // set up shared directory URLs // deprecated $smarty->assign('skinDir', $this->getSkinDir()); $smarty->assign('skinDirShared', $this->getSkinDirShared()); // new names $smarty->assign('skinTypeAssetsDir', $this->getSkinTypeAssetsDir()); $smarty->assign('skinSharedAssetsDir', $this->getSkinSharedAssetsDir()); $smarty->assign('skinThemeAssetsDir', $this->getSkinThemeAssetsDir()); // FS paths of things $smarty->assign('skinTemplatesDir', $skinTemplatesDir); $smarty->assign('skinTypeDir', $this->getSkinTypeDir()); // build the <head> section $smarty->assign('skinPhocoaHeadTpl', WFWebApplication::appDirPath(WFWebApplication::DIR_SMARTY) . '/head.tpl'); $smarty->assign('skinHead', $smarty->fetch($this->headTemplate)); // set the template if ($this->templateType == WFSkin::SKIN_WRAPPER_TYPE_RAW) { $smarty->setTemplate(WFWebApplication::appDirPath(WFWebApplication::DIR_SMARTY) . '/template_raw.tpl'); } else { $smarty->setTemplate($skinTemplatesDir . '/template_' . $this->templateType . '.tpl'); } // pre-render callback $this->willRender(); // render smarty if ($display) { $smarty->render(); } else { return $smarty->render(false); } }