Exemple #1
0
$this->pageCaption = 'Ver Galeria #' . $model->id;
$this->pageTitle = Yii::app()->name . ' - ' . $this->pageCaption;
$this->pageDescription = '';
$this->breadcrumbs = array('Galeria' => array('index'), $model->id);
$this->menu = array(array('label' => 'Volver a Galerías', 'url' => array('index')));
?>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'baseScriptUrl' => false, 'cssFile' => false, 'htmlOptions' => array('class' => 'table table-bordered table-striped'), 'attributes' => array('id', 'nombre', 'descripcion', array('name' => 'estatus_did', 'value' => $model->estatus->nombre))));
?>

<div class="row">          
  <div class="col-lg-12">
		<?php 
$fotos = DetalleGaleria::model()->findAll("galeria_did = " . $model->id);
?>
		<hr>
		<?php 
if (count($fotos) > 0) {
    ?>
	    <div class="container">
				<div class="row">	
						<?php 
    foreach ($fotos as $foto) {
        ?>
							
							<img class="img-responsive img-thumbnail col-lg-3" src="<?php 
        echo Yii::app()->baseUrl . "/images/uploads/tmp/" . $foto->ruta;
        ?>
"/>								
Exemple #2
0
<?php

$this->pageCaption = '';
$this->pageTitle = Yii::app()->name . ' - ' . $this->pageCaption;
$this->pageDescription = '';
?>
<div class="row">	
	<?php 
foreach ($galerias as $galeria) {
    $detalle = DetalleGaleria::model()->find("galeria_did = :g and estatus_did = 1", array(":g" => $galeria->id));
    if (count($detalle) > 0) {
        echo CHtml::link("<div class='col-md-3 col-sm-4 col-xs-6'>\n\t\t\t\t\t<img class='img-responsive img-thumbnail' src='" . Yii::app()->baseUrl . "/administracion/images/uploads/tmp/" . $detalle->ruta . "'/>\n\t\t\t\t\t<p class='lead' style='margin-bottom:0px;'>" . $galeria->nombre . "</p>\n\t\t\t\t\t<small>" . $galeria->descripcion . "</small>\n\t\t\t\t</div>", array('galeria/view', 'id' => $galeria->id));
    }
}
?>
</div>
 public function actionUpload($id)
 {
     Yii::import("xupload.models.XUploadForm");
     //Here we define the paths where the files will be stored temporarily
     $path = realpath(Yii::app()->getBasePath() . "/../images/uploads/tmp/") . "/";
     $publicPath = Yii::app()->getBaseUrl() . "/images/uploads/tmp/";
     //This is for IE which doens't handle 'Content-type: application/json' correctly
     header('Vary: Accept');
     if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) {
         header('Content-type: application/json');
     } else {
         header('Content-type: text/plain');
     }
     //Here we check if we are deleting and uploaded file
     if (isset($_GET["_method"])) {
         if ($_GET["_method"] == "delete") {
             if ($_GET["file"][0] !== '.') {
                 $file = $path . $_GET["file"];
                 if (is_file($file)) {
                     unlink($file);
                 }
             }
             echo json_encode(true);
         }
     } else {
         $model = new XUploadForm();
         $model->file = CUploadedFile::getInstance($model, 'file');
         //We check that the file was successfully uploaded
         if ($model->file !== null) {
             //Grab some data
             $model->mime_type = $model->file->getType();
             $model->size = $model->file->getSize();
             $model->name = $model->file->getName();
             //(optional) Generate a random name for our file
             $filename = Yii::app()->user->id . microtime() . $model->name;
             //$filename .= ".".$model->file->getExtensionName( );
             if ($model->validate()) {
                 //Move our file to our temporary dir
                 if ($model->file->saveAs($path . $filename)) {
                     $modelDetalleGaleria = new DetalleGaleria();
                     $modelDetalleGaleria->ruta = $filename;
                     $modelDetalleGaleria->galeria_did = $id;
                     $modelDetalleGaleria->estatus_did = 1;
                     $modelDetalleGaleria->save();
                 }
                 chmod($path . $filename, 0777);
                 //here you can also generate the image versions you need
                 //using something like PHPThumb
                 //Now we need to save this path to the user's session
                 if (Yii::app()->user->hasState('images')) {
                     $userImages = Yii::app()->user->getState('images');
                 } else {
                     $userImages = array();
                 }
                 $userImages[] = array("path" => $path . $filename, "thumb" => $path . $filename, "filename" => $filename, 'size' => $model->size, 'mime' => $model->mime_type, 'name' => $model->name);
                 Yii::app()->user->setState('images', $userImages);
                 //Now we need to tell our widget that the upload was succesfull
                 //We do so, using the json structure defined in
                 // https://github.com/blueimp/jQuery-File-Upload/wiki/Setup
                 echo json_encode(array(array("name" => $model->name, "type" => $model->mime_type, "size" => $model->size, "url" => $publicPath . $filename, "thumbnail_url" => $publicPath . "thumbs/{$filename}", "delete_url" => $this->createUrl("upload", array("_method" => "delete", "file" => $filename)), "delete_type" => "POST")));
             } else {
                 //If the upload failed for some reason we log some data and let the widget know
                 echo json_encode(array(array("error" => $model->getErrors('file'))));
                 Yii::log("XUploadAction: " . CVarDumper::dumpAsString($model->getErrors()), CLogger::LEVEL_ERROR, "xupload.actions.XUploadAction");
             }
         } else {
             throw new CHttpException(500, "Could not upload file");
         }
     }
 }
Exemple #4
0
<?php

$this->pageCaption = 'Galería: ' . $model->nombre;
$this->pageTitle = Yii::app()->name . ' - ' . $this->pageCaption;
$this->pageDescription = '';
?>

<div class="row">          
  <div class="col-lg-12">
		<?php 
$fotos = DetalleGaleria::model()->findAll("estatus_did  = 1 and galeria_did = " . $model->id);
if (count($fotos) > 0) {
    ?>
				<div class="row">	
					<div class='list-group gallery'>
						<?php 
    foreach ($fotos as $foto) {
        ?>
		
							<div class='col-md-3 col-sm-4 col-xs-6 col-lg-3'>
								<a class="thumbnail fancybox" rel="ligthbox" href="<?php 
        echo Yii::app()->baseUrl . "/administracion/images/uploads/tmp/" . $foto->ruta;
        ?>
">
									<img class="img-responsive img-thumbnail" src="<?php 
        echo Yii::app()->baseUrl . "/administracion/images/uploads/tmp/" . $foto->ruta;
        ?>
"/>						
								</a>
							</div>