コード例 #1
0
 function get_qa_level_test_result($registry_object, $relatedClassStr)
 {
     $xslt_processor = Transforms::get_qa_level_transformer();
     $dom = new DOMDocument();
     $dom->loadXML(str_replace('&', '&', $registry_object->getRif()), LIBXML_NOENT);
     $xslt_processor->setParameter('', 'relatedObjectClassesStr', $relatedClassStr);
     // XXX: TODO!!!
     return $xslt_processor->transformToXML($dom);
 }
コード例 #2
0
    function transformToEndnote()
    {
        $this->_CI->load->helper('normalisation');
        try {
            $xslt_processor = Transforms::get_extrif_to_endnote_transformer();
            $dom = new DOMDocument();
            $dom->loadXML(str_replace('&', '&', $this->ro->getExtRif()), LIBXML_NOENT);
            $xslt_processor->setParameter('', 'dateHarvested', date("Y", $this->ro->created));
            $xslt_processor->setParameter('', 'dateRequested', date("Y-m-d"));
            $xslt_processor->setParameter('', 'portal_url', portal_url() . $this->ro->slug . "/" . $this->ro->id);
            $xml_output = $xslt_processor->transformToXML($dom);
            $authStr = '';
            //we want to post process the authors and funding name
            if (str_replace("%%%AU  - Anonymous", "", $xml_output) != $xml_output) {
                $relationshipTypeArray = array('hasPrincipalInvestigator', 'principalInvestigator', 'author', 'coInvestigator', 'isOwnedBy', 'hasCollector');
                $classArray = array('party');
                $authors = $this->ro->getRelatedObjectsByClassAndRelationshipType($classArray, $relationshipTypeArray);
                if (count($authors) > 0) {
                    foreach ($authors as $author) {
                        if ($author['status'] == PUBLISHED) {
                            $authStr .= "AU  - " . $author['title'] . "\n";
                        }
                    }
                } else {
                    $authStr = 'AU  - Anonymous';
                }
                if ($authStr == '') {
                    $authStr = 'AU  - Anonymous';
                }
                $xml_output = str_replace("%%%AU  - Anonymous", trim($authStr), $xml_output);
            } else {
                $authors = explode('%%%AU - ', $xml_output);
                for ($i = 1; $i < count($authors); $i++) {
                    $author = explode(' - AU%%%', $authors[$i]);
                    $author_object = $this->_CI->ro->getPublishedByKey(trim($author[0]));
                    if ($author_object->list_title) {
                        $xml_output = str_replace('%%%AU - ' . trim($author[0]) . ' - AU%%%', 'AU  - ' . $author_object->list_title, $xml_output);
                    } else {
                        $xml_output = str_replace('%%%AU - ' . trim($author[0]) . ' - AU%%%
', '', $xml_output);
                    }
                }
            }
            $funders = explode('%%%A4 - ', $xml_output);
            for ($i = 1; $i < count($funders); $i++) {
                $funder = explode(' - A4%%%', $funders[$i]);
                $grant_object = $this->_CI->ro->getPublishedByKey(trim($funder[0]));
                if ($grant_object && $grant_object->status == PUBLISHED) {
                    $grant_sxml = $grant_object->getSimpleXML(NULL, true);
                    // Handle the researcher IDs (using the normalisation_helper.php)
                    $grant_id = $grant_sxml->xpath("//ro:identifier[@type='arc'] | //ro:identifier[@type='nhmrc'] | //ro:identifier[@type='purl']");
                    $related_party = $grant_object->getRelatedObjectsByClassAndRelationshipType(array('party'), array('isFunderOf', 'isFundedBy'));
                    if (is_array($grant_id)) {
                        if (is_array($related_party) && isset($related_party[0])) {
                            $xml_output = str_replace('%%%A4 - ' . trim($funder[0]) . ' - A4%%%', 'A4  - ,' . $related_party[0]['title'], $xml_output);
                        } else {
                            $xml_output = str_replace('%%%A4 - ' . trim($funder[0]) . ' - A4%%%
', '', $xml_output);
                        }
                    } else {
                        $xml_output = str_replace('%%%A4 - ' . trim($funder[0]) . ' - A4%%%
', '', $xml_output);
                    }
                } else {
                    $xml_output = str_replace('%%%A4 - ' . trim($funder[0]) . ' - A4%%%
', '', $xml_output);
                }
            }
            return $xml_output;
        } catch (Exception $e) {
            echo "UNABLE TO TRANSFORM" . BR;
            echo "<pre>" . nl2br($e->getMessage()) . "</pre>" . BR;
        }
    }
コード例 #3
0
 function cleanRIFCSofEmptyTags($rifcs, $removeFormAttributes = 'true')
 {
     if (strlen($rifcs) > 50000) {
         $rifcs = preg_replace('/<relatedObject.*?<\\/relatedObject>|\\s{2,}/ms', '', $rifcs);
     }
     $xslt_processor = Transforms::get_form_to_cleanrif_transformer();
     $dom = new DOMDocument();
     //$dom->loadXML($this->ro->getXML());
     $dom->loadXML(wrapRegistryObjects(unWrapRegistryObjects($rifcs)));
     //$dom->loadXML($rifcs);
     $xslt_processor->setParameter('', 'removeFormAttributes', $removeFormAttributes);
     return $xslt_processor->transformToXML($dom);
 }
コード例 #4
0
 function cleanNameSpace($rifcs)
 {
     try {
         $xslt_processor = Transforms::get_clean_ns_transformer();
         $dom = new DOMDocument();
         $dom->loadXML($rifcs);
         return $xslt_processor->transformToXML($dom);
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
コード例 #5
0
 static function get_extrif_to_endnote_transformer()
 {
     if (is_null(self::$extrif_to_endnote_transformer)) {
         $endnote_xsl = new DomDocument();
         $endnote_xsl->load(REGISTRY_APP_PATH . 'registry_object/transforms/extrif_to_endnote.xsl');
         $endProc = new XSLTProcessor();
         $endProc->importStyleSheet($endnote_xsl);
         self::$extrif_to_endnote_transformer = $endProc;
     }
     return self::$extrif_to_endnote_transformer;
 }