diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2019-03-07 04:29:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-07 04:29:09 +0300 |
commit | 0d5d0dfe40f771d437fa0bf36e8393daa3da07d3 (patch) | |
tree | 0cb56ec4ef88bcad81d54ffa6d7d5bcb7bed0f6d /plugins/Actions/DataTable/Filter/Actions.php | |
parent | d94ab385300bb531956928716019f6d2d564f251 (diff) |
Set segments for folder branches in page urls/page titles report (#14076)
* unfinished commit
* Set matadata on Action folder rows in order to correctly set subfolder segments.
* Get rid of warning
* Apply review feedback.
* Remove unneeded metadata.
* Update expected test files.
* Update expected screenshot.
Diffstat (limited to 'plugins/Actions/DataTable/Filter/Actions.php')
-rw-r--r-- | plugins/Actions/DataTable/Filter/Actions.php | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/plugins/Actions/DataTable/Filter/Actions.php b/plugins/Actions/DataTable/Filter/Actions.php index d931cab2e0..2001be6385 100644 --- a/plugins/Actions/DataTable/Filter/Actions.php +++ b/plugins/Actions/DataTable/Filter/Actions.php @@ -35,6 +35,8 @@ class Actions extends BaseFilter public function filter($table) { $table->filter(function (DataTable $dataTable) { + $site = $dataTable->getMetadata('site'); + $urlPrefix = $site ? $site->getMainUrl() : null; $defaultActionName = Config::getInstance()->General['action_default_name']; @@ -50,11 +52,28 @@ class Actions extends BaseFilter foreach ($dataTable->getRows() as $row) { $url = $row->getMetadata('url'); + $pageTitlePath = $row->getMetadata('page_title_path'); + $folderUrlStart = $row->getMetadata('folder_url_start'); $label = $row->getColumn('label'); if ($url) { $row->setMetadata('segmentValue', urldecode($url)); + } else if ($folderUrlStart) { + $row->setMetadata('segment', 'pageUrl=^' . urlencode($folderUrlStart)); + } else if ($pageTitlePath) { + if ($row->getIdSubDataTable()) { + $row->setMetadata('segment', 'pageTitle=^' . urlencode(urlencode(trim(urldecode($pageTitlePath))))); + } else { + $row->setMetadata('segmentValue', trim(urldecode($pageTitlePath))); + } } else if ($this->isPageTitleType && !in_array($label, [DataTable::LABEL_SUMMARY_ROW])) { - $row->setMetadata('segmentValue', trim(urldecode($label))); + // for older data w/o page_title_path metadata + if ($row->getIdSubDataTable()) { + $row->setMetadata('segment', 'pageTitle=^' . urlencode(urlencode(trim(urldecode($label))))); + } else { + $row->setMetadata('segmentValue', trim(urldecode($label))); + } + } else if (!$this->isPageTitleType && $urlPrefix) { // folder for older data w/ no folder URL metadata + $row->setMetadata('segment', 'pageUrl=^' . urlencode(urlencode($urlPrefix . '/' . $label))); } // remove the default action name 'index' in the end of flattened urls and prepend $actionDelimiter @@ -68,6 +87,9 @@ class Actions extends BaseFilter } $dataTable->setLabelsHaveChanged(); } + + $row->deleteMetadata('folder_url_start'); + $row->deleteMetadata('page_title_path'); } }); |