Ticket #351: 080511_pages_optional_uri.diff
| File 080511_pages_optional_uri.diff, 3.0 kB (added by rho, 5 months ago) |
|---|
-
a/mod/pages/lib/pages.inc.php
old new 51 51 $messages[] = __gettext('Menu title not available, please choose another.'); 52 52 } else { 53 53 // update current record uri 54 $page->uri = pages_build_uri($page->name); 54 if (empty($page->uri)) { 55 $page->uri = pages_build_uri($page->name); 56 } 55 57 56 58 if (empty($page->uri)) { 57 59 $messages[] = __gettext('Menu title not available, please choose another.'); … … 63 65 } 64 66 } else { 65 67 // new uri 66 $page->uri = pages_build_uri($page->name); 68 if (empty($page->uri)) { 69 $page->uri = pages_build_uri($page->name); 70 } 67 71 68 72 if (empty($page->uri)) { 69 73 $messages[] = __gettext('Menu title not available, please choose another.'); … … 167 171 $name = trim(optional_param('page-name')); 168 172 $parent = optional_param('menu-parent', 0, PARAM_INT); 169 173 $weight = optional_param('menu-weight', 0, PARAM_INT); 174 $uri = str_replace(' ', '', trim(optional_param('page-uri'))); 170 175 $access = optional_param('page-access'); 171 176 172 177 // try to get from uri query … … 221 226 $page->parent = !isset($page->parent) ? $parent : $page->parent; 222 227 $page->weight = !isset($page->weight) ? $weight : $page->weight; 223 228 $page->access = !isset($page->access) ? $CFG->default_access : $page->access; 229 230 if (!empty($uri)) { 231 $page->uri = $uri; 232 } 224 233 225 234 //workaround 226 235 if ($owner == -1 && pages_is_frontpage($page->name)) { … … 528 537 $input_access .= run('display:access_level_select', array('page-access', $page->access)); 529 538 } 530 539 540 $input_uri = pages_html_wrap('label', __gettext('URI:'), array('for' => 'page-uri')); 541 $input_uri .= pages_html_input('text', array('name' => 'page-uri', 'value' => $page->uri)); 542 $input_uri .= pages_html_wrap('span', __gettext('Optional')); 543 531 544 // help 532 545 $form_help = __gettext('You can use {{page}} keyword to link to others pages.'); 533 546 $form_help .= '<br />» '; … … 582 595 $content .= pages_html_wrap('div', $input_menu . $input_default, array('class' => 'form-item')); 583 596 $content .= pages_html_wrap('div', $input_parent . $input_weight, array('class' => 'form-item')); 584 597 $content .= pages_html_wrap('div', $input_access, array('class' => 'form-item')); 598 $content .= pages_html_wrap('div', $input_uri, array('class' => 'form-item')); 585 599 $content .= pages_html_wrap('div', $input_buttons, array('class' => 'form-item form-button')); 586 600 587 601 $content = pages_html_wrap('form', $content, array(
