/** * This method is intend to render the current state of the view as html. For this it makes use of the base * template engine, and html5 template files. If you need another output or something like this, you must * overwrite this method. * * @param array $data The data as override for internal stored data * @param string $fingerprint Optional fingerprint used as cache identifier for front- and * backend! Hint: Rendering user specific data an user identifier * MUST be used as salt when generating the fingerprint!!! * Otherwise user specific data can and will be sent to another * user!. So the following rule should be followed: * - generic view/template no user data = fingerprint by * content/path/url * - user specific view/template with user data = use * session-id or user-id! * @param Doozr_I18n_Service_Interface $i18n An instance of a Doozr I18n service * * @author Benjamin Carl <*****@*****.**> * * @return bool TRUE if successful, otherwise FALSE * * @throws Doozr_Cache_Service_Exception * @throws Doozr_Base_View_Exception * @throws Doozr_Exception * @throws PHPTAL_ConfigurationException */ protected function render(array $data = [], $fingerprint = null, Doozr_I18n_Service_Interface $i18n = null) { $this->setFingerprint($this->generateFingerprint($fingerprint, $data)); $html = null; if (false === $this->getConfiguration()->kernel->debugging->enabled) { // We try to receive data for rendering from cache :) this is much faster try { $html = $this->cache->read($this->getFingerprint()); } catch (Doozr_Cache_Service_Exception $e) { $html = null; } } // If data was/could not be retrieved we get it fresh here ... if ($html === null) { // Get name of template file $templateFile = $this->configuration->kernel->view->template->path . $this->translateToTemplateFilename() . '.' . $this->getTemplateExtension(); if (false === $this->getRegistry()->getFilesystem()->exists($templateFile)) { throw new Doozr_Base_View_Exception(sprintf('The template file "%s" is required for rendering but it does not exist.', $templateFile)); } /* @var $template PHPTAL */ $template = Doozr_Loader_Serviceloader::load('template', $templateFile); // Set output runtimeEnvironment ... $template->setOutputMode($this->getOutputMode()); // if I18n passed -> forward to template engine (e.g. PHPTAL) if (null !== $i18n) { $i18n->useDomain($this->translateToTextdomain()); $template->setTranslator($i18n); $template->{'doozr_locale'} = $i18n->getLocale(); } // Assign data from passed in array to template (for use as a template variable) foreach ($data as $key => $value) { $template->{$key} = $value; } // setup template compile output dir $template->setPhpCodeDestination($this->configuration->kernel->view->directories->compiled); // set the encoding of output $template->setEncoding($this->configuration->kernel->localization->encoding); // Output XHTML or HTML5 ... ? $template->setOutputMode($this->configuration->kernel->view->settings->outputmode); // execute = get result $html = $template->execute(); if (true === $this->isDebugging()) { $renderer = $this->getRegistry()->getDebugbar()->getJavascriptRenderer(); $renderer->setBaseUrl('/assets'); $head = $renderer->renderHead(); $body = $renderer->render(); $html = str_replace('</head>', $head . '</head>', $html); $html = str_replace('</body>', $body . '</body>', $html); } // finally store in cache try { $this->cache->create($html, $this->getFingerprint()); } catch (Doozr_Cache_Service_Exception $e) { pred($e); } } return $html; }
public function toJson() { foreach ($this->arguments as $argument => $value) { pred($argument); } }
/** * calculates the score for the differences between two passwords. * * This method is intend to calculate a score of difference between two given passwords. * Usage: e.g. scoreDifference('myPassword', 'myPassword123'); * Returns an indicator for the * * @param string $passwordOne The first password * @param string $passwordTwo The second password * * @author Benjamin Carl <*****@*****.**> * * @return float The score * * @throws Doozr_Exception */ public function scoreDifference($passwordOne = null, $passwordTwo = null) { // check input if (!$passwordOne) { throw new Doozr_Exception('Missing input parameter one: $passwordOne for calculating score!'); } elseif (!$passwordOne) { throw new Doozr_Exception('Missing input parameter two: $passwordTwo for calculating score!'); } /* * basic check - shortcut */ if ($passwordOne == $passwordTwo) { return 0; } /* * get cologne phonetic - soundex() works only good on english words */ pre($this->_getColognePhonetic($passwordOne)); pre($this->_getColognePhonetic($passwordTwo)); /* * calculate difference of length between the two strings */ $scoreDiffLength = abs(strlen($passwordOne) - strlen($passwordTwo)); /* * get ASCII score * using different character's */ $scoreDiffAscii = abs($this->_asciiSum($passwordOne) - $this->_asciiSum($passwordTwo)) / 1000; pred($scoreDiffAscii); }
public function update(SplSubject $subject) { pred($subject); }
/** * Parses elements from passed array of elements-HTML. * * @param array $elements The elements to use ... * * @author Benjamin Carl <*****@*****.**> * * @return array The resulting structure */ protected function parseElements(array $elements) { // assume empty result $result = []; //@todo check input? // get count of inner elements $countElements = count($elements[1]); pred($elements); // iterate elements of <form> for ($j = 0; $j < $countElements; ++$j) { // get properties $element = $this->parsePropertiesFromHtml($elements[1][$j]); // rearrange them $element = $this->prepareStructureAndData($element); // check fieldname for existence of our own prefix so rip off $fieldName = isset($element['properties']['name']) ? substr($element['properties']['name'], 0, strlen(Doozr_Form_Service_Constant::PREFIX)) : ''; if ($fieldName !== Doozr_Form_Service_Constant::PREFIX) { // get Id $id = $this->getId($element['properties']); // inject Id $element['properties']['id'] = $id; // get template identifier $templateIdentifier = $this->buildTemplateIdentifier($id, isset($element['properties']['type']) ? $element['properties']['type'] : $element['tag']); $this->template = str_replace($elements[1][$j], $templateIdentifier, $this->template); // drop into result $result[] = $element; } } return $result; }
/** * validates if given value fulfill the requirement "impact". * * This method is intend to validation if given value fulfill the requirement "impact". * * @param mixed $value The value to validation * * @author Benjamin Carl <*****@*****.**> * * @return bool TRUE if fulfilled requirements, otherwise FALSE */ public function validateImpact($value) { // pre($value); pred('and how should we get the impact now?'); }