/** * Fucntion to display result of query. */ protected function displayEntityData() { $this->_query = str_replace("\\'", "'", $this->_query); $queryToRun = $this->_query; $pagingSection = '<table border="0" align="center" CELLSPACING="15">'; $nextSkip = null; $canPage = false; if ($this->_enablePaging && (isset($_REQUEST['pagingAllowed']) && $_REQUEST['pagingAllowed'] == 'true')) { $canPage = true; $skip = 0; if (isset($_REQUEST['skip'])) { $skip = $_REQUEST['skip']; } $parts = parse_url($queryToRun); if (isset($parts['query'])) { $queryToRun .= '&$top=' . $this->_pageSize . '&$skip=' . $skip; } else { $queryToRun .= '?$top=' . $this->_pageSize . '&$skip=' . $skip; } $nextSkip = $skip + $this->_pageSize; if ($nextSkip != $this->_pageSize) { $prev = $skip - $this->_pageSize; $pagingSection .= "<td><a href=\"" . $this->_containerScriptName . "?query=" . $this->_query . "&serviceUri=" . $this->_uri . '&skip=' . $prev . '&pagingAllowed=true' . "\">Prev</a></td>"; } } $response = $this->_proxyObject->Execute($queryToRun); $resultSet = $response->Result; echo "<br><br><table style=\"border: thin solid #C0C0C0;\" border=\"1\">"; if (count($resultSet) > 0) { $propertyArray = WCFDataServicesEntity::getProperties($resultSet[0]); $this->displayHeader($propertyArray, $resultSet[0]); foreach ($resultSet as $result) { echo "<tr style=\"font-family: Calibri; " . "background-color: #CCFFFF\">"; WCFDataServicesEntity::getDetailButtonText($result); foreach ($propertyArray as $property) { $prop = new ReflectionProperty($result, $property); $propertyAttributes = Utility::getAttributes($prop); if ($propertyAttributes['Type'] == 'NavigationProperty') { $pagingAllowed = 'pagingAllowed=true'; $relationShip = $this->_proxyObject->GetRelationShip($propertyAttributes["Relationship"], $propertyAttributes["ToRole"]); if ($relationShip != '*') { $pagingAllowed = 'pagingAllowed=false'; } $skip = null; if (isset($_REQUEST['skip'])) { $skip = '&skip=' . $_REQUEST['skip']; } $pagingAllowedWhileAttaching = null; if (isset($_GET['pagingAllowed'])) { $pagingAllowedWhileAttaching = '&pagingAllowed=' . $_GET['pagingAllowed']; } echo "<td>"; $relatedLinks = $result->getRelatedLinks(); $finalQuery = $relatedLinks[$property]; $finalQuery = str_replace("%20", '', $finalQuery); echo "<a href=\"" . $this->_containerScriptName . "?query=" . $finalQuery . '&' . $pagingAllowed . $skip . "&serviceUri=" . $this->_uri . "\">" . $property . "</a>"; echo "<br><a href=\"" . $this->_containerScriptName . "?query=" . $this->_query . $pagingAllowedWhileAttaching . $skip . "&serviceUri=" . $this->_uri . "&Type=" . $property . "&AttachTo=" . $finalQuery . "\"> Add Link </a>"; echo "</td>"; } else { $propertyAttributes = Utility::getAttributes($prop); if (isset($propertyAttributes['EdmType']) && ($index = strpos($propertyAttributes['EdmType'], 'Edm.')) !== 0) { $value = $prop->getValue($result); $type = ClientType::Create(get_class($value)); $nonEpmProperties = $type->getRawNonEPMProperties(true); echo '<td><table style="border: thin solid #C0C0C0;" border="1">'; foreach ($nonEpmProperties as $nonEpmProperty) { $propertyName = $nonEpmProperty->getName(); $refProperty = new ReflectionProperty($value, $propertyName); $propertyValue = $refProperty->getValue($value); echo '<tr><td>'; echo $propertyValue; echo '</td></tr>'; } echo '</table></td>'; } else { if (Utility::ContainAttribute($prop->getDocComment(), 'Binary')) { // TODO: Display image in the cell echo "<td>Image</td>"; } else { $value = $prop->getValue($result); if ($value == '') { $value = 'null'; } echo "<td>" . $value . "</td>"; } } } } echo "</tr>"; } if ($canPage) { $pagingSection .= "<td><a href=\"" . $this->_containerScriptName . "?query=" . $this->_query . "&serviceUri=" . $this->_uri . '&skip=' . $nextSkip . '&pagingAllowed=true' . "\">Next</a></td><tr/></table>"; } } if ($canPage) { echo $pagingSection; } echo "</table><br><br>"; }
public static function PopulateMediaEntryKeyFields($atomXML, $object) { $domDocument = new DomDocument(); $domDocument->loadXML($atomXML); $xPath = new DOMXPath($domDocument); self::ApplyNamespace($xPath); $type = ClientType::Create(get_class($object)); $keyPropertyNames = $type->geyKeyProperties(); foreach ($keyPropertyNames as $keyPropertyName) { $properties = $xPath->query(self::$QUERY_PROPERTY2 . $keyPropertyName); if ($properties->length) { $value = $properties->item(0)->nodeValue; $refProp = new ReflectionProperty($object, $keyPropertyName); $refProp->setValue($object, $value); } } }
/** * * @param ClientType::Property $property * @param Object $object reference to the complex property of entity */ protected function CheckAndCreateChangeSetBodyPartForComplexType($property, $object) { $propertyNameCT = $property->getName(); $propertyAttributes = $property->getAttributes(); $complexBody = null; $index = 0; //Now check for complex type. If type not start with 'Edm.' //it can be a complex type. if (isset($propertyAttributes['EdmType']) && ($index = strpos($propertyAttributes['EdmType'], 'Edm.')) !== 0) { $complexBody = '<d:' . $propertyNameCT . ' m:type="' . $propertyAttributes['EdmType'] . '">' . "\n"; $type = ClientType::Create($propertyNameCT); $nonEpmProperties = $type->getRawNonEPMProperties(true); foreach ($nonEpmProperties as $nonEpmProperty) { $propertyName = $nonEpmProperty->getName(); $refProperty = new ReflectionProperty($object, $propertyName); $propertyValue = $refProperty->getValue($object); $property = ''; // determine if the property is null and should be output accordingly // for numeric types, utilize a numeric value if (!$propertyValue) { Utility::GetPropertyType($refProperty, $notNullable); if (!$notNullable) { $property = "<d:" . $propertyName . " " . "m:null=\"true\" />"; } elseif (strpos($edmType, 'Edm.Decimal') === 0) { $property = '<d:' . $propertyName . '>0.0M</d:' . $propertyName . '>'; } elseif (strpos($edmType, 'Edm.Double') === 0) { $property = '<d:' . $propertyName . '>0.0</d:' . $propertyName . '>'; } elseif (strpos($edmType, 'Edm.Int') === 0) { $property = '<d:' . $propertyName . '>0</d:' . $propertyName . '>'; } elseif (strpos($edmType, 'Edm.Single') === 0) { $property = '<d:' . $propertyName . '>0.0f</d:' . $propertyName . '>'; } else { continue; } } else { $attributes = $nonEpmProperty->getAttributes(); $edmType = ''; if (isset($attributes['EdmType']) && $attributes['EdmType'] != 'Edm.String') { $edmType = ' m:type="' . $attributes['EdmType'] . '"'; // wrap value in CDATA tag since strings may contain XML special characters $propertyValue = "<![CDATA[" . $propertyValue . "]]>"; } $property = '<d:' . $propertyName . $edmType . '>' . $propertyValue . '</d:' . $propertyName . '>'; } if (isset($property)) { Utility::WriteLine($complexBody, $property); } } } if ($complexBody) { $complexBody .= '</d:' . $propertyNameCT . '>'; } return $complexBody; }
/** * * @param ClientType::Property $property * @param Object $object reference to the complex property of entity */ protected function CheckAndCreateChangeSetBodyPartForComplexType($property, $object) { $propertyNameCT = $property->getName(); $propertyAttributes = $property->getAttributes(); $complexBody = null; $index = 0; //Now check for complex type. If type not start with 'Edm.' //it can be a complex type. if (isset($propertyAttributes['EdmType']) && ($index = strpos($propertyAttributes['EdmType'], 'Edm.')) !== 0) { $complexBody = '<d:' . $propertyNameCT . ' m:type="' . $propertyAttributes['EdmType'] . '">' . "\n"; $type = ClientType::Create($propertyNameCT); $nonEpmProperties = $type->getRawNonEPMProperties(true); foreach ($nonEpmProperties as $nonEpmProperty) { $propertyName = $nonEpmProperty->getName(); $refProperty = new ReflectionProperty($object, $propertyName); $propertyValue = $refProperty->getValue($object); $property = null; if (empty($propertyValue) || is_null($propertyValue)) { Utility::GetPropertyType($refProperty, $notNullable); if (!$notNullable) { $property = "<d:" . $propertyName . " " . "m:null=\"true\" />"; } else { continue; } } else { $attributes = $nonEpmProperty->getAttributes(); $edmType = ''; if (isset($attributes['EdmType']) && $attributes['EdmType'] != 'Edm.String') { $edmType = ' m:type="' . $attributes['EdmType'] . '"'; } $property = '<d:' . $propertyName . "{$edmType}>" . $propertyValue . '</d:' . $propertyName . '>'; } if (isset($property)) { Utility::WriteLine($complexBody, $property); } } } if ($complexBody) { $complexBody .= '</d:' . $propertyNameCT . '>'; } return $complexBody; }