public function __construct() { parent::__construct(); // set tracking cookie FrontendModel::getVisitorId(); // add reference Spoon::set('page', $this); // get pageId for requested URL $this->pageId = FrontendNavigation::getPageId(implode('/', $this->URL->getPages())); // set headers if this is a 404 page if ($this->pageId == 404) { $this->statusCode = 404; } // create breadcrumb instance $this->breadcrumb = new FrontendBreadcrumb(); // create header instance $this->header = new FrontendHeader(); // new footer instance $this->footer = new FrontendFooter(); // get pagecontent $this->getPageContent(); // process page $this->processPage(); // execute all extras linked to the page $this->processExtras(); // store statistics $this->storeStatistics(); // display $this->display(); // trigger event FrontendModel::triggerEvent('core', 'after_page_processed', array('id' => $this->getId(), 'record' => $this->getRecord(), 'statusCode' => $this->getStatusCode(), 'sessionId' => SpoonSession::getSessionId(), 'visitorId' => FrontendModel::getVisitorId(), 'SESSION' => $_SESSION, 'COOKIE' => $_COOKIE, 'GET' => $_GET, 'POST' => $_POST, 'SERVER' => $_SERVER)); }
/** * Load the data */ private function loadData() { // get the current page id $pageId = Spoon::get('page')->getId(); $navigation = FrontendNavigation::getNavigation(); $pageInfo = FrontendNavigation::getPageInfo($pageId); $this->navigation = array(); if (isset($navigation['page'][$pageInfo['parent_id']])) { $pages = $navigation['page'][$pageInfo['parent_id']]; // store $pagesPrev = $pages; $pagesNext = $pages; // check for current id foreach ($pagesNext as $key => $value) { if ((int) $key != (int) $pageId) { // go to next pointer in array next($pagesNext); next($pagesPrev); } else { break; } } // get previous page $this->navigation['previous'] = prev($pagesPrev); // get next page $this->navigation['next'] = next($pagesNext); // get parent page $this->navigation['parent'] = FrontendNavigation::getPageInfo($pageInfo['parent_id']); } }
/** * This will disappear in time in favour of container-driven parameters. * @deprecated */ public function defineForkConstants() { $container = $this->getContainer(); Spoon::setDebug($container->getParameter('kernel.debug')); Spoon::setDebugEmail($container->getParameter('fork.debug_email')); Spoon::setDebugMessage($container->getParameter('fork.debug_message')); Spoon::setCharset($container->getParameter('kernel.charset')); /** * @deprecated SPOON_* constants are deprecated in favor of Spoon::set*(). * Will be removed in the next major release. */ defined('SPOON_DEBUG') || define('SPOON_DEBUG', $container->getParameter('kernel.debug')); defined('SPOON_DEBUG_EMAIL') || define('SPOON_DEBUG_EMAIL', $container->getParameter('fork.debug_email')); defined('SPOON_DEBUG_MESSAGE') || define('SPOON_DEBUG_MESSAGE', $container->getParameter('fork.debug_message')); defined('SPOON_CHARSET') || define('SPOON_CHARSET', $container->getParameter('kernel.charset')); defined('PATH_WWW') || define('PATH_WWW', $container->getParameter('site.path_www')); defined('PATH_LIBRARY') || define('PATH_LIBRARY', $container->getParameter('site.path_library')); defined('SITE_DEFAULT_LANGUAGE') || define('SITE_DEFAULT_LANGUAGE', $container->getParameter('site.default_language')); defined('SITE_DEFAULT_TITLE') || define('SITE_DEFAULT_TITLE', $container->getParameter('site.default_title')); defined('SITE_MULTILANGUAGE') || define('SITE_MULTILANGUAGE', $container->getParameter('site.multilanguage')); defined('SITE_DOMAIN') || define('SITE_DOMAIN', $container->getParameter('site.domain')); defined('SITE_PROTOCOL') || define('SITE_PROTOCOL', $container->getParameter('site.protocol')); defined('SITE_URL') || define('SITE_URL', SITE_PROTOCOL . '://' . SITE_DOMAIN); defined('FORK_VERSION') || define('FORK_VERSION', $container->getParameter('fork.version')); defined('ACTION_GROUP_TAG') || define('ACTION_GROUP_TAG', $container->getParameter('action.group_tag')); defined('ACTION_RIGHTS_LEVEL') || define('ACTION_RIGHTS_LEVEL', $container->getParameter('action.rights_level')); }
/** * Load the data */ private function loadData() { // get the current page id $pageId = Spoon::get('page')->getId(); // fetch the items $this->items = FrontendPagesModel::getSubpages($pageId); }
/** * Returns the CampaignMonitor object * * @param int[optional] $listId The default list id to use. * @return CampaignMonitor */ public static function getCM($listId = null) { // campaignmonitor reference exists if (!Spoon::exists('campaignmonitor')) { // check if the CampaignMonitor class exists if (!SpoonFile::exists(PATH_LIBRARY . '/external/campaignmonitor.php')) { // the class doesn't exist, so throw an exception throw new SpoonFileException('The CampaignMonitor wrapper class is not found. Please locate and place it in /library/external'); } // require CampaignMonitor class require_once 'external/campaignmonitor.php'; // set login data $url = FrontendModel::getModuleSetting('mailmotor', 'cm_url'); $username = FrontendModel::getModuleSetting('mailmotor', 'cm_username'); $password = FrontendModel::getModuleSetting('mailmotor', 'cm_password'); // init CampaignMonitor object $cm = new CampaignMonitor($url, $username, $password, 5, self::getClientId()); // set CampaignMonitor object reference Spoon::set('campaignmonitor', $cm); // get the default list ID $listId = !empty($listId) ? $listId : self::getDefaultListID(); // set the default list ID $cm->setListId($listId); } // return the CampaignMonitor object return Spoon::get('campaignmonitor'); }
/** * Stores a value in a cookie, by default the cookie will expire in one day. * * @param string $key A name for the cookie. * @param mixed $value The value to be stored. Keep in mind that they will be serialized. * @param int[optional] $time The number of seconds that this cookie will be available, 30 days is the default. * @param string[optional] $path The path on the server in which the cookie will be availabe. Use / for the entire domain, /foo if you just want it to be available in /foo. * @param string[optional] $domain The domain that the cookie is available on. Use .example.com to make it available on all subdomains of example.com. * @param bool[optional] $secure Should the cookie be transmitted over a HTTPS-connection? If true, make sure you use a secure connection, otherwise the cookie won't be set. * @param bool[optional] $httpOnly Should the cookie only be available through HTTP-protocol? If true, the cookie can't be accessed by Javascript, ... * @return bool If set with succes, returns true otherwise false. */ public static function set($key, $value, $time = 2592000, $path = '/', $domain = null, $secure = null, $httpOnly = true) { // redefine $key = (string) $key; $value = serialize($value); $time = time() + (int) $time; $path = (string) $path; $httpOnly = (bool) $httpOnly; // when the domain isn't passed and the url-object is available we can set the cookies for all subdomains if ($domain === null && Spoon::exists('url')) { $domain = '.' . Spoon::get('url')->getDomain(); } // when the secure-parameter isn't set if ($secure === null) { /* detect if we are using HTTPS, this wil only work in Apache, if you are using nginx you should add the code below into your config: ssl on; fastcgi_param HTTPS on; for lighttpd you should add: setenv.add-environment = ("HTTPS" => "on") */ $secure = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on'; } // set cookie $cookie = setcookie($key, $value, $time, $path, $domain, $secure, $httpOnly); // problem occured return $cookie === false ? false : true; }
public function __construct() { // store in reference so we can access it from everywhere Spoon::set('header', $this); // grab from the reference $this->URL = Spoon::get('url'); $this->tpl = Spoon::get('template'); }
public function __construct() { // add to registry Spoon::set('url', $this); $this->setQueryString($_SERVER['REQUEST_URI']); $this->setHost($_SERVER['HTTP_HOST']); $this->processQueryString(); }
public function testSet() { // set value $value = array('Davy Hellemans', 'Tijs Verkoyen', 'Dave Lens', 'Matthias Mullie'); $this->assertEquals(Spoon::set('salad_fingers', $value), $value); // get rid of value Spoon::set('salad_fingers'); $this->assertFalse(Spoon::exists('salad_fingers')); }
/** * Default constructor * * @return void */ public function __construct() { // add ourself to the reference so other classes can retrieve us Spoon::set('url', $this); // set query-string for later use $this->setQueryString($_SERVER['REQUEST_URI']); // set host for later use $this->setHost($_SERVER['HTTP_HOST']); // process URL $this->processQueryString(); }
/** * You have to specify the action and module so we know what to do with this instance * * @param string $action The action to load. * @param string $module The module to load. */ public function __construct($action, $module) { // grab stuff from the reference and store them in this object (for later/easy use) $this->tpl = Spoon::get('template'); $this->setModule($module); $this->setAction($action); $this->loadConfig(); // is the requested action possible? If not we throw an exception. We don't redirect because that could trigger a redirect loop if (!in_array($this->getAction(), $this->config->getPossibleActions())) { throw new BackendException('This is an invalid action (' . $this->getAction() . ').'); } }
/** * Check if all required settings have been set * * @param string $module The module. */ public function __construct($module) { parent::__construct($module); $this->loadEngineFiles(); $url = Spoon::exists('url') ? Spoon::get('url') : null; // do the client ID check if we're not in the settings page if ($url != null && !in_array($url->getAction(), array('settings', 'import_groups', 'link_account', 'load_client_info'))) { $this->checkForAccount(); $this->checkForClientID(); $this->checkForGroups(); } }
/** * @param string $name Name of the form. * @param string[optional] $action The action (URL) whereto the form will be submitted, if not provided it will be autogenerated. * @param string[optional] $method The method to use when submiting the form, default is POST. * @param string[optional] $hash The id of the anchor to append to the action-URL. * @param bool[optional] $useToken Should we automagically add a formtoken? */ public function __construct($name, $action = null, $method = 'post', $hash = null, $useToken = true) { $this->URL = Spoon::get('url'); $this->header = Spoon::get('header'); $name = (string) $name; $hash = $hash !== null ? (string) $hash : null; $useToken = (bool) $useToken; // build the action if it wasn't provided $action = $action === null ? '/' . $this->URL->getQueryString() : (string) $action; // call the real form-class parent::__construct($name, $action, $method, $useToken); // add default classes $this->setParameter('id', $name); $this->setParameter('class', 'forkForms submitWithLink'); }
/** * Default constructor * * @return void */ public function __construct() { // add ourself to the reference so other classes can retrieve us Spoon::set('url', $this); // if there is a trailing slash we permanent redirect to the page without slash if (mb_strlen($_SERVER['REQUEST_URI']) != 1 && mb_substr($_SERVER['REQUEST_URI'], -1) == '/') { SpoonHTTP::redirect(mb_substr($_SERVER['REQUEST_URI'], 0, -1), 301); } // set query-string for later use $this->setQueryString($_SERVER['REQUEST_URI']); // set host for later use $this->setHost($_SERVER['HTTP_HOST']); // process URL $this->processQueryString(); // set constant define('SELF', SITE_URL . '/' . $this->queryString); }
/** * Default constructor * * @return void */ public function __construct() { // call parent parent::__construct(); // add into the reference Spoon::set('breadcrumb', $this); // get more information for the homepage $homeInfo = FrontendNavigation::getPageInfo(1); // add homepage as first item (with correct element) $this->addElement($homeInfo['navigation_title'], FrontendNavigation::getURL(1)); // get other pages $pages = $this->URL->getPages(); // init vars $items = array(); $errorURL = FrontendNavigation::getUrl(404); // loop pages while (!empty($pages)) { // init vars $URL = implode('/', $pages); $menuId = FrontendNavigation::getPageId($URL); $pageInfo = FrontendNavigation::getPageInfo($menuId); // do we know something about the page if ($pageInfo !== false && isset($pageInfo['navigation_title'])) { // only add pages that aren't direct actions if ($pageInfo['tree_type'] != 'direct_action') { // get URL $pageURL = FrontendNavigation::getUrl($menuId); // if this is the error-page, so we won't show an URL. if ($pageURL == $errorURL) { $pageURL = null; } // add to the items $items[] = array('title' => $pageInfo['navigation_title'], 'url' => $pageURL); } } // remove element array_pop($pages); } // reverse so everything is in place krsort($items); // loop and add elements foreach ($items as $row) { $this->addElement($row['title'], $row['url']); } }
/** * Check if all required settings have been set * * @param string $module The module. */ public function __construct($module) { parent::__construct($module); $error = false; $action = Spoon::exists('url') ? Spoon::get('url')->getAction() : null; // analytics session token if (BackendModel::getModuleSetting('analytics', 'session_token') === null) { $error = true; } // analytics table id if (BackendModel::getModuleSetting('analytics', 'table_id') === null) { $error = true; } // missing settings, so redirect to the index-page to show a message (except on the index- and settings-page) if ($error && $action != 'settings' && $action != 'index') { SpoonHTTP::redirect(BackendModel::createURLForAction('index')); } }
/** * Check if all required settings have been set * * @return void * @param string $module The module. */ public function __construct($module) { // parent construct parent::__construct($module); // load additional engine files $this->loadEngineFiles(); // get url object reference $url = Spoon::exists('url') ? Spoon::get('url') : null; // do the client ID check if we're not in the settings page if ($url != null && $url->getAction() != 'settings' && $url->getAction() != 'import_groups' && strpos($url->getQueryString(), 'link_account') === false && strpos($url->getQueryString(), 'load_client_info') === false) { // check for CM account $this->checkForAccount(); // check for client ID $this->checkForClientID(); // check for groups $this->checkForGroups(); } }
/** * Default constructor * * @return void */ public function __construct() { // call the parent parent::__construct(); // store in reference Spoon::set('header', $this); // add some default CSS files $this->addCSS('/frontend/core/layout/css/jquery_ui/jquery_ui.css'); $this->addCSS('/frontend/core/layout/css/screen.css'); // debug stylesheet if (SPOON_DEBUG) { $this->addCSS('/frontend/core/layout/css/debug.css'); } // add default javascript-files $this->addJS('/frontend/core/js/jquery/jquery.js', false); $this->addJS('/frontend/core/js/jquery/jquery.ui.js', false); $this->addJS('/frontend/core/js/utils.js', true); $this->addJS('/frontend/core/js/frontend.js', false, true); }
/** * @param string[optional] $name Name of the form. * @param string[optional] $action The action (URL) whereto the form will be submitted, if not provided it will be autogenerated. * @param string[optional] $method The method to use when submiting the form, default is POST. * @param bool[optional] $useToken Should we automagically add a formtoken? * @param bool[optional] $useGlobalError Should we automagically show a global error? */ public function __construct($name = null, $action = null, $method = 'post', $useToken = true, $useGlobalError = true) { if (Spoon::exists('url')) { $this->URL = Spoon::get('url'); } if (Spoon::exists('header')) { $this->header = Spoon::get('header'); } $this->useGlobalError = (bool) $useGlobalError; // build a name if there wasn't one provided $name = $name === null ? SpoonFilter::toCamelCase($this->URL->getModule() . '_' . $this->URL->getAction(), '_', true) : (string) $name; // build the action if it wasn't provided $action = $action === null ? '/' . $this->URL->getQueryString() : (string) $action; // call the real form-class parent::__construct($name, $action, $method, $useToken); // add default classes $this->setParameter('id', $name); $this->setParameter('class', 'forkForms submitWithLink'); }
/** * Initialize Facebook */ private function initializeFacebook() { // get settings $facebookApplicationId = FrontendModel::getModuleSetting('core', 'facebook_app_id'); $facebookApplicationSecret = FrontendModel::getModuleSetting('core', 'facebook_app_secret'); // needed data available? if ($facebookApplicationId != '' && $facebookApplicationSecret != '') { // require require_once 'external/facebook.php'; // create instance $facebook = new Facebook($facebookApplicationSecret, $facebookApplicationId); // get the cookie, this will set the access token. $facebook->getCookie(); // store in reference Spoon::set('facebook', $facebook); // trigger event FrontendModel::triggerEvent('core', 'after_facebook_initialization'); } }
public function __construct() { // store in reference so we can access it from everywhere Spoon::set('navigation', $this); // grab from the reference $this->URL = Spoon::get('url'); // check if navigation cache file exists if (!SpoonFile::exists(BACKEND_CACHE_PATH . '/navigation/navigation.php')) { $this->buildCache(); } $navigation = array(); // require navigation-file require_once BACKEND_CACHE_PATH . '/navigation/navigation.php'; // load it $this->navigation = (array) $navigation; // cleanup navigation (not needed for god user) if (!BackendAuthentication::getUser()->isGod()) { $this->navigation = $this->cleanup($this->navigation); } }
/** * Retrieve the initial or submitted value. * * @return string */ public function getValue() { // redefine default value $value = $this->value; // form submitted if ($this->isSubmitted()) { // post/get data $data = $this->getMethod(true); // submitted by post (may be empty) if (isset($data[$this->getName()])) { $value = $data[$this->getName()]; $value = is_array($value) ? 'Array' : (string) $value; // maximum length? if (isset($this->attributes['maxlength']) && $this->attributes['maxlength'] > 0) { $value = mb_substr($value, 0, (int) $this->attributes['maxlength'], Spoon::getCharset()); } } } return $value; }
/** * Retrieve the initial or submitted value. * * @param bool[optional] $allowHTML Is HTML allowed? * @return string */ public function getValue($allowHTML = null) { // redefine default value $value = $this->value; // added to form if ($this->isSubmitted()) { // post/get data $data = $this->getMethod(true); // submitted by post/get (may be empty) if (isset($data[$this->attributes['name']])) { // value $value = $data[$this->getName()]; $value = is_scalar($value) ? (string) $value : 'Array'; if (!$allowHTML) { $value = Spoon::getCharset() == 'utf-8' ? SpoonFilter::htmlspecialchars($value) : SpoonFilter::htmlentities($value); } } } return $value; }
/** * Default constructor * * @return void * @param BackendForm $form An instance of Backendform, the elements will be parsed in here. * @param int[optional] $metaId The metaID to load. * @param string[optional] $baseFieldName The field where the URL should be based on. * @param bool[optional] $custom Add/show custom-meta. */ public function __construct(BackendForm $form, $metaId = null, $baseFieldName = 'title', $custom = false) { // check if URL is available from the referene if (!Spoon::exists('url')) { throw new BackendException('URL should be available in the reference.'); } // get BackendURL instance $this->URL = Spoon::get('url'); // should we use meta-custom $this->custom = (bool) $custom; // set form instance $this->frm = $form; // set base field name $this->baseFieldName = (string) $baseFieldName; // metaId was specified, so we should load the item if ($metaId !== null) { $this->loadMeta($metaId); } // load the form $this->loadForm(); }
/** * Returns the mailchimp object. * * @return mailchimp */ public static function getMC() { // mailchimp reference exists if (!\Spoon::exists('mailchimp')) { // check if the mailchimp class exists if (!\SpoonFile::exists(PATH_LIBRARY . '/external/mcapi.php')) { // the class doesn't exist, so throw an exception throw new \SpoonFileException(sprintf(FL::err('ClassDoesNotExist'), 'mailchimp')); } // require mailchimp class require_once PATH_LIBRARY . '/external/mcapi.php'; // set login data $key = FrontendModel::getModuleSetting('MailMotor', 'api_key'); if (empty($key)) { throw new \Exception('Mailmotor api_key is required.'); } // init mailchimp object $mc = new \MCAPI($key); // set mailchimp object reference \Spoon::set('mailchimp', $mc); } // return the CampaignMonitor object return \Spoon::get('mailchimp'); }
/** * Parse a field and return the HTML. * * @return string * @param array $field Field data. */ public static function parseField(array $field) { // got a field if (!empty($field)) { // init $frm = new BackendForm('tmp', ''); $tpl = Spoon::exists('template') ? Spoon::get('template') : new BackendTemplate(); $fieldHTML = ''; $fieldName = 'field' . $field['id']; $values = isset($field['settings']['values']) ? $field['settings']['values'] : null; $defaultValues = isset($field['settings']['default_values']) ? $field['settings']['default_values'] : null; /** * Create form and parse to HTML */ // dropdown if ($field['type'] == 'dropdown') { // get index of selected item $defaultIndex = array_search($defaultValues, $values, true); if ($defaultIndex === false) { $defaultIndex = null; } // create element $ddm = $frm->addDropdown($fieldName, $values, $defaultIndex); // empty default element $ddm->setDefaultElement(''); // get content $fieldHTML = $ddm->parse(); } elseif ($field['type'] == 'radiobutton') { // rebuild values foreach ($values as $value) { $newValues[] = array('label' => $value, 'value' => $value); } // create element $rbt = $frm->addRadiobutton($fieldName, $newValues, $defaultValues); // get content $fieldHTML = $rbt->parse(); } elseif ($field['type'] == 'checkbox') { // rebuild values foreach ($values as $value) { $newValues[] = array('label' => $value, 'value' => $value); } // create element $chk = $frm->addMultiCheckbox($fieldName, $newValues, $defaultValues); // get content $fieldHTML = $chk->parse(); } elseif ($field['type'] == 'textbox') { // create element $txt = $frm->addText($fieldName, $defaultValues); $txt->setAttribute('disabled', 'disabled'); // get content $fieldHTML = $txt->parse(); } elseif ($field['type'] == 'textarea') { // create element $txt = $frm->addTextarea($fieldName, $defaultValues); $txt->setAttribute('cols', 30); $txt->setAttribute('disabled', 'disabled'); // get content $fieldHTML = $txt->parse(); } elseif ($field['type'] == 'heading') { $fieldHTML = '<h3>' . $values . '</h3>'; } elseif ($field['type'] == 'paragraph') { $fieldHTML = $values; } /** * Parse the field into the template */ // init $tpl->assign('plaintext', false); $tpl->assign('simple', false); $tpl->assign('multiple', false); $tpl->assign('id', $field['id']); $tpl->assign('required', isset($field['validations']['required'])); // plaintext items if ($field['type'] == 'heading' || $field['type'] == 'paragraph') { // assign $tpl->assign('content', $fieldHTML); $tpl->assign('plaintext', true); } elseif ($field['type'] == 'checkbox' || $field['type'] == 'radiobutton') { // name (prefixed by type) $name = $field['type'] == 'checkbox' ? 'chk' . ucfirst($fieldName) : 'rbt' . ucfirst($fieldName); // rebuild so the html is stored in a general name (and not rbtName) foreach ($fieldHTML as &$item) { $item['field'] = $item[$name]; } // show multiple $tpl->assign('label', $field['settings']['label']); $tpl->assign('items', $fieldHTML); $tpl->assign('multiple', true); } else { // assign $tpl->assign('label', $field['settings']['label']); $tpl->assign('field', $fieldHTML); $tpl->assign('simple', true); } // cough up created html return $tpl->getContent(BACKEND_MODULE_PATH . '/layout/templates/field.tpl'); } else { return ''; } }
/** * @inheritdoc */ protected function setDebugging() { if ($this->getContainer()->getParameter('kernel.debug') === false) { // set error reporting as low as possible error_reporting(0); // don't show error on the screen ini_set('display_errors', 'Off'); // add callback for the spoon exceptionhandler switch ($this->type) { case 'BackendAjax': \Spoon::setExceptionCallback(__CLASS__ . '::exceptionAJAXHandler'); break; default: \Spoon::setExceptionCallback(__CLASS__ . '::exceptionHandler'); } } }
/** * If an exception occures, you can hook into the process that handles this exception * and add your own logic. The callback may be a function or static method. If you wish * to use a static method define this constant in this way: 'MyClass::myMethod' * * @param string $callback */ public static function setExceptionCallback($callback) { self::$exceptionCallback = $callback; }
/** * Get the traffic sources grouped by medium * * @return array * @param int $startTimestamp The start timestamp for the cache file. * @param int $endTimestamp The end timestamp for the cache file. */ public static function getTrafficSourcesGrouped($startTimestamp, $endTimestamp) { // get data from cache $items = self::getDataFromCacheByType('traffic_sources', $startTimestamp, $endTimestamp); // get current action $action = Spoon::get('url')->getAction(); // nothing in cache if ($items === false) { self::redirectToLoadingPage($action); } // reset loop counter for the current action if we got data from cache SpoonSession::set($action . 'Loop', null); // return items return $items; }
/** * Parse the forms. * * @return string The updated content, containing the parsed form tags. * @param string $content The content that may contain the form tags. */ protected function parseForms($content) { // regex pattern $pattern = '/\\{form:([a-z0-9_]+?)\\}?/siU'; // find matches if (preg_match_all($pattern, $content, $matches)) { // loop matches foreach ($matches[1] as $name) { // init vars $search = array(); $replace = array(); // start & close tag $search = array('{form:' . $name . '}', '{/form:' . $name . '}'); // using UTF-8 as charset if (Spoon::getCharset() == 'utf-8') { $replace[0] = '<?php if(isset($this->forms[\'' . $name . '\'])) { ?><form accept-charset="UTF-8" action="<?php echo $this->forms[\'' . $name . '\']->getAction(); ?>" method="<?php echo $this->forms[\'' . $name . '\']->getMethod(); ?>"<?php echo $this->forms[\'' . $name . '\']->getParametersHTML(); ?>> <?php echo $this->forms[\'' . $name . '\']->getField(\'form\')->parse(); if($this->forms[\'' . $name . '\']->getUseToken()) { ?><input type="hidden" name="form_token" id="<?php echo $this->forms[\'' . $name . '\']->getField(\'form_token\')->getAttribute(\'id\'); ?>" value="<?php echo htmlspecialchars($this->forms[\'' . $name . '\']->getField(\'form_token\')->getValue()); ?>" /> <?php } ?>'; } else { $replace[0] = '<?php if(isset($this->forms[\'' . $name . '\'])) { ?><form action="<?php echo $this->forms[\'' . $name . '\']->getAction(); ?>" method="<?php echo $this->forms[\'' . $name . '\']->getMethod(); ?>"<?php echo $this->forms[\'' . $name . '\']->getParametersHTML(); ?>> <?php echo $this->forms[\'' . $name . '\']->getField(\'form\')->parse(); if($this->forms[\'' . $name . '\']->getUseToken()) { ?><input type="hidden" name="form_token" id="<?php echo $this->forms[\'' . $name . '\']->getField(\'form_token\')->getAttribute(\'id\'); ?>" value="<?php echo htmlentities($this->forms[\'' . $name . '\']->getField(\'form_token\')->getValue()); ?>" /> <?php } ?>'; } $replace[1] = '</form> <?php } ?>'; $content = str_replace($search, $replace, $content); } } return $content; }