diff --git a/ui/PlaylistBuilder.php b/ui/PlaylistBuilder.php index a4737c9d..dc2c0210 100644 --- a/ui/PlaylistBuilder.php +++ b/ui/PlaylistBuilder.php @@ -31,8 +31,9 @@ class PlaylistBuilder extends PlaylistObserver { private const PARAMS = [ "action", "editMode", "authUser" ]; - protected $params; protected $template; + protected $params; + protected $break; public static function newInstance(array $params) { // validate all parameters are present @@ -51,31 +52,32 @@ public static function newInstance(array $params) { protected function renderBlock($block, $entry) { return $this->template->renderBlock($block, [ "params" => $this->params, + "break" => $this->break, "entry" => $entry ]); } protected function __construct(array $params) { $templateFact = new TemplateFactoryUI(); - $this->template = $templateFact->load('list/item.html'); + $this->template = $templateFact->load('list/body.html'); $this->params = $params; - $this->params['break'] = false; $this->params['usLocale'] = UI::isUsLocale(); + $this->break = false; $this->on('comment', function($entry) { $fragment = $this->renderBlock('comment', $entry); - $this->params['break'] = false; + $this->break = false; return $fragment; })->on('logEvent', function($entry) { $fragment = $this->renderBlock('logEvent', $entry); - $this->params['break'] = !$this->params['authUser']; + $this->break = !$this->params['authUser']; return $fragment; })->on('setSeparator', function($entry) { $fragment = $this->renderBlock('setSeparator', $entry); - $this->params['break'] = true; + $this->break = true; return $fragment; })->on('spin', function($entry) { $fragment = $this->renderBlock('spin', $entry); - $this->params['break'] = false; + $this->break = false; return $fragment; }); } diff --git a/ui/Playlists.php b/ui/Playlists.php index da245dcb..8101fa6f 100644 --- a/ui/Playlists.php +++ b/ui/Playlists.php @@ -266,17 +266,18 @@ private function emitPlaylistBody($playlist, $editMode) { $tracks = $api->getTracks($playlist['id'], $editMode)->asArray(); Engine::api(ILibrary::class)->markAlbumsReviewed($tracks); - $observer = PlaylistBuilder::newInstance([ + $params = [ "action" => $this->subaction, "editMode" => $editMode, - "authUser" => $this->session->isAuth("u") - ]); + "authUser" => $this->session->isAuth("u"), + "usLocale" => UI::isUsLocale() + ]; $entries = array_map(function($track) { return new PlaylistEntry($track); }, $tracks); - $this->addVar("observer", $observer); + $this->addVar("params", $params); $this->addVar("entries", $entries); $this->addVar("editMode", $editMode); $this->addVar("isLive", $api->isNowWithinShow($playlist)); diff --git a/ui/templates/default/list/item.html b/ui/templates/default/list/body.html similarity index 77% rename from ui/templates/default/list/item.html rename to ui/templates/default/list/body.html index 87f60683..ce1c6914 100644 --- a/ui/templates/default/list/item.html +++ b/ui/templates/default/list/body.html @@ -1,8 +1,3 @@ -{# - This template is rendered only by block. - - See UI::PlaylistBuilder - #} {% macro makeTime(params, entry) %} {%~ set created = entry.getCreatedTimestamp() %} {#~ colon is included in 24hr format for symmetry with fxtime #} @@ -10,7 +5,7 @@