diff --git a/assets/urlrouter.preferences.js b/assets/url_router.preferences.js similarity index 100% rename from assets/urlrouter.preferences.js rename to assets/url_router.preferences.js diff --git a/content/content.routes.php b/content/content.routes.php index ad91454..76a48d7 100644 --- a/content/content.routes.php +++ b/content/content.routes.php @@ -16,7 +16,7 @@ public function __actionIndex() { public function __viewIndex() { $this->setPageType('form'); - $this->addScriptToHead(URL . '/extensions/url_router/assets/urlrouter.preferences.js', 400, false); + $this->addScriptToHead(URL . '/extensions/url_router/assets/url_router.preferences.js', 400, false); $this->setTitle(__('%1$s – %2$s', array(__('Symphony'), __('URL Router')))); $this->appendSubheading(__('URL Router')); @@ -27,173 +27,168 @@ public function __viewIndex() { $fieldset->appendChild(new XMLElement('p', __('Choose between a Route, which silently shows the content under the original URL, or a Redirect which will actually redirect the user to the new URL.'), array('class' => 'help'))); - $group = new XMLElement('div'); - $group->setAttribute('class', 'frame'); + $group = new XMLElement('div'); + $group->setAttribute('class', 'frame'); - $ol = new XMLElement('ol'); - $ol->setAttribute('data-name', __('Add route')); - $ol->setAttribute('data-type', __('Remove route')); + $ol = new XMLElement('ol'); + $ol->setAttribute('data-name', __('Add route')); + $ol->setAttribute('data-type', __('Remove route')); // Redirect Template - $li_re = new XMLElement('li'); - $li_re->setAttribute('class', 'template'); - $li_re->setAttribute('data-name', 'Redirect'); - $li_re->setAttribute('data-type', 'redirect'); - $header_re = new XMLElement('header', __('Redirect')); - $hidden_re = Widget::Input("settings[url-router][routes][][type]", 'redirect', 'hidden'); - $li_re->appendChild($header_re); - $li_re->appendChild($hidden_re); + $li_re = new XMLElement('li'); + $li_re->setAttribute('class', 'template'); + $li_re->setAttribute('data-name', 'Redirect'); + $li_re->setAttribute('data-type', 'redirect'); + $header_re = new XMLElement('header', __('Redirect')); + $hidden_re = Widget::Input("settings[url-router][routes][][type]", 'redirect', 'hidden'); + $li_re->appendChild($header_re); + $li_re->appendChild($hidden_re); // Route Template - $li_ro = new XMLElement('li'); - $li_ro->setAttribute('class', 'template'); - $li_ro->setAttribute('data-name', 'Route'); - $li_ro->setAttribute('data-type', 'route'); - $header_ro = new XMLElement('header', __('Route')); - $hidden_ro = Widget::Input("settings[url-router][routes][][type]", 'route', 'hidden'); - $li_ro->appendChild($header_ro); - $li_ro->appendChild($hidden_ro); + $li_ro = new XMLElement('li'); + $li_ro->setAttribute('class', 'template'); + $li_ro->setAttribute('data-name', 'Route'); + $li_ro->setAttribute('data-type', 'route'); + $header_ro = new XMLElement('header', __('Route')); + $hidden_ro = Widget::Input("settings[url-router][routes][][type]", 'route', 'hidden'); + $li_ro->appendChild($header_ro); + $li_ro->appendChild($hidden_ro); // From To boxes - $divgroup = new XMLElement('div'); - $divgroup->setAttribute('class', 'group'); - - $labelfrom = Widget::Label(__('From')); - $labelfrom->appendChild(Widget::Input("settings[url-router][routes][][from]")); - $labelfrom->appendChild(new XMLElement('p', __('Simplified: page-name/$user/projects/$project'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); - $labelfrom->appendChild(new XMLElement('p', __('Regular expression: /\\/page-name\\/(.+\\/)/ Wrap in / and ensure to escape metacharacters with \\'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); - - $labelto = Widget::Label(__('To')); - $labelto->appendChild(Widget::Input("settings[url-router][routes][][to]")); - $labelto->appendChild(new XMLElement('p', __('Simplified: /new-page-name/$user/$project'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); - $labelto->appendChild(new XMLElement('p', __('Regular expression: /new-page-name/$1/'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); + $divgroup = new XMLElement('div'); + $divgroup->setAttribute('class', 'group'); + + $labelfrom = Widget::Label(__('From')); + $labelfrom->appendChild(Widget::Input("settings[url-router][routes][][from]")); + $labelfrom->appendChild(new XMLElement('p', __('Simplified: page-name/$user/projects/$project'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); + $labelfrom->appendChild(new XMLElement('p', __('Regular expression: /\\/page-name\\/(.+\\/)/ Wrap in / and ensure to escape metacharacters with \\'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); + + $labelto = Widget::Label(__('To')); + $labelto->appendChild(Widget::Input("settings[url-router][routes][][to]")); + $labelto->appendChild(new XMLElement('p', __('Simplified: /new-page-name/$user/$project'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); + $labelto->appendChild(new XMLElement('p', __('Regular expression: /new-page-name/$1/'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); + + + $divgroup->appendChild($labelfrom); + $divgroup->appendChild($labelto); + + $divcontent = new XMLElement('div'); + $divcontent->setAttribute('class', 'content'); + $divcontent->appendChild($divgroup); + + $recontent = clone $divcontent; + + $regroup = new XMLElement('div'); + $regroup->setAttribute('class', 'group'); + $label = Widget::Label(); + $input = Widget::Input('settings[url-router][routes][][http301]', 'yes', 'checkbox'); + $label->setValue($input->generate() . ' ' . __('Send an HTTP 301 Redirect')); + $regroup->appendChild($label); + $recontent->appendChild($regroup); + + $divgroup = new XMLElement('div'); + $divgroup->setAttribute('class', 'group'); + $label = Widget::Label(); + $input = Widget::Input('settings[url-router][routes][][http301]', 'yes', 'checkbox'); + $label->setValue($input->generate() . ' ' . __('Force re-route even if page exists')); + $divgroup->appendChild($label); + $divcontent->appendChild($divgroup); + + $li_re->appendChild($recontent); + $li_ro->appendChild($divcontent); + + $ol->appendChild($li_ro); + $ol->appendChild($li_re); + + if($routes = $this->_driver->getRoutes()) + { + if(is_array($routes)) + { + foreach($routes as $route) + { + $from = isset($route['from-clean']) ? $route['from-clean'] : $route['from']; + $to = isset($route['to-clean']) ? $route['to-clean'] : $route['to']; + $header = new XMLElement('header'); + $header->appendChild(new XMLElement('h4', $route['type'] == 'redirect' ? __('Redirect') : __('Route') )); + $header->appendChild(new XMLElement('span', __('From'), array('class' => 'type'))); + $header->appendChild(new XMLElement('span', $from, array('class' => 'type'))); + $header->appendChild(new XMLElement('span', __('To'), array('class' => 'type'))); + $header->appendChild(new XMLElement('span', $to, array('class' => 'type'))); - $divgroup->appendChild($labelfrom); - $divgroup->appendChild($labelto); + $hidden = Widget::Input("settings[url-router][routes][][type]", $route['type'], 'hidden'); - $divcontent = new XMLElement('div'); - $divcontent->setAttribute('class', 'content'); - $divcontent->appendChild($divgroup); + $li = new XMLElement('li'); + $li->setAttribute('class', 'instance expanded'); + $li->appendChild($header); + $li->appendChild($hidden); - $recontent = clone $divcontent; + $divcontent = new XMLElement('div'); + $divcontent->setAttribute('class', 'content'); - $regroup = new XMLElement('div'); - $regroup->setAttribute('class', 'group'); - $label = Widget::Label(); - $input = Widget::Input('settings[url-router][routes][][http301]', 'yes', 'checkbox'); - $label->setValue($input->generate() . ' ' . __('Send an HTTP 301 Redirect')); - $regroup->appendChild($label); - $recontent->appendChild($regroup); + $divgroup = new XMLElement('div'); + $divgroup->setAttribute('class', 'group'); - $divgroup = new XMLElement('div'); - $divgroup->setAttribute('class', 'group'); - $label = Widget::Label(); - $input = Widget::Input('settings[url-router][routes][][http301]', 'yes', 'checkbox'); - $label->setValue($input->generate() . ' ' . __('Force re-route even if page exists')); - $divgroup->appendChild($label); - $divcontent->appendChild($divgroup); + $labelfrom = Widget::Label(__('From')); + $labelfrom->appendChild(Widget::Input("settings[url-router][routes][][from]", General::sanitize($from))); + $labelfrom->appendChild(new XMLElement('p', __('Simplified: page-name/:user/projects/:project'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); + $labelfrom->appendChild(new XMLElement('p', __('Regular expression: /\\/page-name\\/(.+\\/)/ Wrap in / and ensure to escape metacharacters with \\'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); - $li_re->appendChild($recontent); - $li_ro->appendChild($divcontent); + $labelto = Widget::Label(__('To')); + $labelto->appendChild(Widget::Input("settings[url-router][routes][][to]", General::sanitize($to))); + $labelto->appendChild(new XMLElement('p', __('Simplified: /new-page-name/:user/:project'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); + $labelto->appendChild(new XMLElement('p', __('Regular expression: /new-page-name/$1/'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); - $ol->appendChild($li_ro); - $ol->appendChild($li_re); + $divgroup->appendChild($labelfrom); + $divgroup->appendChild($labelto); - if($routes = $this->_driver->getRoutes()) - { - if(is_array($routes)) - { - foreach($routes as $route) + $divcontent->appendChild($divgroup); + if($route['type'] == 'redirect') { - if($route['type'] == 'redirect') - { - $header = new XMLElement('header', __('Redirect')); - } - else + $regroup = new XMLElement('div'); + $regroup->setAttribute('class', 'group'); + + $label = Widget::Label(); + $input = Widget::Input('settings[url-router][routes][][http301]', 'yes', 'checkbox'); + if($route['http301'] == 'yes') { - $header = new XMLElement('header', __('Route')); + $input->setAttribute('checked', 'checked'); } - - $hidden = Widget::Input("settings[url-router][routes][][type]", $route['type'], 'hidden'); - - $li = new XMLElement('li'); - $li->setAttribute('class', 'instance expanded'); - $li->appendChild($header); - $li->appendChild($hidden); - - $divcontent = new XMLElement('div'); - $divcontent->setAttribute('class', 'content'); - + $label->setValue($input->generate() . ' ' . __('Send an HTTP 301 Redirect')); + $regroup->appendChild($label); + $divcontent->appendChild($regroup); + } + else + { $divgroup = new XMLElement('div'); $divgroup->setAttribute('class', 'group'); - $from = $route['from']; - if (isset($route['from-clean'])) $from = $route['from-clean']; - - $labelfrom = Widget::Label(__('From')); - $labelfrom->appendChild(Widget::Input("settings[url-router][routes][][from]", General::sanitize($from))); - $labelfrom->appendChild(new XMLElement('p', __('Simplified: page-name/:user/projects/:project'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); - $labelfrom->appendChild(new XMLElement('p', __('Regular expression: /\\/page-name\\/(.+\\/)/ Wrap in / and ensure to escape metacharacters with \\'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); - - $to = $route['to']; - if (isset($route['to-clean'])) $to = $route['to-clean']; - - $labelto = Widget::Label(__('To')); - $labelto->appendChild(Widget::Input("settings[url-router][routes][][to]", General::sanitize($to))); - $labelto->appendChild(new XMLElement('p', __('Simplified: /new-page-name/:user/:project'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); - $labelto->appendChild(new XMLElement('p', __('Regular expression: /new-page-name/$1/'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;'))); - - $divgroup->appendChild($labelfrom); - $divgroup->appendChild($labelto); - - $divcontent->appendChild($divgroup); - if($route['type'] == 'redirect') + $label = Widget::Label(); + $input = Widget::Input('settings[url-router][routes][][http301]', 'yes', 'checkbox'); + if($route['http301'] == 'yes') { - $regroup = new XMLElement('div'); - $regroup->setAttribute('class', 'group'); - - $label = Widget::Label(); - $input = Widget::Input('settings[url-router][routes][][http301]', 'yes', 'checkbox'); - if($route['http301'] == 'yes') - { - $input->setAttribute('checked', 'checked'); - } - $label->setValue($input->generate() . ' ' . __('Send an HTTP 301 Redirect')); - $regroup->appendChild($label); - $divcontent->appendChild($regroup); + $input->setAttribute('checked', 'checked'); } - else - { - $divgroup = new XMLElement('div'); - $divgroup->setAttribute('class', 'group'); - - $label = Widget::Label(); - $input = Widget::Input('settings[url-router][routes][][http301]', 'yes', 'checkbox'); - if($route['http301'] == 'yes') - { - $input->setAttribute('checked', 'checked'); - } - $label->setValue($input->generate() . ' ' . __('Force re-route even if page exists')); - $divgroup->appendChild($label); - $divcontent->appendChild($divgroup); - } - $li->appendChild($divcontent); - $ol->appendChild($li); + $label->setValue($input->generate() . ' ' . __('Force re-route even if page exists')); + $divgroup->appendChild($label); + $divcontent->appendChild($divgroup); } + $li->appendChild($divcontent); + $ol->appendChild($li); } } + } - $group->appendChild($ol); + $group->appendChild($ol); - $fieldset->appendChild($group); + $fieldset->appendChild($group); $this->Form->appendChild($fieldset); $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); - $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', $attr)); + $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', array('accesskey' => 's'))); $this->Form->appendChild($div);