/** * Agregar elemento * * @param mixed Instancia de Publicacion */ public function agregar_elemento(Publicacion $publicacion) { // Si el estado NO es publicar, NO se agrega if (strtolower($publicacion->estado) != 'publicar') { return false; } // Fecha $t = strtotime($publicacion->fecha); if ($t === false) { // Fecha errónea, se usará 1980-01-01 $ano = 1980; $mes = 1; $dia = 1; $hora = 0; $minuto = 0; $fecha = date('r', mktime($hora, $minuto, 0, $mes, $dia, $ano)); } else { // Sí se interpretó bien $a = getdate($t); $ano = $a['year']; $mes = $a['mon']; $dia = $a['mday']; $hora = $a['hours']; $minuto = $a['minutes']; $fecha = date('r', mktime($hora, $minuto, 0, $mes, $dia, $ano)); } // Considerar vínculos desde la raíz $publicacion->en_raiz = true; // Formatear URL $url = sprintf('%s/%s', $this->sitio_url, $publicacion->url()); // Identificador único directorio + archivo $id = sprintf('%s-%s', $publicacion->directorio, $publicacion->archivo); // La clave del arreglo asociativo es el tiempo_creado-archivo y sirve para ordenarlo $clave = sprintf('%s-%s', $publicacion->tiempo_creado(), $publicacion->archivo); // Tomar el contenido $contenido = $publicacion->redifusion_html(); // Si autor es un arreglo if (is_array($publicacion->autor)) { $autor = implode(', ', $publicacion->autor); } else { $autor = $publicacion->autor; } // Acumular $this->elementos[$clave] = array('id' => $id, 'fecha' => $fecha, 'titulo' => $publicacion->nombre, 'descripcion' => $publicacion->descripcion, 'contenido' => $this->vinculos_absolutos($contenido, $publicacion->directorio), 'autor' => $autor, 'url' => $url); // Entregar verdadero return true; }
/** * Definir con publicacion * * @param mixed Instancia de Publicacion */ public function definir_con_publicacion(Publicacion $p) { // Imponer estas propiedades en la publicación $p->en_raiz = $this->en_raiz; $p->en_otro = $this->en_otro; // Validar publicación $p->validar(); // Definir parámetros desde la publicación $this->nombre = $p->nombre; $this->directorio = $p->directorio; $this->descripcion = $p->descripcion; $this->autor = $p->autor; $this->fecha = $p->fecha_con_formato_humano(); $this->imagen_id = $p->imagen_id; $this->imprenta_titulo = $p->imprenta_titulo; // La imagen puede ser la imagen_previa o el icono if ($p->imagen != '' && $p->imagen_previa != '') { $this->imagen = $p->imagen; $this->imagen_previa = $p->imagen_previa; } elseif ($p->imagen_previa != '') { $this->imagen = $p->imagen_previa; $this->imagen_previa = $p->imagen_previa; } elseif ($p->imagen != '') { $this->imagen = $p->imagen; $this->imagen_previa = $p->imagen; } elseif ($p->icono != '') { $this->imagen = $p->icono; $this->imagen_previa = ''; } else { $this->imagen = ''; $this->imagen_previa = ''; } // Definir el vínculo if ($p->archivo != '') { $this->vinculo = "{$p->archivo}.html"; // Es una página } elseif ($p->url != '') { $this->vinculo = $p->url; // Apunta a otra dirección en internet } else { $this->vinculo = ''; } }
<?php /** @var PublicacionController $this */ /** @var Publicacion $model */ $this->breadcrumbs = array($model->label(2) => array('index'), Yii::t('AweCrud.app', 'Create')); $this->menu = array(array('label' => Yii::t('AweCrud.app', 'Manage'), 'icon' => 'list-alt', 'url' => array('admin'))); ?> <fieldset> <legend><?php echo Yii::t('AweCrud.app', 'Create') . ' ' . Publicacion::label(); ?> </legend> <?php echo $this->renderPartial('_form', array('model' => $model)); ?> </fieldset>
<?php //Classes include_once 'blog/Classes/Publicacion.php'; //Objects $publicacion = new Publicacion(); //primero obtenemos el parametro que nos dice en que pagina estamos $page = 1; //inicializamos la variable $page a 1 por default if (array_key_exists('pg', $_GET)) { $page = $_GET['pg']; //si el valor pg existe en nuestra url, significa que estamos en una pagina en especifico. } ?> <!DOCTYPE html> <html lang="en"> <!-- Mirrored from wbpreview.com/previews/WB07LH680/blog_right_sidebar.html by HTTrack Website Copier/3.x [XR&CO'2013], Wed, 21 Aug 2013 17:12:17 GMT --> <head> <meta charset="utf-8"> <title>dinero para mi negocio</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- styles --> <link href="assets/css/bootstrap.css" rel="stylesheet"> <link href="assets/css/bootstrap-responsive.css" rel="stylesheet"> <link href="assets/css/docs.css" rel="stylesheet">
<?php // Classes include_once 'Classes/Publicacion.php'; // Variables $url; $directory = '../blog/'; $image = ''; $office = ''; //Objects $publicacion = new Publicacion(); if (isset($_POST['check'])) { $check = $_POST['check']; $publicacion->Publicacion($check); $publicacion->updateEstadoPublicacion(); header("Location: publicaciones.php"); /* Redirect browser */ } ?> <!doctype html> <html class="no-js" lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Blog</title> <link rel="stylesheet" href="css/foundation.css" /> <script src="js/modernizr.js"></script> <script> function confirmDelete(delUrl) { if (confirm("Are you sure you want to delete?")) { document.location = delUrl;
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id, $modelClass = __CLASS__) { $model = Publicacion::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php // Classes include_once 'blog/Classes/Publicacion.php'; //Object $publicacion = new Publicacion(); //Variables //$url=$_SERVER['REQUEST_URI']; $url = $_GET['url']; //$text = explode("-id",$url); //$id_product=preg_replace('/[^0-9]/','',$text[1]); //$url = substr($url, 11, -5); $publicacion->setURL($url); $publicacion->getPublicacionPorUrl(); $publicacion->getTitulo(); if ($publicacion->getTitulo() != null) { } else { //header('Location: /furniture/404.html'); } ?> <!DOCTYPE html> <html lang="en"> <!-- Mirrored from wbpreview.com/previews/WB07LH680/post_right_sidebar.html by HTTrack Website Copier/3.x [XR&CO'2013], Wed, 21 Aug 2013 17:12:18 GMT --> <head> <meta charset="utf-8"> <title>Financiamiento para pequeño negocio</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- styles -->
<?php /** @var PublicacionController $this */ /** @var Publicacion $model */ $this->breadcrumbs = array('Publicacions' => array('index'), $model->id_publicacion); $this->menu = array(array('label' => Yii::t('AweCrud.app', 'Create') . ' ' . Publicacion::label(), 'icon' => 'plus', 'url' => array('create')), array('label' => Yii::t('AweCrud.app', 'Update'), 'icon' => 'pencil', 'url' => array('update', 'id' => $model->id_publicacion)), array('label' => Yii::t('AweCrud.app', 'Delete'), 'icon' => 'trash', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id_publicacion), 'confirm' => Yii::t('AweCrud.app', 'Are you sure you want to delete this item?'))), array('label' => Yii::t('AweCrud.app', 'Manage'), 'icon' => 'list-alt', 'url' => array('admin'))); ?> <fieldset> <legend><?php echo Yii::t('AweCrud.app', 'View') . ' ' . Publicacion::label(); ?> <?php echo CHtml::encode($model); ?> </legend> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id_publicacion', 'nombre_publicacion', 'titulo_publicacion', 'descripcion_publicacion', array('name' => 'id_producto', 'value' => $model->idProducto !== null ? CHtml::link($model->idProducto, array('/producto/view', 'id_producto' => $model->idProducto->id_producto)) . ' ' : null, 'type' => 'html'), 'precio_publicacion', 'imagen'))); ?> </fieldset>
<?php include_once 'lock.php'; // Classes include_once 'Classes/Publicacion.php'; // Variables $url; $directory = '../blog/'; $image = ''; $office = ''; //Objects $publicacion = new Publicacion(); if (isset($_POST['check'])) { $check = $_POST['check']; $publicacion->Publicacion($check); $publicacion->updateEstadoPublicacion(); header("Location: index.php"); /* Redirect browser */ } //primero obtenemos el parametro que nos dice en que pagina estamos $page = 1; //inicializamos la variable $page a 1 por default if (array_key_exists('pg', $_GET)) { $page = $_GET['pg']; //si el valor pg existe en nuestra url, significa que estamos en una pagina en especifico. } ?> <!doctype html> <html class="no-js" lang="en"> <head> <meta charset="utf-8" />
<?php /** @var PublicacionController $this */ /** @var Publicacion $model */ $this->breadcrumbs = array('Publicacions' => array('index'), Yii::t('AweCrud.app', 'Manage')); $this->menu = array(array('label' => Yii::t('AweCrud.app', 'List') . ' ' . Publicacion::label(2), 'icon' => 'list', 'url' => array('index')), array('label' => Yii::t('AweCrud.app', 'Create') . ' ' . Publicacion::label(), 'icon' => 'plus', 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('publicacion-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <fieldset> <legend> <?php echo Yii::t('AweCrud.app', 'Manage'); ?> <?php echo Publicacion::label(2); ?> </legend> <?php echo CHtml::link('<i class="icon-search"></i> ' . Yii::t('AweCrud.app', 'Advanced Search'), '#', array('class' => 'search-button btn')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('bootstrap.widgets.TbGridView', array('id' => 'publicacion-grid', 'type' => 'striped condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id_publicacion', 'nombre_publicacion', 'titulo_publicacion', 'descripcion_publicacion', array('name' => 'id_producto', 'value' => 'isset($data->idProducto) ? $data->idProducto : null', 'filter' => CHtml::listData(Producto::model()->findAll(), 'id_producto', Producto::representingColumn())), 'precio_publicacion', array('class' => 'bootstrap.widgets.TbButtonColumn')))); ?>
<?php //include_once 'lock.php'; //Classes include_once 'Classes/Publicacion.php'; include_once 'Classes/Functions.php'; // Variables $id_publicacion = ''; $url; $titulo = ''; $directory = '../blog-images/'; $image = ''; $texto = ''; $today = ''; //Objects $publicacion = new Publicacion(); if (isset($_POST['id_publicacion']) && !is_numeric($_POST['id_publicacion'])) { date_default_timezone_set('America/Los_Angeles'); // Tiempo del Pacifico if (isset($_FILES["myfile"])) { //Filter the file types , if you want. if ($_FILES["myfile"]["error"] > 0) { // echo "Error: " . $_FILES["file"]["error"] . "<br>"; } else { $today = date("YmdHis"); // 20010310 //move the uploaded file to uploads folder; move_uploaded_file($_FILES["myfile"]["tmp_name"], $directory . $today . $_FILES["myfile"]["name"]); $image = $_FILES["myfile"]["name"]; resize_image($directory, $today . $image); }
public function obtenerPublicacionesActivas() { $publicacion = new Publicacion(); $respuestaObtenerPublicaciones = $publicacion->obtenerPublicacionesActivas(); return $respuestaObtenerPublicaciones; }
/** * Validar * * Puede causar excepción si falta una propiedad obligatoria. También busca definir las opcionales. */ public function validar() { // Si ya fue validado, no se hace nada if ($this->validado) { return; } // Validar nombre if (!is_string($this->nombre) || $this->nombre == '') { throw new \Exception("Error en PublicacionSchemaBlogPosting, validar: La propiedad nombre no está definida."); } // Validar archivo if (!is_string($this->archivo) || $this->archivo == '') { throw new \Exception("Error en PublicacionSchemaBlogPosting, validar: La propiedad archivo no está definida."); } // Validar directorio if (!is_string($this->directorio) || $this->directorio == '') { throw new \Exception("Error en PublicacionSchemaBlogPosting, validar: La propiedad directorio no está definida."); } // Validar descripcion if (!is_string($this->descripcion) || $this->descripcion == '') { throw new \Exception("Error en PublicacionSchemaBlogPosting, validar: La propiedad descripcion no está definida."); } // Validar autor if (!(is_string($this->autor) && $this->autor != '') && !(is_array($this->autor) && count($this->autor) > 0)) { throw new \Exception("Error en PublicacionSchemaBlogPosting, validar: La propiedad autor no está definida."); } // Si no está definida imagen if ($this->imagen == '') { // Si existe una imagen jpg if (file_exists("{$this->directorio}/{$this->archivo}/imagen.jpg")) { $this->imagen = "{$this->archivo}/imagen.jpg"; } // Si existe una imagen png if (file_exists("{$this->directorio}/{$this->archivo}/imagen.png")) { $this->imagen = "{$this->archivo}/imagen.png"; } } // Si no está definida imagen previa if ($this->imagen_previa == '') { // Si existe una imagen previa jpg if (file_exists("{$this->directorio}/{$this->archivo}/imagen-previa.jpg")) { $this->imagen_previa = "{$this->archivo}/imagen-previa.jpg"; } // Si existe una imagen previapng if (file_exists("{$this->directorio}/{$this->archivo}/imagen-previa.png")) { $this->imagen_previa = "{$this->archivo}/imagen-previa.png"; } } // El contenido es estructurado en un esquema $schema = new SchemaBlogPosting(); $schema->name = $this->nombre; $schema->description = $this->descripcion; $schema->datePublished = $this->fecha; $schema->image = $this->imagen; $schema->image_show = $this->poner_imagen_en_contenido; $schema->author = $this->autor; // El contenido es una instancia de SchemaBlogPosting $this->contenido = $schema; // Ejecutar método en el padre parent::validar(); }