/** * Renders a expandable child with a callback in the middle. * * @param Model $model * The model, which hosts all the data we need. * @param bool $isExpanded * Is this one expanded from the beginning? * TRUE when we render the settings menu only. * * @return string * The generated markup from the template files. */ public function renderExpandableChild(Model $model, $isExpanded = false) { // Check for emergency break. if (!$this->storage->emergencyHandler->checkEmergencyBreak()) { return ''; } // We need to render this one normally. $template = $this->getTemplateFileContent('expandableChildNormal'); // Replace our stuff in the partial. $template = str_replace('{name}', $model->getName(), $template); $template = str_replace('{type}', $model->getType(), $template); // Explode the type to get the class names right. $types = explode(' ', $model->getType()); $cssType = ''; foreach ($types as $singleType) { $cssType .= ' k' . $singleType; } $template = str_replace('{ktype}', $cssType, $template); $template = str_replace('{additional}', $model->getAdditional(), $template); $template = str_replace('{help}', $this->renderHelp($model->getHelpid()), $template); $template = str_replace('{connector1}', $this->renderConnector($model->getConnector1()), $template); $template = str_replace('{connector2}', $this->renderConnector($model->getConnector2()), $template); // Generating our code and adding the Codegen button, if there is // something to generate. $gencode = $this->storage->codegenHandler->generateSource($model); $template = str_replace('{gensource}', $gencode, $template); if ($gencode === ';stop;' || empty($gencode)) { // Remove the button marker, because here is nothing to add. $template = str_replace('{sourcebutton}', '', $template); } else { // Add the button. $template = str_replace('{sourcebutton}', $this->getTemplateFileContent('sourcebutton'), $template); } // Is it expanded? if ($isExpanded) { $template = str_replace('{isExpanded}', 'kopened', $template); } else { $template = str_replace('{isExpanded}', '', $template); } return str_replace('{nest}', $this->storage->chunks->chunkMe($this->renderNest($model, $isExpanded)), $template); }
/** * Simple concatenation of all parameters. * * @param \Brainworxx\Krexx\Analyse\Model $model * * @return string * The generated code. */ protected function concatenation(Model $model) { // We simply add the connectors for public access. // Escape the quotes. This is not done by the model. $name = str_replace('"', '"', $model->getName()); $name = str_replace("'", ''', $name); return $model->getConnector1() . $name . trim($model->getConnector2(), ' = '); }