Esempio n. 1
0
 /**
  * Save a meta value to the database
  * This only works if the model is setup to work a meta table
  *
  * @param Fishpig_Wordpress_Model_Meta_Abstract $object
  * @param string $metaKey
  * @param string $metaValue
  */
 public function setMetaValue(Fishpig_Wordpress_Model_Abstract $object, $metaKey, $metaValue)
 {
     if ($object->hasMeta()) {
         $metaValue = trim($metaValue);
         $metaData = array($object->getMetaObjectField() => $object->getId(), 'meta_key' => $metaKey, 'meta_value' => $metaValue);
         if (($metaId = $this->getMetaValue($object, $metaKey, $object->getMetaPrimaryKeyField())) !== false) {
             $this->_getWriteAdapter()->update($object->getMetaTable(), $metaData, $object->getMetaPrimaryKeyField() . '=' . $metaId);
         } else {
             $this->_getWriteAdapter()->insert($object->getMetaTable(), $metaData);
         }
     }
 }
Esempio n. 2
0
 /**
  * Set the categories after loading
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     parent::_afterLoad();
     $this->getResource()->preparePosts(array($this));
     return $this;
 }
 /**
  * Retrieve the object resource model
  *
  * @return Fishpig_Wordpress_Model_Resource_Post_Collection_Abstract
  */
 protected function _getObjectResourceModel()
 {
     return parent::getPostCollection();
 }
Esempio n. 4
0
 /**
  * Loads the posts belonging to this category
  *
  * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
  */
 public function getPostCollection()
 {
     return parent::getPostCollection()->addIsViewableFilter()->addTermIdFilter($this->getId(), $this->getTaxonomy());
 }
 /**
  * Loads the associated attachment meta data
  * This data is stored as a serialized array
  *
  * @param int $id
  * @param string $field
  * @return Fishpig_Wordpress_Model_Post_Attachment_Abstract
  */
 public function load($id, $field = null)
 {
     parent::load($id, $field);
     $this->loadSerializedData();
     return $this;
 }