Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

creado los campos dir y pagina para darle magia al boton save

  • Loading branch information...
commit 898f8bd332675ebb826e44994bd6e91a7a64201e 1 parent fbe8d44
@demonio authored
View
32 app/controllers/admin/pagina_controller.php
@@ -10,19 +10,19 @@ class PaginaController extends AppController
{
public function index()
{
- if ( ! empty( $_POST['accion'] ) )
+ if ( ! empty( $_POST['dir'] ) and ! empty( $_POST['pagina'] ) )
{
- $accion = ( $_POST['accion'] == 'borrar' ) ? 'borrar' : 'editar';
- $this->$accion( $_POST );
- return Router::redirect( '/admin/cms/index?dir=' . $_POST['pagina'] );
+ $this->editar( $_POST );
+ return Router::redirect( "/admin/cms/index?dir={$_POST['dir']}/{$_POST['pagina']}" );
}
+ return Router::redirect( '/admin/cms' );
}
public function editar( $post )
{
- if ( strstr( $post['pagina'], APP_PATH . 'views/pages' ) )
+ if ( strstr( $post['dir'], APP_PATH . 'views/pages' ) )
{
- if ( _fs::updateFile( $post['pagina'], $post['codigo'] ) )
+ if ( _fs::updateFile( "{$post['dir']}/{$post['pagina']}", $post['codigo'] ) )
{
$_SESSION['flash'] = Flash::valid( 'Página actualizada' );
}
@@ -30,21 +30,21 @@ public function editar( $post )
{
$_SESSION['flash'] = Flash::error( 'Error editando' );
}
- return Router::redirect( '/admin/cms/index?dir=' . $post['pagina'] );
+ return Router::redirect( "/admin/cms/index?dir={$post['dir']}/{$post['pagina']}" );
}
return Router::redirect( '/admin/cms' );
}
public function borrar( $post )
{
- if ( _fs::deleteFile( $post['pagina'] ) )
- {
- $_SESSION['flash'] = Flash::valid( 'Página borrada' );
- }
- else
- {
- $_SESSION['flash'] = Flash::error( 'Error borrando' );
- }
- return Router::redirect( '/admin/cms/index?dir=' . basename( $post['pagina'] ) );
+ /*if ( _fs::deleteFile( $post['pagina'] ) )
+ {
+ $_SESSION['flash'] = Flash::valid( 'Página borrada' );
+ }
+ else
+ {
+ $_SESSION['flash'] = Flash::error( 'Error borrando' );
+ }
+ return Router::redirect( '/admin/cms/index?dir=' . basename( $post['pagina'] ) );*/
}
}
View
28 app/views/admin/cms/pagina.phtml
@@ -1,20 +1,28 @@
<form action="/admin/pagina" method="post">
- <textarea class="wymeditor" name="codigo"><?php echo $codigo; ?></textarea>
- <select name="accion">
- <option value="editar">Editar</option>
- <option value="borrar">Borrar</option>
- </select>
- <input name="pagina" value="<?php echo $pagina; ?>" type="hidden">
- <button class="wymupdate type="submit">Enviar</button>
- <button class="codigo" type="button">Codigo</button>
+ <p>
+ <label>DIR:</label>
+ <input name="dir" value="<?php echo dirname( $pagina ); ?>" size="69" type="text">
+ </p>
+ <p>
+ <label>PÁGINA:</label>
+ <input name="pagina" value="<?php echo basename( $pagina ); ?>" size="15" type="text">
+ </p>
+ <p>
+ <textarea class="wymeditor" name="codigo"><?php echo $codigo; ?></textarea>
+ </p>
+ <p>
+ <button class="wymupdate type="submit">Salvar</button>
+ <button class="codigo" type="button">Codigo</button>
+ </p>
</form>
<script type="text/javascript">
$( 'button.codigo' ).on( 'click', function()
{
- var dir = $( 'input[name="pagina"]' ).val();
- location = '/admin/cms/codigo?dir='+dir;
+ var dir = $( 'input[name="dir"]' ).val();
+ var pagina = $( 'input[name="pagina"]' ).val();
+ location = '/admin/cms/codigo?dir='+dir+'/'+pagina;
});
$( '.wymeditor' ).wymeditor();
</script>
View
4 app/views/pages/index.phtml
@@ -1,2 +1,2 @@
-<h1>RaudoCMS</h1>
-<h2>Fácil y rápido CMS en K u m b i a P H P</h2>
+<h1>Raudo C M S</h1>
+<h2>Fácil y rápido C M S en K u m b i a P H P</h2>
Please sign in to comment.
Something went wrong with that request. Please try again.