public function action_buscar() { \Config::load('phpthumb'); $photos_path = str_replace("\\", "/", Config::get('photos_path')); $document_root = str_replace("\\", "/", Config::get('document_root')); $termino = Input::post('p'); $fotos = Search::buscar($photos_path . '/*', $termino); $data['fotos'] = null; if ($fotos) { $files = ""; foreach ($fotos as $file) { list($img_width, $img_height, $img_type, $img_attr) = getimagesize($document_root . "/" . $file); $files .= "<li class='thumbnail'>" . "<a href='" . Myhtml::img_watermark($file) . "' rel='gallery' title='{$file}'>" . "<img class='detalle' data-original-title='" . $file . "' " . "data-content='Dimensiones: {$img_width} por {$img_height} pixels' src='" . Config::get('phpthumbroot') . "phpThumb.php?src=" . $document_root . $file . "&w=" . Config::get('thumb_size') . "&h=" . Config::get('thumb_size') . "&zc=1' />" . "</a>" . "</li>"; } $data['fotos'] = html_entity_decode($files, ENT_QUOTES); } //Incio articulos $fi = date("Y-m-d") . ' 01:00:00'; $ff = date("Y-m-d") . ' 23:59:00'; $fecha_inicio = Date::create_from_string($fi, "mysql"); $fecha_fin = Date::create_from_string($ff, "mysql"); $articulos = Model_Articulo::find('all', array('related' => array('fotos', 'seccion'), 'where' => array(array('periodista_id', '=', $this->user_id), array('fecha_publicacion', '>=', $fecha_inicio->get_timestamp())), 'order_by' => array('fecha_publicacion' => 'asc'))); $select_articulos = array(); if ($articulos) { foreach ($articulos as $articulo) { $select_articulos[$articulo->id] = $articulo->nombre; } } else { $select_articulos = array('none' => 'No existen articulos creados'); } $data['select_articulos'] = $select_articulos; // Fin articulos // Inicio Dimensiones $dimensiones = Model_Dimension::find('all'); $select_dimensiones = array(); if ($dimensiones) { foreach ($dimensiones as $dimension) { $select_dimensiones[$dimension->id] = $dimension->descipcion; } } else { $select_dimensiones = array('none' => 'No existen dimensiones creadas'); } $data['select_dimensiones'] = $select_dimensiones; $data['periodista_id'] = $this->user_id; $view = View::forge(Session::get('template')); $view->set_global('user_id', 1); $view->set_global('data', $data); $view->set_global('title', 'Resultado de Búsqueda'); $view->set_global('content', 'Resultado de BBúsqueda'); $view->content = View::forge('buscar/buscar', $data); return $view; }
public static function generate() { //is_null(Input::get('dir')) and Response::redirect('user/login'); static::$default_config['thumbdir'] = rtrim(Config::get('photos_path') . "/" . Input::get('dir'), "/"); $currentdir = static::$default_config['thumbdir']; //----------------------- // READ FILES AND FOLDERS //----------------------- $files = array(); $dirs = array(); if (is_dir($currentdir)) { if ($handle = opendir($currentdir)) { while (false !== ($file = readdir($handle))) { // 1. LOAD FOLDERS if (Gallery::is_directory($currentdir . "/" . $file)) { if ($file != "." && $file != ".." & $file != "cache" && !Gallery::startsWith($file, '.')) { Gallery::checkpermissions($currentdir . "/" . $file); // Check for correct file permission // Set thumbnail to folder.jpg if found: if (file_exists("{$currentdir}/" . $file . "/folder.jpg")) { $dirs[] = array("name" => $file, "date" => filemtime($currentdir . "/" . $file . "/folder.jpg"), "html" => "<li class='thumbnail'><a href='?dir=" . ltrim(Input::get('dir') . "/" . $file, "/") . "'><em>" . Gallery::padstring($file, static::$default_config['label_max_length']) . "</em><span></span><img src='" . static::$default_config['phpthumbroot'] . "phpThumb.php?src={$currentdir}/" . $file . "/folder.jpg&w=thumb_size&h=" . static::$default_config['thumb_size'] . "&zc=1'/></a></li>"); } else { // Set thumbnail to first image found (if any): unset($firstimage); $firstimage = Gallery::getfirstImage("{$currentdir}/" . $file); if ($firstimage != "") { $dirs[] = array("name" => $file, "date" => filemtime($currentdir . "/" . $file), "html" => "<li class='thumbnail'>" . "<a href='?dir=" . ltrim(Input::get('dir') . "/" . $file, "/") . "'>" . "<img src='" . static::$default_config['phpthumbroot'] . "phpThumb.php?src=" . static::$default_config['thumbdir'] . "/" . $file . "/" . $firstimage . "&w=" . static::$default_config['thumb_size'] . "&h=" . static::$default_config['thumb_size'] . "&zc=1' /></a>" . "<a href='?dir=" . ltrim(Input::get('dir') . "/" . $file, "/") . "'>" . "<h5>" . Gallery::padstring($file, static::$default_config['label_max_length']) . "</h5>" . '</a>' . "</li>"); } else { // If no folder.jpg or image is found, then display default icon: $dirs[] = array("name" => $file, "date" => filemtime($currentdir . "/" . $file), "html" => "<li class='thumbnail'>" . "<a href='?dir=" . ltrim(Input::get('dir') . "/" . $file, "/") . "'>" . "<img src='public/assets/img/folder_" . strtolower(static::$default_config['folder_color']) . ".png' width='" . static::$default_config['thumb_size'] . "' height='" . static::$default_config['thumb_size'] . "' />" . "<h5>" . Gallery::padstring($file, static::$default_config['label_max_length']) . "</h5>" . "</li>"); } } } } // 2. LOAD FILES if ($file != "." && $file != ".." && $file !== "folder.jpg" && !Gallery::startsWith($file, '.')) { // JPG, GIF and PNG if (preg_match("/.jpg\$|.gif\$|.png\$/i", $file)) { Gallery::checkpermissions($currentdir . "/" . $file); list($img_width, $img_height, $img_type, $img_attr) = getimagesize($currentdir . "/" . $file); $imagen_destino = static::$default_config['galleryroot'] . Input::get('dir') . "/" . $file; $files[] = array("name" => $file, "date" => filemtime($currentdir . "/" . $file), "size" => filesize($currentdir . "/" . $file), "html" => "<li class='thumbnail'>" . "<a href='" . Myhtml::img_watermark($imagen_destino) . "' rel='gallery' title='{$file}'>" . "<img class='detalle' data-original-title='" . $file . "' " . "data-content='Dimensiones: {$img_width} por {$img_height} pixels' src='" . static::$default_config['phpthumbroot'] . "phpThumb.php?src=" . static::$default_config['thumbdir'] . "/" . $file . "&w=" . static::$default_config['thumb_size'] . "&h=" . static::$default_config['thumb_size'] . "&zc=1' />" . "</a>" . "</li>"); } /* // Other filetypes $extension = ""; if (preg_match("/.pdf$/i", $file)) $extension = "PDF"; // PDF if (preg_match("/.zip$/i", $file)) $extension = "ZIP"; // ZIP archive if (preg_match("/.rar$|.r[0-9]{2,}/i", $file)) $extension = "RAR"; // RAR Archive if (preg_match("/.tar$/i", $file)) $extension = "TAR"; // TARball archive if (preg_match("/.gz$/i", $file)) $extension = "GZ"; // GZip archive if (preg_match("/.doc$|.docx$/i", $file)) $extension = "DOCX"; // Word if (preg_match("/.ppt$|.pptx$/i", $file)) $extension = "PPTX"; //Powerpoint if (preg_match("/.xls$|.xlsx$/i", $file)) $extension = "XLXS"; // Excel if ($extension != "") { $files[] = array ( "name" => $file, "date" => filemtime($currentdir . "/" . $file), "size" => filesize($currentdir . "/" . $file), "html" => "<li class='thumbnail'><a href='" . $currentdir . "/" . $file . "' title='$file'><em-pdf>" . Gallery::padstring($file, 20) . "</em-pdf><span></span><img src='" . static::$default_config['phpthumbroot'] . "images/filetype_" . $extension . ".png' width='" . static::$default_config['thumb_size'] . "' height='" . static::$default_config['thumb_size'] . "' alt='$file' /></a></li>"); } */ } } //end while (false !== ($file = readdir($handle))) closedir($handle); } else { die("ERROR: Could not open {$currentdir} for reading!"); } } //----------------------- // SORT FILES AND FOLDERS //----------------------- //----------------------- // OFFSET DETERMINATION //----------------------- $offset_start = Input::get('page') * static::$default_config['thumbs_pr_page'] - static::$default_config['thumbs_pr_page']; if (is_null(Input::get('page'))) { $offset_start = 0; } $offset_end = $offset_start + static::$default_config['thumbs_pr_page']; if ($offset_end > sizeof($dirs) + sizeof($files)) { $offset_end = sizeof($dirs) + sizeof($files); } if (Input::get('page') == "all") { $offset_start = 0; $offset_end = sizeof($dirs) + sizeof($files); } $get_page = is_null(Input::get('page')) ? 1 : Input::get('page'); if (sizeof($dirs) + sizeof($files) > static::$default_config['thumbs_pr_page']) { static::$default_config['page_navigation'] .= static::$default_config['label_page']; for ($i = 1; $i <= ceil((sizeof($files) + sizeof($dirs)) / static::$default_config['thumbs_pr_page']); $i++) { if ($get_page == $i) { static::$default_config['page_navigation'] .= "{$i}"; } else { static::$default_config['page_navigation'] .= "<a href='?dir=" . Input::get('dir') . "&page=" . $i . "'>" . $i . "</a>"; } if ($i != ceil((sizeof($files) + sizeof($dirs)) / static::$default_config['thumbs_pr_page'])) { static::$default_config['page_navigation'] .= " | "; } } //Insert link to view all images if ($get_page == "all") { static::$default_config['page_navigation'] .= " | " . static::$default_config['label_all']; } else { static::$default_config['page_navigation'] .= " | <a href='?dir=" . Input::get('dir') . "&page=all'>" . static::$default_config['label_all'] . "</a>"; } } //----------------------- // BREADCRUMB NAVIGATION //----------------------- if (Input::get('dir') != "") { static::$default_config['breadcrumb_navigation'] .= "<li><a href='?dir='>" . static::$default_config['label_home'] . "</a> <span class='divider'>/</span></li>"; $navitems = explode("/", Input::get('dir')); for ($i = 0; $i < sizeof($navitems); $i++) { if ($i == sizeof($navitems) - 1) { static::$default_config['breadcrumb_navigation'] .= $navitems[$i]; } else { static::$default_config['breadcrumb_navigation'] .= "<li><a href='?dir="; for ($x = 0; $x <= $i; $x++) { static::$default_config['breadcrumb_navigation'] .= $navitems[$x]; if ($x < $i) { static::$default_config['breadcrumb_navigation'] .= "/"; } } static::$default_config['breadcrumb_navigation'] .= "'>" . $navitems[$i] . "</a><span class='divider'>/</span></li>"; } } } else { static::$default_config['breadcrumb_navigation'] .= static::$default_config['label_home']; } //----------------------- // DISPLAY FOLDERS //----------------------- if (count($dirs) + count($files) == 0) { static::$default_config['thumbnails'] .= "<li class='thumbnail'>" . static::$default_config['label_noimages'] . "</li>"; //Display 'no images' text //if($currentdir == "photos") $messages = "It looks like you have just installed MiniGal Nano. Please run the <a href='system_check.php'>system check tool</a>"; } $offset_current = $offset_start; for ($x = $offset_start; $x < sizeof($dirs) && $x < $offset_end; $x++) { $offset_current++; static::$default_config['thumbnails'] .= $dirs[$x]["html"]; } //----------------------- // DISPLAY FILES //----------------------- for ($i = $offset_start - sizeof($dirs); $i < $offset_end && $offset_current < $offset_end; $i++) { if ($i >= 0) { $offset_current++; static::$default_config['thumbnails'] .= $files[$i]["html"]; } } $data['thumbnails'] = html_entity_decode(static::$default_config['thumbnails'], ENT_QUOTES); $data['breadcrumb_navigation'] = static::$default_config['breadcrumb_navigation']; $data['page_navigation'] = static::$default_config['page_navigation']; return $data; }
<?php if ($articulo->fotos) { ?> <ul class="thumbnails" data-toggle="modal-gallery" data-target="#modal-gallery"> <?php foreach ($articulo->fotos as $foto) { ?> <li class="thumbnail"> <?php echo Myhtml::img($foto->imagen, array('width' => '110', 'height' => '110', 'class' => 'detalle', 'data-content' => "Dimensiones: {$foto->dimension->descipcion}<br/>Seccion: {$articulo->seccion->descripcion}<br/>Página: {$articulo->pagina->descripcion}", 'alt' => $foto->imagen, 'data-original-title' => $foto->imagen)); ?> <div class="btn-group"> <a href="<?php echo Myhtml::img_watermark($foto->imagen); ?> " class='btn detalles_foto' rel='gallery' title='<?php echo $articulo->nombre; ?> ' alt='<?php echo $articulo->nombre; ?> '> <i class="icon-eye-open"></i> </a> <!-- echo Html::anchor('foto/delete/' . $foto->id, '<i class="icon-trash"></i>', array('class' => 'btn', 'rel' => 'tooltip', 'data-original-title' => 'Borrar foto del articulo', 'onclick' => "return confirm('Seguro desea Borrar la foto?')")); -->