Example #1
0
 function preDispatch()
 {
     $this->_helper->layout->setLayout('layout-store');
     $this->_helper->layout->setLayoutPath(array('layoutPath' => ROOT_DIR . '/app/modules/hol-site/layouts'));
     Zend_Session::start();
     $sReturn = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
     $sReturn = base64_encode($sReturn);
     $identity = Pandamp_Application::getResource('identity');
     $loginUrl = $identity->loginUrl;
     //$loginUrl = ROOT_URL.'/helper/synclogin/generate/?returnTo='.$sReturn;
     $auth = Zend_Auth::getInstance();
     if (!$auth->hasIdentity()) {
         $this->_redirect($loginUrl . '?returnTo=' . $sReturn);
         //$this->_redirect($loginUrl);
     } else {
         // [TODO] else: check if user has access to admin page
         $username = $auth->getIdentity()->username;
         $this->view->username = $username;
     }
     $userId = $auth->getIdentity()->guid;
     $this->_userId = $userId;
     $tblUserFinance = new Pandamp_Modules_Identity_UserFinance_Model_UserFinance();
     $this->_userInfo = $tblUserFinance->find($userId)->current();
     $storeConfig = Pandamp_Application::getOption('store');
     $this->_configStore = $storeConfig;
 }
Example #2
0
 public function runJobAction()
 {
     $resource = Pandamp_Application::getOption('resources')['multidb'];
     $options = array('name' => self::NAME_ORDERQUEUE, 'driverOptions' => array('host' => $resource['db1']['host'], 'port' => '3306', 'username' => $resource['db1']['username'], 'password' => $resource['db1']['password'], 'dbname' => $resource['db1']['dbname'], 'type' => $resource['db1']['adapter']));
     include_once 'Pandamp/Job/Queue.php';
     $queue = new Pandamp_Job_Queue('Db', $options);
     $queue->runJobs();
 }
Example #3
0
 function preDispatch()
 {
     $this->_helper->layout->setLayout('layout-store-checkout');
     Zend_Session::start();
     $storeConfig = Pandamp_Application::getOption('store');
     $this->_configStore = $storeConfig;
     $sReturn = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
     $sReturn = base64_encode($sReturn);
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $this->_user = $auth->getIdentity();
     }
 }
Example #4
0
 function preDispatch()
 {
     $this->_helper->layout->setLayout('layout-store');
     Zend_Session::start();
     $storeConfig = Pandamp_Application::getOption('store');
     $this->_configStore = $storeConfig;
     $sReturn = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
     $sReturn = base64_encode($sReturn);
     $auth = Zend_Auth::getInstance();
     //        $sso = new Pandamp_Session_Remote();
     //        $user = $sso->getInfo();
     if (!$auth->hasIdentity()) {
         //            $this->_helper->redirector('login','account','identity',array('sReturn'=>$sReturn));
     } else {
         $this->_user = $auth->getIdentity();
     }
 }
Example #5
0
 /**
  * Find images
  */
 public function findimageAction()
 {
     $request = $this->getRequest();
     $pageIndex = $request->getParam('pageIndex', 1);
     $perPage = $request->getParam('perpage');
     $perPage = $perPage ? $perPage : 20;
     $offset = ($pageIndex - 1) * $perPage;
     $params = null;
     $exp = array();
     $params = $request->getParam('q');
     if (null != $params) {
         $exp = rawurldecode(base64_decode($params));
         $exp = Zend_Json::decode($exp);
     } else {
         $params = rawurlencode(base64_encode(Zend_Json::encode($exp)));
     }
     $indexingEngine = Pandamp_Search::manager();
     if ($exp['keyword'] == '*' || $exp['keyword'] == '') {
         $exp['keyword'] = '*:*';
     }
     $hits = $indexingEngine->find($exp['keyword'] . ' mimeType:image* profile:kutu_doc', $offset, $perPage, 'createdDate desc');
     $solrNumFound = count($hits->response->docs);
     $num_rows = $hits->response->numFound;
     $paginator = Zend_Paginator::factory($num_rows);
     $cache = Pandamp_Cache::getInstance();
     if ($cache) {
         Zend_Paginator::setCache($cache);
     }
     $paginator->setCacheEnabled(true);
     $paginator->setCurrentPageNumber($pageIndex);
     $paginator->setItemCountPerPage($perPage);
     $paginator = get_object_vars($paginator->getPages('Sliding'));
     $paginatorOptions = array('path' => $this->view->url(array('lang' => $this->view->getLanguage()), 'search_catalog_findimage'), 'itemLink' => null == $params ? 'page-%d' : 'page-%d?perpage=' . $perPage . '&q=' . $params);
     /**
      * Support searching from other page
      * For example, search files at adding set page
      */
     if (isset($exp['format']) && $exp['format'] == 'JSON') {
         $this->_helper->getHelper('viewRenderer')->setNoRender();
         $this->_helper->getHelper('layout')->disableLayout();
         $config = Pandamp_Application::getOption('cdn');
         if ($solrNumFound > $perPage) {
             $numRowset = $perPage;
         } else {
             $numRowset = $solrNumFound;
         }
         $res = array('files' => array(), 'paginator' => $this->view->paginator()->slide($paginator, $paginatorOptions));
         for ($i = 0; $i < $numRowset; $i++) {
             $row = $hits->response->docs[$i];
             $fs = 'thumbnail_';
             //$filename = $row->systemName; <-- metode ini kadang suka kosong
             $filename = $this->view->getCatalogAttribute($row->id, 'docSystemName');
             $fn = pathinfo($filename, PATHINFO_FILENAME);
             $ext = pathinfo($filename, PATHINFO_EXTENSION);
             //$ext = strtolower($ext);
             if (substr($fn, 0, 2) !== 'lt') {
                 $fn = $row->id;
                 $fs = 'tn_';
                 $filename = $fn . '.' . strtolower($ext);
             }
             $title = $this->view->getCatalogAttribute($fn, 'fixedTitle');
             $relDb = new App_Model_Db_Table_RelatedItem();
             $rel = $relDb->fetchRow("itemGuid='" . $fn . "' AND relateAs='RELATED_IMAGE'");
             $relGuid = isset($rel->relatedGuid) ? $rel->relatedGuid : '';
             if (is_array(@getimagesize($config['static']['url']['images'] . '/' . $relGuid . '/' . $fs . $filename))) {
                 $url = $config['static']['url']['images'] . '/' . $relGuid . '/' . $fs . $filename;
             } elseif (is_array(@getimagesize($config['static']['url']['images'] . '/' . $fs . $filename))) {
                 $url = $config['static']['url']['images'] . '/' . $fs . $filename;
             } else {
                 $url = 'http://static.hukumonline.com/frontend/default/images/kaze/karticle-img.jpg';
             }
             //$url = $config['static']['url']['images'].'/'.$rel->relatedGuid.'/'.$rel->itemGuid.'.'.strtolower($ext);
             //$url = $config['static']['url']['images'].'/upload/'.$pd1.'/'.$pd2.'/'.$pd3.'/'.$pd4.'/'.$fn.'_square'.'.'.$ext;
             $res['files'][] = array('id' => isset($fn) ? $fn : '', 'relatedGuid' => isset($relGuid) ? $relGuid : '', 'title' => isset($title) ? $title : '', 'url' => isset($url) ? $url : '');
         }
         $this->getResponse()->setBody(Zend_Json::encode($res));
     }
 }
Example #6
0
 public function uploadAction()
 {
     $this->_helper->getHelper('viewRenderer')->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     $request = $this->getRequest();
     if (!$request->isPost()) {
         return;
     }
     $user = Zend_Auth::getInstance()->getIdentity();
     $userName = $user->username;
     $type = $request->getParam('type');
     $newguid = $request->getParam('guid');
     $cdn = Pandamp_Application::getOption('cdn');
     if ($type == 'file') {
         $dir = $cdn['static']['dir']['files'];
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $files = $adapter->getFileInfo();
         foreach ($files as $file => $info) {
             $guid = (new Pandamp_Core_Guid())->generateGuid();
             $path = implode(DS, array($newguid));
             Pandamp_Utility_File::createDirs($dir, $path);
             $adapter->setDestination($dir . DS . $path);
             $name = $adapter->getFileName($file, false);
             $fileku = $dir . DS . $path . DS . strtoupper(str_replace(' ', '_', $name));
             $adapter->addFilter('rename', ['overwrite' => true, 'target' => $fileku]);
             // file uploaded & is valid
             if (!$adapter->isUploaded($file)) {
                 continue;
             }
             if (!$adapter->isValid($file)) {
                 continue;
             }
             // receive the files into the user directory
             $adapter->receive($file);
             /*
             $baseUrl = $cdn['static']['url']['files'];
             if (isset($_SERVER['SCRIPT_NAME']) && ($pos = strripos($baseUrl, basename($_SERVER['SCRIPT_NAME']))) !== false) {
             	$baseUrl = substr($baseUrl, 0, $pos);
             }
             $prefixUrl 		 = rtrim($baseUrl, '/') . '/' . $userName . '/' . date('Y') . '/' . date('m');
             $ret['original'] = array(
             	'title' => strtoupper(str_replace(' ','_',$name)),
             	'url'  => $prefixUrl . '/' . strtoupper(str_replace(' ','_',$name)),
             	'size' => $adapter->getFileSize($file),
             	'filetype' => $adapter->getMimeType($file),
             	'type' => $type	
             );
             */
             $ret['original'] = array('id' => $guid, 'title' => strtoupper(str_replace(' ', '_', $name)), 'size' => $adapter->getFileSize($file), 'filetype' => $adapter->getMimeType($file), 'type' => $type);
         }
     } else {
         /*$size = [
         			'square' => 'crop_99_103',
         			'thumbnail' => 'resize_100_53',
         			'multimedia' => 'resize_245_169',
         			'small' => 'resize_213_142', //klinik
         			'headsmall' => 'resize_213_160', //header berita
         			'crop' => 'crop_324_169', //ijt
         			'cropnext' => 'crop_325_183', //nextevent
         			'mainhead' => 'resize_462_309', //utama
         			'medium' => 'resize_646_431'
         		];*/
         $tool = 'gd';
         $size = new Zend_Config_Ini(APPLICATION_PATH . '/configs/image.ini', 'size');
         $sizes = array();
         foreach ($size->toArray() as $key => $value) {
             list($method, $width, $height) = explode('_', $value);
             $sizes[$key] = array('method' => $method, 'width' => $width, 'height' => $height);
         }
         /**
          * Prepare folders
          */
         //$dir  = $cdn['static']['dir']['images'] . DS . 'upload';
         $dir = $cdn['static']['dir']['images'];
         //$path = implode(DS, array($userName, date('Y'), date('m'), date('d')));
         $path = implode(DS, array($newguid));
         Pandamp_Utility_File::createDirs($dir, $path);
         /**
          * Upload file
          */
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->setDestination($dir . DS . $path);
         $adapter->addValidator('Extension', false, 'jpg,png,gif');
         $adapter->addValidator('Size', false, 5242880);
         $files = $adapter->getFileInfo();
         foreach ($files as $file => $info) {
             $name = $adapter->getFileName($file);
             $ext = explode('.', $name);
             $extension = $ext[count($ext) - 1];
             $extension = strtolower($extension);
             //$fileName  = uniqid();
             $fileName = (new Pandamp_Core_Guid())->generateGuid();
             $fileku = $dir . DS . $path . DS . $fileName . '.' . $extension;
             $adapter->addFilter('rename', $fileku);
             // file uploaded & is valid
             if (!$adapter->isUploaded($file)) {
                 continue;
             }
             if (!$adapter->isValid($file)) {
                 continue;
             }
             // receive the files into the user directory
             $adapter->receive($file);
             // this has to be on top
             /**
              * Generate thumbnails
              */
             $thumbnailSizes = array_keys($sizes);
             $service = null;
             $service = new Pandamp_Image_GD();
             /**
              * Remove script filename from base URL
              */
             $baseUrl = $cdn['static']['url']['images'];
             /*
             if (isset($_SERVER['SCRIPT_NAME']) && ($pos = strripos($baseUrl, basename($_SERVER['SCRIPT_NAME']))) !== false) {
             	$baseUrl = substr($baseUrl, 0, $pos);
             }
             $prefixUrl 		 = rtrim($baseUrl, '/') . '/upload/' . $userName . '/' . date('Y') . '/' . date('m') . '/' . date('d');
             */
             $prefixUrl = $baseUrl . '/' . $newguid;
             $ret['original'] = array('id' => $fileName, 'title' => $fileName . '.' . $extension, 'url' => $prefixUrl . '/' . $fileName . '.' . $extension, 'size' => null, 'filetype' => $adapter->getMimeType($file), 'type' => $type);
             if ($thumbnailSizes) {
                 $service->setFile($fileku);
                 $ret['original']['size'] = $service->getWidth() . ' x ' . $service->getHeight();
                 foreach ($thumbnailSizes as $s) {
                     $service->setFile($fileku);
                     $method = $sizes[$s]['method'];
                     $width = $sizes[$s]['width'];
                     $height = $sizes[$s]['height'];
                     $f = $s . '_' . $fileName . '.' . $extension;
                     $newFile = $dir . DS . $path . DS . $f;
                     /**
                      * Create thumbnail
                      */
                     switch ($method) {
                         case 'resize':
                             $service->resizeLimit($newFile, $width, $height);
                             break;
                         case 'crop':
                             $service->crop($newFile, $width, $height);
                             break;
                     }
                     /*$ret[$s] = array(
                     			'title' => 	$f,
                     			'url'  => $prefixUrl . '/' . $f,
                     			'size' => $width . ' x ' . $height,
                     			'filetype' => $adapter->getMimeType($file),
                     			'type' => $type
                     		);*/
                 }
             }
         }
     }
     /**
      * Return the reponse
      */
     $ret = Zend_Json::encode($ret);
     $this->getResponse()->setBody($ret);
 }