Example #1
0
 /**
  * {@inheritDoc}
  */
 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('{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?
     // This is done in the js.
     $template = str_replace('{isExpanded}', '', $template);
     $json = $model->getJson();
     $json['Help'] = $this->storage->messages->getHelp($model->getHelpid());
     $json = json_encode($json);
     $template = str_replace('{addjson}', $json, $template);
     return str_replace('{nest}', $this->storage->chunks->chunkMe($this->renderNest($model, false)), $template);
 }
Example #2
0
 /**
  * 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);
 }
Example #3
0
 /**
  * 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('"', '&#034;', $model->getName());
     $name = str_replace("'", '&#039;', $name);
     return $model->getConnector1() . $name . trim($model->getConnector2(), ' = ');
 }