public function test() { $xml = '<root><child1 /><child2 /><child3 /></root>'; $node = simpledom_load_string($xml); $this->assertSame('SimpleDOM', get_class($node), 'Wrong class returned'); $this->assertXmlStringEqualsXmlString($xml, $node->asXML()); }
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); $basPath = JURI::base(false) . 'components/com_bookingforconnector/assets/'; $this->document->addScript('components/com_bookingforconnector/assets/js/royalslider/jquery.royalslider.min.js'); $this->document->addStyleSheet('components/com_bookingforconnector/assets/js/royalslider/royalslider.css'); $this->document->addStyleSheet('components/com_bookingforconnector/assets/js/royalslider/skins/universal/rs-universal.css'); $resource = $this->item; $images = array(); try { // $imageData = new SimpleXmlElement($resource->PlanimetryData); if (!empty($resource->PlanimetryData)) { if (strpos($resource->PlanimetryData, '<xmlhashtable>') !== false) { $imageData = simpledom_load_string($resource->PlanimetryData); if (!empty($imageData)) { // valore xml //$nodes = $imageData; if (strpos($resource->ImageData, 'order') !== false) { $nodes = $imageData->sortedXPath('//image', '@order'); //dati ordinati per "order" } else { $nodes = $imageData; } } foreach ($nodes as $image) { $images[] = $image; } } else { foreach (explode(',', $resource->PlanimetryData) as $image) { $images[] = $image;
$jdate = new JDate($checkInDate); // 3:20 PM, December 1st, 2012 $checkInDateLabel = sprintf(JTEXT::_('COM_BOOKINGFORCONNECTOR_MERCHANTS_VIEW_MERCHANTDETAILS_RATING_CHECKINDATE_LABEL'), $jdate->format('F Y')); } $location = ""; if ($rating->City != "") { $location .= $rating->City . ", "; } $location .= $rating->Nation; $t = BFCHelper::convertTotal($rating->Total); //Reply=<risposte><risposta><![CDATA[Test risposta]]></risposta></risposte> $reply = ""; $replydateLabel = ""; if (!empty($rating->Reply)) { if (strpos($rating->Reply, '<replies>') !== false) { $replies = simpledom_load_string($rating->Reply); $reply = $replies->reply[0]; $replydate = $replies->reply[0]["date"]; if (!empty($replydate)) { // $jdatereply = new JDate(strtotime($replydate),2); // 3:20 PM, December 1st, 2012 $jdatereply = DateTime::createFromFormat('Ymd', $replydate); $replydateLabel = sprintf(JTEXT::_('COM_BOOKINGFORCONNECTOR_MERCHANTS_VIEW_MERCHANTDETAILS_RATING_DATEREPLY_LABEL'), $jdatereply->format('d/m/Y')); } } else { $reply = $rating->Reply; } } ?> <div class="<?php echo COM_BOOKINGFORCONNECTOR_BOOTSTRAP_ROW; ?>
protected function _createConfigXml($schemaPath) { $schemaPath = str_replace(array_keys($this->_schemas), array_values($this->_schemas), $schemaPath); return simpledom_load_string('<?xml version="1.0"?> <config xmlns:xsi="' . $this->_schemas['@XSI'] . '" xsi:noNamespaceSchemaLocation="' . $schemaPath . '"> </config>'); }
/** * @param string $schemaPath * @param string $rootTagName * @return SimpleDOM */ protected function _createConfigXml($schemaPath, $rootTagName = 'config') { $schemaPath = str_replace(array_keys($this->_schemas), array_values($this->_schemas), $schemaPath); return simpledom_load_string('<?xml version="1.0" encoding="UTF-8"?> <' . $rootTagName . ' xmlns:xsi="' . $this->_schemas['@XSI'] . '" xsi:noNamespaceSchemaLocation="' . $schemaPath . '"> </' . $rootTagName . '>'); }
/** * @param string $schemaPath * @param string $rootTagName * @return SimpleDOM */ public function createConfigXml($schemaPath, $rootTagName = 'config') { return simpledom_load_string('<?xml version="1.0" encoding="UTF-8"?> <' . $rootTagName . ' xmlns:xsi="' . self::XSI . '" xsi:noNamespaceSchemaLocation="' . $schemaPath . '"> </' . $rootTagName . '>'); }
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); JHTML::_('behavior.mootools'); // this will make sure mootools loads first so we can load jquery with noconflict $basPath = JURI::base(false) . 'components/com_bookingforconnector/assets/'; $this->document->addScript('components/com_bookingforconnector/assets/js/royalslider/jquery.royalslider.min.js'); $this->document->addStyleSheet('components/com_bookingforconnector/assets/js/royalslider/royalslider.css'); $this->document->addStyleSheet('components/com_bookingforconnector/assets/js/royalslider/skins/universal/rs-universal.css'); $resource = $this->item->OnSellUnit; $images = array(); try { // $imageData = new SimpleXmlElement($resource->VideoData); if (!empty($resource->VideoData)) { $imageData = simpledom_load_string($resource->VideoData); $nodes = $imageData->sortedXPath('//video', '@order'); //dati ordinati per "order" foreach ($nodes as $image) { $images[] = $image; } } } catch (Exception $e) { // suppressing any errors } ?> <?php if (count($images) > 0) { ?> <div class="royalSlider rsUni" id="resourceVideogallery">
function display($tpl = NULL, $preparecontent = false) { $document = JFactory::getDocument(); $language = $document->getLanguage(); // load scripts $document->addScript('components/com_bookingforconnector/assets/js/jquery.validate.min.js'); $document->addScript('components/com_bookingforconnector/assets/js/additional-methods.min.js'); // Initialise variables $trackorder = false; $state = $this->get('State'); $actionmode = JRequest::getVar('actionmode', ""); $item = $this->get('Item'); $params =& $state->params; $this->assignRef('state', $state); $this->assignRef('params', $params); $this->assignRef('language', $language); $this->assignRef('item', $item); $this->assignRef('actionmode', $actionmode); if ($actionmode == "orderpayment") { //recupero quanti pagamenti sono stati effettuati $item->paymentCount = BFCHelper::getTotalOrderPayments($item->order->OrderId); $item->overrideAmount = JRequest::getFloat('overrideAmount'); //sostituisco i dati dell'ordine da pagare con i dati passati e l'ordine con un suffisso in più /*$item = $this->get('Item');*/ /*$item = "fet";*/ } if ($actionmode == "orderpaid") { $trackorder = true; } if ($actionmode != '' && $actionmode != 'cancel' && $actionmode != 'donation' && $actionmode != 'orderpayment') { if ($item->order->Status != 5) { $hasPayed = $this->processPayment($actionmode, $item->order->OrderId); /* eccezione per setefi che pretende un url di ritorno */ } else { //$hasPayed = true; $hasPayed = $this->processOrderPayment($actionmode, $item->order->OrderId, $language); } /* $link = ''; if ($hasPayed){ } $app = JFactory::getApplication(); $app->redirect($link, $msg); */ } if ($actionmode == '' && $actionmode != 'donation') { if ($item->order->Status != 5) { $this->inizializePayment($item->order->OrderId); } } if ($actionmode == 'orderpaid') { $hasPayed = $item->order->Status == 5; } if (isset($trackorder) && $trackorder) { $merchants = array(); $merchants[] = $item->order->MerchantId; $criteoConfig = BFCHelper::getCriteoConfiguration(4, $merchants, $item->order->OrderId); if (isset($criteoConfig) && isset($criteoConfig->enabled) && $criteoConfig->enabled && count($criteoConfig->merchants) > 0) { $document->addScript('//static.criteo.net/js/ld/ld.js'); $document->addScriptDeclaration('window.criteo_q = window.criteo_q || []; window.criteo_q.push( { event: "setAccount", account: ' . $criteoConfig->campaignid . '}, { event: "setSiteType", type: "d" }, { event: "setEmail", email: "" }, { event: "trackTransaction", id: "' . $criteoConfig->transactionid . '", item: [' . json_encode($criteoConfig->orderdetails) . '] } );'); } $analyticsEnabled = $this->checkAnalytics("Sales Resource List"); if ($analyticsEnabled && $config->get('eecenabled', 0) == 1) { $purchaseObject = new stdClass(); $purchaseObject->id = "" . $item->order->OrderId; $purchaseObject->affiliation = "" . $item->order->Label; $purchaseObject->revenue = "" . $item->order->TotalAmount; $purchaseObject->tax = 0.0; $allobjects = array(); $svcTotal = 0; $allservices = array_values(array_filter(simpledom_load_string($order->NotesData)->xpath("//price"), function ($prc) { return (string) $prc->tag == "extrarequested"; })); foreach ($allservices as $svc) { $svcObj = new stdClass(); $svcObj->id = "" . (int) $svc->priceId . " - Service"; $svcObj->name = (string) $svc->name; $svcObj->category = "Services"; $svcObj->brand = $item->Name; $svcObj->variant = (string) BFCHelper::getItem($order->NotesData, 'nome', 'unita'); $svcObj->price = round((double) $svc->discountedamount / (int) $svc->quantity, 2); $svcObj->quantity = (int) $svc->quantity; $allobjects[] = $svcObj; $svcTotal += (double) $svc->discountedamount; } $mainObj = new stdClass(); $mainObj->id = "" . $item->order->RequestedItemId . " - Resource"; $mainObj->name = (string) BFCHelper::getItem($order->NotesData, 'nome', 'unita'); $mainObj->variant = (string) BFCHelper::getItem($order->NotesData, 'refid', 'rateplan'); $mainObj->category = $item->MainCategoryName; $mainObj->brand = $item->Name; $mainObj->price = $item->order->TotalAmount - $svcTotal; $mainObj->quantity = 1; $allobjects[] = $mainObj; $document->addScriptDeclaration('callAnalyticsEEc("addProduct", ' . json_encode($allobjects) . ', "purchase", "", ' . json_encode($purchaseObject) . ');'); } } // assegno il riferimento dopo gli altri altrimenti non ho nessuna associazione $this->assignRef('hasPayed', $hasPayed); /* $items = $this->get('Items'); $pagination = $this->get('Pagination'); $sortColumn = $state->get('list.ordering'); $sortDirection = $state->get('list.direction'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } $pagination->setAdditionalUrlParam("filter_order", $ordering); $pagination->setAdditionalUrlParam("filter_order_Dir", $direction); $this->assignRef('items', $items); $this->assignRef('pagination', $pagination); */ // Display the view parent::display($tpl); }
function display($tpl = null, $preparecontent = false) { // Initialise variables $state = $this->get('State'); $item = $this->get('Item'); $document = JFactory::getDocument(); $language = $document->getLanguage(); $params = $state->params; $app = JFactory::getApplication(); $sitename = $app->get('sitename'); $config = JComponentHelper::getParams('com_bookingforconnector'); $orderid = 0; // add stylesheet JHTML::stylesheet('components/com_bookingforconnector/assets/css/font-awesome.css'); JHTML::stylesheet('components/com_bookingforconnector/assets/bootstrap/css/bootstrap.css'); $document->addStyleSheet('components/com_bookingforconnector/assets/css/bookingfor.css'); $document->addStyleSheet('components/com_bookingforconnector/assets/css/bookingfor-responsive.css'); $document->addStyleSheet('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css'); $document->addScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js'); $document->addScript('components/com_bookingforconnector/assets/js/jquery.shorten.js'); $document->addScript('components/com_bookingforconnector/assets/js/jquery.validate.min.js'); $document->addScript('components/com_bookingforconnector/assets/js/additional-methods.min.js'); $document->addScript('components/com_bookingforconnector/assets/js/jquery.expander.min.js'); if (substr($language, 0, 2) != 'en') { // $document->addScript('//jquery-ui.googlecode.com/svn/tags/legacy/ui/i18n/ui.datepicker-' . substr($language,0,2) . '.js'); $document->addScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/i18n/datepicker-' . substr($language, 0, 2) . '.min.js?ver=1.11.4'); } $checkAnalytics = false; if (!isset($item)) { header("Location: " . JURI::root()); $app->close(); } if ($item->HasResources) { if (JRequest::getString('layout') == 'resourcesajax') { $items = $this->get('ItemsResourcesAjax'); } } if ($item->HasResources) { if (JRequest::getString('layout') == 'resources') { $items = $this->get('Items'); $checkAnalytics = true; $pagination = $this->get('Pagination'); } } if (JRequest::getString('layout') == 'packages') { $items = $this->get('ItemsPackages'); $checkAnalytics = true; $pagination = $this->get('PaginationPackages'); } if (JRequest::getString('layout') == 'package') { $items = $this->get('Package'); $checkAnalytics = true; BFCHelper::setState($items, 'packages', 'merchant'); } if (JRequest::getString('layout') == 'offers') { $items = $this->get('ItemsOffer'); $checkAnalytics = true; $pagination = $this->get('PaginationOffers'); } if (JRequest::getString('layout') == 'offer') { $items = $this->get('Offer'); $checkAnalytics = true; BFCHelper::setState($items, 'offers', 'merchant'); } if (JRequest::getString('layout') == 'onsellunits') { $items = $this->get('ItemsOnSellUnit'); $checkAnalytics = true; $pagination = $this->get('PaginationOnSellUnits'); } if (JRequest::getString('layout') == 'onsellunit') { $items = array($this->get('OnSellUnit')); $checkAnalytics = true; BFCHelper::setState($items, 'onsellunits', 'merchant'); } if (JRequest::getString('layout') == 'ratings') { $items = $this->get('ItemsRating'); $pagination = $this->get('PaginationRatings'); // load scripts $document->addScript('components/com_bookingforconnector/assets/js/jquery.expander.min.js'); } if (JRequest::getString('layout', 'default') == 'default') { $checkAnalytics = true; } if (JRequest::getString('layout', 'default') == 'thanks') { $checkAnalytics = true; } if (JRequest::getString('layout') == 'rating') { // load css $document->addStyleSheet('components/com_bookingforconnector/assets/css/jquery.rating.css'); $document->addStyleSheet('components/com_bookingforconnector/assets/css/jquery.validate.css'); // load scripts $document->addScript('components/com_bookingforconnector/assets/js/jquery.rating.pack.js'); $document->addScript('components/com_bookingforconnector/assets/js/jquery.form.js'); $document->addScript('components/com_bookingforconnector/assets/js/jquery.blockUI.js'); } $listName = ""; if ($checkAnalytics) { $checkAnalytics = false; $itemType = 0; $totalItems = array(); $type = ""; switch (JRequest::getString('layout', 'default')) { case "resources": $listName = "Resources List"; $type = "Resource"; $itemType = 1; foreach ($items as $key => $value) { $obj = new stdClass(); $obj->Id = $value->ResourceId; $obj->Name = $value->Name; $totalItems[] = $obj; } break; case "packages": $listName = "Packages List"; $type = "Package"; $itemType = 1; foreach ($items as $key => $value) { $obj = new stdClass(); $obj->Id = $value->PackageId; $obj->Name = $value->Name; $totalItems[] = $obj; } break; case "offers": $listName = "Offers List"; $type = "Offer"; $itemType = 1; foreach ($items as $key => $value) { $obj = new stdClass(); $obj->Id = $value->VariationPlanId; $obj->Name = $value->Name; $totalItems[] = $obj; } break; case "onsellunits": $listName = "Sales Resources Merchant List"; $type = "Sales Resource"; $itemType = 1; foreach ($items as $key => $value) { $obj = new stdClass(); $obj->Id = $value->ResourceId; $obj->Name = $value->Name; $totalItems[] = $obj; } break; case "package": $listName = "Packages Page"; $type = "Package"; $itemType = 0; $obj = new stdClass(); $obj->Id = $items->PackageId; $obj->Name = $items->Name; $totalItems[] = $obj; break; case "offer": $listName = "Offers Page"; $type = "Offer"; $itemType = 0; $obj = new stdClass(); $obj->Id = $items->VariationPlanId; $obj->Name = $items->Name; $totalItems[] = $obj; break; case "onsellunit": $listName = "Sales Resources Merchant Page"; $type = "Sales Resource"; $itemType = 0; $obj = new stdClass(); $obj->Id = $items->ResourceId; $obj->Name = $items->Name; $totalItems[] = $obj; break; case "thanks": $itemType = 2; break; case "default": $listName = "Merchants Page"; $type = "Merchant"; $itemType = 0; $obj = new stdClass(); $obj->Id = $item->MerchantId; $obj->Name = $item->Name; $totalItems[] = $obj; break; } if ($this->checkAnalytics($listName) && $config->get('eecenabled', 0) == 1) { $checkAnalytics = true; switch ($itemType) { case 0: $value = $totalItems[0]; $obj = new stdClass(); $obj->id = "" . $value->Id . " - " . $type; $obj->name = $value->Name; $obj->category = $item->MainCategoryName; $obj->brand = $item->Name; $obj->variant = 'NS'; $document->addScriptDeclaration('callAnalyticsEEc("addProduct", [' . json_encode($obj) . '], "item");'); break; case 1: $allobjects = array(); foreach ($totalItems as $key => $value) { $obj = new stdClass(); $obj->id = "" . $value->Id . " - " . $type; $obj->name = $value->Name; $obj->category = $item->MainCategoryName; $obj->brand = $item->Name; $obj->position = $key; $allobjects[] = $obj; } $document->addScriptDeclaration('callAnalyticsEEc("addImpression", ' . json_encode($allobjects) . ', "list");'); break; case 2: $orderid = JRequest::getString('orderid'); if (!empty($orderid)) { $order = BFCHelper::getSingleOrderFromService($orderid); $purchaseObject = new stdClass(); $purchaseObject->id = "" . $order->OrderId; $purchaseObject->affiliation = "" . $order->Label; $purchaseObject->revenue = $order->TotalAmount; $purchaseObject->tax = 0.0; $allobjects = array(); $allservices = array(); $svcTotal = 0; if (!empty($order->NotesData) && !empty(simpledom_load_string($order->NotesData)->xpath("//price"))) { $allservices = array_values(array_filter(simpledom_load_string($order->NotesData)->xpath("//price"), function ($prc) { return (string) $prc->tag == "extrarequested"; })); if (!empty($allservices)) { foreach ($allservices as $svc) { $svcObj = new stdClass(); $svcObj->id = "" . (int) $svc->priceId . " - Service"; $svcObj->name = (string) $svc->name; $svcObj->category = "Services"; $svcObj->brand = $item->Name; $svcObj->variant = (string) BFCHelper::getItem($order->NotesData, 'nome', 'unita'); $svcObj->price = round((double) $svc->discountedamount / (int) $svc->quantity, 2); $svcObj->quantity = (int) $svc->quantity; $allobjects[] = $svcObj; $svcTotal += (double) $svc->discountedamount; } } $mainObj = new stdClass(); $mainObj->id = "" . $order->RequestedItemId . " - Resource"; $mainObj->name = (string) BFCHelper::getItem($order->NotesData, 'nome', 'unita'); $mainObj->variant = (string) BFCHelper::getItem($order->NotesData, 'refid', 'rateplan'); $mainObj->category = $item->MainCategoryName; $mainObj->brand = $item->Name; $mainObj->price = $order->TotalAmount - $svcTotal; $mainObj->quantity = 1; $allobjects[] = $mainObj; $document->addScriptDeclaration('callAnalyticsEEc("addProduct", ' . json_encode($allobjects) . ', "purchase", "", ' . json_encode($purchaseObject) . ');'); } } break; } } } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } $layout = JRequest::getString('layout', "default"); if ($layout == "thanks" || $layout == "default") { $merchants = array(); $merchants[] = $item->MerchantId; if ($layout == "thanks") { $orderid = JRequest::getString('orderid'); $criteoConfig = BFCHelper::getCriteoConfiguration(4, $merchants, $orderid); } else { if ($layout == "") { $criteoConfig = BFCHelper::getCriteoConfiguration(2, $merchants); } } if (isset($criteoConfig) && isset($criteoConfig->enabled) && $criteoConfig->enabled && count($criteoConfig->merchants) > 0) { $document->addScript('//static.criteo.net/js/ld/ld.js'); if ($layout == "thanks") { $document->addScriptDeclaration('window.criteo_q = window.criteo_q || []; window.criteo_q.push( { event: "setAccount", account: ' . $criteoConfig->campaignid . '}, { event: "setSiteType", type: "d" }, { event: "setEmail", email: "" }, { event: "trackTransaction", id: "' . $criteoConfig->transactionid . '", item: [' . json_encode($criteoConfig->orderdetails) . '] } );'); } else { if ($layout == "default") { $document->addScriptDeclaration('window.criteo_q = window.criteo_q || []; window.criteo_q.push( { event: "setAccount", account: ' . $criteoConfig->campaignid . '}, { event: "setSiteType", type: "d" }, { event: "setEmail", email: "" }, { event: "viewItem", item: "' . $criteoConfig->merchants[0] . '" } );'); } } } } BFCHelper::setState($item, 'merchant', 'merchant'); $this->setBreadcrumb($item, JRequest::getString('layout')); $this->assignRef('params', $params); $this->assignRef('item', $item); $this->assignRef('items', $items); $this->assignRef('pagination', $pagination); $this->assignRef('document', $document); $this->assignRef('language', $language); $this->assignRef('sitename', $sitename); $this->assignRef('config', $config); $this->assignRef('state', $state); $this->assignRef('checkAnalytics', $checkAnalytics); $this->assignRef('analyticsListName', $listName); // Display the view parent::display($tpl, true); }
/** * @overrides get() from RestResource */ public function get() { if (parent::get() !== false) { if ($this->_logfile != '') { try { $oldvalue = ''; $newvalue = ''; $list = array(); if (is_numeric($this->getParam('id'))) { $id = $this->getParam('id'); } elseif (substr($this->getParam('id'), 0, 2) === "s:") { db()->setFetchMode(Zend_Db::FETCH_BOTH); $id = db()->query("(SELECT id FROM applications WHERE cname ILIKE '" . pg_escape_string(substr($this->getParam('id'), 2)) . "\n' FETCH FIRST 1 ROWS ONLY)")->fetchAll(); try { $id = $id[0][0]; $this->_pars["id"] = $id; } catch (Exception $e) { debug_log('could not find if for application with cname `' . pg_escape_string(substr($this->getParam('id'), 2)) . "'"); } } $log = ''; $f = fopen($this->_logfile, "r"); if ($f !== false) { error_log('Acquiring shared lock on logfile "' . $this->_logfile . '"'); if (flock($f, LOCK_SH)) { error_log('Shared lock on logfile "' . $this->_logfile . '" acquired'); $log = file_get_contents($this->_logfile); // error_log('Logfile "' . $this->_logfile . '" loaded as text'); flock($f, LOCK_UN); } else { error_log('Could not acquire shared lock on logfile "' . $this->_logfile . '"'); } fclose($f); } if ($log == '') { $this->setError(RestErrorEnum::RE_BACKEND_ERROR, "Could not access history database."); return false; } $log = "<log>" . $log . "</log>"; //$log = new SimpleXMLElement($log); $log = simpledom_load_string($log); // error_log("Logfile loaded as XML"); $xpath = $log->sortedXPath('action[@target="application" and @id="' . $id . '" and (@event="update" or @event="delete")]', '@timestamp'); // error_log("Got sorted XPath from XML log"); //$xpath = $log->xpath('action[@target="application" and @id="'.$id.'"]'); $counter = 0; foreach ($xpath as $x) { $counter = $counter + 1; if ($x->attributes()->event) { $event = strval($x->attributes()->event); } else { $event = ''; } if ($x->attributes()->userid) { $userid = strval($x->attributes()->userid); } else { $userid = ''; } if ($x->attributes()->username) { $username = strval($x->attributes()->username); } else { $username = ''; } if ($x->attributes()->usercontact) { $usercontact = strval($x->attributes()->usercontact); } else { $usercontact = ''; } if ($x->attributes()->apiver) { $apiver = strval($x->attributes()->apiver); } else { $apiver = '1.0'; } if ($x->attributes()->disposition) { $disposition = strval($x->attributes()->disposition); } else { $disposition = ''; } if ($x->attributes()->timestamp) { $timestamp = strval($x->attributes()->timestamp); } else { $timestamp = ''; } if ($timestamp != '') { $timestamp = str_replace(' ', 'T', $timestamp); $timestamp = substr($timestamp, 0, 4) . "-" . substr($timestamp, 6, 2) . "-" . substr($timestamp, 4, 2) . substr($timestamp, 8); } if ($userid !== '') { $ppl = new Default_Model_Researchers(); // retreive the user's CName even if the record has been marked as deleted $ppl->viewModerated = true; $ppl->filter->id->numequals($userid); if (count($ppl->items) > 0) { $userCname = $ppl->items[0]->cname; } else { $userCname = ''; } } $counter = str_replace(array("-", ":", "T"), "", $timestamp) . $userid . substr($event, 0, 1); $value = $x->xpath('oldvalue'); if (count($value) === 1) { $value = $value[0]; $value = base64_decode($value); $value = bzdecompress($value); $oldvalue = '<history:oldvalue xmlns:history="http://appdb.egi.eu/api/' . $this->getParam('version') . '/history">' . $value . '</history:oldvalue>'; } $value = $x->xpath('newvalue'); if (count($value) === 1) { $value = $value[0]; $value = base64_decode($value); $value = bzdecompress($value); $newvalue = '<history:newvalue xmlns:history="http://appdb.egi.eu/api/' . $this->getParam('version') . '/history">' . $value . '</history:newvalue>'; } if ($oldvalue != '' && $newvalue != '') { if ($this->_listMode === RestListModeEnum::RL_NORMAL) { $list[] = '<history:history xmlns:history="http://appdb.egi.eu/api/' . $this->getParam('version') . '/history"' . ' id="' . $counter . '" event="' . $event . '"' . ($disposition != '' ? ' disposition="' . $disposition . '"' : '') . ' userid="' . $userid . '" usercname="' . $userCname . '" username="******" usercontact="' . $usercontact . '" apiver="' . $apiver . '" timestamp="' . $timestamp . '">' . $oldvalue . $newvalue . '</history:history>'; } elseif ($this->_listMode === RestListModeEnum::RL_LISTING) { $list[] = '<history:history xmlns:history="http://appdb.egi.eu/api/' . $this->getParam('version') . '/history"' . ' id="' . $counter . '" event="' . $event . '" userid="' . $userid . '" usercname="' . $userCname . '" username="******" usercontact="' . $usercontact . '" apiver="' . $apiver . '" timestamp="' . $timestamp . '"/>'; } } } $this->_total = count($list); } catch (Exception $e) { $this->setError(RestErrorEnum::RE_BACKEND_ERROR, $e->getMessage()); return false; } // error_log("XML logfile parsed successfully"); return new XMLFragmentRestResponse($list, $this); } else { return new XMLFragmentRestResponse("", $this); } } else { return false; } }