Fixed bad url in theme page

This commit is contained in:
Li Chen 2013-12-01 20:03:20 +01:00
parent 31eabf84b4
commit 5656d116af
3 changed files with 22 additions and 7 deletions

View File

@ -5,9 +5,16 @@ if(!defined('ONYX')) exit;
$p = $out[0]; $p = $out[0];
if (isset($p[2])) if (isset($p[2]))
$template->assign("theme", $p[2]); {
$tmp = explode("-", $p[2]);
$id = intval($tmp[0]);
if ($id == 0)
return "404";
$theme = new Theme($id);
$template->assign("theme", $theme);
}
if (isset($p[3])) if (isset($p[3]))
$template->assign("ex", $p[3]); $template->assign("ex", new Exercice($p[3], $theme));
return "admin/exercice"; return SALT_ADMIN."/exercice";

View File

@ -1,7 +1,15 @@
{extends file="admin/layout.tpl"} {extends file="admin/layout.tpl"}
{block name=content} {block name=content}
<p> <p>
Theme: {$theme} </br> Theme: {$theme->name} </br>
Exercice: {$ex} {if isset($ex)}
Exercice: {$ex->id}
{else}
<ul>
{foreach $theme->get_exercices_ordered() as $ex}
<li><a href="/{$SALT_ADMIN}/ex/{$theme->id}-{$theme->name}/{$ex->id}">{$ex->get_name()}</a></li>
{/foreach}
</ul>
{/if}
</p> </p>
{/block} {/block}

View File

@ -19,10 +19,10 @@
<a href="?delete={$t->id}"><span class="glyphicon glyphicon-trash"></span></a> <a href="?delete={$t->id}"><span class="glyphicon glyphicon-trash"></span></a>
<a href="/{$SALT_ADMIN}/themes/export?id={$t->id}" role="button"><span class="glyphicon glyphicon-floppy-save"></span> Exporter</a> <a href="/{$SALT_ADMIN}/themes/export?id={$t->id}" role="button"><span class="glyphicon glyphicon-floppy-save"></span> Exporter</a>
</td> </td>
<td><a href="/{$SALT_ADMIN}/{$t->id}-{$t->name}">{$t->name}</a></td> <td><a href="/{$SALT_ADMIN}/ex/{$t->id}-{$t->name}">{$t->name}</a></td>
<td><ul> <td><ul>
{foreach from=$t->get_exercices_ordered() item=e} {foreach from=$t->get_exercices_ordered() item=e}
<li><a href="/{$SALT_ADMIN}/{$t->id}-{$t->name}/{$e->id}">{$e->get_name()}</a></li> <li><a href="/{$SALT_ADMIN}/ex/{$t->id}-{$t->name}/{$e->id}">{$e->get_name()}</a></li>
{/foreach} {/foreach}
</ul></td> </ul></td>
<td>FIXME</td> <td>FIXME</td>