本文整理汇总了PHP中eZURL::urlByURL方法的典型用法代码示例。如果您正苦于以下问题:PHP eZURL::urlByURL方法的具体用法?PHP eZURL::urlByURL怎么用?PHP eZURL::urlByURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZURL
的用法示例。
在下文中一共展示了eZURL::urlByURL方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateUniqueURLHTTPInput
/**
* This method validates unique URL.
*
* @param string $data
* @param object $contentObjectAttribute
* @return boolean
*/
public static function validateUniqueURLHTTPInput($data, $contentObjectAttribute)
{
$ini = eZINI::instance('uniquedatatypes.ini');
$uniqueURLINI = $ini->group('UniqueURLSettings');
if (count($uniqueURLINI['AllowedSchemaList'])) {
if (!eregi("^(" . implode('|', $uniqueURLINI['AllowedSchemaList']) . ")", $data)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/ezuniquedatatypes', 'Only URLs beginning with "%schemas" are accepted!', '', array('%schemas' => implode('", "', $uniqueURLINI['AllowedSchemaList']))));
return eZInputValidator::STATE_INVALID;
}
}
$url = eZURL::urlByURL($data);
if (is_object($url)) {
$contentObjectID = $contentObjectAttribute->ContentObjectID;
$contentClassAttributeID = $contentObjectAttribute->ContentClassAttributeID;
$db = eZDB::instance();
if ($uniqueURLINI['CurrentVersionOnly'] == 'true') {
$query = "SELECT COUNT(*) AS row_counter\n\t\t\t\t\tFROM ezcontentobject co, ezcontentobject_attribute coa\n\t\t\t\t\tWHERE co.id = coa.contentobject_id\n\t\t\t\t\tAND co.current_version = coa.version\n\t\t\t\t\tAND coa.contentclassattribute_id = " . $db->escapeString($contentClassAttributeID) . "\n\t\t\t\t\tAND coa.contentobject_id <> " . $db->escapeString($contentObjectID) . "\n AND coa.data_int = " . $db->escapeString($url->ID);
} else {
$query = "SELECT COUNT(*) AS row_counter\n\t\t\t\t\tFROM ezcontentobject_attribute coa\n\t\t\t\t\tWHERE coa.contentclassattribute_id = " . $db->escapeString($contentClassAttributeID) . "\n\t\t\t\t\tAND coa.contentobject_id <> " . $db->escapeString($contentObjectID) . "\n AND coa.data_int = " . $db->escapeString($url->ID);
}
if (self::EZUNIQUEURL_DEBUG) {
eZDebug::writeDebug('Query: ' . $query, 'eZUniqueURLType::validateUniqueURLHTTPInput');
}
$rows = $db->arrayQuery($query);
$rowCount = (int) $rows[0]['row_counter'];
if ($rowCount >= 1) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/ezuniquedatatypes', 'Given URL already exists in another content object of this type!'));
return eZInputValidator::STATE_INVALID;
}
}
return eZInputValidator::STATE_ACCEPTED;
}
示例2: unserializeContentObjectAttribute
function unserializeContentObjectAttribute($package, $objectAttribute, $attributeNode)
{
/* For all links found in the XML, do the following:
* Search for url specified in 'href' link attribute (in ezurl table).
* If the url not found then create a new one.
* Then associate the found (or created) URL with the object attribute by creating new url-object link.
* After that, remove "href" attribute, add new "id" attribute.
* This new 'id' will always refer to the existing url object.
*/
$linkNodes = $attributeNode->getElementsByTagName('link');
foreach ($linkNodes as $linkNode) {
$href = $linkNode->getAttribute('href');
if (!$href) {
continue;
}
$urlObj = eZURL::urlByURL($href);
if (!$urlObj) {
$urlObj = eZURL::create($href);
$urlObj->store();
}
$linkNode->removeAttribute('href');
$linkNode->setAttribute('url_id', $urlObj->attribute('id'));
$urlObjectLink = eZURLObjectLink::create($urlObj->attribute('id'), $objectAttribute->attribute('id'), $objectAttribute->attribute('version'));
$urlObjectLink->store();
}
foreach ($attributeNode->childNodes as $childNode) {
if ($childNode->nodeType == XML_ELEMENT_NODE) {
$xmlString = $childNode->ownerDocument->saveXML($childNode);
$objectAttribute->setAttribute('data_text', $xmlString);
break;
}
}
}