Skip to content

Commit

Permalink
Accion ver fichero con Wysiwyg
Browse files Browse the repository at this point in the history
  • Loading branch information
demonio committed Jan 1, 2012
1 parent beb86f0 commit 96419d8
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 16 deletions.
10 changes: 9 additions & 1 deletion app/controllers/admin/cms_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ class CmsController extends AppController

public function index()
{
$this->ficheros = Load::model( 'ficheros' )->ver();
$this->ficheros = Load::model( 'ficheros' )->leerDirectorio();
$this->raiz = APP_PATH . 'views/pages/';
}

public function ver()
{
$this->fichero = Load::model( 'ficheros' )->leerFichero( $_GET );
$this->ruta = $_GET['f'];
$this->version = 2;
}

/*public function codigo( $vista )
Expand Down
16 changes: 9 additions & 7 deletions app/extensions/helpers/tree.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<?php

function _tree( $a )
function _tree( $ficheros, $raiz )
{
#_::stop($a);
if ( empty( $a ) ) return;
#_::stop($ficheros);
if ( empty( $ficheros ) ) return;

$s = '';
foreach ( $a as $k => $v )
$directorio = '';
foreach ( $ficheros as $k => $v )
{
if ( is_array( $v ) or ! $v )
{
$s .= "<li>" . basename( $k ) . "/</li>";
$s .= _tree( $v );

$s .= _tree( $v, $raiz );
$directorio .= str_replace( $raiz, '', $k );
}
else
{
$s .= "<li>$v</li>";

$s .= "<li><a href=\"admin/cms/ver?f=$directorio/$v\">$v</a></li>";
}
}
return "<ul id=\"$k\">$s</ul>";
Expand Down
8 changes: 7 additions & 1 deletion app/models/ficheros.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

class Ficheros
{
public function ver( $get )
public function leerDirectorio()
{
// CONTENIDO DEL DIRECTORIO
return _fs::readDirs( APP_PATH . "views/pages/" );
}

public function leerFichero( $get )
{
// CONTENIDO DEL FICHERO
return _fs::readFile( APP_PATH . "views/pages/{$get['f']}" );
}


/*public function ver( $get )
{
Expand Down
2 changes: 1 addition & 1 deletion app/views/_shared/partials/admin/paginas.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

View::helpers( 'tree' );

echo _tree( $ficheros );
echo _tree( $ficheros, $raiz );


/*if ( $a['directorio'] and $a['directorio'] <> '/' ) echo "<li class=\"directory up\"><a href=\"?d={$a['padre']}\">..</a></li>";
Expand Down
8 changes: 2 additions & 6 deletions app/views/_shared/templates/admin/cms.phtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html lang="es">
<head>
<base href="/RaudoCMS/" />
<meta charset="<?php echo APP_CHARSET ?>" />
<title>RaudoCMS</title>
<?php Tag::css( 'cms' ) ?>
Expand All @@ -13,14 +14,9 @@
<h1>RaudoCMS | Administración</h1>
<hr />
</header>
<aside>
<h3>Páginas:</h3>
<?php View::partial( 'admin/paginas', false, get_object_vars( $controller ) ); ?>
<hr />
</aside>
<section>
<h3>Página:</h3>
<div id="pagina"></div>
<div id="pagina"><?php View::content(); ?></div>
<hr />
</section>
<footer>
Expand Down
5 changes: 5 additions & 0 deletions app/views/admin/cms/index.phtml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@

<aside>
<h3>Páginas:</h3>
<?php View::partial( 'admin/paginas', false, get_object_vars( $controller ) ); ?>
<hr />
</aside>
41 changes: 41 additions & 0 deletions app/views/admin/cms/ver.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

<form action="/admin/pagina" method="post">
<p>
<label>RUTA:</label>
<input name="pagina" value="<?php echo $ruta; ?>" type="text">
</p>
<p>
<label>VERSIÓN:</label>
<?php echo ++$version; ?>
</p>
<p>
<textarea class="wymeditor" name="codigo"><?php echo $fichero; ?></textarea>
</p>
<p>
<button class="wymupdate type="submit">Salvar</button>
<button class="ace" type="button">Ace</button>
<button class="codemirror" type="button">Codemirror</button>
</p>
</form>

<script>
$( '.wymeditor' ).wymeditor(
{
stylesheet: 'web.css',
skin: 'twopanels'
});
// BOTON ACE
$( 'button.ace' ).on( 'click', function()
{
var dir = $( 'input[name="dir"]' ).val();
var pagina = $( 'input[name="pagina"]' ).val();
location = '/admin/cms/codigo/ace?dir='+dir+'/'+pagina;
});
// BOTON CODEMIRROR
$( 'button.codemirror' ).on( 'click', function()
{
var dir = $( 'input[name="dir"]' ).val();
var pagina = $( 'input[name="pagina"]' ).val();
location = '/admin/cms/codigo/codemirror?dir='+dir+'/'+pagina;
});
</script>

0 comments on commit 96419d8

Please sign in to comment.