Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phame/storage/PhamePost.php
| Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | public function setBlog(PhameBlog $blog) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getBlog() { | public function getBlog() { | ||||
| return $this->blog; | return $this->blog; | ||||
| } | } | ||||
| public function getLiveURI() { | public function getLiveURI() { | ||||
| // go for the pretty uri if we can | $blog = $this->getBlog(); | ||||
| $domain = ($this->blog ? $this->blog->getDomain() : ''); | $is_draft = $this->isDraft(); | ||||
| if ($domain) { | if (strlen($blog->getDomain()) && !$is_draft) { | ||||
| $phame_title = PhabricatorSlug::normalize($this->getPhameTitle()); | return $this->getExternalLiveURI(); | ||||
| return 'http://'.$domain.'/post/'.$phame_title; | } else { | ||||
| return $this->getInternalLiveURI(); | |||||
| } | } | ||||
| $uri = '/phame/post/view/'.$this->getID().'/'; | |||||
| return PhabricatorEnv::getProductionURI($uri); | |||||
| } | } | ||||
| public function getViewURI() { | public function getExternalLiveURI() { | ||||
| $phame_title = PhabricatorSlug::normalize($this->getPhameTitle()); | $id = $this->getID(); | ||||
| return '/phame/post/view/'.$this->getID().'/'.$phame_title; | $slug = $this->getSlug(); | ||||
| $path = "/post/{$id}/{$slug}/"; | |||||
| $domain = $this->getBlog()->getDomain(); | |||||
| return (string)id(new PhutilURI('http://'.$domain)) | |||||
| ->setPath($path); | |||||
| } | } | ||||
| public function getEditURI() { | public function getInternalLiveURI() { | ||||
| return '/phame/post/edit/'.$this->getID().'/'; | $id = $this->getID(); | ||||
| $slug = $this->getSlug(); | |||||
| $blog_id = $this->getBlog()->getID(); | |||||
| return "/phame/live/{$blog_id}/post/{$id}/{$slug}/"; | |||||
| } | } | ||||
| public function isDraft() { | public function getViewURI() { | ||||
| return $this->getVisibility() == PhameConstants::VISIBILITY_DRAFT; | $id = $this->getID(); | ||||
| $slug = $this->getSlug(); | |||||
| return "/phame/post/view/{$id}/{$slug}/"; | |||||
| } | } | ||||
| public function getHumanName() { | public function getEditURI() { | ||||
| if ($this->isDraft()) { | return '/phame/post/edit/'.$this->getID().'/'; | ||||
| $name = 'draft'; | |||||
| } else { | |||||
| $name = 'post'; | |||||
| } | } | ||||
| return $name; | public function isDraft() { | ||||
| return ($this->getVisibility() == PhameConstants::VISIBILITY_DRAFT); | |||||
| } | } | ||||
| protected function getConfiguration() { | protected function getConfiguration() { | ||||
| return array( | return array( | ||||
| self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
| self::CONFIG_SERIALIZATION => array( | self::CONFIG_SERIALIZATION => array( | ||||
| 'configData' => self::SERIALIZATION_JSON, | 'configData' => self::SERIALIZATION_JSON, | ||||
| ), | ), | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | public function save() { | ||||
| return parent::save(); | return parent::save(); | ||||
| } | } | ||||
| public function generatePHID() { | public function generatePHID() { | ||||
| return PhabricatorPHID::generateNewPHID( | return PhabricatorPHID::generateNewPHID( | ||||
| PhabricatorPhamePostPHIDType::TYPECONST); | PhabricatorPhamePostPHIDType::TYPECONST); | ||||
| } | } | ||||
| public function getSlug() { | |||||
| return rtrim($this->getPhameTitle(), '/'); | |||||
| } | |||||
| public function toDictionary() { | public function toDictionary() { | ||||
| return array( | return array( | ||||
| 'id' => $this->getID(), | 'id' => $this->getID(), | ||||
| 'phid' => $this->getPHID(), | 'phid' => $this->getPHID(), | ||||
| 'blogPHID' => $this->getBlogPHID(), | 'blogPHID' => $this->getBlogPHID(), | ||||
| 'bloggerPHID' => $this->getBloggerPHID(), | 'bloggerPHID' => $this->getBloggerPHID(), | ||||
| 'viewURI' => $this->getViewURI(), | 'viewURI' => $this->getViewURI(), | ||||
| 'title' => $this->getTitle(), | 'title' => $this->getTitle(), | ||||
| ▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines | |||||