コード例 #1
0
 /**
  * Dump the PukiWiki output of a page into a html file
  *
  * @param string $page Pagename
  * @param string $file Filename to be dumped. Default is computed from $page. 
  * @param boolean $overwrite Force to overwrite. Default overwrites if $page is newer than $file
  * @return mixed
  *   TRUE : Success
  *   FALSE: Failure
  *   -1   : It is already up2date
  *   -2   : Exit by read-restriction
  *   -3   : Exit because statichtml USER_AGENT called statichtml again (infinite loop)
  */
 function dump_page($page, $file = null, $overwrite = FALSE)
 {
     $ret = parent::dump_page($page, $file, $overwrite);
     if ($ret !== TRUE) {
         return $ret;
     }
     if ($this->modifier->CONF['modify_href'] || $this->modifier->CONF['modify_linkrel']) {
         $file = isset($file) ? $file : $this->get_dump_filename($page);
         $contents = file_get_contents($file);
         $modified = $this->modifier->format($contents, $file);
         if (!file_put_contents($file, $modified)) {
             $this->error = 'Failed to create ' . $file;
             return FALSE;
         }
         // Extra: $defaultpage -> index.html
         if ($page == $GLOBALS['defaultpage'] && !is_page('index')) {
             $file = $this->CONF['DUMPDIR'] . 'index.html';
             $modified = $this->modifier->format($contents, $file);
             if (!file_put_contents($file, $modified)) {
                 $this->error = 'Failed to create ' . $file;
                 return FALSE;
             }
         }
     }
     return TRUE;
 }