Compare commits
11 Commits
3164787d19
...
cf85bebd09
Author | SHA1 | Date |
---|---|---|
chris | cf85bebd09 | |
buttle | faa9eda485 | |
buttle | 317d2898b9 | |
buttle | 9d992658d9 | |
buttle | 82d895d7e7 | |
chris | 2ea286fa7b | |
buttle | 52c86af842 | |
buttle | ea5e33d0a2 | |
buttle | dffeb3ff33 | |
buttle | 2c14639d0d | |
buttle | b072beed88 |
12
Module.php
12
Module.php
|
@ -138,4 +138,16 @@ class Module extends AbstractModule
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code to run when first using the module.
|
||||||
|
*
|
||||||
|
* @param MvcEvent $event
|
||||||
|
*/
|
||||||
|
public function onBootstrap(MvcEvent $event): void
|
||||||
|
{
|
||||||
|
parent::onBootstrap($event);
|
||||||
|
|
||||||
|
$acl = $this->getServiceLocator()->get('Omeka\Acl');
|
||||||
|
$acl->allow(null, 'Controller\ArchiveSiteMetaController');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,44 @@
|
||||||
<?php
|
<?php
|
||||||
|
use Laminas\Router\Http\Literal;
|
||||||
namespace ArchiveSiteMeta;
|
namespace ArchiveSiteMeta;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
//https://docs.laminas.dev/tutorials/getting-started/routing-and-controllers/
|
||||||
|
'router' => [
|
||||||
|
'routes' => [
|
||||||
|
'archiveSiteMeta' => [
|
||||||
|
//'type' => \Laminas\Router\Http\Segment::class,
|
||||||
|
'type' => \Laminas\Router\Http\Literal::class,
|
||||||
|
'options' => [
|
||||||
|
'route' => '/api/collections/search',
|
||||||
|
'defaults' => [
|
||||||
|
'__NAMESPACE__' => 'ArchiveSiteMeta\Controller',
|
||||||
|
'controller' => Controller\ArchiveSiteMetaController::class,
|
||||||
|
'action' => 'index',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'controllers' => [
|
||||||
|
'invokables' => [
|
||||||
|
'Controller\ArchiveSiteMetaController' => Controller\ArchiveSiteMetaController::class
|
||||||
|
],
|
||||||
|
],
|
||||||
'view_manager' => [
|
'view_manager' => [
|
||||||
'template_path_stack' => [
|
'template_path_stack' => [
|
||||||
dirname(__DIR__) . '/view',
|
dirname(__DIR__) . '/view',
|
||||||
],
|
],
|
||||||
|
'strategies' => [
|
||||||
|
'ViewJsonStrategy',
|
||||||
|
],
|
||||||
'template_map' => [
|
'template_map' => [
|
||||||
|
// used to remove available blocks when editing a page
|
||||||
|
'omeka/site-admin/page/edit' => __DIR__ . '/../../../themes/archive/view/omeka/site-admin/page/edit.phtml',
|
||||||
|
//'archive-site-meta/archive-site-meta/index' => __DIR__ . '/../view/collections/index.phtml',
|
||||||
//'layout/layout' => __DIR__ . '/../../../themes/archive/view/layout/layout.phtml',
|
//'layout/layout' => __DIR__ . '/../../../themes/archive/view/layout/layout.phtml',
|
||||||
//'omeka/index/index' => __DIR__ . '/../../../themes/archive/view/omeka/site/index/index.phtml',
|
//'omeka/index/index' => __DIR__ . '/../../../themes/archive/view/omeka/site/index/index.phtml',
|
||||||
'omeka/search/results' => __DIR__ . '/../../../themes/archive/view/omeka/search/results.phtml',
|
//'omeka/search/results' => __DIR__ . '/../../../themes/archive/view/omeka/search/results.phtml',
|
||||||
'omeka/site-admin/page/edit' => __DIR__ . '/../../../themes/archive/view/omeka/site-admin/page/edit.phtml',
|
|
||||||
//'common/site-list-entry' => __DIR__ . '/../../../themes/archive/view/common/site-list-entry.phtml',
|
//'common/site-list-entry' => __DIR__ . '/../../../themes/archive/view/common/site-list-entry.phtml',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
namespace ArchiveSiteMeta\Controller;
|
||||||
|
|
||||||
|
use Laminas\Mvc\Controller\AbstractActionController;
|
||||||
|
use Laminas\View\Model\JsonModel;
|
||||||
|
|
||||||
|
class ArchiveSiteMetaController extends AbstractActionController
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public function indexAction()
|
||||||
|
{
|
||||||
|
|
||||||
|
$query = [
|
||||||
|
'limit' => 10,
|
||||||
|
//'in_sites' => true,
|
||||||
|
'fulltext_search' => $this->params()->fromQuery('fulltext_search'),
|
||||||
|
];
|
||||||
|
$resources = [
|
||||||
|
'site_pages' => [
|
||||||
|
'action' => 'site-pages',
|
||||||
|
'query' => $query,
|
||||||
|
'response' => null,
|
||||||
|
],
|
||||||
|
'items' => [
|
||||||
|
'action' => 'items',
|
||||||
|
'query' => array_merge($query, ['in_sites' => true]),
|
||||||
|
'response' => null,
|
||||||
|
],
|
||||||
|
/*
|
||||||
|
'item_sets' => [
|
||||||
|
'action' => 'item-sets',
|
||||||
|
'query' => array_merge($query, ['in_sites' => true]),
|
||||||
|
'response' => null,
|
||||||
|
],
|
||||||
|
*/
|
||||||
|
];
|
||||||
|
|
||||||
|
$resourceNames = ['site_pages', 'items'];
|
||||||
|
|
||||||
|
//$ids = $this->api()->search('site_pages', $query)->getContent();
|
||||||
|
//$ids = $this->api()->search('site_pages', $query, ['return' => 'site'])->getContent();
|
||||||
|
//$ids = $this->api()->search('site_pages', $query, ['returnScalar' => 'site'])->getContent();
|
||||||
|
|
||||||
|
$query_results = array();
|
||||||
|
$items = $this->api()->search('items', $resources['items']['query'])->getContent();
|
||||||
|
foreach($items as $item) {
|
||||||
|
foreach($item->sites() as $site){
|
||||||
|
array_push($query_results, $site->id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$pages = $this->api()->search('site_pages',
|
||||||
|
$resources['site_pages']['query'],
|
||||||
|
['returnScalar' => 'site'])->getContent();
|
||||||
|
foreach($pages as $page) {
|
||||||
|
array_push($query_results, (int)$page);
|
||||||
|
}
|
||||||
|
$search_results = [];
|
||||||
|
foreach($query_results as $site_id) {
|
||||||
|
if (array_key_exists($site_id, $search_results)) {
|
||||||
|
$search_results[$site_id] = $search_results[$site_id] + 1;
|
||||||
|
} else {
|
||||||
|
$search_results[$site_id] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new JsonModel($search_results);
|
||||||
|
}
|
||||||
|
}
|
|
@ -119,6 +119,9 @@ class ArchiveSiteMetaViewHelper extends AbstractHelper
|
||||||
$view = $this->getView();
|
$view = $this->getView();
|
||||||
return isset($view->site)
|
return isset($view->site)
|
||||||
? $view->site
|
? $view->site
|
||||||
: $view->getHelperPluginManager()->get('Laminas\View\Helper\ViewModel')->getRoot()->getVariable('site');
|
: $view->getHelperPluginManager()
|
||||||
|
->get('Laminas\View\Helper\ViewModel')
|
||||||
|
->getRoot()
|
||||||
|
->getVariable('site');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
<?php echo "this is index.phtml"; ?>
|
Loading…
Reference in New Issue