function setImageProduction($production_id)
 {
     if (!isset($_GET["poster"])) {
         return "Sin poster";
     }
     /**
      *  MODIFICAR LA IMAGEN DE UNA PRODUCCION
      */
     $production = Production::find($production_id);
     $data[Production::ATTR_IMAGE] = "";
     $data[Production::ATTR_POSTER] = "http://" . $_GET["poster"];
     $path_image = public_path("assets/db/images/") . md5($production->title_original . $production->year);
     copy($data[Production::ATTR_POSTER], $path_image . "-poster.jpg");
     $production->poster = Util::convertPathToUrl($path_image . "-poster.jpg");
     if (strlen($data[Production::ATTR_IMAGE]) > 9) {
         copy($data[Production::ATTR_IMAGE], $path_image . ".jpg");
         $production->image = Util::convertPathToUrl($path_image . ".jpg");
     } else {
         $title_md5 = md5($production->title_original . $production->year);
         $image = new Image($production->poster);
         $production->image = $image->createCopy(214, 334, $title_md5, public_path("assets/db/images/"), false);
     }
     $production->save();
     return "REALIZADO EXITOSAMENTE";
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Auth::check()) {
         return redirect("browser");
     }
     $productions = Production::all()->take(60);
     return view("frontend/index")->with("productions", $productions);
 }
 function getInfo($slug)
 {
     $person = Person::where(Person::ATTR_SLUG, $slug)->get()[0];
     if (is_null($person->biography)) {
         abort(404);
     }
     $productions = $person->productions;
     $productions = Production::sortByState($productions);
     return view("frontend/contents/person/info")->with("person", $person)->with("productions", $productions);
 }
 function getSearch($query)
 {
     $productions = Production::search($query);
     $persons = Person::search($query);
     foreach ($persons as $person) {
         $pros = $person->productions()->orderBy(Production::ATTR_STATE, "DESC")->get();
         foreach ($pros as $pr) {
             $productions[] = $pr;
         }
     }
     $productions = Production::sortByState($productions);
     return view("frontend/contents/gen/search")->with("productions", $productions)->with("persons", $persons)->with("query", $query);
 }
Example #5
0
 static function search($query, $take = 50)
 {
     return Production::where(self::ATTR_TITLE, "LIKE", "%" . $query . "%")->orWhere(self::ATTR_TITLE_ORIGINAL, "LIKE", "%" . $query . "%")->orderBy(self::ATTR_STATE, "DESC")->take($take)->get();
 }
<?php

use App\System\Models\Production;
use App\System\Library\Complements\DateUtil;
?>
@extends("user/templates/gen",array("title"=>"<span class='glyphicon glyphicon-time'></span> Actividad: Comentarios"))

@section("content")


@foreach($comments as $comment)

<?php 
$production = Production::findOrNew($comment->production_id);
$date = new DateUtil($comment->created_at);
?>
<div class="col-sm-3 date-activity">{{$date->getDay()}} de {{$date->getMonth()}} del {{$date->getYear()}}</div>
<div class="col-sm-9 description-activity">
    <span class="glyphicon glyphicon-comment tooltip-top" style="color:#0072FF;" title="{{$comment->content}}"></span>
    Realizaste un comentario en <a target="_blank" href="{{URL::to("production/".$production->slug)}}">{{$production->title}}</a>.
</div>


@endforeach

<div class="text-center clearfix">
    {{$comments->render()}}
</div>

@stop
 /** Obtiene un numero indicado de registros
  * 
  * @param Request $request
  * @return type
  */
 function ajaxGetRecords(Request $request)
 {
     if (!$request->ajax()) {
         return;
     }
     $data = $request->all();
     $productions = Production::orderBy(Production::ATTR_ID, "DESC")->take(intval($data["count"]))->get();
     return json_encode($productions);
 }
 private function cron()
 {
     \Event::listen('cron.collectJobs', function () {
         /**
          * CRON: Alimentación de cola de producciones
          * DESCRIPCION: Alimenta la cola de producciones que se van a procesar
          * EJECUCION: Cada 3 minutos
          */
         \Cron::add(AutoProcess::CRON_PRODUCTIONS_FEED, '*/3 * * * *', function () {
             if (!AutoProcess::isActived(AutoProcess::CRON_PRODUCTIONS_FEED)) {
                 return "Desactivado";
             }
             $productionFeed = new ProductionFeed();
             //Carga datos de producciones (peliculas) en el repositorio
             $productionFeed->loadRepository();
             //Alimenta la cola de actualizaciones de peliculas
             $productionFeed->feedQueue();
             return count($productionFeed->dataRepository) . " Producciones cargadas en cola";
         });
         /**
          * CRON: Seguimiento de produccion
          * DESCRIPCION: Toma las producciones en cola indicadas y las procesa obtienendo todos los datos de la produccion
          * EJECUCION: Cada minuto
          */
         \Cron::add(AutoProcess::CRON_PRODUCTION_TRACK, '* * * * *', function () {
             if (!AutoProcess::isActived(AutoProcess::CRON_PRODUCTION_TRACK)) {
                 return "Desactivado";
             }
             $queue = QueueProductions::where(QueueProductions::ATTR_DATE_PROCESSED, null)->orderBy(QueueProductions::ATTR_ID, "ASC")->take(1)->get();
             foreach ($queue as $production) {
                 $provider = new ProductionProvider($production->name, $production->link);
                 $production_id = $provider->save();
                 //Indica el registro como procesado. Esto ocasiona que la produccion ya no se vuelva a actualizar, hasta una nueva cola.
                 $production->production_id = $production_id;
                 $production->date_processed = DateUtil::getCurrentTime();
                 $production->save();
                 return $production->name . " Agregado";
             }
             return "Sin cola";
         });
         /**
          * CRON: Seguimiento de persona
          * DESCRIPCION: Toma las personas indicadas y las procesa para obtener todos sus datos
          * EJECUCION: Cada minuto
          */
         \Cron::add(AutoProcess::CRON_PERSON_TRACK, '* * * * *', function () {
             if (!AutoProcess::isActived(AutoProcess::CRON_PERSON_TRACK)) {
                 return "Desactivado";
             }
             $queue = QueuePersons::where(QueuePersons::ATTR_DATE_PROCESSED, null)->orderBy(QueuePersons::ATTR_ID, "DESC")->take(1)->get();
             foreach ($queue as $person) {
                 $provider = new PersonProvider($person->name, $person->link);
                 $provider->save();
                 //Indica el registro como procesado. Esto ocasiona que la produccion ya no se vuelva a actualizar, hasta una nueva cola.
                 $person->date_processed = DateUtil::getCurrentTime();
                 $person->save();
                 return $person->name . " Agregado";
             }
             return "Sin cola";
         });
         /**
          * CRON: Envio de correo de notificacion de producciones disponibles
          * DESCRIPCION: Verifica todos las producciones en seguimientos por parte de los usuarios premium y cuando esten disponibles les envia un correo notificandoles
          * EJECUCION: Cada 12 horas
          */
         \Cron::add(AutoProcess::CRON_USER_PRODUCTION_TRACK_SEND_MAIL, '0 */12 * * *', function () {
             if (!AutoProcess::isActived(AutoProcess::CRON_USER_PRODUCTION_TRACK_SEND_MAIL)) {
                 return "Desactivado";
             }
             //Obtiene todos los usuarios premium
             $users = User::where(User::ATTR_ROLE, User::ROLE_SUSCRIPTOR_PREMIUM)->get();
             foreach ($users as $user) {
                 //Obtiene las producciones que siguen que ya se encuentran disponibles y que no sean notificado por correo
                 $productions = $user->tracks()->wherePivot(User::ATTR_TRACK_PIVOT_MAILED, 0)->where(Production::ATTR_STATE, Production::STATE_ACTIVE)->get();
                 if (count($productions) == 0) {
                     continue;
                 }
                 if (count($productions) > 1) {
                     $description_email = "<p>Este mensaje es para informate que varias producciones que te gustaria ver en nuestra plataforma ya se encuentran disponibles y las puedes ver cuando quieras.</p>" . "<div style='text-align:center;'>" . "<h2>Nuevas producciones disponibles para ti</h2>" . "</div>" . "<div style='text-align:center;'>";
                 } else {
                     $description_email = "<p>Este mensaje es para informate que una producción que te gustaria ver en nuestra plataforma ya se encuentran disponible y la puede ver cuando quieras.</p>" . "<div style='text-align:center;'>" . "<h2>Nueva producción disponible para ti</h2>" . "</div>" . "<div style='text-align:center;'>";
                 }
                 foreach ($productions as $production) {
                     //Notifica las producciones disponibles asociadas
                     $description_email .= "<a href='" . AutoProcess::URL_SITE . "production/" . $production->slug . "'><img width='192px' height='289px' style='margin: 0px 10px;' src='" . $production->image . "'></a>";
                     $production->pivot->mailed = 1;
                     $production->pivot->save();
                 }
                 $description_email .= "</div>";
                 //Envia el correo de notificacion del usuario
                 $email = new Email(count($productions) > 1 ? "¡Hay varias producciones que te gustaria ver que ya estan disponible!" : "¡Una producción que te gustaria ver ya esta disponible!", $user[User::ATTR_EMAIL], [Email::VAR_NAME => $user->name, Email::VAR_DESCRIPTION => $description_email]);
                 $email->queue();
             }
             return "Notificaciones realizadas (Si aplican)";
         });
         /**
          * CRON: Genera el sitemap.xml del sitio
          * EJECUCION: Cada Semana
          */
         \Cron::add(AutoProcess::CRON_GENERATE_SITEMAP, '0 0 * * 0', function () {
             //Url standards del sitio web
             $urls = array(AutoProcess::URL_SITE, AutoProcess::URL_SITE . "doc/terms", AutoProcess::URL_SITE . "doc/privacypolicy", AutoProcess::URL_SITE . "doc/cookies-policy", AutoProcess::URL_SITE . "doc/help", AutoProcess::URL_SITE . "catalogue");
             $file = fopen(public_path("sitemap.xml"), "w");
             fwrite($file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . PHP_EOL);
             fwrite($file, "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"> " . PHP_EOL);
             for ($i = 0; $i < count($urls); $i++) {
                 fwrite($file, "<url><loc>" . $urls[$i] . "</loc></url>" . PHP_EOL);
             }
             //Inserta las url de cada persona
             $persons = \App\System\Models\Person::whereNotNull(Person::ATTR_BIOGRAPHY)->get();
             foreach ($persons as $person) {
                 fwrite($file, "<url><loc>" . AutoProcess::URL_SITE . "person/" . $person->slug . "</loc></url>" . PHP_EOL);
             }
             //Inserta las url de todas las producciones
             $productions = Production::all();
             foreach ($productions as $production) {
                 fwrite($file, "<url><loc>" . AutoProcess::URL_SITE . "production/" . $production->slug . "</loc></url>" . PHP_EOL);
             }
             fwrite($file, "</urlset>" . PHP_EOL);
             fclose($file);
             return "Sitemap.xml generado (" . count($persons) . " Personas) (" . count($productions) . " Producciones)";
         });
         /**
          * CRON: Publica automaticamente una produccion programada
          * EJECUCION: Cada hora
          */
         \Cron::add(AutoProcess::CRON_PRODUCTION_AUTO_PUBLISH, '0 */4 * * *', function () {
             $productions = Production::where(Production::ATTR_STATE, Production::STATE_PROGRAMMED)->orderBy(Production::ATTR_UPDATED_AT, "ASC")->take(1)->get();
             foreach ($productions as $production) {
                 $production->state = Production::STATE_ACTIVE;
                 $production->save();
                 return $production->title . " Publicado";
             }
             return "No hay producciones programadas";
         });
     });
 }
 function ajax_getProductions(Request $request)
 {
     if (!$request->ajax()) {
         return json_encode(array());
     }
     $data = $request->all();
     $skip = $data["skip"];
     $productions = Production::orderBy("id", "ASC")->skip($skip)->take(72)->get();
     $response = array();
     if ($skip == 0) {
         $total_productions = Production::all()->count();
     }
     foreach ($productions as $production) {
         $data_production = array("html" => Production::getVisualHtml($production));
         if ($skip == 0) {
             $data_production["total"] = $total_productions;
         }
         $response[] = $data_production;
     }
     if (count($productions) == 0) {
         $response[] = array("total" => 0);
     }
     return json_encode($response);
 }
 /**
  *  Agrega una produccion al listado de seguimientos del usuario
  */
 function ajax_trackProduction(Request $request)
 {
     if (!$request->ajax()) {
         return;
     }
     $data = $request->all();
     if (Auth::check() && Auth::user()->role == User::ROLE_SUSCRIPTOR_PREMIUM && !Production::isTracking($data["production_id"])) {
         Auth::user()->tracks()->attach($data["production_id"]);
         return json_encode(array("true"));
     }
     return json_encode(array("false"));
 }
Example #11
0
<?php

use App\System\Models\Production;
use App\System\Library\Complements\DateUtil;
?>
@extends("user/templates/gen",array("title"=>"<span class='glyphicon glyphicon-time'></span> Actividad: Puntuaciones"))

@section("content")


@foreach($ratings as $rating)

<?php 
$production = Production::findOrNew($rating->production_id);
$date = new DateUtil($rating->date);
?>
<div class="col-sm-3 date-activity">{{$date->getDay()}} de {{$date->getMonth()}} del {{$date->getYear()}}</div>
<div class="col-sm-9 description-activity">Puntuaste <img class="tooltip-top" title="{{trans("attr.production.rating.rating_".$rating->rating)}}" width="20px" src="{{URL::to("assets/images/ratings/".$rating->rating.".png")}}"> a <a target="_blank" href="{{URL::to("production/".$production->slug)}}">{{$production->title}}</a>.
</div>


@endforeach

<div class="text-center clearfix">
    {{$ratings->render()}}
</div>

@stop
 function save()
 {
     if (!$this->validate()) {
         return null;
     }
     $production = new Production();
     $production->title = $this->getTitle();
     $production->title_original = $this->getTitle_original();
     $production->year = $this->getYear();
     $production->slug = $this->getSlug();
     $production->description = $this->getDescription();
     $production->state = is_null($this->getRating_rel()) ? Production::STATE_COMING_SOON : Production::STATE_IN_WAIT;
     $production->rating_rel = $this->getRating_rel();
     $production->duration = $this->getDuration();
     $production->image = $this->getImage();
     $production->poster = $this->poster;
     $production->save();
     //CATEGORIAS DE LA PRODUCCION
     $categories = $this->categories;
     foreach ($categories as $category) {
         //Verifica si ya existe la categoria, si no existe la crea y la asigna a la produccion
         $cat = Term::searchByName($category);
         if (is_null($term = $cat)) {
             $term = new Term();
             $term->name = ucfirst(strtolower($category));
             $term->taxonomy_id = Production::TAXONOMY_ID;
             $term->slug = Util::createSlug($category);
             $term->save();
         }
         $production->terms()->attach($term->id);
     }
     //Relaciona un director con la producción a uno existente o lo crea sin o existe
     $director = $this->getDirector();
     $staff_director = is_null($person = Person::searchByName($director[0])) ? new Person() : $person;
     $staff_director->name = $director[0];
     $staff_director->slug = Util::createSlug($director[0]);
     $staff_director->save();
     if (count(DB::select("SELECT * FROM staff WHERE production_id='" . $production->id . "' && person_id='" . $staff_director->id . "'")) == 0) {
         $staff_director->productions()->attach($production->id, array(Person::ATTR_PIVOT_ROLE => Person::ROLE_DIRECTOR));
     }
     //Determina si el nombre del director se encuentra en cola para actualización, si no lo esta, lo agrega.
     if (is_null(QueuePersons::searchByNameInQueue($director[0]))) {
         $queue = new QueuePersons();
         $queue->person_id = $staff_director->id;
         $queue->name = $director[0];
         $queue->link = $director[1];
         $queue->date_creation = DateUtil::getCurrentTime();
         $queue->save();
     }
     //Relaciona los actores con la produccion a uno existente o lo crea sino existe
     $actors = $this->actors;
     foreach ($actors as $actor) {
         if (is_null($actor[0]) || !isset($actor[0]) || strlen($actor[0]) == 0) {
             continue;
         }
         $staff_actor = is_null($person = Person::searchByName($actor[0])) ? new Person() : $person;
         $staff_actor->name = $actor[0];
         $staff_actor->slug = Util::createSlug($actor[0]);
         $staff_actor->save();
         if (count(DB::select("SELECT * FROM staff WHERE production_id='" . $production->id . "' && person_id='" . $staff_actor->id . "'")) == 0) {
             $staff_actor->productions()->attach($production->id, array(Person::ATTR_PIVOT_ROLE => Person::ROLE_ACTOR));
         }
         //Determina si el nombre del actor/actriz se encuentra en cola para actualización, si no lo esta, lo agrega.
         if (is_null(QueuePersons::searchByNameInQueue($actor[0]))) {
             $queue = new QueuePersons();
             $queue->person_id = $staff_actor->id;
             $queue->name = $actor[0];
             $queue->link = $actor[1];
             $queue->date_creation = DateUtil::getCurrentTime();
             $queue->save();
         }
     }
     return $production->id;
 }
<div id="set-request" class="col-lg-12 text-left">
    <button id="open-modal-request" class="btn btn-primary"><span class="glyphicon glyphicon-plus-sign"></span> Solicitar producción</button>
</div>

@if(count($requests)>0)

<table id="table-requests" class="table text-left table-striped table-responsive">
    <th>Fecha</th><th>Producción</th><th class="link-imdb">Enlace IMDB</th><th class="text-center">Estado</th>
    @foreach($requests as $request)
    <?php 
$queue = QueueProductions::find($request->queue_id);
if (is_null($queue->date_processed)) {
    $status = "in-queue";
} else {
    $production = Production::find($queue->production_id);
    if ($production->state == Production::STATE_ACTIVE) {
        $status = "available";
    } else {
        $status = "in-wait";
    }
}
?>
    <tr>
        <td>Hace {{DateUtil::calculateDifference($request->date)}}</td><td>{{$queue->name}}</td><td class="link-imdb">{{$queue->link}}</td><td class="text-center"><span class="glyphicon glyphicon-flag {{$status}}"></span></td>
    </tr>
    @endforeach
</table>

{{Util::pagination($requests)}}