當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。