function viewme($id, $classname, $classID)
 {
     $this->getByID($id);
     $gp = new Galleryphoto();
     $arrCar = $gp->getWhere("photo_filename !='' AND gallery_id = '{$this->gallery_id}'  ORDER BY photo_zindex DESC ");
     //pr($arrCar);
     $arr['id'] = $id;
     $arr['arrCar'] = $arrCar;
     //        Mold::theme("Pages/Carousel_attachment",$arr);
     $layout_id = "Carousel_attachment";
     $file = Layout::getFile($layout_id);
     //        echo "Pages/".$layout_id."/".$file;
     Mold::theme("Pages/" . $layout_id . "/" . $file, $arr);
 }
 function id($args)
 {
     list($id, $name) = $args;
     $id = tin($id);
     $gal = new Gallery();
     $gal->getByID($id);
     //        pr($gal);
     $gs = new Galleryphoto();
     $arrPic = $gs->getWhere("gallery_id = '{$id}' ORDER BY photo_zindex DESC");
     $arr['gal'] = $gal;
     $arr['id'] = $id;
     $arr['arrPic'] = $arrPic;
     $layout_id = "Gallery_id";
     $file = Layout::getFile($layout_id);
     //        echo "Pages/".$layout_id."/".$file;
     Mold::theme("Pages/" . $layout_id . "/" . $file, $arr);
     //        Mold::theme("Pages/Gallery_id",$arr);
 }
    function pictureInsert()
    {
        $gp = new Galleryphoto();
        $gid = isset($_GET['gid']) ? addslashes($_GET['gid']) : '0';
        if ($gid == '0') {
            die("Please provide ID");
        }
        $img = isset($_GET['img']) ? addslashes($_GET['img']) : 0;
        if ($img) {
            $gp->gallery_id = $gid;
            $gp->photo_filename = $img;
            $gp->photo_date = leap_mysqldate();
            $gp->save();
        }
        $arrCar = $gp->getWhere("photo_filename !='' AND gallery_id = '{$gid}'  ORDER BY photo_date DESC ");
        //pr($arrCar);
        foreach ($arrCar as $num => $pic) {
            ?>
            <div class="gp_thumb thumbnail col-md-2">
                <div style="position:absolute;width: 10px; height: 10px;">
                    <input <?php 
            if ($pic->photo_mainpic) {
                echo 'checked="true"';
            }
            ?>
  type="checkbox" onclick="gallery_setmainpic(<?php 
            echo $pic->photo_id;
            ?>
,<?php 
            echo $gid;
            ?>
);">
                </div>

                <img style="cursor:pointer;" onclick="gallery_openpicture(<?php 
            echo $pic->photo_id;
            ?>
,<?php 
            echo $gid;
            ?>
);"
                     class="img-responsive"
                     src="<?php 
            echo _SPPATH;
            echo $this->uploadURLThumb;
            echo $pic->photo_filename;
            ?>
">

                <div class="gp_menu">
                    <button type="button"
                            onclick="if(confirm('<?php 
            echo Lang::t("Are You Sure?");
            ?>
'))gallery_deletephoto(<?php 
            echo $pic->photo_id;
            ?>
);"
                            class="btn btn-default"><?php 
            echo Lang::t('delete');
            ?>
</button>
                </div>
            </div>

        <?php 
        }
    }
 function movezIndex()
 {
     $pid = isset($_GET['pid']) ? addslashes($_GET['pid']) : 0;
     if ($pid == 0) {
         die('No ID');
     }
     $gid = isset($_GET['gid']) ? addslashes($_GET['gid']) : '0';
     if ($gid == '0') {
         die("Please provide ID");
     }
     $act = isset($_GET['act']) ? addslashes($_GET['act']) : 'left';
     $gp = new Galleryphoto();
     $gp->getByID($pid);
     $currentpos = $gp->photo_zindex;
     //        echo "curr ".$currentpos;
     if ($act == "left") {
         $desired = $currentpos + 1;
     } else {
         $desired = $currentpos - 1;
     }
     //        echo "desired ".$desired;
     $gp->photo_zindex = $desired;
     $gp->load = 1;
     $arrWhe = $gp->getWhere("photo_zindex = '{$desired}' AND gallery_id = '{$gid}'");
     $desiredItem = $arrWhe[0];
     $desiredItem->photo_zindex = $currentpos;
     $desiredItem->load = 1;
     echo $gp->save();
     $desiredItem->save();
     //        echo " desired end ".$desiredItem->photo_zindex;
     //        echo " cur end ".$gp->photo_zindex;
 }