<?php $widget_id = (int) $_REQUEST['widget_id']; $widget = module_widget::get_widget($widget_id); if ($widget_id > 0 && $widget['widget_id'] == $widget_id) { $module->page_title = 'Widget' . ': ' . $widget['name']; } else { $module->page_title = 'Widget' . ': ' . _l('New'); } if ($widget_id > 0 && $widget) { if (class_exists('module_security', false)) { module_security::check_page(array('module' => $module->module_name, 'feature' => 'edit')); } } else { if (class_exists('module_security', false)) { module_security::check_page(array('module' => $module->module_name, 'feature' => 'create')); } module_security::sanatise_data('widget', $widget); } ?> <form action="" method="post"> <input type="hidden" name="_process" value="save_widget" /> <input type="hidden" name="widget_id" value="<?php echo $widget_id; ?> " />
public static function get_replace_fields($widget_id, $widget_data = false) { if (!$widget_data) { $widget_data = self::get_widget($widget_id); } $data = array('widget_name' => $widget_data['name']); $data = array_merge($data, $widget_data); if (class_exists('module_group', false)) { // get the widget groups $g = array(); if ($widget_id > 0) { $widget_data = module_widget::get_widget($widget_id); foreach (module_group::get_groups_search(array('owner_table' => 'widget', 'owner_id' => $widget_id)) as $group) { $g[$group['group_id']] = $group['name']; } } $data['widget_group'] = implode(', ', $g); } // addition. find all extra keys for this widget and add them in. // we also have to find any EMPTY extra fields, and add those in as well. $all_extra_fields = module_extra::get_defaults('widget'); foreach ($all_extra_fields as $e) { $data[$e['key']] = _l('N/A'); } // and find the ones with values: $extras = module_extra::get_extras(array('owner_table' => 'widget', 'owner_id' => $widget_id)); foreach ($extras as $e) { $data[$e['extra_key']] = $e['extra']; } return $data; }