Ejemplo n.º 1
0
 /**
  * Генерация виджета
  * @param mixed номер виджета или его keyword
  * @param array поля виджета
  * @param bool обновлять ли экземпляр виджета
  * @param integer id обновляемого виджета
  * @return string html-код виджета
  */
 public function generate($id, $fields = '', $static = 0, $widget_id = 0)
 {
     $nc_core = $this->core;
     $db = $nc_core->db;
     $params = $this->get_widgetclass($id);
     $res = $db->get_results("SELECT `Field_Name`, `DefaultState` FROM `Field` WHERE `Widget_Class_ID`='" . $params['Widget_Class_ID'] . "'");
     if ($res) {
         foreach ($res as $r) {
             $new_fields .= "\$f_" . $r->Field_Name . "= '" . $r->DefaultState . "';";
         }
     }
     if ($fields != '') {
         foreach ($fields as $f => $val) {
             $new_fields .= "\$f_" . $f . "= '" . $val . "';";
         }
     }
     $result = '';
     eval($new_fields);
     if ($params['File_Mode']) {
         $widget_view = new nc_widget_view($nc_core->WIDGET_TEMPLATE_FOLDER, $db);
         $widget_view->load($params['Widget_Class_ID']);
         include $widget_view->get_field_path('Settings');
         ob_start();
         include $widget_view->get_field_path('Template');
         $result .= ob_get_clean();
     } else {
         eval($params['Settings']);
         eval("\$result .= \"" . $params['Template'] . "\";");
     }
     if ($static) {
         $db->query("UPDATE `Widget` SET `LastUpdated` = NOW(), `Result`='" . $this->core->db->escape($result) . "'" . $this->get_where($widget_id, 1) . "");
     }
     return $result;
 }
Ejemplo n.º 2
0
 protected function generate_aggregator($widget_id, $settings)
 {
     if (is_string($settings) && $settings[0] == 'a') {
         $settings = unserialize($settings);
     } else {
         $settings = (array) $settings;
     }
     $widget = nc_db_table::make('Widget')->where_id($widget_id)->get_row();
     $fields = array();
     $nc_core = nc_core();
     $db = nc_db();
     $widget_class_id = $widget['Widget_Class_ID'];
     $field_values = nc_db_table::make('Widget_Field')->where('Widget_ID', $widget_id)->get_list('Field_ID', 'Value');
     $result = $db->get_results("SELECT `Field_ID`, `Field_Name`, `DefaultState` FROM `Field` WHERE `Widget_Class_ID`='" . $widget_class_id . "'", ARRAY_A);
     foreach ($result as $row) {
         $field_id = $row['Field_ID'];
         $fields[$row['Field_Name']] = isset($field_values[$field_id]) ? $field_values[$field_id] : $row['DefaultState'];
     }
     extract($fields, EXTR_PREFIX_ALL, 'f');
     $widget_view = new nc_widget_view($this->core->WIDGET_TEMPLATE_FOLDER, nc_db());
     $widget_view->load($widget['Widget_Class_ID']);
     include $widget_view->get_field_path('Settings');
     ob_start();
     include $widget_view->get_field_path('Template');
     return ob_get_clean();
 }
Ejemplo n.º 3
0
                     $f_val = str_replace(",", ".", $f_val);
                 }
                 break;
         }
         if ($type_err) {
             nc_print_status(str_replace("%NAME", $fieldDescriptions[$f_Id], NETCAT_MODERATION_MSG_TWO), 'error');
             nc_widget_edit_form($post, $widget_id);
         }
     }
 }
 $file_mode = $db->get_var("SELECT `File_Mode` FROM `Widget_Class` WHERE `Widget_Class_ID` = " . $widget_class_id);
 // Выполняем действие перед сохранением (insert & update) объекта
 if ($file_mode) {
     $action_data = array('action' => 'update', 'widget_class_id' => $widget_class_id);
     extract($action_data);
     $widget_view = new nc_widget_view($nc_core->WIDGET_TEMPLATE_FOLDER, $db);
     $widget_view->load($widget_class_id);
     $before_action_file = $widget_view->get_field_path('BeforeSaveAction');
     if (file_exists($before_action_file)) {
         include $before_action_file;
     }
 }
 nc_widget_edit($widget_id, $params, $fields);
 // Выполняем действие после сохранения (insert & update) объекта
 if ($file_mode) {
     $after_action_file = $widget_view->get_field_path('AfterSaveAction');
     if (file_exists($after_action_file)) {
         include $after_action_file;
     }
 }
 nc_print_status(WIDGET_EDIT_OK, 'ok');