<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ProgTips</title>
	<atom:link href="http://tips.naivist.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://tips.naivist.net</link>
	<description>Kodējot radušās domeles</description>
	<lastBuildDate>Fri, 08 Jul 2011 11:17:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Kārtošana latviešu valodā ar Microsoft SQL Server</title>
		<link>http://tips.naivist.net/2011/07/08/kartosana-latviesu-valoda-ar-microsoft-sql-server/</link>
		<comments>http://tips.naivist.net/2011/07/08/kartosana-latviesu-valoda-ar-microsoft-sql-server/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 07:20:05 +0000</pubDate>
		<dc:creator>Krišs Rauhvargers</dc:creator>
				<category><![CDATA[Datorlietas]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://tips.naivist.net/?p=210</guid>
		<description><![CDATA[Jau kopš senām Microsoft SQL Server versijām ir bijusi problēma, ka latviešu valodas teksti tiek kārtoti nepareizi. Proti, pat tad, ja datubāzei iestatīta &#8220;Latviešu&#8221; valoda, netiek šķiroti īsie un garie burti (šeit ar &#8220;latviešu&#8221; saprotu tādas kolācijas kā, piemēram, &#8216;Latvian&#95;CI&#95;AS&#8217; vai &#8216;SQL_Latvian&#95;Cp1257&#95;CI&#95;AS&#95;KI&#95;WI&#8217;). Līdz ar to sarakstu bērziņš, avotiņš, āboliņš SQL serveris kārtoja kā āboliņš, avotiņš, [...]]]></description>
			<content:encoded><![CDATA[<p>Jau kopš senām Microsoft SQL Server versijām ir bijusi problēma, ka latviešu valodas teksti tiek kārtoti nepareizi. Proti, pat tad, ja datubāzei iestatīta &#8220;Latviešu&#8221; valoda, netiek šķiroti īsie un garie burti (šeit ar &#8220;latviešu&#8221; saprotu tādas kolācijas kā, piemēram, &#8216;Latvian&#95;CI&#95;AS&#8217; vai &#8216;SQL_Latvian&#95;Cp1257&#95;CI&#95;AS&#95;KI&#95;WI&#8217;).
Līdz ar to sarakstu <code>bērziņš, avotiņš, āboliņš</code> SQL serveris kārtoja kā <code>āboliņš, avotiņš, bērziņš</code>. Kā zinām no ābeces mācīšanās, latviešu alfabēts ir <code>A, Ā, B, C, Č...</code>, tas ir, diakritiskās zīmes ir atsevišķas un tās seko aiz tā paša burta bez diakritiskās zīmes, tāpēc pareizi būtu bijis <code>avotiņš, āboliņš, bērziņš</code>.</p>

<p>Kopš SQL server 2008 ir pieejama vēl viena kolāciju saime &#8211; tādas, kas sākas ar <code>Latvian_100</code>, piemēram, <code>Latvian_100_CI_AS</code>. Šajās kolācijās gan viss ir salabots un kārtošana tiešām strādā pareizi: </p>

<pre><code>select VARDS from (
        select 'Bērziņš' as VARDS union
        select 'Āboliņš' as VARDS union
        select 'Avotiņš' as VARDS) as SAMPLES
order by VARDS collate Latvian_100_CI_AS
</code></pre>

<p>rezultāts ir</p>

<pre><code>VARDS
-------
Avotiņš
Āboliņš
Bērziņš
</code></pre>

<p>Papildus informāciju var pasmelties <a href="http://download.microsoft.com/download/d/9/4/d948f981-926e-40fa-a026-5bfcf076d9b9/Pre-SQLServer2008_NativeDataProviders_and_NewCollations.docx" onclick="pageTracker._trackPageview('/outgoing/download.microsoft.com/download/d/9/4/d948f981-926e-40fa-a026-5bfcf076d9b9/Pre-SQLServer2008_NativeDataProviders_and_NewCollations.docx?referer=');">MSDN dokumentācijā</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://tips.naivist.net/2011/07/08/kartosana-latviesu-valoda-ar-microsoft-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>InfoPath form cleanup for faster load times</title>
		<link>http://tips.naivist.net/2011/05/11/infopath-form-cleanup-for-faster-load-times/</link>
		<comments>http://tips.naivist.net/2011/05/11/infopath-form-cleanup-for-faster-load-times/#comments</comments>
		<pubDate>Wed, 11 May 2011 09:28:49 +0000</pubDate>
		<dc:creator>Krišs Rauhvargers</dc:creator>
				<category><![CDATA[.NET pasaule]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://tips.naivist.net/?p=198</guid>
		<description><![CDATA[InfoPath forms may contain variable definitions which are not referenced by any view. Existance of these variables slow down form load times. This article presents a script for automatic clean-up of such variables.]]></description>
			<content:encoded><![CDATA[<p>My team has been working on an InfoPath 2007 form (using Visual Studio Tools for Applications) for a while. The form is bound to an XML structure having approximately 100 fields/properties. Since its initial build, the form has been modified, recompiled and re-packaged for quite a lot of times.</p>

<p>Users complained that form load times are quite long. It seemed that by every version they are getting even worse. The initial thought was that the delay was due to loading of SharePoint data (through secondary data sources). However, profiling showed that it takes less than a second to load them.</p>

<p>Recently, we found out that by each build the <code>manifest.xsf</code> file becomes larger and larger. The initial version was less than 100K, while the current one is 500K. The reason for such growth was &#8211; automatically generated &#8220;InfoPath variables&#8221; in the form. Something like this:</p>

<pre><code> &lt;xsf:xmlToEdit name="SomeFieldName_3721" item="/my:SomeContainer/my:SomeSubNode/my:SubSubNode"&gt;
    &lt;xsf:editWith autoComplete="no" component="xField"&gt;&lt;/xsf:editWith&gt;
 &lt;/xsf:xmlToEdit&gt;
</code></pre>

<p>The variables can be later referenced in InfoPath&#8217;s own XSLT views as well as in context menu definitions in the manifest.xsf. However, these variables are never cleaned up. The list is growing each time you save your form using form designer.</p>

<p>It seems that Infopath initializes each variable upon form load. The more variables you have, the longer it takes to load the form.</p>

<p>When there are thousands of such variables, cleanup is not very easy. Hence, I wrote a PowerShell script to do the job. It enumerates all the variables and looks for references to this variable in manifest.xsf and in all .xsd views of your InfoPath form. </p>

<p><a href="http://tips.naivist.net/wp-content/clean_manifest.txt">Download the InfoPath manifest.xsf clean-up script</a> here.</p>
]]></content:encoded>
			<wfw:commentRss>http://tips.naivist.net/2011/05/11/infopath-form-cleanup-for-faster-load-times/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>InfoPath forms in SharePoint</title>
		<link>http://tips.naivist.net/2010/09/30/infopath-forms-in-sharepoint/</link>
		<comments>http://tips.naivist.net/2010/09/30/infopath-forms-in-sharepoint/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 14:56:54 +0000</pubDate>
		<dc:creator>Krišs Rauhvargers</dc:creator>
				<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://tips.naivist.net/?p=192</guid>
		<description><![CDATA[These two articles just made my day. At least, they made my intranet portal a much better &#8220;place to live&#8221;. How to host Microsoft InfoPath forms in SharePoint pages Infopath &#8211; Get the current user without writing code (the current user from SharePoint site, of course)]]></description>
			<content:encoded><![CDATA[<p>These two articles just made my day. At least, they made my intranet portal a much better &#8220;place to live&#8221;.</p>

<ul>
<li><a href="http://www.nickgrattan.net/Publications/How%20to%20Host%20Microsoft%20InfoPath%20Forms%20in%20SharePoint%20Pages.pdf" onclick="pageTracker._trackPageview('/outgoing/www.nickgrattan.net/Publications/How_20to_20Host_20Microsoft_20InfoPath_20Forms_20in_20SharePoint_20Pages.pdf?referer=');">How to host Microsoft InfoPath forms in SharePoint pages</a></li>
<li><a href="http://blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-_2D00_-Get-the-current-user-without-writing-code.aspx" onclick="pageTracker._trackPageview('/outgoing/blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-_2D00_-Get-the-current-user-without-writing-code.aspx?referer=');">Infopath &#8211; Get the current user without writing code</a> (the current user from SharePoint site, of course)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tips.naivist.net/2010/09/30/infopath-forms-in-sharepoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Document title in SharePoint&#8217;s &#8220;ECB&#8221; dropdown menu</title>
		<link>http://tips.naivist.net/2010/09/16/document-title-in-sharepoints-ecb-dropdown-menu/</link>
		<comments>http://tips.naivist.net/2010/09/16/document-title-in-sharepoints-ecb-dropdown-menu/#comments</comments>
		<pubDate>Thu, 16 Sep 2010 08:40:06 +0000</pubDate>
		<dc:creator>Krišs Rauhvargers</dc:creator>
				<category><![CDATA[.NET pasaule]]></category>
		<category><![CDATA[Datorlietas]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://tips.naivist.net/?p=169</guid>
		<description><![CDATA[Have you ever wondered why the SharePoint team decided to show only filename in dropdown menus, but not the title of the document? So when you save your file with an unreadable filename, it is displayed in your list and looks something like this (Historical note: it was not the case in SharePoint 2001. They [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wondered why the SharePoint team decided to show only filename in dropdown menus, but not the title of the document? So when you save your file with an <em>unreadable</em> filename, it is displayed in your list and looks something like this (Historical note: it was not the case in SharePoint 2001. They changed it in SPPS2003 and in 2007 versions. 2010. <a href="http://blah.winsmarts.com/2010-1-SharePoint_2010_lets_you_put_the_ECB_Menu_on_any_column.aspx" onclick="pageTracker._trackPageview('/outgoing/blah.winsmarts.com/2010-1-SharePoint_2010_lets_you_put_the_ECB_Menu_on_any_column.aspx?referer=');">has it fixed</a>):</p>

<p><img src="http://tips.naivist.net/wp-content/defaultecb.png" /></p>

<p>You can, of course, modify the &#8220;All Items&#8221; view and add the &#8220;Title&#8221; column, but it never has a link to the document, nor has it the fancy drop-down for editing (see the column &#8220;Title&#8221; in the picture).</p>

<p>So, I decided to dig into CAML schemas and to create a field which would display the title of the document <em>and</em> have the dropdown menu. To achieve that, one can use &#8220;computed fields&#8221; &#8211; fields which do not actually represent data editable by the user, but are only used for presentational purposes. Hence, one only has to define the <a href="http://msdn.microsoft.com/en-us/library/ms435494(v=office.12).aspx" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/ms435494_v=office.12_.aspx?referer=');"><code>DisplayPattern</code></a> of that field.<br />
There are two fields already built into SharePoint &#8211; the <code>_EditMenuTableStart</code> and <code>_EditMenuTableEnd</code>, which build the dropdown menu contents. What I had to add, was generation of the readable content. The most important part of the display pattern is this:</p>

<pre><code>&lt;IfEqual&gt;
  &lt;Expr1&gt;&lt;LookupColumn Name="Title" /&gt;&lt;/Expr1&gt;
 &lt;Expr2&gt;&lt;/Expr2&gt;
&lt;Then&gt;
     &lt;Field Name="FileLeafRef" /&gt;
 &lt;/Then&gt;
 &lt;Else&gt;
     &lt;Column HTMLEncode="FALSE" Name="Title" Default="(no title)" /&gt;
  &lt;/Else&gt;
&lt;/IfEqual&gt;
</code></pre>

<p>It compares the value of the <code>Title</code> column to an empty string. If this is the case (you have uploaded a document with no title or created a folder using Explorer view), it just shows <code>FileLeafRef</code> &#8211; the filename. Otherwise, it displays the value of the title field.</p>

<p>In my case I had an existing document library which I wanted to &#8220;fix&#8221;. Hence, I created a PowerShell script, which adds my field to the library. I used &#8220;<a href="http://msdn.microsoft.com/en-us/library/ms457586(v=office.12).aspx" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/ms457586_v=office.12_.aspx?referer=');">AddFieldAsXML()</a>&#8221; method of <code>SPList</code> object to inject my CAML code into sharepoint.</p>

<p>Now it looks like this:</p>

<p><img src="http://tips.naivist.net/wp-content/modfiedecb.png" /></p>

<p>You can dowload the whole script here: <a href="http://tips.naivist.net/wp-content/CreateTitleField1033.ps1_.txt">http://tips.naivist.net/wp-content/CreateTitleField1033.ps1_.txt</a>
Rename it to <code>.ps1</code> and run it <code>.\CreateTitleField1033.ps1 -url http://yourserver/sites/somesite/someweb -ListName "Your list"</code>. Then modify the view settings to display the field.</p>

<p>If you are developing your own list defintion, you can use the particular fragment in <code>schema.xml</code> and have your field defined in a regular fashion.</p>

<pre><code>param(
  [string] $url      =  "",
  [string] $ListName = ""
)

$sharepoint = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$site=[Microsoft.Sharepoint.SPSite]($url);
$web=$site.openweb();
$list= $web.lists[$ListName];

$schema =@"
    &lt;Field ID="{E2ABF8D3-6435-4773-A3D6-67508FEB7CF5}" ReadOnly="TRUE" 
             Type="Computed" 
             Name="KRItemLinkTitleDropdown" 
             DisplayName="Title" 
             DisplayNameSrcField="Title"
             AuthoringInfo="(dropdown displaying the title field)"
             EnableLookup="TRUE" 
             SourceID="http://schemas.microsoft.com/sharepoint/v3"
             StaticName="KRItemLinkTitleDropdown" FromBaseType="TRUE" ClassInfo="Menu"&gt;
         &lt;FieldRefs&gt;
          &lt;FieldRef Name="Title" /&gt;
          &lt;FieldRef Name="LinkTitleNoMenu" /&gt;
          &lt;FieldRef Name="FSObjType" /&gt;
        &lt;/FieldRefs&gt;
        &lt;DisplayPattern&gt;
           &lt;Field Name="_EditMenuTableStart" /&gt;
           &lt;HTML&gt;
           &lt;![CDATA[&lt;A onfocus="OnLink(this)" HREF="]]&gt;&lt;/HTML&gt;
       &lt;IfEqual&gt;
            &lt;Expr1&gt;
              &lt;LookupColumn Name="FSObjType" /&gt;
            &lt;/Expr1&gt;
            &lt;Expr2&gt;1&lt;/Expr2&gt;
            &lt;Then&gt;
                &lt;FieldSwitch&gt;
                &lt;Expr&gt;
                  &lt;GetVar Name="RecursiveView" /&gt;
                &lt;/Expr&gt;
                &lt;Case Value="1"&gt;
                  &lt;LookupColumn Name="FileLeafRef" HTMLEncode="TRUE" /&gt;
                &lt;/Case&gt;
                &lt;Default&gt;
                  &lt;SetVar Name="UnencodedFilterLink"&gt;
                    &lt;SetVar Name="RootFolder"&gt;&lt;HTML&gt;/&lt;/HTML&gt;
                      &lt;LookupColumn Name="FileRef" /&gt;
                    &lt;/SetVar&gt;
                    &lt;SetVar Name="FolderCTID"&gt;
                      &lt;FieldSwitch&gt;
                        &lt;Expr&gt;
                          &lt;ListProperty Select="EnableContentTypes" /&gt;
                        &lt;/Expr&gt;
                        &lt;Case Value="1"&gt;
                          &lt;Column Name="ContentTypeId" /&gt;
                        &lt;/Case&gt;
                      &lt;/FieldSwitch&gt;
                    &lt;/SetVar&gt;
                    &lt;FilterLink Default="" Paged="FALSE" /&gt;
                  &lt;/SetVar&gt;
                  &lt;GetVar Name="UnencodedFilterLink" HTMLEncode="TRUE" /&gt;
                &lt;/Default&gt;
              &lt;/FieldSwitch&gt;     
             &lt;/Then&gt;
            &lt;Else&gt;
                &lt;Field Name="ServerUrl" URLEncodeAsURL="TRUE" /&gt;
            &lt;/Else&gt;
            &lt;/IfEqual&gt;


       &lt;HTML&gt;&lt;![CDATA[" onclick="return DispEx(this,event,']]&gt;&lt;/HTML&gt;
                  &lt;ScriptQuote NotAddingQuote="TRUE"&gt;
                    &lt;ServerProperty Select="HtmlTransform" /&gt;
                  &lt;/ScriptQuote&gt;&lt;HTML&gt;&lt;![CDATA[',']]&gt;&lt;/HTML&gt;
                  &lt;ScriptQuote NotAddingQuote="TRUE"&gt;
                    &lt;ServerProperty Select="HtmlTrAcceptType"&gt;
                      &lt;Column Name="File_x0020_Type" /&gt;
                    &lt;/ServerProperty&gt;
                  &lt;/ScriptQuote&gt;&lt;HTML&gt;&lt;![CDATA[',']]&gt;&lt;/HTML&gt;
                  &lt;ScriptQuote NotAddingQuote="TRUE"&gt;
                    &lt;ServerProperty Select="HtmlTrHandleUrl"&gt;
                      &lt;Column Name="File_x0020_Type" /&gt;
                    &lt;/ServerProperty&gt;
                  &lt;/ScriptQuote&gt;&lt;HTML&gt;&lt;![CDATA[',']]&gt;&lt;/HTML&gt;
                  &lt;ScriptQuote NotAddingQuote="TRUE"&gt;
                    &lt;ServerProperty Select="HtmlTrProgId"&gt;
                      &lt;Column Name="File_x0020_Type" /&gt;
                    &lt;/ServerProperty&gt;
                  &lt;/ScriptQuote&gt;&lt;HTML&gt;&lt;![CDATA[',']]&gt;&lt;/HTML&gt;
                  &lt;ScriptQuote NotAddingQuote="TRUE"&gt;
                    &lt;ListProperty Select="DefaultItemOpen" /&gt;
                  &lt;/ScriptQuote&gt;&lt;HTML&gt;&lt;![CDATA[',']]&gt;&lt;/HTML&gt;
                  &lt;ScriptQuote NotAddingQuote="TRUE"&gt;
                    &lt;MapToControl&gt;
                      &lt;Column Name="HTML_x0020_File_x0020_Type" /&gt;&lt;HTML&gt;|&lt;/HTML&gt;
                      &lt;Column Name="File_x0020_Type" /&gt;
                    &lt;/MapToControl&gt;
                  &lt;/ScriptQuote&gt;&lt;HTML&gt;&lt;![CDATA[',']]&gt;&lt;/HTML&gt;
                  &lt;ScriptQuote NotAddingQuote="TRUE"&gt;
                    &lt;Column Name="HTML_x0020_File_x0020_Type" /&gt;
                  &lt;/ScriptQuote&gt;&lt;HTML&gt;&lt;![CDATA[',']]&gt;&lt;/HTML&gt;
                  &lt;ScriptQuote NotAddingQuote="TRUE"&gt;
                    &lt;ServerProperty Select="GetServerFileRedirect"&gt;
                      &lt;Field Name="ServerUrl" /&gt;&lt;HTML&gt;|&lt;/HTML&gt;
                      &lt;Column Name="HTML_x0020_File_x0020_Type" /&gt;
                    &lt;/ServerProperty&gt;
                  &lt;/ScriptQuote&gt;&lt;HTML&gt;&lt;![CDATA[',']]&gt;&lt;/HTML&gt;
                  &lt;ScriptQuote NotAddingQuote="TRUE"&gt;
                    &lt;Column Name="CheckoutUser" /&gt;
                  &lt;/ScriptQuote&gt;&lt;HTML&gt;&lt;![CDATA[',']]&gt;&lt;/HTML&gt;
                  &lt;ScriptQuote NotAddingQuote="TRUE"&gt;
                    &lt;UserID AllowAnonymous="TRUE" /&gt;
                  &lt;/ScriptQuote&gt;&lt;HTML&gt;&lt;![CDATA[',']]&gt;&lt;/HTML&gt;
                  &lt;ScriptQuote NotAddingQuote="TRUE"&gt;
                    &lt;ListProperty Select="ForceCheckout" /&gt;
                  &lt;/ScriptQuote&gt;&lt;HTML&gt;&lt;![CDATA[',']]&gt;&lt;/HTML&gt;
                  &lt;ScriptQuote NotAddingQuote="TRUE"&gt;
                    &lt;Field Name="IsCheckedoutToLocal" /&gt;
                  &lt;/ScriptQuote&gt;&lt;HTML&gt;&lt;![CDATA[',']]&gt;&lt;/HTML&gt;
                  &lt;ScriptQuote NotAddingQuote="TRUE"&gt;
                    &lt;Field Name="PermMask" /&gt;
                  &lt;/ScriptQuote&gt;&lt;HTML&gt;&lt;![CDATA[')"&gt;]]&gt;&lt;/HTML&gt;
                  &lt;UrlBaseName HTMLEncode="TRUE"&gt;
                  &lt;/UrlBaseName&gt;
                    &lt;IfEqual&gt;
                    &lt;Expr1&gt;
                      &lt;LookupColumn Name="Title" /&gt;
                    &lt;/Expr1&gt;
                    &lt;Expr2&gt;&lt;/Expr2&gt;
                    &lt;Then&gt;
                        &lt;Field Name="FileLeafRef" /&gt;
                     &lt;/Then&gt;
                    &lt;Else&gt;
                        &lt;Column HTMLEncode="FALSE" Name="Title" Default="(no title)" /&gt;
                    &lt;/Else&gt;
                    &lt;/IfEqual&gt;
                  &lt;IfEqual&gt;
                    &lt;Expr1&gt;
                      &lt;GetVar Name="ShowAccessibleIcon" /&gt;
                    &lt;/Expr1&gt;
                    &lt;Expr2&gt;1&lt;/Expr2&gt;
                    &lt;Then&gt;&lt;HTML&gt;&lt;![CDATA[&lt;img src="/_layouts/images/blank.gif" class="ms-hidden" border=0 width=1 height=1&gt;]]&gt;&lt;/HTML&gt;
                    &lt;/Then&gt;
                  &lt;/IfEqual&gt;&lt;HTML&gt;&lt;![CDATA[&lt;/A&gt;]]&gt;&lt;/HTML&gt;
                  &lt;IfNew Name="Created_x0020_Date"&gt;&lt;HTML&gt;&lt;![CDATA[&lt;IMG SRC="/_layouts/1033/images/new.gif" alt="New!"&gt;]]&gt;&lt;/HTML&gt;
                  &lt;/IfNew&gt;
                  &lt;Field Name="_EditMenuTableEnd" /&gt;
        &lt;/DisplayPattern&gt;
      &lt;/Field&gt;
"@
$fieldname = $list.fields.AddFieldAsXml($schema);
$list.update();
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://tips.naivist.net/2010/09/16/document-title-in-sharepoints-ecb-dropdown-menu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>String concatenation versus array.join() in JavaScript</title>
		<link>http://tips.naivist.net/2010/01/19/string-concatenation-versus-array-join-in-javascript/</link>
		<comments>http://tips.naivist.net/2010/01/19/string-concatenation-versus-array-join-in-javascript/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 14:46:12 +0000</pubDate>
		<dc:creator>Krišs Rauhvargers</dc:creator>
				<category><![CDATA[JScript]]></category>
		<category><![CDATA[Tīmeklis]]></category>

		<guid isPermaLink="false">http://tips.naivist.net/?p=154</guid>
		<description><![CDATA[To answer a question on StackOverflow, I made an experiment which actually qualifies for a separate blog post. So, I compared the speed of str1+str2 concatenation and array.push(str1, str2).join() methods. The code I used was quite simple: var iIterations =800000; var d1 = (new Date()).valueOf(); str1 = ""; for (var i = 0; i&#60;iIterations; i++) [...]]]></description>
			<content:encoded><![CDATA[<p>To answer a question on <a href="http://stackoverflow.com/questions/2087522/does-javascript-have-a-built-in-stringbuilder-class/2087538#2087538" onclick="pageTracker._trackPageview('/outgoing/stackoverflow.com/questions/2087522/does-javascript-have-a-built-in-stringbuilder-class/2087538_2087538?referer=');">StackOverflow</a>, I made an experiment which actually qualifies for a separate blog post.</p>

<p>So, I compared the speed of <code>str1+str2</code> concatenation  and <code>array.push(str1, str2).join()</code> methods.
The code I used was quite simple:</p>

<pre><code>var iIterations =800000;
var d1 = (new Date()).valueOf();
str1 = "";
for (var i = 0; i&lt;iIterations; i++) str1 = str1 + Math.random().toString();
var d2 = (new Date()).valueOf();
log("Time (strings): " + (d2-d1));

var d3 = (new Date()).valueOf();
arr1 = [];
for (var i = 0; i&lt;iIterations; i++)arr1.push(Math.random().toString());
var str2 = arr1.join("");
var d4 = (new Date()).valueOf();
log("Time (arrays): " + (d4-d3));
</code></pre>

<p>I tested it in IE8 and FireFox 3.5.5, both on a Windows 7 x64.</p>

<p>In the beginning I tested on small number of iterations (some hundred, some thousand items). The results were unpredictable (sometimes string concatenation took 0 milliseconds, sometimes it took 16 milliseconds, the same for array joining).</p>

<p>When I increased the count to 50&#8217;000, the results were different in different browsers &#8211; in IE the string concatenation was faster (94 milliseconds) and join was slower(125 milliseconds), while in Firefox the array join was faster (113 milliseconds) than string joining (117 milliseconds).</p>

<p>Then I increased the count to 500&#8217;000. Now the <code>array.join()</code> was <strong>slower than string concatenation</strong> in both browsers: string concat 937ms in IE, 1155 ms in Firefox, array join 1265 in IE, 1207 in Firefox.</p>

<p>Maximum iteration count I could test in IE without having &#8220;the script is taking too long to execute&#8221; was 850&#8217;000. Then IE was 1593 for string concatenation and 2046 for array join, Firefox had 2101 for string concatenation and 2249 for array join.</p>

<p><strong>Results</strong> &#8211; if the number of iterations is small, you can try to use <code>array.join()</code>, as it might be faster in Firefox. When the number increases, the <code>string1+string2</code> method is faster.</p>

<p>UPDATE<br />
I performed the test on IE6 (WindowsXP). The process stopped to respond immediately and never ended, if I tried the test on more than 100&#8217;000 iterations. 
On 40&#8217;000 iterations the results were </p>

<pre><code>Time (strings): 59175 ms
Time (arrays): 220 ms
</code></pre>

<p>This means &#8211; if you need to support IE6, choose <code>array.join()</code> which is way faster than string concatenation.</p>
]]></content:encoded>
			<wfw:commentRss>http://tips.naivist.net/2010/01/19/string-concatenation-versus-array-join-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restoring the top navigation bar of a SharePoint site</title>
		<link>http://tips.naivist.net/2009/12/01/restoring-the-top-navigation-bar-of-a-sharepoint-site/</link>
		<comments>http://tips.naivist.net/2009/12/01/restoring-the-top-navigation-bar-of-a-sharepoint-site/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 16:14:10 +0000</pubDate>
		<dc:creator>Krišs Rauhvargers</dc:creator>
				<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://tips.naivist.net/?p=149</guid>
		<description><![CDATA[It&#8217;s a known issue that if you delete the &#8220;Top Navigation&#8221; menu through the API in SharePoint 2007, you cannot restore it easily. I came across this problem in one of my development sites. When looking for a solution, I found this article, saying you have to do it through the database. The code below [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a known issue that if you delete the &#8220;Top Navigation&#8221; menu through the API in SharePoint 2007, you cannot restore it easily. I came across this problem in one of my development sites. When looking for a solution, I found <a href="http://statto1974.wordpress.com/2008/04/09/beware-of-deleting-global-navigation-nodes-in-spwebnavigationglobalnodes/" onclick="pageTracker._trackPageview('/outgoing/statto1974.wordpress.com/2008/04/09/beware-of-deleting-global-navigation-nodes-in-spwebnavigationglobalnodes/?referer=');">this article</a>, saying you have to do it through the database. </p>

<p>The code below solves the problem programmatically (and yes, it changes the database directly). Of course, it&#8217;s an unsupported solution &#8211; if you use it, you may get in trouble with Microsoft official support. 
<pre>
string sSiteUrl = "http://moss/sites/yoursite/";
//after the code gets executed, we have to dispose the 
//spweb object, since the Navigation object of the current SPWeb instance will contain wrong information
using (SPSite oSite = new SPSite(sSiteUrl))
{
    using (SPWeb oWeb = oSite.RootWeb)
    {
        //check if the top navigation bar is already there
        SPNavigationNode oTopnav = null;
        try
        {
            oTopnav = oWeb.Navigation.GetNodeById(1002);
        }
        catch (Exception)
        {
            oTopnav = null;
        }</p>

<pre><code>    if (oTopnav == null)
    {
        //we've found out there is no top navigation bar. Let's create one;

        //we create a temporary navigation node pointing back to web site root
        Microsoft.SharePoint.Navigation.SPNavigationNode oTempNode = new Microsoft.SharePoint.Navigation.SPNavigationNode("Navigation", oWeb.ServerRelativeUrl);
        //we add this node to the "global" collection (where quick launch and top nav bar normally live)
        oWeb.Navigation.GlobalNodes.AddAsLast(oTempNode);

        //now the dirty work - go to the database and change the ID of the navigation node
        System.Data.SqlClient.SqlConnection oConn = new System.Data.SqlClient.SqlConnection(oSite.ContentDatabase.DatabaseConnectionString);
        System.Data.SqlClient.SqlCommand oCmd = new System.Data.SqlClient.SqlCommand();
        oCmd.Connection = oConn;
        oCmd.CommandType = System.Data.CommandType.Text;
        //we only update the node which has the same ID as the one we just created, but, to be completely sure that 
        //nothing else gets changed, we add a requirement to have the same siteid and webid
        oCmd.CommandText = @"UPDATE NavNodes SET Eid=1002 WHERE (Eid=" + oTempNode.Id.ToString() + 
             @") AND (SiteId='" + oSite.ID.ToString("D") + "') AND (WebId='" + oWeb.ID.ToString("D") + "')"; ;
        oConn.Open();
        oCmd.ExecuteNonQuery();
        //closing the connection
        oConn.Dispose();
    }
}
</code></pre>

<p>}    //the oSite object is disposed here
</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://tips.naivist.net/2009/12/01/restoring-the-top-navigation-bar-of-a-sharepoint-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;_vti_bin&#8221; folder defined</title>
		<link>http://tips.naivist.net/2009/09/11/vtibin-folder-defined/</link>
		<comments>http://tips.naivist.net/2009/09/11/vtibin-folder-defined/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 11:34:28 +0000</pubDate>
		<dc:creator>Krišs Rauhvargers</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Tīmeklis]]></category>

		<guid isPermaLink="false">http://tips.naivist.net/?p=137</guid>
		<description><![CDATA[Ever wondered why SharePoint &#8220;lists web service&#8221; (i.e., lists.asmx) lives in an interesting address of http://mossserver/sites/somesite/&#95;vti&#95;bin/lists.asmx ? This is actually not the only place where you can see the magic &#95;vti&#95;something. I remember myself deleting such directories from &#8220;wwwroot&#8221; quite often back in the days &#8220;everyone&#8221; used MS FrontPage. FrontPage used to create the folders [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wondered why SharePoint &#8220;lists web service&#8221; (i.e., <em>lists.asmx</em>) lives in an interesting address of http://mossserver/sites/somesite/<strong>&#95;vti&#95;bin</strong>/lists.asmx ?</p>

<p>This is actually not the only place where you can see the magic &#95;vti&#95;<em>something</em>. I remember myself deleting such directories from &#8220;wwwroot&#8221; quite often back in the days &#8220;everyone&#8221; used MS FrontPage. FrontPage used to create the folders &#8220;&#95;vti&#95;bin&#8221;, &#8220;&#95;vti&#95;cnf&#8221; on your computer locally as you developed a website .. and also on the server, if you used &#8220;Frontpage Extensions&#8221; for publishing. The <em>&#95;bin</em> folder would normally contain executables required for FP server components (as far as I understand, something like <em>cgi&#95;bin</em>).</p>

<p>So, even though FP is <a href="http://office.microsoft.com/en-us/frontpage/HA101205221033.aspx" onclick="pageTracker._trackPageview('/outgoing/office.microsoft.com/en-us/frontpage/HA101205221033.aspx?referer=');">announced dead</a>, guys from the SharePoint team apparently like the idea of puting executables in the <em>&#95;vti&#95;bin</em> folder which was used by FrontPage Extensions. </p>

<p>Anyway, the question is, what does the acronym &#8220;VTI&#8221; mean. Apparently, Microsoft did not develop MS FrontPage from scratch, they <a href="http://www.seoconsultants.com/frontpage/history/" onclick="pageTracker._trackPageview('/outgoing/www.seoconsultants.com/frontpage/history/?referer=');">acquired</a> &#8220;<strong>V</strong>ermeer <strong>T</strong>echnologies <strong>I</strong>nc&#8221;. Thus the name of &#8220;bin&#8221; folder in FrontPage. Thus the URL for <em>lists.asmx</em> in SharePoint. </p>
]]></content:encoded>
			<wfw:commentRss>http://tips.naivist.net/2009/09/11/vtibin-folder-defined/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shooting yourself in the foot</title>
		<link>http://tips.naivist.net/2008/10/08/shooting-yourself-in-the-foot/</link>
		<comments>http://tips.naivist.net/2008/10/08/shooting-yourself-in-the-foot/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 18:26:07 +0000</pubDate>
		<dc:creator>Krišs Rauhvargers</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tips.naivist.net/?p=133</guid>
		<description><![CDATA[Ideja no &#8220;labās prakses&#8221; prezentācijas C: You shoot yourself in the foot PHP: You shoot yourself in the foot with a gun made from pieces taken from 300 other guns Ruby on Rails: You want to shoot yourself in the foot, but the convention is to shoot yourself in the head (pievienošu no sevis) SharePoint: [...]]]></description>
			<content:encoded><![CDATA[<p>Ideja no <a href="http://laurat.blogs.com/talks/best_practices.pdf" onclick="pageTracker._trackPageview('/outgoing/laurat.blogs.com/talks/best_practices.pdf?referer=');">&#8220;labās prakses&#8221; prezentācijas</a></p>

<ul>
<li>C: You shoot yourself in the foot</li>
<li>PHP: You shoot yourself in the foot with a gun made from pieces taken from 300 other guns</li>
<li>Ruby on Rails: You want to shoot yourself in the foot, but the convention is to shoot yourself in the head</li>
</ul>

<p>(pievienošu no sevis)</p>

<ul>
<li>SharePoint: You want to shoot yourself in the foot, but first you have to &#8220;IISRESET /noforce&#8221;</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tips.naivist.net/2008/10/08/shooting-yourself-in-the-foot/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MOSS &amp; custom master pages</title>
		<link>http://tips.naivist.net/2008/08/05/moss-custom-master/</link>
		<comments>http://tips.naivist.net/2008/08/05/moss-custom-master/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 07:19:22 +0000</pubDate>
		<dc:creator>Krišs Rauhvargers</dc:creator>
				<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://tips.naivist.net/?p=128</guid>
		<description><![CDATA[I just found an interesting &#8220;feature&#8221; in MOSS publishing infrastructure. We&#8217;re designing a custom master page for our MOSS portal solution. If I recall correctly, we started with Heather Solomon&#8217;s minimal master page, but I&#8217;m not really sure. We swiped out all of the built-in styles and layouts to achieve maximum flexibility and stylability of [...]]]></description>
			<content:encoded><![CDATA[<p>I just found an interesting &#8220;feature&#8221; in MOSS publishing infrastructure. We&#8217;re designing a custom master page for our MOSS portal solution. If I recall correctly, we started with Heather Solomon&#8217;s <em><a href="http://www.heathersolomon.com/blog/archive/2007/01/26/6153.aspx" onclick="pageTracker._trackPageview('/outgoing/www.heathersolomon.com/blog/archive/2007/01/26/6153.aspx?referer=');">minimal</a></em> master page, but I&#8217;m not really sure.</p>

<p>We swiped out all of the built-in styles and layouts to achieve maximum flexibility and stylability of MOSS infrastructure. I believe this is the best choice when you have to adapt your portal to custom tailored design layout.</p>

<p>Well, the result was, the portal worked fine with our master page, BUT the content query web part failed. It failed every time we enabled the RSS feed feature. Instead of seeing the actual content, it showed only an error message (in Latvian, since we&#8217;re using the latvian language pack) &#8220;Šo Web daļu nevar parādīt. Lai novērstu problēmu, atveriet šo Web lapu ar Windows SharePoint Services saderīgā HTML redaktorā, piemēram, Microsoft Office SharePoint Designer. Ja problēma netiek novērsta, sazinieties ar Web servera administratoru.&#8221;</p>

<p>No traces could be found in the ULS log nor in the event log of the server. After setting the diagnostic logging of all categories to <em>verbose</em>, finally an exception was written to the logfile:</p>

<pre><code> Error while executing web part: System.Xml.Xsl.XslTransformException: An error occurred during a
 call to extension function 'RegisterFeedUrl'. See InnerException for a complete description of the error. ---&gt; 
 System.Web.HttpException: The control collection cannot be modified during DataBind, 
 Init, Load, PreRender or Unload phases.     at System.Web.UI.ControlCollection.Add(Control 
 child)     at Microsoft.SharePoint.Publishing.WebControls.WebPartRuntime.RegisterFeedUrl(String url, String type)    
 --- End of inner exception stack trace ---     at ....
</code></pre>

<p>When looking at the RegisterFeedUrl in .Net Reflector, we found out that the code actually accesses the <em>Header</em> property of the <em>Page</em> object that is being rendered and adds HtmlLink control to the collection. It gave us a hint that probably there is something wrong with the <em>page</em> and <em>header</em> objects. And &#8211; yes, we had left out the <code>runat="server"</code> part of the HTML and HEAD tags.  So, this is the absolute minimum you must have:</p>

<pre><code>&lt;HTML runat="server"&gt;
    &lt;HEAD runat="server"&gt;
....
</code></pre>

<p>.. and, of course, the name space references and other stuff you usually put in the HTML element tag.</p>
]]></content:encoded>
			<wfw:commentRss>http://tips.naivist.net/2008/08/05/moss-custom-master/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Closed or open?</title>
		<link>http://tips.naivist.net/2008/06/08/closed-or-open/</link>
		<comments>http://tips.naivist.net/2008/06/08/closed-or-open/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 16:10:36 +0000</pubDate>
		<dc:creator>Krišs Rauhvargers</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tips.naivist.net/?p=127</guid>
		<description><![CDATA[No šiem abiem vismaz man mazliet skaidrāks kļuva, ko viņi saprot ar &#8220;open world approach&#8221;. Un, ka man to vajag. http://www.cs.man.ac.uk/~drummond/presentations/OWA.pdf http://www.betaversion.org/~stefano/linotype/news/91/]]></description>
			<content:encoded><![CDATA[<p>No šiem abiem vismaz man mazliet skaidrāks kļuva, ko <em>viņi</em> saprot ar &#8220;open world approach&#8221;. Un, ka man to vajag.<br />
<a href="http://www.cs.man.ac.uk/~drummond/presentations/OWA.pdf" onclick="pageTracker._trackPageview('/outgoing/www.cs.man.ac.uk/_drummond/presentations/OWA.pdf?referer=');">http://www.cs.man.ac.uk/~drummond/presentations/OWA.pdf</a><br />
<a href="http://www.betaversion.org/~stefano/linotype/news/91/" onclick="pageTracker._trackPageview('/outgoing/www.betaversion.org/_stefano/linotype/news/91/?referer=');">http://www.betaversion.org/~stefano/linotype/news/91/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tips.naivist.net/2008/06/08/closed-or-open/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

