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 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
    }
 public static function getMyChannels()
 {
     if (class_exists("NewsChannel")) {
         return NewsChannel::myChannels();
     } else {
         return array();
     }
 }
    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>
            			 <?*/
        }
    }