static function replaceVars($template, $er = array()) { $r = rex_extension::registerPoint(new rex_extension_point('YFORM_EMAIL_BEFORE_REPLACEVARS', ['template' => $template, 'search_replace' => $er, 'status' => false])); $template = $r['template']; $er = $r['search_replace']; $status = $r['status']; if ($status) { return true; } $er['REX_SERVER'] = rex::getServer(); $er['REX_ERROR_EMAIL'] = rex::getErrorEmail(); $er['REX_SERVERNAME'] = rex::getServerName(); $er['REX_NOTFOUND_ARTICLE_ID'] = rex_article::getNotfoundArticleId(); $er['REX_ARTICLE_ID'] = rex_article::getCurrentId(); $template['body'] = rex_var::parse($template['body'], '', 'yform_email_template', $er); $template['body_html'] = rex_var::parse($template['body_html'], '', 'yform_email_template', $er); // rex_vars bug: sonst wird der Zeilenumbruch entfernt - wenn DATA_VAR am Ende einer Zeile if (rex_string::versionCompare(rex::getVersion(), '5.0.1', '<')) { $template['body'] = str_replace("?>\r", "?>\r\n\r", $template['body']); $template['body'] = str_replace("?>\n", "?>\n\r\n", $template['body']); $template['body_html'] = str_replace("?>\r", "?>\r\n\r", $template['body_html']); $template['body_html'] = str_replace("?>\n", "?>\n\r\n", $template['body_html']); } $template['body'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/body', $template['body'])); $template['body_html'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/body_html', $template['body_html'])); return $template; }
public function exec($type) { if (!in_array($type, [self::PREVIEW, self::PRESAVE, self::POSTSAVE])) { throw new InvalidArgumentException('$type musst be rex_article_action::PREVIEW, ::PRESAVE or ::POSTSAVE'); } $this->messages = []; $this->save = true; $ga = rex_sql::factory(); $ga->setQuery('SELECT a.id, `' . $type . '` as code FROM ' . rex::getTable('module_action') . ' ma,' . rex::getTable('action') . ' a WHERE `' . $type . '` != "" AND ma.action_id=a.id AND module_id=? AND (a.' . $type . 'mode & ?)', [$this->moduleId, $this->mode]); foreach ($ga as $row) { $action = $row->getValue('code'); $action = str_replace($this->vars['search'], $this->vars['replace'], $action); $action = rex_var::parse($action, rex_var::ENV_BACKEND | rex_var::ENV_INPUT, 'action', $this->sql); require rex_stream::factory('action/' . $row->getValue('id') . '/' . $type, $action); } }
public function generate() { $template_id = $this->getId(); if ($template_id < 1) { return false; } $sql = rex_sql::factory(); $qry = 'SELECT * FROM ' . rex::getTablePrefix() . 'template WHERE id = ' . $template_id; $sql->setQuery($qry); if ($sql->getRows() == 1) { $templateFile = self::getFilePath($template_id); $content = $sql->getValue('content'); $content = rex_var::parse($content, rex_var::ENV_FRONTEND, 'template'); if (rex_file::put($templateFile, $content) !== false) { return true; } else { throw new rex_exception('Unable to generate template ' . $template_id . '!'); } } else { throw new rex_exception('Template with id "' . $template_id . '" does not exist!'); } }
protected function replaceObjectVars(rex_sql $sql, $content) { $sliceId = $sql->getValue(rex::getTablePrefix() . 'article_slice.id'); if ($this->mode == 'edit') { $env = rex_var::ENV_BACKEND; if ($this->function == 'add' && $sliceId == null || $this->function == 'edit' && $sliceId == $this->slice_id) { $env = $env | rex_var::ENV_INPUT; } } else { $env = rex_var::ENV_FRONTEND; } $content = rex_var::parse($content, $env, 'module', $sql); return $content; }
protected function getParseOutput($content) { return rex_file::getOutput(rex_stream::factory('rex-var-test', rex_var::parse($content))); }