<?xml version="1.0" encoding="utf-8"?>
<KScriptSetting>
  <Name>TextContentRepository</Name>
  <Description>The text content repository</Description>
  <Example>

    <![CDATA[
<script engine="kscript"> 
    var list= k.site.textContents.all();  
</script>
<div k-foreach="item list">
    <h2 k-content="item.title">Welcome!</h2> 
     <h4 k-content="item.userkey">Welcome!</h4> 
</div>
	]]>

  </Example>
  <Props />
  <Methods>
    <Method>
      <Name>get</Name>
      <Description>Get a text content object based on Id or UserKey</Description>
      <Example>
        <![CDATA[
        <script engine="kscript">
          var item = k.site.textContents.get("titletwo");
        </script>

        <div>
          <h2 k-content="item.title">Welcome!</h2>
          <p k-content="item.age">Welcome to Kooboo CMS</p>
          <p k-content="item.userkey">Welcome to Kooboo CMS</p>
        </div>
	]]>
      </Example>
      <Params>
        <Param>
          <Name>nameorid</Name>
          <Description>The userkey or id of target content</Description>
          <Type>string</Type>
        </Param>
      </Params>
      <ReturnType>TextContentObject</ReturnType>
    </Method>
    <Method>
      <Name>all</Name>
      <Description>Return an array of all TextContentObjects</Description>
      <Example>

        <![CDATA[
   <script engine="kscript"> 
    var list= k.site.textContents.all();  
</script>
<div k-foreach="item list">
    <h2 k-content="item.title">Welcome!</h2> 
     <h4 k-content="item.userkey">Welcome!</h4> 
</div>
	]]>

      </Example>

      <ReturnType>TextContentObject</ReturnType>
    </Method>

    <Method>
      <Name>findAll</Name>
      <Description>Return an array of all matched TextContentObjects</Description>
      <Example>
        <![CDATA[
<script engine="kscript"> 
    var all = k.site.textContents.findAll("age>10");   
</script>

<div k-foreach="item all">
    <h2 k-content="item.title">Welcome!</h2>
    <p k-content="item.age">Welcome to Kooboo CMS</p> 
</div>
	]]>

      </Example>

      <Params>
        <Param>
          <Name>searchCondition</Name>
          <Description>The Query syntax string</Description>
          <Type>Query</Type>
        </Param>
      </Params>
      <ReturnType>TextContentObject</ReturnType>
    </Method>

    <Method>
      <Name>find</Name>
      <Description>Return the first TextContentObject based on search condition</Description>
      <Example>
        <![CDATA[
 <script engine="kscript"> 
    var item = k.site.textContents.find("age==12"); 
</script>

<div>
    <h2 k-content="item.title">Welcome!</h2>
    <p k-content="item.age">Welcome to Kooboo CMS</p> 
</div>
	]]>

      </Example>

      <Params>
        <Param>
          <Name>searchCondition</Name>
          <Description>The Query syntax string</Description>
          <Type>Query</Type>
        </Param>
      </Params>
      <ReturnType>TextContentObject</ReturnType>
    </Method>

    <Method>
      <Name>query</Name>
      <Description>Query the content repository with fluent API</Description>
      <Example>
        <![CDATA[
 <script engine="kscript"> 
    var all = k.site.textContents.query("age>4").OrderByDesc("age").skip(1).take(6);   
</script>

<div k-foreach="item all">
    <h2 k-content="item.title">Welcome!</h2>
    <p k-content="item.age">Welcome to Kooboo CMS</p> 
</div>
        ]]>
      </Example>
      <Params>
        <Param>
          <Name>searchCondition</Name>
          <Description>The search query</Description>
          <Type>Query</Type>
        </Param>
      </Params>
      <ReturnType>ContentQuery</ReturnType>
    </Method>


    <Method>
      <Name>add</Name>
      <Description>Add a text content into content repository. Folder is a required.</Description>
      <Example>
        <![CDATA[
        <script engine="kscript"> 
        var obj = {fieldone: "value one", fieldtwo: "value two"};
        obj.folder = "blogfolder"; 
        k.site.textContents.add(obj); 
        </script>
		]]>
      </Example>
      <Params>
        <Param>
          <Name>value</Name>
          <Description>value</Description>
          <Type>object</Type>
        </Param>
      </Params>
      <ReturnType>null</ReturnType>
    </Method>

    <Method>
      <Name>update</Name>
      <Description>update a text content values</Description>
      <Example>
        <![CDATA[
        <script engine="kscript">
          var item = k.site.textContents.get("titletwo");
          item.title = "new value"; 
          k.site.textContents.update(item);           
        </script> 
	]]>
      </Example>
      <Params>
        <Param>
          <Name>value</Name>
          <Description>TextConentObject from repository</Description>
          <Type>TextContentObject</Type>
        </Param>
      </Params>
      <ReturnType>null</ReturnType>
    </Method>

    <Method>
      <Name>delete</Name>
      <Description>Delete an item  based on id or userkey</Description>
      <Example>

        <![CDATA[
        <script engine="kscript">
         k.site.textContents.delete("userkey"); 
        </script> 
	]]>
      </Example>
      <Params>
        <Param>
          <Name>id</Name>
          <Description>Id or UserKey</Description>
          <Type>string</Type>
        </Param>
      </Params>
    </Method>

  </Methods>
</KScriptSetting>