/** * de-activate constructor */ private final function __construct() { $config = Pandamp_Config::getConfig(); $zl = Zend_Registry::get('Zend_Locale'); if ($zl->getLanguage() == "id") { self::$_schema = $config->web->db->ina; } else { self::$_schema = $config->web->db->en; } }
/** * Get global cache instance * * @return Zend_Cache_Core */ public static function getInstance() { $config = Pandamp_Config::getConfig(); if (!isset($config->cache->frontend) || !isset($config->cache->backend)) { return null; } $frontendOptions = $config->cache->frontend->options->toArray(); $backendOptions = $config->cache->backend->options->toArray(); $frontendOptions = self::_replaceConst($frontendOptions); $backendOptions = self::_replaceConst($backendOptions); return Zend_Cache::factory($config->cache->frontend->name, $config->cache->backend->name, $frontendOptions, $backendOptions); }
/** * Add link to sitemap */ public function addAction() { $this->_helper->getHelper('layout')->disableLayout(); $this->_helper->getHelper('viewRenderer')->setNoRender(); $config = Pandamp_Config::getConfig(); $file = ROOT_DIR . DS . 'sitemap_news.xml'; $output = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">' . PHP_EOL; //$folderGuid = array('fb16','lt4a0a533e31979','fb29'); $profileGuid = array('article', 'klinik', 'kutu_peraturan'); $rowset = App_Model_Show_Catalog::show()->fetchNewsCatalog($profileGuid, 0, 50); foreach ($rowset as $row) { if ($row['profileGuid'] == 'klinik') { $clinicTitle = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($row['guid'], 'fixedCommentTitle'); $url = $config->web->url->base . DS . 'klinik' . DS . 'detail' . DS . $row['guid'] . DS . App_Model_Show_CatalogAttribute::show()->getFormatedURLForKlinikTitle($clinicTitle); } else { if ($row['profileGuid'] == 'kutu_peraturan') { $peraturanTitle = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($row['guid'], 'fixedTitle'); $peraturanSubTitle = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($row['guid'], 'fixedSubTitle'); $url = $config->web->url->base . DS . 'pusatdata' . DS . 'detail' . DS . $row['guid'] . DS . 'node' . DS . $row['folderGuid'] . DS . App_Model_Show_CatalogAttribute::show()->getFormatedURLForDetalPeraturan($peraturanTitle, $peraturanSubTitle); } else { $url = $config->web->url->base . DS . 'berita' . DS . 'baca' . DS . $row['guid'] . DS . $row['shortTitle']; } } $loc = $url; $pubDate = date('D, d M Y h:i:s O', strtotime($row['publishedDate'])); $keywords = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($row['guid'], 'fixedKeywords'); //$item = new Pandamp_Seo_Sitemap_Item($loc, $pubDate); //Pandamp_Seo_Sitemap::addToSitemap($file, $item); $output .= "\t<url>" . "\n"; $output .= "\t\t<loc>" . "\n"; $output .= "\t\t\t{$loc}" . "\n"; $output .= "\t\t</loc>" . "\n"; $output .= "\t\t<news:news>" . "\n"; $output .= "\t\t\t<news:publication_date>" . "\n"; $output .= "\t\t\t\t{$pubDate}" . "\n"; $output .= "\t\t\t</news:publication_date>" . "\n"; if ($keywords) { $output .= "\t\t\t<news:keywords>" . "\n"; $output .= "\t\t\t\t{$keywords}" . "\n"; $output .= "\t\t\t</news:keywords>" . "\n"; } $output .= "\t\t</news:news>" . "\n"; $output .= "\t</url>" . "\n"; } $output .= '</urlset>'; /** * Write to file */ $f = fopen($file, 'w'); fwrite($f, $output); fclose($f); return true; }
public function sendReceiptToUser($orderId, $paymentMethod = '') { $config = new Zend_Config_Ini(CONFIG_PATH . '/mail.ini', 'mail'); $siteOwner = "Hukumonline"; $siteName = $config->mail->sender->support->name; $contactEmail = $config->mail->sender->support->email; $tblOrder = new App_Model_Db_Table_Order(); $rowOrder = $tblOrder->find($orderId)->current(); $userId = $rowOrder->userId; //first check if orderId status is PAID, then send the email. switch ($rowOrder->orderStatus) { case 1: die('ORDER STATUS IS NOT YET PAID. CAN NOT SEND RECEIPT!.'); break; case 3: $orderStatus = "PAID"; break; case 5: $orderStatus = "POSTPAID PENDING"; break; case 6: $orderStatus = "PAYMENT REJECTED"; break; case 7: $orderStatus = "PAYMENT ERROR"; break; default: $orderStatus = "PAYMENT ERROR"; break; } $tblUser = new App_Model_Db_Table_User(); $rowUser = $tblUser->find($userId)->current(); $userEmail = $rowUser->email; $userFullname = $rowUser->fullName; $registry = Zend_Registry::getInstance(); $config = $registry->get(Pandamp_Keys::REGISTRY_APP_OBJECT); $store = $config->getOption('store'); $cEmail = new Zend_Config_Ini(CONFIG_PATH . '/mail.ini', 'mail'); $holConfig = Pandamp_Config::getConfig(); switch (strtolower($rowOrder->paymentMethod)) { case 'paypal': case 'manual': case 'bank': case 'postpaid': default: $message = "\t\t\t\t\t\nDear {$userFullname},\n\nThis is a payment receipt for Invoice # {$rowOrder->invoiceNumber}\n\nTotal Amount: IDR {$rowOrder->orderTotal}\nTransaction #:\nTotal Paid: IDR {$rowOrder->orderTotal}\nStatus: {$orderStatus}\nYour payment method is: {$paymentMethod}\n\nYou may review your invoice history at any time by logging in to your account " . $holConfig->cdn->id->url . "/user/payment/list\n\nNote: This email will serve as an official receipt for this payment.\n\nSalam,\n\nHUKUMONLINE\n\n=============================="; } $this->send($cEmail->mail->sender->support->email, $cEmail->mail->sender->support->name, $userEmail, $userFullname, "[HUKUMONLINE] Receipt Invoice# " . $rowOrder->invoiceNumber, $message); }
public function selectAuthor($attributes = array()) { $selectedId = isset($attributes['selected']) ? $attributes['selected'] : null; $disableId = isset($attributes['disable']) ? $attributes['disable'] : null; $config = Pandamp_Config::getConfig(); $cache = Pandamp_Cache::getInstance(); $output = "<select onchange='javascript:document.peraturan.submit();' class='{$attributes['class']}' name='{$attributes['name']}' id='{$attributes['id']}'>" . self::EOL . '<option value="">All</option>' . self::EOL; $author = App_Model_Show_Catalog::show()->getAuthor($attributes['profile']); for ($i = 0; $i < count($author); $i++) { if (empty($author[$i]['author'])) { continue; } if (isset($author[$i]['author'])) { $selected = $selectedId == null || $selectedId != $author[$i]['author'] ? '' : ' selected="selected"'; $disable = $disableId == null || $disableId != $author[$i]['author'] ? '' : ' disabled'; $output .= sprintf('<option value="%s"%s%s>%s</option>', $author[$i]['author'], $selected, $disable, $author[$i]['author']) . self::EOL; } } $output .= '</select>' . self::EOL; return $output; }
public function getShareCount($catalogGuid, $social) { $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); if (null === $viewRenderer->view) { $viewRenderer->initView(); } $view = $viewRenderer->view; $config = Pandamp_Config::getConfig(); $catalogs = App_Model_Show_Catalog::show()->getCatalogByGuid($catalogGuid); if ($catalogs && !in_array($catalogs['profileGuid'], array('partner', 'author', 'kategoriklinik'))) { if (in_array($catalogs['profileGuid'], ['article', 'isuhangat'])) { $uri = "berita/baca/" . $catalogs['guid'] . "/" . $catalogs['shortTitle']; } else { if ($catalogs['profileGuid'] == 'klinik') { $uri = "klinik/detail/" . $catalogs['guid'] . "/" . $catalogs['shortTitle']; } else { if (in_array($catalogs['profileGuid'], array('kutu_putusan', 'kutu_peraturan', 'kutu_rancangan_peraturan', 'kutu_peraturan_kolonial'))) { $node = $view->getNode($catalogs['guid']); $lnode = $view->getLabelNode($node); $uri = "pusatdata/detail/" . $catalogs['guid'] . "/" . $lnode . "/" . $node . "/" . $catalogs['shortTitle']; } } } $url = $config->web->url->base . DS . $uri; $sharecount = new Pandamp_Lib_ShareCount($url); switch ($social) { case 'facebook': return $sharecount->get_fb(); break; case 'twitter': return $sharecount->get_tweets(); break; } } return; }
/** * Compress the JavaScripts or CSS files * * @param string $type Can be js or css * @param string $prefix * @return Core_View_Helper_Compressor The compressor instance */ public function compressor($type = 'js', $prefix = 'head') { $type = strtolower($type); $this->_type = $type; /** * Check whether the compression is enable or not */ $config = Pandamp_Config::getConfig(); $compressCss = isset($config->cache->compress->css) ? (string) $config->cache->compress->css : 'false'; $compressJs = isset($config->cache->compress->js) ? (string) $config->cache->compress->js : 'false'; if ($type == 'css' && $compressCss == 'false') { $return = $this->view->headLink()->toString() . $this->view->headStyle()->toString(); return $return; } elseif ($type == 'js' && $compressJs == 'false') { $return = $this->view->headScript()->toString(); $this->_resetHeadScript(); return $return; } $request = Zend_Controller_Front::getInstance()->getRequest(); $module = $request->getModuleName(); $controller = $request->getControllerName(); $action = $request->getActionName(); $cacheFile = md5(implode('_', array($prefix, $module, $controller, $action))) . '.' . $type; /** * Build cache dir and URL to show cache data */ $cacheDir = TEMP_DIR . DS . 'cache' . DS . $type; $htaccess = $cacheDir . DS . '.htaccess'; if (!file_exists($cacheDir)) { mkdir($cacheDir); } /** * Create .htaccess file that allows browser to access */ if (!file_exists($htaccess)) { if ($fp = fopen($htaccess, 'wb')) { fwrite($fp, 'Allow from all'); fclose($fp); } } $staticUrl = $config->web->static_server; $cachePath = $cacheDir . DS . $cacheFile; $this->_cacheUrl = $staticUrl . '/temp/cache/' . $type . '/' . $cacheFile; $files = array(); $urls = array(); $cssStyles = array(); $jsScripts = array(); switch ($type) { case 'css': $iterator = $this->view->headLink()->getIterator(); foreach ($iterator as $item) { if ($item->type == 'text/css') { $urls[] = $item->href; } } $styleIterator = $this->view->headStyle()->getIterator(); foreach ($styleIterator as $item) { $cssStyles[] = $item->content; } break; case 'js': $iterator = $this->view->headScript()->getIterator(); foreach ($iterator as $item) { if ($item->source == null) { $urls[] = $item->attributes['src']; } else { $jsScripts[] = $item->source; } } $this->_resetHeadScript(); break; } if (count($urls) == 0) { return ''; } $start = strlen($staticUrl); foreach ($urls as $url) { if (substr($url, 0, $start) == $staticUrl) { $url = substr($url, $start); $url = ltrim($url, '/'); $url = str_replace('/', DS, $url); $url = ROOT_DIR . DS . $url; } $files[] = $url; } /** * Compare the timestamp of the cached file with * timestamp of all included file */ $maxTimeStamp = 0; foreach ($files as $index => $f) { if (file_exists($f)) { $maxTimeStamp = max($maxTimeStamp, filemtime($f)); } } if (file_exists($cachePath) && $maxTimeStamp > filemtime($cachePath)) { unlink($cachePath); } if (!file_exists($cachePath)) { $content = ''; switch ($type) { case 'css': foreach ($files as $index => $f) { $path = pathinfo($f); $url = $urls[$index]; $url = substr($url, 0, -strlen($path['basename'])); $url = rtrim($url, '/'); $str = file_get_contents($f); /** * Replace value of background and background-image properties * with the full URL. * We have to handle some expressions: * - background: #Color_Code url(images/...) * - background-image: url(images/...) * - background: url('images/...') * - jQueryUI theme (/js/jquery.ui/themes/base/ui.theme.css) */ $str = preg_replace("/background([-image]*):(\\s*)([#0-9a-zA-Z]*)([\\/\\*\\{a-zA-Z\\}\\*\\/]*)(\\s*)url\\(([']*)images\\/([\\w-.]+)([']*)\\)/", 'background$1: $3 url(' . $url . '/images/$7)', $str); $content .= "\n\n" . trim($str); } foreach ($cssStyles as $style) { $content .= "\n\n" . trim($style); } /** * Use CSSTidy to compress CSS content */ require_once 'csstidy/class.csstidy.php'; $csstidy = new csstidy(); $csstidy->set_cfg('remove_last_;', true); $csstidy->load_template(self::$_CSS_COMPRESS); $csstidy->parse($content); $content = $csstidy->print->plain(); break; case 'js': require_once 'jsmin/jsmin.php'; foreach ($files as $index => $f) { if (file_exists($f)) { $str = file_get_contents($f); } else { $str = file_get_contents($urls[$index]); } $content .= "\n\n" . trim(JSMin::minify($str)); } foreach ($jsScripts as $script) { $content .= "\n\n" . trim(JSMin::minify($script)); } break; } if ($fp = fopen($cachePath, 'wb')) { fwrite($fp, $content); fclose($fp); } } return $this; }
public function fetchCountCatalogShortenerAction() { $this->_helper->layout->disableLayout(); $request = $this->getRequest(); $catalogGuid = $request->getParam('guid'); $config = Pandamp_Config::getConfig(); $modelCatalog = App_Model_Show_Catalog::show()->getCatalogByGuid($catalogGuid); $short = ""; if ($modelCatalog['profileGuid'] == 'article') { $uri = "berita/baca/" . $modelCatalog['guid'] . "/" . $modelCatalog['shortTitle']; } else { if ($modelCatalog['profileGuid'] == 'klinik') { $uri = "klinik/detail/" . $modelCatalog['guid'] . "/" . $modelCatalog['shortTitle']; } else { if (in_array($modelCatalog['profileGuid'], array('kutu_putusan', 'kutu_peraturan', 'kutu_rancangan_peraturan', 'kutu_peraturan_kolonial'))) { $node = $this->view->getNode($modelCatalog['guid']); $lnode = $this->view->getLabelNode($node); $uri = "pusatdata/detail/" . $modelCatalog['guid'] . "/" . $lnode . "/" . $node . "/" . $modelCatalog['shortTitle']; } } } $url = $config->web->url->base . DS . $uri; $urlDb = new App_Model_Db_Table_Url(); $shortid = $urlDb->fetchRow("url = '" . $url . "'"); if (isset($shortid->id)) { $hex = dechex($shortid->id); $short = $config->web->url->short . '/' . $hex; } $this->view->assign('guid', $catalogGuid); $this->view->assign('shortUrl', $short); }