Exemplo n.º 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);
 }
Exemplo n.º 2
0
 /**
  * Renders a simple editable child node.
  *
  * @param Model $model
  *   The model, which hosts all the data we need.
  *
  * @return string
  *   The generated markup from the template files.
  */
 public function renderSingleEditableChild(Model $model)
 {
     $template = $this->getTemplateFileContent('singleEditableChild');
     $element = $this->getTemplateFileContent('single' . $model->getType());
     $element = str_replace('{name}', $model->getData(), $element);
     $element = str_replace('{value}', $model->getName(), $element);
     // For dropdown elements, we need to render the options.
     if ($model->getType() === 'Select') {
         $option = $this->getTemplateFileContent('single' . $model->getType() . 'Options');
         // Here we store what the list of possible values.
         switch ($model->getData()) {
             case "destination":
                 // Frontend or file.
                 $valueList = array('frontend', 'file');
                 break;
             case "skin":
                 // Get a list of all skin folders.
                 $valueList = $this->getSkinList();
                 break;
             default:
                 // true/false
                 $valueList = array('true', 'false');
                 break;
         }
         // Paint it.
         $options = '';
         foreach ($valueList as $value) {
             if ($value === $model->getName()) {
                 // This one is selected.
                 $selected = 'selected="selected"';
             } else {
                 $selected = '';
             }
             $options .= str_replace(array('{text}', '{value}', '{selected}'), array($value, $value, $selected), $option);
         }
         // Now we replace the options in the output.
         $element = str_replace('{options}', $options, $element);
     }
     $template = str_replace('{name}', $model->getData(), $template);
     $template = str_replace('{source}', $model->getNormal(), $template);
     $template = str_replace('{normal}', $element, $template);
     $template = str_replace('{type}', 'editable', $template);
     $template = str_replace('{help}', $this->renderHelp($model->getHelpid()), $template);
     return $template;
 }
Exemplo n.º 3
0
 /**
  * Analyses the type and then decides what to do with it
  *
  * @param Model $model
  *   The type we are analysing, for example 'private array'.
  *
  * @return string
  *   Possible values:
  *   - concatenation
  *   - method
  *   - property
  */
 protected function analyseType(Model $model)
 {
     $type = $model->getType();
     $multiline = $model->getMultiLineCodeGen();
     $concatenation = 'concatenation';
     $method = 'method';
     $property = 'property';
     $stop = 'stop';
     // Debug methods are always public.
     if ($type === 'debug method' || $this->counter === 0) {
         return $concatenation;
     }
     // Test for constants.
     if ($type === 'class internals' && $model->getName() === 'Constants') {
         // We must only take the stuff from the constant itself
         return $stop;
     }
     // Test for  multiline code generation.
     if (!empty($multiline)) {
         return $multiline;
     }
     // Test for protected or private.
     if (strpos($type, 'protected') === false && strpos($type, 'private') === false) {
         // Is not protected.
         return $concatenation;
     }
     // Test if we are inside the scope.
     if (self::isInScope($type)) {
         // We are inside the scope, this value, function or class is reachable.
         return $concatenation;
     }
     // We are still here? Must be a protected method or property.
     if (strpos($type, 'method') === false) {
         // This is not a method.
         return $property;
     } else {
         return $method;
     }
 }