/** * Renders the second part of the fatal error handler. * * @param string $type * The type of the error (should always be fatal). * @param string $errstr * The string from the error. * @param string $errfile * The file where the error occurred. * @param int $errline * The line number where the error occurred. * * @return string * The template file, with all markers replaced. */ public function renderFatalMain($type, $errstr, $errfile, $errline) { $template = $this->getTemplateFileContent('fatalMain'); $from = $errline - 5; $to = $errline + 5; $source = $this->storage->readSourcecode($errfile, $errline - 1, $from - 1, $to - 1); // Insert our values. $template = str_replace('{type}', $type, $template); $template = str_replace('{errstr}', $errstr, $template); $template = str_replace('{file}', $errfile, $template); $template = str_replace('{source}', $source, $template); $template = str_replace('{KrexxCount}', $this->storage->emergencyHandler->getKrexxCount(), $template); return str_replace('{line}', $errline, $template); }
/** * Gets the original data from the string. * * Reads the data from a file in the chunks folder. * The output may contain other chunk keys. * nothing more then a wrapper for file_get_contents() * * @param string $key * The key of the chunk of which we want to get the data. * * @return string * The original date * */ protected function dechunkMe($key) { $filename = $this->krexxDir . 'chunks/' . $key . '.Krexx.tmp'; if (is_writable($filename)) { // Read the file. $string = $this->storage->getFileContents($filename); // Delete it, we don't need it anymore. unlink($filename); } else { // Huh, we can not fully access this one. $string = 'Could not access chunk file ' . $filename; $this->storage->messages->addMessage('Could not access chunk file ' . $filename); } return $string; }
/** * Analyses a closure. * * @param Model $model * The closure we want to analyse. * * @return string * The generated markup. */ public function analyseClosure(Model $model) { $ref = new \ReflectionFunction($model->getData()); $result = array(); // Adding comments from the file. $methodclass = new ThroughMethods($this->storage); $result['comments'] = $methodclass->prettifyComment($ref->getDocComment()); // Adding the sourcecode $highlight = $ref->getStartLine() - 1; $from = $highlight - 3; $to = $ref->getEndLine() - 1; $file = $ref->getFileName(); $result['source'] = $this->storage->readSourcecode($file, $highlight, $from, $to); // Adding the place where it was declared. $result['declared in'] = $ref->getFileName() . "\n"; $result['declared in'] .= 'in line ' . $ref->getStartLine(); // Adding the namespace, but only if we have one. $namespace = $ref->getNamespaceName(); if (!empty($namespace)) { $result['namespace'] = $namespace; } // Adding the parameters. $parameters = $ref->getParameters(); $paramList = ''; foreach ($parameters as $parameter) { preg_match('/(.*)(?= \\[ )/', $parameter, $key); $parameter = str_replace($key[0], '', $parameter); $result[$key[0]] = trim($parameter, ' []'); $paramList .= trim($result[$key[0]]) . ', '; } $paramList = str_replace(array('<required> ', '<optional> '), '', $this->storage->encodeString($paramList)); // Remove the ',' after the last char. $paramList = '<small>' . trim($paramList, ', ') . '</small>'; $model->setType($model->getAdditional() . ' closure')->setAdditional('. . .')->setConnector2($model->getConnector2() . '(' . $paramList . ')')->setDomid($this->generateDomIdFromObject($model->getData()))->addParameter('data', $result)->initCallback('Iterate\\ThroughMethodAnalysis'); return $this->storage->render->renderExpandableChild($model); }
/** * Outputs the CSS and JS. * * @return string * The generated markup. */ protected function outputCssAndJs() { $krexxDir = $this->storage->config->krexxdir; // Get the css file. $css = $this->storage->getFileContents($krexxDir . 'resources/skins/' . $this->storage->config->getSetting('skin') . '/skin.css'); // Remove whitespace. $css = preg_replace('/\\s+/', ' ', $css); // Adding our DOM tools to the js. if (is_readable($krexxDir . 'resources/jsLibs/kdt.min.js')) { $jsFile = $krexxDir . 'resources/jsLibs/kdt.min.js'; } else { $jsFile = $krexxDir . 'resources/jsLibs/kdt.js'; } $js = $this->storage->getFileContents($jsFile); // Krexx.js is comes directly form the template. $path = $krexxDir . 'resources/skins/' . $this->storage->config->getSetting('skin'); if (is_readable($path . '/krexx.min.js')) { $jsFile = $path . '/krexx.min.js'; } else { $jsFile = $path . '/krexx.js'; } $js .= $this->storage->getFileContents($jsFile); return $this->storage->render->renderCssJs($css, $js); }