/** * Callback method for appending preview and appview parameter to href and action attributes. * * @access private * @param array $matches regex matches * @return string replacement string */ private function appendParameters($matches) { $before = $matches[1]; $quote = $matches[2]; $value = $matches[3]; $after = $matches[4]; if (strpos($value, '?') !== false) { list($path, $query) = explode('?', $value); $query = \Cx\Core\Routing\Url::params2array($query); } else { $path = $value; $query = array(); } $extension = pathinfo($path, PATHINFO_EXTENSION); if (!empty($extension) && $extension != 'php') { return $matches[0]; } if (!empty($_GET['preview']) && !isset($query['preview'])) { $query['preview'] = $_GET['preview']; } if (!empty($_GET['templateEditor']) && !isset($query['templateEditor'])) { $query['templateEditor'] = $_GET['templateEditor']; } if (isset($_GET['appview']) && $_GET['appview'] == 1 && !isset($query['appview'])) { $query['appview'] = $_GET['appview']; } $query = \Cx\Core\Routing\Url::array2params($query); // replace & with & but only & (not followed by amp;) $query = preg_replace('/&(?!amp;)/', '&', $query); return $before . $quote . $path . '?' . $query . $quote . $after; }