本文整理汇总了PHP中JApplicationCms::getBody方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationCms::getBody方法的具体用法?PHP JApplicationCms::getBody怎么用?PHP JApplicationCms::getBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JApplicationCms
的用法示例。
在下文中一共展示了JApplicationCms::getBody方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAfterRender
/**
* Convert links in com_templates to point into Gantry Administrator component.
*/
public function onAfterRender()
{
if (!$this->app->isAdmin()) {
return;
}
$document = JFactory::getDocument();
$type = $document->getType();
$option = $this->app->input->getString('option');
$view = $this->app->input->getString('view', 'styles');
$task = $this->app->input->getString('task');
if (in_array($option, ['com_templates', 'com_advancedtemplates']) && $view == 'styles' && !$task && $type == 'html') {
$this->styles = $this->getStyles();
$body = preg_replace_callback('/(<a\\s[^>]*href=")([^"]*)("[^>]*>)(.*)(<\\/a>)/siU', array($this, 'appendHtml'), $this->app->getBody());
$this->app->setBody($body);
}
}
示例2: onAfterRender
/**
* Convert links in com_templates to point into Gantry Administrator component.
*/
public function onAfterRender()
{
if (!$this->app->isAdmin()) {
return;
}
$document = JFactory::getDocument();
$type = $document->getType();
$option = $this->app->input->getString('option');
$view = $this->app->input->getString('view', 'g5');
$task = $this->app->input->getString('task');
if (in_array($option, array('com_templates', 'com_advancedtemplates')) && ($view == 'g5' || $view == 'styles') && !$task && $type == 'html') {
$this->styles = $this->getStyles();
$body = preg_replace_callback('/(<a\\s[^>]*href=")([^"]*)("[^>]*>)(.*)(<\\/a>)/siU', array($this, 'appendHtml'), $this->app->getBody());
$this->app->setBody($body);
}
if (($option == 'com_modules' || $option == 'com_advancedmodules') && ($view == 'g5' || $view == 'modules' || empty($view)) && $type == 'html') {
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('id, title, params');
$query->from('#__modules');
$query->where('module = ' . $db->quote('mod_gantry5_particle'));
$db->setQuery($query);
$data = $db->loadObjectList();
if (sizeof($data) > 0) {
$this->modules = [];
$body = $this->app->getBody();
foreach ($data as $module) {
$params = json_decode($module->params);
$particle = isset($params->particle) ? json_decode($params->particle) : '';
$title = isset($particle->title) ? $particle->title : (isset($particle->particle) ? $particle->particle : '');
$this->modules[$module->id] = $particle;
$body = preg_replace_callback('/(<a\\s[^>]*href=")([^"]*)("[^>]*>)(.*)(<\\/a>)/siU', function ($matches) use($title) {
return $this->appendHtml($matches, $title);
}, $body);
}
$this->app->setBody($body);
}
}
}
示例3: onAfterRender
/**
* Convert the site URL to fit to the HTTP request.
*
* @return void
*/
public function onAfterRender()
{
if (!$this->app->isSite() || $this->app->get('sef', '0') == '0') {
return;
}
// Replace src links.
$base = JUri::base(true) . '/';
$buffer = $this->app->getBody();
// Replace index.php URI by SEF URI.
if (strpos($buffer, 'href="index.php?') !== false) {
preg_match_all('#href="index.php\\?([^"]+)"#m', $buffer, $matches);
foreach ($matches[1] as $urlQueryString) {
$buffer = str_replace('href="index.php?' . $urlQueryString . '"', 'href="' . JRoute::_('index.php?' . $urlQueryString) . '"', $buffer);
}
$this->checkBuffer($buffer);
}
// Check for all unknown protocals (a protocol must contain at least one alpahnumeric character followed by a ":").
$protocols = '[a-zA-Z0-9\\-]+:';
$attributes = array('href=', 'src=', 'poster=');
foreach ($attributes as $attribute) {
if (strpos($buffer, $attribute) !== false) {
$regex = '#\\s+' . $attribute . '"(?!/|' . $protocols . '|\\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, ' ' . $attribute . '"' . $base . '$1"', $buffer);
$this->checkBuffer($buffer);
}
}
// Replace all unknown protocals in javascript window open events.
if (strpos($buffer, 'window.open(') !== false) {
$regex = '#onclick="window.open\\(\'(?!/|' . $protocols . '|\\#)([^/]+[^\']*?\')#m';
$buffer = preg_replace($regex, 'onclick="window.open(\'' . $base . '$1', $buffer);
$this->checkBuffer($buffer);
}
// Replace all unknown protocols in onmouseover and onmouseout attributes.
$attributes = array('onmouseover=', 'onmouseout=');
foreach ($attributes as $attribute) {
if (strpos($buffer, $attribute) !== false) {
$regex = '#' . $attribute . '"this.src=([\']+)(?!/|' . $protocols . '|\\#|\')([^"]+)"#m';
$buffer = preg_replace($regex, $attribute . '"this.src=$1' . $base . '$2"', $buffer);
$this->checkBuffer($buffer);
}
}
// Replace all unknown protocols in CSS background image.
if (strpos($buffer, 'style=') !== false) {
$regex = '#style=\\s*[\'\\"](.*):\\s*url\\s*\\([\'\\"]?(?!/|' . $protocols . '|\\#)([^\\)\'\\"]+)[\'\\"]?\\)#m';
$buffer = preg_replace($regex, 'style="$1: url(\'' . $base . '$2$3\')', $buffer);
$this->checkBuffer($buffer);
}
// Replace all unknown protocols in OBJECT param tag.
if (strpos($buffer, '<param') !== false) {
// OBJECT <param name="xx", value="yy"> -- fix it only inside the <param> tag.
$regex = '#(<param\\s+)name\\s*=\\s*"(movie|src|url)"[^>]\\s*value\\s*=\\s*"(?!/|' . $protocols . '|\\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, '$1name="$2" value="' . $base . '$3"', $buffer);
$this->checkBuffer($buffer);
// OBJECT <param value="xx", name="yy"> -- fix it only inside the <param> tag.
$regex = '#(<param\\s+[^>]*)value\\s*=\\s*"(?!/|' . $protocols . '|\\#|\')([^"]*)"\\s*name\\s*=\\s*"(movie|src|url)"#m';
$buffer = preg_replace($regex, '<param value="' . $base . '$2" name="$3"', $buffer);
$this->checkBuffer($buffer);
}
// Replace all unknown protocols in OBJECT tag.
if (strpos($buffer, '<object') !== false) {
$regex = '#(<object\\s+[^>]*)data\\s*=\\s*"(?!/|' . $protocols . '|\\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, '$1data="' . $base . '$2"', $buffer);
$this->checkBuffer($buffer);
}
// Use the replaced HTML body.
$this->app->setBody($buffer);
}