original_string: public function cmdDeletePage()
      {
          $id = $this->getParam(0);
          $all = $this->getParam('all');
          $blog = $this->getParam('blog');
  
          if (empty($id) && empty($all) && empty($blog)) {
              $this->errorAndExit($this->text('Invalid command'));
          }
  
          if (isset($id) && (empty($id) || !is_numeric($id))) {
              $this->errorAndExit($this->text('Invalid argument'));
          }
  
          $options = null;
  
          if (isset($id)) {
  
              if ($this->getParam('store')) {
                  $options = array('store_id' => $id);
              } else if ($this->getParam('category')) {
                  $options = array('category_id' => $id);
              } else if ($this->getParam('user')) {
                  $options = array('user_id' => $id);
              }
  
          } else if ($blog) {
              $options = array('blog_post' => true);
          } else if ($all) {
              $options = array();
          }
  
          if (isset($options)) {
  
              $deleted = $count = 0;
              foreach ($this->page->getList($options) as $item) {
                  $count++;
                  $deleted += (int) $this->page->delete($item['page_id']);
              }
  
              $result = $count && $count == $deleted;
  
          } else {
              $result = $this->page->delete($id);
          }
  
          if (empty($result)) {
              $this->errorAndExit($this->text('Unexpected result'));
          }
  
          $this->output();
      }
code: public function cmdDeletePage()
      {
          $id = $this->getParam(0);
          $all = $this->getParam('all');
          $blog = $this->getParam('blog');
  
          if (empty($id) && empty($all) && empty($blog)) {
              $this->errorAndExit($this->text('Invalid command'));
          }
  
          if (isset($id) && (empty($id) || !is_numeric($id))) {
              $this->errorAndExit($this->text('Invalid argument'));
          }
  
          $options = null;
  
          if (isset($id)) {
  
              if ($this->getParam('store')) {
                  $options = array('store_id' => $id);
              } else if ($this->getParam('category')) {
                  $options = array('category_id' => $id);
              } else if ($this->getParam('user')) {
                  $options = array('user_id' => $id);
              }
  
          } else if ($blog) {
              $options = array('blog_post' => true);
          } else if ($all) {
              $options = array();
          }
  
          if (isset($options)) {
  
              $deleted = $count = 0;
              foreach ($this->page->getList($options) as $item) {
                  $count++;
                  $deleted += (int) $this->page->delete($item['page_id']);
              }
  
              $result = $count && $count == $deleted;
  
          } else {
              $result = $this->page->delete($id);
          }
  
          if (empty($result)) {
              $this->errorAndExit($this->text('Unexpected result'));
          }
  
          $this->output();
      }
code_tokens: public function cmdDeletePage ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; $ blog = $ this -> getParam ( 'blog' ) ; if ( empty ( $ id ) && empty ( $ all ) && empty ( $ blog ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( isset ( $ id ) && ( empty ( $ id ) || ! is_numeric ( $ id ) ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ options = null ; if ( isset ( $ id ) ) { if ( $ this -> getParam ( 'store' ) ) { $ options = array ( 'store_id' => $ id ) ; } else if ( $ this -> getParam ( 'category' ) ) { $ options = array ( 'category_id' => $ id ) ; } else if ( $ this -> getParam ( 'user' ) ) { $ options = array ( 'user_id' => $ id ) ; } } else if ( $ blog ) { $ options = array ( 'blog_post' => true ) ; } else if ( $ all ) { $ options = array ( ) ; } if ( isset ( $ options ) ) { $ deleted = $ count = 0 ; foreach ( $ this -> page -> getList ( $ options ) as $ item ) { $ count ++ ; $ deleted += ( int ) $ this -> page -> delete ( $ item [ 'page_id' ] ) ; } $ result = $ count && $ count == $ deleted ; } else { $ result = $ this -> page -> delete ( $ id ) ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; }
docstring: Callback for "page-delete" command
docstring_tokens: Callback for page - delete command