public function renameAction()
    {
        $this->getResponse()->setTypeJson();
        if (null !== $cat = (new \Cms\Orm\CmsCategoryQuery)->findPk($this->getPost()->id)) {
            $name = trim($this->getPost()->name);
            if (mb_strlen($name) < 2 || mb_strlen($name) > 64) {
                return json_encode(['status' => false, 'error' => $this->view->_('controller.category.rename.validator')]);
            }
            $cat->name = $name;
            if ($cat->save()) {
                return json_encode(['status' => true, 'id' => $cat->id, 'name' => $name, 'message' => $this->view->_('controller.category.rename.message')]);
            }
        }
        return json_encode(['status' => false, 'error' => $this->view->_('controller.category.rename.error')]);
    }
public function renameAction()
    {
        $this->getResponse()->setTypeJson();
        if (null !== $cat = (new \Cms\Orm\CmsCategoryQuery)->findPk($this->getPost()->id)) {
            $name = trim($this->getPost()->name);
            if (mb_strlen($name) < 2 || mb_strlen($name) > 64) {
                return json_encode(['status' => false, 'error' => $this->view->_('controller.category.rename.validator')]);
            }
            $cat->name = $name;
            if ($cat->save()) {
                return json_encode(['status' => true, 'id' => $cat->id, 'name' => $name, 'message' => $this->view->_('controller.category.rename.message')]);
            }
        }
        return json_encode(['status' => false, 'error' => $this->view->_('controller.category.rename.error')]);
    }
public function renameAction ( ) { $ this -> getResponse ( ) -> setTypeJson ( ) ; if ( null !== $ cat = ( new \ Cms \ Orm \ CmsCategoryQuery ) -> findPk ( $ this -> getPost ( ) -> id ) ) { $ name = trim ( $ this -> getPost ( ) -> name ) ; if ( mb_strlen ( $ name ) < 2 || mb_strlen ( $ name ) > 64 ) { return json_encode ( [ 'status' => false , 'error' => $ this -> view -> _ ( 'controller.category.rename.validator' ) ] ) ; } $ cat -> name = $ name ; if ( $ cat -> save ( ) ) { return json_encode ( [ 'status' => true , 'id' => $ cat -> id , 'name' => $ name , 'message' => $ this -> view -> _ ( 'controller.category.rename.message' ) ] ) ; } } return json_encode ( [ 'status' => false , 'error' => $ this -> view -> _ ( 'controller.category.rename.error' ) ] ) ; }
Zmiana nazwy strony
Zmiana nazwy strony