public function overwriteRead($return)
 {
     $objs = $return['objs'];
     foreach ($objs as $obj) {
         if (isset($obj->news_postdate)) {
             $obj->news_postdate = date("d-m-Y", strtotime($obj->news_postdate));
         }
         if (isset($obj->news_updatedate)) {
             $obj->news_updatedate = date("d-m-Y", strtotime($obj->news_updatedate));
         }
         if (isset($obj->news_validity_begin)) {
             $obj->news_validity_begin = date("d-m-Y", strtotime($obj->news_validity_begin));
         }
         if (isset($obj->news_validity_end)) {
             $obj->news_validity_end = date("d-m-Y", strtotime($obj->news_validity_end));
         }
         if (isset($obj->news_author)) {
             $acc = new Account();
             $acc->getByID($obj->news_author);
             $obj->news_author = $acc->admin_nama_depan;
         }
         if (isset($obj->news_channel_id)) {
             $acc = new NewsChannel();
             $acc->getByID($obj->news_channel_id);
             $obj->news_channel_id = $acc->channel_name;
         }
     }
     //pr($return);
     return $return;
 }
 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 overwriteRead($return)
 {
     $objs = $return['objs'];
     foreach ($objs as $obj) {
         if (isset($obj->webapps_channel_id)) {
             $acc = new NewsChannel();
             $acc->getByID($obj->webapps_channel_id);
             $obj->webapps_channel_id = $acc->channel_name;
         }
     }
     //pr($return);
     return $return;
 }
    public static function portalIndex()
    {
        $mode = isset($_GET['mode']) ? addslashes($_GET['mode']) : die('no mode');
        if ($mode < 1) {
            die("mode hrs integer");
        }
        /*
         * LOAD page con, cek apakah bisa ini sub atau main con
         */
        $a = NewsChannel::myChannels();
        //pr($a);
        foreach ($a as $chn) {
            $str = " page_channel_id = '{$chn}' ";
            $imp[] = $str;
        }
        $wherechannel = implode("OR", $imp);
        $wherechannel = "(" . $wherechannel . ")";
        $pc = new PageContainer();
        $pc->getByID($mode);
        $gw = new GalleryWeb();
        if ($pc->container_parent_id == 0) {
            //self::subconMenu($mode);
            $class = "col-md-7 col-md-offset-1";
            $yangdipakai = "post_gallery_id";
        } else {
            $pc2 = new PageContainer();
            $pc2->getByID($pc->container_parent_id);
            $breadcrumbs = "<a href='" . _SPPATH . "pagecontainer?mode=" . $pc2->container_id . "'>" . $pc2->container_name . "</a> / <a href='" . _SPPATH . "pagecontainer?mode=" . $pc->container_id . "'>" . $pc->container_name . "</a>";
            $class = "col-md-8 col-md-offset-2";
            $yangdipakai = "post_subcon_id";
        }
        $s = isset($_GET['s']) ? addslashes($_GET['s']) : "";
        $halaman = isset($_GET['p']) ? addslashes($_GET['p']) : 1;
        $limit = 10;
        $begin = ($halaman - 1) * $limit;
        $searchText = "";
        if ($s != "") {
            $searchText = " AND ( post_title LIKE '%{$s}%' OR post_content LIKE '%{$s}%')";
        }
        $page = new Page();
        $whereClause = "{$yangdipakai} = '{$mode}' AND post_status = 'publish' AND {$wherechannel} {$searchText}";
        $arrPage = $page->getWhere($whereClause . " ORDER BY post_modified DESC LIMIT {$begin},{$limit}");
        $jml = $page->getJumlah($whereClause);
        if (count($arrPage) == 0) {
            ?>
<h3><?php 
            echo Lang::t('No Page on this category yet');
            ?>
</h3>    
            <?php 
            return "";
        }
        ?>

<div class="<?php 
        echo $class;
        ?>
">
    <?php 
        echo $breadcrumbs;
        ?>
    <h1 class="tbsh1" style="margin-bottom:20px;">
            <div style="float: right; width: 200px;">
                <div class="input-group">
                    <input id="seachtext" type="text" value="<?php 
        echo $s;
        ?>
" class="form-control" placeholder="search <?php 
        echo $pc->container_name;
        ?>
">
                    <span class="input-group-btn">
                        <button onclick="document.location='<?php 
        echo _SPPATH;
        ?>
pagecontainer?mode=<?php 
        echo $mode;
        ?>
&s='+$('#seachtext').val();" class="btn btn-default" type="button">
                            <i class="glyphicon glyphicon-search"></i>
                        </button>
                    </span>
                    <script>
                    $("#seachtext").keyup(function(){
                        if (event.keyCode == 13) { //on enter
                        var slc = $('#seachtext').val();
                        document.location='<?php 
        echo _SPPATH;
        ?>
pagecontainer?mode=<?php 
        echo $mode;
        ?>
&s='+$('#seachtext').val();
                        }
                    });
                    </script>
              </div><!-- /input-group -->
            </div>
            <?php 
        echo $pc->container_name;
        ?>
        </h1>    
        <style>
    .post-title{
        font-size: 18px !important;
        color:#333 !important;
        font-weight: bold;
    }
    .post-title a{
        color:#555 !important;
    }
</style>    
        <?php 
        foreach ($arrPage as $num => $p) {
            ?>
               <div class="post-preview">
                   <div class="col-md-4">
                       <img class="img-responsive" src="<?php 
            echo _SPPATH . $gw->uploadURL . $p->post_image;
            ?>
">
                   </div>
                   <div class="col-md-8">
                       <div style="padding-left:10px;">
                       <div class="post-meta"><?php 
            echo indonesian_date($p->post_modified);
            ?>
</div>
                        <div class="post-title">
                            <a href="<?php 
            echo _SPPATH;
            ?>
page?id=<?php 
            echo $p->ID;
            ?>
">
                            <?php 
            echo stripslashes($p->post_title);
            ?>
                            </a>
                        </div>
                        <div class="post-subtitle">
                            
                            <?php 
            echo substr(stripslashes(strip_tags($p->post_content)), 0, 100);
            ?>
                            <?php 
            if (strlen($p->post_content) > 100) {
                ?>
                            ...
                            <?php 
            }
            ?>
<br>
                            <a href="<?php 
            echo _SPPATH;
            ?>
page?id=<?php 
            echo $p->ID;
            ?>
">
                            <?php 
            echo Lang::t('read more');
            ?>
                            </a>
                        </div>
                       </div>
                   </div>
                    
                   <div class="clearfix"></div>
                </div>
                <?php 
            if ($num < count($arrPage) - 1) {
                ?>
                <hr> 
                <?php 
            }
            ?>
                <style>
                    .post-meta{
                        font-size: 14px;
                        padding-top: 0;
                        margin-top: 0;
                    }
                    .post-title{
                        margin-bottom: 0;
                        margin-top: 0;
                        padding: 0;
                    }
                    .post-subtitle{
                        padding-top: 10px;
                    }
                    .buttonefi{
                        margin: 0 auto; text-align: center; font-weight: bold; cursor: pointer; background-color: #dedede; border-radius: 5px; padding: 10px; margin: 10px;
                    }
                    .buttonefi:hover{
                        background-color: #efefef;
                    }
                </style>
             <?php 
        }
        $jmlpage = ceil($jml / $limit);
        ?>
                  
                
 <nav>
  <ul class="pagination">
      <?php 
        if ($halaman > 1) {
            ?>
    <li><a href="<?php 
            echo _SPPATH;
            ?>
pagecontainer?mode=<?php 
            echo $mode;
            ?>
&s=<?php 
            echo $s;
            ?>
&p=<?php 
            echo $halaman - 1;
            ?>
"><span aria-hidden="true">&laquo;</span><span class="sr-only">Previous</span></a></li>
    <?php 
        }
        ?>
    <?php 
        //ambil 3 bh terdekat //
        $mulai = $halaman - 2;
        $akhir = $halaman + 2;
        //echo $mulai.$akhir;
        $min = max($mulai, 1);
        $max = min($akhir, $jmlpage);
        //echo "<br> max :".$max;
        //echo "<br> min :".$min;
        for ($x = $min; $x <= $max; $x++) {
            ?>
    
    <li <?php 
            if ($x == $halaman) {
                ?>
class="active"<?php 
            }
            ?>
><a href="<?php 
            echo _SPPATH;
            ?>
pagecontainer?mode=<?php 
            echo $mode;
            ?>
&s=<?php 
            echo $s;
            ?>
&p=<?php 
            echo $x;
            ?>
"><?php 
            echo $x;
            ?>
</a></li>
    <?php 
        }
        ?>
    
    <?php 
        if ($jml > $begin + $limit) {
            ?>
    <li><a href="<?php 
            echo _SPPATH;
            ?>
pagecontainer?mode=<?php 
            echo $mode;
            ?>
&s=<?php 
            echo $s;
            ?>
&p=<?php 
            echo $halaman + 1;
            ?>
"><span aria-hidden="true">&raquo;</span><span class="sr-only">Next</span></a></li>
    <?php 
        }
        ?>
  </ul>
</nav>
        <h4><?php 
        echo $jml;
        ?>
 results in <?php 
        echo $jmlpage;
        ?>
 pages</h4>  
</div><?php 
        if ($pc->container_parent_id == 0) {
            self::subconMenu($mode);
            //$class = "col-md-7";
        }
    }
 public static function getMyChannels()
 {
     if (class_exists("NewsChannel")) {
         return NewsChannel::myChannels();
     } else {
         return array();
     }
 }
    public function NewsChannelMatrix()
    {
        $t = time();
        //create matrix to adjust menu
        $ro = new RoleOrganization();
        $arr = $ro->getWhere("organization_active = 1");
        $chn = new NewsChannel();
        $arrChn = $chn->getWhere("channel_active = 1");
        $curlvl = "";
        ?>
<script>
    var channelSelected = [];
</script>
<style>
    select option.no_text{
        color: #dedede !important;
    }
    .selectchannel{
       
        margin-bottom:30px;
    }
    .buttonselectchannel{
        border-radius: 5px;
        background-color: #efefef; 
        float:left;
        padding: 10px;
        margin: 5px;
        cursor:pointer;
    }
    .buttonselectchannelactive{
        background-color: #bbb;
        text-decoration:line-through;
    }
</style>
<div class="selectchannel">
    <?php 
        foreach ($arrChn as $ch) {
            ?>
    <div class="buttonselectchannel buttonselectchannelactive" id="chan_<?php 
            echo $ch->channel_id;
            ?>
_<?php 
            echo $t;
            ?>
"><?php 
            echo $ch->channel_name;
            ?>
</div>
    <script>
        $("#chan_<?php 
            echo $ch->channel_id;
            ?>
_<?php 
            echo $t;
            ?>
").click(function(){
            for(var x in channelSelected){
                //console.log(x+" in2222 "+channelSelected[x]);
                $("#chan_"+channelSelected[x]+"_<?php 
            echo $t;
            ?>
").addClass("buttonselectchannelactive");
                $('.channel_form_'+channelSelected[x]).hide();
            }
            var index = jQuery.inArray("<?php 
            echo $ch->channel_id;
            ?>
", channelSelected);
            //console.log(index);
            if(index == -1){
                channelSelected.push("<?php 
            echo $ch->channel_id;
            ?>
");
            }else{
                //var index2 = channelSelected.indexOf("<?php 
            echo $ch->channel_id;
            ?>
");
                channelSelected.splice(index,1);
                /*$("#chan_"+channelSelected[index2]+"_<?php 
            echo $t;
            ?>
").removeClass("buttonselectchannelactive");
                console.log("in");
                console.log(index2);
                for(var x in channelSelected){
                  if(channelSelected[x] =="<?php 
            echo $ch->channel_id;
            ?>
" )
                        channelSelected.splice(x,1);
                        $("#chan_"+channelSelected[x]+"_<?php 
            echo $t;
            ?>
").removeClass("buttonselectchannelactive");
                }*/
            }
            
            for(var x in channelSelected){
                //console.log(x+" in "+channelSelected[x]);
                $("#chan_"+channelSelected[x]+"_<?php 
            echo $t;
            ?>
").removeClass("buttonselectchannelactive");
                $('.channel_form_'+channelSelected[x]).show();
            }
        });
    </script>
    <?php 
        }
        ?>
</div>
<div  style="margin-bottom:20px; clear:both;"></div>
<div class="table-responsive">
    <table class="table table-bordered table-striped table-hover">
        <thead>
            <tr>
                <td><?php 
        echo Lang::t('Department');
        ?>
</td>
                <?php 
        foreach ($arrChn as $ch) {
            ?>
                <td  style="display:none;" class="channel_form_<?php 
            echo $ch->channel_id;
            ?>
"><?php 
            echo $ch->channel_name;
            ?>
</td>
                <?php 
        }
        ?>
            </tr>
        </thead>
        <tbody>
            <?php 
        $rl = new RoleLevel();
        $existingRoles = $rl->getWhere("level_active = 1 ORDER BY level_tingkatan ASC");
        $nc = new NewsChannel2Org();
        $arrNC = $nc->getAll();
        if (isset($arrNC)) {
            foreach ($arrNC as $cn) {
                $arrNN[$cn->c2d_id] = $cn;
            }
        }
        //pr($existingRoles);
        foreach ($arr as $org) {
            if ($org->organization_id == '1') {
                continue;
            }
            ?>
            <tr>
                <td><?php 
            echo $org->organization_name;
            ?>
</td>
                <?php 
            foreach ($arrChn as $ch) {
                $menu = $org->organization_id . "_" . $ch->channel_id;
                ?>
                <td class="channel_form_<?php 
                echo $ch->channel_id;
                ?>
" style="display:none;">
                    <select id="role_lvl_<?php 
                echo $menu;
                ?>
_<?php 
                echo $t;
                ?>
">
                        <option class="no_text" value="no"></option>
                <?php 
                foreach ($existingRoles as $ro) {
                    $id = $ch->channel_id . "_" . $org->organization_id;
                    $curlvl = "0";
                    if (isset($arrNN[$id])) {
                        $curlvl = $arrNN[$id]->c2d_level_id;
                    }
                    ?>
                
                        <option value="<?php 
                    echo $ro->level_id;
                    ?>
" <?php 
                    if ($ro->level_id == $curlvl) {
                        echo "selected";
                    }
                    ?>
><?php 
                    echo $ro->level_name;
                    ?>
</option>
                <?php 
                }
                ?>
                    </select>
                    <script>
                    $("#role_lvl_<?php 
                echo $menu;
                ?>
_<?php 
                echo $t;
                ?>
").change(function(){
                        
                       var slc = $("#role_lvl_<?php 
                echo $menu;
                ?>
_<?php 
                echo $t;
                ?>
").val();
                       //if(slc != "no")
                       $.get("<?php 
                echo _SPPATH;
                ?>
NewsChannelWeb/ins?org=<?php 
                echo $org->organization_id;
                ?>
&chn=<?php 
                echo $ch->channel_id;
                ?>
&level_id="+slc,function(data){
                           //alert(data);
                       }); 
                    });    
                    </script>
                </td>
                <?php 
            }
            ?>
            </tr>
            <?php 
        }
        ?>
        </tbody>
       
    </table>
</div>    
        <?php 
    }
    public function show()
    {
        $url = $_GET['gurl'];
        $id = addslashes($_GET['id']);
        if ($id < 0) {
            die("no ID");
        }
        //Log
        BLogger::addLog("file_id = {$id}", "open_file");
        //echo $url;echo "<br>";
        //echo $id;
        $auth = 1;
        $if = new InputFileModel();
        if ($url == "dm") {
            $if = new DocumentsPortal();
            //cek parent id ada 2 "company policy"
            /*
            			$d = new DMWeb();
            			$arrCHild2 = $d->findChildren(2);
            			$arrCHild = explode(",", $arrCHild2);
            * 
            */
            //pr($arrCHild);
            //Perbaikan 27 Feb 2015
            // Cek parents terluarnya apakah dia saveable
            $if->getByID($id);
            //grand grand parents- init folder - folder awal
            $InitparentsFolder = $if->findInitParent();
            //folder simpannya
            $terletakDiFolder = new DocumentsPortalFolder();
            $terletakDiFolder->getByID($if->file_folder_id);
            //pr($InitparentsFolder);
            //cek KMType nya
            //untuk cek channel
            /*
             * LOAD page con, cek apakah bisa ini sub atau main con
             */
            $a = NewsChannel::myChannels();
            //pr($a);
            /*foreach($a as $chn){
                  $str = " page_channel_id = '$chn' ";
                  $imp[] = $str;
              }
              $wherechannel = implode("OR", $imp);
              $wherechannel = "(".$wherechannel.")";
              */
            $kmtype = new KMType();
            $arrKMTYPE = $kmtype->getWhere("km_folder_id = '{$InitparentsFolder->folder_id}'");
            //kalau punya channel id nya
            if (in_array($arrKMTYPE[0]->webapps_channel_id, $a)) {
                //boleh masuk
            } else {
                if ($_SESSION['DocumentPortal_view_only'] < 1) {
                } else {
                    //nggak boleh lihat
                    $auth = 0;
                }
                //die('Not Authorized To View this Documents');
            }
        }
        if ($auth) {
            $if->getByID($id);
            /*
             * cek folder if apakah ada di child
             */
            //if ($if->file_folder_id == 2 || in_array($if->file_folder_id, $arrCHild)) {
            if (!$InitparentsFolder->folder_saveable) {
                $if->bolehsave = "reg";
                //nosave
            } else {
                $if->bolehsave = "als";
                //save
            }
            //pr($if);
            $path = _SPPATH . $if->upload_url;
            $fil = $if->file_filename;
            $inp = new \Leap\View\InputFile();
            if (in_array($if->file_ext, $inp->arrImgExt)) {
                $this->showImage($if);
            } elseif (in_array($if->file_ext, $inp->arrVideoExt)) {
                $this->showVideo($if);
            } elseif ($if->file_ext == "pdf") {
                $this->showPDF($if);
            } else {
                $this->showDefault($if);
            }
        } else {
            ?>
<h2><?php 
            echo Lang::t('Not Authorized to view this documents');
            ?>
</h2>    
                    <?php 
        }
        //else auth
    }
$c->p();
?>
                <span class="help-block" id="warning_post_files"></span>
    </div>
</div>
  
  
  <!-- channel tambahan -->
  <div id="formgroup_page_channel_id" class="form-group">
        <label for="page_channel_id" class="col-sm-2 control-label"><?php 
echo Lang::t('page_channel_id');
?>
</label>
        <div class="col-sm-10">
            <?php 
$gal2 = new NewsChannel();
$arrGal = $gal2->getWhere("channel_active =1 AND channel_type = 'content' ORDER BY channel_name ASC");
?>
            <select class="form-control" name="page_channel_id" id="page_channel_id">
                
                <?php 
if (!isset($obj->page_channel_id) || $obj->page_channel_id < 1) {
    $obj->page_channel_id = 1;
}
foreach ($arrGal as $gal) {
    ?>
                <option <?php 
    if ($gal->channel_id == $obj->page_channel_id) {
        echo "selected";
    }
    ?>
 public function loadSubscription()
 {
     //get all channels
     $channel = new NewsChannel();
     $arrChannel = $channel->getWhere("channel_active = 1");
     //get my level and org
     $org = RoleOrganization::getMy();
     $lvl = RoleLevel::getMy();
     foreach ($arrChannel as $chn) {
         $id = $chn->channel_id . "_" . $org->organization_id;
         $n = new NewsChannel2Org();
         $n->getByID($id);
         if (isset($n->c2d_level_id) && $lvl->level_id >= $n->c2d_level_id && $n->c2d_level_id) {
             $_SESSION['newsfeed'][] = $chn->channel_id;
         }
     }
 }
    function p()
    {
        $id = isset($_GET['id']) ? addslashes($_GET['id']) : 0;
        if ($id) {
            $page = new Page();
            $page->getByID($id);
            if (!isset($page->post_title) || $page->post_title == '') {
                die('Not Found');
            }
            //add channel feb 2015
            $a = NewsChannel::myChannels();
            if ($page->page_channel_id > 0) {
                if (!in_array($page->page_channel_id, $a)) {
                    echo 'Not Authorize To View';
                    return "";
                }
            }
            $pc = new PageContainer();
            if ($page->post_gallery_id > 0) {
                $pc->getByID($page->post_gallery_id);
            }
            $page->setSEO();
            $gw = new GalleryWeb();
            ?>
			<style>
				.pl_file_item {
					padding          : 10px;
					clear            : both;
					text-decoration  : underline;
					color            : #0072b1;
					cursor           : pointer;
					margin           : 5px;
					background-color : #efefef;
				}

				.if_text {
					height      : 30px;
					line-height : 30px;
					float       : left;
					margin-left : 10px;
				}

				.fotoIF {
					width    : 30px;
					height   : 30px;
					overflow : hidden;
					float    : left;
				}

				.fotoIF img {
					width : 30px;
				}

				.h3pv {
					font-size      : 18px;
					border-bottom  : 1px dashed #333;
					padding-bottom : 10px;
					margin-bottom  : 0px;
				}
			</style>
			<h1 style="padding-bottom: 0; margin-bottom: 0; margin-bottom: 10px;"><?php 
            echo stripslashes($page->post_title);
            ?>
</h1>
			<div class="breadcrumbs">Pages
				<?php 
            if ($page->post_gallery_id > 0) {
                ?>
/
					<a href="<?php 
                echo _SPPATH;
                ?>
pagecontainer?mode=<?php 
                echo $pc->container_id;
                ?>
"><?php 
                echo $pc->container_name;
                ?>
</a><?php 
            }
            ?>
			</div>

			<small style="font-size: 12px;"><?php 
            echo indonesian_date($page->post_modified);
            ?>
</small>

			<?php 
            if ($page->post_image != "") {
                ?>
				<div class="bigimage"
				     style="padding-bottom: 10px;">
					<img style="width: 100%; padding-top: 20px;"
					     src="<?php 
                echo _SPPATH . $gw->uploadURL . $page->post_image;
                ?>
">
				</div>
			<?php 
            }
            ?>

			<div class="postcontent">
				<?php 
            $content = stripslashes($page->post_content);
            $content = str_replace('#tbs_video#', '<video id="player_normal" width="100%" controls src="', $content);
            $content = str_replace('#/tbs_video#', '"></video>', $content);
            echo $content;
            ?>
			</div>
			<?php 
            if ($page->post_files != "") {
                ?>
				<div class="clearfix"
				     style="padding:  10px;">

					<h3 class="h3pv"><?php 
                echo Lang::t('Attachments');
                ?>
</h3>
				</div>
				<div style="">
				<?php 
                $exp = explode(",", trim(rtrim($page->post_files)));
                $arrNames = array();
                foreach ($exp as $fil) {
                    // echo $fil."<br>";
                    if ($fil == "") {
                        continue;
                    }
                    $exp2 = explode(".", $fil);
                    $if = new \InputFileModel();
                    // echo $exp2[0]."<br>";
                    $if->getByID($exp2[0]);
                    $arrNames[] = $if;
                    $text .= $if->printLink();
                }
                echo $text;
                ?>
</div><?php 
            }
            ?>
			<?php 
            if ($page->comment_allowed) {
                ?>
				<div class="clearfix"
				     style="padding:  10px;"></div>
				<?php 
                PageCommentWeb::beginComment($id);
            }
            // pr($page);
            /* $str = '';
            			 global $template;
            			 if($page->post_gallery_id != 0 || $page->post_event_id != 0){
            
            				 if($page->post_event_id!=0){
            					 $event = new Event();
            					 $event->getByID($page->post_event_id);
            					// pr($event);
            					 $str .= '<div class="event-item"><div class="event-name">'.$event->cal_name.'</div></div>';
            					 $efi = new EfiHome();
            					 $_GET['eid'] = $page->post_event_id;
            					 $efi->eventview(1);
            				 }
            				 if($page->post_gallery_id!=0){
            					 $gal = new Gallery();
            					 $gal->getByID($page->post_gallery_id);
            					 //pr($gal);
            					 $str .= '<div class="gallery-item"><div class="gallery-name">'.$gal->gallery_name.'</div></div>';
            					 $efi = new EfiHome();
            					 $_GET['gid'] = $page->post_gallery_id;
            					 $efi->galleryview(1);
            				 }
            				 //$template->useSidebar = 1;
            				 //$template->sideBar = $str;
            			 }*/
            /*
            			 ?>
            			 <div class="fb-comments" data-href="http://developers.facebook.com/docs/plugins/comments/" data-width="100%" data-numposts="5" data-colorscheme="light"></div>
            			 <?*/
        }
    }
    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 
    }