/** * To pad the nchar properties with spaces at the right end if its size is * less than the maximum size defined for the property. * * @param ClientType $type * @param Object $object */ protected function HandleNCharProperties($type, $object) { $properties = $type->getRawProperties(); foreach ($properties as $property) { $attributes = $property->getAttributes(); if (isset($attributes['EdmType']) && isset($attributes['FixedLength']) && $attributes['EdmType'] == 'Edm.String' && $attributes['FixedLength'] == 'true') { $refProperty = new ReflectionProperty($object, $property->getName()); $propertyValue = $refProperty->getValue($object); if (is_null($propertyValue)) { continue; } $currentLength = strlen($propertyValue); $padLength = $attributes['MaxLength'] - $currentLength; if ($padLength > 0) { $propertyValue = str_pad($propertyValue, $currentLength + $padLength); $refProperty->setValue($object, $propertyValue); } } } }
/** * 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); } } }