/** * Base class for widget renderer. Will set basic widget view variables such as DOM 'id', 'widget_id' and the 'settings' array * as well as filling in default values for any unspecified widget settings * * @param $ps_widget_id string the unique id (actually an md5 hash) for the widget * @param $pa_settings array An array of widget settings in a key-value format; this is passed by reference to this base class so it can modify the array for the caller with appropriate default values * @return void */ public function renderWidget($ps_widget_id, &$pa_settings) { $this->opo_view = new View($this->request, $this->ops_widget_path . '/views'); $this->opo_view->setVar('widget_id', $ps_widget_id); $o_appvar = null; // Load default settings if needed if (is_array($va_settings = $this->getAvailableSettings(true))) { foreach ($va_settings as $vs_setting_name => $va_setting_info) { if (!isset($pa_settings[$vs_setting_name])) { $pa_settings[$vs_setting_name] = $this->getSetting($vs_setting_name); } // scope="application" means this setting value should be coming from ApplicationVars; this means it is a value shared across all users of the application. if (isset($va_setting_info['scope']) && $va_setting_info['scope'] == 'application') { $vs_widget_name = preg_replace('!Widget$!', '', get_class($this)); // name is class name minus trailing "Widget" if (!$o_appvar) { $o_appvar = new ApplicationVars(); } $pa_settings[$vs_setting_name] = $o_appvar->getVar('widget_settings_' . $vs_widget_name . '_' . $vs_setting_name); } } } $this->opo_view->setVar('settings', $pa_settings); }
/** * Check if the ElasticSearch mapping needs refreshing * @return bool */ public function needsRefresh() { return time() > $this->opo_app_vars->getVar('ElasticSearchMappingRefresh'); }
/** * */ public function getRefinerySettingsForm($ps_refinery_name, $ps_refinery_id, $pa_settings) { $vs_buf = ''; ExportRefineryManager::initRefineries(); if (ExportRefineryManager::$s_refinery_instances[$ps_refinery_name] && is_object(ExportRefineryManager::$s_refinery_instances[$ps_refinery_name])) { $va_available_settings = ExportRefineryManager::$s_refinery_instances[$ps_refinery_name]->getAvailableSettings(); foreach ($va_available_settings as $vs_setting_name => $va_setting_info) { // scope = "application" means value should be stored as an application-wide value using ApplicationVars. if (isset($va_setting_info['scope']) && $va_setting_info['scope'] == 'application') { if (!$o_appvar) { $o_appvar = new ApplicationVars(); } // get application vars $pa_settings[$vs_setting_name] = $o_appvar->getVar('export_refinery_settings_' . $ps_refinery_name . '_' . $vs_setting_name); } $vs_buf .= ExportRefineryManager::$s_refinery_instances[$ps_refinery_name]->settingHTMLFormElement($ps_refinery_id, $vs_setting_name, array('value' => $pa_settings[$vs_setting_name])); } } return $vs_buf; }
/** * */ function unregisterProcess($pn_proc_id) { $o_appvars = new ApplicationVars(); $va_opo_processes = $o_appvars->getVar("taskqueue_opo_processes"); unset($va_opo_processes[$pn_proc_id]); $o_appvars->setVar("taskqueue_opo_processes", $va_opo_processes); $o_appvars->save(); }