Exemplo n.º 1
0
 function generateFormAdd($relatedGuid)
 {
     $aBaseAttributes = array();
     $aBaseAttributes['profileGuid']['description'] = '';
     $aBaseAttributes['profileGuid']['form'] = "<input type='hidden' name='profileGuid' id='profileGuid' value='kutu_doc'>";
     $aBaseAttributes['uploadedFile']['description'] = 'Upload File';
     $aBaseAttributes['uploadedFile']['form'] = "<input type='file' name='uploadedFile' id='uploadedFile' size='50'>";
     $aBaseAttributes['relatedGuid']['description'] = '';
     $aBaseAttributes['relatedGuid']['form'] = "<input type='hidden' name='relatedGuid' id='relatedGuid' value='{$relatedGuid}'>";
     $tableProfileAttribute = new Pandamp_Modules_Dms_Profile_Model_ProfileAttribute();
     $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', 'kutu_doc');
     $rows = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC');
     $aRenderedAttributes = array();
     $i = 0;
     foreach ($rows as $row) {
         $row3 = $row->findParentRow('Pandamp_Modules_Dms_Catalog_Model_Attribute');
         $attributeRenderer = new Pandamp_Form_Attribute_Renderer($row3->guid, null, $row3->type, null, 'kutu_doc');
         $aRenderedAttributes[$row3->guid]['description'] = $row3->description;
         $aRenderedAttributes[$row3->guid]['form'] = $attributeRenderer->render();
         $i++;
     }
     $aReturn = array();
     $aReturn['baseForm'] = $aBaseAttributes;
     $aReturn['attributeForm'] = $aRenderedAttributes;
     return $aReturn;
 }
Exemplo n.º 2
0
 public function save($aData)
 {
     if (empty($aData['profileGuid'])) {
         throw new Zend_Exception('Catalog Profile can not be EMPTY!');
     }
     $tblCatalog = new Pandamp_Modules_Dms_Catalog_Model_Catalog();
     $gman = new Pandamp_Core_Guid();
     $catalogGuid = isset($aData['guid']) && !empty($aData['guid']) ? $aData['guid'] : $gman->generateGuid();
     $folderGuid = isset($aData['folderGuid']) && !empty($aData['folderGuid']) ? $aData['folderGuid'] : '';
     //if not empty, there are 2 possibilities
     $where = $tblCatalog->getAdapter()->quoteInto('guid=?', $catalogGuid);
     if ($tblCatalog->fetchRow($where)) {
         $rowCatalog = $tblCatalog->find($catalogGuid)->current();
         $rowCatalog->shortTitle = isset($aData['shortTitle']) ? $aData['shortTitle'] : $rowCatalog->shortTitle;
         $rowCatalog->publishedDate = isset($aData['publishedDate']) ? $aData['publishedDate'] : $rowCatalog->publishedDate;
         $rowCatalog->expiredDate = isset($aData['expiredDate']) ? $aData['expiredDate'] : $rowCatalog->expiredDate;
         $rowCatalog->status = isset($aData['status']) ? $aData['status'] : $rowCatalog->status;
         $rowCatalog->price = isset($aData['price']) ? $aData['price'] : $rowCatalog->price;
     } else {
         $rowCatalog = $tblCatalog->fetchNew();
         $rowCatalog->guid = $catalogGuid;
         $rowCatalog->shortTitle = isset($aData['shortTitle']) ? $aData['shortTitle'] : '';
         $rowCatalog->profileGuid = $aData['profileGuid'];
         $rowCatalog->publishedDate = isset($aData['publishedDate']) ? $aData['publishedDate'] : '0000-00-00 00:00:00';
         $rowCatalog->expiredDate = isset($aData['expiredDate']) ? $aData['expiredDate'] : '0000-00-00 00:00:00';
         $rowCatalog->createdBy = isset($aData['username']) ? $aData['username'] : '';
         $rowCatalog->modifiedBy = $rowCatalog->createdBy;
         $rowCatalog->createdDate = date("Y-m-d h:i:s");
         $rowCatalog->modifiedDate = $rowCatalog->createdDate;
         $rowCatalog->deletedDate = '0000-00-00 00:00:00';
         $rowCatalog->status = isset($aData['status']) ? $aData['status'] : 0;
         $rowCatalog->price = isset($aData['price']) ? $aData['price'] : 0;
     }
     try {
         $catalogGuid = $rowCatalog->save();
     } catch (Exception $e) {
         die($e->getMessage());
     }
     //$cache = Zend_Registry::get('cache');
     $tableProfileAttribute = new Pandamp_Modules_Dms_Profile_Model_ProfileAttribute();
     $profileGuid = $rowCatalog->profileGuid;
     $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $profileGuid);
     $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC');
     $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute();
     foreach ($rowsetProfileAttribute as $rowProfileAttribute) {
         if ($rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid)) {
             $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid);
         } else {
             $tblCatalogAttribute = new Pandamp_Modules_Dms_Catalog_Model_CatalogAttribute();
             $rowCatalogAttribute = $tblCatalogAttribute->fetchNew();
             $rowCatalogAttribute->catalogGuid = $catalogGuid;
             $rowCatalogAttribute->attributeGuid = $rowProfileAttribute->attributeGuid;
         }
         $rowCatalogAttribute->value = isset($aData[$rowProfileAttribute->attributeGuid]) ? $aData[$rowProfileAttribute->attributeGuid] : '';
         //$cacheKey = "gcav_cg_".$catalogGuid."_ag_".$rowProfileAttribute->attributeGuid;
         //if ($cacheKey) $cache->remove($cacheKey);
         $rowCatalogAttribute->save();
     }
     //save to table CatalogFolder only if folderGuid is not empty
     if (!empty($folderGuid)) {
         $tblCatalogFolder = new Pandamp_Modules_Dms_Catalog_Model_CatalogFolder();
         $rowsetCatalogFolder = $tblCatalogFolder->find($catalogGuid, $folderGuid);
         if (count($rowsetCatalogFolder) <= 0) {
             $rowCatalogFolder = $tblCatalogFolder->createRow(array('catalogGuid' => '', 'folderGuid' => ''));
             $rowCatalogFolder->catalogGuid = $catalogGuid;
             $rowCatalogFolder->folderGuid = $folderGuid;
             $rowCatalogFolder->save();
         }
     }
     //do indexing
     $indexingEngine = Pandamp_Search::manager();
     $indexingEngine->indexCatalog($catalogGuid);
     //$cache->remove("catalog");
     try {
         $url_content = ROOT_URL . '/berita/baca/' . $catalogGuid . '/' . $rowCatalog->shortTitle;
         $url = 'http://developers.facebook.com/tools/lint/?url={' . $url_content . '}&format=json';
         $ch = curl_init($url);
         curl_setopt($ch, CURLOPT_NOBODY, true);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
         curl_exec($ch);
         $retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         curl_close($ch);
     } catch (Exception $e) {
         die($e->getMessage());
     }
     return $catalogGuid;
 }
Exemplo n.º 3
0
 public function viewerAction()
 {
     $catalogGuid = $this->_getParam('guid') ? $this->_getParam('guid') : '';
     $modelCatalog = new Pandamp_Modules_Dms_Catalog_Model_Catalog();
     if (!empty($catalogGuid)) {
         $rowCatalog = $modelCatalog->find($catalogGuid)->current();
         $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute();
         $tableProfileAttribute = new Pandamp_Modules_Dms_Profile_Model_ProfileAttribute();
         $profileGuid = $rowCatalog->profileGuid;
         $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $profileGuid);
         $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC');
         $aAttribute = array();
         $i = 0;
         $tblAttribute = new Pandamp_Modules_Dms_Catalog_Model_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->rowsetCatalogAttribute = $rowsetCatalogAttribute;
     $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";
         //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>";
         }
     }
     $this->_helper->viewRenderer('viewer-generic');
 }
 function saveAction()
 {
     $response = array();
     $request = $this->getRequest();
     $tblCatalog = new Pandamp_Modules_Dms_Catalog_Model_Catalog();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $userName = $auth->getIdentity()->username;
     }
     $gman = new Pandamp_Core_Guid();
     $catalogGuid = $request->getParam('guid') ? $request->getParam('guid') : $gman->generateGuid();
     $folderGuid = $request->getParam('folderGuid') ? $request->getParam('folderGuid') : '';
     //if not empty, there are 2 possibilities
     $where = $tblCatalog->getAdapter()->quoteInto('guid=?', $catalogGuid);
     if ($tblCatalog->fetchRow($where)) {
         $rowCatalog = $tblCatalog->find($catalogGuid)->current();
         $rowCatalog->shortTitle = $request->getParam('shortTitle');
         $rowCatalog->publishedDate = $request->getParam('publishedDate');
         $rowCatalog->expiredDate = $request->getParam('expiredDate');
         $rowCatalog->modifiedBy = $userName;
         $rowCatalog->modifiedDate = date("Y-m-d h:i:s");
         $rowCatalog->status = $request->getParam('status');
     } else {
         $rowCatalog = $tblCatalog->fetchNew();
         $rowCatalog->shortTitle = $request->getParam('shortTitle');
         $rowCatalog->profileGuid = $request->getParam('profileGuid');
         $rowCatalog->publishedDate = $request->getParam('publishedDate');
         $rowCatalog->expiredDate = $request->getParam('expiredDate');
         $rowCatalog->createdBy = $userName;
         $rowCatalog->modifiedBy = $userName;
         $rowCatalog->createdDate = date("Y-m-d h:i:s");
         $rowCatalog->modifiedDate = date("Y-m-d h:i:s");
         $rowCatalog->deletedDate = '0000-00-00 00:00:00';
         $rowCatalog->status = $request->getParam('status');
     }
     $catalogGuid = $rowCatalog->save();
     $tableProfileAttribute = new Pandamp_Modules_Dms_Profile_Model_ProfileAttribute();
     $profileGuid = $rowCatalog->profileGuid;
     $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $profileGuid);
     $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC');
     $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute();
     foreach ($rowsetProfileAttribute as $rowProfileAttribute) {
         if ($rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid)) {
             $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid);
         } else {
             $tblCatalogAttribute = new Pandamp_Modules_Dms_Catalog_Model_CatalogAttribute();
             $rowCatalogAttribute = $tblCatalogAttribute->fetchNew();
             $rowCatalogAttribute->catalogGuid = $catalogGuid;
             $rowCatalogAttribute->attributeGuid = $rowProfileAttribute->attributeGuid;
         }
         $rowCatalogAttribute->value = $request->getParam($rowProfileAttribute->attributeGuid);
         $rowCatalogAttribute->save();
     }
     //save to table CatalogFolder only if folderGuid is not empty
     if (!empty($folderGuid)) {
         $tblCatalogFolder = new Pandamp_Modules_Dms_Catalog_Model_CatalogFolder();
         $rowsetCatalogFolder = $tblCatalogFolder->find($catalogGuid, $folderGuid);
         if (count($rowsetCatalogFolder) <= 0) {
             $rowCatalogFolder = $tblCatalogFolder->createRow(array('catalogGuid' => '', 'folderGuid' => ''));
             $rowCatalogFolder->catalogGuid = $catalogGuid;
             $rowCatalogFolder->folderGuid = $folderGuid;
             $rowCatalogFolder->save();
         }
     }
     $response['success'] = true;
     echo Zend_Json::encode($response);
 }
Exemplo n.º 5
0
 function generateFormAdd($catalogGuid, $folderGuid = null)
 {
     $aRenderedAttributes = array();
     $aBaseAttributes = array();
     $tableCatalog = new Pandamp_Modules_Dms_Catalog_Model_Catalog();
     $rowsetCatalog = $tableCatalog->find($catalogGuid);
     $rowCatalog = $rowsetCatalog->current();
     if (!isset($rowCatalog)) {
         $tableProfileAttribute = new Pandamp_Modules_Dms_Profile_Model_ProfileAttribute();
         $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', 'setting');
         $rows = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC');
         $i = 0;
         foreach ($rows as $row) {
             $rowset = $row->findParentRow('Pandamp_Modules_Dms_Catalog_Model_Attribute');
             $attributeRenderer = new Pandamp_Form_Attribute_Renderer($rowset->guid, null, $rowset->type, null);
             $aRenderedAttributes[$rowset->guid]['description'] = $rowset->description;
             $aRenderedAttributes[$rowset->guid]['form'] = $attributeRenderer->render();
             $i++;
         }
         $aBaseAttributes['profileGuid']['description'] = '';
         $aBaseAttributes['profileGuid']['form'] = "<input type='hidden' name='profileGuid' id='profileGuid' value='setting'>";
         $aBaseAttributes['folderGuid']['description'] = '';
         $aBaseAttributes['folderGuid']['form'] = "<input type='hidden' name='folderGuid' id='folderGuid' value='{$folderGuid}'>";
         $aBaseAttributes['status']['description'] = '';
         $aBaseAttributes['status']['form'] = "<input type='hidden' name='status' id='status' value='1'>";
     } else {
         $tableProfileAttributes = new Pandamp_Modules_Dms_Profile_Model_ProfileAttribute();
         $where = $tableProfileAttributes->getAdapter()->quoteInto('profileGuid=?', $rowCatalog->profileGuid);
         $rowsetProfileAttributes = $tableProfileAttributes->fetchAll($where, array('viewOrder ASC'));
         $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute();
         $i = 0;
         foreach ($rowsetProfileAttributes as $row) {
             $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($row->attributeGuid);
             $rowAttribute = $row->findParentRow('Pandamp_Modules_Dms_Catalog_Model_Attribute');
             if (isset($rowCatalogAttribute->value)) {
                 $attributeValue = $rowCatalogAttribute->value;
             } else {
                 $attributeValue = '';
             }
             if (isset($rowCatalogAttribute->guid)) {
                 $catalogAttributeGuid = $rowCatalogAttribute->guid;
             } else {
                 $guidMan = new Pandamp_Core_Guid();
                 $catalogAttributeGuid = $guidMan->generateGuid();
             }
             $attributeRenderer = new Pandamp_Form_Attribute_Renderer($rowAttribute->guid, $attributeValue, $rowAttribute->type, null);
             $aRenderedAttributes[$rowAttribute->guid]['description'] = $rowAttribute->description;
             $aRenderedAttributes[$rowAttribute->guid]['form'] = $attributeRenderer->render();
             $i++;
         }
         $aBaseAttributes['guid']['description'] = '';
         $aBaseAttributes['guid']['form'] = "<input type='hidden' name='guid' id='guid' value='{$rowCatalog->guid}'>";
         $aBaseAttributes['profileGuid']['description'] = '';
         $aBaseAttributes['profileGuid']['form'] = "<input type='hidden' name='profileGuid' id='profileGuid' value='{$rowCatalog->profileGuid}'>";
         $aBaseAttributes['status']['description'] = '';
         $aBaseAttributes['status']['form'] = "<input type='hidden' name='status' id='status' value='1'>";
     }
     $aReturn = array();
     $aReturn['baseForm'] = $aBaseAttributes;
     $aReturn['attributeForm'] = $aRenderedAttributes;
     return $aReturn;
 }
Exemplo n.º 6
0
 function generateFormAnswer($catalogGuid)
 {
     $today = date('Y-m-d H:i:s');
     $aRenderedAttributes = array();
     $aBaseAttributes = array();
     $tableCatalog = new Pandamp_Modules_Dms_Catalog_Model_Catalog();
     $rowsetCatalog = $tableCatalog->find($catalogGuid);
     $rowCatalog = $rowsetCatalog->current();
     $tableProfileAttribute = new Pandamp_Modules_Dms_Profile_Model_ProfileAttribute();
     $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $rowCatalog->profileGuid);
     $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, array('viewOrder ASC'));
     $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute();
     $i = 0;
     foreach ($rowsetProfileAttribute as $row) {
         $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($row->attributeGuid);
         $rowAttribute = $row->findParentRow('Pandamp_Modules_Dms_Catalog_Model_Attribute');
         if (isset($rowCatalogAttribute->value)) {
             $attributeValue = $rowCatalogAttribute->value;
         } else {
             $attributeValue = '';
         }
         if (isset($rowCatalogAttribute->guid)) {
             $catalogAttributeGuid = $rowCatalogAttribute->guid;
         } else {
             $guidMan = new Pandamp_Core_Guid();
             $catalogAttributeGuid = $guidMan->generateGuid();
         }
         $attributeRenderer = new Pandamp_Form_Attribute_Renderer($rowAttribute->guid, $attributeValue, $rowAttribute->type, null, 'author', 'partner');
         $aRenderedAttributes[$rowAttribute->guid]['description'] = $rowAttribute->description;
         $aRenderedAttributes[$rowAttribute->guid]['form'] = $attributeRenderer->render();
         $i++;
     }
     $aBaseAttributes['guid']['description'] = '';
     $aBaseAttributes['guid']['form'] = "<input type='hidden' name='guid' id='guid' value='{$rowCatalog->guid}'>";
     $aBaseAttributes['profileGuid']['description'] = '';
     $aBaseAttributes['profileGuid']['form'] = "<input type='hidden' name='profileGuid' id='profileGuid' value='{$rowCatalog->profileGuid}'>";
     $s = '<input type="Text" id="publishedDate" maxlength="25" size="25" name="publishedDate" value="' . $rowCatalog->publishedDate . '"><a href="javascript:NewCal(\'publishedDate\',\'yyyymmdd\',true,24)"><img src="' . ROOT_URL . '/resources/images/img.gif" width="16" height="16" border="0" alt="Pick a date"></a>';
     $aBaseAttributes['publishedDate']['description'] = 'Published Date';
     $aBaseAttributes['publishedDate']['form'] = $s;
     $n = '<input type="Text" id="expiredDate" maxlength="25" size="25" name="expiredDate" value="' . $rowCatalog->expiredDate . '"><a href="javascript:NewCal(\'expiredDate\',\'yyyymmdd\',true,24)"><img src="' . ROOT_URL . '/resources/images/img.gif" width="16" height="16" border="0" alt="Pick a date"></a>';
     $aBaseAttributes['expiredDate']['description'] = 'Expired Date';
     $aBaseAttributes['expiredDate']['form'] = $n;
     $aBaseAttributes['createdDate']['description'] = 'Created on';
     $aBaseAttributes['createdDate']['form'] = $rowCatalog->createdDate . "<input type='hidden' name='createdDate' id='createdDate' value='{$rowCatalog->createdDate}'>";
     $aBaseAttributes['modifiedDate']['description'] = 'Last Modified on';
     $aBaseAttributes['modifiedDate']['form'] = $rowCatalog->modifiedDate . "<input type='hidden' name='modifiedDate' id='modifiedDate' value='{$today}'>";
     $aBaseAttributes['deletedDate']['description'] = 'Deleted on';
     $aBaseAttributes['deletedDate']['form'] = $rowCatalog->deletedDate . "<input type='hidden' name='deletedDate' id='deletedDate' value='{$rowCatalog->deletedDate}'>";
     //		$aBaseAttributes['profileGuid']['description'] = 'Sender';
     //		$aBaseAttributes['profileGuid']['form'] = "$rowCatalog->createdBy";
     //		$aBaseAttributes['status']['description'] = '';
     //		$aBaseAttributes['status']['form'] = "<input type='hidden' name='status' id='status' value='$rowCatalog->status'>";
     $aBaseAttributes['status']['description'] = 'Status';
     require_once CONFIG_PATH . '/master-status.php';
     $statusConfig = MasterStatus::getPublishingStatus();
     $attributeRenderer = new Pandamp_Form_Attribute_Renderer('status', $rowCatalog->status, 101);
     $aBaseAttributes['status']['form'] = $attributeRenderer->render();
     $aReturn = array();
     $aReturn['baseForm'] = $aBaseAttributes;
     $aReturn['attributeForm'] = $aRenderedAttributes;
     return $aReturn;
 }