Esempio n. 1
0
 protected function private_core()
 {
     $this->noticia = FALSE;
     $this->relacionada = FALSE;
     if (isset($_REQUEST['id'])) {
         $noti0 = new inme_noticia_fuente();
         $this->noticia = $noti0->get($_REQUEST['id']);
     }
     if ($this->noticia) {
         if (isset($_POST['url'])) {
             $this->noticia->editada = TRUE;
             $this->noticia->url = $_POST['url'];
             $this->noticia->titulo = $_POST['titulo'];
             $this->noticia->resumen = substr($_POST['resumen'], 0, 300);
             $this->noticia->texto = $_POST['texto'];
             $this->noticia->id_relacionada = null;
             if ($_POST['id_relacionada'] != '') {
                 $this->noticia->id_relacionada = intval($_POST['id_relacionada']);
             }
             $this->noticia->preview = $_POST['preview'];
             $this->noticia->clean_keywords();
             $keys = explode(',', $_POST['keywords']);
             if ($keys) {
                 foreach ($keys as $k) {
                     $this->noticia->set_keyword($k);
                 }
             }
             if ($this->noticia->save()) {
                 $this->new_message('Datos modificados correctamente.');
             } else {
                 $this->new_error_msg('Error al guardar los datos.');
             }
         }
         if (!is_null($this->noticia->id_relacionada)) {
             $this->relacionada = $noti0->get($this->noticia->id_relacionada);
         }
     } else {
         $this->new_error_msg('Noticia no encontrada.');
     }
 }
 protected function public_core()
 {
     $this->template = 'inme_public/editar_noticia';
     $this->page_description = 'Detalle de la noticia.';
     $this->buscar = '';
     $fsvar = new fs_var();
     $this->analytics = $fsvar->simple_get('inme_analytics');
     $this->modrewrite = $fsvar->simple_get('inme_modrewrite');
     if (isset($_GET['ok_cookies'])) {
         setcookie('ok_cookies', 'TRUE', time() + FS_COOKIES_EXPIRE, '/');
         $fslog = new fs_log();
         $fslog->tipo = 'cookies';
         $fslog->detalle = 'Se han aceptado las cookies';
         $fslog->ip = $_SERVER['REMOTE_ADDR'];
         $fslog->save();
     }
     $this->noticia = FALSE;
     $this->relacionada = FALSE;
     $this->temas = array();
     $noti0 = new inme_noticia_fuente();
     if (isset($_REQUEST['id'])) {
         $this->noticia = $noti0->get($_REQUEST['id']);
     } else {
         if (isset($_REQUEST['permalink'])) {
             $this->noticia = $noti0->get_by_permalink($_REQUEST['permalink']);
         }
     }
     if ($this->noticia) {
         $this->page_title = $this->noticia->titulo;
         $this->page_description = $this->true_text_break($this->noticia->resumen, 140);
         if (!is_null($this->noticia->id_relacionada)) {
             $this->relacionada = $noti0->get($this->noticia->id_relacionada);
         }
         $tema0 = new inme_tema();
         foreach ($this->noticia->keywords() as $key) {
             $tema = $tema0->get($key);
             if ($tema) {
                 if ($tema->activo) {
                     $this->temas[] = $tema;
                     /// si no hay una preview, usamos la de un tema
                     if ($tema->imagen and !$this->noticia->preview) {
                         $this->noticia->preview = $tema->imagen;
                         $this->noticia->save();
                     }
                 }
             } else {
                 $this->new_error_msg('Tema ' . $key . ' no encontrado.');
             }
         }
     } else {
         $this->new_error_msg('Noticia no encontrada.');
     }
 }