Skip to content

Commit

Permalink
Merge pull request #596 from axis80/fix-plugins-current-page-data
Browse files Browse the repository at this point in the history
Fix plugins current page data
  • Loading branch information
axis80 committed Feb 16, 2019
2 parents 5262287 + 10a4b68 commit 9cc197d
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions app/Respond/Libraries/Publish.php
Expand Up @@ -839,7 +839,7 @@ public static function publishPluginsForPage($page, $user, $site, $pages = null)

$html = file_get_contents($location);

// setup current page
// setup meta info
$meta = array(
'url' => $page->url,
'firstName' => $page->firstName,
Expand All @@ -849,7 +849,7 @@ public static function publishPluginsForPage($page, $user, $site, $pages = null)
);

// inject plugin HTML to the page
$dom = Publish::injectPluginHTML($html, $user, $site, $meta, $pages);
$dom = Publish::injectPluginHTML($html, $user, $site, $meta, $pages, $page);

// put html back
file_put_contents($location, $dom);
Expand All @@ -870,7 +870,7 @@ public static function publishPluginsForPage($page, $user, $site, $pages = null)
* @param {User} $user
* @param {Site} $site
*/
public static function injectPluginHTML($html, $user, $site, $meta, $pages = null) {
public static function injectPluginHTML($html, $user, $site, $meta, $pages = null, $page = null) {

// caches the values of these variables across the request to improve performance
static $forms = array();
Expand Down Expand Up @@ -924,6 +924,30 @@ public static function injectPluginHTML($html, $user, $site, $meta, $pages = nul
'timeZone' => $site->timeZone,
);

// If page data is provided
if($page) {

// setup current page
$current_page = array(
'title' => $page->title,
'description' => $page->description,
'keywords' => $page->keywords,
'callout' => $page->callout,
'url' => $page->url,
'photo' => $page->photo,
'thumb' => $page->thumb,
'language' => $page->language,
'direction' => $page->direction,
'firstName' => $page->firstName,
'lastName' => $page->lastName,
'lastModifiedBy' => $page->lastModifiedBy,
'lastModifiedDate' => $page->lastModifiedDate
);

} else {
$current_page = array();
}

// get plugins for the site
$dir = app()->basePath().'/public/sites/'.$site->id.'/plugins';
$exts = array('html', 'php');
Expand Down Expand Up @@ -985,7 +1009,7 @@ public static function injectPluginHTML($html, $user, $site, $meta, $pages = nul
if(array_search($el->type, $plugins) !== FALSE) {

// render array
$render_arr = array('page' => $meta,
$render_arr = array('page' => $current_page,
'meta' => $meta,
'site' => $current_site,
'pages' => $pages,
Expand Down

0 comments on commit 9cc197d

Please sign in to comment.