/**
  * @param $arguments \Wave\Framework\Application\Contexts\ArgumentsContext
  * @param $context \Wave\Framework\Storage\Registry
  */
 public function create($arguments, $context)
 {
     $config = $context->get('config');
     $via = $arguments->get('methods');
     list($controller, $method) = explode(';', trim($arguments->get('callback'), '"'));
     $module = $arguments->get('module');
     $pattern = $config['modules'][$module] . implode('/', $arguments->get('pattern'));
     if (!is_null($module) && is_readable(sprintf(getcwd() . '/application/modules/%s.xml', $module))) {
         $xml = new \SimpleXMLElement(sprintf(getcwd() . '/application/modules/%s.xml', $module), null, true);
         /**
          * @var $child \SimpleXMLElement
          */
         foreach ($xml->children() as $child) {
             if ($child['pattern'] == $pattern && $child['method'] == $method) {
                 echo sprintf("\t Error route already exists in module '%s'\n\r\n\r", $module);
                 exit(1);
             }
         }
         $route = $xml->addChild('route');
         $route->addAttribute('pattern', $pattern);
         $route->addAttribute('via', $via);
         $route->addAttribute('method', $method);
         $route->addAttribute('controller', $controller);
         if (!is_null($arguments->get('handler'))) {
             $route->addAttribute('handler', $arguments->get('handler'));
         }
         $xml->saveXML(sprintf(getcwd() . '/application/modules/%s.xml', $module));
     }
 }
Example #2
0
 public function setUp()
 {
     $xml = new SimpleXMLElement('<docblox />');
     $xml->title = self::TITLE;
     $xml->visibility = self::VISIBILITY;
     DocBlox_Core_Abstract::setConfig(new DocBlox_Core_Config($xml->saveXML()));
     $this->fixture = new DocBlox_Task_Project_Parse();
 }
 /**
  * Convert XML object to string.
  *
  * @param   \SimpleXMLElement|\DOMDocument|string  $data  XML object or data.
  *
  * @return  string  Converted XML string.
  */
 protected function toString($data)
 {
     if ($data instanceof \SimpleXMLElement) {
         return $data->asXML();
     } elseif ($data instanceof \DOMDocument) {
         return $data->saveXML();
     } elseif (is_string($data)) {
         return $data;
     }
     throw new \InvalidArgumentException(sprintf('Invalid XML content type, %s provided.', gettype($data)));
 }
Example #4
0
 private function xmlconfig($mac)
 {
     $this->gsgeral();
     $this->gsuser($mac);
     $xml = new SimpleXMLElement("<?xml version='1.0' encoding='utf-8'?><gs_provision/>");
     $xml->addAttribute('version', '1');
     $xml->addChild("mac", $mac);
     $xml->addChild("config")->addAttribute('version', '1');
     foreach ($this->gsconfig as $k => $v) {
         $xml->config->addChild($k, $v);
     }
     $this->output->set_content_type('application/xml')->set_output($xml->saveXML());
 }
 /**
  * @see uspsQuery::prepareRequest()
  */
 protected function prepareRequest()
 {
     $xml = new SimpleXMLElement('<TrackRequest/>');
     $xml->addAttribute('USERID', $this->plugin->user_id);
     $track = $xml->addChild('TrackID');
     if ($this->plugin->test_mode) {
         // test request
         // @see https://www.usps.com/business/web-tools-apis/delivery-information.htm
         $track->addAttribute('ID', 'EJ958083578US');
     } else {
         $track->addAttribute('ID', $this->params['tracking_id']);
     }
     return $xml->saveXML();
 }
Example #6
0
function adrotate_export_ads($ids, $format)
{
    global $wpdb;
    $all_ads = $wpdb->get_results("SELECT * FROM `{$wpdb->prefix}adrotate` ORDER BY `id` ASC;", ARRAY_A);
    $ads = array();
    foreach ($all_ads as $single) {
        if (in_array($single['id'], $ids)) {
            $starttime = $stoptime = 0;
            $starttime = $wpdb->get_var("SELECT `starttime` FROM `{$wpdb->prefix}adrotate_schedule`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = '" . $single['id'] . "' AND `schedule` = `{$wpdb->prefix}adrotate_schedule`.`id` ORDER BY `starttime` ASC LIMIT 1;");
            $stoptime = $wpdb->get_var("SELECT `stoptime` FROM `{$wpdb->prefix}adrotate_schedule`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = '" . $single['id'] . "' AND  `schedule` = `{$wpdb->prefix}adrotate_schedule`.`id` ORDER BY `stoptime` DESC LIMIT 1;");
            if (!is_array($single['cities'])) {
                $single['cities'] = array();
            }
            if (!is_array($single['countries'])) {
                $single['countries'] = array();
            }
            $ads[$single['id']] = array('title' => $single['title'], 'bannercode' => stripslashes($single['bannercode']), 'imagetype' => $single['imagetype'], 'image' => $single['image'], 'tracker' => $single['tracker'], 'mobile' => $single['mobile'], 'tablet' => $single['tablet'], 'responsive' => $single['responsive'], 'weight' => $single['weight'], 'budget' => $single['budget'], 'crate' => $single['crate'], 'irate' => $single['irate'], 'cities' => implode(',', maybe_unserialize($single['cities'])), 'countries' => implode(',', maybe_unserialize($single['countries'])), 'start' => $starttime, 'end' => $stoptime);
        }
    }
    if ($ads) {
        $filename = "AdRotate_export_" . date_i18n("mdYHi") . "_" . uniqid() . ".xml";
        $xml = new SimpleXMLElement('<adverts></adverts>');
        foreach ($ads as $ad) {
            $node = $xml->addChild('advert');
            $node->addChild('title', $ad['title']);
            $node->addChild('bannercode', $ad['bannercode']);
            $node->addChild('imagetype', $ad['imagetype']);
            $node->addChild('image', $ad['image']);
            $node->addChild('tracker', $ad['tracker']);
            $node->addChild('mobile', $ad['mobile']);
            $node->addChild('tablet', $ad['tablet']);
            $node->addChild('responsive', $ad['responsive']);
            $node->addChild('weight', $ad['weight']);
            $node->addChild('budget', $ad['budget']);
            $node->addChild('crate', $ad['crate']);
            $node->addChild('irate', $ad['irate']);
            $node->addChild('cities', $ad['cities']);
            $node->addChild('countries', $ad['countries']);
            $node->addChild('start', $ad['start']);
            $node->addChild('end', $ad['end']);
        }
        file_put_contents(WP_CONTENT_DIR . '/reports/' . $filename, $xml->saveXML());
        unset($all_ads, $ads);
        adrotate_return('adrotate-ads', 215, array('file' => $filename));
        exit;
    } else {
        adrotate_return('adrotate-ads', 509);
    }
}
Example #7
0
 public function __construct(SimpleXMLElement $xml = null)
 {
     if (!$xml) {
         return;
     }
     foreach ($xml->children() as $nodeName => $node) {
         if (!is_null($this->{$nodeName})) {
             continue;
         }
         $type = $this->getAttributeType($nodeName);
         if (is_null($type)) {
             throw new WebexXmlException("No type found for " . get_class($this) . "->{$nodeName}, XML: " . $xml->saveXML());
         }
         $this->{$nodeName} = $this->getAttributeValue($type, $xml->xpath($nodeName));
     }
     //		foreach($xml->attributes($prefix, true) as $attributeName => $attribute)
     //			$this->attributes[$attributeName] = strval($attribute);
 }
 /**
  * Set the Xml
  *
  * @param SimpleXMLElement $xml OSM XML
  *
  * @return Services_OpenStreetMap_Relation
  */
 public function setXml(SimpleXMLElement $xml)
 {
     $this->xml = $xml->saveXML();
     $obj = $xml->xpath('//' . $this->getType());
     foreach ($obj[0]->children() as $child) {
         $childname = $child->getName();
         if ($childname == 'tag') {
             $key = (string) $child->attributes()->k;
             if ($key != '') {
                 $this->tags[$key] = (string) $child->attributes()->v;
             }
         } elseif ($childname == 'member') {
             $this->members[] = array('type' => (string) $child->attributes()->type, 'ref' => (string) $child->attributes()->ref, 'role' => (string) $child->attributes()->role);
         }
     }
     $this->obj = $obj;
     return $this;
 }
 /**
  * @param Request $request
  * @return string|\Symfony\Component\HttpFoundation\RedirectResponse
  * @throws
  */
 public function newAction(Request $request)
 {
     $createNewFileForm = new NewFileForm($this->app['form.factory']);
     $newFileForm = $createNewFileForm->createForm();
     if ($request->getMethod() === 'POST') {
         $newFileForm->bind($request);
         if ($newFileForm->isValid()) {
             $filename = $newFileForm->getData();
             $filename = $filename['fileName'];
             $XMLPattern = new \SimpleXMLElement("<?xml version=\"1.0\" encoding=\"utf-8\" ?><YealinkIPPhoneDirectory></YealinkIPPhoneDirectory>");
             if ($XMLPattern->saveXML($this->app['sourceDirectory'] . '/' . $filename . '.xml') !== false) {
                 return $this->app->redirect($this->app['url_generator']->generate('contact', array('name' => $filename . ".xml")));
             } else {
                 throw \Exception("Problem with save file into given directory");
             }
         }
     }
     return $this->twig->render('twigs/Source/new.html.twig', array('newFileForm' => $newFileForm->createView()));
 }
function adrotate_export_ads($ids)
{
    global $wpdb;
    $all_ads = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "adrotate` ORDER BY `id` ASC;", ARRAY_A);
    $filename = "AdRotate_export_" . date_i18n("mdYHi") . "_" . uniqid() . ".xml";
    $fp = fopen(WP_CONTENT_DIR . '/reports/' . $filename, 'r');
    $xml = new SimpleXMLElement('<adverts></adverts>');
    foreach ($all_ads as $single) {
        if (in_array($single['id'], $ids)) {
            $starttime = $stoptime = 0;
            $starttime = $wpdb->get_var("SELECT `starttime` FROM `" . $wpdb->prefix . "adrotate_schedule`, `" . $wpdb->prefix . "adrotate_linkmeta` WHERE `ad` = '" . $single['id'] . "' AND `schedule` = `" . $wpdb->prefix . "adrotate_schedule`.`id` ORDER BY `starttime` ASC LIMIT 1;");
            $stoptime = $wpdb->get_var("SELECT `stoptime` FROM `" . $wpdb->prefix . "adrotate_schedule`, `" . $wpdb->prefix . "adrotate_linkmeta` WHERE `ad` = '" . $single['id'] . "' AND  `schedule` = `" . $wpdb->prefix . "adrotate_schedule`.`id` ORDER BY `stoptime` DESC LIMIT 1;");
            if (!is_array($single['cities'])) {
                $single['cities'] = array();
            }
            if (!is_array($single['countries'])) {
                $single['countries'] = array();
            }
            $node = $xml->addChild('advert');
            $node->addChild('title', $single['title']);
            $node->addChild('bannercode', stripslashes($single['bannercode']));
            $node->addChild('imagetype', $single['imagetype']);
            $node->addChild('image', $single['image']);
            $node->addChild('link', $single['link']);
            $node->addChild('tracker', $single['tracker']);
            $node->addChild('responsive', $single['responsive']);
            $node->addChild('weight', $single['weight']);
            $node->addChild('budget', $single['budget']);
            $node->addChild('crate', $single['crate']);
            $node->addChild('irate', $single['irate']);
            $node->addChild('cities', implode(',', unserialize($single['cities'])));
            $node->addChild('countries', implode(',', unserialize($single['countries'])));
            $node->addChild('start', $starttime);
            $node->addChild('end', $stoptime);
        }
    }
    file_put_contents(WP_CONTENT_DIR . '/reports/' . $filename, $xml->saveXML());
    adrotate_return('exported', array($filename));
    exit;
}
Example #11
0
 function saveXMLdocumentToFile($books, $Page)
 {
     $xml = new SimpleXMLElement('<Books/>');
     foreach ($books as $key) {
         $book = $xml->addChild('book');
         $book->addChild('title', $key['title']);
         $book->addChild('author', $key['author']);
         $book->addChild('pages', $key['pages']);
         $book->addChild('language', $key['language']);
     }
     $xml->saveXML('data/books.xml');
     // write only 5 records to xml file depends on current page
     $xml = new SimpleXMLElement('<Books/>');
     $curPage = $Page - 1;
     for ($i = $curPage * 5; $i < $curPage * 5 + 5; $i++) {
         $book = $xml->addChild('book');
         $book->addChild('title', $books[$i]['title']);
         $book->addChild('author', $books[$i]['author']);
         $book->addChild('pages', $books[$i]['pages']);
         $book->addChild('language', $books[$i]['language']);
     }
     $xml->saveXML('data/pagebooks.xml');
 }
 /**
  * @see uspsQuery::prepareRequest()
  * @throws waException
  */
 protected function prepareRequest()
 {
     $services = $this->getServices();
     $type = uspsServices::getServiceType($services[0]['id']);
     if (!$this->plugin->zip) {
         throw new waException($this->plugin->_w("Cannot calculate shipping rate because origin (sender's) ZIP code is not defined in USPS module settings"));
     }
     switch ($type) {
         case uspsServices::TYPE_DOMESTIC:
             $this->api = 'RateV4';
             $xml = new SimpleXMLElement('<RateV4Request/>');
             $xml->addChild('Revision');
             break;
         case uspsServices::TYPE_INTERNATIONAL:
             $this->api = 'IntlRateV2';
             $xml = new SimpleXMLElement('<IntlRateV2Request/>');
             break;
         default:
             throw new waException($this->plugin->_w("Unknown type of service"));
     }
     $xml->addAttribute('USERID', $this->plugin->user_id);
     $xml->addAttribute('PASSWORD', '');
     foreach ($services as $service) {
         $package = $xml->addChild('Package');
         $package->addAttribute('ID', str_replace(' ', '_', $service['code']));
         switch ($type) {
             case 'Domestic':
                 $this->prepareDomesticPackage($package, $service);
                 break;
             case 'International':
                 $this->prepareInternationalPackage($package, $service);
                 break;
         }
     }
     return $xml->saveXML();
 }
Example #13
0
//Run a loop for each uiConf to get its filesync key, thus acquiring its confile
foreach ($kcwUiconfs as $kcwUiconf) {
    /* @var $kcwUiconf uiConf */
    $kcwUiconfFilesyncKey = $kcwUiconf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_DATA);
    $kcwConfile = kFileSyncUtils::file_get_contents($kcwUiconfFilesyncKey, false, false);
    if (!$kcwConfile) {
        continue;
    }
    $kcwConfileXML = new SimpleXMLElement($kcwConfile);
    $path = '//provider[@id="kaltura" or @name="kaltura"]';
    $nodesToRemove = $kcwConfileXML->xpath($path);
    if (!count($nodesToRemove)) {
        continue;
    }
    if ($kcwUiconf->getCreationMode() != uiConf::UI_CONF_CREATION_MODE_MANUAL) {
        //No point in this "for" loop if we can't save the UIConf.
        foreach ($nodesToRemove as $nodeToRemove) {
            $nodeToRemoveDom = dom_import_simplexml($nodeToRemove);
            $nodeToRemoveDom->parentNode->removeChild($nodeToRemoveDom);
        }
        $kcwConfile = $kcwConfileXML->saveXML();
        $kcwUiconf->setConfFile($kcwConfile);
        $kcwUiconf->save();
    } else {
        $confilePath = $kcwUiconf->getConfFilePath() . "\n";
        fwrite($flog, $confilePath);
    }
    //$kcw_uiconf_filesync_key = $kcw_uiconf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_DATA);
    //kFileSyncUtils::file_put_contents($kcw_uiconf_filesync_key, $kcw_confile , false);
}
fclose($flog);
 /**
  * @param boolean $returnSXE
  * @param \SimpleXMLElement $sxe
  * @return string|\SimpleXMLElement
  */
 public function xmlSerialize($returnSXE = false, $sxe = null)
 {
     if (null === $sxe) {
         $sxe = new \SimpleXMLElement('<SearchModifierCode xmlns="http://hl7.org/fhir"></SearchModifierCode>');
     }
     $sxe->addAttribute('value', $this->value);
     if ($returnSXE) {
         return $sxe;
     }
     return $sxe->saveXML();
 }
 /**
  * @param boolean $returnSXE
  * @param \SimpleXMLElement $sxe
  * @return string|\SimpleXMLElement
  */
 public function xmlSerialize($returnSXE = false, $sxe = null)
 {
     if (null === $sxe) {
         $sxe = new \SimpleXMLElement('<QuestionnaireStatus xmlns="http://hl7.org/fhir"></QuestionnaireStatus>');
     }
     $sxe->addAttribute('value', $this->value);
     if ($returnSXE) {
         return $sxe;
     }
     return $sxe->saveXML();
 }
 /**
  * @param boolean $returnSXE
  * @param \SimpleXMLElement $sxe
  * @return string|\SimpleXMLElement
  */
 public function xmlSerialize($returnSXE = false, $sxe = null)
 {
     if (null === $sxe) {
         $sxe = new \SimpleXMLElement('<OperationParameterUse xmlns="http://hl7.org/fhir"></OperationParameterUse>');
     }
     $sxe->addAttribute('value', $this->value);
     if ($returnSXE) {
         return $sxe;
     }
     return $sxe->saveXML();
 }
 /**
  * @param boolean $returnSXE
  * @param \SimpleXMLElement $sxe
  * @return string|\SimpleXMLElement
  */
 public function xmlSerialize($returnSXE = false, $sxe = null)
 {
     if (null === $sxe) {
         $sxe = new \SimpleXMLElement('<ParticipantRequired xmlns="http://hl7.org/fhir"></ParticipantRequired>');
     }
     $sxe->addAttribute('value', $this->value);
     if ($returnSXE) {
         return $sxe;
     }
     return $sxe->saveXML();
 }
 /**
  * @param boolean $returnSXE
  * @param \SimpleXMLElement $sxe
  * @return string|\SimpleXMLElement
  */
 public function xmlSerialize($returnSXE = false, $sxe = null)
 {
     if (null === $sxe) {
         $sxe = new \SimpleXMLElement('<ResourceContainer xmlns="http://hl7.org/fhir"></ResourceContainer>');
     }
     if (null !== $this->Account) {
         $this->Account->xmlSerialize(true, $sxe->addChild('Account'));
     }
     if (null !== $this->AllergyIntolerance) {
         $this->AllergyIntolerance->xmlSerialize(true, $sxe->addChild('AllergyIntolerance'));
     }
     if (null !== $this->Appointment) {
         $this->Appointment->xmlSerialize(true, $sxe->addChild('Appointment'));
     }
     if (null !== $this->AppointmentResponse) {
         $this->AppointmentResponse->xmlSerialize(true, $sxe->addChild('AppointmentResponse'));
     }
     if (null !== $this->AuditEvent) {
         $this->AuditEvent->xmlSerialize(true, $sxe->addChild('AuditEvent'));
     }
     if (null !== $this->Basic) {
         $this->Basic->xmlSerialize(true, $sxe->addChild('Basic'));
     }
     if (null !== $this->Binary) {
         $this->Binary->xmlSerialize(true, $sxe->addChild('Binary'));
     }
     if (null !== $this->BodySite) {
         $this->BodySite->xmlSerialize(true, $sxe->addChild('BodySite'));
     }
     if (null !== $this->Bundle) {
         $this->Bundle->xmlSerialize(true, $sxe->addChild('Bundle'));
     }
     if (null !== $this->CarePlan) {
         $this->CarePlan->xmlSerialize(true, $sxe->addChild('CarePlan'));
     }
     if (null !== $this->Claim) {
         $this->Claim->xmlSerialize(true, $sxe->addChild('Claim'));
     }
     if (null !== $this->ClaimResponse) {
         $this->ClaimResponse->xmlSerialize(true, $sxe->addChild('ClaimResponse'));
     }
     if (null !== $this->ClinicalImpression) {
         $this->ClinicalImpression->xmlSerialize(true, $sxe->addChild('ClinicalImpression'));
     }
     if (null !== $this->Communication) {
         $this->Communication->xmlSerialize(true, $sxe->addChild('Communication'));
     }
     if (null !== $this->CommunicationRequest) {
         $this->CommunicationRequest->xmlSerialize(true, $sxe->addChild('CommunicationRequest'));
     }
     if (null !== $this->Composition) {
         $this->Composition->xmlSerialize(true, $sxe->addChild('Composition'));
     }
     if (null !== $this->ConceptMap) {
         $this->ConceptMap->xmlSerialize(true, $sxe->addChild('ConceptMap'));
     }
     if (null !== $this->Condition) {
         $this->Condition->xmlSerialize(true, $sxe->addChild('Condition'));
     }
     if (null !== $this->Conformance) {
         $this->Conformance->xmlSerialize(true, $sxe->addChild('Conformance'));
     }
     if (null !== $this->Contract) {
         $this->Contract->xmlSerialize(true, $sxe->addChild('Contract'));
     }
     if (null !== $this->Coverage) {
         $this->Coverage->xmlSerialize(true, $sxe->addChild('Coverage'));
     }
     if (null !== $this->DataElement) {
         $this->DataElement->xmlSerialize(true, $sxe->addChild('DataElement'));
     }
     if (null !== $this->DetectedIssue) {
         $this->DetectedIssue->xmlSerialize(true, $sxe->addChild('DetectedIssue'));
     }
     if (null !== $this->Device) {
         $this->Device->xmlSerialize(true, $sxe->addChild('Device'));
     }
     if (null !== $this->DeviceComponent) {
         $this->DeviceComponent->xmlSerialize(true, $sxe->addChild('DeviceComponent'));
     }
     if (null !== $this->DeviceMetric) {
         $this->DeviceMetric->xmlSerialize(true, $sxe->addChild('DeviceMetric'));
     }
     if (null !== $this->DeviceUseRequest) {
         $this->DeviceUseRequest->xmlSerialize(true, $sxe->addChild('DeviceUseRequest'));
     }
     if (null !== $this->DeviceUseStatement) {
         $this->DeviceUseStatement->xmlSerialize(true, $sxe->addChild('DeviceUseStatement'));
     }
     if (null !== $this->DiagnosticOrder) {
         $this->DiagnosticOrder->xmlSerialize(true, $sxe->addChild('DiagnosticOrder'));
     }
     if (null !== $this->DiagnosticReport) {
         $this->DiagnosticReport->xmlSerialize(true, $sxe->addChild('DiagnosticReport'));
     }
     if (null !== $this->DocumentManifest) {
         $this->DocumentManifest->xmlSerialize(true, $sxe->addChild('DocumentManifest'));
     }
     if (null !== $this->DocumentReference) {
         $this->DocumentReference->xmlSerialize(true, $sxe->addChild('DocumentReference'));
     }
     if (null !== $this->EligibilityRequest) {
         $this->EligibilityRequest->xmlSerialize(true, $sxe->addChild('EligibilityRequest'));
     }
     if (null !== $this->EligibilityResponse) {
         $this->EligibilityResponse->xmlSerialize(true, $sxe->addChild('EligibilityResponse'));
     }
     if (null !== $this->Encounter) {
         $this->Encounter->xmlSerialize(true, $sxe->addChild('Encounter'));
     }
     if (null !== $this->EnrollmentRequest) {
         $this->EnrollmentRequest->xmlSerialize(true, $sxe->addChild('EnrollmentRequest'));
     }
     if (null !== $this->EnrollmentResponse) {
         $this->EnrollmentResponse->xmlSerialize(true, $sxe->addChild('EnrollmentResponse'));
     }
     if (null !== $this->EpisodeOfCare) {
         $this->EpisodeOfCare->xmlSerialize(true, $sxe->addChild('EpisodeOfCare'));
     }
     if (null !== $this->ExplanationOfBenefit) {
         $this->ExplanationOfBenefit->xmlSerialize(true, $sxe->addChild('ExplanationOfBenefit'));
     }
     if (null !== $this->FamilyMemberHistory) {
         $this->FamilyMemberHistory->xmlSerialize(true, $sxe->addChild('FamilyMemberHistory'));
     }
     if (null !== $this->Flag) {
         $this->Flag->xmlSerialize(true, $sxe->addChild('Flag'));
     }
     if (null !== $this->Goal) {
         $this->Goal->xmlSerialize(true, $sxe->addChild('Goal'));
     }
     if (null !== $this->Group) {
         $this->Group->xmlSerialize(true, $sxe->addChild('Group'));
     }
     if (null !== $this->HealthcareService) {
         $this->HealthcareService->xmlSerialize(true, $sxe->addChild('HealthcareService'));
     }
     if (null !== $this->ImagingObjectSelection) {
         $this->ImagingObjectSelection->xmlSerialize(true, $sxe->addChild('ImagingObjectSelection'));
     }
     if (null !== $this->ImagingStudy) {
         $this->ImagingStudy->xmlSerialize(true, $sxe->addChild('ImagingStudy'));
     }
     if (null !== $this->Immunization) {
         $this->Immunization->xmlSerialize(true, $sxe->addChild('Immunization'));
     }
     if (null !== $this->ImmunizationRecommendation) {
         $this->ImmunizationRecommendation->xmlSerialize(true, $sxe->addChild('ImmunizationRecommendation'));
     }
     if (null !== $this->ImplementationGuide) {
         $this->ImplementationGuide->xmlSerialize(true, $sxe->addChild('ImplementationGuide'));
     }
     if (null !== $this->List) {
         $this->List->xmlSerialize(true, $sxe->addChild('List'));
     }
     if (null !== $this->Location) {
         $this->Location->xmlSerialize(true, $sxe->addChild('Location'));
     }
     if (null !== $this->Media) {
         $this->Media->xmlSerialize(true, $sxe->addChild('Media'));
     }
     if (null !== $this->Medication) {
         $this->Medication->xmlSerialize(true, $sxe->addChild('Medication'));
     }
     if (null !== $this->MedicationAdministration) {
         $this->MedicationAdministration->xmlSerialize(true, $sxe->addChild('MedicationAdministration'));
     }
     if (null !== $this->MedicationDispense) {
         $this->MedicationDispense->xmlSerialize(true, $sxe->addChild('MedicationDispense'));
     }
     if (null !== $this->MedicationOrder) {
         $this->MedicationOrder->xmlSerialize(true, $sxe->addChild('MedicationOrder'));
     }
     if (null !== $this->MedicationStatement) {
         $this->MedicationStatement->xmlSerialize(true, $sxe->addChild('MedicationStatement'));
     }
     if (null !== $this->MessageHeader) {
         $this->MessageHeader->xmlSerialize(true, $sxe->addChild('MessageHeader'));
     }
     if (null !== $this->NamingSystem) {
         $this->NamingSystem->xmlSerialize(true, $sxe->addChild('NamingSystem'));
     }
     if (null !== $this->NutritionOrder) {
         $this->NutritionOrder->xmlSerialize(true, $sxe->addChild('NutritionOrder'));
     }
     if (null !== $this->Observation) {
         $this->Observation->xmlSerialize(true, $sxe->addChild('Observation'));
     }
     if (null !== $this->OperationDefinition) {
         $this->OperationDefinition->xmlSerialize(true, $sxe->addChild('OperationDefinition'));
     }
     if (null !== $this->OperationOutcome) {
         $this->OperationOutcome->xmlSerialize(true, $sxe->addChild('OperationOutcome'));
     }
     if (null !== $this->Order) {
         $this->Order->xmlSerialize(true, $sxe->addChild('Order'));
     }
     if (null !== $this->OrderResponse) {
         $this->OrderResponse->xmlSerialize(true, $sxe->addChild('OrderResponse'));
     }
     if (null !== $this->Organization) {
         $this->Organization->xmlSerialize(true, $sxe->addChild('Organization'));
     }
     if (null !== $this->Patient) {
         $this->Patient->xmlSerialize(true, $sxe->addChild('Patient'));
     }
     if (null !== $this->PaymentNotice) {
         $this->PaymentNotice->xmlSerialize(true, $sxe->addChild('PaymentNotice'));
     }
     if (null !== $this->PaymentReconciliation) {
         $this->PaymentReconciliation->xmlSerialize(true, $sxe->addChild('PaymentReconciliation'));
     }
     if (null !== $this->Person) {
         $this->Person->xmlSerialize(true, $sxe->addChild('Person'));
     }
     if (null !== $this->Practitioner) {
         $this->Practitioner->xmlSerialize(true, $sxe->addChild('Practitioner'));
     }
     if (null !== $this->Procedure) {
         $this->Procedure->xmlSerialize(true, $sxe->addChild('Procedure'));
     }
     if (null !== $this->ProcedureRequest) {
         $this->ProcedureRequest->xmlSerialize(true, $sxe->addChild('ProcedureRequest'));
     }
     if (null !== $this->ProcessRequest) {
         $this->ProcessRequest->xmlSerialize(true, $sxe->addChild('ProcessRequest'));
     }
     if (null !== $this->ProcessResponse) {
         $this->ProcessResponse->xmlSerialize(true, $sxe->addChild('ProcessResponse'));
     }
     if (null !== $this->Provenance) {
         $this->Provenance->xmlSerialize(true, $sxe->addChild('Provenance'));
     }
     if (null !== $this->Questionnaire) {
         $this->Questionnaire->xmlSerialize(true, $sxe->addChild('Questionnaire'));
     }
     if (null !== $this->QuestionnaireResponse) {
         $this->QuestionnaireResponse->xmlSerialize(true, $sxe->addChild('QuestionnaireResponse'));
     }
     if (null !== $this->ReferralRequest) {
         $this->ReferralRequest->xmlSerialize(true, $sxe->addChild('ReferralRequest'));
     }
     if (null !== $this->RelatedPerson) {
         $this->RelatedPerson->xmlSerialize(true, $sxe->addChild('RelatedPerson'));
     }
     if (null !== $this->RiskAssessment) {
         $this->RiskAssessment->xmlSerialize(true, $sxe->addChild('RiskAssessment'));
     }
     if (null !== $this->Schedule) {
         $this->Schedule->xmlSerialize(true, $sxe->addChild('Schedule'));
     }
     if (null !== $this->SearchParameter) {
         $this->SearchParameter->xmlSerialize(true, $sxe->addChild('SearchParameter'));
     }
     if (null !== $this->Slot) {
         $this->Slot->xmlSerialize(true, $sxe->addChild('Slot'));
     }
     if (null !== $this->Specimen) {
         $this->Specimen->xmlSerialize(true, $sxe->addChild('Specimen'));
     }
     if (null !== $this->StructureDefinition) {
         $this->StructureDefinition->xmlSerialize(true, $sxe->addChild('StructureDefinition'));
     }
     if (null !== $this->Subscription) {
         $this->Subscription->xmlSerialize(true, $sxe->addChild('Subscription'));
     }
     if (null !== $this->Substance) {
         $this->Substance->xmlSerialize(true, $sxe->addChild('Substance'));
     }
     if (null !== $this->SupplyDelivery) {
         $this->SupplyDelivery->xmlSerialize(true, $sxe->addChild('SupplyDelivery'));
     }
     if (null !== $this->SupplyRequest) {
         $this->SupplyRequest->xmlSerialize(true, $sxe->addChild('SupplyRequest'));
     }
     if (null !== $this->TestScript) {
         $this->TestScript->xmlSerialize(true, $sxe->addChild('TestScript'));
     }
     if (null !== $this->ValueSet) {
         $this->ValueSet->xmlSerialize(true, $sxe->addChild('ValueSet'));
     }
     if (null !== $this->VisionPrescription) {
         $this->VisionPrescription->xmlSerialize(true, $sxe->addChild('VisionPrescription'));
     }
     if (null !== $this->Parameters) {
         $this->Parameters->xmlSerialize(true, $sxe->addChild('Parameters'));
     }
     if ($returnSXE) {
         return $sxe;
     }
     return $sxe->saveXML();
 }
 public function toggleSqlProfilerAction()
 {
     $localConfigFile = Mage::getBaseDir('etc') . DS . 'local.xml';
     $localConfigBackupFile = Mage::getBaseDir('etc') . DS . 'local-magneto.xml';
     $configContent = file_get_contents($localConfigFile);
     $xml = new SimpleXMLElement($configContent);
     $profiler = $xml->global->resources->default_setup->connection->profiler;
     if ((int) $xml->global->resources->default_setup->connection->profiler != 1) {
         $xml->global->resources->default_setup->connection->addChild('profiler', 1);
     } else {
         unset($xml->global->resources->default_setup->connection->profiler);
     }
     // backup config file
     if (file_put_contents($localConfigBackupFile, $configContent) === FALSE) {
         Mage::getSingleton('core/session')->addError("Operation aborted: couldn't create backup for config file");
         $this->_redirectReferer();
     }
     if ($xml->saveXML($localConfigFile) === FALSE) {
         Mage::getSingleton('core/session')->addError("Couldn't save {$localConfigFile}: check write permissions.");
         $this->_redirectReferer();
     }
     Mage::getSingleton('core/session')->addSuccess("SQL profiler status changed in local.xml");
     Mage::helper('debug')->cleanCache();
     $this->_redirectReferer();
 }
 /**
  * @param boolean $returnSXE
  * @param \SimpleXMLElement $sxe
  * @return string|\SimpleXMLElement
  */
 public function xmlSerialize($returnSXE = false, $sxe = null)
 {
     if (null === $sxe) {
         $sxe = new \SimpleXMLElement('<IdentityAssuranceLevel xmlns="http://hl7.org/fhir"></IdentityAssuranceLevel>');
     }
     $sxe->addAttribute('value', $this->value);
     if ($returnSXE) {
         return $sxe;
     }
     return $sxe->saveXML();
 }
 /**
  * @param boolean $returnSXE
  * @param \SimpleXMLElement $sxe
  * @return string|\SimpleXMLElement
  */
 public function xmlSerialize($returnSXE = false, $sxe = null)
 {
     if (null === $sxe) {
         $sxe = new \SimpleXMLElement('<Element xmlns="http://hl7.org/fhir"></Element>');
     }
     if (0 < count($this->extension)) {
         foreach ($this->extension as $extension) {
             $extension->xmlSerialize(true, $sxe->addChild('extension'));
         }
     }
     if (null !== $this->id) {
         $idElement = $sxe->addChild('id');
         $idElement->addAttribute('value', (string) $this->id);
     }
     if ($returnSXE) {
         return $sxe;
     }
     return $sxe->saveXML();
 }
Example #22
0
 /**
  * Converts a Zotero_Item object to a SimpleXMLElement Atom object
  *
  * Note: Increment Z_CONFIG::$CACHE_VERSION_ATOM_ENTRY when changing
  * the response.
  *
  * @param	object				$item		Zotero_Item object
  * @param	string				$content
  * @return	SimpleXMLElement					Item data as SimpleXML element
  */
 public static function convertItemToAtom(Zotero_Item $item, $queryParams, $permissions, $sharedData = null)
 {
     $t = microtime(true);
     // Uncached stuff or parts of the cache key
     $version = $item->version;
     $parent = $item->getSource();
     $isRegularItem = !$parent && $item->isRegularItem();
     $downloadDetails = $permissions->canAccess($item->libraryID, 'files') ? Zotero_Storage::getDownloadDetails($item) : false;
     if ($isRegularItem) {
         $numChildren = $permissions->canAccess($item->libraryID, 'notes') ? $item->numChildren() : $item->numAttachments();
     }
     // <id> changes based on group visibility in v1
     if ($queryParams['v'] < 2) {
         $id = Zotero_URI::getItemURI($item, false, true);
     } else {
         $id = Zotero_URI::getItemURI($item);
     }
     $libraryType = Zotero_Libraries::getType($item->libraryID);
     // Any query parameters that have an effect on the output
     // need to be added here
     $allowedParams = array('content', 'style', 'css', 'linkwrap');
     $cachedParams = Z_Array::filterKeys($queryParams, $allowedParams);
     $cacheVersion = 2;
     $cacheKey = "atomEntry_" . $item->libraryID . "/" . $item->id . "_" . md5($version . json_encode($cachedParams) . ($downloadDetails ? 'hasFile' : '') . ($libraryType == 'group' ? 'id' . $id : '')) . "_" . $queryParams['v'] . "_" . $cacheVersion . (isset(Z_CONFIG::$CACHE_VERSION_ATOM_ENTRY) ? "_" . Z_CONFIG::$CACHE_VERSION_ATOM_ENTRY : "") . (in_array('bib', $queryParams['content']) && isset(Z_CONFIG::$CACHE_VERSION_BIB) ? "_" . Z_CONFIG::$CACHE_VERSION_BIB : "");
     $xmlstr = Z_Core::$MC->get($cacheKey);
     if ($xmlstr) {
         try {
             // TEMP: Strip control characters
             $xmlstr = Zotero_Utilities::cleanString($xmlstr, true);
             $doc = new DOMDocument();
             $doc->loadXML($xmlstr);
             $xpath = new DOMXpath($doc);
             $xpath->registerNamespace('atom', Zotero_Atom::$nsAtom);
             $xpath->registerNamespace('zapi', Zotero_Atom::$nsZoteroAPI);
             $xpath->registerNamespace('xhtml', Zotero_Atom::$nsXHTML);
             // Make sure numChildren reflects the current permissions
             if ($isRegularItem) {
                 $xpath->query('/atom:entry/zapi:numChildren')->item(0)->nodeValue = $numChildren;
             }
             // To prevent PHP from messing with namespace declarations,
             // we have to extract, remove, and then add back <content>
             // subelements. Otherwise the subelements become, say,
             // <default:span xmlns="http://www.w3.org/1999/xhtml"> instead
             // of just <span xmlns="http://www.w3.org/1999/xhtml">, and
             // xmlns:default="http://www.w3.org/1999/xhtml" gets added to
             // the parent <entry>. While you might reasonably think that
             //
             // echo $xml->saveXML();
             //
             // and
             //
             // $xml = new SimpleXMLElement($xml->saveXML());
             // echo $xml->saveXML();
             //
             // would be identical, you would be wrong.
             $multiFormat = !!$xpath->query('/atom:entry/atom:content/zapi:subcontent')->length;
             $contentNodes = array();
             if ($multiFormat) {
                 $contentNodes = $xpath->query('/atom:entry/atom:content/zapi:subcontent');
             } else {
                 $contentNodes = $xpath->query('/atom:entry/atom:content');
             }
             foreach ($contentNodes as $contentNode) {
                 $contentParts = array();
                 while ($contentNode->hasChildNodes()) {
                     $contentParts[] = $doc->saveXML($contentNode->firstChild);
                     $contentNode->removeChild($contentNode->firstChild);
                 }
                 foreach ($contentParts as $part) {
                     if (!trim($part)) {
                         continue;
                     }
                     // Strip the namespace and add it back via SimpleXMLElement,
                     // which keeps it from being changed later
                     if (preg_match('%^<[^>]+xmlns="http://www.w3.org/1999/xhtml"%', $part)) {
                         $part = preg_replace('%^(<[^>]+)xmlns="http://www.w3.org/1999/xhtml"%', '$1', $part);
                         $html = new SimpleXMLElement($part);
                         $html['xmlns'] = "http://www.w3.org/1999/xhtml";
                         $subNode = dom_import_simplexml($html);
                         $importedNode = $doc->importNode($subNode, true);
                         $contentNode->appendChild($importedNode);
                     } else {
                         if (preg_match('%^<[^>]+xmlns="http://zotero.org/ns/transfer"%', $part)) {
                             $part = preg_replace('%^(<[^>]+)xmlns="http://zotero.org/ns/transfer"%', '$1', $part);
                             $html = new SimpleXMLElement($part);
                             $html['xmlns'] = "http://zotero.org/ns/transfer";
                             $subNode = dom_import_simplexml($html);
                             $importedNode = $doc->importNode($subNode, true);
                             $contentNode->appendChild($importedNode);
                         } else {
                             $docFrag = $doc->createDocumentFragment();
                             $docFrag->appendXML($part);
                             $contentNode->appendChild($docFrag);
                         }
                     }
                 }
             }
             $xml = simplexml_import_dom($doc);
             StatsD::timing("api.items.itemToAtom.cached", (microtime(true) - $t) * 1000);
             StatsD::increment("memcached.items.itemToAtom.hit");
             // Skip the cache every 10 times for now, to ensure cache sanity
             if (Z_Core::probability(10)) {
                 $xmlstr = $xml->saveXML();
             } else {
                 return $xml;
             }
         } catch (Exception $e) {
             error_log($xmlstr);
             error_log("WARNING: " . $e);
         }
     }
     $content = $queryParams['content'];
     $contentIsHTML = sizeOf($content) == 1 && $content[0] == 'html';
     $contentParamString = urlencode(implode(',', $content));
     $style = $queryParams['style'];
     $entry = '<?xml version="1.0" encoding="UTF-8"?>' . '<entry xmlns="' . Zotero_Atom::$nsAtom . '" xmlns:zapi="' . Zotero_Atom::$nsZoteroAPI . '"/>';
     $xml = new SimpleXMLElement($entry);
     $title = $item->getDisplayTitle(true);
     $title = $title ? $title : '[Untitled]';
     $xml->title = $title;
     $author = $xml->addChild('author');
     $createdByUserID = null;
     $lastModifiedByUserID = null;
     switch (Zotero_Libraries::getType($item->libraryID)) {
         case 'group':
             $createdByUserID = $item->createdByUserID;
             // Used for zapi:lastModifiedByUser below
             $lastModifiedByUserID = $item->lastModifiedByUserID;
             break;
     }
     if ($createdByUserID) {
         $author->name = Zotero_Users::getUsername($createdByUserID);
         $author->uri = Zotero_URI::getUserURI($createdByUserID);
     } else {
         $author->name = Zotero_Libraries::getName($item->libraryID);
         $author->uri = Zotero_URI::getLibraryURI($item->libraryID);
     }
     $xml->id = $id;
     $xml->published = Zotero_Date::sqlToISO8601($item->dateAdded);
     $xml->updated = Zotero_Date::sqlToISO8601($item->dateModified);
     $link = $xml->addChild("link");
     $link['rel'] = "self";
     $link['type'] = "application/atom+xml";
     $href = Zotero_API::getItemURI($item);
     if (!$contentIsHTML) {
         $href .= "?content={$contentParamString}";
     }
     $link['href'] = $href;
     if ($parent) {
         // TODO: handle group items?
         $parentItem = Zotero_Items::get($item->libraryID, $parent);
         $link = $xml->addChild("link");
         $link['rel'] = "up";
         $link['type'] = "application/atom+xml";
         $href = Zotero_API::getItemURI($parentItem);
         if (!$contentIsHTML) {
             $href .= "?content={$contentParamString}";
         }
         $link['href'] = $href;
     }
     $link = $xml->addChild('link');
     $link['rel'] = 'alternate';
     $link['type'] = 'text/html';
     $link['href'] = Zotero_URI::getItemURI($item, true);
     // If appropriate permissions and the file is stored in ZFS, get file request link
     if ($downloadDetails) {
         $details = $downloadDetails;
         $link = $xml->addChild('link');
         $link['rel'] = 'enclosure';
         $type = $item->attachmentMIMEType;
         if ($type) {
             $link['type'] = $type;
         }
         $link['href'] = $details['url'];
         if (!empty($details['filename'])) {
             $link['title'] = $details['filename'];
         }
         if (isset($details['size'])) {
             $link['length'] = $details['size'];
         }
     }
     $xml->addChild('zapi:key', $item->key, Zotero_Atom::$nsZoteroAPI);
     $xml->addChild('zapi:version', $item->version, Zotero_Atom::$nsZoteroAPI);
     if ($lastModifiedByUserID) {
         $xml->addChild('zapi:lastModifiedByUser', Zotero_Users::getUsername($lastModifiedByUserID), Zotero_Atom::$nsZoteroAPI);
     }
     $xml->addChild('zapi:itemType', Zotero_ItemTypes::getName($item->itemTypeID), Zotero_Atom::$nsZoteroAPI);
     if ($isRegularItem) {
         $val = $item->creatorSummary;
         if ($val !== '') {
             $xml->addChild('zapi:creatorSummary', htmlspecialchars($val), Zotero_Atom::$nsZoteroAPI);
         }
         $val = $item->getField('date', true, true, true);
         if ($val !== '') {
             if ($queryParams['v'] < 3) {
                 $val = substr($val, 0, 4);
                 if ($val !== '0000') {
                     $xml->addChild('zapi:year', $val, Zotero_Atom::$nsZoteroAPI);
                 }
             } else {
                 $sqlDate = Zotero_Date::multipartToSQL($val);
                 if (substr($sqlDate, 0, 4) !== '0000') {
                     $xml->addChild('zapi:parsedDate', Zotero_Date::sqlToISO8601($sqlDate), Zotero_Atom::$nsZoteroAPI);
                 }
             }
         }
         $xml->addChild('zapi:numChildren', $numChildren, Zotero_Atom::$nsZoteroAPI);
     }
     if ($queryParams['v'] < 3) {
         $xml->addChild('zapi:numTags', $item->numTags(), Zotero_Atom::$nsZoteroAPI);
     }
     $xml->content = '';
     //
     // DOM XML from here on out
     //
     $contentNode = dom_import_simplexml($xml->content);
     $domDoc = $contentNode->ownerDocument;
     $multiFormat = sizeOf($content) > 1;
     // Create a root XML document for multi-format responses
     if ($multiFormat) {
         $contentNode->setAttribute('type', 'application/xml');
         /*$multicontent = $domDoc->createElementNS(
         			Zotero_Atom::$nsZoteroAPI, 'multicontent'
         		);
         		$contentNode->appendChild($multicontent);*/
     }
     foreach ($content as $type) {
         // Set the target to either the main <content>
         // or a <multicontent> <content>
         if (!$multiFormat) {
             $target = $contentNode;
         } else {
             $target = $domDoc->createElementNS(Zotero_Atom::$nsZoteroAPI, 'subcontent');
             $contentNode->appendChild($target);
         }
         $target->setAttributeNS(Zotero_Atom::$nsZoteroAPI, "zapi:type", $type);
         if ($type == 'html') {
             if (!$multiFormat) {
                 $target->setAttribute('type', 'xhtml');
             }
             $div = $domDoc->createElementNS(Zotero_Atom::$nsXHTML, 'div');
             $target->appendChild($div);
             $html = $item->toHTML(true);
             $subNode = dom_import_simplexml($html);
             $importedNode = $domDoc->importNode($subNode, true);
             $div->appendChild($importedNode);
         } else {
             if ($type == 'citation') {
                 if (!$multiFormat) {
                     $target->setAttribute('type', 'xhtml');
                 }
                 if (isset($sharedData[$type][$item->libraryID . "/" . $item->key])) {
                     $html = $sharedData[$type][$item->libraryID . "/" . $item->key];
                 } else {
                     if ($sharedData !== null) {
                         //error_log("Citation not found in sharedData -- retrieving individually");
                     }
                     $html = Zotero_Cite::getCitationFromCiteServer($item, $queryParams);
                 }
                 $html = new SimpleXMLElement($html);
                 $html['xmlns'] = Zotero_Atom::$nsXHTML;
                 $subNode = dom_import_simplexml($html);
                 $importedNode = $domDoc->importNode($subNode, true);
                 $target->appendChild($importedNode);
             } else {
                 if ($type == 'bib') {
                     if (!$multiFormat) {
                         $target->setAttribute('type', 'xhtml');
                     }
                     if (isset($sharedData[$type][$item->libraryID . "/" . $item->key])) {
                         $html = $sharedData[$type][$item->libraryID . "/" . $item->key];
                     } else {
                         if ($sharedData !== null) {
                             //error_log("Bibliography not found in sharedData -- retrieving individually");
                         }
                         $html = Zotero_Cite::getBibliographyFromCitationServer(array($item), $queryParams);
                     }
                     $html = new SimpleXMLElement($html);
                     $html['xmlns'] = Zotero_Atom::$nsXHTML;
                     $subNode = dom_import_simplexml($html);
                     $importedNode = $domDoc->importNode($subNode, true);
                     $target->appendChild($importedNode);
                 } else {
                     if ($type == 'json') {
                         if ($queryParams['v'] < 2) {
                             $target->setAttributeNS(Zotero_Atom::$nsZoteroAPI, "zapi:etag", $item->etag);
                         }
                         $textNode = $domDoc->createTextNode($item->toJSON(false, $queryParams, true));
                         $target->appendChild($textNode);
                     } else {
                         if ($type == 'csljson') {
                             $arr = $item->toCSLItem();
                             $json = Zotero_Utilities::formatJSON($arr);
                             $textNode = $domDoc->createTextNode($json);
                             $target->appendChild($textNode);
                         } else {
                             if (in_array($type, Zotero_Translate::$exportFormats)) {
                                 $export = Zotero_Translate::doExport(array($item), $type);
                                 $target->setAttribute('type', $export['mimeType']);
                                 // Insert XML into document
                                 if (preg_match('/\\+xml$/', $export['mimeType'])) {
                                     // Strip prolog
                                     $body = preg_replace('/^<\\?xml.+\\n/', "", $export['body']);
                                     $subNode = $domDoc->createDocumentFragment();
                                     $subNode->appendXML($body);
                                     $target->appendChild($subNode);
                                 } else {
                                     $textNode = $domDoc->createTextNode($export['body']);
                                     $target->appendChild($textNode);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // TEMP
     if ($xmlstr) {
         $uncached = $xml->saveXML();
         if ($xmlstr != $uncached) {
             $uncached = str_replace('<zapi:year></zapi:year>', '<zapi:year/>', $uncached);
             $uncached = str_replace('<content zapi:type="none"></content>', '<content zapi:type="none"/>', $uncached);
             $uncached = str_replace('<zapi:subcontent zapi:type="coins" type="text/html"></zapi:subcontent>', '<zapi:subcontent zapi:type="coins" type="text/html"/>', $uncached);
             $uncached = str_replace('<title></title>', '<title/>', $uncached);
             $uncached = str_replace('<note></note>', '<note/>', $uncached);
             $uncached = str_replace('<path></path>', '<path/>', $uncached);
             $uncached = str_replace('<td></td>', '<td/>', $uncached);
             if ($xmlstr != $uncached) {
                 error_log("Cached Atom item entry does not match");
                 error_log("  Cached: " . $xmlstr);
                 error_log("Uncached: " . $uncached);
                 Z_Core::$MC->set($cacheKey, $uncached, 3600);
                 // 1 hour for now
             }
         }
     } else {
         $xmlstr = $xml->saveXML();
         Z_Core::$MC->set($cacheKey, $xmlstr, 3600);
         // 1 hour for now
         StatsD::timing("api.items.itemToAtom.uncached", (microtime(true) - $t) * 1000);
         StatsD::increment("memcached.items.itemToAtom.miss");
     }
     return $xml;
 }
 /**
  * @param boolean $returnSXE
  * @param \SimpleXMLElement $sxe
  * @return string|\SimpleXMLElement
  */
 public function xmlSerialize($returnSXE = false, $sxe = null)
 {
     if (null === $sxe) {
         $sxe = new \SimpleXMLElement('<CarePlanRelationship xmlns="http://hl7.org/fhir"></CarePlanRelationship>');
     }
     $sxe->addAttribute('value', $this->value);
     if ($returnSXE) {
         return $sxe;
     }
     return $sxe->saveXML();
 }
 * @author Gassan Idriss <gidriss@mivamerchant.com>
*/
require_once dirname(__FILE__) . '/functions.php';
if (!isset($argv[1]) || !isset($argv[2])) {
    print_line(PHP_EOL . 'Usage:');
    print_line("\t" . 'php ' . $_SERVER['SCRIPT_NAME'] . ' /path/to/fragment.xml ClassName [/out/dir]');
    print_line("\t" . 'php ' . $_SERVER['SCRIPT_NAME'] . ' "<XML></XML>" ClassName [/out/dir]', true);
}
$sourceXml = $argv[1];
$targetClass = $argv[2];
$targetDir = isset($argv[3]) && is_dir($argv[3]) ? $argv[3] : dirname(__FILE__);
if (!is_dir($targetDir)) {
    print_line(spritnf('Dir %s Not Found', $targetDir), true);
}
if (file_exists($sourceXml)) {
    $xml = new \SimpleXMLElement(file_get_contents($sourceXml));
} else {
    $xml = new \SimpleXMLElement($sourceXml);
}
$setters = '';
$assertions = '';
foreach ($xml->children() as $child) {
    print_line($child->getName());
    $name = $child->getName();
    $camelName = $name;
    $camelName[0] = strtolower($camelName[0]);
    $setters .= generate_setter($name, $camelName);
    $assertions .= generate_assertion($name, $camelName);
}
$template = replace_template(dirname(__FILE__) . '/generate_class_from_xml_fragment_class_template.php.template', array('{name}' => $targetClass, '{setters}' => $setters, '{assertions}' => $assertions, '{expected_xml}' => $xml->saveXML(), '{xml_assertions}' => null));
file_put_contents($targetDir . '/' . $targetClass . 'Test.php', $template);
Example #25
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $workplanExtension = \Workplan::getInstance();
     $workplanExtension->addJS();
     $workplanExtension->addJS($fileName = 'jsgantt.js');
     $workplanExtension->addCSS($fileName = 'jsgantt.css');
     $user = $GLOBALS["STEAM"]->get_current_steam_user();
     $portal = \lms_portal::get_instance();
     $objectID = $this->params[0];
     $workplanContainer = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $objectID);
     $xmlfile = $workplanContainer->get_inventory_filtered(array(array("+", "class", CLASS_DOCUMENT)));
     $createContainer = 0;
     // check if user submitted create milestone or create task form
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (isset($_POST["new_milestone"])) {
             $createContainer = 1;
         } else {
             if (isset($_POST["new_task"])) {
                 $createContainer = 2;
             }
         }
     }
     // create new milestone or task
     if ($createContainer != 0) {
         $xmltree = new \SimpleXMLElement($xmlfile[0]->get_content());
         if ($createContainer == 1) {
             $xml = $xmltree->addChild("milestone");
             $newName = $_POST["milestonename"];
             $newStart = $_POST["milestonedate"];
             $newStart = mktime(0, 0, 0, substr($newStart, 3, 2), substr($newStart, 0, 2), substr($newStart, 6, 4));
             $newEnd = $_POST["milestonedate"];
             $newEnd = mktime(0, 0, 0, substr($newEnd, 3, 2), substr($newEnd, 0, 2), substr($newEnd, 6, 4));
             if (strlen($_POST["milestoneduration"]) > 0) {
                 $newDuration = $_POST["milestoneduration"];
             } else {
                 $newDuration = -1;
             }
             if (strlen($_POST["milestonedepends"]) > 0) {
                 $newDepends = $_POST["milestonedepends"];
             } else {
                 $newDepends = -1;
             }
             $newUsers = "";
             if (isset($_POST["milestoneusers"])) {
                 for ($count = 0; $count < count($_POST["milestoneusers"]); $count++) {
                     $newUsers = $newUsers . $_POST["milestoneusers"][$count] . ",";
                 }
                 $newUsers = substr($newUsers, 0, strlen($newUsers) - 1);
             }
             $portal->set_confirmation("Meilenstein " . $newName . " wurde erfolgreich erstellt.");
         } else {
             $xml = $xmltree->addChild("task");
             $newName = $_POST["taskname"];
             $newStart = $_POST["taskstart"];
             $newStart = mktime(0, 0, 0, substr($newStart, 3, 2), substr($newStart, 0, 2), substr($newStart, 6, 4));
             $newEnd = $_POST["taskend"];
             $newEnd = mktime(0, 0, 0, substr($newEnd, 3, 2), substr($newEnd, 0, 2), substr($newEnd, 6, 4));
             if (strlen($_POST["taskduration"]) > 0) {
                 $newDuration = $_POST["taskduration"];
             } else {
                 $newDuration = -1;
             }
             if (strlen($_POST["taskdepends"]) > 0) {
                 $newDepends = $_POST["taskdepends"];
             } else {
                 $newDepends = -1;
             }
             $newUsers = "";
             if (isset($_POST["taskusers"])) {
                 for ($count = 0; $count < count($_POST["taskusers"]); $count++) {
                     $newUsers = $newUsers . $_POST["taskusers"][$count] . ",";
                 }
                 $newUsers = substr($newUsers, 0, strlen($newUsers) - 1);
             }
             $portal->set_confirmation("Vorgang " . $newName . " wurde erfolgreich erstellt.");
         }
         $newContainer = \steam_factory::create_container($GLOBALS["STEAM"]->get_id(), $newName, $workplanContainer);
         $xml->addChild("name", $newName);
         $xml->addChild("oid", $newContainer->get_id());
         $newContainer->set_attribute("WORKPLAN_START", $newStart);
         $xml->addChild("start", $newStart);
         $newContainer->set_attribute("WORKPLAN_END", $newEnd);
         $xml->addChild("end", $newEnd);
         $xml->addChild("duration", $newDuration);
         $newContainer->set_attribute("WORKPLAN_DURATION", $newDuration);
         $xml->addChild("depends", $newDepends);
         $newContainer->set_attribute("WORKPLAN_DEPENDS", $newDepends);
         $newContainer->set_attribute("WORKPLAN_USERS", $newUsers);
         $xml->addChild("users", $newUsers);
         $xmlfile[0]->set_content($xmltree->saveXML());
     }
     if (is_object($workplanContainer) && $workplanContainer instanceof \steam_room) {
         // if user has the required rights display actionbar
         if ($user->get_id() == $workplanContainer->get_creator()->get_id() || in_array("WORKPLAN_" . $user->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) {
             $content = $workplanExtension->loadTemplate("workplan_ganttview.template.html");
             $content->setCurrentBlock("BLOCK_CONFIRMATION");
             $content->setVariable("CONFIRMATION_TEXT", "NONE");
             $content->parse("BLOCK_CONFIRMATION");
             $content->setCurrentBlock("BLOCK_WORKPLAN_GANTT_ACTIONBAR");
             $content->setVariable("LABEL_NEW_SNAPSHOT", "Snapshot erstellen");
             $content->setVariable("WORKPLAN_ID", $objectID);
             $content->setVariable("LABEL_NEW_MILESTONE", "Neuer Meilenstein");
             $content->setVariable("LABEL_NEW_TASK", "Neuer Vorgang");
             $content->parse("BLOCK_WORKPLAN_GANTT_ACTIONBAR");
             $actionBar = new \Widgets\RawHtml();
             $actionBar->setHtml($content->get());
             $frameResponseObject->addWidget($actionBar);
         }
         $tabBar = new \Widgets\TabBar();
         $tabBar->setTabs(array(array("name" => "Überblick", "link" => $this->getExtension()->getExtensionUrl() . "overview/" . $objectID), array("name" => "Tabelle", "link" => $this->getExtension()->getExtensionUrl() . "listView/" . $objectID), array("name" => "Gantt-Diagramm", "link" => $this->getExtension()->getExtensionUrl() . "ganttView/" . $objectID), array("name" => "Mitarbeiter", "link" => $this->getExtension()->getExtensionUrl() . "users/" . $objectID), array("name" => "Snapshots", "link" => $this->getExtension()->getExtensionUrl() . "snapshots/" . $objectID)));
         $tabBar->setActiveTab(2);
         $frameResponseObject->addWidget($tabBar);
         $xml = simplexml_load_string($xmlfile[0]->get_content());
         $helpToArray = $xml->children();
         $list = array();
         for ($counter = 0; $counter < count($helpToArray); $counter++) {
             array_push($list, $helpToArray[$counter]);
         }
         usort($list, 'sort_xmllist');
         $content = $workplanExtension->loadTemplate("workplan_ganttview.template.html");
         if (count($list) == 0) {
             $content->setCurrentBlock("BLOCK_WORKPLAN_GANTT_EMPTY");
             $content->setVariable("WORKPLAN_GANTT_EMPTY", "Keine Meilensteine oder Vorgänge zu diesem Projektplan vorhanden.");
             $content->parse("BLOCK_WORKPLAN_GANTT_EMPTY");
         }
         // change the format of the information so it can be displayed via javascript/jsgantt
         $oids = "[";
         $tasks = "[";
         $starts = "[";
         $ends = "[";
         $dependslist = "[";
         $milestones = "[";
         for ($counter = 0; $counter < count($list); $counter++) {
             $name = $list[$counter]->name;
             $tasks = $tasks . $name . ",";
             $starts = $starts . (int) $list[$counter]->start . ",";
             $ends = $ends . (int) $list[$counter]->end . ",";
             $oids = $oids . $list[$counter]->oid . ",";
             $depends = $list[$counter]->depends;
             if ($depends == -1) {
                 $dependslist = $dependslist . "-1,";
             } else {
                 $dependslist = $dependslist . $depends . ",";
             }
             if ($list[$counter]->getName() == "milestone") {
                 $milestones = $milestones . "1,";
             } else {
                 $milestones = $milestones . "0,";
             }
         }
         if (count($list) > 0) {
             $oids = substr($oids, 0, strlen($oids) - 1) . "]";
             $tasks = substr($tasks, 0, strlen($tasks) - 1) . "]";
             $starts = substr($starts, 0, strlen($starts) - 1) . "]";
             $ends = substr($ends, 0, strlen($ends) - 1) . "]";
             $dependslist = substr($dependslist, 0, strlen($dependslist) - 1) . "]";
             $milestones = substr($milestones, 0, strlen($milestones) - 1) . "]";
         } else {
             $oids = $oids . "]";
             $tasks = $tasks . "]";
             $starts = $starts . "]";
             $ends = $ends . "]";
             $dependslist = $dependslist . "]";
             $milestones = $milestones . "]";
         }
         $content->setCurrentBlock("BLOCK_GANTT_CHART");
         $content->setVariable("GANTT_DIV", "ganttchartdiv");
         $content->setVariable("WORKPLAN_GANTT_TASKS", $tasks);
         $content->setVariable("WORKPLAN_GANTT_OID", $oids);
         $content->setVariable("WORKPLAN_GANTT_MILESTONE", $milestones);
         $content->setVariable("WORKPLAN_GANTT_DEPENDS", $dependslist);
         $content->setVariable("WORKPLAN_GANTT_START", $starts);
         $content->setVariable("WORKPLAN_GANTT_END", $ends);
         $content->parse("BLOCK_GANTT_CHART");
         $content->setCurrentBlock("BLOCK_WORKPLAN_LIST_FORMULAR");
         $content->setVariable("LABEL_NEW_MILESTONE", "Meilenstein hinzufügen");
         $content->setVariable("LABEL_NEW_TASK", "Vorgang hinzufügen");
         $content->setVariable("NAME_LABEL", "Name:*");
         $content->setVariable("START_LABEL", "Beginn:*");
         $content->setVariable("END_LABEL", "Ende:*");
         $content->setVariable("DATE_LABEL", "Datum:*");
         $content->setVariable("DURATION_LABEL", "Dauer:");
         $content->setVariable("DEPENDS_LABEL", "Abhängigkeit:");
         $content->setVariable("USERS_LABEL", "Mitarbeiter:");
         $groupID = 0;
         if (in_array("WORKPLAN_GROUP", $workplanContainer->get_attribute_names())) {
             $groupID = $workplanContainer->get_attribute("WORKPLAN_GROUP");
         }
         if ($groupID == 0) {
             $content->setCurrentBlock("BEGIN BLOCK_USER_OPTION_MILESTONE");
             $content->setVariable("USER_ID", $user->get_id());
             $content->setVariable("USER_NAME", $user->get_full_name());
             $content->parse("BLOCK_USER_OPTION_MILESTONE");
             $content->setCurrentBlock("BEGIN BLOCK_USER_OPTION_TASK");
             $content->setVariable("USER_ID", $user->get_id());
             $content->setVariable("USER_NAME", $user->get_full_name());
             if (in_array("WORKPLAN_" . $user->get_id() . "_RESSOURCE", $workplanContainer->get_attribute_names())) {
                 $content->setVariable("USER_RESSOURCE", $workplanContainer->get_attribute("WORKPLAN_" . $user->get_id() . "_RESSOURCE"));
             } else {
                 $content->setVariable("USER_RESSOURCE", 0);
             }
             $content->parse("BLOCK_USER_OPTION_TASK");
         } else {
             $groupObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $groupID);
             $members = $groupObject->get_members();
             for ($count = 0; $count < count($members); $count++) {
                 $currentMember = $members[$count];
                 $content->setCurrentBlock("BEGIN BLOCK_USER_OPTION_MILESTONE");
                 $content->setVariable("USER_ID", $currentMember->get_id());
                 $content->setVariable("USER_NAME", $currentMember->get_full_name());
                 $content->parse("BLOCK_USER_OPTION_MILESTONE");
                 $content->setCurrentBlock("BEGIN BLOCK_USER_OPTION_TASK");
                 $content->setVariable("USER_ID", $currentMember->get_id());
                 $content->setVariable("USER_NAME", $currentMember->get_full_name());
                 if (in_array("WORKPLAN_" . $currentMember->get_id() . "_RESSOURCE", $workplanContainer->get_attribute_names())) {
                     $content->setVariable("USER_RESSOURCE", $workplanContainer->get_attribute("WORKPLAN_" . $currentMember->get_id() . "_RESSOURCE"));
                 } else {
                     $content->setVariable("USER_RESSOURCE", 0);
                 }
                 $content->parse("BLOCK_USER_OPTION_TASK");
             }
         }
         $content->setCurrentBlock("BLOCK_LIST_MILESTONE_DEPENDS");
         $content->setVariable("DEPENDS_OID", "-1");
         $content->setVariable("DEPENDS_NAME", "Keine Abhängigkeit");
         $content->parse("BLOCK_LIST_MILESTONE_DEPENDS");
         $content->setCurrentBlock("BLOCK_LIST_TASK_DEPENDS");
         $content->setVariable("DEPENDS_OID", "-1");
         $content->setVariable("DEPENDS_NAME", "Keine Abhängigkeit");
         $content->parse("BLOCK_LIST_TASK_DEPENDS");
         for ($count = 0; $count < count($list); $count++) {
             if ($list[$count]->getName() == 'task') {
                 $content->setCurrentBlock("BLOCK_LIST_MILESTONE_DEPENDS");
                 $content->setVariable("DEPENDS_OID", $list[$count]->oid);
                 $content->setVariable("DEPENDS_NAME", $list[$count]->name);
                 $content->parse("BLOCK_LIST_MILESTONE_DEPENDS");
                 $content->setCurrentBlock("BLOCK_LIST_TASK_DEPENDS");
                 $content->setVariable("DEPENDS_OID", $list[$count]->oid);
                 $content->setVariable("DEPENDS_NAME", $list[$count]->name);
                 $content->parse("BLOCK_LIST_TASK_DEPENDS");
             }
         }
         $content->setVariable("LABEL_BACK", "Ausblenden");
         $content->setVariable("LABEL_ADD", "Hinzufügen");
         $content->setVariable("WORKPLAN_ID", $this->params[0]);
         $content->parse("BLOCK_WORKPLAN_LIST_FORMULAR");
         $rawWidget = new \Widgets\RawHtml();
         $rawWidget->setHtml($content->get());
         $frameResponseObject->setTitle("Projektplan: " . $workplanContainer->get_name());
         $frameResponseObject->setHeadline(array(array("link" => $this->getExtension()->getExtensionUrl(), "name" => "Projektplanverwaltung"), array("", "name" => $workplanContainer->get_name())));
         $frameResponseObject->addWidget($rawWidget);
         return $frameResponseObject;
     }
 }
 /**
  * @param boolean $returnSXE
  * @param \SimpleXMLElement $sxe
  * @return string|\SimpleXMLElement
  */
 public function xmlSerialize($returnSXE = false, $sxe = null)
 {
     if (null === $sxe) {
         $sxe = new \SimpleXMLElement('<Resource xmlns="http://hl7.org/fhir"></Resource>');
     }
     if (null !== $this->id) {
         $this->id->xmlSerialize(true, $sxe->addChild('id'));
     }
     if (null !== $this->meta) {
         $this->meta->xmlSerialize(true, $sxe->addChild('meta'));
     }
     if (null !== $this->implicitRules) {
         $this->implicitRules->xmlSerialize(true, $sxe->addChild('implicitRules'));
     }
     if (null !== $this->language) {
         $this->language->xmlSerialize(true, $sxe->addChild('language'));
     }
     if ($returnSXE) {
         return $sxe;
     }
     return $sxe->saveXML();
 }
Example #27
0
 /**
  * add/edit seller
  * @param array $dataArray
  * @return string
  */
 public function AddEditSeller(array $dataArray)
 {
     if (!$this->WS()) {
         return null;
     }
     try {
         $xml = new SimpleXMLElement("<Seller></Seller>");
         if (isset($dataArray['Id'])) {
             $xml->addAttribute('Id', $dataArray['Id']);
             unset($dataArray['Id']);
         }
         foreach ($dataArray as $name => $value) {
             $xml->addChild($name, $value);
         }
         $xmlString = $xml->saveXML();
         dump($xmlString);
         $tempFileName = md5(time() + $_SERVER['HTTP_USER_AGENT'] + $_SERVER['REMOTE_ADDR']) . '.zip';
         $zip = new ZipArchive();
         $res = $zip->open($tempFileName, ZipArchive::CREATE);
         $zip->addFromString('seller.xml', $xmlString);
         $zip->close();
         $xmlZip = file_get_contents($tempFileName);
         unlink($tempFileName);
         $params = array('sid' => $this->_sid, 'xmlZip' => $xmlZip);
         $result = $this->WS()->getSC()->__soapCall("AddEditSeller", array($params));
         return $result;
     } catch (Exception $ex) {
         Errors::LogError("WebService:AddEditSeller", $ex->getMessage());
     }
 }
 /**
  * Set Xml for the object.
  *
  * @param SimpleXMLElement $xml OSM XML
  *
  * @return Services_OpenStreetMap_Objects
  */
 public function setXml(SimpleXMLElement $xml)
 {
     $this->xml = $xml->saveXML();
     $objs = $xml->xpath('//' . $this->getType());
     foreach ($objs as $obj) {
         $this->objects[] = $obj->saveXML();
     }
     return $this;
 }
Example #29
0
 /**
  * Set request
  *
  * $request may be any of:
  * - DOMDocument; if so, then cast to XML
  * - DOMNode; if so, then grab owner document and cast to XML
  * - SimpleXMLElement; if so, then cast to XML
  * - stdClass; if so, calls __toString() and verifies XML
  * - string; if so, verifies XML
  *
  * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
  * @return Zend_Soap_Server
  */
 private function _setRequest($request)
 {
     if ($request instanceof DOMDocument) {
         $xml = $request->saveXML();
     } elseif ($request instanceof DOMNode) {
         $xml = $request->ownerDocument->saveXML();
     } elseif ($request instanceof SimpleXMLElement) {
         $xml = $request->asXML();
     } elseif (is_object($request) || is_string($request)) {
         if (is_object($request)) {
             $xml = $request->__toString();
         } else {
             $xml = $request;
         }
         $dom = new DOMDocument();
         if (strlen($xml) == 0 || !$dom->loadXML($xml)) {
             throw new Zend_Soap_Server_Exception('Invalid XML');
         }
     }
     $this->_request = $xml;
     return $this;
 }
 /**
  * Set request
  *
  * $request may be any of:
  * - DOMDocument; if so, then cast to XML
  * - DOMNode; if so, then grab owner document and cast to XML
  * - SimpleXMLElement; if so, then cast to XML
  * - stdClass; if so, calls __toString() and verifies XML
  * - string; if so, verifies XML
  *
  * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
  * @return Zend_Soap_Server
  */
 protected function _setRequest($request)
 {
     if ($request instanceof DOMDocument) {
         $xml = $request->saveXML();
     } elseif ($request instanceof DOMNode) {
         $xml = $request->ownerDocument->saveXML();
     } elseif ($request instanceof SimpleXMLElement) {
         $xml = $request->asXML();
     } elseif (is_object($request) || is_string($request)) {
         if (is_object($request)) {
             $xml = $request->__toString();
         } else {
             $xml = $request;
         }
         $dom = new DOMDocument();
         try {
             if (strlen($xml) == 0 || !($dom = Zend_Xml_Security::scan($xml, $dom))) {
                 #require_once 'Zend/Soap/Server/Exception.php';
                 throw new Zend_Soap_Server_Exception('Invalid XML');
             }
         } catch (Zend_Xml_Exception $e) {
             #require_once 'Zend/Soap/Server/Exception.php';
             throw new Zend_Soap_Server_Exception($e->getMessage());
         }
     }
     $this->_request = $xml;
     return $this;
 }