当前位置: 首页>>代码示例>>PHP>>正文


PHP SimpleXMLExtended::attribute方法代码示例

本文整理汇总了PHP中SimpleXMLExtended::attribute方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleXMLExtended::attribute方法的具体用法?PHP SimpleXMLExtended::attribute怎么用?PHP SimpleXMLExtended::attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleXMLExtended的用法示例。


在下文中一共展示了SimpleXMLExtended::attribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: xmlToCMSNavItem

 public function xmlToCMSNavItem(ModelObject $CMSNavItem, SimpleXMLExtended $xml)
 {
     if (($id = $xml->attribute('id')) !== null) {
         $CMSNavItem->CMSNavItemID = intval($id);
     }
     if (($id = $xml->attribute('slug')) !== null) {
         $CMSNavItem->Slug = strval($id);
     }
     if (($id = $xml->attribute('pluginid')) !== null) {
         $CMSNavItem->PluginID = strval($id);
     }
     if (($id = $xml->attribute('uri')) !== null) {
         $CMSNavItem->URI = strval($id);
     }
     if (($id = $xml->attribute('create_add_menu')) !== null) {
         $CMSNavItem->DoAddLinksFor = strval($id);
     }
     if (($id = $xml->attribute('enabled')) !== null) {
         $CMSNavItem->Enabled = StringUtils::strToBool($id);
     } else {
         $CMSNavItem->Enabled = true;
     }
     foreach (array('label', 'sort_order', 'permissions', 'parent_slug') as $key) {
         $camel = StringUtils::camelize($key);
         $CMSNavItem->{$camel} = trim($xml->attribute($key));
     }
     if ($CMSNavItem->Slug == '') {
         $CMSNavItem->Slug = SlugUtils::createSlug($CMSNavItem->Label);
     }
     if (empty($CMSNavItem->SortOrder)) {
         $CMSNavItem->SortOrder = PHP_INT_MAX;
     }
     $children = array();
     foreach ($xml as $childNode) {
         if ($childNode->getName() == 'item') {
             $child = $this->xmlToCMSNavItem(new CMSNavItem(), $childNode);
             $child->ParentSlug = $CMSNavItem->Slug;
             $children[] = $child;
             $sort_array[] = $child->SortOrder;
             $sort_array2[] = $child->Slug;
         }
     }
     if (!empty($children)) {
         array_multisort($sort_array, SORT_ASC, $sort_array2, SORT_ASC, $children);
     }
     $CMSNavItem->Children = $children;
     //        if($xml->creation_date)
     //            $CMSNavItem->CreationDate = $this->DateFactory->newStorageDate(strval($xml->creation_date));
     //        if($xml->modified_date)
     //            $CMSNavItem->ModifiedDate = $this->DateFactory->newStorageDate(strval($xml->modified_date));
     return $CMSNavItem;
 }
开发者ID:wb-crowdfusion,项目名称:crowdfusion,代码行数:52,代码来源:SystemXMLConverter.php


注:本文中的SimpleXMLExtended::attribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。