diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index 89e6be48e0abb7c0616fd4effe921b8553cdc05b..578eb6f67c868d544b02a9defafca50c55761ef2 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -270,7 +270,8 @@ $staticRoutes = array( 'Tag/Home', 'Upgrade/Home', 'Upgrade/FixAnonymousTags', 'Upgrade/FixConfig', 'Upgrade/FixDatabase', 'Upgrade/FixMetadata', 'Upgrade/GetDBCredentials', - 'Upgrade/GetSourceDir', 'Upgrade/Reset', 'Upgrade/ShowSQL', 'VuDL/Record', + 'Upgrade/GetSourceDir', 'Upgrade/Reset', 'Upgrade/ShowSQL', + 'VuDL/Browse', 'VuDL/DSRecord', 'VuDL/Record', 'Worldcat/Advanced', 'Worldcat/Home', 'Worldcat/Search' ); diff --git a/module/VuFind/src/VuFind/Controller/InstallController.php b/module/VuFind/src/VuFind/Controller/InstallController.php index df1faf18acd614f920e3b3eb334597c2c7b67051..a4c79e30df3c0ce29ac26638ca3729dd4784e840 100644 --- a/module/VuFind/src/VuFind/Controller/InstallController.php +++ b/module/VuFind/src/VuFind/Controller/InstallController.php @@ -323,39 +323,46 @@ class InstallController extends AbstractBase $connection . '/mysql' ); try { + $skip = $this->params()->fromPost('printdb', 'nope'); + // Get SQL together $query = 'CREATE DATABASE ' . $view->dbname; - $db->query($query, $db::QUERY_MODE_EXECUTE); $grant = "GRANT SELECT,INSERT,UPDATE,DELETE ON " . $view->dbname . ".* TO '{$view->dbuser}'@'{$view->dbhost}' " . "IDENTIFIED BY " . $db->getPlatform()->quoteValue($newpass) . " WITH GRANT OPTION"; - $db->query($grant, $db::QUERY_MODE_EXECUTE); - $db->query('FLUSH PRIVILEGES', $db::QUERY_MODE_EXECUTE); - $db = AdapterFactory::getAdapterFromConnectionString( - $connection . '/' . $view->dbname - ); $sql = file_get_contents( APPLICATION_PATH . '/module/VuFind/sql/mysql.sql' ); - $statements = explode(';', $sql); - foreach ($statements as $current) { - // Skip empty sections: - if (strlen(trim($current)) == 0) { - continue; + if($skip == 'Skip') { + $omnisql = $query .';'. $grant .';FLUSH PRIVILEGES;'. $sql; + echo $omnisql; + } else { + $db->query($query, $db::QUERY_MODE_EXECUTE); + $db->query($grant, $db::QUERY_MODE_EXECUTE); + $db->query('FLUSH PRIVILEGES', $db::QUERY_MODE_EXECUTE); + $db = AdapterFactory::getAdapterFromConnectionString( + $connection . '/' . $view->dbname + ); + $statements = explode(';', $sql); + foreach ($statements as $current) { + // Skip empty sections: + if (strlen(trim($current)) == 0) { + continue; + } + $db->query($current, $db::QUERY_MODE_EXECUTE); + } + // If we made it this far, we can update the config file and + // forward back to the home action! + $string = "mysql://{$view->dbuser}:{$newpass}@" + . $view->dbhost . '/' . $view->dbname; + $config + = ConfigReader::getLocalConfigPath('config.ini', null, true); + $writer = new ConfigWriter($config); + $writer->set('Database', 'database', $string); + if (!$writer->save()) { + return $this->forwardTo('Install', 'fixbasicconfig'); } - $db->query($current, $db::QUERY_MODE_EXECUTE); - } - // If we made it this far, we can update the config file and - // forward back to the home action! - $string = "mysql://{$view->dbuser}:{$newpass}@" - . $view->dbhost . '/' . $view->dbname; - $config - = ConfigReader::getLocalConfigPath('config.ini', null, true); - $writer = new ConfigWriter($config); - $writer->set('Database', 'database', $string); - if (!$writer->save()) { - return $this->forwardTo('Install', 'fixbasicconfig'); } return $this->redirect()->toRoute('install-home'); } catch (\Exception $e) { diff --git a/module/VuFind/src/VuFind/Controller/VudlController.php b/module/VuFind/src/VuFind/Controller/VudlController.php index 744996e56648855de43e9e8d45cb8d41c115cd52..281fd11b43fc4b45f2849469f2bfc91894d885ff 100644 --- a/module/VuFind/src/VuFind/Controller/VudlController.php +++ b/module/VuFind/src/VuFind/Controller/VudlController.php @@ -40,6 +40,155 @@ use VuFind\Search\Solr\Results as SolrResults; */ class VudlController extends AbstractBase { + /** + * + * + * + */ + public function browseAction() + { + // TARGET ID + $id = $this->params()->fromQuery('id'); + $view = $this->createViewModel(); + $view->id = $id; + + // REDUCE TO INTEGER + if(empty($id)) { + $id = 'vudl:1'; + } elseif(strpos($id, 'vudl') < 0) { + $id = 'vudl' . $id; + } + + // GET THIS FOLDER'S DETAILS + $view->details = $this->getDSDetails($id); + $xml = simplexml_load_file('http://falveydev.villanova.edu:8088/fedora/objects/'.$id.'/datastreams/STRUCTMAP/content'); + $view->xml = $xml; + + // GET CHILDREN AND CHILD DETAILS + $children = array(); + foreach($xml->xpath('//METS:structMap/METS:div') as $order) { + $item = $order->xpath('METS:fptr'); + $id = strval($item[0]['FILEID']); + + $children[intval($order['ORDER'])] = $this->getDSDetails($id); + $children[intval($order['ORDER'])]['classes'] = $this->getDSClasses($id); + } + $view->children = $children; + + return $view; + } + + /** + * + * + * + */ + protected function getDSDetails($id) + { + $xml = simplexml_load_file('http://falveydev.villanova.edu:8088/fedora/objects/'.$id.'/datastreams/DC/content'); + $data = array(); + foreach($xml->children('dc', true) as $detail) { + $data[$detail->getName()] = (string) $detail; + } + $data['thumbnail'] = 'http://falveydev.villanova.edu:8088/fedora/objects/'.$id.'/datastreams/THUMBNAIL/content'; + return $data; + } + + /** + * + * + * + */ + protected function getDSClasses($id) + { + $data = file_get_contents('http://falveydev.villanova.edu:8088/fedora/objects/'.$id.'/datastreams/RELS-EXT/content'); + $matches = array(); + preg_match_all('/rdf:resource="info:fedora\/vudl-system:[^"]+/', $data, $matches); + $classes = array(); + foreach($matches[0] as $match) { + $classes[] = substr($match, 38); + } + return $classes; + } + + /** + * + * + * + */ + protected function getDSOutline($root) + { + $outline = array(); + $queue = array($root); + $matches = array(); + // BFS + do { + $id = array_shift($queue); + // Have we reached the bottom? We get a 404 if we have. + $check = get_headers('http://falveydev.villanova.edu:8088/fedora/objects/'.$id.'/datastreams/STRUCTMAP/content', 1); + // Figure out which parent to put this link under + if(strpos($check[0], '404')) { + $data = file_get_contents('http://falveydev.villanova.edu:8088/fedora/objects/'.$id.'/datastreams/PARENT-LIST/content'); + preg_match_all('/vudl:[^"]+/', $data, $matches); + $parent = $matches[0][0] == 'MASTER' ? 'original' : substr($matches[0][0], 5); + $index = strtolower(explode(' ', $this->getDSDetails($id)['title'])[0]); + $outline[$parent][$index] = 'http://falveydev.villanova.edu:8088/fedora/objects/'.$id.'/datastreams/FILE/content'; + // echo $id, ' ', $parent, ' ', $this->getDSDetails($id)['title'], '<br>'; + } else { + $data = file_get_contents('http://falveydev.villanova.edu:8088/fedora/objects/'.$id.'/datastreams/STRUCTMAP/content'); + preg_match_all('/vudl:[^"]+/', $data, $matches); + if(count($matches) > 0) { + foreach($matches[0] as $m) { + $queue[] = $m; + } + } + $outline[substr($id, 5)]['label'] = $this->getDSDetails($id)['title']; + // echo $id, ' ', $this->getDSDetails($id)['title'], '<br>'; + } + } while(count($queue) > 0); + // Remove parents and empty items + foreach($outline as $item) { + if(!isset($item['large'])) { + array_shift($outline); + } + } + return $outline; + } + + /** + * + * + * + */ + public function dsrecordAction() + { + // TARGET ID + $id = $this->params()->fromQuery('id'); + $view = $this->createViewModel(); + $view->id = $id; + + // GET XML FILE NAME + $url = 'http://falveydev.villanova.edu:8088/fedora/objects/'.$id.'/datastreams/DC/content'; + + // LOAD FILE + $xml = simplexml_load_file($url); + + // FILE INFORMATION / DESCRIPTION + $fileDetails = $this->getDSDetails($id); + $view->details = $fileDetails; + $view->file = urlencode($url); + + // GET IDS FOR ALL FILES + $pages = $this->getDSOutline($id); + + // SEND THE DATA FOR THE FIRST PAGES + // (Original, Large, Medium, Thumbnail srcs) and THE DOCUMENTS + $view->pages = $pages; + $view->docs = array(); + $view->setTemplate('/vudl/record.phtml'); + return $view; + } + /** * Get the information from the XML * diff --git a/module/VuFind/src/VuFind/Record/Loader.php b/module/VuFind/src/VuFind/Record/Loader.php index 2f31d6072b72955fdf048716dc42a239a9320763..63132acff698d4ca75c38799af146f86614d85e8 100644 --- a/module/VuFind/src/VuFind/Record/Loader.php +++ b/module/VuFind/src/VuFind/Record/Loader.php @@ -46,7 +46,7 @@ class Loader implements ServiceLocatorAwareInterface * * @return Loader */ - public function getInstance() + static public function getInstance() { static $instance = false; if (!$instance) { diff --git a/themes/blueprint/css/styles.css b/themes/blueprint/css/styles.css index afdd6d6da65da514775add87933d966f9189f5ad..dace46dbaa0cddd228d99fa7e25002c186f45684 100644 --- a/themes/blueprint/css/styles.css +++ b/themes/blueprint/css/styles.css @@ -342,6 +342,10 @@ div.searchHomeForm div.searchform { padding:0; } +#searchForm_type { + padding:2px; +} + /******** Result List ***/ ul.recordSet { diff --git a/themes/blueprint/templates/vudl/record.phtml b/themes/blueprint/templates/vudl/record.phtml index cf921040a9d4eb5955254dbf4412929b3d7f1fab..cb3e04ec172681bc3562d8f6b782ab4a1b79b537 100644 --- a/themes/blueprint/templates/vudl/record.phtml +++ b/themes/blueprint/templates/vudl/record.phtml @@ -15,10 +15,7 @@ // TRUNCATE PAGES TO FIRST PAGES $this->firstPages = array_slice($this->pages, 0, 6); ?> -<script> - var documentID = '<?=$this->id ?>'; - var fileName = '<?=$this->file ?>'; -</script> +<script>var documentID = '<?=$this->id ?>'</script> <div class="inspector_container"> <div class="side_nav"> <a href="javascript:showPages()" class="top"><?=$this->transEsc('vudl_tab_pages') ?></a>