public function executeCommentForm() { sfContext::getInstance()->getResponse()->addStylesheet('/sfPropelActAsCommentableBehaviorPlugin/css/sf_comment'); $this->getConfig(); if ($this->object instanceof sfOutputEscaperObjectDecorator) { $object = $this->object->getRawValue(); } else { $object = $this->object; } $this->object_model = get_class($object); $this->object_id = $object->getPrimaryKey(); $this->token = sfPropelActAsCommentableToolkit::addTokenToSession($this->object_model, $this->object_id); if ($this->getUser()->isAuthenticated() && $this->config_user['enabled']) { $this->action = 'authenticated_comment'; $this->config_used = $this->config_user; } else { $this->action = 'anonymous_comment'; $this->config_used = $this->config_anonymous; } }
/** * Retrieve a commentable object * * @param string $object_model * @param int $object_id */ public static function retrieveCommentableObject($object_model, $object_id) { try { $peer = sprintf('%sPeer', $object_model); if (!class_exists($peer)) { throw new Exception(sprintf('Unable to load class %s', $peer)); } $object = call_user_func(array($peer, 'retrieveByPk'), $object_id); if (is_null($object)) { throw new Exception(sprintf('Unable to retrieve %s with primary key %s', $object_model, $object_id)); } if (!sfPropelActAsCommentableToolkit::isCommentable($object)) { throw new Exception(sprintf('Class %s does not have the commentable behavior', $object_model)); } return $object; } catch (Exception $e) { return sfContext::getInstance()->getLogger()->log($e->getMessage()); } }
/** * Displays the comment form */ public function executeCommentForm() { $token = $this->getRequestParameter('sf_comment_object_token'); $this->object = sfPropelActAsCommentableToolkit::retrieveFromToken($token); $this->namespace = $this->getRequestParameter('sf_comment_namespace', null); }