/** * getMailContent */ function getMailContent($title) { $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $where = $tblCatalog->getAdapter()->quoteInto("shortTitle=?", $title); $rowset = $tblCatalog->fetchRow($where); $rowsetCatalogAttribute = $rowset->findDependentRowsetCatalogAttribute(); $content = $rowsetCatalogAttribute->findByAttributeGuid('fixedContent')->value; return $content; }
public function save($aData) { //do minimal pre-requisite of aData if (empty($aData['fixedTitle'])) { throw new Zend_Exception('Catalog Title can not be EMPTY!'); } if (empty($aData['profileGuid'])) { throw new Zend_Exception('Catalog Profile can not be EMPTY!'); } $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $gman = new Kutu_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(); //echo "guid ditemukan:" .$rowCatalog->guid; $rowCatalog->shortTitle = isset($aData['shortTitle']) ? $aData['shortTitle'] : $rowCatalog->shortTitle; //$rowCatalog->profileGuid = $request->getParam('profileGuid'); $rowCatalog->publishedDate = isset($aData['publishedDate']) ? $aData['publishedDate'] : $rowCatalog->publishedDate; $rowCatalog->expiredDate = isset($aData['expiredDate']) ? $aData['expiredDate'] : $rowCatalog->expiredDate; //$rowCatalog->createdBy = $request->getParam('createdBy'); //$rowCatalog->modifiedBy = ($aData['username'])?$aData['username']:''; //$rowCatalog->createdDate = $request->getParam('createdDate'); //$rowCatalog->modifiedDate = $aData['modifiedDate']; //$rowCatalog->deletedDate = $request->getParam('deletedDate'); $rowCatalog->status = isset($aData['status']) ? $aData['status'] : $rowCatalog->status; $rowCatalog->price = isset($aData['price']) ? $aData['price'] : $rowCatalog->price; } else { $rowCatalog = $tblCatalog->fetchNew(); //echo "guid tidak ditemukan"; $rowCatalog->guid = $catalogGuid; $rowCatalog->shortTitle = isset($aData['shortTitle']) ? $aData['shortTitle'] : ''; $rowCatalog->profileGuid = $aData['profileGuid']; $rowCatalog->publishedDate = '0000-00-00 00:00:00'; $rowCatalog->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()); } $tableProfileAttribute = new Kutu_Core_Orm_Table_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); //echo "rowcatalogattribute:" . $rowCatalogAttribute->attributeGuid; } else { $tblCatalogAttribute = new Kutu_Core_Orm_Table_CatalogAttribute(); $rowCatalogAttribute = $tblCatalogAttribute->fetchNew(); $rowCatalogAttribute->catalogGuid = $catalogGuid; $rowCatalogAttribute->attributeGuid = $rowProfileAttribute->attributeGuid; } $rowCatalogAttribute->value = isset($aData[$rowProfileAttribute->attributeGuid]) ? $aData[$rowProfileAttribute->attributeGuid] : ''; $rowCatalogAttribute->save(); } //save to table CatalogFolder only if folderGuid is not empty if (!empty($folderGuid)) { $rowCatalog->copyToFolder($folderGuid); } //do indexing $indexingEngine = Kutu_Search::manager(); $indexingEngine->indexCatalog($catalogGuid); //after indexing, update isIndex and indexedDate in table KutuCatalog return $catalogGuid; }