Exemplo n.º 1
0
    public static function renderSlidles()
    {
        if (count(self::$posts) > 0) {
            $posts10 = PostData::get10ByUserId(self::$user->id);
            $last_id = null;
            // recorremos todos los posts
            foreach ($posts10 as $post) {
                $post_id = $post->id;
                $post_title = $post->title;
                $post_content = $post->content;
                $theme = ThemeData::getById($post->theme_id);
                $header_background_color = $theme->header_background_color;
                $header_text_color = $theme->header_text_color;
                $body_background_color = $theme->body_background_color;
                $body_text_color = $theme->body_text_color;
                $content = $post_content;
                $buttons = "";
                $love_button = "";
                $user_id = self::$user->id;
                $loved = LoveData::LoveId($post->id);
                if ($loved == true) {
                    $love_button = '<button class="btn btn-danger"><i class="glyphicon glyphicon-heart"></i> Love It</button>';
                } else {
                    $love_button = <<<LLL
<button id="loveit-{$post_id}" class="btn btn-default "><i class="glyphicon glyphicon-heart"></i> Love It</button>
<script>
\$("#loveit-"+"{$post_id}").click(function(){
\txhr = new XMLHttpRequest();
\txhr.open("POST","index.php?view=loveit"+"&postid={$post_id}",false);
\txhr.send();
\tconsole.log(xhr.responseText);
\t\$("#loveit-"+"{$post_id}").removeClass("btn-default");
\t\$("#loveit-"+"{$post_id}").addClass("btn-danger");
});
</script>
LLL;
                }
                if ($post->image == null) {
                    $content = $post_content;
                }
                $buttons .= '<button id="reslidle-$post_id" class="btn btn-default "><i class="glyphicon glyphicon-th-large"></i> Reslidle It</button> ';
                $buttons .= $love_button;
                print <<<XXX
\t\t\t\t<div class="row">
\t\t\t\t\t<div class="col-md-12">
\t\t\t\t\t\t<div class="slide" style="box-shadow:-1px 1px 10px #999;">
\t\t\t\t\t\t\t<div class="header" style="background:{$header_background_color};color:{$header_text_color};padding:10px;">

\t\t\t\t\t\t\t\t<div class="btn-group pull-right">
\t\t\t\t\t\t\t\t  <button type="button" class="btn btn-link dropdown-toggle" data-toggle="dropdown">
\t\t\t\t\t\t\t\t<i class="glyphicon glyphicon-chevron-down"></i>
\t\t\t\t\t\t\t\t  </button>
\t\t\t\t\t\t\t\t  <ul class="dropdown-menu" role="menu">
\t\t\t\t\t\t\t\t    <li><a href="index.php?view=post&id={$post_id}" target="_blank"><i class="glyphicon glyphicon-eye-open"></i> Ver</a></li>
\t\t\t\t\t\t\t\t    <li><a href="index.php?view=editpost&id={$post_id}"><i class="glyphicon glyphicon-pencil"></i> Editar</a></li>
\t\t\t\t\t\t\t\t    <li class="divider"></li>
\t\t\t\t\t\t\t\t    <li><a href="#"><i class="glyphicon glyphicon-trash"></i> Eliminar</a></li>
\t\t\t\t\t\t\t\t  </ul>
\t\t\t\t\t\t\t\t</div>
\t\t\t
\t\t\t\t\t\t\t<div style="font-size:26px;">{$post_title}</div>
\t\t\t\t\t\t\t</div>

\t\t\t\t\t\t\t<div class="body" style="background:{$body_background_color};color:{$theme->body_text_color};padding:10px;font-size:18px;font-wieght:none;">
\t\t\t\t\t\t\t<p>{$content}</p>
\t\t\t\t\t\t\t<div class='pull-right'>
\t\t\t\t\t\t\t{$buttons}
\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t<div class='clearfix'></div>

\t\t\t\t\t\t\t</div>

\t\t\t\t\t\t</div>\t
\t\t\t\t\t\t<br>\t\t\t\t
\t\t\t\t\t</div>
\t\t\t\t</div>


XXX;
                $last_id = $post_id;
            }
            /// aqui termina el foreach
            if (count(self::$posts) > 10) {
                print "<div id='more-1'><button id='btn-more-1' class='btn btn-default btn-lg btn-block'><i class='glyphicon glyphicon-refresh'></i> Cargar mas ...</button></div>";
                print <<<MMM
\t\t\t<script>
\t\t\t\t\$("#btn-more-1").click(function(){
\t\t\t\t\txhr = new XMLHttpRequest();
\t\t\t\t\txhr.open("GET","loadsldl.php?uid={$user_id}&from={$last_id}&ref=2",false);
\t\t\t\t\txhr.send();
\t\t\t\t\t\$("#more-1").html(xhr.responseText);
\t\t\t\t});
\t\t\t</script>
MMM;
            }
        }
    }