Пример #1
0
 /**
  * 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);
 }
Пример #2
0
 /** 
  *
  */
 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;
 }
Пример #3
0
 /**
  *
  */
 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();
 }
Пример #4
0
 /**
  * Ping the ElasticSearch mapping, effectively resetting the refresh time
  */
 public function ping()
 {
     $this->opo_app_vars->setVar('ElasticSearchMappingRefresh', time() + 24 * 60 * 60);
     $this->opo_app_vars->save();
 }
Пример #5
0
 /**
  * 
  */
 public function saveWidgetSettings($ps_widget_id)
 {
     if ($va_widget_info = $this->getWidgetByID($ps_widget_id)) {
         $va_available_settings = $this->opo_widget_manager->getWidgetAvailableSettings($va_widget_info['widget']);
         $va_setting_values = $this->opa_dashboard_config['columns'][$va_widget_info['col']][$va_widget_info['pos']]['settings'];
         $o_appvar = null;
         foreach ($va_available_settings as $vs_setting_name => $va_setting_info) {
             $va_setting_values[$vs_setting_name] = $this->opo_request->getParameter('setting_' . $vs_setting_name, pString);
             // 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
                 $o_appvar->setVar('widget_settings_' . $va_widget_info['widget'] . '_' . $vs_setting_name, $va_setting_values[$vs_setting_name]);
                 // put setting value into application var
             }
         }
         if ($o_appvar) {
             $o_appvar->save();
         }
         $this->opa_dashboard_config['columns'][$va_widget_info['col']][$va_widget_info['pos']]['settings'] = $va_setting_values;
         $this->opo_request->user->setVar('dashboard_config', $this->opa_dashboard_config);
     }
     return null;
 }