Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/vlad-ghita/url_router into …
Browse files Browse the repository at this point in the history
…vlad-ghita-master
  • Loading branch information
nils-werner committed Aug 22, 2012
2 parents 029a943 + 2f34097 commit 948665a
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 133 deletions.
File renamed without changes.
261 changes: 128 additions & 133 deletions content/content.routes.php
Expand Up @@ -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'));
Expand All @@ -27,173 +27,168 @@ public function __viewIndex() {

$fieldset->appendChild(new XMLElement('p', __('Choose between a <strong>Route</strong>, which silently shows the content under the original URL, or a <strong>Redirect</strong> 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: <code>page-name/$user/projects/$project</code>'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;')));
$labelfrom->appendChild(new XMLElement('p', __('Regular expression: <code>/\\/page-name\\/(.+\\/)/</code> Wrap in <code>/</code> and ensure to escape metacharacters with <code>\\</code>'), 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: <code>/new-page-name/$user/$project</code>'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;')));
$labelto->appendChild(new XMLElement('p', __('Regular expression: <code>/new-page-name/$1/</code>'), 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: <code>page-name/$user/projects/$project</code>'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;')));
$labelfrom->appendChild(new XMLElement('p', __('Regular expression: <code>/\\/page-name\\/(.+\\/)/</code> Wrap in <code>/</code> and ensure to escape metacharacters with <code>\\</code>'), 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: <code>/new-page-name/$user/$project</code>'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;')));
$labelto->appendChild(new XMLElement('p', __('Regular expression: <code>/new-page-name/$1/</code>'), 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: <code>page-name/:user/projects/:project</code>'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;')));
$labelfrom->appendChild(new XMLElement('p', __('Regular expression: <code>/\\/page-name\\/(.+\\/)/</code> Wrap in <code>/</code> and ensure to escape metacharacters with <code>\\</code>'), 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: <code>/new-page-name/:user/:project</code>'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;')));
$labelto->appendChild(new XMLElement('p', __('Regular expression: <code>/new-page-name/$1/</code>'), 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: <code>page-name/:user/projects/:project</code>'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;')));
$labelfrom->appendChild(new XMLElement('p', __('Regular expression: <code>/\\/page-name\\/(.+\\/)/</code> Wrap in <code>/</code> and ensure to escape metacharacters with <code>\\</code>'), 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: <code>/new-page-name/:user/:project</code>'), array('class' => 'help', 'style' => 'margin: 0.5em 0 -0.5em;')));
$labelto->appendChild(new XMLElement('p', __('Regular expression: <code>/new-page-name/$1/</code>'), 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);

Expand Down

0 comments on commit 948665a

Please sign in to comment.