public static function getAllParents($id, $arrParent) { if ($id < 1) { return $arrParent; } $cat = new ProdCat(); $cat->getByID($id); if ($cat->cat_id) { $arrParent[] = $cat; return self::getAllParents($cat->cat_parent_id, $arrParent); } else { return $arrParent; } }
public function p($arg) { list($id, $judul) = $arg; $arrkirim = array(); if ($id < 1 || $id == "") { die("NO ID"); } $_SESSION['hist_prod'] = array("id" => $id, "judul" => $judul); $_SESSION['hist_url'] = _LANGPATH . "pwa/p/{$id}/" . urlencode($judul); $p = new ProdModel(); $p->getByID($id); if ($p->prod_active < 1) { header("Location:" . _LANGPATH . "p404"); exit; } global $template; $template->title = $p->prod_name; $src = self::getMainPic($p); if ($p->prod_diskon > 0) { $hrgbaru = ceil((100 - $p->prod_diskon) / 100 * $p->prod_price); } else { $hrgbaru = $p->prod_price; } $cp = new CampaignProdMatrix(); $arr = $cp->getWhere("cm_prod_id = '{$id}'"); $cp_id = $arr[0]->cm_camp_id; $cp = new CampaignModel(); $cp->getByID($cp_id); $cw = new Cw(); // $cw->campaign_header($cp_id, $cp); //process image $exp = explode(",", $p->prod_pic); $sudah = array(); $arrImg = array(); if (count($exp) > 1) { $if = new InputFileModel(); foreach ($exp as $num => $img) { if (!in_array($img, $sudah)) { $sudah[] = $img; $srcs = _SPPATH . $if->upload_url . "thumbnail/" . $img; $srcs_big = _SPPATH . $if->upload_url . $img; $cl = 'class="nonaktif"'; if ($src["thumbs"] == $srcs) { $cl = 'class="aktif"'; } // $id = base64_encode($srcs); $arrImg[$num] = array($srcs, $srcs_big, $cl); } } } //process category $cat = new ProdCat(); $cat->getByID($p->prod_cat_id); $arrParent = array(); $arrpp = ProdCat::getAllParents($cat->cat_parent_id, $arrParent); //pr($arrpp); $arrpp2 = array_reverse($arrpp); foreach ($arrpp2 as $bc) { $str[] = $bc->cat_name; } $str[] = $cat->cat_name; // $str2 = "<a href='" . _LANGPATH . "pwa/category/" . urlencode($cat->cat_name) . "'>".$cat->cat_name . "</a>"; //bypass roy //$str2 = $cat->cat_name; $arrCat = $str; $arrkirim['p'] = $p; $arrkirim['id'] = $id; $arrkirim['cp'] = $cp; $arrkirim['arrImg'] = $arrImg; $arrkirim['arrCat'] = $arrCat; $arrkirim['hargaafterdiskon'] = $hrgbaru; $arrkirim['src'] = $src; $layout_id = "eComm_product"; $file = Layout::getFile($layout_id); // echo "Pages/".$layout_id."/".$file; Mold::theme("Pages/" . $layout_id . "/" . $file, $arrkirim); }