Ejemplo n.º 1
0
 function dspSkinCSS_PageDidLoad()
 {
     // determine skin type/skin/theme
     $cssTemplate = $skinName = $skinThemeName = NULL;
     @(list(, , , $cssTemplate, $skinTypeName, $skinName, $skinThemeName) = split('/', $_SERVER['PATH_INFO']));
     $cssFilePath = WFWebApplication::appDirPath(WFWebApplication::DIR_SKINS) . '/' . $skinTypeName . '/' . $skinName . '/' . $cssTemplate;
     if (!file_exists($cssFilePath)) {
         header("HTTP/1.0 404 Not Found");
         print "No css file at: {$cssFilePath}";
         exit;
     }
     // set the skin's wrapper information
     $skin = $this->invocation->rootSkin();
     $skin->setDelegateName($skinTypeName);
     $skin->setSkin($skinName);
     $skin->setTemplateType(WFSkin::SKIN_WRAPPER_TYPE_RAW);
     $skin->setValueForKey($skinThemeName, 'skinThemeName');
     // load the theme vars into our smarty for this module
     $this->requestPage->assign('skinThemeVars', $skin->valueForKey('skinManifestDelegate')->loadTheme($skinThemeName));
     $this->requestPage->assign('cssFilePath', $cssFilePath);
     $this->requestPage->assign('skinDir', $skin->getSkinDir());
     $this->requestPage->assign('skinDirShared', $skin->getSkinDirShared());
     header("Content-Type: text/css");
     // make CSS cacheable for a day at least
     $seconds = 24 * 60 * 60;
     // cache control - we can certainly safely cache the search results for 15 minutes
     header('Pragma: ');
     // php adds Pragma: nocache by default, so we have to disable it
     header('Cache-Control: max-age=' . $seconds);
     // Format: Fri, 30 Oct 1998 14:19:41 GMT
     header('Expires: ' . gmstrftime("%a, %d %b %Y %T ", time() + $seconds) . ' GMT');
 }
Ejemplo n.º 2
0
 /**
  * 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));
 }
Ejemplo n.º 3
0
 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);
 }
 /**
  * Constructor.
  */
 function __construct($id, $page)
 {
     parent::__construct($id, $page);
     $this->containerClass = 'PhocoaDialog';
     $this->moduleView = NULL;
     $this->deferModuleViewLoading = false;
     $this->cacheModuleView = false;
     $this->inline = false;
     $this->yuiloader()->addModule('phocoaDialog', 'js', NULL, WFWebApplication::webDirPath(WFWebApplication::WWW_DIR_FRAMEWORK) . '/js/yahoo-phocoa-min.js', array('connection', 'container', 'dragdrop', 'selector'), NULL, NULL, NULL);
     $this->yuiloader()->yuiRequire("phocoaDialog");
 }
Ejemplo n.º 5
0
 /**
  * Log the passed exception to the framework's log folder.
  */
 function log(Exception $e)
 {
     $logfile = WFWebApplication::appDirPath(WFWebApplication::DIR_LOG) . '/framework_exceptions.log';
     $smarty = new WFSmarty();
     $smarty->assign('exception', $e);
     $smarty->setTemplate(WFWebApplication::appDirPath(WFWebApplication::DIR_SMARTY) . '/app_error_log.tpl');
     $errText = $smarty->render(false);
     // append info to log
     $fs = fopen($logfile, 'a');
     fputs($fs, $errText);
     fclose($fs);
 }
Ejemplo n.º 6
0
 function __construct()
 {
     parent::Smarty();
     $this->template = NULL;
     // by default, no template!
     // smarty stuff
     // runtime directories
     $this->compile_dir = WFWebApplication::appDirPath(WFWebApplication::DIR_RUNTIME) . '/smarty/templates_c/';
     $this->cache_dir = WFWebApplication::appDirPath(WFWebApplication::DIR_RUNTIME) . '/smarty/cache/';
     // default directories
     $this->template_dir = WFWebApplication::appDirPath(WFWebApplication::DIR_SMARTY) . '/templates/';
     $this->config_dir = WFWebApplication::appDirPath(WFWebApplication::DIR_SMARTY) . '/configs/';
     // add a local plugins dir
     array_push($this->plugins_dir, FRAMEWORK_DIR . '/smarty/plugins/');
     // GLOBAL variables for all smarty templates
     $this->assign('WWW_ROOT', WWW_ROOT);
 }
Ejemplo n.º 7
0
 function dspSkinCSS_PageDidLoad()
 {
     // determine skin type/skin/theme
     $cssTemplate = $skinName = $skinThemeName = NULL;
     @(list(, , , $cssTemplate, $skinTypeName, $skinName, $skinThemeName) = split('/', $_SERVER['PATH_INFO']));
     $cssFilePath = WFWebApplication::appDirPath(WFWebApplication::DIR_SKINS) . '/' . $skinTypeName . '/' . $skinName . '/' . $cssTemplate;
     if (!file_exists($cssFilePath)) {
         header("HTTP/1.0 404 Not Found");
         exit;
     }
     // set the skin's wrapper information
     $skin =& WFRequestController::sharedSkin();
     $skin->setDelegateName($skinTypeName);
     $skin->setSkin($skinName);
     $skin->setTemplateType(SKIN_WRAPPER_TYPE_RAW);
     $skin->setValueForKey($skinThemeName, 'skinThemeName');
     // load the theme vars into our smarty for this module
     $this->requestPage->assign('skinThemeVars', $skin->valueForKey('skinManifestDelegate')->loadTheme($skinThemeName));
     $this->requestPage->assign('cssFilePath', $cssFilePath);
     $this->requestPage->assign('skinDir', $skin->getSkinDir());
     $this->requestPage->assign('skinDirShared', $skin->getSkinDirShared());
     header("Content-Type: text/css");
 }
Ejemplo n.º 8
0
/** 
*  Smarty plugin to display errors from a form submission.
*
*  The error is rendered by the "form_error.tpl" template file.
*
*  Smarty Params:
*  id - The id of the WFWidget to show errors for. OPTIONAL -- if the ID is for a WFForm, will show ALL errors from form submission. 
8       NOTE: DEPRECATED: You can also leave the ID BLANK to show all errors. But this has been deprecated b/c we need the ID to make AJAX updating work.
*       NOTE: to show errors on WFDynamic-generated widgets, use WFShowErrors with the ID of the WFDynamic. The WFShowErrors tag must occur AFTER the WFDynamic tag.
*
*  @param array The params from smarty tag.
*  @param object WFSmarty object of the current tpl.
*  @return string The rendered HTML of the error.
*  @todo Need to make it not-hard-coded to get the form_error.tpl file... should be able to override this in userland.
*/
function smarty_function_WFShowErrors($params, &$smarty)
{
    static $errorSmarty = NULL;
    $page = $smarty->getPage();
    if ($page->ignoreErrors()) {
        return;
    }
    if (is_null($errorSmarty)) {
        $errorSmarty = new WFSmarty();
        $errorSmarty->setTemplate(WFWebApplication::appDirPath(WFWebApplication::DIR_SMARTY) . '/form_error.tpl');
    }
    // if the ID is a WFForm, that is the same as "all errors"
    $getErrorsForId = NULL;
    if (!empty($params['id'])) {
        if (!$page->outlet($params['id']) instanceof WFForm) {
            $getErrorsForId = $params['id'];
        }
    }
    // get error list
    if ($getErrorsForId === NULL) {
        // get all errors
        $errors = $page->errors();
    } else {
        // get errors for a specific widget
        $widget = $smarty->getCurrentWidget($params);
        if ($widget instanceof WFDynamic and !$widget->valueForKeyPath('oneShotMode')) {
            $widget = $widget->getLastRenderedWidget();
        }
        $errors = $widget->errors();
    }
    $errorHTML = '';
    $errorSmarty->assign('errorList', $errors);
    $errorSmarty->assign('id', empty($params['id']) ? NULL : $params['id']);
    $errorHTML = $errorSmarty->render(false);
    return $errorHTML;
}
Ejemplo n.º 9
0
 /**
  *  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);
 }
Ejemplo n.º 10
0
 /**
  *  Cause the visitor to be re-directed to the login page.
  *
  *  OPTIONAL: "continueURL" support.
  *
  *  This will issue a 302 redirect and exit the current request execution.
  *
  *  @param string The URL of the page to go to after successful login. Note that this should be a PLAIN URL, but it WILL BE base64-encoded before being passed to the login module.
  */
 function doLoginRedirect($continueURL)
 {
     $loginInvocationPath = $this->loginInvocationPath();
     if (WFRequestController::sharedRequestController()->isAjax()) {
         header("HTTP/1.0 401 Login Required");
         print WWW_ROOT . "/{$loginInvocationPath}/" . WFWebApplication::serializeURL($continueURL);
     } else {
         header("Location: " . WWW_ROOT . "/{$loginInvocationPath}/" . WFWebApplication::serializeURL($continueURL));
     }
     exit;
 }
Ejemplo n.º 11
0
 /**
  * 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();
 }
Ejemplo n.º 12
0
 /**
  * Get a reference to the shared application object.
  * @static
  * @return object The WFWebApplication object.
  */
 static function sharedWebApplication()
 {
     static $webapp = NULL;
     if (!$webapp) {
         $webapp = new WFWebApplication();
         $webapp->init();
     }
     return $webapp;
 }
Ejemplo n.º 13
0
 /**
  * Get a list of all installed skins for the current Skin Type.
  *
  * @return array Skins that are installed.
  */
 function installedSkins()
 {
     $skins = array();
     $skinsDir = WFWebApplication::appDirPath(WFWebApplication::DIR_SKINS);
     $skinDirPath = $skinsDir . '/' . $this->delegateName;
     $dh = opendir($skinDirPath);
     if ($dh) {
         while (($file = readdir($dh)) !== false) {
             if (is_dir($skinDirPath . '/' . $file) and !in_array($file, array('.', '..'))) {
                 array_push($skins, $file);
             }
         }
         closedir($dh);
     }
     return $skins;
 }
Ejemplo n.º 14
0
 function render($blockContent = NULL)
 {
     if ($this->hidden) {
         return NULL;
     } else {
         if ($this->enableDragDropTree) {
             $this->yuiloader()->addModule('treeviewdd', 'js', NULL, WFWebApplication::webDirPath(WFWebApplication::WWW_DIR_FRAMEWORK) . '/js/yahoo-treeviewdd.js', array('treeview', 'dragdrop'), NULL, NULL, NULL);
             $this->yuiloader()->yuiRequire('treeviewdd');
         }
         // set up basic HTML
         $html = parent::render($blockContent);
         $html .= "<div id=\"{$this->id}_status\" style=\"display: none;\"></div><div id=\"{$this->id}\"></div>\n";
         return $html;
     }
 }
Ejemplo n.º 15
0
    function render($blockContent = NULL)
    {
        // craft a WFRPC that we can insert into the form stream to have our callback fire
        $rpc = WFRPC::RPC()->setInvocationPath($this->page->module()->invocation()->invocationPath())->setTarget('#page#' . $this->id)->setAction('handleUploadedFile')->setForm($this)->setIsAjax(true);
        return '
<applet name="postlet" code="Main.class" archive="' . $this->getWidgetWWWDir() . '/postlet.jar" width="305" height="200" mayscript="mayscript">
    <param name = "uploadparametername"      value = "' . $this->id . '" />
    <param name = "additionalformparameters" value = "' . http_build_query($rpc->rpcAsParameters($this), '', '&amp;') . '" />

    ' . ($this->dropimage ? '<param name = "dropimage"       value = "' . $this->baseurl . $this->dropimage . '"/>' : NULL) . '
    ' . ($this->dropimageupload ? '<param name = "dropimageupload"       value = "' . $this->baseurl . $this->dropimageupload . '"/>' : NULL) . '

    <param name = "maxthreads"      value = "' . $this->maxthreads . '" />
    <param name = "destination"     value = "' . $this->baseurl . '/' . $this->page->module()->invocation()->invocationPath() . '" />
    ' . ($this->backgroundcolour ? '<param name = "backgroundcolour" value = "' . $this->backgroundcolour . '" />' : NULL) . '
    ' . ($this->tableheaderbackgroundcolour ? '<param name = "tableheaderbackgroundcolour" value = "' . $this->tableheaderbackgroundcolour . '" />' : NULL) . '
    ' . ($this->tableheadercolour ? '<param name = "tableheadercolour" value = "' . $this->tableheadercolour . '" />' : NULL) . '
    <param name = "warnmessage" value = "' . ($this->warnmessage ? 'true' : 'false') . '" />
    <param name = "autoupload" value = "' . ($this->autoupload ? 'true' : 'false') . '" />
    <param name = "helpbutton" value = "' . ($this->helpbutton ? 'true' : 'false') . '" />
    <param name = "removebutton" value = "' . ($this->removebutton ? 'true' : 'false') . '" />
    <param name = "addbutton" value = "' . ($this->addbutton ? 'true' : 'false') . '" />
    <param name = "uploadbutton" value = "' . ($this->uploadbutton ? 'true' : 'false') . '" />
    <param name = "fileextensions" value = "JPEG Image Files,jpg,jpeg" />
    ' . ($this->endpage ? '<param name = "endpage" value = "' . $this->baseurl . $this->endpage . '" />' : NULL) . '
</applet>
<script type="text/javascript" src="' . WFWebApplication::webDirPath(WFWebApplication::WWW_DIR_FRAMEWORK) . '/js/embeddedcontent_min.js" defer="defer"></script>
        ';
    }
Ejemplo n.º 16
0
 /**
  * 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);
     }
 }
Ejemplo n.º 17
0
 /**
  *  Get an absolute filesystem path to the www dir for graphics for this widget in the current project.
  *
  *  @return string The path to directory containing www items for this widget.
  */
 function getWidgetDir()
 {
     return WFWebApplication::appDirPath(WFWebApplication::DIR_WWW) . '/framework/widgets/' . get_class($this);
 }
Ejemplo n.º 18
0
 /**
  *  Constructor.
  *
  *  @param object Criteria The Propel criteria for the query.
  *  @param string The name of the Peer class to run the query against.
  *  @param string The name of the Peer method to use for the select. Defaults to doSelect.
  */
 function __construct($criteria, $peerName, $peerSelectMethod = 'doSelect')
 {
     $this->criteria = $criteria;
     $this->peerName = $peerName;
     $this->peerSelectMethod = $peerSelectMethod;
     // There is a bug in call_user_func that causes PHP to crash if the peer being called isn't already loaded.
     if (!class_exists($this->peerName)) {
         WFWebApplication::autoload($this->peerName);
     }
 }
Ejemplo n.º 19
0
 function promptLogin_doLogin_Action($page)
 {
     $ac = WFAuthorizationManager::sharedAuthorizationManager();
     $ok = $ac->login($page->outlet('username')->value(), $page->outlet('password')->value());
     if ($ok) {
         // login was successful
         // remember me stuff
         // ...
         // continue to next page
         if ($page->outlet('continueURL')->value()) {
             $continueURL = WFWebApplication::unserializeURL($page->outlet('continueURL')->value());
         } else {
             $continueURL = $ac->defaultLoginContinueURL();
         }
         $this->gotoURL($continueURL);
     } else {
         // login failed
         $failMsg = $ac->loginFailedMessage($page->outlet('username')->value());
         if (!is_array($failMsg)) {
             $failMsg = array($failMsg);
         }
         foreach ($failMsg as $msg) {
             $page->addError(new WFError($msg));
         }
     }
 }
Ejemplo n.º 20
0
 public function debug()
 {
     return WFWebApplication::sharedWebApplication()->debug();
 }
Ejemplo n.º 21
0
 private function sendPageErrorsOverAjax()
 {
     // Collect all errors and send them back in a WFActionResponseWFErrorsException
     $errorSmarty = new WFSmarty();
     $errorSmarty->setTemplate(WFWebApplication::appDirPath(WFWebApplication::DIR_SMARTY) . '/form_error.tpl');
     $uiUpdates = new WFActionResponseWFErrorsException();
     foreach ($this->widgets() as $id => $obj) {
         $errors = $obj->errors();
         if (count($errors)) {
             $errorSmarty->assign('errorList', $errors);
             $errorSmarty->assign('id', $id);
             $errId = "phocoaWFFormError_{$id}";
             $uiUpdates->addReplaceHTML($errId, $errorSmarty->render(false));
         }
     }
     // put "all errors" in the submitted form err handler
     $errorSmarty->assign('errorList', $this->errors());
     $errorSmarty->assign('id', $this->submittedFormName());
     $errId = "phocoaWFFormError_" . $this->submittedFormName();
     $uiUpdates->addReplaceHTML($errId, $errorSmarty->render(false));
     $uiUpdates->send();
 }
Ejemplo n.º 22
0
 /**
  *  Cause the visitor to be re-directed to the login page.
  *
  *  OPTIONAL: "continueURL" support.
  *
  *  This will issue a 302 redirect and exit the current request execution.
  *
  *  @param string The URL of the page to go to after successful login. Note that this should be a PLAIN URL, but it WILL BE base64-encoded before being passed to the login module.
  *  @param boolean TRUE to force the login screen even if already logged in (used for forcing re-auth of secure areas).
  */
 function doLoginRedirect($continueURL, $reauthorizeEvenIfLoggedIn = false)
 {
     $reauthorizeEvenIfLoggedInSuffix = $reauthorizeEvenIfLoggedIn ? "/1" : NULL;
     $loginInvocationPath = $this->loginInvocationPath();
     if (WFRequestController::sharedRequestController()->isAjax()) {
         header("HTTP/1.0 401 Login Required");
         print WWW_ROOT . "/{$loginInvocationPath}/" . WFWebApplication::serializeURL($continueURL) . $reauthorizeEvenIfLoggedInSuffix;
     } else {
         header("Location: " . WWW_ROOT . "/{$loginInvocationPath}/" . WFWebApplication::serializeURL($continueURL) . $reauthorizeEvenIfLoggedInSuffix);
     }
     exit;
 }
Ejemplo n.º 23
0
    // 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;
}
Ejemplo n.º 24
0
 function render($blockContent = NULL)
 {
     if ($this->activeTab == NULL) {
         $this->setActiveTabID($this->defaultTabID);
     }
     $template = $this->page->template();
     $template->assign('__tabView', $this);
     if ($this->onePageMode) {
         $tabTplFile = WFWebApplication::appDirPath(WFWebApplication::DIR_SMARTY) . '/onepage_tabs.tpl';
     } else {
         $tabTplFile = WFWebApplication::appDirPath(WFWebApplication::DIR_SMARTY) . '/multipage_tabs.tpl';
         throw new Exception("Non-onePage mode not yet implemented.");
     }
     return $template->fetch($tabTplFile);
 }