public function getFeed($socmedType)
 {
     $ch = new NewsChannel();
     $ch->getDefaultChannel();
     $cat = isset($_GET['cat']) ? addslashes($_GET['cat']) : $ch->channel_id;
     $limit = 10;
     $np = new SocmedPortal();
     $arrEv = $np->getByChannel($cat, " and socmed_type = {$socmedType} ORDER BY socmed_id DESC LIMIT 0,{$limit}");
     return $arrEv;
 }
 public function getFeed()
 {
     $ch = new NewsChannel();
     $ch->getDefaultChannel();
     $cat = isset($_GET['cat']) ? addslashes($_GET['cat']) : $ch->channel_id;
     $limit = 1;
     $np = new VideoPortal();
     $np->default_read_coloms = "video_upload, video_external_link ,video_id,video_title,news_validity_begin,news_channel_id,news_author";
     $arrEv = $np->getByChannelAndIsValid($cat, " AND video_status = 'publish' ORDER BY news_validity_begin DESC LIMIT 0,{$limit}");
     return $arrEv;
 }
    public function createCarousel()
    {
        $n = new NewsChannel();
        $n->getDefaultChannel();
        /*
         * TODO : filter news
         */
        $c = new CarouselPortal();
        $arrPic = $c->getByChannelAndIsValid($n->channel_id, " AND carousel_active = 1 ORDER BY news_validity_begin DESC");
        //$arrPic = $db->query($q, 2);
        ?>
        <style>
            #maincarousel .carousel {
                max-height: 380px;
                overflow: hidden;

            }

            #maincarousel .carousel .item img {
                width: 100%;
                height: auto;
            }

            #maincarousel .carousel-caption2 {
                position: absolute;
                margin-top: 290px;
                z-index: 3;
                color: white;
                padding-left: 20px;
                width: 100%;
                background-color: rgba(0, 0, 0, 0.2);
                font-family: verdana;
                height: 90px;
            }

            @media screen and (min-width: 768px) {
                #maincarousel .carousel-indicators {
                    bottom: -5px;
                }
                #maincarousel .carousel-caption2 h3{
                    font-size: 20px;
                }
	            .carousel-inner{height:380px;}
            }

            @media (max-width: 768px) {

                #maincarousel .carousel {
                    max-height: 250px;
                    overflow: hidden;

                }

                #maincarousel .carousel-caption2 {
                    position: absolute;
                    margin-top: 170px;
                    z-index: 3;
                    color: white;
                    padding-left: 20px;
                    width: 100%;
                    background-color: rgba(0, 0, 0, 0.2);
                    font-family: verdana;

                    height: 90px;
                }

                #maincarousel .carousel-caption2 h3 {
                    font-size: 12px;
                }
                #maincarousel .carousel-indicators {
                    bottom: -5px;
                }
            }
        </style>
        <div id="maincarousel">

            <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
                <!-- Indicators -->
                <ol class="carousel-indicators">
                    <?php 
        foreach ($arrPic as $num => $c) {
            ?>
                        <li data-target="#carousel-example-generic" data-slide-to="<?php 
            echo $num;
            ?>
"
                            <?php 
            if ($num == 0) {
                ?>
class="active"<?php 
            }
            ?>
></li>
                    <?php 
        }
        ?>
                </ol>

                <!-- Wrapper for slides -->
                <div class="carousel-inner">
                    <?php 
        $gw = new GalleryWeb();
        foreach ($arrPic as $num => $c) {
            ?>
                        <div class="item <?php 
            if ($num == 0) {
                ?>
active<?php 
            }
            ?>
">
                            <div class="carousel-caption2">
                                <h3 style="cursor:pointer;  " onclick="document.location='<?php 
            echo _SPPATH;
            ?>
page?id=<?php 
            echo $c->carousel_page_id;
            ?>
';"><?php 
            echo stripslashes($c->carousel_title);
            ?>
</h3>
                            </div>
	                        <img onload="fixmyheight('<?php 
            echo $c->carousel_id;
            ?>
');" id="carc_<?php 
            echo $c->carousel_id;
            ?>
"  width="100%" src="<?php 
            echo _SPPATH . $gw->uploadURL . $c->carousel_photo;
            ?>
" alt="<?php 
            echo $c->carousel_title;
            ?>
">

                        </div>
                    <?php 
        }
        ?>


                </div>

                <!-- Controls -->
                <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
                    <span class="glyphicon glyphicon-chevron-left"></span>
                </a>
                <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
                    <span class="glyphicon glyphicon-chevron-right"></span>
                </a>
            </div>
            <!-- Carousel -->
        </div><!-- Main Carousel -->
	    <script>
		    /*
		     $(window).resize(function(){
		     var wit = $('.carousel-inner').width();
		     var heit = $('.carousel-inner').height();
		     console.log('w : '+wit+' h : '+heit);

		     });*/
		    function fixmyheight(id) {
			    var mywit = $('#carc_' + id).width();
			    var myheit = $('#carc_' + id).height();

			    var boxheit = $('.carousel-inner').height();
			    var boxwit = $('.carousel-inner').width();
			    if (myheit < boxheit) {
				    var mynewheit = boxheit;
				    $('#carc_' + id).height(mynewheit);

				    var perbedaan = mynewheit * mywit / myheit;
				    $('#carc_' + id).width(perbedaan);
			    }
		    }
	    </script>
    <?php 
    }
    public static function portalIndex()
    {
        $ch = new NewsChannel();
        $ch->getDefaultChannel();
        $cat = isset($_GET['cat']) ? addslashes($_GET['cat']) : $ch->channel_id;
        //get channel
        $arrCh = $ch->getWhere("channel_active = 1 AND channel_type = 'content'");
        $limit = 30;
        $np = new NewsPortal();
        $np->default_read_coloms = "news_page_id,news_image,news_id,news_title,news_validity_begin,news_channel_id,news_author";
        $arrEv = $np->getByChannelAndIsValid($cat, " AND news_status = 'publish' ORDER BY news_validity_begin DESC");
        //$jumlah = $np->getJumlahByChannelAndIsValid($cat," AND news_status = 'publish'");
        //pr($arrE);
        //pr($arrE);
        ?>
		<style>
			.news-item {
				height           : 60px;
				background-color : #e8e9d7;
				width            : 100%;
				font-family      : verdana;
				font-size        : 13px;
			}

			.white {
				background-color : #efefef;
			}

			.news-item .nfoto {
				float       : left;
				margin     : 5px;
				width       : 50px;
				height      : 50px;
				overflow    : hidden;
				margin-left : 5px;
			}

			.news-item .nfoto img {

			}

			.news-item .nmessage {
				margin-left : 65px;
				padding-top : 5px;
			}
                        .news-item .nmessage a{
				color:#555;
                                
			}
			.news-containter {
				height     : 332px;
				overflow-y : auto;
			}

			#newsfeed .viewmore {
				background-color : #e8e9d7;
				width            : 100%;
				height           : 40px;
				line-height      : 40px;
				text-align       : center;
				font-weight      : bold;
				letter-spacing   : 2px;
				cursor           : pointer;

			}

			.ago {
				font-style : italic;
				font-size  : 11px;
                                color:#888;
			}

			#newsfeed_category_selector {
				background-color : #dedede;
				padding          : 10px;
			}

			.newsfeed_selectbox {
				float : right;
				color : #555;
			}

			.newsfeed_selectbox select {
			<?php 
        $bgcolor = ThemeReg::mod("portlet_headbgcolor", "#038563", "color");
        $bgimage = ThemeReg::mod("portlet_headbg", _SPPATH . _THEMEPATH . "/images/h3bg2.jpg", "image");
        $strbgimage = '';
        if ($bgimage != "") {
            $strbgimage = 'background-image: url("' . $bgimage . '");';
        }
        $textcolor = ThemeReg::mod("portlet_headtextcolor", "#fff", "color");
        ?>
 background     : <?php 
        echo $bgcolor;
        ?>
;
			<?php 
        echo $strbgimage;
        ?>
 // background : #038563;
				color         : <?php 
        echo $textcolor;
        ?>
;
				border        : 0px;
				text-align    : right;
				padding-right : 10px;
			}

			.newsfeed_selectbox select option {
				text-align : right;
			}
		</style>

		<div class="col-md-8 col-md-offset-2">
			<h1 class="tbsh1"
			    style="margin-bottom:20px;">

				<i class="glyphicon glyphicon-th-large"
				   style="top:5px;"></i>
				<?php 
        echo Lang::t('News');
        ?>
				<div style="float:right;">
					<select class="form-control"
					        id="selectnewsfeed"
					        dir="rtl"
					        onchange="document.location='<?php 
        echo _SPPATH;
        ?>
newsfeed?cat='+$('#selectnewsfeed').val();">
						<?php 
        foreach ($arrCh as $ct => $chna) {
            if (NewsChannel::isSubscribe($chna->channel_id)) {
                ?>
								<option value="<?php 
                echo $chna->channel_id;
                ?>
" <?php 
                if ($cat == $chna->channel_id) {
                    echo "selected";
                }
                ?>
><?php 
                echo $chna->channel_name;
                ?>
</option>
							<?php 
            }
        }
        ?>
					</select>

				</div>

			</h1>

			<?php 
        $gw = new GalleryWeb();
        $activemon = "";
        foreach ($arrEv as $num => $ev) {
            $vname = stripslashes($ev->news_title);
            if (strlen($vname) > 60) {
                $vname = substr($vname, 0, 60) . "...";
            }
            ?>
				<div class="news-item <?php 
            if ($num % 2 == 1) {
                echo 'white';
            }
            ?>
">
					<div class="nfoto">
						<img onload="OnImageLoad(event,50);"
						     src="<?php 
            $url = _SPPATH . $gw->uploadURL . "thumbnail/" . $ev->news_image;
            if (NewsFeedWeb::isExists($url)) {
                echo $url;
            } else {
                echo _SPPATH . $gw->uploadURL . $ev->news_image;
            }
            ?>
">
					</div>
					<div class="nmessage">
						<a href="<?php 
            echo _SPPATH;
            ?>
page?id=<?php 
            echo $ev->news_page_id;
            ?>
"><?php 
            echo $vname;
            ?>
</a>

						<div class="ago">
							<?php 
            echo ago(strtotime($ev->news_validity_begin));
            ?>
						</div>
					</div>
				</div>
			<?php 
        }
        ?>
		</div>
	<?php 
    }
    public function chart()
    {
        //masi tidak benar logicnya
        $n = new NewsChannel();
        $n->getDefaultChannel();
        /*
         * TODO : filter news
         */
        $c = new PopUp();
        $arrPic = $c->getByChannelAndIsValid($n->channel_id, " AND news_tag = 'statistic' ORDER BY news_validity_begin DESC LIMIT 0,1");
        $obj = $arrPic[0];
        $cnt = 0;
        if ($obj->pop_file != "") {
            $cnt++;
        }
        if ($obj->pop_donut != "") {
            $cnt++;
        }
        ?>
    <style>
        .mfp-bg{
            background: rgba(0,0,0,0.7);
        }
        
    </style>
    <div onclick="$.magnificPopup.close();" class="container" style="padding: 20px; border-radius: 10px; background-color: #fff; text-align: center;">
    <?php 
        if ($obj->pop_file != "") {
            ?>
    <div class="<?php 
            if ($cnt == 2) {
                ?>
col-md-6<?php 
            } else {
                ?>
col-md-8 col-md-offset-2<?php 
            }
            ?>
">
        <?php 
            $this->printPopChart($obj);
            ?>
    </div>
    <?php 
        }
        ?>
    <?php 
        if ($obj->pop_donut != "") {
            ?>
    <div class="<?php 
            if ($cnt == 2) {
                ?>
col-md-6<?php 
            } else {
                ?>
col-md-8 col-md-offset-2<?php 
            }
            ?>
">
        <?php 
            $this->printDonutChart($obj);
            ?>
 
    </div>
     <?php 
        }
        ?>
</div>
    
            
            <?php 
        if ($_GET['ex'] || $ex) {
            exit;
        }
    }
    function printQuote()
    {
        $n = new NewsChannel();
        $n->getDefaultChannel();
        $arrQuote = $this->getByChannelAndIsValid($n->channel_id, " AND quote_active = 1 ORDER BY news_validity_begin DESC LIMIT 0,1");
        //pr($arrQuote);
        $quote = $arrQuote[0];
        /*
        global $db;
        
        $q = "SELECT * FROM {$this->table_name} ORDER BY quote_id DESC LIMIT 0,1";
        $quote = $db->query($q, 1);
        */
        $quote->quote_msg_indonesia = trim(preg_replace('/\\s\\s+/', ' ', $quote->quote_msg_indonesia));
        $quote->quote_msg = trim(preg_replace('/\\s\\s+/', ' ', $quote->quote_msg));
        ?>
        <style>
            .quote-item {
                <?php 
        $bgitem = ThemeReg::mod("quote_color", "#758536", "color");
        ?>
                background-color: <?php 
        echo $bgitem;
        ?>
;
                color: white;
                text-align: center;
                font-size: 15px;
                font-family: verdana;
                font-weight: bold;
                height: 94px;
            // line-height : 80 px;
            // padding : 10 px;
            }

            .quote-msg {
                font-style: italic;
            }

            .quote-padder {
                padding: 25px 20px;
            }

            @media (max-width: 768px) {

                .quote-padder {
                    padding: 15px 20px;
                }

                .quote-item {
                    font-size: 13px;
                }
            }
        </style>
        <div class="quote-item">
            <div id="quotemsg1" class="quote-padder">
                <span  class="quote-msg">"<?php 
        echo stripslashes($quote->quote_msg);
        ?>
"</span>
                                
                <span class="quote-author"> - <?php 
        echo $quote->quote_author;
        ?>
</span>
            </div>
        </div>
        <?php 
        if (isset($quote->quote_msg_indonesia)) {
            ?>
        <script>
$(document).ready(function(){
    var cur = 1;
    function slideshow() {
        if (cur >= 1) {
            cur = 0;
        } else {
            cur++;
        }
        setTimeout(function(){
            $("#quotemsg1").fadeOut(400, function(){
            if(cur == 1)
                $("#quotemsg1").empty().append("<span  class='quote-msg'><?php 
            echo stripslashes(nl2br($quote->quote_msg_indonesia));
            ?>
</span><span class='quote-author'> - <?php 
            echo $quote->quote_author;
            ?>
</span>");
            else
                $("#quotemsg1").empty().append("<span  class='quote-msg'><?php 
            echo stripslashes(nl2br($quote->quote_msg));
            ?>
</span><span class='quote-author'> - <?php 
            echo $quote->quote_author;
            ?>
</span>");
            $("#quotemsg1").fadeIn(400);
            });
            slideshow();
        }, 6000);
    }
    slideshow();
});
    
 
            </script>
        <?php 
        }
        ?>
    <?php 
    }