示例#1
0
 public function categoryCheckbox($attributes = array())
 {
     $zl = Zend_Registry::get('Zend_Locale');
     $lang = $zl->getLanguage();
     $auth = Zend_Auth::getInstance();
     $group = $auth->getIdentity()->name;
     $group = strtolower(str_replace(" ", "", $group));
     $cache = Pandamp_Cache::getInstance();
     if (isset($attributes['selected'])) {
         $sel = join("_", $attributes['selected']);
         $cacheKey = 'categoryCheckbox_' . $sel;
     } else {
         $cacheKey = 'categoryCheckbox';
     }
     $cacheKey = $cacheKey . '_' . $lang . '_' . $group;
     if ($cache != null) {
         $cache->setLifetime("86400");
     }
     if (!($fromCache = $cache->load($cacheKey))) {
         $output = sprintf("<div id='%s' viewHelperClass='%s' viewHelperAttributes='%s'>", $attributes['id'], get_class($this), Zend_Json::encode($attributes)) . self::EOL;
         $output .= $this->_traverseFolder('root', '', 0, $attributes);
         $output .= '</div>' . self::EOL;
         $cache->save($output, $cacheKey);
         $fromCache = $cache->load($cacheKey);
     }
     return $fromCache;
 }
示例#2
0
 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;
 }
示例#3
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));
     }
 }