本文整理汇总了PHP中SimpleXMLExtended::addXMLElement方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleXMLExtended::addXMLElement方法的具体用法?PHP SimpleXMLExtended::addXMLElement怎么用?PHP SimpleXMLExtended::addXMLElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleXMLExtended
的用法示例。
在下文中一共展示了SimpleXMLExtended::addXMLElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cmsNavItemToXML
public function cmsNavItemToXML(ModelObject $CMSNavItem)
{
$xml = new SimpleXMLExtended('<item/>');
$xml->addAttribute('id', $CMSNavItem->CMSNavItemID);
$xml->addAttribute('pluginid', $CMSNavItem->PluginID);
$xml->addAttribute('uri', $CMSNavItem->URI);
foreach (array('slug', 'label', 'sort_order', 'permissions') as $key) {
$camel = StringUtils::camelize($key);
if (!empty($CMSNavItem->{$camel})) {
$xml->addAttribute($key, $CMSNavItem->{$camel});
}
}
$xml->addAttribute('enabled', $CMSNavItem->isEnabled() ? 'true' : 'false');
if (!empty($CMSNavItem->DoAddLinksFor)) {
$xml->addAttribute('create_add_menu', $CMSNavItem->DoAddLinksFor);
}
// if($CMSNavItem->hasModifiedDate())
// $xml->addChild('modified_date', $this->DateFactory->toStorageDate($CMSNavItem->ModifiedDate)->toMySQLDate());
// if($CMSNavItem->hasCreationDate())
// $xml->addChild('creation_date', $this->DateFactory->toStorageDate($CMSNavItem->CreationDate)->toMySQLDate());
$sort_array = array();
$children = $CMSNavItem->getChildren();
if (!empty($children)) {
foreach ($children as $child) {
$sort_array[] = $child->SortOrder;
$sort_array2[] = $child->Slug;
}
array_multisort($sort_array, SORT_ASC, $sort_array2, SORT_ASC, $children);
foreach ($children as $child) {
$xml->addXMLElement($this->cmsNavItemToXML($child));
}
}
return $xml;
}