Esempio n. 1
0
 public function seccionAction($seccion_slug)
 {
     $this->view->disable();
     $result = array();
     foreach (\Rpp\Services\Get\Flow::seccion($seccion_slug, 50, 0) as $item) {
         $article['abstractText'] = \Rpp\Services\Get\Content::node($item->_id)->bajada;
         $article['date'] = array('published' => date('Y-m-d\\TH:i:sP', \Rpp\Services\Get\Content::node($item->_id)->fecha_publicacion), 'updated' => date('Y-m-d\\TH:i:sP', \Rpp\Services\Get\Content::node($item->_id)->fecha_publicacion));
         $article['id'] = $item->_id;
         $image = $audio = $video = array();
         $texto_nota = $relacionado = array();
         if (\Rpp\Services\Get\Content::part($item->_id, 'tipo') == 'galeria') {
             $galeria = $gitem = array();
             foreach (\Rpp\Services\Get\Content::part($item->_id, 'galeria') as $v => $key) {
                 $gitem[] = array('title' => @\Rpp\Services\Get\Content::part($item->_id, 'contenido')[$key]['alt'], 'author' => @\Rpp\Services\Get\Content::part($item->_id, 'contenido')[$key]['credito'], 'description' => @\Rpp\Services\Get\Content::part($item->_id, 'contenido')[$key]['alt'], 'id' => 0, 'url' => \Rpp\Services\Get\UrlMedia::image(\Rpp\Services\Get\Content::part($item->_id, 'contenido')[$key]['foto']['hash'], 'medium'), 'thumbnail' => \Rpp\Services\Get\UrlMedia::image(\Rpp\Services\Get\Content::part($item->_id, 'contenido')[$key]['foto']['hash'], 'small'));
                 \Rpp\Services\Get\Content::unset_part($item->_id, 'contenido', $key);
             }
             $galeria[0]['images'] = $gitem;
             $article['slideshows'] = $galeria;
         }
         foreach (\Rpp\Services\Get\Content::part($item->_id, 'contenido') as $contenido) {
             if ($contenido['tipo'] == 'photo') {
                 $image[] = array('title' => @$contenido['foto']['alt'], 'autor' => @$contenido['credito'], 'description' => @$contenido['foto']['alt'], 'id' => 0, 'url' => \Rpp\Services\Get\UrlMedia::image($contenido['foto']['hash'], 'medium'), 'thumbnail' => \Rpp\Services\Get\UrlMedia::image($contenido['foto']['hash'], 'samll'));
             } elseif ($contenido['tipo'] == 'video') {
                 $video[] = array('title' => @$contenido['video']['alt'], 'autor' => @$contenido['via'], 'description' => @$contenido['foto']['alt'], 'id' => 0, 'size' => 17791133, 'duration' => 10, 'url' => @$contenido['video']['url'], 'thumbnail' => @$contenido['video']['url_cover']);
             } elseif ($contenido['tipo'] == 'audio') {
                 $audio[] = array('title' => @$contenido['audio']['alt'], 'autor' => @$contenido['via'], 'description' => @$contenido['audio']['alt'], 'id' => 0, 'size' => 1547822, 'duration' => 10, 'url' => @$contenido['audio']['url'], 'thumbnail' => @$contenido['audio']['url_cover']);
             } elseif ($contenido['tipo'] == 'text') {
                 $texto_nota[] = strip_tags($contenido['texto']);
                 if (count(@$contenido['relacionado']['items']) > 0) {
                     foreach ($contenido['relacionado']['items'] as $value) {
                         $relacionado[] = array('rel' => 'related', 'href' => \Rpp\Services\Get\Content::nurl($value['nid']), 'mediaType' => 'text/html', 'thumbnail' => \Rpp\Services\Get\UrlMedia::image(\Rpp\Services\Get\Content::node($value['nid'])->imagen_portada['hash'], 'samll'), 'title' => \Rpp\Services\Get\Content::node($value['nid'])->imagen_portada['alt'], 'author' => 'RPP', 'description' => \Rpp\Services\Get\Content::node($value['nid'])->bajada);
                     }
                 }
             }
         }
         $keywords = array();
         foreach (\Rpp\Services\Get\Content::part($item->_id, 'keywords') as $value) {
             $keywords[] = $value['nombre'];
         }
         $article['images'] = $image;
         $article['videos'] = $video;
         $article['audio'] = $audio;
         $article['title'] = \Rpp\Services\Get\Content::node($item->_id)->titulo;
         $article['subtitle'] = \Rpp\Services\Get\Content::node($item->_id)->titulo_corto;
         $article['body'] = implode(' ', $texto_nota);
         $article['keywords'] = $keywords;
         $article['relatedLinks'] = $relacionado;
         $result[] = $article;
     }
     echo json_encode(array('items' => $result));
 }
Esempio n. 2
0
 private function reload_categoria($categoria)
 {
     foreach ($categoria as $seccion_slug) {
         $seccion_slug = explode("/", $seccion_slug);
         unset($seccion_slug[0]);
         if (count($seccion_slug) > 0) {
             for ($i = count($seccion_slug); $i > 0; $i--) {
                 \Rpp\Services\Get\Flow::seccion(implode('/', $seccion_slug));
                 unset($seccion_slug[$i]);
             }
         }
     }
 }
Esempio n. 3
0
      <article class="flow-prominent">
              <?php 
foreach (\Rpp\Services\Get\Flow::seccion($this->model->slug, 1) as $item) {
    ?>
                    <h1> <a href="<?php 
    echo \Rpp\Services\Get\Content::nurl($item->_id);
    echo \Rpp\Services\Get\UrlTrack::add_params(1);
    ?>
"><?php 
    echo \Rpp\Services\Get\Content::node($item->_id)->titulo_corto;
    ?>
</a></h1>
                    <div class="prominent-media">
                   <?php 
    foreach (\Rpp\Services\Get\Content::part($item->_id, 'contenido') as $contenido) {
        ?>
                 
                      <?php 
        if ($contenido['tipo'] == 'photo') {
            ?>
                      <figure class="media"><a href="<?php 
            echo \Rpp\Services\Get\Content::nurl($item->_id);
            echo \Rpp\Services\Get\UrlTrack::add_params(1);
            ?>
"><img src="<?php 
            echo $contenido['foto']['url'];
            ?>
" alt="<?php 
            echo $contenido['foto']['alt'];
            ?>
" width="445" height="251"></a></figure>
Esempio n. 4
0
<?php

$e = 0;
foreach (\Rpp\Services\Get\Flow::seccion($slug, 50, 1) as $item) {
    ?>
    <?php 
    echo $this->partial('partials/portada/flujo/box/normal', array('nid' => $item->_id, 'position' => $e + 1));
    $e++;
}
Esempio n. 5
0
 public function make($user)
 {
     Cache::request()->save('analitica.recomendadas.rebuild' . $user, true, Cache::get_conf()->cache_time->analitica_user_recomendados_rebuild);
     $intervalos_timeline = array(12, 24, 36, 48, 60, 72, 84, 96, 108, 120);
     /*intervalos de timeline*/
     $hot_minimo_numero = 2;
     $nids_view = array();
     $nids_suggested = array();
     $secciones_rank_timeline = array();
     $tag_rank_timeline = array();
     foreach ($intervalos_timeline as $intervalo) {
         $now = $intervalo - 12;
         $notas_muestra = $this->redis->zRangeByScore(user_notas . $user, strtotime("-{$intervalo} hours"), strtotime("-{$now} hours"), array('limit' => array(0, 20)));
         $notas_muestra = array_reverse($notas_muestra);
         foreach ($notas_muestra as $time_nid) {
             $time_nid = explode(":", $time_nid);
             //var_dump("[", date("Y:m:d G:i:s",$time_nid[1]) , " ]");
             $nids_view[$time_nid[0]] = $time_nid[0];
             $mtags = \Rpp\Services\Get\Content::part($time_nid[0], 'tags');
             if (is_array($mtags)) {
                 foreach ($mtags as $tag) {
                     if (isset($tag_rank_timeline[$tag['slug']])) {
                         $tag_rank_timeline[$tag['slug']]++;
                     } else {
                         $tag_rank_timeline[$tag['slug']] = 1;
                     }
                 }
             }
             $categoria = \Rpp\Services\Get\Content::part($time_nid[0], 'categoria')['slug'];
             if (isset($secciones_rank_timeline[$categoria])) {
                 $secciones_rank_timeline[$categoria]++;
             } else {
                 $secciones_rank_timeline[$categoria] = 1;
             }
         }
     }
     arsort($tag_rank_timeline);
     arsort($secciones_rank_timeline);
     $portadas_view_rank = array();
     foreach ($intervalos_timeline as $intervalo) {
         $now = $intervalo - 12;
         $portadas_view = $this->redis->zRangeByScore(user_portadas . $user, strtotime("-{$intervalo} hours"), strtotime("-{$now} hours"), array('limit' => array(0, 20)));
         foreach ($portadas_view as $portada) {
             $time_portada = explode(":", $portada);
             if (isset($portadas_view_rank[$time_portada[0]])) {
                 $portadas_view_rank[$time_portada[0]]++;
             } else {
                 $portadas_view_rank[$time_portada[0]] = 1;
             }
         }
     }
     arsort($portadas_view_rank);
     $nids_portada_top = array();
     /*nids de la portada hot*/
     if (count($portadas_view_rank) > 0) {
         foreach ($portadas_view_rank as $portada => $rank) {
             if ($rank >= $hot_minimo_numero) {
                 $portada = str_replace(".", "/", $portada);
                 foreach (\Rpp\Services\Get\Flow::seccion($portada, 30) as $node) {
                     $nids_portada_top[$node->_id] = $node->_id;
                 }
                 break;
             } else {
                 break;
             }
         }
     }
     /*var_dump("<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>");
              $ultimas_temas = $this->redis->zRevRange(user_temas.$user, 0,50, true);  
     
              foreach ($ultimas_temas as $tema => $time) {
              	$tema = explode(":", $tema);
              	var_dump("[",date("Y:m:d h:i:s",$time)," => ", $tema[0] , " ]");
              }
     
              var_dump("<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>");
              $ultimas_search = $this->redis->zRevRange(user_search.$user, 0,50, true);
              foreach ($ultimas_search as $search => $time) {
              	var_dump("[",date("Y:m:d h:i:s",$time)," => ", $search , " ]");
              }*/
     $nids_suggested[1] = array();
     $nids_suggested[2] = array();
     $nids_suggested[3] = array();
     $tags_top = array_slice($tag_rank_timeline, 0, 3);
     $secciones_top = array_slice($secciones_rank_timeline, 0, 3);
     if (count($tags_top) > 0) {
         $tags_slug = array_keys($tags_top);
         $SearchPatternBuilder = new SearchPatternBuilder(new \Rpp\Repositorio\Builder\Search\Pattern\Tag());
         $Pattern = $SearchPatternBuilder->addFields(array("_id"))->addFilter(array("tags.slug" => $tags_slug[0]))->addLimit(20)->build();
         $result = $Pattern->load();
         foreach ($result as $suggested) {
             $nids_suggested[1][$suggested->_id] = $suggested->_id;
         }
         $Pattern = $SearchPatternBuilder->addFilter(array("tags.slug" => array('$in' => $tags_slug)))->build();
         $result = $Pattern->load();
         foreach ($result as $suggested) {
             $nids_suggested[3][$suggested->_id] = $suggested->_id;
         }
         array_pop($tags_top);
         if (count($tags_top) > 0) {
             $tags_slug = array_keys($tags_top);
             $Pattern = $SearchPatternBuilder->addFilter(array("tags.slug" => $tags_slug[0]))->build();
             $result = $Pattern->load();
             foreach ($result as $suggested) {
                 $nids_suggested[1][$suggested->_id] = $suggested->_id;
             }
             $Pattern = $SearchPatternBuilder->addFilter(array("tags.slug" => array('$in' => $tags_slug)))->build();
             $result = $Pattern->load();
             foreach ($result as $suggested) {
                 $nids_suggested[2][$suggested->_id] = $suggested->_id;
             }
         }
     }
     $add = 20;
     $top_rangos = array(3 => 20, 2 => 40, 1 => 60);
     $notas_by_tops = array();
     $sugeridas_news_calculate[3] = array();
     $sugeridas_news_calculate[2] = array();
     $sugeridas_news_calculate[1] = array();
     foreach ($top_rangos as $id => $rango) {
         $notas_by_tops[$id] = $this->redis->zRevRangeByScore(SITESLUG . ':notas:views', 10000000, 0, array('withscores' => TRUE, 'limit' => array($rango - $add, $rango)));
         $notas_by_tops[$id] = array_reverse(array_keys($notas_by_tops[$id]));
         $notas_by_tops[$id] = array_combine($notas_by_tops[$id], $notas_by_tops[$id]);
     }
     foreach ($notas_by_tops as $id => $top) {
         $notas_by_tops[$id] = array_diff($top, $nids_view);
     }
     foreach ($nids_suggested as $id => $suggested) {
         $nids_suggested[$id] = array_diff($suggested, $nids_view);
     }
     $nids_portada_top = array_diff($nids_portada_top, $nids_view);
     $sugeridas_portadas_calculate = array();
     $levels = array(3, 2, 1);
     foreach ($levels as $lsuge) {
         $sugeridas_news_calculate['level'][$lsuge] = array();
         foreach ($levels as $ltops) {
             $sugeridas_news_calculate['level'][$lsuge] = $sugeridas_news_calculate['level'][$lsuge] + array_intersect($nids_suggested[$lsuge], $notas_by_tops[$ltops]);
         }
     }
     foreach ($levels as $ltops) {
         $sugeridas_portadas_calculate = $sugeridas_portadas_calculate + array_intersect($nids_portada_top, $notas_by_tops[$ltops]);
     }
     $nids_sugeridos = array();
     $nids_sugeridos = array_slice($sugeridas_news_calculate['level'][3], 0, 3, true) + array_slice($sugeridas_portadas_calculate, 0, 2, true) + array_slice($sugeridas_news_calculate['level'][3], 3, 6, true) + array_slice($sugeridas_portadas_calculate, 2, 2, true) + array_slice($sugeridas_news_calculate['level'][3], 6, 20, true) + array_slice($sugeridas_news_calculate['level'][2], 0, 3, true) + array_slice($sugeridas_portadas_calculate, 4, 8, true) + array_slice($sugeridas_news_calculate['level'][2], 3, true) + $sugeridas_news_calculate['level'][1];
     $nids_sugeridos = array_slice($nids_sugeridos, 0, 15, true);
     Cache::request()->save('analitica.recomendadas.' . $user, $nids_sugeridos, Cache::get_conf()->cache_time->analitica_user_recomendados);
     $this->viewCache->delete('sidebar.recomendados.' . $user);
     var_dump(Cache::request()->get('analitica.recomendadas.' . $user));
 }