Exemple #1
0
 /**
  * Add a new section to the page
  * @param $heading string
  * @param $content string
  * @param bool $minor
  * @param bool $bot
  * @param bool $retry
  * @return mixed
  */
 public function addSection($heading, $content, $minor = false, $bot = true, $retry = true)
 {
     echo "Adding Section \"{$heading}\" to [[" . $this->title . "]]\n";
     $post = array('title' => $this->title, 'text' => $content, 'md5' => md5($content), 'sectiontitle' => $heading, 'section' => 'new', 'token' => $this->wiki->getedittoken(), 'basetimestamp' => $this->ecTimestamp);
     if ($minor) {
         $post['minor'] = true;
     }
     if ($bot) {
         $post['bot'] = true;
     }
     $x = $this->wiki->query(array('action' => 'edit'), $post);
     if ($x['error']['code'] == 'badtoken' && $retry) {
         $this->wiki->getedittoken(true);
         return $this->addSection($heading, $content, $minor, $bot, false);
     }
     $this->getContent();
     return $x;
 }