Changeset 11346
- Timestamp:
- 07/24/07 16:41:07 (1 year ago)
- Files:
-
- trunk/midcom/midcom.admin.styleeditor/config/config.inc (modified) (1 diff)
- trunk/midcom/midcom.admin.styleeditor/handler/file.php (modified) (7 diffs)
- trunk/midcom/midcom.admin.styleeditor/locale/default.en.txt (modified) (1 diff)
- trunk/midcom/midcom.admin.styleeditor/style/midcom-admin-styleeditor-files-delete.php (added)
- trunk/midcom/midcom.admin.styleeditor/style/midcom-admin-styleeditor-files-file.php (modified) (5 diffs)
- trunk/midcom/midcom.admin.styleeditor/style/midcom-admin-styleeditor-files-header.php (modified) (1 diff)
- trunk/midcom/midcom.admin.styleeditor/viewer.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/midcom.admin.styleeditor/config/config.inc
r5455 r11346 1 1 'text_types' => array 2 2 ( 3 'text/css' => 'cascading style sheet', 4 'text/javascript' => 'javascript', 5 'text/plain' => 'plain text', 6 'text/xml' => 'xml', 3 'text/css' => 'cascading style sheet', 4 'text/javascript' => 'javascript', 5 'application/x-javascript' => 'javascript', 6 'text/plain' => 'plain text', 7 'text/xml' => 'xml', 8 'text/html' => 'html', 7 9 ), trunk/midcom/midcom.admin.styleeditor/handler/file.php
r11341 r11346 138 138 MIDCOM_NAV_NAME => $_MIDCOM->i18n->get_string('style attachments', 'midcom.admin.styleeditor'), 139 139 ); 140 140 141 141 switch ($handler_id) 142 142 { 143 case '____mfa- styleeditor-file_edit':143 case '____mfa-asgard_midcom.admin.styleeditor-file_edit': 144 144 $tmp[] = Array 145 145 ( 146 146 MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.styleeditor/files/{$this->_request_data['filename']}/", 147 MIDCOM_NAV_NAME => sprintf($_MIDCOM->i18n->get_string('edit file %s', 'midcom.admin.styleeditor'), $this->_request_data['filename']), 147 MIDCOM_NAV_NAME => $this->_request_data['filename'], 148 ); 149 break; 150 case '____mfa-asgard_midcom.admin.styleeditor-file_delete': 151 $tmp[] = array 152 ( 153 MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.styleeditor/files/{$this->_request_data['filename']}/", 154 MIDCOM_NAV_NAME => sprintf($_MIDCOM->i18n->get_string('%s', 'midcom.admin.styleeditor'), $this->_request_data['filename']), 155 ); 156 $tmp[] = array 157 ( 158 MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.styleeditor/files/{$this->_request_data['filename']}/delete/", 159 MIDCOM_NAV_NAME => $_MIDCOM->i18n->get_string('delete', 'midcom'), 148 160 ); 149 161 break; … … 295 307 $qb = midcom_baseclasses_database_attachment::new_query_builder(); 296 308 $qb->add_constraint('parentguid', '=', $this->_style->guid); 309 297 310 $qb->add_constraint('name', '=', $filename); 311 298 312 $files = $qb->execute(); 299 313 if (empty($files)) … … 340 354 else 341 355 { 342 $_MIDCOM->relocate("__mfa/asgard_midcom.admin.styleeditor/files/{$filename} ");356 $_MIDCOM->relocate("__mfa/asgard_midcom.admin.styleeditor/files/{$filename}/"); 343 357 } 344 358 … … 405 419 * Handler method for listing style elements for the currently used component topic 406 420 * 407 * @access p rivate421 * @access public 408 422 * @param string $handler_id Name of the used handler 409 423 * @param mixed $args Array containing the variable arguments passed to the handler … … 439 453 if ($filename != $data['filename']) 440 454 { 441 $_MIDCOM->relocate("__mfa/asgard_midcom.admin.styleeditor/files/{$filename} ");455 $_MIDCOM->relocate("__mfa/asgard_midcom.admin.styleeditor/files/{$filename}/"); 442 456 } 443 457 } … … 452 466 // Skip the page styles 453 467 $_MIDCOM->skip_page_style = true; 468 469 // Add the codepress syntax highlight 470 $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL . '/midcom.helper.datamanager2/codepress/codepress.js'); 454 471 455 472 // Add the page title … … 502 519 midcom_show_style('midgard_admin_asgard_footer'); 503 520 } 521 522 /** 523 * Handler method for confirming file deleting for the requested file 524 * 525 * @access public 526 * @param string $handler_id Name of the used handler 527 * @param mixed $args Array containing the variable arguments passed to the handler 528 * @param mixed $data Data passed to the show method 529 * @return boolean Indicating successful request 530 */ 531 function _handler_delete($handler_id, $args, &$data) 532 { 533 $this->_load_config(); 534 $data['filename'] = $args[0]; 535 if (!$this->_load_style()) 536 { 537 return false; 538 } 539 $this->_topic->require_do('midcom.admin.styleeditor:template_management'); 540 $this->_style->require_do('midgard:attachments'); 541 542 $this->_file = $this->_get_file($data['filename']); 543 if (!$this->_file) 544 { 545 return false; 546 } 547 548 // Require delete privilege 549 $this->_file->require_do('midgard:delete'); 550 551 if (isset($_POST['f_cancel'])) 552 { 553 $_MIDCOM->uimessages->add($_MIDCOM->i18n->get_string('midcom.admin.styleeditor', 'midcom.admin.styleeditor'), $_MIDCOM->i18n->get_string('delete cancelled', 'midcom.admin.styleeditor')); 554 $_MIDCOM->relocate("__mfa/asgard_midcom.admin.styleeditor/files/{$data['filename']}/"); 555 // This will exit 556 } 557 558 if (isset($_POST['f_confirm'])) 559 { 560 if ($this->_file->delete()) 561 { 562 $_MIDCOM->uimessages->add($_MIDCOM->i18n->get_string('midcom.admin.styleeditor', 'midcom.admin.styleeditor'), sprintf($_MIDCOM->i18n->get_string('file %s deleted', 'midcom.admin.styleeditor'), $data['filename'])); 563 $_MIDCOM->relocate("__mfa/asgard_midcom.admin.styleeditor/files/"); 564 // This will exit 565 } 566 567 568 } 569 570 $_MIDCOM->bind_view_to_object($this->_file); 571 572 // Ensure we get the correct styles 573 $_MIDCOM->style->prepend_component_styledir('midgard.admin.asgard'); 574 $_MIDCOM->style->prepend_component_styledir('midcom.admin.styleeditor'); 575 576 $this->_update_breadcrumb($handler_id); 577 578 // Skip the page styles 579 $_MIDCOM->skip_page_style = true; 580 581 // Add the page title 582 $data['view_title'] = sprintf($_MIDCOM->i18n->get_string('delete file %s', 'midcom.admin.styleeditor'), "'{$args[0]}'"); 583 584 // Set the Asgard toolbar 585 $data['asgard_toolbar'] = new midcom_helper_toolbar(); 586 587 $data['asgard_toolbar']->add_item 588 ( 589 array 590 ( 591 MIDCOM_TOOLBAR_URL => "__mfa/asgard_midcom.admin.styleeditor/create/", 592 MIDCOM_TOOLBAR_LABEL => $_MIDCOM->i18n->get_string('create a new element', 'midcom.admin.styleeditor'), 593 MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/text-x-generic-template.png', 594 ) 595 ); 596 $data['asgard_toolbar']->add_item 597 ( 598 array 599 ( 600 MIDCOM_TOOLBAR_URL => "__mfa/asgard_midcom.admin.styleeditor/files/", 601 MIDCOM_TOOLBAR_LABEL => $_MIDCOM->i18n->get_string('style attachments', 'midcom.admin.styleeditor'), 602 MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/attach.png', 603 ) 604 ); 605 606 return true; 607 } 608 609 /** 610 * Show the delete request 611 * 612 * @access private 613 * @param string $handler_id Name of the used handler 614 * @param mixed $data Data passed to the show method 615 */ 616 function _show_delete($handler_id, &$data) 617 { 618 midcom_show_style('midgard_admin_asgard_header'); 619 midcom_show_style('midgard_admin_asgard_middle'); 620 621 $data['file'] =& $this->_file; 622 $data['text_types'] = $this->_config->get('text_types'); 623 midcom_show_style('midcom-admin-styleeditor-files-delete'); 624 midcom_show_style('midgard_admin_asgard_footer'); 625 } 626 504 627 } 505 628 ?> trunk/midcom/midcom.admin.styleeditor/locale/default.en.txt
r11341 r11346 127 127 Style element %s created 128 128 ---STRINGEND 129 130 ---STRING delete file %s 131 Delete file '%s' 132 ---STRINGEND 133 134 ---STRING confirm delete of file %s 135 Confirm delete of file '%s' 136 ---STRINGEND 137 138 ---STRING delete cancelled 139 Delete cancelled 140 ---STRINGEND 141 142 ---STRING file %s deleted 143 File '%s' deleted 144 ---STRINGEND trunk/midcom/midcom.admin.styleeditor/style/midcom-admin-styleeditor-files-file.php
r11341 r11346 1 1 <h1><?php echo sprintf($_MIDCOM->i18n->get_string('edit file %s', 'midcom.admin.styleeditor'), $data['filename']); ?></h1> 2 2 3 <form method="post" enctype="multipart/form-data" >3 <form method="post" enctype="multipart/form-data" action="&(_MIDGARD['uri']:h);" onsubmit="midcom_admin_styleeditor_file_edit.toggleEditor();"> 4 4 <fieldset> 5 5 <legend><?php echo $_MIDCOM->i18n->get_string('upload file', 'midcom.admin.styleeditor'); ?></legend> … … 10 10 if (array_key_exists($data['file']->mimetype, $data['text_types'])) 11 11 { 12 switch(preg_replace('/.+?\//', '', $data['file']->mimetype)) 13 { 14 case 'css': 15 $codepress_type = 'css'; 16 break; 17 18 case 'html': 19 $codepress_type = 'html'; 20 break; 21 22 case 'x-javascript': 23 case 'javascript': 24 $codepress_type = 'javascript'; 25 break; 26 27 default: 28 $codepress_type = 'text'; 29 } 30 12 31 // Show file for editing only if it is a text file 13 32 ?> … … 23 42 <label> 24 43 <span><?php echo $_MIDCOM->i18n->get_string('file contents', 'midcom.admin.styleeditor'); ?></span> 25 <textarea name="midcom_admin_styleeditor_contents" cols="60" rows="30" wrap="none" ><?php44 <textarea name="midcom_admin_styleeditor_contents" cols="60" rows="30" wrap="none" id="midcom_admin_styleeditor_file_edit" class="&(codepress_type); codepress"><?php 26 45 $f = $data['file']->open('r'); 27 46 if ($f) … … 41 60 </form> 42 61 43 <form class="urlform" >62 <form class="urlform" method="post" action="&(_MIDGARD['uri']:h);delete/"> 44 63 <?php 45 64 $file_url = $_MIDCOM->get_host_prefix() . "midcom-serveattachmentguid-{$data['file']->guid}/{$data['file']->name}"; … … 59 78 <input class="text" type="text" value="&(file_url);" readonly="readonly" /> 60 79 </label> 80 <br /> 81 <input type="submit" class="delete" name="f_delete" value="<?php echo $_MIDCOM->i18n->get_string('delete', 'midcom'); ?>" /> 61 82 </fieldset> 62 83 </form> trunk/midcom/midcom.admin.styleeditor/style/midcom-admin-styleeditor-files-header.php
r5458 r11346 19 19 } 20 20 21 echo "<li{$class}><a href=\"{$prefix}__mfa/ styleeditor/files/{$file->name}\"><img src=\"{$mime_icon}\" /> {$file->name}</a></li>\n";21 echo "<li{$class}><a href=\"{$prefix}__mfa/asgard_midcom.admin.styleeditor/files/{$file->name}/\"><img src=\"{$mime_icon}\" /> {$file->name}</a></li>\n"; 22 22 } 23 23 echo "</ul>\n"; trunk/midcom/midcom.admin.styleeditor/viewer.php
r11335 r11346 95 95 'variable_args' => 1, 96 96 ), 97 /** 98 * Delete a file 99 * 100 * Match /files/<filename>/delete/ 101 */ 102 'file_delete' => array 103 ( 104 'handler' => array ('midcom_admin_styleeditor_handler_file', 'delete'), 105 'fixed_args' => array('files'), 106 'variable_args' => 2, 107 ), 97 108 ); 98 109 }
