/** * Internal helper, loads the controller for the current document. Any error triggers a 500. */ private function _load_edit_controller() { $this->_controller = midcom_helper_datamanager2_controller::create('simple'); $this->_controller->schemadb =& $this->_schemadb; $this->_controller->set_storage($this->_document, $this->_schema); if (!$this->_controller->initialize()) { throw new midcom_error("Failed to initialize a DM2 controller instance for document {$this->_document->id}."); } }
/** * Internal helper, loads the controller for the current article. Any error triggers a 500. */ private function _load_controller() { $this->_load_schemadb(); $this->_controller = midcom_helper_datamanager2_controller::create('simple'); $this->_controller->schemadb =& $this->_schemadb; $this->_controller->set_storage($this->_page); if (!$this->_controller->initialize()) { throw new midcom_error("Failed to initialize a DM2 controller instance for article {$this->_article->id}."); } }
/** * Internal helper, loads the controller for the current directoy. Any error triggers a 500. */ private function _load_edit_controller() { $this->_load_schemadb(); $this->_controller = midcom_helper_datamanager2_controller::create('simple'); $this->_controller->schemadb =& $this->_schemadb; $this->_controller->set_storage($this->_request_data['directory'], $this->_schema); if (!$this->_controller->initialize()) { throw new midcom_error("Failed to initialize a DM2 controller instance for task {$this->_directory->id}."); } }
/** * Internal helper, fires up the creation mode controller. Any error triggers a 500. */ private function _load_create_controller() { $this->_controller = midcom_helper_datamanager2_controller::create('create'); $this->_controller->schemadb =& $this->_schemadb; $this->_controller->schemaname = $this->_schema; $this->_controller->callback_object =& $this; $this->_controller->defaults =& $this->_defaults; if (!$this->_controller->initialize()) { throw new midcom_error("Failed to initialize a DM2 create controller."); } }
/** * Internal helper, fires up the creation mode controller. Any error triggers a 500. */ private function _load_create_controller() { $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_directory')); $this->_controller = midcom_helper_datamanager2_controller::create('create'); $this->_controller->schemadb =& $this->_schemadb; $this->_controller->schemaname = $this->_schema; $this->_controller->callback_object =& $this; if (!$this->_controller->initialize()) { throw new midcom_error("Failed to initialize a DM2 create controller."); } }
/** * Looks up an hour_report to edit. * * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_edit($handler_id, array $args, array &$data) { $this->_hour_report = new org_openpsa_projects_hour_report_dba($args[0]); $this->_load_schemadb(); $this->_controller = midcom_helper_datamanager2_controller::create('simple'); $this->_controller->schemadb =& $this->_schemadb; $this->_controller->set_storage($this->_hour_report); if (!$this->_controller->initialize()) { throw new midcom_error("Failed to initialize a DM2 controller instance for hour_report {$this->_hour_report->id}."); } switch ($this->_controller->process_form()) { case 'save': $this->_hour_report->modify_hours_by_time_slot(); // *** FALL-THROUGH *** // *** FALL-THROUGH *** case 'cancel': $task = new org_openpsa_projects_task_dba($this->_hour_report->task); return new midcom_response_relocate("hours/task/" . $task->guid . "/"); } $this->_prepare_request_data(); // Add toolbar items org_openpsa_helpers::dm2_savecancel($this); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "hours/delete/{$this->_hour_report->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ACCESSKEY => 'd')); $parent = $this->_hour_report->get_parent(); $this->_add_toolbar_items($parent); $this->_view_toolbar->bind_to($this->_hour_report); midcom::get('metadata')->set_request_metadata($this->_hour_report->metadata->revised, $this->_hour_report->guid); midcom::get('head')->set_pagetitle($this->_l10n->get($handler_id)); $this->_update_breadcrumb_line($handler_id); }
/** * Copy handler * * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. * @return boolean Indicating success. */ public function _handler_copy($handler_id, array $args, array &$data) { // Get the object that will be copied $this->_load_object($args[0]); midcom::get('auth')->require_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin'); static $targets = array(); $mgdschema_class = midcom_helper_reflector::resolve_baseclass(get_class($this->_object)); // Get the target details if (in_array($mgdschema_class, $targets)) { $target = $targets[$mgdschema_class]; } else { $target = midcom_helper_reflector_copy::get_target_properties($this->_object); } // Load the schemadb for searching the parent object $this->_load_schemadb($target['class'], $target['parent'], true); // Change the name for the parent field $this->_schemadb['object']->fields[$target['parent']]['title'] = $this->_l10n->get('choose the target'); // Load the nullstorage controller $this->_controller = midcom_helper_datamanager2_controller::create('nullstorage'); $this->_controller->schemadb =& $this->_schemadb; if (!$this->_controller->initialize()) { throw new midcom_error('Failed to initialize the controller'); } $this->_prepare_request_data(); // Process the form switch ($this->_controller->process_form()) { case 'save': $new_object = $this->_process_copy($target); // Relocate to the newly created object return new midcom_response_relocate("__mfa/asgard/object/{$this->_request_data['default_mode']}/{$new_object->guid}/"); case 'cancel': return new midcom_response_relocate("__mfa/asgard/object/{$this->_request_data['default_mode']}/{$args[0]}/"); } // Add Thickbox midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/midgard.admin.asgard/object_browser.js'); midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/jQuery/thickbox/jquery-thickbox-3.1.pack.js'); $this->add_stylesheet(MIDCOM_STATIC_URL . '/jQuery/thickbox/thickbox.css', 'screen'); midcom::get('head')->add_jscript('var tb_pathToImage = "' . MIDCOM_STATIC_URL . '/jQuery/thickbox/loadingAnimation.gif"'); // Add jQuery file for the checkbox operations midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/midgard.admin.asgard/jquery-copytree.js'); midcom::get('head')->add_jscript('jQuery(document).ready(function(){jQuery("#midgard_admin_asgard_copytree").tree_checker();})'); // Common hooks for Asgard midgard_admin_asgard_plugin::bind_to_object($this->_object, $handler_id, $data); // Set the page title switch ($handler_id) { case '____mfa-asgard-object_copy_tree': $data['page_title'] = sprintf($this->_l10n->get('copy %s and its descendants'), $this->_object->{$target}['label']); break; default: $data['page_title'] = sprintf($this->_l10n->get('copy %s'), $this->_object->{$target}['label']); } $data['target'] = $target; }
/** * Internal helper, loads the controller for the current object. Any error triggers a 500. * * @param string $type Controller to instantiate (typically 'simple' or 'ajax') */ public function _load_controller($type = 'simple') { $this->_controller = midcom_helper_datamanager2_controller::create($type); $this->_controller->schemadb =& $this->_schemadb; if ($type == 'create') { // Creation controller, give additional parameters $this->_controller->schemaname = $this->_schema; $this->_controller->defaults = $this->_defaults; $this->_controller->callback_object =& $this; } else { if (!$this->_object) { throw new midcom_error_notfound("No object defined for DM2."); } $this->_controller->set_storage($this->_object); } if (!$this->_controller->initialize()) { throw new midcom_error("Failed to initialize a DM2 controller instance for object {$this->_object->guid}."); } }
private function _create_controller(&$data) { // Run datamanager for handling the images $this->_controller = midcom_helper_datamanager2_controller::create('simple'); $this->_controller->schemadb = $this->_load_schema($data['schema_name']); $this->_controller->schemaname = $data['schema_name']; if ($data['list_type'] == 'page') { $this->_controller->set_storage($data['object']); } else { $this->_controller->set_storage($data['folder']); } $this->_controller->initialize(); $this->_request_data['form'] =& $this->_controller; switch ($this->_controller->process_form()) { case 'cancel': midcom::get('head')->add_jsonload("window.close();"); break; } midcom::get('head')->add_jsonload("jQuery('.midcom_helper_datamanager2_widget_images_image').dm2ImagePopupConvert()"); midcom::get('head')->add_jsonload("jQuery('.midcom_helper_datamanager2_widget_downloads_download').dm2ImagePopupConvert();"); }
/** * Handle the message copying interface * * @return boolean Indicating success */ public function _handler_copy($handler_id, array $args, array &$data) { $this->_topic->require_do('midgard:create'); $this->_message = new org_openpsa_directmarketing_campaign_message_dba($args[0]); $guid = $args[0]; $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_message_copy')); $this->_controller = midcom_helper_datamanager2_controller::create('nullstorage'); $this->_controller->schemadb =& $this->_schemadb; $this->_controller->initialize(); $data['targets'] = array(); switch ($this->_controller->process_form()) { case 'save': $copy = new midcom_helper_reflector_copy(); $campaigns = $this->_controller->datamanager->types['campaign']->convert_to_storage(); $copy_objects = array(); foreach ($campaigns as $campaign_id) { try { $campaign = new org_openpsa_directmarketing_campaign_dba($campaign_id); } catch (midcom_error $e) { continue; } $new_object = $copy->copy_object($this->_message->guid, $campaign); $guid = $new_object->guid; // Store for later use $copy_objects[] = $new_object; } if (count($copy_objects) > 1) { $data['targets'] =& $copy_objects; break; } // Fall through // Fall through case 'cancel': return new midcom_response_relocate("message/{$guid}/"); } midcom::get('head')->set_pagetitle($this->_message->title); $this->bind_view_to_object($this->_message); $this->_update_breadcrumb_line($handler_id); }