set('runOrder', 0); } /** * Optional method to initialize the module. * * This is called after ProcessWire's API is fully ready for use and hooks * */ public function init() { } /** * The compile method processes the contents of a file * * 1. If you want to compile the entire contents of the file, override this method and don't parent::compile(). * 2. If you only want to compile non-PHP sections of the file, implement the compileMarkup() method instead. * * @param string $data * @return string * */ public function compile($data) { // extract markup sections $openPos = strpos($data, ''); if($closePos === false) { // document contains no closing PHP tag if($openPos === false) { // document also has no open PHP tag: must be all markup return $this->compileMarkup($data); } else if($openPos === 0) { // document is all PHP return $data; } } $trimFront = false; if($openPos !== 0) { $data = '?>' . $data; $trimFront = true; } $data .= '(.+?)<\?!s', $data, $matches)) return array(); foreach($matches[1] as $key => $markup) { $_markup = $this->compileMarkup($markup); if($_markup !== $markup) { $data = str_replace("?>$markup$_markupsourceFile = $file; } /** * Get the source file (full path and filename) that this module is acting upon * * @return string * */ public function getSourceFile() { return $this->sourceFile; } /** * Configure the FileCompiler module * * @param InputfieldWrapper $inputfields * */ public function getModuleConfigInputfields(InputfieldWrapper $inputfields) { $f = $this->wire('modules')->get('InputfieldInteger'); $f->attr('name', 'runOrder'); $f->attr('value', (int) $this->get('runOrder')); $f->label = $this->_('Runtime execution order'); $f->description = $this->_('Order that this module runs in relative to other FileCompiler modules. Lower numbers run first.'); $inputfields->add($f); } }