/da_catalog_edit_testSection.php
PHP | 634 lines | 367 code | 178 blank | 89 comment | 72 complexity | 4208f476d982c584727f036ab848d2e8 MD5 | raw file
- <html>
- <head><title>Data Archive Catalog: Edit</title>
- <link rel="stylesheet" href="2col_leftNav.css" type="text/css">
- <!-- Javascript(s) to 1) paste PI names into text field, 2) clear the text fiels -->
- <script language="JavaScript" src="da_catalog.js" type="text/javascript"><!-- da_catalog scripts //--></script>
- <!-- end Javascript PI paste and clear -->
- </head>
- <body>
- <?php
-
- $sscnetHTTP = "http://www.sscnet.ucla.edu/issr/da/da_catalog/";
- $sscnetHTTP_maintenance_test = "http://www.sscnet.ucla.edu/issr/da/da_catalog_maintenance_test/";
- $sscnetHTTP_maintenance_live = "http://www.sscnet.ucla.edu/issr/da/da_catalog_maintenance/";
- $mydestopHTTP = "http://localhost/da_catalog/";
- $currentHTTP = $sscnetHTTP_maintenance_live;
-
- $sscnetInclude = "ISSRDATEST_login.php";
- $mydesktopInclude = "../db_login2.php";
- $currentInclude = $sscnetInclude;
- include($currentInclude);
-
- // for desktop test system
- //$db_name = "da_catalog";
-
-
- if (!empty($_POST['studynumber'])) {
- //echo "studynumber: " . $studynumber;
- $_SESSION['studynumber'] = $_POST['studynumber'];
-
- // something is selected
- $queryGetBaseRecord = "SELECT title.*, picode.ID as picode_id, picode.picode, picode.tisubsort, pifull.*, shcode.ID as shcode_id, shcode.subjectcode, shcode.subsort as subject_subsort, shfull.*, wwwlink_pi.wwwlink AS wwwlink_pi, wwwlink_pi.wwwtext AS wwwtext_pi, wwwlink_subject.wwwlink AS wwwlink_subject, wwwlink_subject.wwwtext AS wwwtext_subject, cite.cite, cite.subsort, pifull.picode FROM cite RIGHT JOIN ((((((title LEFT JOIN picode ON title.tisort = picode.tisort) LEFT JOIN pifull ON picode.picode = pifull.picode) LEFT JOIN shcode ON title.tisort = shcode.tisort) LEFT JOIN shfull ON shcode.subjectcode = shfull.subjectcode) LEFT JOIN wwwlink AS wwwlink_subject ON shfull.subjectcode = wwwlink_subject.subjectcode) LEFT JOIN wwwlink AS wwwlink_pi ON pifull.picode = wwwlink_pi.picode) ON cite.citenum = title.Cite WHERE (((title.StudyNum)='" . $studynumber ."'))";
-
- //echo "<br>" . $queryGetBaseRecord . "<br>";
-
- // PDO connect
- $PDO_string = "mysql:host=" . $db_host . ";port=" . $db_port . ";dbname=" . $db_name ;
-
- // echo "<br>" . $queryGetBaseRecord . "<br>";
- try {
- $PDO_connection = new PDO($PDO_string, $db_username, $db_password);
-
- } catch(PDOException $e) {
- echo "Could not connect to the database because: ". $e->getMessage()."<br>";
- die();
- }
-
- // PDO - create prepared statement: get the table.pifull
- // --------------------------------------------------------
- $PDO_query = $PDO_connection->prepare($queryGetBaseRecord);
- // PDO - execute the query
- $result = $PDO_query->execute();
- if (!$result) {
- die ("Could not query the database: <br />". mysql_error());
- }
- // complete record info
- $titleRecord = array(); // record - the title, sub# and restricted y/n
- // list of pi(s)
- $piList = array(); // list of pi(s)
- $piListFull = array();
- $current_pi = null;
- $temp = "";
-
- $subjectList = array(); // list of subjects
- $subjectListFull = array();
- $current_subject = null;
-
- $usefulLinks = array(); // linklist
-
- $row_index = 0;
- while ($row = $PDO_query->fetch(PDO::FETCH_ASSOC)) {
-
- //----------------------------------------------------------------------------------------------------------------------------
- //
- // there will only be one title record. these are essentially the fields from the title table
- // because the query grabs everything in one big swoop the title record items will appear more than once even though there can only be
- // one title record - the title record is the base record
- //
- // on the otherhand there can be multiple PIs, Subjects/Keywords and links. Those are handled separated. This note referes specifically to
- // the title record
- //
- //---------------------------------------------------------------------------------------------------------------------------
-
- // relevant fields from the title and cite tables
-
- $_SESSION['title'] = $row["Title"];
- $_SESSION['tisort'] = $row["tisort"]; // ID for title table, connecting field to the picode and shcode tables
- $_SESSION['restricted'] = $row[ "Restricted" ];
- $_SESSION['www'] = $row[ "WWW" ];
- $_SESSION['cite_title'] = $row[ "cite"];
- $_SESSION['cite_subsort'] = $row["subsort"];
- if ($_SESSION['cite_subsort'] <= 1) { $_SESSION['cite_subsort'] = 1; } // in the event that subsort is 0/not set, reset it to 1
- $_SESSION['sda'] = $row["SDA"];
- $_SESSION['varsrch'] = $row["Varsrch"];
- $_SESSION['justonCD'] = $row["JustOnCD"];
- $_SESSION['mobilityData'] = $row["mobilityData"];
- $_SESSION['eveFielderCollection'] = $row["eveFielderCollection"];
-
-
- $piList[$row_index] = $row[ "pi"];
-
-
- $temp_pi = $row["pi"];
- if ($temp_pi != $current_pi) {
-
- $piListFull[$row_index]["picode_id"] = $row["picode_id"];
- $piListFull[$row_index]["pi_tisubsort"] = $row["tisubsort"];
- $piListFull[$row_index]["pi"] = $temp_pi;
- $piListFull[$row_index]["picode"] = $row["picode"];
-
- $current_pi = $temp_pi;
- //echo "<br>" . $temp_pi . "<br>";
- }
-
-
-
- $subjectList[$row_index] = $row[ "subject"];
-
- $temp_subject = $row["subject"];
- if ($temp_subject != $current_subject) {
-
- $subjectListFull[$row_index]["shcode_id"] = $row["shcode_id"];
- $subjectListFull[$row_index]["subject_subsort"] = $row["subject_subsort"];
- $subjectListFull[$row_index]["subject"] = $temp_subject;
- $subjectListFull[$row_index]["subjectcode"] = $row["subjectcode"];
-
- $current_subject = $temp_subject;
- //echo "<br>" . $temp_subject . "<br>";
- }
-
- $row_index++;
-
- }
- //print_r($subjectListFull);
- //echo "<br>";
-
- sort($piListFull); // this will sort and re-number
- sort($subjectListFull);
- //print_r($piListFull);
- //echo "<br><br>";
- $piListFullCount = count($piListFull);
- $subjectListFullCount = count($subjectListFull);
-
- $piList = array_unique($piList);
- sort($piList);
- $piListCount = count($piList);
- //echo "<br>unique pi rows: " . $piListCount;
-
- //print_r($piList);
-
- if ($piListCount <= 1) { // just one pi
-
- $row_index = 0;
-
- $pi = $piList[$row_index];
- // I'm still using both of these
- $piTempList = $piList[$row_index];
-
- $_SESSION['pi'] = $piList[$row_index];
-
- } elseif ($piListCount > 1) { // there will be a list of PIs
-
- $piTempList = "";
-
- for ($row_index = 0; $row_index < $piListCount-1; $row_index++) { // minus 1 so the last item won't have a ;
-
- $piTempList .= $piList[$row_index] . "; ";
-
- }
-
- $piTempList .= $piList[$row_index];
-
- //echo $piTempList . "<br>";
-
- $_SESSION["pi"] = $piTempList;
-
- }
- //echo $piTempList . "<br>";
- //$subjectListCount = count($piList);
- $subjectList = array_unique($subjectList);
- sort($subjectList);
- $subjectListCount = count($subjectList);
-
- if ($subjectListCount <= 1) { // just one subject/keyword
-
- $row_index = 0;
- $_SESSION['subject'] = $subjectList[$row_index];
-
- } elseif ($subjectListCount > 1) { // there will be a list of PIs
-
- $subjectTempList = "";
-
- for ($row_index = 0; $row_index < $subjectListCount-1; $row_index++) { // minus 1 so the last item won't have a ;
-
- $subjectTempList .= $subjectList[$row_index] . "; ";
-
- }
-
- $subjectTempList .= $subjectList[$row_index];
-
- //echo $subjectTempList . "<br>";
-
- $_SESSION["subject"] = $subjectTempList;
-
- }
-
- //echo "<br>" . $subjectTempList . "<br>";
-
- // close connection
- $PDO_connection = null;
-
- //
-
-
-
-
- } else
-
- $studynumber = '';
-
- // add session variables so the pages stays populated
- //session_start();
-
- if (isset($_SESSION['studynumber']))
- $studynumber = $_SESSION['studynumber'];
- else
- $studynumber = '';
-
- if (isset($_SESSION['title']))
- $title = $_SESSION['title'];
- else
- $title = '';
-
- if (isset($_SESSION['tisort']))
- $tisort = $_SESSION['tisort'];
- else
- $tisort = '';
-
- if (isset($_SESSION['pi']))
- $pi = $_SESSION['pi'];
- else
- $pi = '';
-
- if (isset($_SESSION['subject']))
- $subject = $_SESSION['subject'];
- else
- $subject = '';
-
- if (isset($_SESSION['cite_title']))
- $cite_title = $_SESSION['cite_title'];
- else
- $cite_title = '';
-
- if (isset($_SESSION['cite_subsort']))
- $cite_subsort = $_SESSION['cite_subsort'];
- else
- $cite_subsort = '';
-
- if (isset($_SESSION['wwwtext']))
- $wwwtext = $_SESSION['wwwtext'];
- else
- $wwwtext = '';
-
- if (isset($_SESSION['wwwlink']))
- $wwwlink = $_SESSION['wwwlink'];
- else
- $wwwlink = '';
-
- if (isset($_SESSION['sda']))
- $sda = $_SESSION['sda'];
- else
- $sda = '';
-
- if (isset($_SESSION['varsrch']))
- $varsrch = $_SESSION['varsrch'];
- else
- $varsrch = '';
-
- if (isset($_SESSION['restricted']))
- $restricted = $_SESSION['restricted'];
- else
- $restricted = '';
-
- if (isset($_SESSION['justonCD']))
- $justonCD = $_SESSION['justonCD'];
- else
- $justonCD = '';
-
- if (isset($_SESSION['mobilityData']))
- $mobilityData = $_SESSION['mobilityData'];
- else
- $mobilityData = '';
-
- if (isset($_SESSION['eveFielderCollection']))
- $eveFielderCollection = $_SESSION['eveFielderCollection'];
-
- else
- $eveFielderCollection = '';
-
-
- //echo "<br>" . $title . ", " . $sda . ", " . $justonCD . ", " . $varsrch . ", " . $mobilityData . ", " . $eveFielderCollection . "<br>";
-
- //$queryFileTypes = "SELECT distinct FileType FROM fileinfo where FileType != '' ORDER BY FileType";
- $queryFileTypes = "SELECT DISTINCT fileinfo.FileType FROM fileinfo WHERE ((Not (fileinfo.FileType)='')) OR (((fileinfo.FileType) Is Not Null)) ORDER BY fileinfo.FileType";
-
- $queryTitleStudyNumFileType = "SELECT title.StudyNum, fileinfo.FileType, fileinfo.DTAfile FROM title LEFT JOIN fileinfo ON title.StudyNum = fileinfo.StudyNum ORDER BY title.StudyNum";
-
-
-
- // PDO connect
- $PDO_string = "mysql:host=" . $db_host . ";port=" . $db_port . ";dbname=" . $db_name ;
-
- try {
- $PDO_connection = new PDO($PDO_string, $db_username, $db_password);
-
- } catch(PDOException $e) {
- echo "Could not connect to the database because: ". $e->getMessage()."<br>";
- die();
- }
-
- // PDO - create prepared statement: get the table.pifull
- // --------------------------------------------------------
- $PDO_query = $PDO_connection->prepare($queryTitleStudyNumFileType);
- // PDO - execute the query
- $result = $PDO_query->execute();
- if (!$result) {
- die ("Could not query the database: <br />". mysql_error());
- }
- $fileTypeList = array();
- $studynumberList = array();
- $titleList = array();
- $dtafileList = array();
-
- $result = $PDO_query->fetch(PDO::FETCH_ASSOC);
- $row_index = 0;
- while ($row = $PDO_query->fetch(PDO::FETCH_ASSOC)) {
-
- $studynumberList[$row_index] = $row["StudyNum"];
- if (!is_null($row["FileType"])) { $fileTypeList[$row_index] = $row["FileType"]; } // others won't have nulls
- $dtafileList[$row_index] = $row["DTAfile"];
-
-
- $row_index++;
- }
-
- $fileTypeList = array_unique($fileTypeList);
- sort($fileTypeList);
- $fileTypeTotal = count($fileTypeList);
-
- $dtafileList = array_unique($dtafileList);
- sort($dtafileList);
-
-
- $studynumberList = array_unique($studynumberList);
- sort($studynumberList);
- $studynumberListTotal = count($studynumberList);
-
-
- $fileTypeListText = implode("','", $fileTypeList);
- $fileTypeListText = "'" . $fileTypeListText . "'";
-
-
- //--------------------------------------------------------------------
- // Section: populate the PI listbox
- // used for authority control, javascript select_PIs will paste in selected fields
- //----------------------------------------------------------------------
- $queryPI_list = "SELECT DISTINCT * FROM pifull ORDER BY pi";
- // echo text for debugging purposes only
-
- // PDO connect
- $PDO_string = "mysql:host=" . $db_host . ";port=" . $db_port . ";dbname=" . $db_name ;
-
- try {
- $PDO_connection = new PDO($PDO_string, $db_username, $db_password);
-
- } catch(PDOException $e) {
- echo "Could not connect to the database because: ". $e->getMessage()."<br>";
- die();
- }
-
- // PDO - create prepared statement: get the table.pifull
- // --------------------------------------------------------
- $PDO_query = $PDO_connection->prepare($queryPI_list);
- // PDO - execute the query
- $result = $PDO_query->execute();
- if (!$result) {
- die ("Could not query the database: <br />". mysql_error());
- }
- $PI_list = array();
-
-
- $result = $PDO_query->fetch(PDO::FETCH_ASSOC);
- $row_index = 0;
-
- while ($row = $PDO_query->fetch(PDO::FETCH_ASSOC)) {
-
- $PI_list[$row_index]["picode"] = $row["picode"];
- $PI_list[$row_index]["pi"] = $row["pi"];
- $row_index++;
- }
-
- $PI_list_count = count($PI_list);
- echo "PI count: " . $PI_list_count . " ";
-
- //--------------------------------------------------------------
- // end populate PI section
- //-------------------------------------------------------------
- //--------------------------------------------------------------------
- // Section: populate the Subject/Index-term listbox
- // used for authority control, javascript to copy and paste in selected fields
- //----------------------------------------------------------------------
- $querySubject_list = "SELECT DISTINCT subject FROM shfull ORDER BY subject";
- // echo for debugging purposes only
-
- // PDO connect
- $PDO_string = "mysql:host=" . $db_host . ";port=" . $db_port . ";dbname=" . $db_name ;
-
- try {
- $PDO_connection = new PDO($PDO_string, $db_username, $db_password);
-
- } catch(PDOException $e) {
- echo "Could not connect to the database because: ". $e->getMessage()."<br>";
- die();
- }
-
- // PDO - create prepared statement: get the table.pifull
- // --------------------------------------------------------
- $PDO_query = $PDO_connection->prepare($querySubject_list);
- // PDO - execute the query
- $result = $PDO_query->execute();
- if (!$result) {
- die ("Could not query the database: <br />". mysql_error());
- }
- $Subject_list = array();
-
-
- $result = $PDO_query->fetch(PDO::FETCH_ASSOC);
- $row_index = 0;
-
- while ($row = $PDO_query->fetch(PDO::FETCH_ASSOC)) {
-
- $Subject_list[$row_index]["subject"] = $row["subject"];
- $row_index++;
- }
-
- $Subject_list_count = count($Subject_list);
- echo "Subject count: " . $Subject_list_count . "<br>";
- //--------------------------------------------------------------
- // end populate Subject section
- //-------------------------------------------------------------
-
-
- ?>
- <div id="masthead">
- <h1 id="siteName">UCLA Institute for Social Research Data Archives</h1>
- <h2 id="siteName"><a href="index.php" target="_self">Maintenance Menu</a> / Edit Base Record</h2>
- </div> <!--end masthead--><!--end masthead-->
- <div style="margin: 1% 5% 2% 2%;line-height: 1.5; ">
- <form <?php
-
- if (isset($_SESSION['studynumber'])) { // a study has been chose so post means go to updateCheck
- echo " action='da_catalog_updateCheck.php'";
-
- } else { // a study HAS NOT been chosen so post the study info back to the input page when you do choose a study
- echo " action=''";
- }
-
- ?> method="post" name="updateRecord" target="_self">
-
-
- <p><label>Studynumber:
- <?php
- if (isset($_SESSION['studynumber'])) {
-
- $studynumber = $_SESSION['studynumber'];
-
- echo '<input name="studynumber" type="text" id="studynumber" value="' . $studynumber . '" size="30" maxlength="255">';
-
-
- echo '</select>';
-
-
- } else {
-
- echo '<select name="studynumber" id="studynumber">';
- echo '<option value="">choose studynumber</option>';
-
- foreach ($studynumberList as $key => $value) {
-
- echo '<option value="' . $value . '">' . $value;
-
- }
-
- echo " <input name='getbaserecord' type='submit' id='getbaserecord' value='Get this Studynumber'>";
- }
-
-
-
- ?></label>
-
- <input name="updateTitle" type="submit" id="updateTitle" value="save/update record">
- <input name="reset form" type="reset" value="reset">
- <input type="button" onClick="history.go(0)" value="Reload page">
- <br><br>
- <input name="title" type="hidden" value="title">
-
- <label>Title: <input name="title" type="text" value="<?php echo $title ?>" size="100" maxlength="225">
- </label><input name="tisubsort" type="hidden" value="1">
-
- <br><br>
- <label>Title level citation: (Subsort number: <?php echo $cite_subsort ?>) <textarea name="cite_title" type="text" cols="200"><?php echo $cite_title ?></textarea></label>
- <input name="cite_subsort" type="hidden" value="<?php echo $cite_subsort ?>">
-
- <label>Restricted:<input name="restricted" type="checkbox" value="*" <?php if ($restricted == "*") { echo "CHECKED"; } ?> >
- </label>
-
- <label>SDA:<input name="sda" type="checkbox" value="*" <?php if ($sda == "*") { echo "CHECKED"; } ?> >
- </label>
-
- <label>Varsrch:<input name="varsrch" type="checkbox" value="*" <?php if ($varsrch == "*") { echo "CHECKED"; } ?> >
- </label>
-
-
- <label>CD Only:
- <input name="justonCD" type="checkbox" id="justonCD" value="*" <?php if ($justonCD == "*") { echo "CHECKED"; } ?> >
- </label>
-
- <label>
- <input name="article" type="hidden" value="">
- </label>
-
- <label>Mobility Data:<input name="mobilityData" type="checkbox" id="mobilityData" value="*" <?php if ($mobilityData == "*") { echo "CHECKED"; } ?> >
- </label> <label>Eve Fielder Collection:<input name="eveFielderCollection" type="checkbox" id="eveFielderCollection" value="*" <?php if ($eveFielderCollection == "*") { echo "CHECKED"; } ?> >
- </label></p>
- </form>
- <form action="da_catalog_processFormCheck.php" method="post" name="editSubject" target="_self">
- <br><label>Subject/Index Term List: <input name="subject" type="text" value="<?php echo $subjectTempList; ?> " size="200" maxlength="255"></label>
-
- <label>Select Subject/Keyword(s) from list:</label>
- <input name="pickSubjects" type="button" id="pickSubjects" onClick="selectPasteCopy('editSubject', 'subject_list','subject')" value="Select and Paste to Subject List">
- <input name="clearOutSubject_list" type="button" id="clearOutSubject_list" onClick="clearoutTextElement('addRecord', 'subject')" value="clear out Subject list">
- <br>
- <strong>Note</strong>: It is possible to select <em>MULTIPLE</em> subject/keyword terms but in order to add terms in a <strong>specific order</strong>, select and paste <em>each term Individually</em>. <br>
-
- <select name="subject_list" size="10" multiple id="subject_list">
- <!--
- //--------------------------------------------------------------------------
- // dropdown box that is populated with Subject/Keyword terms
- // used as authority control
- // pick from list and paste into text box/pi with javscript (da_catalog.js library) selectPasteCopy and clearoutTextElement scripts functions
- //--------------------------------------------------------------------------
- -->
- <?php
-
- for ($row_index=0; $row_index < $Subject_list_count; $row_index++) {
- $subject = $Subject_list[$row_index]["subject"];
-
- echo '<option value="' . $subject . '">' .$subject;
-
- }
- ?>
- <!--
- //---------------------------------------------------------------------------------
- // end of suybject list box
- //------------------------------------------------
- -->
-
- </select>
-
-
- <label>Subject(s)/Keywords(s) currently linked to <?php echo $studynumber; ?></label>
- <?php if (isset($_SESSION['studynumber'])) {
-
- //echo "<br>";
- $studynumber = $_SESSION['studynumber'];
-
- //sort($subjectListFull);
- //$subjectListFull = array_unique($subjectListFull);
- sort($subjectListFull);
- $subjectListFullCount = count($subjectListFull);
- //echo "<br>unique subject rows: " . $subjectListFullCount . "<br>";
-
-
- for ($row_index = 0; $row_index < $subjectListFullCount; $row_index++) {
-
- $subject = $subjectListFull[$row_index]["subject"];
- $shcode_id = $subjectListFull[$row_index]["shcode_id"];
- $subjectcode = $subjectListFull[$row_index]["subjectcode"];
- $subject_subsort = $subjectListFull[$row_index]["subject_subsort"];
- $currentSubject = null;
-
- if ($subjectcode != $currentSubjectCode) {
- echo "<input name='subject' type='text' value='" . $subject . "' size='100' maxlength='255'>";
- echo "<input name='studynumber' type='hidden' value='" . $studynumber . "' >";
- echo "<input name='tisort' type='hidden' value='" . $tisort . "' >";
- echo "<input name='subjectcode' type='text' value='subjectcode: " . $subjectcode . "' >";
- echo "<input name='shcode_id' type='text' value='shcode_id: " . $shcode_id . "' >";
- echo "<input name='item_id' type='hidden' value='" . $shcode_id . "' >";
- echo "<input name='requestCategory' type='hidden' value='subject'>";
- // name below is the connecting table for the subjects
- //
- echo "<input name='subject_subsort' type='hidden' value='" . $subject_subsort . "' size='3' maxlength='3'>";
- echo "<input name='item_subsort' type='text' value='" . $subject_subsort . "' size='3' maxlength='3'>";
- //
- echo "<input name='table_name' type='hidden' value='shcode'>";
- echo "<input name='item_subsort_fieldname' type='hidden' value='subsort'>";
- echo "<input name='requestType' type='submit' value='Update sort number'> <input name='requestType' type='submit' value='Delete link'>";
- //echo " " . $row_index;
- $currentSubjectCode = $subjectcode;
- }
-
- }
-
- }
-
- ?>
- </form>
-
- <br>
- <?php
-
- // close the connection
- // mysql_close($connection);
- $PDO_connection = null;
-
- ?>
-
- </div> <!-- end content-->
-
- </body></html>