Exemple #1
0
 /**
  * edit url rewriting 
  * @author EL GUENNUNI Sohaib s.elguennuni@gmail.com
  * @param 
  * @return 
  */
 public function editAction()
 {
     $this->title = 'Edit url';
     $form = new UrlRewritingForm();
     $urlModel = new UrlAlias();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $urlModel->save($form->getValues());
             $this->_helper->FlashMessenger(array('msg-success' => 'The url was successfully edited.'));
             //Regenerate Flag and Flippers
             App_FlagFlippers_Manager::save();
             $this->_redirect('/url/');
         }
     } else {
         $id = $this->_getParam('id');
         //   var_dump($id);die;
         if (!is_numeric($id)) {
             $this->_helper->FlashMessenger(array('msg-error' => 'The provided url_id is invalid.'));
             $this->_redirect('/url/');
         }
         $row = $urlModel->findById($id);
         if (empty($row)) {
             $this->_helper->FlashMessenger(array('msg-warning' => 'The requested url could not be found.'));
             $this->_redirect('/url/');
         }
         $form->populate($row->toArray());
         $this->view->item = $row;
     }
     $this->view->form = $form;
 }
Exemple #2
0
 public function updateSEOKeyword($keyword)
 {
     if (!$this->isNewRecord) {
         $alias = $this->getUrlAlias();
         // if keyword is empty delete url alias
         if (empty($keyword) || is_null($keyword)) {
             if (!is_null($alias)) {
                 return $alias->delete();
             }
             return false;
         } else {
             if (is_null($alias)) {
                 $alias = new UrlAlias();
                 $alias->query = "category_id={$this->category_id}";
             }
             $alias->keyword = $keyword;
             return $alias->save();
         }
     } else {
         throw new CException(Yii::t('errors', 'Tried to update SEO Keyword for an object that doesn\'t exists yet.'));
     }
 }