The followings are the available columns in table 'url_alias':
Наследование: extends CActiveRecord
Пример #1
0
 public function setGotoRoute(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
 {
     $router = $this->getFrontController()->getRouter();
     $currentModule = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
     if ($currentModule !== 'frontend') {
         $url = $router->assemble($urlOptions, $name, $reset, $encode);
         $this->_redirect($url);
     }
     $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
     $tempPageParams = array();
     if (array_key_exists('page', $urlOptions)) {
         $controller = isset($urlOptions['controller']) ? $urlOptions['controller'] : 'index';
         $action = isset($urlOptions['action']) ? $urlOptions['action'] : 'index';
         foreach ($urlOptions as $key => $value) {
             if (!in_array($key, array('module', 'controller', 'action')) && !($key == 'id' && $controller == 'category' && $action == 'products') && !($key == 'brandId' && $controller == 'brand' && $action == 'brandproducts')) {
                 $tempPageParams[$key] = $value;
                 unset($urlOptions[$key]);
             }
         }
     }
     $url = $router->assemble($urlOptions, $name, $reset, $encode);
     $urlAliasModel = new UrlAlias();
     $source = $urlAliasModel->getUriFromUrl($url, $view->baseUrl());
     $alias = $urlAliasModel->getAliasBySource($source);
     if (count($tempPageParams) > 0 && $alias == $source) {
         $this->_redirect($router->assemble($tempPageParams + $urlOptions, $name, $reset, $encode));
     }
     $this->_redirect($view->baseUrl() . '/' . $alias . (count($tempPageParams) == 0 ? '' : $this->stringifyParams($tempPageParams)));
 }
Пример #2
0
 public function url(array $urlOptions = array(), $name = 'default', $reset = true, $encode = true)
 {
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $currentModule = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
     if ($currentModule != 'frontend') {
         return $router->assemble($urlOptions, $name, $reset, $encode);
     }
     $tempPageParams = array();
     if (array_key_exists('page', $urlOptions)) {
         $controller = isset($urlOptions['controller']) ? $urlOptions['controller'] : 'index';
         $action = isset($urlOptions['action']) ? $urlOptions['action'] : 'index';
         foreach ($urlOptions as $key => $value) {
             if (!in_array($key, array('module', 'controller', 'action'))) {
                 $tempPageParams[$key] = $value;
                 unset($urlOptions[$key]);
             }
         }
     }
     $url = $router->assemble($urlOptions, $name, $reset, $encode);
     $urlAliasModel = new UrlAlias();
     $source = $urlAliasModel->getUriFromUrl($url, $this->view->baseUrl());
     $alias = $urlAliasModel->getAliasBySource($source);
     //  echo $source.'ddd';die;
     if (count($tempPageParams) > 0 && $alias == $source) {
         return $router->assemble($tempPageParams + $urlOptions, $name, $reset, $encode);
     }
     //  echo $this->view->baseUrl() . '/' . $alias . ((count($tempPageParams) == 0) ? '' : $this->stringifyParams($tempPageParams));die;
     return $this->view->baseUrl() . '/' . $alias . (count($tempPageParams) == 0 ? '' : $this->stringifyParams($tempPageParams));
 }
Пример #3
0
 /**
  * delete url rewriting 
  * @author EL GUENNUNI Sohaib s.elguennuni@gmail.com
  * @param 
  * @return 
  */
 public function deleteAction()
 {
     $this->title = 'Delete url';
     $form = new DeleteForm();
     $urlModel = new UrlAlias();
     if ($this->getRequest()->isPost()) {
         $urlModel->deleteById($this->_getParam('id'));
         $this->_helper->FlashMessenger(array('msg-success' => 'The url was successfully deleted.'));
         //Regenerate Flag and Flippers
         App_FlagFlippers_Manager::save();
         $this->_redirect('/url/');
     } else {
         $id = $this->_getParam('id');
         $row = $urlModel->findById($id);
         if (empty($row)) {
             $this->_helper->FlashMessenger(array('msg-warning' => sprintf('We cannot find url with id %s', $id)));
             $this->_redirect('/url/');
         }
         $form->populate($row->toArray());
         $this->view->item = $row;
     }
     $this->view->form = $form;
 }
Пример #4
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.'));
     }
 }
Пример #5
0
 public function saveUserAlias($userId)
 {
     //die;
     $user = new Member();
     $user = $user->fetchRow("member_id='" . $userId . "'");
     // var_dump($login);die;
     $urlAliasModel = new UrlAlias();
     $paramsAlias = array("module" => "frontend", "controller" => "profile", "action" => "index", "id" => $user->member_id);
     if (isset($user->first_name) && isset($user->last_name)) {
         $profileAlias = $user->first_name . '.' . $user->last_name;
         if ($urlAliasModel->getByAlias($profileAlias)) {
             $randInt = 1;
             while ($urlAliasModel->getByAlias($profileAlias . $randInt)) {
                 $randInt++;
             }
             $profileAlias = $profileAlias . $randInt;
         }
         $urlAliasModel->saveAlias('profile/' . $profileAlias, $paramsAlias, false, true);
     }
 }
Пример #6
0
 /**
  * Init Request
  * @return Zend_Controller_Request_Http
  */
 protected function _initRequest()
 {
     if (CURRENT_MODULE == 'frontend') {
         $front = Zend_Controller_Front::getInstance();
         $request = new Zend_Controller_Request_Http();
         $front->setRequest($request);
         $router = $front->getRouter();
         $route = new Zend_Controller_Router_Route_Static('dsrpc.html', array('controller' => 'wsclientpoint', 'action' => 'index'));
         $rewriteUrlArray = array();
         $rewriteUrlArray[''] = array('controller' => 'index', 'action' => 'index');
         $auth = Zend_Auth::getInstance();
         foreach ($rewriteUrlArray as $key => $value) {
             $router->addRoute($key, new Zend_Controller_Router_Route_Static($key, array('controller' => $value['controller'], 'action' => $value['action'])));
         }
         $urlAliasModel = new UrlAlias();
         $url = $request->getRequestUri();
         /**
          * If the alias contains a pagination
          */
         $pagePosition = strpos($url, '--page-');
         $pageParams = array();
         if ($pagePosition !== false) {
             $stringParams = substr($url, $pagePosition + 2, strlen($url));
             $pageParams = explode('-', $stringParams);
             $url = substr($url, 0, $pagePosition);
         }
         /**
          * /If
          */
         $alias = $urlAliasModel->getUriFromUrl($url, $request->getBaseUrl());
         $aliasItem = $urlAliasModel->getByAlias($alias);
         //var_dump($aliasItem->params);die;
         if ($aliasItem !== false) {
             $paramArray = (array) json_decode($aliasItem->params);
             if (count($pageParams) > 0) {
                 $alias .= '-';
                 $i = 0;
                 foreach ($pageParams as $param) {
                     $alias .= '-' . $param;
                     if ($i % 2 == 0 && $pageParams[$i + 1] != '') {
                         $paramArray[$param] = $pageParams[$i + 1];
                     }
                     $i++;
                 }
             }
             $router->addRoute($alias, new Zend_Controller_Router_Route_Static($alias, $paramArray));
         }
         /**
          * Rewrite the captchas path
          */
         $route = new Zend_Controller_Router_Route('captcha/:filename', array('controller' => 'file', 'action' => 'getcaptcha'));
         $router->addRoute('captchas', $route);
         return $request;
     }
 }
Пример #7
0
 public function deleteAlias(UrlAlias $toDelete)
 {
     $permissionEngine = PermissionEngine::getInstance();
     if (!$permissionEngine->currentUserCanDo('canDeleteUrlAliases')) {
         return false;
     }
     $database = Database::getInstance();
     if (!$database->isConnected()) {
         return false;
     }
     $id = $database->escapeString($toDelete->getID());
     if (!is_numeric($id)) {
         return false;
     }
     $deleted = $database->removeData('urlAlias', "aliasID={$id}");
     if ($deleted === false) {
         return false;
     }
     return true;
 }