Beispiel #1
0
        private void GetExtraNodeInfo()
        {
            // Get template node field
            XmlNode templateNodeField = null;

            try
            {
                templateNodeField = _sitecoreApi.GetItem("/sitecore/templates/" + _sTemplateName + "/" + _sName);
                _TemplateFieldID  = new Guid(templateNodeField.Attributes["id"].Value);
            }
            catch { }

            if (_TemplateFieldID == Guid.Empty)
            {
                try
                {
                    templateNodeField = _sitecoreApi.GetItem("/sitecore/templates/__Standard template/" + _sName);
                    _TemplateFieldID  = new Guid(templateNodeField.Attributes["id"].Value);
                }
                catch { }
            }

            _sSource  = templateNodeField.SelectSingleNode("field[@key='source']").InnerText;
            _sSection = templateNodeField.SelectSingleNode("field[@key='section']").InnerText;
            _sType    = templateNodeField.SelectSingleNode("field[@key='type']").InnerText;

            // Remap id's if neeeded
            RemapTemplateIDs();
        }
Beispiel #2
0
        private Sitecore43Item(XmlNode itemNode, IItem parent, Sitecore43.SitecoreClientAPI sitecoreApi)
        {
            _Parent      = parent;
            _sitecoreApi = sitecoreApi;

            _ID            = new Guid(itemNode.Attributes["id"].Value);
            _sName         = itemNode.Attributes["name"].Value;
            _sKey          = itemNode.Attributes["key"].Value;
            _sTemplateName = itemNode.Attributes["template"].Value;

            // Fetch latest field content
            XmlNode newestContentNode = _sitecoreApi.GetItem(Util.GuidToSitecoreID(_ID));

            _sPath = newestContentNode.Attributes["path"].Value;
            _sIcon = newestContentNode.Attributes["icon"].Value;

            // Only the standard template has an empty TemplateID
            // The item is an template if it's id is the same as the template id
            if ((newestContentNode.Attributes["templateid"].Value == "") ||
                (newestContentNode.Attributes["templateid"].Value == Util.GuidToSitecoreID(_ID)))
            {
                _TemplateID = Guid.Empty;
            }
            else
            {
                _TemplateID = new Guid(newestContentNode.Attributes["templateid"].Value);
            }

            // Get TemplateID from itemNode instead
//            if ((_TemplateID == Guid.Empty) && (itemNode.Attributes["tid"] != null) && (itemNode.Attributes["tid"].Value != ""))
//                _TemplateID = new Guid(itemNode.Attributes["tid"].Value);



            int         iRejected = 0;
            XmlNodeList list      = itemNode.SelectNodes("field");

            foreach (XmlNode node in list)
            {
                Sitecore43Field field = new Sitecore43Field(node, _sTemplateName, _sitecoreApi);

/*
 *              // Fetch latest field content
 *              string sContent = newestContentNode.SelectSingleNode("field[@key = '" + field.Key + "']").InnerText;
 *              if (sContent != "")
 *                  field.Content = sContent;
 */
                // Only add valid fields
                if (IsValidField(field))
                {
                    _fields.Add(field);
                }
                else
                {
                    iRejected++;
                }
            }
            _sXmlNode = itemNode.OuterXml;

            // Additional info
            _sSortOrder = itemNode.Attributes["sortorder"].Value;

            if ((itemNode.Attributes["haschildren"] != null) && (itemNode.Attributes["haschildren"].Value == "1"))
            {
                _bHasChildren = true;
            }


            // This is a template item
            if (_sPath.ToLower().IndexOf("/sitecore/templates/") > -1)
            {
                XmlNode childrenNode = _sitecoreApi.GetItemTree("{" + _ID.ToString().ToUpper() + "}", 2);
                foreach (XmlNode node in childrenNode.SelectNodes("./item"))
                {
                    // Get full-blown item
                    XmlNode templateFieldNode = _sitecoreApi.GetItemXml(node.Attributes["id"].Value, "", this.Options.Language);

                    Sitecore43Field field = new Sitecore43Field(templateFieldNode, _sTemplateName, _sitecoreApi);

                    var existingfields = from f in _fields
                                         where f.TemplateFieldID == field.TemplateFieldID
                                         select f;
                    if ((existingfields.Count() == 0) && (IsValidField(field)))
                    {
                        _fields.Add(field);
                    }
                }
            }
        }