예제 #1
0
파일: Mvc.php 프로젝트: schpill/thin
 /**
  * Returns href for this page
  *
  * This method uses {@link Zend_Controller_Action_Helper_Url} to assemble
  * the href based on the page's properties.
  *
  * @return string  page href
  */
 public function getHref()
 {
     if ($this->_hrefCache) {
         return $this->_hrefCache;
     }
     if (null === self::$_urlHelper) {
         self::$_urlHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('Url');
     }
     $params = $this->getParams();
     if ($param = $this->getModule()) {
         $params['module'] = $param;
     }
     if ($param = $this->getController()) {
         $params['controller'] = $param;
     }
     if ($param = $this->getAction()) {
         $params['action'] = $param;
     }
     $url = self::$_urlHelper->url($params, $this->getRoute(), $this->getResetParams(), $this->getEncodeUrl());
     // Use scheme?
     $scheme = $this->getScheme();
     if (null !== $scheme) {
         if (null === self::$_schemeHelper) {
             self::$_schemeHelper = new \Zend_View_Helper_ServerUrl();
         }
         $url = self::$_schemeHelper->setScheme($scheme)->serverUrl($url);
     }
     // Add the fragment identifier if it is set
     $fragment = $this->getFragment();
     if (null !== $fragment) {
         $url .= '#' . $fragment;
     }
     return $this->_hrefCache = $url;
 }
예제 #2
0
 /**
  * Retrieves URI/href for the given site
  * 
  * @return string
  */
 public function getHref()
 {
     if (isset($this->uri)) {
         return $this->uri;
     }
     if (null === self::$_urlHelper) {
         self::$_urlHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('url');
     }
     return self::$_urlHelper->url(array('module' => $this->module, 'controller' => $this->controller, 'action' => $this->action), $this->route, $this->resetParams);
 }
예제 #3
0
 /**
  * Deletes a post and its comments
  *
  * @return void
  */
 public function deleteAction()
 {
     /**
      * @var $request Zend_Controller_Request_Http
      */
     $request = $this->getRequest();
     $pid = intval($request->getParam('pid'));
     $postModel = new Blog_Model_DbTable_Post();
     $post = $postModel->find($pid)->current();
     if ($post) {
         $post->delete();
     }
     $this->_redirect($this->urlHelper->url(array(), 'posts'));
 }
예제 #4
0
 /**
  * Add a comment
  *
  * @return void
  */
 public function addAction()
 {
     /**
      * @var $request Zend_Controller_Request_Http
      */
     $request = $this->getRequest();
     // Retrieve id of commented object
     $pid = intval($request->getParam('pid'));
     $ns = new Zend_Session_Namespace('Comment_CommentsController');
     $ns->setExpirationHops(1);
     $form = new Comment_Form_Comment();
     if (isset($ns->commentFormData)) {
         $form->setDefaults($ns->commentFormData);
         foreach ($ns->commentFormErrorsMessages as $elementName => $error) {
             $form->getElement($elementName)->addErrors($error);
         }
     }
     $fromRoute = Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName();
     $toRoute = $this->urlHelper->url();
     if ('comment_add' !== $fromRoute) {
         $ns->commentFromRoute = $fromRoute;
         $toRoute = $toRoute . '/comment';
     }
     $form->setAction($toRoute);
     if ($request->isPost()) {
         $parentModel = new $this->_parentModelClass();
         $parentObject = $parentModel->find($pid)->current();
         if (!$parentObject) {
             throw new Zend_Controller_Action_Exception('Unable to find commented object in database', 500);
         }
         if ($form->isValid($request->getParam('commentForm'))) {
             $commentsModel = new Comment_Model_DbTable_Comment();
             $data = $form->getValues(true);
             $data['pid'] = $pid;
             $identity = Zend_Auth::getInstance();
             if ($identity->hasIdentity()) {
                 $data['uid'] = $identity->getIdentity()->uid;
                 $data['name'] = $identity->getIdentity()->username;
                 $data['email'] = $identity->getIdentity()->email;
             }
             $data['created_on'] = time();
             $commentsModel->insert($data);
         } else {
             $ns->commentFormData = $form->getValues();
             $ns->commentFormErrorsMessages = $form->getMessages(null, true);
         }
         $this->_redirect($this->urlHelper->url(array('pid' => $pid), $ns->commentFromRoute));
     }
     $this->view->assign('form', $form);
 }
예제 #5
0
 /**
  * Deletes a forum and all its threads
  *
  * @return void
  */
 public function deleteAction()
 {
     /**
      * @var $request Zend_Controller_Request_Http
      */
     $request = $this->getRequest();
     $fid = intval($request->getParam('fid'));
     $model = new Forum_Model_DbTable_Forum();
     $forum = $model->find($fid)->current();
     if ($forum) {
         $forum->delete();
     }
     $this->_redirect($this->urlHelper->url(array(), 'forum_index'));
 }
예제 #6
0
 /**
  * Delete a thread
  *
  * @throws Zend_Controller_Action_Exception
  * @return void
  */
 public function deleteThreadAction()
 {
     echo $this->urlHelper->url(array(), 'forum_add');
     //echo $this->_helper->url('delete.thread', null, null, array('tid' => '100'));
     exit;
     /**
      * @var $request Zend_Controller_Request_Http
      */
     $request = $this->getRequest();
     echo '<pre>';
     echo "deleteThreadAction\n";
     print_r($request->getParams());
     exit;
     // TODO Delete rows from dependent tables (posts)
     // TODO Forum posts counter must be updated
     // TODO Forum threads counter must be updated
     // TODO Forum lastpost_date, lastposter_username, lastposter_id, lastthread_id, lastthread_subject must be checked and updated if neede
     // TODO User(s) posts counter must be updated
 }
예제 #7
0
파일: Mvc.php 프로젝트: realfluid/umbaugh
    /**
     * Returns href for this page
     *
     * This method uses {@link Zend_Controller_Action_Helper_Url} to assemble
     * the href based on the page's properties.
     *
     * @return string  page href
     */
    public function getHref()
    {
        if ($this->_hrefCache) {
            return $this->_hrefCache;
        }

        if (null === self::$_urlHelper) {
            self::$_urlHelper =
                Zend_Controller_Action_HelperBroker::getStaticHelper('Url');
        }

        $params = $this->getParams();

        if ($param = $this->getModule()) {
            $params['module'] = $param;
        }

        if ($param = $this->getController()) {
            $params['controller'] = $param;
        }

        if ($param = $this->getAction()) {
            $params['action'] = $param;
        }

        $url = self::$_urlHelper->url($params,
                                      $this->getRoute(),
                                      $this->getResetParams());

        return $this->_hrefCache = $url;
    }
예제 #8
0
파일: Mvc.php 프로젝트: Tony133/zf-web
 /**
  * Returns href for this page
  *
  * This method uses {@link Zend_Controller_Action_Helper_Url} to assemble
  * the href based on the page's properties.
  *
  * @return string  page href
  */
 public function getHref()
 {
     if ($this->_hrefCache) {
         return $this->_hrefCache;
     }
     if (null === self::$_urlHelper) {
         self::$_urlHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Url');
     }
     $params = $this->getParams();
     if ($param = $this->getModule()) {
         $params['module'] = $param;
     }
     if ($param = $this->getController()) {
         $params['controller'] = $param;
     }
     if ($param = $this->getAction()) {
         $params['action'] = $param;
     }
     // [START] Modified by webligo developments
     $router = self::$_urlHelper->getFrontController()->getRouter();
     $routeName = $this->getRoute();
     if ($router->hasRoute($routeName)) {
         $route = $router->getRoute($routeName);
         if (method_exists($route, 'getDefaults')) {
             $defaults = $route->getDefaults();
             foreach ($params as $key => $value) {
                 if (isset($defaults[$key]) && $defaults[$key] == $value) {
                     unset($params[$key]);
                 }
             }
         }
     }
     // [END] Modified by webligo developments
     $url = self::$_urlHelper->url($params, $this->getRoute(), $this->getResetParams());
     return $this->_hrefCache = $url;
 }
예제 #9
0
 /**
  * Returns href for this page
  *
  * @return string|null
  */
 public function getHref()
 {
     if (null === self::$_urlHelper) {
         self::$_urlHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('url');
     }
     return self::$_urlHelper->url(array_merge($this->_params, array('module' => $this->_module, 'controller' => $this->_controller, 'action' => $this->_action)), $this->_route, $this->_resetParams);
 }