예제 #1
0
파일: Agregar.php 프로젝트: joksnet/php-old
 public function post()
 {
     $foto = new Inmuebles_Fotos();
     $foto->inmueble_id = $this->inmueble->id;
     $foto->codigo = strtolower($this->codigo);
     if ($foto->queryAll()) {
         return ($this->unique = false) && false;
     }
     $foto->nombre = $_FILES['foto']['name'];
     $foto->posicion = Inmuebles_Fotos::pos($this->inmueble->id) + 1;
     $id = $foto->insert();
     Inmuebles_Fotos::upload($_FILES['foto']['tmp_name'], $this->inmuebleCodigo, $foto->codigo);
     return "/admin/inmuebles/{$this->inmuebleCodigo}/fotos/{$foto->codigo}?added=1";
 }
예제 #2
0
파일: Fotos.php 프로젝트: joksnet/php-old
 public function init($inmueble, $pagina)
 {
     $this->inmueble = $inmueble;
     $this->pagina = $pagina;
     if (!$this->inmueble->found()) {
         return false;
     }
     if (!$this->pagina->found()) {
         return false;
     }
     $this->datos = Inmuebles_Paginas_Datos::allPairs(array('inmueble_pagina_id' => $this->pagina->inmueble_pagina_id));
     $this->fotos = Inmuebles_Fotos::all(array('inmueble_id' => $this->inmueble->inmueble_id), array('posicion'));
     return true;
 }
예제 #3
0
파일: Fotos.php 프로젝트: joksnet/php-old
 public static function destroy($foto, $inmueble = null)
 {
     if (!$foto instanceof Inmuebles_Fotos) {
         $foto = new Inmuebles_Fotos($foto);
     }
     if (!$foto->found()) {
         return false;
     }
     if (null === $inmueble) {
         $inmueble = new Inmuebles($foto->inmueble_id);
     } elseif (!$inmueble instanceof Inmuebles) {
         $inmueble = new Inmuebles($inmueble);
     }
     if (!$inmueble->found()) {
         return false;
     }
     foreach (Inmuebles_Fotos::$sizes as $folder => $size) {
         if (file_exists("upload/{$inmueble->codigo}/{$folder}/{$foto->codigo}.jpg")) {
             unlink("upload/{$inmueble->codigo}/{$folder}/{$foto->codigo}.jpg");
         }
     }
     return $foto->delete();
 }
예제 #4
0
파일: Fotos.php 프로젝트: joksnet/php-old
 public function get()
 {
     $page = Request::getQuery('page', 1);
     $per = Configuration::getInstance()->per;
     $start = ($page - 1) * $per;
     $fotos = array();
     $count = 0;
     $pos = 0;
     if ($this->inmueble->found()) {
         $fotos = Inmuebles_Fotos::all(array('inmueble_id' => $this->inmueble->id), array('posicion'), array($start, $per));
         $count = Inmuebles_Fotos::count(array('inmueble_id' => $this->inmueble->id));
         $pos = Inmuebles_Fotos::pos($this->inmueble->id);
     }
     return array('codigo' => $this->codigo, 'inmueble' => $this->inmueble, 'fotos' => $fotos, 'count' => $count, 'start' => $start, 'page' => $page, 'per' => $per, 'pos' => $pos);
 }
예제 #5
0
 public function init($inmueble, $foto, $mover)
 {
     if (!Session::getInstance()->usuario) {
         return '/admin/ingresar';
     }
     $this->inmuebleCodigo = $inmueble;
     $this->inmueble = new Inmuebles();
     $this->inmueble->codigo = $this->inmuebleCodigo;
     $this->inmueble->queryAll();
     if (!$this->inmueble->found()) {
         return true;
     }
     $this->fotoCodigo = $foto;
     $this->foto = new Inmuebles_Fotos();
     $this->foto->inmueble_id = $this->inmueble->id;
     $this->foto->codigo = $this->fotoCodigo;
     $this->foto->queryAll();
     if (!$this->foto->found()) {
         return true;
     }
     $this->pos = Inmuebles_Fotos::pos($this->inmueble->id);
     $this->new = false;
     $this->signo = substr($mover, 0, 1);
     $this->cantidad = intval(substr($mover, 1));
     switch ($this->signo) {
         case '+':
             $pos = $this->foto->posicion + $this->cantidad;
             if ($pos <= $this->pos) {
                 $this->new = $pos;
             }
             break;
         case '-':
             $pos = $this->foto->posicion - $this->cantidad;
             if ($pos > 0) {
                 $this->new = $pos;
             }
             break;
     }
     return true;
 }
예제 #6
0
파일: Welcome.php 프로젝트: joksnet/php-old
 public function get()
 {
     $configuracion = Configuration::getInstance();
     $idioma = Translate::locale();
     $inmuebles = Inmuebles::allContenido(array('inmuebles.activo' => 1), null, null, $idioma);
     foreach ($inmuebles as $i => $inmueble) {
         if (!isset($inmueble->contenidos[$idioma])) {
             unset($inmuebles[$i]);
             continue;
         }
         $inmueble->fotos = Inmuebles_Fotos::all(array('inmueble_id' => $inmueble->id), array('posicion'));
     }
     $twitter = null;
     if (!empty($configuracion->twitter)) {
         $twitter = $this->twitter($configuracion->twitter);
     }
     $title = $configuracion->getContent('title', $idioma);
     # __('Principal');
     if (null === $title) {
         $title = __('Principal');
     }
     return array('title' => $title, 'nombre' => $configuracion->nombre, 'efecto' => $configuracion->efecto, 'twitter' => $twitter, 'idioma' => $idioma, 'inmuebles' => $inmuebles);
 }
예제 #7
0
 public static function destroy($inmueble)
 {
     if (!$inmueble instanceof Inmuebles) {
         $inmueble = new Inmuebles($inmueble);
     }
     if (!$inmueble->found()) {
         return false;
     }
     $contenidos = Inmuebles_Contenidos::all(array('inmueble_id' => $inmueble->id));
     $paginas = Inmuebles_Paginas::all(array('inmueble_id' => $inmueble->id));
     $fotos = Inmuebles_Fotos::all(array('inmueble_id' => $inmueble->id));
     foreach ($contenidos as $contenido) {
         Inmuebles_Contenidos::destroy($contenido);
     }
     foreach ($paginas as $pagina) {
         Inmuebles_Paginas::destroy($pagina);
     }
     foreach ($fotos as $foto) {
         Inmuebles_Fotos::destroy($foto);
     }
     foreach (Inmuebles_Fotos::$sizes as $folder => $size) {
         if (file_exists("upload/{$inmueble->codigo}/{$folder}/")) {
             rmdir("upload/{$inmueble->codigo}/{$folder}/");
         }
     }
     if (file_exists("upload/{$inmueble->codigo}/")) {
         rmdir("upload/{$inmueble->codigo}/");
     }
     return $inmueble->delete();
 }
예제 #8
0
 public function post()
 {
     Inmuebles_Fotos::destroy($this->foto, $this->inmueble);
     return "/admin/inmuebles/{$this->inmuebleCodigo}/fotos?deleted={$this->fotoCodigo}";
 }