Skip to content

Commit

Permalink
Arbol de ficheros completo via helper
Browse files Browse the repository at this point in the history
  • Loading branch information
demonio committed Jan 1, 2012
1 parent e8f74da commit beb86f0
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 14 deletions.
26 changes: 13 additions & 13 deletions app/controllers/admin/cms_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,41 @@

class CmsController extends AppController
{
protected function before_filter()
/*protected function before_filter()
{
if ( Input::isAjax() ) View::template( NULL );
}
}*/

public function index()
{
$this->dir = empty( $_REQUEST['dir'] ) ? '' : $_REQUEST['dir'];
$this->ficheros = Load::model( 'ficheros' )->ver();
}

public function codigo( $vista )
/*public function codigo( $vista )
{
$this->pagina = $_REQUEST['dir'];
$this->pagina = $_GET['f'];
$this->codigo = file_get_contents( $this->pagina );
$this->codigo = htmlspecialchars( $this->codigo, ENT_QUOTES, APP_CHARSET );
View::select( $vista, NULL );
}
public function pagina()
{
// $_REQUEST['dir'] deberia llamarse item o similar
$this->dir = dirname( $_REQUEST['dir'] );
$this->pagina = basename( $_REQUEST['dir'] );
$this->codigo = file_get_contents( $_REQUEST['dir'] );
// $_GET['f'] deberia llamarse item o similar
$this->dir = dirname( $_GET['f'] );
$this->pagina = basename( $_GET['f'] );
$this->codigo = file_get_contents( $_GET['f'] );
$this->codigo = htmlspecialchars( $this->codigo, ENT_QUOTES, APP_CHARSET );
$this->version = Load::model( 'versiones' )->leyendo( $this->dir, $this->pagina );
}
public function paginas()
{
if ( empty( $_REQUEST['dir'] ) ) $_REQUEST['dir'] = APP_PATH . 'views/pages';
$dir = is_dir( $_REQUEST['dir'] ) ? $_REQUEST['dir'] : dirname( $_REQUEST['dir'] );
if ( empty( $_GET['f'] ) ) $_GET['f'] = APP_PATH . 'views/pages';
$dir = is_dir( $_GET['f'] ) ? $_GET['f'] : dirname( $_GET['f'] );
$dir = '/' . ltrim( $dir, '/' );
$this->items = _fs::readDir( $dir );
$this->dad = $dir == '/' ? '' : $dir;
$this->up = ( empty( $_REQUEST['up'] ) or $_REQUEST['dir'] == APP_PATH . 'views/pages' )? 0 : 1;
}
$this->up = ( empty( $_REQUEST['up'] ) or $_GET['f'] == APP_PATH . 'views/pages' )? 0 : 1;
}*/
}
23 changes: 23 additions & 0 deletions app/extensions/helpers/tree.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

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

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

}
else
{
$s .= "<li>$v</li>";
}
}
return "<ul id=\"$k\">$s</ul>";
}
32 changes: 32 additions & 0 deletions app/models/ficheros.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

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


/*public function ver( $get )
{
// DIRECTORIO POR DEFECTO
$a['directorio'] = empty( $get['d'] ) ? '' : $get['d'];
// NO SE PERMITE INTRODUCIR ..
$a['directorio'] = str_replace( '..', '', $a['directorio'] );
// DIRECTORIO PADRE REAL
$a['padre'] = realpath( APP_PATH . "views/pages/{$a['directorio']}/.." ) . '/';
// DIRECTORIO PADRE RELATIVO
$a['padre'] = str_replace( APP_PATH . 'views/pages/', '', $a['padre'] );
// CONTENIDO DEL DIRECTORIO
$a['ficheros'] = _fs::readDir( APP_PATH . "views/pages/{$a['directorio']}" );
// ARCHIVO POR DEFECTO
$a['fichero'] = empty( $get['f'] ) ? '' : $get['f'];
return $a;
}*/
}
30 changes: 30 additions & 0 deletions app/views/_shared/partials/admin/paginas.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

View::helpers( 'tree' );

echo _tree( $ficheros );


/*if ( $a['directorio'] and $a['directorio'] <> '/' ) echo "<li class=\"directory up\"><a href=\"?d={$a['padre']}\">..</a></li>";
if ( $a['ficheros'] )
{
foreach ( $a['ficheros'] as $k => $v )
{
if ( is_array( $v ) )
{
$k = basename( $k );
echo "<li class=\"directory collapsed\"><a href=\"?d={$a['directorio']}$k/\">$k/</a></li>";
}
else
{
$pathinfo = pathinfo( $v );
$ext = ! empty( $pathinfo['extension'] ) ? $pathinfo['extension'] : 'txt';
echo "<li class=\"file ext_$ext\"><a href=\"?d={$a['directorio']}/&f=$v\">$v</a></li>";
}
}
}
else
{
echo 'Vacio';
}*/
2 changes: 1 addition & 1 deletion app/views/_shared/templates/admin/cms.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</header>
<aside>
<h3>Páginas:</h3>
<?php View::partial( 'admin/file_manager', false, get_object_vars( $controller ) ); ?>
<?php View::partial( 'admin/paginas', false, get_object_vars( $controller ) ); ?>
<hr />
</aside>
<section>
Expand Down

0 comments on commit beb86f0

Please sign in to comment.