public function getAttributeTitle($attributeGuid)
 {
     Zend_Loader::loadClass('Kutu_Core_Orm_Table_Attribute');
     $tblAttribute = new Kutu_Core_Orm_Table_Attribute();
     $rowsetAttribute = $tblAttribute->find($attributeGuid);
     if (count($rowsetAttribute)) {
         $rowAttribute = $rowsetAttribute->current();
         return $rowAttribute->name;
     } else {
         return '';
     }
 }
 public function view()
 {
     $this->view->addHelperPath(KUTU_ROOT_DIR . '/lib/Kutu/View/Helper', 'Kutu_View_Helper');
     $catalogGuid = $this->catalogGuid ? $this->catalogGuid : '';
     $node = $this->folderGuid ? $this->folderGuid : 'root';
     Zend_Loader::loadClass('Kutu_Core_Orm_Table_Catalog');
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     if (!empty($catalogGuid)) {
         $rowCatalog = $tblCatalog->find($catalogGuid)->current();
         $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute();
         Zend_Loader::loadClass('Kutu_Core_Orm_Table_ProfileAttribute');
         $tableProfileAttribute = new Kutu_Core_Orm_Table_ProfileAttribute();
         $profileGuid = $rowCatalog->profileGuid;
         $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $profileGuid);
         $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC');
         $aAttribute = array();
         $i = 0;
         Zend_Loader::loadClass('Kutu_Core_Orm_Table_Attribute');
         $tblAttribute = new Kutu_Core_Orm_Table_Attribute();
         foreach ($rowsetProfileAttribute as $rowProfileAttribute) {
             if ($rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid)) {
                 $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid);
                 $rowsetAttribute = $tblAttribute->find($rowCatalogAttribute->attributeGuid);
                 if (count($rowsetAttribute)) {
                     $rowAttribute = $rowsetAttribute->current();
                     $aAttribute[$i]['name'] = $rowAttribute->name;
                 } else {
                     $aAttribute[$i]['name'] = '';
                 }
                 $aAttribute[$i]['value'] = $rowCatalogAttribute->value;
             } else {
             }
             $i++;
         }
     }
     $this->view->aAttribute = $aAttribute;
     $this->view->rowCatalog = $rowCatalog;
     $this->view->rowsetCatalogAttribute = $rowsetCatalogAttribute;
     $this->view->node = $node;
     $this->view->catalogGuid = $catalogGuid;
     $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid('fixedExpired');
     //set your year, month, daym hour, minute, second you want to cuntdown to, Change the numbers beetwen " and "
     if (!empty($rowCatalogAttribute->value)) {
         $tDate = $rowCatalogAttribute->value;
         $aDate = explode('-', $tDate);
         $year = $aDate[0];
         $month = $aDate[1];
         $day = $aDate[2];
         $hour = "00";
         $minute = "00";
         $second = "00";
         //set what is going to happen than
         $event = "My birthday";
         //don't change anything below unless you know what you are doing
         $time = mktime($hour, $minute, $second, $month, $day, $year);
         $timecurrent = date('U');
         $cuntdowntime = $time - $timecurrent;
         $cuntdownminutes = $cuntdowntime / 60;
         $cuntdownhours = $cuntdowntime / 3600;
         $cuntdowndays = $cuntdownhours / 24;
         $cuntdownmonths = $cuntdowndays / 30;
         $cuntdownyears = $cuntdowndays / 365;
         //echo 'sisa hari: ' . $cuntdowndays;
         if ($cuntdowndays < 0) {
             echo "<script>alert('Dokumen perjanjian ini telah berakhir masa berlakunya.');</script>";
             echo "<br><strong>Dokumen perjanjian ini telah berakhir masa berlakunya.</strong>";
         } else {
             //echo "<script>alert('Dokumen perjanjian ini akan berakhir masa berlakunya dalam ".round($cuntdowndays)." hari.');</script>";
             echo "<br><strong>Dokumen perjanjian ini akan berakhir masa berlakunya dalam " . round($cuntdowndays) . " hari.</strong>";
         }
     }
 }
Exemple #3
0
 public function indexCatalog($catalogGuid)
 {
     $index = $this->_index;
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     $rowsetCatalog = $tblCatalog->find($catalogGuid);
     if (count($rowsetCatalog)) {
         //check if guid exist in index, then delete
         $term = new Zend_Search_Lucene_Index_Term($catalogGuid, 'guid');
         $docIds = $index->termDocs($term);
         foreach ($docIds as $id) {
             $doc = $index->getDocument($id);
             $index->delete($id);
         }
         $rowCatalog = $rowsetCatalog->current();
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::Keyword('guid', $rowCatalog->guid));
         //fill parentGuid with catalogGuid if it's kutu_doc
         if ($rowCatalog->profileGuid == 'kutu_doc') {
             $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
             $rowset = $tblRelatedItem->fetchAll("itemGuid='{$rowCatalog->guid}' AND relateAs='RELATED_FILE'");
             if (count($rowset)) {
                 $row = $rowset->current();
                 $parentCatalogGuid = $row->relatedGuid;
                 $doc->addField(Zend_Search_Lucene_Field::Keyword('parentGuid', $parentCatalogGuid));
             }
         } else {
             $doc->addField(Zend_Search_Lucene_Field::Keyword('parentGuid', $rowCatalog->guid));
         }
         $doc->addField(Zend_Search_Lucene_Field::Text('profile', $rowCatalog->profileGuid));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('publishedDate', $this->_filterDateTime($rowCatalog->publishedDate)));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('expiredDate', $this->_filterDateTime($rowCatalog->expiredDate)));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('createdBy', $rowCatalog->createdBy));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('modifiedBy', $rowCatalog->modifiedBy));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('createdDate', $this->_filterDateTime($rowCatalog->createdDate)));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('modifiedDate', $this->_filterDateTime($rowCatalog->modifiedDate)));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('status', $rowCatalog->status));
         if ($rowCatalog->profileGuid == 'kutu_doc') {
             $doc->addField(Zend_Search_Lucene_Field::Keyword('objectType', 'file'));
         } else {
             $doc->addField(Zend_Search_Lucene_Field::Keyword('objectType', 'catalog'));
         }
         $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute();
         if (count($rowsetCatalogAttribute)) {
             foreach ($rowsetCatalogAttribute as $rowCatalogAttribute) {
                 switch ($rowCatalogAttribute->attributeGuid) {
                     case 'fixedTitle':
                     case 'title':
                         $doc->addField(Zend_Search_Lucene_Field::Text('title', $rowCatalogAttribute->value));
                         break;
                     case 'fixedSubTitle':
                     case 'subTitle':
                         $doc->addField(Zend_Search_Lucene_Field::Text('subtitle', $rowCatalogAttribute->value));
                         break;
                     case 'fixedContent':
                     case 'content':
                         $docHtml = Zend_Search_Lucene_Document_Html::loadHTML($rowCatalogAttribute->value);
                         $cleanedText = $docHtml->getFieldValue('body');
                         $doc->addField(Zend_Search_Lucene_Field::UnStored('content', $cleanedText));
                         break;
                     case 'fixedKeywords':
                     case 'keywords':
                         $doc->addField(Zend_Search_Lucene_Field::UnStored('keywords', $rowCatalogAttribute->value));
                         break;
                     case 'fixedDescription':
                     case 'description':
                         $doc->addField(Zend_Search_Lucene_Field::Text('description', $rowCatalogAttribute->value));
                         break;
                     case 'ptsKetua':
                         $doc->addField(Zend_Search_Lucene_Field::Text('judge', $rowCatalogAttribute->value));
                         break;
                     case 'prtNomor':
                     case 'fixedNomor':
                     case 'fixedNumber':
                     case 'nomor':
                     case 'ptsNomor':
                         $doc->addField(Zend_Search_Lucene_Field::UnStored('number', $rowCatalogAttribute->value));
                         break;
                     case 'prtTahun':
                     case 'fixedTahun':
                     case 'fixedYear':
                     case 'tahun':
                     case 'ptsTahun':
                         $doc->addField(Zend_Search_Lucene_Field::UnStored('year', $rowCatalogAttribute->value));
                         break;
                     default:
                         //check if attribute is a datetime field
                         $tblAttribute = new Kutu_Core_Orm_Table_Attribute();
                         $rowAttribute = $tblAttribute->find($rowCatalogAttribute->attributeGuid)->current();
                         if ($rowAttribute->type == 4) {
                             $doc->addField(Zend_Search_Lucene_Field::UnStored(strtolower($rowCatalogAttribute->attributeGuid), $this->_filterDateTime($rowCatalogAttribute->value)));
                         } else {
                             if ($rowAttribute->type == 2) {
                                 $docHtml = Zend_Search_Lucene_Document_Html::loadHTML($rowCatalogAttribute->value);
                                 $cleanedText = $docHtml->getFieldValue('body');
                                 $doc->addField(Zend_Search_Lucene_Field::UnStored(strtolower($rowCatalogAttribute->attributeGuid), $cleanedText));
                             } else {
                                 $doc->addField(Zend_Search_Lucene_Field::UnStored(strtolower($rowCatalogAttribute->attributeGuid), $rowCatalogAttribute->value));
                             }
                         }
                         break;
                 }
             }
             //if profile=kutu_doc, extract text from its file and put it in content field
             if ($rowCatalog->profileGuid == 'kutu_doc') {
                 $row = $rowsetCatalogAttribute->findByAttributeGuid('docSystemName');
                 $systemName = $row->value;
                 $row = $rowsetCatalogAttribute->findByAttributeGuid('docMimeType');
                 $mimeType = $row->value;
                 $extactedText = $this->_extractText($rowCatalog->guid, $systemName, $mimeType);
                 $doc->addField(Zend_Search_Lucene_Field::UnStored('content', $extactedText));
             }
         }
         // if catalog is a kutu_doc, and if field content empty (this means
         // file can't be read, text can't be extracted, or file empty), do not index
         if ($rowCatalog->profileGuid == 'kutu_doc') {
             $tmpS = $doc->getFieldValue('content');
             if (!empty($tmpS)) {
                 $index->addDocument($doc);
             } else {
             }
         } else {
             $index->addDocument($doc);
         }
     } else {
         // do nothing
     }
 }
Exemple #4
0
 /**
  * attributePullDown
  * @return attribute
  */
 function attributePullDown()
 {
     $tblAttribute = new Kutu_Core_Orm_Table_Attribute();
     $row = $tblAttribute->fetchAll(null, 'guid ASC');
     $attribute = "<select name=\"attribute\" id=\"attribute\">\n";
     $attribute .= "<option value='' selected>----------Choose Attribute----------</option>";
     foreach ($row as $rowset) {
         $attribute .= "<option value='{$rowset->guid}'>{$rowset->guid}</option>";
     }
     $attribute .= "</select>\n\n";
     return $attribute;
 }
 function viewerAction()
 {
     $catalogGuid = $this->_getParam('guid') ? $this->_getParam('guid') : '';
     $node = $this->_getParam('node') ? $this->_getParam('node') : '';
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     if (!empty($catalogGuid)) {
         $rowCatalog = $tblCatalog->find($catalogGuid)->current();
         if ($rowCatalog) {
             $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute();
             $tableProfileAttribute = new Kutu_Core_Orm_Table_ProfileAttribute();
             $profileGuid = $rowCatalog->profileGuid;
             $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $profileGuid);
             $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC');
             $aAttribute = array();
             $i = 0;
             $tblAttribute = new Kutu_Core_Orm_Table_Attribute();
             foreach ($rowsetProfileAttribute as $rowProfileAttribute) {
                 if ($rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid)) {
                     $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid);
                     $rowsetAttribute = $tblAttribute->find($rowCatalogAttribute->attributeGuid);
                     if (count($rowsetAttribute)) {
                         $rowAttribute = $rowsetAttribute->current();
                         $aAttribute[$i]['name'] = $rowAttribute->name;
                     } else {
                         $aAttribute[$i]['name'] = '';
                     }
                     $aAttribute[$i]['value'] = $rowCatalogAttribute->value;
                 } else {
                 }
                 $i++;
             }
             $this->view->aAttribute = $aAttribute;
             $this->view->rowCatalog = $rowCatalog;
             $this->view->rowsetCatalogAttribute = $rowsetCatalogAttribute;
             $this->view->node = $node;
             $this->view->catalogGuid = $catalogGuid;
             $this->view->profileGuid = $profileGuid;
             $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid('fixedExpired');
             if (!empty($rowCatalogAttribute->value)) {
                 $tDate = $rowCatalogAttribute->value;
                 $aDate = explode('-', $tDate);
                 $year = $aDate[0];
                 $month = $aDate[1];
                 $day = $aDate[2];
                 $hour = "00";
                 $minute = "00";
                 $second = "00";
                 $event = "My birthday";
                 $time = mktime($hour, $minute, $second, $month, $day, $year);
                 $timecurrent = date('U');
                 $cuntdowntime = $time - $timecurrent;
                 $cuntdownminutes = $cuntdowntime / 60;
                 $cuntdownhours = $cuntdowntime / 3600;
                 $cuntdowndays = $cuntdownhours / 24;
                 $cuntdownmonths = $cuntdowndays / 30;
                 $cuntdownyears = $cuntdowndays / 365;
                 if ($cuntdowndays < 0) {
                     echo "<script>alert('Dokumen perjanjian ini telah berakhir masa berlakunya.');</script>";
                     echo "<br><strong>Dokumen perjanjian ini telah berakhir masa berlakunya.</strong>";
                 } else {
                     echo "<br><strong>Dokumen perjanjian ini akan berakhir masa berlakunya dalam " . round($cuntdowndays) . " hari.</strong>";
                 }
             }
         }
     }
 }