Changeset 11684
- Timestamp:
- 08/22/07 18:25:42 (1 year ago)
- Files:
-
- branches/branch-2_6/src/midcom.admin.folder/config/config.inc (modified) (1 diff)
- branches/branch-2_6/src/midcom.admin.folder/config/manifest.inc (modified) (4 diffs)
- branches/branch-2_6/src/midcom.admin.folder/config/schemadb_folder.inc (added)
- branches/branch-2_6/src/midcom.admin.folder/documentation/CHANGES (modified) (1 diff)
- branches/branch-2_6/src/midcom.admin.folder/folder_management.php (modified) (13 diffs)
- branches/branch-2_6/src/midcom.admin.folder/handler/create.php (deleted)
- branches/branch-2_6/src/midcom.admin.folder/handler/edit.php (modified) (7 diffs)
- branches/branch-2_6/src/midcom.admin.folder/style/midcom-admin-folder-stylelist-footer.php (deleted)
- branches/branch-2_6/src/midcom.admin.folder/style/midcom-admin-folder-stylelist-header.php (deleted)
- branches/branch-2_6/src/midcom.admin.folder/style/midcom-admin-folder-stylelist-item.php (deleted)
- branches/branch-2_6/src/midcom.admin.folder/style/midcom-admin-show-create-folder.php (deleted)
- branches/branch-2_6/src/midcom.admin.folder/style/midcom-admin-show-edit-folder.php (deleted)
- branches/branch-2_6/src/midcom.admin.folder/style/midcom-admin-show-folder-actions.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/branch-2_6/src/midcom.admin.folder/config/config.inc
r5150 r11684 1 1 'schemadb' => 'file:/midcom/config/metadata_dm2_default.inc', 2 'schemadbs_folder' => array 3 ( 4 'default' => 'file:/midcom/admin/folder/config/schemadb_folder.inc', 5 ), 6 branches/branch-2_6/src/midcom.admin.folder/config/manifest.inc
r5772 r11684 1 1 'name' => 'midcom.admin.folder', 2 2 'purecode' => true, 3 'version' => '1.1. 4',4 'state' => ' stable',5 'privileges' => Array3 'version' => '1.1.5', 4 'state' => 'beta', 5 'privileges' => array 6 6 ( 7 7 'topic_management' => MIDCOM_PRIVILEGE_DENY, 8 'template_management' => MIDCOM_PRIVILEGE_DENY, 8 9 ), 9 'package.xml' => Array10 'package.xml' => array 10 11 ( 11 12 'summary' => 'Folder management', 12 13 'description' => 'Management of MidCOM site folders', 13 'maintainers' => Array14 'maintainers' => array 14 15 ( 15 'bergie' => Array16 'bergie' => array 16 17 ( 17 18 'name' => 'Henri Bergius', … … 19 20 'role' => 'lead', 20 21 ), 21 'adrenalin' => Array22 'adrenalin' => array 22 23 ( 23 24 'name' => 'Arttu Manninen', … … 25 26 'role' => 'lead', 26 27 ), 27 'torben' => Array28 'torben' => array 28 29 ( 29 30 'name' => 'Torben Nehmer', … … 33 34 ), 34 35 ), 35 'dependencies' => Array36 'dependencies' => array 36 37 ( 37 'midcom.helper.datamanager2' => Array(), 38 'midcom.helper.datamanager2' => array (), 39 'midcom' => array (), 38 40 ), 39 41 ), branches/branch-2_6/src/midcom.admin.folder/documentation/CHANGES
r5768 r11684 6 6 which might even break existing functionality. 7 7 - All items marked with "+" represent completly new features. 8 9 2007-06-07 adrenalin 10 - Masked PHP notices on component listings for possible missing 'state' keys in manifests 11 12 2007-06-03 13 - Added component state display 8 14 9 15 2007-04-20 adrenalin branches/branch-2_6/src/midcom.admin.folder/folder_management.php
r5150 r11684 79 79 80 80 $this->_request_data['folder'] = $this->_topic; 81 82 // if (!array_key_exists($this->_topic->get_parameter('midcom', 'component'), $_MIDCOM->componentloader->manifests))83 // {84 // $this->_topic->set_parameter('midcom', 'component', 'midcom.core.nullcomponent');85 // }86 81 } 87 82 … … 108 103 'create' => array 109 104 ( 110 'handler' => array('midcom_admin_folder_handler_ create', 'create'),111 'fixed_args' => 'create',105 'handler' => array('midcom_admin_folder_handler_edit', 'edit'), 106 'fixed_args' => array ('create'), 112 107 ), 113 108 … … 120 115 ( 121 116 'handler' => array('midcom_admin_folder_handler_edit', 'edit'), 122 'fixed_args' => 'edit',117 'fixed_args' => array ('edit'), 123 118 ), 124 119 … … 131 126 ( 132 127 'handler' => array('midcom_admin_folder_handler_delete', 'delete'), 133 'fixed_args' => 'delete',128 'fixed_args' => array ('delete'), 134 129 ), 135 130 … … 146 141 ( 147 142 'handler' => array('midcom_admin_folder_handler_approvals', 'approval'), 148 'fixed_args' => 'approve',143 'fixed_args' => array ('approve'), 149 144 ), 150 145 … … 157 152 ( 158 153 'handler' => array('midcom_admin_folder_handler_approvals', 'approval'), 159 'fixed_args' => 'unapprove',154 'fixed_args' => array ('unapprove'), 160 155 ), 161 156 … … 171 166 ( 172 167 'handler' => array('midcom_admin_folder_handler_metadata', 'metadata'), 173 'fixed_args' => 'metadata', 168 'fixed_args' => array ('metadata'), 169 'variable_args' => 1, 170 ), 171 172 /** 173 * Object moving 174 * 175 * Match /move/<object guid>/ 176 */ 177 'move' => array 178 ( 179 'handler' => array('midcom_admin_folder_handler_move', 'move'), 180 'fixed_args' => array ('move'), 174 181 'variable_args' => 1, 175 182 ), … … 179 186 ( 180 187 'handler' => array('midcom_admin_folder_handler_order', 'order'), 181 'fixed_args' => 'order',188 'fixed_args' => array ('order'), 182 189 ), 183 190 ); … … 205 212 206 213 // Skip components beginning with midcom or midgard 207 if (ereg('^(midcom|midgard)\.', $manifest->name)) 214 if ( ereg('^(midcom|midgard)\.', $manifest->name) 215 && $manifest->name != 'midcom.helper.search') 208 216 { 209 217 continue; … … 225 233 $description = ''; 226 234 } 227 235 228 236 $components[$manifest->name] = array 229 237 ( 230 'name' => $manifest->get_name_translated(),238 'name' => $manifest->get_name_translated(), 231 239 'description' => $description, 240 'state' => @$manifest->state, 241 'version' => $manifest->version, 232 242 ); 233 243 } … … 251 261 252 262 /** 263 * Static method for populating user interface for editing and creating topics 264 * 265 * @access static public 266 * @return Array Containing a list of components 267 */ 268 function list_components($parent_component = '', $all = false) 269 { 270 $list = array(); 271 272 foreach (midcom_admin_folder_folder_management::get_component_list() as $component => $details) 273 { 274 // TODO: configuration options for either excluding or including components to the list 275 if ( isset($GLOBALS['midcom_config']['component_listing_allowed']) 276 && is_array($GLOBALS['midcom_config']['component_listing_allowed']) 277 && !in_array($component, $GLOBALS['midcom_config']['component_listing_allowed']) 278 && $component !== $parent_component 279 && !$all) 280 { 281 continue; 282 } 283 284 if ( isset($GLOBALS['midcom_config']['component_listing_excluded']) 285 && is_array($GLOBALS['midcom_config']['component_listing_excluded']) 286 && in_array($component, $GLOBALS['midcom_config']['component_listing_excluded']) 287 && $component !== $parent_component 288 && !$all) 289 { 290 continue; 291 } 292 293 $list[$component] = "{$details['name']} ({$component} {$details['version']})"; 294 } 295 296 return $list; 297 } 298 299 /** 253 300 * Static method for listing available style templates 254 301 * … … 258 305 { 259 306 static $style_array = array(); 307 308 $style_array[''] = $_MIDCOM->i18n->get_string('default', 'midcom.admin.folder'); 260 309 261 310 $qb = midcom_db_style::new_query_builder(); … … 266 315 { 267 316 $style_string = "{$prefix}{$style->name}"; 317 318 // Hide common unwanted material with heuristics 319 if (preg_match('/(asgard|aegir|empty|spider|admin site)/i', $style_string)) 320 { 321 continue; 322 } 323 268 324 $style_array[$style_string] = "{$spacer}{$style->name}"; 269 325 midcom_admin_folder_folder_management::list_styles($style->id, $style_string . '/', $spacer . ' '); branches/branch-2_6/src/midcom.admin.folder/handler/edit.php
r5150 r11684 16 16 { 17 17 /** 18 * DM2 schema 19 * 20 * @access private 21 * @var midcom_helper_datamanager2_schema $_schema 22 */ 23 var $_schemadb; 24 25 /** 26 * DM2 controller instance 27 * 28 * @access private 29 * @var midcom_helper_datamanager2_controller $_controller 30 */ 31 var $_controller; 32 33 /** 34 * ID of the handler 35 * 36 * @access private 37 */ 38 var $_handler_id; 39 40 /** 18 41 * Constructor method 19 42 * … … 24 47 parent::midcom_baseclasses_components_handler(); 25 48 } 26 49 50 /** 51 * Load the schemadb and other midcom.admin.folder specific stuff 52 * 53 * @access public 54 */ 55 function _on_initialize() 56 { 57 // Load the configuration 58 $_MIDCOM->componentloader->load('midcom.admin.folder'); 59 $this->_config =& $GLOBALS['midcom_component_data']['midcom.admin.folder']['config']; 60 } 61 62 /** 63 * Load either a create controller or an edit (simple) controller or trigger an error message 64 * 65 * @access private 66 */ 67 function _load_controller() 68 { 69 // Get the configured schemas 70 $schemadbs = $this->_config->get('schemadbs_folder'); 71 72 // Check if a custom schema exists 73 if (array_key_exists($this->_topic->get_parameter('midcom', 'component'), $schemadbs)) 74 { 75 $schemadb = $schemadbs[$this->_topic->get_parameter('midcom', 'component')]; 76 } 77 else 78 { 79 if (!array_key_exists('default', $schemadbs)) 80 { 81 $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 'Configuration error. No default schema for topic has been defined!'); 82 // This will exit 83 } 84 85 $schemadb = $schemadbs['default']; 86 } 87 88 $GLOBALS['midcom_admin_folder_mode'] = $this->_handler_id; 89 90 // Create the schema instance 91 $this->_schemadb = midcom_helper_datamanager2_schema::load_database($schemadb); 92 93 switch ($this->_handler_id) 94 { 95 case 'edit': 96 $this->_controller =& midcom_helper_datamanager2_controller::create('simple'); 97 $this->_controller->schemadb =& $this->_schemadb; 98 $this->_controller->set_storage($this->_topic); 99 break; 100 101 case 'create': 102 $this->_schemadb->default->fields['name']['required'] = 0; 103 $this->_controller =& midcom_helper_datamanager2_controller::create('create'); 104 $this->_controller->schemadb =& $this->_schemadb; 105 $this->_controller->schemaname = 'default'; 106 $this->_controller->callback_object =& $this; 107 108 // Suggest to create the same type of a folder as the parent is 109 $this->_controller->defaults = array 110 ( 111 'component' => $this->_topic->get_parameter('midcom', 'component'), 112 ); 113 break; 114 115 default: 116 $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 'Unable to process the request, unknown handler id'); 117 // This will exit 118 } 119 120 if (! $this->_controller->initialize()) 121 { 122 $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Failed to initialize a DM2 controller instance for article {$this->_event->id}."); 123 // This will exit. 124 } 125 126 } 127 128 /** 129 * DM2 creation callback, binds to the current content topic. 130 */ 131 function & dm2_create_callback (&$controller) 132 { 133 $this->_new_topic = new midcom_db_topic(); 134 $this->_new_topic->up = $this->_topic->id; 135 136 if (! $this->_new_topic->create()) 137 { 138 debug_push_class(__CLASS__, __FUNCTION__); 139 debug_print_r('We operated on this object:', $this->_new_topic); 140 debug_pop(); 141 $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 142 'Failed to create a new article, cannot continue. Last Midgard error was: '. mgd_errstr()); 143 // This will exit. 144 } 145 146 return $this->_new_topic; 147 } 148 149 27 150 /** 28 151 * Handler for folder editing. Checks for the permissions and folder integrity. … … 36 159 $this->_topic->require_do('midcom.admin.folder:topic_management'); 37 160 38 if (array_key_exists('f_cancel', $_REQUEST)) 39 { 40 $_MIDCOM->relocate(''); 41 // This will exit. 42 } 43 44 if (array_key_exists('f_submit', $_REQUEST)) 45 { 46 if ($this->_process_edit_form()) 47 { 48 // Relocate to the renamed topic 49 $_MIDCOM->relocate($_MIDCOM->permalinks->create_permalink($this->_topic->guid)); 50 // This will exit. 51 } 161 $this->_handler_id = str_replace('____ais-folder-', '', $handler_id); 162 163 // Load the DM2 controller 164 $this->_load_controller(); 165 166 // Get the content topic prefix 167 $prefix = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_ANCHORPREFIX); 168 169 // Store the old name before editing 170 $old_name = $this->_topic->name; 171 172 switch ($this->_controller->process_form()) 173 { 174 case 'cancel': 175 $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.folder'), $this->_l10n->get('cancelled')); 176 $_MIDCOM->relocate($prefix); 177 break; 178 179 case 'save': 180 if ($this->_handler_id === 'edit') 181 { 182 $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.folder'), $this->_l10n->get('folder saved')); 183 184 // Get the relocation url 185 $url = preg_replace("/{$old_name}\/\$/", "{$this->_topic->name}/", $prefix); 186 } 187 else 188 { 189 $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.folder'), $this->_l10n->get('folder created')); 190 191 // Generate name if it is missing 192 if (!$this->_new_topic->name) 193 { 194 $this->_new_topic->name = midcom_generate_urlname_from_string($this->_new_topic->extra); 195 $this->_new_topic->update(); 196 } 197 198 // Get the relocation url 199 $url = "{$prefix}/{$this->_new_topic->name}/"; 200 } 201 202 $_MIDCOM->relocate($url); 203 // This will exit 52 204 } 53 205 … … 65 217 $this->_node_toolbar->hide_item('__ais/folder/edit.html'); 66 218 219 $data['topic'] =& $this->_topic; 220 $data['controller'] =& $this->_controller; 221 67 222 // Set page title 68 $this->_request_data['topic'] = $this->_topic; 69 $this->_request_data['title'] = sprintf($_MIDCOM->i18n->get_string('edit folder %s', 'midcom.admin.folder'), $this->_request_data['topic']->extra); 70 $_MIDCOM->set_pagetitle($this->_request_data['title']); 223 $data['title'] = sprintf($_MIDCOM->i18n->get_string('edit folder %s', 'midcom.admin.folder'), $data['topic']->extra); 224 $_MIDCOM->set_pagetitle($data['title']); 71 225 72 226 // Set the help object in the toolbar … … 75 229 // Ensure we get the correct styles 76 230 $_MIDCOM->style->prepend_component_styledir('midcom.admin.folder'); 231 232 // Serve the correct localization 233 $data['l10n'] =& $this->_l10n; 77 234 78 235 // Add style sheet … … 91 248 92 249 /** 93 * Processes the _Edit folder_ page form and updates the folder. 94 * 95 * @access private 96 * @return boolean Indicating success 97 */ 98 function _process_edit_form() 99 { 100 if (trim($_REQUEST['f_name']) == '') 101 { 102 $this->_processing_msg = 'Error: URL name was empty.'; 103 return false; 104 } 105 if (trim($_REQUEST['f_title']) == '') 106 { 107 $this->_processing_msg = 'Error: Title was empty.'; 108 return false; 109 } 110 if (mgd_get_topic_by_name($this->_topic->id, $_REQUEST['f_name'])) 111 { 112 $this->_processing_msg = 'Error: a Folder with this name already exists.'; 113 return false; 114 } 115 116 // store form data in topic object 117 $this->_topic->name = midcom_generate_urlname_from_string($_REQUEST['f_name']); 118 $this->_topic->extra = $_REQUEST['f_title']; 119 //$this->_topic->score = $_REQUEST['f_score']; 120 //$this->_topic->owner = $_REQUEST['f_owner']; 121 $this->_topic->set_parameter('midcom', 'style', $_REQUEST['f_style']); 122 123 // TODO: Move to metadata 124 $this->_topic->set_parameter('midcom.helper.nav', 'navorder', $_REQUEST['f_navorder']); 125 126 if ( array_key_exists('f_style_inherit', $_REQUEST) 127 && $_REQUEST['f_style_inherit'] == 'on') 128 { 129 $this->_topic->set_parameter('midcom', 'style_inherit', true); 250 * Create a new style for the topic 251 * 252 * @access private 253 * @param string $name Name of the style 254 * @return string Style path 255 */ 256 function _create_style($style_name) 257 { 258 debug_push_class(__CLASS__, __FUNCTION__); 259 260 if (isset($GLOBALS['midcom_style_inherited'])) 261 { 262 $up = $_MIDCOM->style->get_style_id_from_path($GLOBALS['midcom_style_inherited']); 263 debug_add("Style inherited from {$GLOBALS['midcom_style_inherited']}"); 130 264 } 131 265 else 132 266 { 133 $this->_topic->set_parameter('midcom', 'style_inherit', false); 134 } 135 136 if ( trim($_REQUEST['f_type']) !== $this->_topic->get_parameter('midcom', 'component') 137 && $_MIDCOM->auth->admin 138 && $_REQUEST['f_type'] !== '') 139 { 140 $this->_topic->set_parameter('midcom', 'component', $_REQUEST['f_type']); 141 } 142 143 144 if (! $this->_topic->update()) 145 { 146 $this->_processing_msg = 'Could not save Folder: ' . mgd_errstr(); 147 return false; 148 } 149 150 $_MIDCOM->cache->invalidate($this->_topic->guid()); 151 152 return true; 267 $up = $_MIDGARD['style']; 268 debug_add("No inherited style found, placing the new style under host style (ID: {$_MIDGARD['style']}"); 269 } 270 271 $style = new midcom_db_style(); 272 $style->name = $style_name; 273 $style->up = $up; 274 275 if (!$style->create()) 276 { 277 debug_print_r('Failed to create a new style due to ' . mgd_errstr(), $style, MIDCOM_LOG_WARN); 278 debug_pop(); 279 280 $_MIDCOM->uimessages->add('edit folder', sprintf($_MIDCOM->i18n->get_string('failed to create a new style template: %s', 'midcom.admin.folder'), mgd_errstr()), 'error'); 281 return ''; 282 } 283 284 debug_print_r('New style created', $style); 285 debug_pop(); 286 287 return $_MIDCOM->style->get_style_path_from_id($style->id); 153 288 } 154 289 … … 160 295 function _show_edit($handler_id, &$data) 161 296 { 162 // Get parent component and navorder163 $this->_request_data['parent_topic'] = $this->_topic->get_parameter('midcom', 'component');164 165 $this->_request_data['view'] =& $this->_topic;166 $this->_request_data['style_inherit'] = $this->_topic->get_parameter('midcom', 'style_inherit');167 $this->_request_data['style'] = $this->_topic->get_parameter('midcom', 'style');168 $this->_request_data['folder'] =& $this->_topic;169 170 // TODO: Move to metadata171 $this->_request_data['navorder'] = $this->_topic->parameter('midcom.helper.nav', 'navorder');172 173 $this->_request_data['navorder_list'] = array174 (175 MIDCOM_NAVORDER_DEFAULT => $_MIDCOM->i18n->get_string('default sort order', 'midcom.admin.folder'),176 MIDCOM_NAVORDER_TOPICSFIRST => $_MIDCOM->i18n->get_string('folders first', 'midcom.admin.folder'),177 MIDCOM_NAVORDER_ARTICLESFIRST => $_MIDCOM->i18n->get_string('pages first', 'midcom.admin.folder'),178 MIDCOM_NAVORDER_SCORE => $_MIDCOM->i18n->get_string('by score', 'midcom.admin.folder'),179 );180 181 $style_default = array182 (183 '' => $_MIDCOM->i18n->get_string('default', 'midcom.admin.folder'),184 );185 186 297 $styles_all = midcom_admin_folder_folder_management::list_styles(); 187 298 188 $this->_request_data['styles'] = array_merge($style_default, $styles_all);189 190 // Place $view as a super global for the style checker function191 // midcom_admin_content_list_styles_selector2192 $GLOBALS['view'] =& $this->_topic;193 194 299 // Show the style element 195 midcom_show_style('midcom-admin-show-edit-folder'); 300 if ($this->_handler_id === 'create') 301 { 302 $data['page_title'] = sprintf($this->_i18n->get_string("create folder", 'midcom.admin.folder')); 303 } 304 else 305 { 306 $data['page_title'] = sprintf($this->_i18n->get_string("{$this->_handler_id} folder %s", 'midcom.admin.folder'), $this->_topic->extra); 307 } 308 309 midcom_show_style('midcom-admin-show-folder-actions'); 196 310 } 197 311 }
