diff options
Diffstat (limited to 'js/dojo/dojox/data/demos')
65 files changed, 3702 insertions, 0 deletions
diff --git a/js/dojo/dojox/data/demos/GoogleFeedTemplate.html b/js/dojo/dojox/data/demos/GoogleFeedTemplate.html new file mode 100644 index 0000000..2d18fca --- /dev/null +++ b/js/dojo/dojox/data/demos/GoogleFeedTemplate.html @@ -0,0 +1,26 @@ +{% load dojox.dtl.contrib.data %} +{% bind_data items to store as google %} +<ul> +{% for item in google %} +<li class="search-result"> + <div> + <a href="{{item.link}}">{{item.title}}</a> + <div style="display:none" class="content"> + <h2>{{item.title}}</h2> + {{item.content}} + </div> + </div> + <div class="summary"> + {{item.summary}} + </div> + <div class="tags"> + <!--{% if item.categories %}--> + Tags: + <!--{% for cat in item.categories %}--> + {{cat}} + <!--{% endfor %}--> + <!--{% endif %}--> + </div> +</li> +{% endfor %} +</ul>
\ No newline at end of file diff --git a/js/dojo/dojox/data/demos/GoogleTemplate.html b/js/dojo/dojox/data/demos/GoogleTemplate.html new file mode 100644 index 0000000..a87d107 --- /dev/null +++ b/js/dojo/dojox/data/demos/GoogleTemplate.html @@ -0,0 +1,7 @@ +{% load dojox.dtl.contrib.data %} +{% bind_data items to store as google %} +{% for item in google %} +<span class="search-result"> + <a href="{{item.unescapedUrl}}">{{item.titleNoFormatting}}</a> +</span> +{% endfor %} diff --git a/js/dojo/dojox/data/demos/GoogleTemplateBlog.html b/js/dojo/dojox/data/demos/GoogleTemplateBlog.html new file mode 100644 index 0000000..4d67548 --- /dev/null +++ b/js/dojo/dojox/data/demos/GoogleTemplateBlog.html @@ -0,0 +1,7 @@ +{% load dojox.dtl.contrib.data %} +{% bind_data items to store as google %} +{% for item in google %} +<span class="search-result"> + <a href="{{item.postUrl}}">{{item.titleNoFormatting}}</a> +</span> +{% endfor %} diff --git a/js/dojo/dojox/data/demos/GoogleTemplateImage.html b/js/dojo/dojox/data/demos/GoogleTemplateImage.html new file mode 100644 index 0000000..37088d8 --- /dev/null +++ b/js/dojo/dojox/data/demos/GoogleTemplateImage.html @@ -0,0 +1,7 @@ +{% load dojox.dtl.contrib.data %} +{% bind_data items to store as google %} +{% for item in google %} +<span class="search-result"> + <a href="{{item.unescapedUrl}}"><img src="{{item.tbUrl}}" alt="{{item.contentNoFormatting}}"></a> +</span> +{% endfor %} diff --git a/js/dojo/dojox/data/demos/GoogleTemplateLocal.html b/js/dojo/dojox/data/demos/GoogleTemplateLocal.html new file mode 100644 index 0000000..da37f90 --- /dev/null +++ b/js/dojo/dojox/data/demos/GoogleTemplateLocal.html @@ -0,0 +1,7 @@ +{% load dojox.dtl.contrib.data %} +{% bind_data items to store as google %} +{% for item in google %} +<span class="search-result"> + <a href="{{item.url}}"><img src="{{item.staticMapUrl}}"></a> +</span> +{% endfor %} diff --git a/js/dojo/dojox/data/demos/GoogleTemplateVideo.html b/js/dojo/dojox/data/demos/GoogleTemplateVideo.html new file mode 100644 index 0000000..0600db0 --- /dev/null +++ b/js/dojo/dojox/data/demos/GoogleTemplateVideo.html @@ -0,0 +1,7 @@ +{% load dojox.dtl.contrib.data %} +{% bind_data items to store as google %} +{% for item in google %} +<span class="search-result"> + <a href="{{item.url}}"><img src="{{item.tbUrl}}" width="100" height="75"></a> +</span> +{% endfor %} diff --git a/js/dojo/dojox/data/demos/demo_CssStores_combo_tree_grid.html b/js/dojo/dojox/data/demos/demo_CssStores_combo_tree_grid.html new file mode 100644 index 0000000..22cf65a --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_CssStores_combo_tree_grid.html @@ -0,0 +1,94 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<!-- + Demo application showing The CssClassStore. +--> +<html> +<head> + <title>Demo: dojox.data.CssClassStore</title> + <style type="text/css"> + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + @import "../../grid/resources/tundraGrid.css"; + </style> + + <!-- + The following script tag instantiates the dojo library and sets some basic properties. In this case, the application + is told that debug mode is off, and to parse all dojoType widgets when it has fully loaded. + --> + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: false, parseOnLoad: true"></script> + <script> + dojo.require("dijit.Tree"); + dojo.require("dijit.tree.ForestStoreModel"); + dojo.require("dijit.form.ComboBox"); + dojo.require("dojox.data.CssRuleStore"); + dojo.require("dojox.data.CssClassStore"); + dojo.require("dojox.grid.DataGrid"); + + var layoutCss = [ + [ + { field: "selector", name: "Selector", width: 20 }, + { field: "parentStyleSheetHref", name: "StyleSheet", width: 20 }, + { field: "cssText", name: "CSS", width: 'auto' } + ] + ]; + + function init() { + var combo = dijit.byId("classCombo"); + var grid = dijit.byId("cssGrid"); + + function requery() { + var val = combo.getValue(); + val = "." + val; + var query = { + selector: "*" + val + "*" + } + grid.filter(query,true); + } + dojo.connect(combo, "onChange", requery); + } + dojo.addOnLoad(init); + + </script> +</head> + +<body class="tundra"> + <h1> + Demo: Demo of using the Css Stores to browse the loaded CSS classes and associated rules. + </h1> + <p>This demo demonstrates hooking up the Css*Stores to the various digit widgets to browse the Css loaded for the page.</p> + <hr> + + <div dojoType="dojox.data.CssRuleStore" jsId="ruleStore"></div> + <div dojoType="dojox.data.CssClassStore" jsId="classStore"></div> + + + <div dojoType="dijit.tree.ForestStoreModel" + jsId="classModel" + store="classStore" + query="{}" + rootId="Loaded Classes" + rootLabel="Loaded Classes" + childrenAttrs="children"> + </div> + + <h2>dojox.data.CssClassStore connected to ComboBox and querying on classSans:</h2> + <div id="classCombo" dojoType="dijit.form.ComboBox" store="classStore" searchAttr="classSans"></div> + + <h2>dojox.data.CssRuleStore:</h2> + <i>Displays the list of CSS rules filtered by the class selected in the ComboBox.</i> + <div id="cssGrid" + jsId="cssGrid" + dojoType="dojox.grid.DataGrid" + query="{}" + rowsPerPage="20" + store="ruleStore" + structure="layoutCss" + style="width: 100%; height: 400px;"> + </div> + + <h2>dojox.data.CssClassStore connected to Tree:</h2> + <span id="tree" dojoType="dijit.Tree" model="classModel"> </span> + <hr> +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_DataDemoTable.html b/js/dojo/dojox/data/demos/demo_DataDemoTable.html new file mode 100644 index 0000000..9c594c1 --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_DataDemoTable.html @@ -0,0 +1,143 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <title>Dojo Visual Loader Test</title> + <style type="text/css"> + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dijit/themes/dijit.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + + .oddRow { background-color: #f2f5f9; } + .population { text-align: right; } + </style> + + <script type="text/javascript" src="../../../dojo/dojo.js" + djConfig="isDebug: false, parseOnLoad: true"></script> + <script type="text/javascript"> + dojo.require("dijit.dijit"); + dojo.require("dojo.parser"); + dojo.require("dijit.Declaration"); + dojo.require("dojo.data.ItemFileReadStore"); + dojo.require("dojox.data.FlickrStore"); + </script> +</head> +<body class="tundra"> + <span dojoType="dojo.data.ItemFileReadStore" + jsId="continentStore" + url="../../../dijit/tests/_data/countries.json"></span> + <span dojoType="dojox.data.FlickrStore" jsId="flickrStore"></span> + + + <h1 class="testTitle">Dojox Data Demo Table</h1> + + <table dojoType="dijit.Declaration" + widgetClass="demo.Table" class="dojoTabular" + defaults="{ store: null, query: { query: { name: '*' } }, columns: [ { name: 'Name', attribute: 'name' } ] }"> + <thead dojoAttachPoint="head"> + <tr dojoAttachPoint="headRow"></tr> + </thead> + <tbody dojoAttachPoint="body"> + <tr dojoAttachPoint="row"> + </tr> + </tbody> + + <script type="dojo/method"> + dojo.forEach(this.columns, function(item, idx){ + var icn = item.className||""; + // add a header for each column + var tth = document.createElement("th"); + tth.innerHTML = item.name; + tth.className = icn; + dojo.connect(tth, "onclick", dojo.hitch(this, "onSort", idx)); + this.headRow.appendChild(tth); + + // and fill in the column cell in the template row + this.row.appendChild(document.createElement("td")); + this.row.lastChild.className = icn; + }, this); + this.runQuery(); + </script> + <script type="dojo/method" event="onSort" args="index"> + var ca = this.columns[index].attribute; + var qs = this.query.sort; + // clobber an existing sort arrow + dojo.query("> th", this.headRow).style("background", "").style("paddingRight", ""); + if(qs && qs[0].attribute == ca){ + qs[0].descending = !qs[0].descending; + }else{ + this.query.sort = [{ + attribute: ca, + descending: false + }]; + } + var th = dojo.query("> th", this.headRow)[index]; + th.style.paddingRight = "16px"; // space for the sort arrow + th.style.background = "url(\""+require.toUrl("dijit/themes/tundra/images/arrow"+(this.query.sort[0].descending ? "Up" : "Down")+((dojo.isIE == 6) ? ".gif" : ".png")) + "\") no-repeat 98% 4px"; + this.runQuery(); + </script> + <script type="dojo/method" event="runQuery"> + this.query.onBegin = dojo.hitch(this, function(){ dojo.query("tr", this.body).orphan(); }); + this.query.onItem = dojo.hitch(this, "onItem"); + this.query.onComplete = dojo.hitch(this, function(){ + dojo.query("tr:nth-child(odd)", this.body).addClass("oddRow"); + dojo.query("tr:nth-child(even)", this.body).removeClass("oddRow"); + }); + this.store.fetch(this.query); + </script> + <script type="dojo/method" event="onItem" args="item"> + var tr = this.row.cloneNode(true); + dojo.query("td", tr).forEach(function(n, i, a){ + var tc = this.columns[i]; + var tv = this.store.getValue(item, tc.attribute)||""; + if(tc.format){ tv = tc.format(tv, item, this.store); } + n.innerHTML = tv; + }, this); + this.body.appendChild(tr); + </script> + </table> + + <span dojoType="demo.Table" store="continentStore" + query="{ query: { type: 'country' }, sort: [ { attribute: 'name', descending: true } ] }" + id="foo"> + <script type="dojo/method" event="preamble"> + this.columns = [ + { name: "Name", attribute: "name" }, + { name: "Population", + attribute: "population", + className: "population" + } + ]; + </script> + </span> + <span dojoType="demo.Table" store="continentStore" + query="{ query: { name: 'A*' } }"></span> + <span dojoType="demo.Table" store="flickrStore" + query="{ query: { groupid: '27475260@N00' } }"> + <script type="dojo/method" event="preamble"> + this.columns = [ + { name: "", attribute: "imageUrlSmall", + format: function(value, item, store){ + return (value.length) ? "<img src='"+value+"'>" : ""; + } + }, + { name: "Title", attribute: "title" } + ]; + </script> + </span> + <span dojoType="demo.Table" store="flickrStore" + query="{ query: { tags: 'dojotoolkit' } }"> + <script type="dojo/method" event="preamble"> + this.columns = [ + { name: "", attribute: "imageUrlSmall", + format: function(value, item, store){ + return (value.length) ? "<img src='"+value+"'>" : ""; + } + }, + { name: "Title", attribute: "title" } + ]; + </script> + </span> +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_FileStore_dojotree.html b/js/dojo/dojox/data/demos/demo_FileStore_dojotree.html new file mode 100644 index 0000000..e134361 --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_FileStore_dojotree.html @@ -0,0 +1,119 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<!-- + Demo application showing LazyLoading File store. +--> +<html> +<head> + <title>Demo: dojox.data.FileStore</title> + <style type="text/css"> + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + + .fileView { + margin: 5px; + width: 100%; + + } + .fileView .fileViewTitle{ + color: white; + background-color: black; + font-size: larger; + font-weight: bold; + + } + + .fileView .fileViewTable { + border-width: 2px; + border-style: solid; + width: 100%; + } + + .fileView .fileViewTable tr td { + border-width: 1px; + border-style: solid; + border-color: lightgray; + width: 50%; + vertical-align: top; + } + + .fileView .fileName { + background-color: lightgray; + } + + </style> + + <!-- + The following script tag instantiates the dojo library and sets some basic properties. In this case, the application + is told that debug mode is off, and to parse all dojoType widgets when it has fully loaded. + --> + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: false, parseOnLoad: true, useCommentedJson: true"></script> + <script> + dojo.require("dijit.Tree"); + dojo.require("dijit.tree.ForestStoreModel"); + dojo.require("dojox.data.FileStore"); + dojo.require("dojox.data.demos.widgets.FileView"); + </script> +</head> + +<body class="tundra"> + <h1> + Demo: Lazy Loading File Browsing Store + </h1> + <p>The tree below uses the dojox.data.FileStore and a PHP implementation for the serverside to browse the dojo tree hierarchy in a lazy-load fashion.</p> + <p><i><b>This demo must be run from a web-server with PHP support enabled. Without PHP support, this demo cannot function. The Demo also requires PHP + support for json_encode and json_decode. Please be sure to have those packages installed in your PHP environment.</b></i></p> + <hr> + <i>Clicking on a file in the tree will display the details about that file.</i> + <div dojoType="dojox.data.FileStore" url="stores/filestore_dojotree.php" jsId="fileStore" pathAsQueryParam="true"></div> + <div dojoType="dijit.tree.ForestStoreModel" jsId="fileModel" + store="fileStore" query="{}" + rootId="DojoFiles" rootLabel="Dojo Files" childrenAttrs="children"></div> + + <table style="width: 100%;"> + <tbody> + <tr style="width: 100%;"> + <td style="width: 50%; vertical-align: top;"> + <span id="tree" dojoType="dijit.Tree" model="fileModel" > + <script type="dojo/method" event="onClick" args="item"> + if (fileStore.isItem(item)){ + var attachPt = dojo.byId("fileInfo"); + if (attachPt) { + while(attachPt.firstChild) { + attachPt.removeChild(attachPt.firstChild); + } + var newArgs = {}; + newArgs.name = fileStore.getValue(item, "name"); + newArgs.path = fileStore.getValue(item, "path"); + newArgs.size = fileStore.getValue(item, "size"); + newArgs.directory = fileStore.getValue(item, "directory"); + newArgs.parentDir = fileStore.getValue(item, "parentDir"); + var children = fileStore.getValues(item, "children"); + if (children && children.length > 0) { + newArgs.children = []; + var i; + for (i = 0; i < children.length; i++) { + //Note here that even though the store is lazy-loading, the unloaded items for children still + //have the 'name' attribute, since it is used as part of the info to load the full item. Generally + //you should not access properties of an item that has not been fully inflated yet. It just works + //well in this case for this store. + newArgs.children.push(fileStore.getValue(children[i], "name")); + } + } + var fInfo = new dojox.data.demos.widgets.FileView(newArgs); + attachPt.appendChild(fInfo.domNode); + fInfo.startup(); + } + } + </script> + </span> + </td> + <td id="fileInfo" STYLE="width: 50%; vertical-align: top;"> + </td> + </tr> + + </tbody> + </table> + <hr> +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_FileStore_dojoxdata_combo_grid.html b/js/dojo/dojox/data/demos/demo_FileStore_dojoxdata_combo_grid.html new file mode 100644 index 0000000..c4eae5a --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_FileStore_dojoxdata_combo_grid.html @@ -0,0 +1,157 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<!-- + Demo application showing LazyLoading File store. +--> +<html> +<head> + <title>Demo: dojox.data.FileStore</title> + <style type="text/css"> + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + @import "../../../dojox/grid/resources/tundraGrid.css"; + + .fileView { + margin: 5px; + width: 100%; + + } + .fileView .fileViewTitle{ + color: white; + background-color: black; + font-size: larger; + font-weight: bold; + + } + + .fileView .fileViewTable { + border-width: 2px; + border-style: solid; + width: 100%; + } + + .fileView .fileViewTable tr td { + border-width: 1px; + border-style: solid; + border-color: lightgray; + width: 50%; + vertical-align: top; + } + + .fileView .fileName { + background-color: lightgray; + } + + .tundra .dojoxGrid-cell { + text-indent: 3px; + } + </style> + + <!-- + The following script tag instantiates the dojo library and sets some basic properties. In this case, the application + is told that debug mode is off, and to parse all dojoType widgets when it has fully loaded. + --> + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: false, parseOnLoad: true, useCommentedJson: true"></script> + <script> + dojo.require("dijit.Tree"); + dojo.require("dijit.tree.ForestStoreModel"); + dojo.require("dijit.form.ComboBox"); + dojo.require("dojox.data.FileStore"); + dojo.require("dojox.grid.DataGrid"); + dojo.require("dojox.data.demos.widgets.FileView"); + + var layoutFiles = [ + [ + { field: "name", name: "Filename", width: 20 }, + { field: "size", name: "File Size (bytes)", width: 10 }, + { field: "directory", name: "Is Directory", width: 10 }, + { field: "path", name: "Path", width: 'auto' } + ] + ]; + + </script> +</head> + +<body class="tundra"> + <h1> + Demo: Lazy Loading File Browsing Store connected to multiple widgets + </h1> + <p>All the widgets used in this demo connect to the same filestore instance. It is talking to a filestore rooted in the dojox/data/ sub-directory to make it fast handling when querying across all files.</p> + <p><i><b>This demo must be run from a web-server with PHP support enabled. Without PHP support, this demo cannot function. The Demo also requires PHP + support for json_encode and json_decode. Please be sure to have those packages installed in your PHP environment.</b></i></p> + <hr> + + <div dojoType="dojox.data.FileStore" url="stores/filestore_dojoxdata.php" jsId="fileStore" pathAsQueryParam="true"></div> + <div dojoType="dijit.tree.ForestStoreModel" jsId="fileModel" + store="fileStore" query="{}" + rootId="./dojox/data" rootLabel="./dojox/data" childrenAttrs="children"></div> + + + <h2>dojox.data.FileStore connected to ComboBox and querying on path:</h2> + <div dojoType="dijit.form.ComboBox" store="fileStore" searchAttr="path" value="./demos"></div> + + + <h2>dojox.data.FileStore connected to Grid and displaying all files:</h2> + <div style="width: 100%; height: 300px;"> + <div id="grid" + dojoType="dojox.grid.DataGrid" + store="fileStore" + structure="layoutFiles" + queryOptions="{deep:true}" + query="{}" + sortFields="[{'attribute':'path', 'descending': false}]" + rowsPerPage="40"> + + </div> + </div> + + + <h2>dojox.data.FileStore connected to Tree:</h2> + <i>Clicking on a file in the tree will display the details about that file.</i> + <table style="width: 100%;"> + <tbody> + <tr style="width: 100%;"> + <td style="width: 50%; vertical-align: top;"> + <span id="tree" dojoType="dijit.Tree" model="fileModel"> + <script type="dojo/method" event="onClick" args="item"> + if (fileStore.isItem(item)){ + var attachPt = dojo.byId("fileInfo"); + if (attachPt) { + while(attachPt.firstChild) { + attachPt.removeChild(attachPt.firstChild); + } + var newArgs = {}; + newArgs.name = fileStore.getValue(item, "name"); + newArgs.path = fileStore.getValue(item, "path"); + newArgs.size = fileStore.getValue(item, "size"); + newArgs.directory = fileStore.getValue(item, "directory"); + newArgs.parentDir = fileStore.getValue(item, "parentDir"); + var children = fileStore.getValues(item, "children"); + if (children && children.length > 0) { + newArgs.children = []; + var i; + for (i = 0; i < children.length; i++) { + //Note here that even though the store is lazy-loading, the unloaded items for children still + //have the 'name' attribute, since it is used as part of the info to load the full item. Generally + //you should not access properties of an item that has not been fully inflated yet. It just works + //well in this case for this store. + newArgs.children.push(fileStore.getValue(children[i], "name")); + } + } + var fInfo = new dojox.data.demos.widgets.FileView(newArgs); + attachPt.appendChild(fInfo.domNode); + fInfo.startup(); + } + } + </script> + </span> + </td> + <td id="fileInfo" STYLE="width: 50%; vertical-align: top;"> + </td> + </tr> + + </tbody> + </table> + <hr> +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_FlickrRestStore.html b/js/dojo/dojox/data/demos/demo_FlickrRestStore.html new file mode 100644 index 0000000..5774c76 --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_FlickrRestStore.html @@ -0,0 +1,236 @@ +<!-- + This file is a demo of the FlickrStore, a simple wrapper to the public feed service + of Flickr. This just does very basic queries against Flickr and loads the results + into a list viewing widget. +--> +<html> +<head> + <title>Demo of FlickrRestStore</title> + <style type="text/css"> + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + </style> + + <script type="text/javascript" src="../../../dojo/dojo.js" + djConfig="isDebug: true, parseOnLoad: true"></script> + <script type="text/javascript"> + dojo.require("dojo.parser"); + dojo.require("dijit.form.TextBox"); + dojo.require("dijit.form.Button"); + dojo.require("dijit.form.ComboBox"); + dojo.require("dijit.form.NumberSpinner"); + dojo.require("dojox.data.FlickrStore"); + dojo.require("dojox.data.FlickrRestStore"); + dojo.require("dojox.data.demos.widgets.FlickrViewList"); + + function init(){ + //Function to invoke the search of the FlickrStore + function invokeSearch(){ + var request = { + query: { + apikey: "8c6803164dbc395fb7131c9d54843627" + } + }; + + if(idWidget){ + var userid = idWidget.getValue(); + if(userid && userid !== ""){ + request.query.userid = userid; + } + } + if(tagsWidget){ + request.query.tags = (tagsWidget.getValue()||"").split(" ").join(","); + } + if(tagmodeWidget){ + request.query.tagmode = tagmodeWidget.getValue()||""; + } + + if(setIdWidget){ + var setid = setIdWidget.getValue(); + if(setid != ""){ + request.query.setid = setid; + } + } + + if(fullTextWidget){ + var fullText = fullTextWidget.getValue(); + if(fullText != ""){ + request.query.text = fullText; + } + } + + if(sortTypeWidget && sortDirWidget){ + var sortType = sortTypeWidget.getValue(); + var sortDirection = sortDirWidget.getValue(); + + if(sortType != "" && sortDirection != ""){ + request.query.sort = [ + { + attribute: sortType, + descending: (sortDirection.toLowerCase() == "descending") + } + ]; + } + } + + if(countWidget){ + request.count = countWidget.getValue(); + } + if(pageWidget){ + request.start = request.count * (pageWidget.getValue() -1); + } + + if(statusWidget){ + statusWidget.setValue("PROCESSING REQUEST"); + } + + // flickrStore.fetch(request); + flickrViewsWidget.fetch(request); + } + + //Lastly, link up the search event. + var button = dijit.byId("searchButton"); + dojo.connect(button, "onClick", invokeSearch); + } + dojo.addOnLoad(init); + </script> +</head> + +<body class="tundra"> + <h1> + DEMO: FlickrRestStore Search + </h1> + <hr> + <h3> + Description: + </h3> + <p> + This simple demo shows how services, such as Flickr, can be wrapped by the datastore API. + In this demo, you can search public Flickr images through a FlickrRestStore by specifying + a series of tags (separated by spaces) to search on. The results will be displayed below the search box. + </p> + <p> + For fun, search on the 3dny tag! + </p> + + <blockquote> + + <!-- + The store instance used by this demo. + --> + <table> + <tbody> + <tr> + <td> + <b>Status:</b> + </td> + <td> + <div dojoType="dijit.form.TextBox" size="50" id="status" jsId="statusWidget" disabled="true"></div> + </td> + <td></td> + <td></td> + </tr> + <tr> + <td> + <b>User ID:</b> + </td> + <td> + <div dojoType="dijit.form.TextBox" size="50" id="userid" jsId="idWidget" value="44153025@N00"></div> + </td> + <td> + <b>Set ID</b> + </td> + <td> + <div dojoType="dijit.form.TextBox" size="50" id="setid" jsId="setIdWidget"></div> + </td> + </tr> + <tr> + <td> + <b>Tags:</b> + </td> + <td> + <div dojoType="dijit.form.TextBox" size="50" id="tags" jsId="tagsWidget" value="rollingstones,kinsale"></div> + </td> + <td> + <b>Full Text</b> + </td> + <td> + <div dojoType="dijit.form.TextBox" size="50" id="fulltext" jsId="fullTextWidget"></div> + </td> + </tr> + <tr> + <td> + <b>Tagmode:</b> + </td> + <td> + <select id="tagmode" + jsId="tagmodeWidget" + dojoType="dijit.form.ComboBox" + autocomplete="false" + value="any" + > + <option>any</option> + <option>all</option> + </select> + </td> + <td> + <b>Sort</b> + </td> + <td> + <select dojoType="dijit.form.ComboBox" size="15" id="sorttype" jsId="sortTypeWidget"> + <option>date-posted</option> + <option>date-taken</option> + <option>interestingness</option> + </select> + <select dojoType="dijit.form.ComboBox" size="15" id="sortdirection" jsId="sortDirWidget"> + <option>ascending</option> + <option>descending</option> + </select> + </td> + </tr> + <tr> + <td> + <b>Number of Pictures:</b> + </td> + <td> + <div + id="count" + jsId="countWidget" + dojoType="dijit.form.NumberSpinner" + value="20" + constraints="{min:1,max:20,places:0}" + ></div> + </td> + <td> + <b>Page:</b> + </td> + <td> + <div + id="page" + jsId="pageWidget" + dojoType="dijit.form.NumberSpinner" + value="1" + constraints="{min:1,max:5,places:0}" + ></div> + </td> + </tr> + <tr> + <td> + </td> + <td> + <div dojoType="dijit.form.Button" label="Search" id="searchButton" jsId="searchButtonWidget"></div> + </td> + </tr> + </tbody> + </table> + <hr/> + </blockquote> + <div dojoType="dojox.data.FlickrRestStore" jsId="flickrStore" label="title"></div> + <div dojoType="dojox.data.demos.widgets.FlickrViewList" + store="flickrStore" + id="flickrViews" + jsId="flickrViewsWidget"></div> + +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_FlickrStore.html b/js/dojo/dojox/data/demos/demo_FlickrStore.html new file mode 100644 index 0000000..0adf8d2 --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_FlickrStore.html @@ -0,0 +1,161 @@ +<html> +<head> + <!-- + This file is a demo of the FlickrStore, a simple wrapper to the public + feed service of Flickr. This just does very basic queries against + Flickr and loads the results into a list viewing widget. + --> + <title>Demo of FlickrStore</title> + <style type="text/css"> + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + </style> + + <script type="text/javascript" src="../../../dojo/dojo.js" + djConfig="isDebug: true, parseOnLoad: true"></script> + <script type="text/javascript"> + dojo.require("dojo.parser"); + dojo.require("dijit.form.TextBox"); + dojo.require("dijit.form.Button"); + dojo.require("dijit.form.ComboBox"); + dojo.require("dijit.form.NumberSpinner"); + dojo.require("dojox.data.FlickrStore"); + dojo.require("dojox.data.demos.widgets.FlickrViewList"); + + function init(){ + //Function to invoke the search of the FlickrStore + var invokeSearch = function(){ + var request = { query: {} }; + + if(idWidget){ + var id = idWidget.getValue() || ""; + if(id && id.length){ + request.query.userid = id; + } + } + + if(tagsWidget){ + request.query.tags = (tagsWidget.getValue()||"").split(" ").join(","); + } + + + if(tagmodeWidget){ + request.query.tagmode = tagmodeWidget.getValue()||""; + } + + if(countWidget){ + request.count = countWidget.getValue(); + } + flickrViewsWidget.fetch(request); + } + + dojo.connect(flickrViewsWidget, "fetch", function() { + statusWidget.setValue("PROCESSING REQUEST"); + }); + + dojo.connect(flickrViewsWidget, "onComplete", function() { + statusWidget.setValue("PROCESSING COMPLETE."); + }); + + dojo.connect(flickrViewsWidget, "onError", function() { + statusWidget.setValue("ERROR!"); + }); + + //Lastly, link up the search event. + var button = dijit.byId("searchButton"); + dojo.connect(button, "onClick", invokeSearch); + } + dojo.addOnLoad(init); + dojo.addOnLoad(function(){ dijit.byId("searchButton").onClick(); }); + </script> +</head> + +<body class="tundra"> + <h1> + DEMO: FlickrStore Search + </h1> + <p> + This simple demo shows how services, such as Flickr, can be wrapped by + the datastore API. In this demo, you can search public Flickr images + through a simple FlickrStore by specifying a series of tags (separated + by spaces) to search on. The results will be displayed below the + search box. + </p> + <table> + <tbody> + <tr> + <td> + <b>Status:</b> + </td> + <td> + <div dojoType="dijit.form.TextBox" size="50" id="status" jsId="statusWidget" disabled="true"></div> + </td> + </tr> + <tr> + <td> + <b>ID:</b> + </td> + <td> + <div dojoType="dijit.form.TextBox" size="50" id="userid" jsId="idWidget"></div> + </td> + </tr> + <tr> + <td> + <b>Tags:</b> + </td> + <td> + <div dojoType="dijit.form.TextBox" size="50" id="tags" jsId="tagsWidget" value="nature"></div> + </td> + </tr> + <tr> + <td> + <b>Tagmode:</b> + </td> + <td> + <select id="tagmode" + jsId="tagmodeWidget" + dojoType="dijit.form.ComboBox" + autocomplete="false" + value="any" + > + <option>any</option> + <option>all</option> + </select> + </td> + </tr> + <tr> + <td> + <b>Number of Pictures:</b> + </td> + <td> + <div + id="count" + jsId="countWidget" + dojoType="dijit.form.NumberSpinner" + value="20" + constraints="{min:1,max:20,places:0}" + ></div> + </td> + </tr> + <tr> + <td> + </td> + <td> + <div dojoType="dijit.form.Button" label="Search" + id="searchButton" jsId="searchButtonWidget"></div> + </td> + </tr> + </tbody> + </table> + <!-- + The store instance used by this demo. + --> + <div dojoType="dojox.data.FlickrStore" jsId="flickrStore" label="title"></div> + <div dojoType="dojox.data.demos.widgets.FlickrViewList" + store="flickrStore" + id="flickrViews" + jsId="flickrViewsWidget"></div> + +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_GoogleFeedStore.html b/js/dojo/dojox/data/demos/demo_GoogleFeedStore.html new file mode 100644 index 0000000..6a4d115 --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_GoogleFeedStore.html @@ -0,0 +1,113 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <style type="text/css"> + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dijit/themes/tundra/tundra_rtl.css"; + + #output { + width: 400px; + position: absolute; + top: 50px; + } + #entryContent { + margin-left: 450px; + position: absolute; + top: 50px; + background-color: #eee; + height: 800px; + padding: 2px; + } + .search-result { + width: 100%; + border: 2px dashed; + padding: 4px; + } + #entryContent h2 { + text-decoration: underline; + } + .summary { + font-weight: bolder; + } + .tags { + background-color: lightGrey; + } + </style> + + <title>Google Feed Store</title> + + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script> + <script type="text/javascript"> + dojo.require("dijit.form.ComboBox"); + dojo.require("dijit.form.FilteringSelect"); + dojo.require("dojox.dtl"); + dojo.require("dojox.dtl.ext-dojo.NodeList"); + dojo.require("dojox.data.GoogleSearchStore"); + dojo.require("dojox.data.GoogleFeedStore"); + + dojo.addOnLoad(function(){ + dojo.connect(dojo.byId("output"), "onclick", function(evt) { + if(evt.target.tagName != "A"){return true;} + dojo.stopEvent(evt); + + dojo.byId("entryContent").innerHTML = dojo.query(".content", evt.target.parentNode)[0].innerHTML; + + return false; + }) + + }); + + function doSearch() { + var query = { + url: dojo.byId("searchText").value + }; + var request = {query:query}; + + var itemBuffer = []; + var maxBufSize = 8; + var outNode = dojo.byId("output"); + outNode.innerHTML = "Searching..."; + var count = 0; + var template = "GoogleFeedTemplate.html"; + testStore = new dojox.data.GoogleFeedStore(); + function doAppend(items){ + var node = document.createElement("div"); + node.id = "res" + (count++); + outNode.appendChild(node); + dojo.query("#"+node.id).dtl(template, { items: items , store: testStore}); + } + + request.onBegin = function(numItems){ + outNode.innerHTML += ".. found " + numItems + " results"; + }; + + request.onComplete = doAppend; + + var count = dojo.byId("count").value; + request.count = count ? Number(count) : 8; + + testStore.fetch(request); + } + </script> +</head> +<body class="tundra" style="margin:20px;"> + <form> + Text: <select id="searchText" > + <option value="http://shaneosullivan.wordpress.com/feed/">http://shaneosullivan.wordpress.com/feed/</option> + <option value="http://dojocampus.org/content/category/dojo-cookies/feed/">http://dojocampus.org/content/category/dojo-cookies/feed/</option> + <option value="http://www.dojotoolkit.org/aggregator/rss">http://www.dojotoolkit.org/aggregator/rss</option> + </select> + Count: <input id="count" type="text" value="10" width=20/> + <input id="searchButton" type="button" value="store.fetch()" onclick="doSearch()" /> + + <div id="output"> + + </div> + <div id="entryContent"> + + </div> + </form> +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_GoogleSearchStore.html b/js/dojo/dojox/data/demos/demo_GoogleSearchStore.html new file mode 100644 index 0000000..b82b334 --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_GoogleSearchStore.html @@ -0,0 +1,125 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <style type="text/css"> + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dijit/themes/tundra/tundra_rtl.css"; + + .search-result { + float: left; + width: 150px; + border: 2px dashed; + padding: 4px; + } + </style> + + <title>Google Search store</title> + + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script> + <script type="text/javascript"> + dojo.require("dojox.data.GoogleSearchStore"); + dojo.require("dijit.form.ComboBox"); + dojo.require("dijit.form.FilteringSelect"); + dojo.require("dojox.dtl"); + dojo.require("dojox.dtl.ext-dojo.NodeList"); + + function doSearch() { + var queryOptions = {}; + + var query = {}; + query.text = dojo.byId("searchText").value; + query.type = dojo.byId("typeText").value; + var request = {query:query}; + + var itemBuffer = []; + var maxBufSize = 8; + var outNode = dojo.byId("output"); + outNode.innerHTML = "Searching..."; + var count = 0; + var template = "GoogleTemplate.html"; + switch(query.type) { + case "web" : + testStore = new dojox.data.GoogleSearchStore(); + break; + case "blogs": + testStore = new dojox.data.GoogleBlogSearchStore(); + template = "GoogleTemplateBlog.html"; + break; + case "local": + testStore = new dojox.data.GoogleLocalSearchStore(); + template = "GoogleTemplateLocal.html"; + break; + case "video": + testStore = new dojox.data.GoogleVideoSearchStore(); + template = "GoogleTemplateVideo.html"; + break; + case "news": + testStore = new dojox.data.GoogleNewsSearchStore(); + break; + case "books": + testStore = new dojox.data.GoogleBookSearchStore(); + break; + case "images": + testStore = new dojox.data.GoogleImageSearchStore(); + template = "GoogleTemplateImage.html"; + break; + } + + function doAppend(){ + var node = document.createElement("span"); + node.id = "res" + (count++); + outNode.appendChild(node); + dojo.query("#"+node.id).dtl(template, { items: itemBuffer , store: testStore}); + } + + request.onBegin = function(numItems){ + outNode.innerHTML += ".. found " + numItems + " results"; + }; + + request.onItem = function(item){ + itemBuffer.push(item); + if(itemBuffer.length >= maxBufSize){ + console.log("onItem, buffer length = " + itemBuffer.length + " & maxBufSize = " + maxBufSize); + doAppend(); + itemBuffer = []; + } else { + console.log("onItem, buffer length = " + itemBuffer.length); + } + }; + + request.onComplete = function (items) { + if (itemBuffer.length > 0) { + doAppend(); + } + }; + + var count = dojo.byId("count").value; + request.count = count ? Number(count) : 8; + + testStore.fetch(request); + } + </script> +</head> +<body class="tundra" style="margin:20px;"> + <form> + Text: <input id="searchText" type="text" value="dojo ajax"/> + Count: <input id="count" type="text" value="8" width=20/> + <input id="searchButton" type="button" value="store.fetch()" onclick="doSearch()" /> + Type + <select id="typeText" name="typeText"> + <option selected value="web">Web</option> + <option value="local">Local</option> + <option value="video">Video</option> + <option value="blogs">Blogs</option> + <option value="news">News</option> + <option value="books">Books</option> + <option value="images">Images</option> + </select> + <div id="output"> + + </div> + </form> +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_GoogleSearchStore_Grid.html b/js/dojo/dojox/data/demos/demo_GoogleSearchStore_Grid.html new file mode 100644 index 0000000..99dacaa --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_GoogleSearchStore_Grid.html @@ -0,0 +1,71 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <style type="text/css"> + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dijit/themes/tundra/tundra_rtl.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + @import "../../../dojox/grid/resources/tundraGrid.css"; + </style> + + <title>Google Search Store with Grid</title> + + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script> + <script type="text/javascript"> + dojo.require("dojox.grid.DataGrid"); + dojo.require("dijit.form.TextBox"); + dojo.require("dijit.form.Button"); + dojo.require("dojox.wire.ml.Invocation"); + dojo.require("dojox.wire.ml.Transfer"); + dojo.require("dojox.wire.ml.Action"); + dojo.require("dojox.data.GoogleSearchStore"); + + var href = function(value) { + return "<a href=\"" + value + "\" target=\"_blank\">" + value + "</a>"; + } + var layoutResults = [ + [ + { name: "Title", field: "title", width: 10 }, + { name: "Summary", field: "content", width: "auto"}, + { name: "URL", field: "url", width: 20, formatter: href } + ] + ]; + var newQuery = {text: 'dojo ajax' }; + </script> +</head> +<body class="tundra" style="margin:20px;"> + <h1>dojox.data.GoogleSearchStore:</h1> + <i>Displays a list of results from a google query.</i> + <div dojoType="dojox.data.GoogleSearchStore" jsId="googleStore"></div> + <br> + <br> + <div dojoType="dijit.form.TextBox" id="searchText" value="dojo ajax"></div> + <button dojoType="dijit.form.Button" id="searchButton">Search</button> + <br> + <br> + <br> + + <div dojoType="dojox.grid.DataGrid" + rowsPerPage="8" + store="googleStore" + structure="layoutResults" + query="{ text: 'dojo ajax' }" + jsId="grid" + style="width: 800px; height: 500px;" + > + </div> + + <!-- + Link the button to updating the query, then triggering the refresh of the grid. + Handy use of dojox.wire! + --> + <div dojoType="dojox.wire.ml.Action" + trigger="searchButton" + triggerEvent="onClick"> + <div dojoType="dojox.wire.ml.Transfer" source="searchText.value" target="newQuery.text"></div> + <div dojoType="dojox.wire.ml.Invocation" object="grid" method="setQuery" parameters="newQuery"></div> + </div> +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_LazyLoad.html b/js/dojo/dojox/data/demos/demo_LazyLoad.html new file mode 100644 index 0000000..358ce84 --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_LazyLoad.html @@ -0,0 +1,66 @@ +<!-- + This file is a simple loader for the Lazy Load demo of a Datastore. In this + Example, a simple extension of ItemFileReadStore that can do rudimentary lazy-loading + of items into the store is used to showcase how Datastores can hide how data + is loaded from the widget. As long as the widget implements to the Dojo.data API + spec, then it should be able to use most datastores as input sources for its + values. +--> +<html> +<head> + <title>Demo of Lazy Loading Datastore</title> + <style type="text/css"> + + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + </style> + + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true, usePlainJson: true"></script> + <script type="text/javascript"> + dojo.require("dojo.parser"); + dojo.require("dojox.data.demos.stores.LazyLoadJSIStore"); + dojo.require("dijit.Tree"); + </script> +</head> + +<body class="tundra"> + <h1> + DEMO: Lazy Loading Datastore used by dijit.Tree + </h1> + <hr> + <h3> + Description: + </h3> + <p> + This simple demo shows how the dijit.Tree widget can work with a Datastore that does lazy-loading of values into the tree. + In this demo, the Datastore is an extension of ItemFileReadStore that overrides the <i>isItemLoaded()</i> and <i>loadItem()</i> functions of + with ones that can detect 'stub' items and use the data in the stub item to load the real data for that item when it + is required. In this demo, the real data is required when one of the tree nodes is expanded. + </p> + <p> + The key thing to note is that all the lazy-loading logic (how to locate the data from the backend and so forth) is encapsulated + into the store functions. The dijit.Tree widget only knows about and uses the dojo.data.Read API interfaces to call to the store to + get items, test if child items are fully loaded or not, and to invoke the <i>loadItem()</i> function on items that are not yet fully + loaded but have been requested to be expanded into view. It has no knowledge of how the store actually goes and gets the data. + </p> + + <blockquote> + + <!-- + The store instance used by this demo. + --> + <div dojoType="dojox.data.demos.stores.LazyLoadJSIStore" jsId="continentStore" + url="geography/root.json"></div> + + <!-- + Display the toplevel tree with items that have an attribute of 'type', + with value of 'contintent' + --> + <b>Continents</b> + <div dojoType="dijit.Tree" id=tree label="Continents" store="continentStore" query="{type:'continent'}" + labelAttr="name" typeAttr="type"></div> + </blockquote> + +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_MultiStores.html b/js/dojo/dojox/data/demos/demo_MultiStores.html new file mode 100644 index 0000000..29ede27 --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_MultiStores.html @@ -0,0 +1,116 @@ +<!-- + This file is a demo of multiple dojo.data aware widgets using different datastore implementations for displaying data. +--> +<html> +<head> + <title>Demo of Multiple Widgets using different Datastores</title> + <style type="text/css"> + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + </style> + + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script> + <script type="text/javascript"> + dojo.require("dojo.parser"); + dojo.require("dijit.form.ComboBox"); + dojo.require("dijit.form.FilteringSelect"); + dojo.require("dijit.Tree"); + dojo.require("dijit.tree.ForestStoreModel"); + + dojo.require("dojox.data.OpmlStore"); + dojo.require("dojox.data.XmlStore"); + dojo.require("dojo.data.ItemFileReadStore"); + + </script> +</head> + +<body class="tundra"> + <h1> + DEMO: Multiple DataStore implementations with dojo.data aware Widgets + </h1> + <hr> + <h3> + Description: + </h3> + <p> + This simple demo shows how widgets which know only the dojo.data interfaces can work with data sources of varying formats. In this case an OpmlStore + and a ItemFileReadStore are used to house the same data in different formats. + </p> + + <blockquote> + + <!-- + The store instances used by this demo. + --> + <div dojoType="dojo.data.ItemFileReadStore" url="geography.json" jsId="ifrGeoStore"></div> + <div dojoType="dojox.data.OpmlStore" url="geography.xml" label="text" jsId="opmlGeoStore"></div> + <div dojoType="dojox.data.XmlStore" url="geography2.xml" label="text" attributeMap="{'text': '@text'}" jsId="xmlGeoStore"></div> + + <h3> + Widgets using OpmlStore: + </h3> + <blockquote> + <b>ComboBox:</b><br> + <input dojoType="dijit.form.ComboBox" id="combo1" name="combo1" class="medium" store="opmlGeoStore" searchAttr="text" query="{}"></input> + <br> + <br> + <b>Filtering Select:</b><br> + <input dojoType="dijit.form.FilteringSelect" id="fs1" name="fs1" class="medium" store="opmlGeoStore" searchAttr="text" query="{}"></input> + <br> + <br> + + <b>Tree:</b><br> + <div dojoType="dijit.tree.ForestStoreModel" jsId="opmlModel" + store="opmlGeoStore" query="{}" + rootId="Continents" rootLabel="Continents" childrenAttrs="children"> + </div> + <div dojoType="dijit.Tree" id="tree1" model="opmlModel"></div> + </blockquote> + + <h3> + Widgets using ItemFileReadStore: + </h3> + <blockquote> + <b>ComboBox:</b><br> + <input dojoType="dijit.form.ComboBox" id="combo2" name="combo2" class="medium" store="ifrGeoStore" searchAttr="name" query="{}"></input> + <br> + <br> + + <b>Filtering Select:</b><br> + <input dojoType="dijit.form.FilteringSelect" id="fs2" name="fs2" class="medium" store="ifrGeoStore" searchAttr="text" query="{}"></input> + <br> + <br> + + <b>Tree:</b><br> + <div dojoType="dijit.tree.ForestStoreModel" jsId="ifrModel" + store="ifrGeoStore" query="{}" + rootId="Continents" rootLabel="Continents" childrenAttrs="children"> + </div> + <div dojoType="dijit.Tree" id="tree2" model="ifrModel"></div> + </blockquote> + + <h3> + Widgets using XmlStore: + </h3> + <blockquote> + <b>ComboBox:</b><br> + <input dojoType="dijit.form.ComboBox" id="combo3" name="combo3" class="medium" store="xmlGeoStore" searchAttr="text" query="{}"></input> + <br> + <br> + + <b>Filtering Select:</b><br> + <input dojoType="dijit.form.FilteringSelect" id="fs3" name="fs3" class="medium" store="xmlGeoStore" searchAttr="text" query="{}"></input> + <br> + <br> + + <b>Tree:</b><br> + <div dojoType="dijit.tree.ForestStoreModel" jsId="xmlModel" + store="xmlGeoStore" query="{}" + rootId="Continents" rootLabel="Continents" childrenAttrs="childNodes"> + </div> + <div dojoType="dijit.Tree" id="tree3" model="xmlModel"></div> + </blockquote> + </blockquote> +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_OpenSearchStore.html b/js/dojo/dojox/data/demos/demo_OpenSearchStore.html new file mode 100644 index 0000000..e8bcc13 --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_OpenSearchStore.html @@ -0,0 +1,215 @@ +<!-- + This file is a demo of the OpenSearchStore, a simple wrapper to any OpenSearch compliant + search engine. + + Note, the simple proxy requires a curl-enabled PHP install +--> +<html> +<head> + <title>Demo of OpenSearchStore</title> + <style type="text/css"> + + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + @import "./openSearchDemo.css"; + </style> + + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script> + + <script type="text/javascript"> + dojo.require("dojo.parser"); + dojo.require("dijit.form.TextBox"); + dojo.require("dijit.form.Button"); + dojo.require("dijit.form.FilteringSelect"); + dojo.require("dijit.form.CheckBox"); + dojo.require("dijit.form.NumberSpinner"); + dojo.require("dijit.Tree"); + dojo.require("dojox.data.OpenSearchStore"); + + function init(){ + var fViewWidgets = []; + + //Set up an onComplete handler for OpenSearchData + function onComplete(items, request){ + if(items.length > 0){ + var ul = dojo.byId("searchResults"); + var test; + var li; + for(var i=0; i<items.length; i++){ + li = dojo.doc.createElement("li"); + li.innerHTML = openSearchStore.getValue(items[i], "content"); + ul.appendChild(li); + } + } + statusWidget.attr('value', "PROCESSING COMPLETE."); + } + //What to do if a search fails... + function onError(error, request){ + statusWidget.attr('value', "PROCESSING ERROR."); + } + + //Function to invoke the search of the openSearchStore + function invokeSearch(){ + var tbody = dojo.byId("searchResults"); + while(tbody.childNodes.length){ + var node = tbody.childNodes.item(0); + node.parentNode.removeChild(node); + } + var request = { + query: {}, + onComplete: onComplete, + onError: onError + }; + if(searchTermsWidget){ + var searchTerms = searchTermsWidget.attr('value'); + if(searchTerms && searchTerms !== ""){ + var searchTermsArray = searchTerms.split(" "); + searchTerms = ""; + for(var i = 0; i < searchTermsArray.length; i++){ + searchTerms = searchTerms + searchTermsArray[i]; + if(i < (searchTermsArray.length - 1)){ + searchTerms += "," + } + } + request.query.searchTerms = searchTerms; + } + } + + if(countWidget){ + request.count = countWidget.attr('value'); + } + + if(statusWidget){ + statusWidget.attr('value', "PROCESSING REQUEST"); + } + + openSearchStore.fetch(request); + } + + //Lastly, link up the search event. + dojo.connect(dijit.byId("searchButton"), 'onClick', invokeSearch); + var currentArgs = {url: 'http://intertwingly.net/search/'}; + var oldProcess = null; + function setTransform(state){ + if(state){ + oldProcess = openSearchStore.processItem; + switch(currentArgs.url){ + case 'http://intertwingly.net/search/': + openSearchStore.processItem = intertwinglyTransform; + break; + case 'http://www.shutterpoint.com/opensearch.xml': + openSearchStore.processItem = shutterpointTransform; + break; + case 'http://technorati.com/osd.xml': + openSearchStore.processItem = technoratiTransform; + break; + } + }else if(oldProcess !== null){ + openSearchStore.processItem = oldProcess; + } + } + dojo.connect(dijit.byId('transformItem'), 'onChange', function(state){ + setTransform(state); + }); + dojo.connect(dijit.byId('urlSelector'), 'onChange', function(args){ + currentArgs = dojo.fromJson(args); + currentArgs.url = 'openSearchProxy.php?osd=true&url='+currentArgs.url; + openSearchStore.close(); + openSearchStore = new dojox.data.OpenSearchStore(currentArgs); + if(dijit.byId('transformItem').checked){ + setTransform(true); + } + }); + + var intertwinglyTransform = function(item, attribute){ + function removeAll(/*NodeList*/list){ + while(list.length) { + var node = list.item(0); + node.parentNode.removeChild(node); + } + } + var content = item.node.getElementsByTagName("content").item(0); + // Remove all blockquote elements + removeAll(content.getElementsByTagName("blockquote")); + // Remove all pre-formatted elements + removeAll(content.getElementsByTagName("pre")); + return openSearchStore._getNodeXml(content, true); + }; + + var shutterpointTransform = function(item, attribute){ + var description = item.node.getElementsByTagName("description").item(0); + var div = dojo.doc.createElement("div"); + div.innerHTML = description.childNodes.item(0).nodeValue; + //Of the description children, remove the divs (to only leave the images) + for(var i=0; i<div.childNodes.length; i++){ + var node = div.childNodes.item(i); + if(node.tagName.toLowerCase() === "div") + node.parentNode.removeChild(node); + } + return openSearchStore._getNodeXml(div, true); + }; + + var technoratiTransform = function(item, attribute){ + function removeAll(/*NodeList*/list){ + while(list.length) { + var node = list.item(0); + node.parentNode.removeChild(node); + } + } + removeAll(item.node.getElementsByTagName("blockquote")); + return item.innerHTML; + }; + } + dojo.addOnLoad(init); + </script> +</head> + +<body class="tundra"> + <h1>DEMO: OpenSearchStore Search</h1> + <hr /> + <h3>Description:</h3> + <p> + This simple demo shows how services, such as an OpenSearch compliant search service, can be wrapped by the datastore API. In this demo, you can search public search engines through a simple OpenSearchStore by specifying a series of search terms (separated by spaces) to search on. The results will be displayed below the search box. + </p> + <p> + <b>NOTE: This demo makes use of a simple PHP based proxy script. The proxy script requires cURL support in PHP. Without cURL support, the demo will throw errors.</b> + </p> + <label for="urlSelector">URL of OpenSearchDocument:</label> + <select dojoType="dijit.form.FilteringSelect" + id="urlSelector" + name="urlSelector" + autoComplete="true"> + <option value="{url: 'http://intertwingly.net/search/'}">http://intertwingly.net/search/</option> + <option value="{url: 'http://www.shutterpoint.com/opensearch.xml'}">http://www.shutterpoint.com/opensearch.xml</option> + <option value="{url: 'http://technorati.com/osd.xml', itemPath: '.hentry'}">http://technorati.com/osd.xml</option> + </select> + <label for="transformItem">Apply transform function?</label> + <input dojoType="dijit.form.CheckBox" + type="checkbox" + id="transformItem" + name="transformItem"> + </input> + <hr /> + <label for="status">Status:</label> + <div dojoType="dijit.form.TextBox" maxLength="50" id="status" name="status" jsId="statusWidget" disabled="true"></div> + <label for="searchTerms">Search For:</label> + <div dojoType="dijit.form.TextBox" maxLength="50" id="searchTerms" name="searchTerms" jsId="searchTermsWidget" value="javascript"></div> + <label for="count">Number of Results:</label> + <div id="count" + name="count" + jsId="countWidget" + dojoType="dijit.form.NumberSpinner" + value="20" + constraints="{min:1,max:20}"> + </div> + <div dojoType="dijit.form.Button" label="Search" id="searchButton" jsId="searchButtonWidget"></div> + <hr/> + <div dojoType="dojox.data.OpenSearchStore" + url="openSearchProxy.php?osd=true&url=http://intertwingly.net/search/" + jsId="openSearchStore"> + </div> + <ul id="searchResults"></ul> + +</body> +</html>
\ No newline at end of file diff --git a/js/dojo/dojox/data/demos/demo_PicasaStore.html b/js/dojo/dojox/data/demos/demo_PicasaStore.html new file mode 100644 index 0000000..47f73a4 --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_PicasaStore.html @@ -0,0 +1,190 @@ +<!-- + This file is a demo of the PicasaStore, a simple wrapper to the public feed service + of Picasa. This just does very basic queries against Picasa and loads the results + into a list viewing widget. +--> +<html> +<head> + <title>Demo of PicasaStore</title> + <style type="text/css"> + + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + @import "./picasaDemo.css"; + </style> + + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script> + <script type="text/javascript"> + dojo.require("dojo.parser"); + dojo.require("dijit.form.TextBox"); + dojo.require("dijit.form.Button"); + dojo.require("dijit.form.ComboBox"); + dojo.require("dijit.form.NumberSpinner"); + dojo.require("dijit.Tree"); + dojo.require("dojox.data.PicasaStore"); + dojo.require("dojox.data.demos.widgets.PicasaViewList"); + dojo.require("dojox.data.demos.widgets.PicasaView"); + + function init(){ + var fViewWidgets = []; + + //Set up an onComplete handler for picasaData + function onComplete(items, request){ + picasaViewsWidget.clearList(); + if(items.length > 0){ + for(var i = 0; i < items.length; i++){ + var picasaData = { + title: picasaStore.getValue(items[i],"title"), + author: picasaStore.getValue(items[i],"author"), + description: picasaStore.getValue(items[i],"description"), + iconUrl: picasaStore.getValue(items[i],"imageUrlSmall"), + imageUrl: picasaStore.getValue(items[i],"imageUrl") + } + picasaViewsWidget.addView(picasaData); + } + } + statusWidget.attr("value", "PROCESSING COMPLETE."); + + } + //What to do if a search fails... + function onError(error, request){ + console.debug(error); + picasaViewsWidget.clearList(); + statusWidget.attr("value", "PROCESSING ERROR."); + } + + //Function to invoke the search of the PicasaStore + function invokeSearch(){ + var request = { + query: {}, + onComplete: onComplete, + onError: onError + }; + + if(idWidget){ + var userid = idWidget.attr("value"); + if(userid && userid !== ""){ + request.query.userid = userid; + } + } + if(tagsWidget){ + var tags = tagsWidget.attr("value"); + if(tags && tags !== ""){ + var tagsArray = tags.split(" "); + tags = ""; + for(var i = 0; i < tagsArray.length; i++){ + tags = tags + tagsArray[i]; + if(i < (tagsArray.length - 1)){ + tags += "," + } + } + request.query.tags = tags; + } + } + if(countWidget){ + request.count = countWidget.attr("value"); + } + + if(startWidget){ + request.query.start = startWidget.attr("value"); + } + + if(statusWidget){ + statusWidget.attr("value","PROCESSING REQUEST"); + } + + picasaStore.fetch(request); + } + + //Lastly, link up the search event. + var button = dijit.byId("searchButton"); + dojo.connect(button, "onClick", invokeSearch); + } + dojo.addOnLoad(init); + </script> +</head> + +<body class="tundra"> + <h1> + DEMO: PicasaStore Search + </h1> + <hr> + <h3> + Description: + </h3> + <p> + This simple demo shows how services, such as Picasa, can be wrapped by the datastore API. In this demo, you can search public Picasa images through a simple PicasaStore by specifying a series of tags (separated by spaces) to search on. The results will be displayed below the search box. + </p> + <p> + For fun, search on the 3dny tag! + </p> + + <blockquote> + + <!-- + The store instance used by this demo. + --> + <table> + <tbody> + <tr> + <td> + <b>Status:</b> + </td> + <td> + <div dojoType="dijit.form.TextBox" size="50" id="status" jsId="statusWidget" disabled="true"></div> + </td> + </tr> + <tr> + <td> + <b>ID:</b> + </td> + <td> + <div dojoType="dijit.form.TextBox" size="50" id="userid" jsId="idWidget"></div> + </td> + </tr> + <tr> + <td> + <b>Query:</b> + </td> + <td> + <div dojoType="dijit.form.TextBox" size="50" id="tags" jsId="tagsWidget" value="flower"></div> + </td> + </tr> + <tr> + <td> + <b>Number of Pictures:</b> + </td> + <td> + <div + id="start" + jsId="startWidget" + dojoType="dijit.form.NumberSpinner" + value="1" + constraints="{min:1,places:0}" + ></div> + <div + id="count" + jsId="countWidget" + dojoType="dijit.form.NumberSpinner" + value="20" + constraints="{min:1,max:100,places:0}" + ></div> + </td> + </tr> + <tr> + <td> + </td> + <td> + <div dojoType="dijit.form.Button" label="Search" id="searchButton" jsId="searchButtonWidget"></div> + </td> + </tr> + </tbody> + </table> + <hr/> + </blockquote> + <div dojoType="dojox.data.PicasaStore" jsId="picasaStore" label="title"></div> + <div dojoType="dojox.data.demos.widgets.PicasaViewList" id="picasaViews" jsId="picasaViewsWidget"></div> + +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_QueryReadStore_ComboBox.html b/js/dojo/dojox/data/demos/demo_QueryReadStore_ComboBox.html new file mode 100644 index 0000000..6be9265 --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_QueryReadStore_ComboBox.html @@ -0,0 +1,58 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <title>Dojox QueryReadStore+ComboBox Demo</title> + <style type="text/css"> + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + </style> + + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script> +</head> +<body class="tundra"> + + <h1 class="testTitle">Dojox QueryReadStore + ComboBox demo</h1> + + <h2>Everything is created ONLY in markup</h2> + <div class="dijitContainer"> + <div style="float:left;"> + <div dojoType="dojox.data.QueryReadStore" + jsId="store1" + url="../tests/stores/QueryReadStore.php" + requestMethod="post"></div> + <div dojoType="dijit.form.ComboBox" id="cb1" store="store1" pageSize="10" autoComplete="false"></div> + <button dojoType="dijit.form.Button" onclick="dijit.byId('cb1').reset()">reset</button> + </div> + <div style="float:left; margin-left:5em;"> + var w = dijit.byId("cb1"); + <br /><input id="value1" type="text" /> = w.value + <br /><input id="itemId1" type="text" /> = w.item ? w.store.getValue(w.item, "id") : "-" + <br /><input id="displayedValue1" type="text" /> = w.attr("displayedValue") + <br /><input id="isValid1" type="text" /> = w.isValid() + <br /><button dojoType="dijit.form.Button" onclick="refresh1()">refresh</button> + </div> + </div> + + <script type="text/javascript"> + dojo.require("dojox.data.QueryReadStore"); + dojo.require("dijit.form.ComboBox"); + dojo.require("dijit.form.Button"); + + var w = null; + var refresh1 = function() { + dojo.byId("value1").value = w.value; + dojo.byId("itemId1").value = w.item ? w.store.getValue(w.item, "id") : "-"; + dojo.byId("displayedValue1").value = w.attr("displayedValue"); + dojo.byId("isValid1").value = w.isValid(); + }; + dojo.addOnLoad(function() { + w = dijit.byId("cb1"); + dojo.connect(w.domNode, "onkeyup", refresh1); + dojo.connect(w, "onBlur", refresh1); + dojo.connect(w, "onChange", refresh1); + refresh1(); + }); + </script> +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_QueryReadStore_FilteringSelect.html b/js/dojo/dojox/data/demos/demo_QueryReadStore_FilteringSelect.html new file mode 100644 index 0000000..6f89167 --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_QueryReadStore_FilteringSelect.html @@ -0,0 +1,56 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <title>Dojox QueryReadStore+FilteringSelect Demo</title> + <style type="text/css"> + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + </style> + + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script> +</head> +<body class="tundra"> + + <h1 class="testTitle">Dojox QueryReadStore + FilteringSelect demo</h1> + + <h2>Everything is created ONLY in markup</h2> + <div style="float:left;"> + <div dojoType="dojox.data.QueryReadStore" + jsId="store1" + url="../tests/stores/QueryReadStore.php" + requestMethod="post"></div> + <div dojoType="dijit.form.FilteringSelect" id="fs1" store="store1" pageSize="10" autoComplete="false"></div> + <button dojoType="dijit.form.Button" onclick="dijit.byId('fs1').reset()">reset</button> + </div> + <div style="float:left; margin-left:5em;"> + var w = dijit.byId("fs1"); + <br /><input id="value1" type="text" /> = w.value + <br /><input id="itemId1" type="text" /> = w.item ? w.store.getValue(w.item, "id") : "-" + <br /><input id="displayedValue1" type="text" /> = w.getDisplayedValue() + <br /><input id="isValid1" type="text" /> = w.isValid() + <br /><button dojoType="dijit.form.Button" onclick="refresh1()">refresh</button> + </div> + + <script type="text/javascript"> + dojo.require("dojox.data.QueryReadStore"); + dojo.require("dijit.form.FilteringSelect"); + dojo.require("dijit.form.Button"); + + var w = null; + var refresh1 = function() { + dojo.byId("value1").value = w.value; + dojo.byId("itemId1").value = w.item ? w.store.getValue(w.item, "id") : "-"; + dojo.byId("displayedValue1").value = w.getDisplayedValue(); + dojo.byId("isValid1").value = w.isValid(); + }; + dojo.addOnLoad(function() { + w = dijit.byId("fs1"); + dojo.connect(w.domNode, "onkeyup", refresh1); + dojo.connect(w, "onBlur", refresh1); + dojo.connect(w, "onChange", refresh1); + refresh1(); + }); + </script> +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_QueryReadStore_grid.html b/js/dojo/dojox/data/demos/demo_QueryReadStore_grid.html new file mode 100644 index 0000000..7035ebd --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_QueryReadStore_grid.html @@ -0,0 +1,110 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <title>Dojox QueryReadStore+grid Demo</title> + <style type="text/css"> + @import "../../../dijit/themes/tundra/tundra.css"; + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/tests/css/dijitTests.css"; + /* BE SURE TO NEVER FORGET IMPORTING THE GRID's CSS, or you will wonder why the + grid looks so strange (or even think that it doesnt work) */ + @import "../../../dojox/grid/resources/tundraGrid.css"; + </style> + + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true, useCommentedJson: true"></script> + <script type="text/javascript"> + dojo.require("dojox.grid.DataGrid"); + dojo.require("dojox.data.QueryReadStore"); + dojo.require("dojo.parser"); // scan page for widgets and instantiate them + var gridLayout = [ + new dojox.grid.cells.RowIndex({ name: "row #", width: 5, styles: "text-align: right;" }), + { + name: "id", + field: "id", + styles: "text-align:right;", + width:5 + }, + { + name: "Name", + field: "name", + width:20 + //formatter: rs.chunk.adminUser.grid.formatUser + }, + { + name: "Capital", + field: "capital", + width:20 + //formatter: rs.chunk.adminUser.grid.formatUser + }, + { + name: "Label", + width:20, + //styles: "text-align:right;", + field: "label" + //formatter: phpr.grid.formatDate + }, + { + name: "Abbrev.", + width:5, + //styles: "text-align:right;", + field: "abbreviation" + //formatter: phpr.grid.formatDate + } + ]; + // Connect the store AFTER the page is loaded, since we can only access + // the widget then, since it will be created just before dojo.addOnLoad() is called. + var store = null; + dojo.addOnLoad(function() { + store = new dojox.data.QueryReadStore({ + url:"../tests/stores/QueryReadStore.php", + requestMethod:"post" + }); + grid1.setStore(store); + grid1.setStructure(gridLayout); + }); + + var lastSearchValue = ""; + function doSearch(el) { + if (el.value!=lastSearchValue) { + lastSearchValue = el.value; + grid1.filter({name:el.value}); + grid2.filter({name:el.value}); + } + } + </script> +</head> +<body class="tundra"> + + <h1 class="testTitle">Dojox QueryReadStore + Grid demo - paging, sortable and filterable all server-side</h1> + + <h2>The grid is in HTML, store, etc. are JS, sorting is added by extending the model class</h2> + <b>Capabilities:</b> load data from server, show data, paging (30 rows at a time), sort, filter<br /> + You can see that data are loaded upon demand by scrolling down in the grid below line #30, + open FireBug and you see a server request being issued, to retreive another 30 rows/items.<br /> + <br /><br /> + <input type="text" onkeyup="doSearch(this)" /> + <div id="grid1" jsid="grid1" dojoType="dojox.grid.DataGrid" query="{ name: '*' }" rowsPerPage="30" style="height:300px; width:800px;"></div> + + <h2>The store and grid are "generated" and connected in HTML, filtering is done via JS</h2> + This store is by default sorted descending by name (not as the one above, which is ascending). + <div dojoType="dojox.data.QueryReadStore" + jsId="store2" + url="../tests/stores/QueryReadStore.php" + requestMethod="post"></div> + <!--<div dojoType="dojox.grid._data.DojoData" + jsId="model2" + store="store2" + sortFields="[{attribute: 'capital', descending: true}]" + rowsPerPage="30"></div>--> + <div dojoType="dojox.grid.DataGrid" + id="grid2" jsid="grid2" + store="store2" + query="{ name: '*' }" + rowsPerPage="30" + structure="gridLayout" + style="height:300px; width:800px;"></div> + + + +</body> +</html> diff --git a/js/dojo/dojox/data/demos/demo_WikipediaStore.html b/js/dojo/dojox/data/demos/demo_WikipediaStore.html new file mode 100644 index 0000000..bc290b0 --- /dev/null +++ b/js/dojo/dojox/data/demos/demo_WikipediaStore.html @@ -0,0 +1,82 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<title>Wikipedia Data Store</title> +<style type="text/css"> +@import "../../../dojo/resources/dojo.css"; +@import "../../../dijit/themes/tundra/tundra.css"; +h1 { margin-bottom: 1em; } +</style> +<script type="text/javascript"> +//<![CDATA[ +djConfig = { isDebug: true }; +//]]> +</script> +<script type="text/javascript" src="../../../dojo/dojo.js"></script> +<script type="text/javascript"> +//<![CDATA[ +dojo.require("dojox.data.WikipediaStore"); +var store = new dojox.data.WikipediaStore(); + +function doSearch(){ + var outNode = dojo.byId("output"); + outNode.innerHTML = "Searching..."; + + function loadArticle(article){ + var request = { + query: { + title: article + }, + onItem: function(item, req){ + var title = store.getValue(item, "title"); + var text = store.getValue(item, "text")["*"]; + outNode.innerHTML = "<h1>" + title + "</h1>" + text; + } + }; + console.log("Article request: ", request); + store.fetch(request); + } + + + var request = { + query: { + action: "query", + text: dojo.byId("searchText").value + }, + count: dojo.byId("count").value, + onBegin: function(count){ + outNode.innerHTML += " found " + count + " results.<br>Click one to load the article."; + }, + onItem: function(item, req){ + console.debug(item); + var node = document.createElement("a"); + node.href = "#"; + node.onclick = function(){ + console.log("clicked ", this.innerHTML); + loadArticle(this.innerHTML); + }; + node.style.padding = "6px"; + node.style.display = "block"; + node.innerHTML = store.getValue(item, "title"); + outNode.appendChild(node); + } + }; + console.log("Request: ", request); + store.fetch(request); +} +//]]> +</script> +</head> +<body class="tundra" style="margin:20px;"> + <form action="#"> + <p> + Text: <input id="searchText" type="text" value="dojo toolkit"> + Count: <input id="count" type="text" value="8" size="3"> + <input id="searchButton" type="button" value="store.fetch()" onclick="doSearch()"> + </p> + + <div id="output" style="padding:0 20px;"> + </div> + </form> +</body> +</html> diff --git a/js/dojo/dojox/data/demos/geography.json b/js/dojo/dojox/data/demos/geography.json new file mode 100644 index 0000000..c2f01bb --- /dev/null +++ b/js/dojo/dojox/data/demos/geography.json @@ -0,0 +1,45 @@ +{ identifier: 'name', + label: 'name', + items: [ + { name:'Africa', type:'continent', children:[ + { name:'Egypt', type:'country' }, + { name:'Kenya', type:'country', children:[ + { name:'Nairobi', type:'city' }, + { name:'Mombasa', type:'city' } ] + }, + { name:'Sudan', type:'country', children: + { name:'Khartoum', type:'city' } + } ] + }, + { name:'Asia', type:'continent', children:[ + { name:'China', type:'country' }, + { name:'India', type:'country' }, + { name:'Russia', type:'country' }, + { name:'Mongolia', type:'country' } ] + }, + { name:'Australia', type:'continent', population:'21 million', children: + { name:'Commonwealth of Australia', type:'country', population:'21 million'} + }, + { name:'Europe', type:'continent', children:[ + { name:'Germany', type:'country' }, + { name:'France', type:'country' }, + { name:'Spain', type:'country' }, + { name:'Italy', type:'country' } ] + }, + { name:'North America', type:'continent', children:[ + { name:'Mexico', type:'country', population:'108 million', area:'1,972,550 sq km', children:[ + { name:'Mexico City', type:'city', population:'19 million', timezone:'-6 UTC'}, + { name:'Guadalajara', type:'city', population:'4 million', timezone:'-6 UTC' } ] + }, + { name:'Canada', type:'country', population:'33 million', area:'9,984,670 sq km', children:[ + { name:'Ottawa', type:'city', population:'0.9 million', timezone:'-5 UTC'}, + { name:'Toronto', type:'city', population:'2.5 million', timezone:'-5 UTC' }] + }, + { name:'United States of America', type:'country' } ] + }, + { name:'South America', type:'continent', children:[ + { name:'Brazil', type:'country', population:'186 million' }, + { name:'Argentina', type:'country', population:'40 million' } ] + } ] +} + diff --git a/js/dojo/dojox/data/demos/geography.xml b/js/dojo/dojox/data/demos/geography.xml new file mode 100644 index 0000000..070a8c1 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<opml version="1.0"> + <head> + <title>geography.opml</title> + <dateCreated>2006-11-10</dateCreated> + <dateModified>2006-11-13</dateModified> + <ownerName>Magellan, Ferdinand</ownerName> + </head> + <body> + <outline text="Africa" type="continent"> + <outline text="Egypt" type="country"/> + <outline text="Kenya" type="country"> + <outline text="Nairobi" type="city"/> + <outline text="Mombasa" type="city"/> + </outline> + <outline text="Sudan" type="country"> + <outline text="Khartoum" type="city"/> + </outline> + </outline> + <outline text="Asia" type="continent"> + <outline text="China" type="country"/> + <outline text="India" type="country"/> + <outline text="Russia" type="country"/> + <outline text="Mongolia" type="country"/> + </outline> + <outline text="Australia" type="continent" population="21 million"> + <outline text="Australia" type="country" population="21 million"/> + </outline> + <outline text="Europe" type="continent"> + <outline text="Germany" type="country"/> + <outline text="France" type="country"/> + <outline text="Spain" type="country"/> + <outline text="Italy" type="country"/> + </outline> + <outline text="North America" type="continent"> + <outline text="Mexico" type="country" population="108 million" area="1,972,550 sq km"> + <outline text="Mexico City" type="city" population="19 million" timezone="-6 UTC"/> + <outline text="Guadalajara" type="city" population="4 million" timezone="-6 UTC"/> + </outline> + <outline text="Canada" type="country" population="33 million" area="9,984,670 sq km"> + <outline text="Ottawa" type="city" population="0.9 million" timezone="-5 UTC"/> + <outline text="Toronto" type="city" population="2.5 million" timezone="-5 UTC"/> + </outline> + <outline text="United States of America" type="country"/> + </outline> + <outline text="South America" type="continent"> + <outline text="Brazil" type="country" population="186 million"/> + <outline text="Argentina" type="country" population="40 million"/> + </outline> + </body> +</opml> diff --git a/js/dojo/dojox/data/demos/geography/Argentina/data.json b/js/dojo/dojox/data/demos/geography/Argentina/data.json new file mode 100644 index 0000000..17ba291 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Argentina/data.json @@ -0,0 +1,5 @@ +{ + name:'Argentina', + type:'country', + population:'40 million' +} diff --git a/js/dojo/dojox/data/demos/geography/Brazil/data.json b/js/dojo/dojox/data/demos/geography/Brazil/data.json new file mode 100644 index 0000000..a326c24 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Brazil/data.json @@ -0,0 +1,5 @@ +{ + name:'Brazil', + type:'country', + population:'186 million' +} diff --git a/js/dojo/dojox/data/demos/geography/Canada/Ottawa/data.json b/js/dojo/dojox/data/demos/geography/Canada/Ottawa/data.json new file mode 100644 index 0000000..df3bbc8 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Canada/Ottawa/data.json @@ -0,0 +1,6 @@ +{ + name:'Ottawa', + type:'city', + population:'0.9 million', + timezone:'-5 UTC' +} diff --git a/js/dojo/dojox/data/demos/geography/Canada/Toronto/data.json b/js/dojo/dojox/data/demos/geography/Canada/Toronto/data.json new file mode 100644 index 0000000..534409b --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Canada/Toronto/data.json @@ -0,0 +1,6 @@ +{ + name:'Toronto', + type:'city', + population:'2.5 million', + timezone:'-5 UTC' +} diff --git a/js/dojo/dojox/data/demos/geography/Canada/data.json b/js/dojo/dojox/data/demos/geography/Canada/data.json new file mode 100644 index 0000000..6ef34ed --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Canada/data.json @@ -0,0 +1,10 @@ +{ + name:'Canada', + type:'country', + population:'33 million', area:'9,984,670 sq km', + children:[ + {stub:'Ottawa'}, + {stub:'Toronto'} + ] +} + diff --git a/js/dojo/dojox/data/demos/geography/China/data.json b/js/dojo/dojox/data/demos/geography/China/data.json new file mode 100644 index 0000000..72c29cc --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/China/data.json @@ -0,0 +1,4 @@ +{ + name:'China', + type:'country' +} diff --git a/js/dojo/dojox/data/demos/geography/Commonwealth of Australia/data.json b/js/dojo/dojox/data/demos/geography/Commonwealth of Australia/data.json new file mode 100644 index 0000000..e093295 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Commonwealth of Australia/data.json @@ -0,0 +1,5 @@ +{ + name:'Commonwealth of Australia', + type:'country', + population:'21 million' +} diff --git a/js/dojo/dojox/data/demos/geography/Egypt/data.json b/js/dojo/dojox/data/demos/geography/Egypt/data.json new file mode 100644 index 0000000..d355537 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Egypt/data.json @@ -0,0 +1,5 @@ +{ + name:'Egypt', + type:'country' +} + diff --git a/js/dojo/dojox/data/demos/geography/France/data.json b/js/dojo/dojox/data/demos/geography/France/data.json new file mode 100644 index 0000000..5b5f3c3 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/France/data.json @@ -0,0 +1,4 @@ +{ + name:'France', + type:'country' +} diff --git a/js/dojo/dojox/data/demos/geography/Germany/data.json b/js/dojo/dojox/data/demos/geography/Germany/data.json new file mode 100644 index 0000000..1656257 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Germany/data.json @@ -0,0 +1,4 @@ +{ + name:'Germany', + type:'country' +} diff --git a/js/dojo/dojox/data/demos/geography/India/data.json b/js/dojo/dojox/data/demos/geography/India/data.json new file mode 100644 index 0000000..3103f89 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/India/data.json @@ -0,0 +1,4 @@ +{ + name:'India', + type:'country' +} diff --git a/js/dojo/dojox/data/demos/geography/Italy/data.json b/js/dojo/dojox/data/demos/geography/Italy/data.json new file mode 100644 index 0000000..6e6b076 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Italy/data.json @@ -0,0 +1,4 @@ +{ + name:'Italy', + type:'country' +} diff --git a/js/dojo/dojox/data/demos/geography/Kenya/Mombasa/data.json b/js/dojo/dojox/data/demos/geography/Kenya/Mombasa/data.json new file mode 100644 index 0000000..28aa849 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Kenya/Mombasa/data.json @@ -0,0 +1,5 @@ +{ + name:'Mombasa', + type:'city', + population: "Unknown" +} diff --git a/js/dojo/dojox/data/demos/geography/Kenya/Nairobi/data.json b/js/dojo/dojox/data/demos/geography/Kenya/Nairobi/data.json new file mode 100644 index 0000000..f5658ec --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Kenya/Nairobi/data.json @@ -0,0 +1,5 @@ +{ + name:'Nairobi', + type:'city', + population: "Unknown" +} diff --git a/js/dojo/dojox/data/demos/geography/Kenya/data.json b/js/dojo/dojox/data/demos/geography/Kenya/data.json new file mode 100644 index 0000000..9253c25 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Kenya/data.json @@ -0,0 +1,9 @@ +{ + name:'Kenya', + type:'country', + children:[ + {stub:'Nairobi'}, + {stub:'Mombasa'} + ] +} + diff --git a/js/dojo/dojox/data/demos/geography/Mexico/Guadalajara/data.json b/js/dojo/dojox/data/demos/geography/Mexico/Guadalajara/data.json new file mode 100644 index 0000000..059fc82 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Mexico/Guadalajara/data.json @@ -0,0 +1,7 @@ +{ + name:'Guadalajara', + type:'city', + population:'4 million', + timezone:'-6 UTC' +} + diff --git a/js/dojo/dojox/data/demos/geography/Mexico/Mexico City/data.json b/js/dojo/dojox/data/demos/geography/Mexico/Mexico City/data.json new file mode 100644 index 0000000..8c67622 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Mexico/Mexico City/data.json @@ -0,0 +1,6 @@ +{ + name:'Mexico City', + type:'city', + population:'19 million', + timezone:'-6 UTC' +} diff --git a/js/dojo/dojox/data/demos/geography/Mexico/data.json b/js/dojo/dojox/data/demos/geography/Mexico/data.json new file mode 100644 index 0000000..aa381e4 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Mexico/data.json @@ -0,0 +1,10 @@ +{ + name:'Mexico', + type:'country', + population:'108 million', + area:'1,972,550 sq km', + children:[ + {stub:'Mexico City'}, + {stub:'Guadalajara'} + ] +} diff --git a/js/dojo/dojox/data/demos/geography/Mongolia/data.json b/js/dojo/dojox/data/demos/geography/Mongolia/data.json new file mode 100644 index 0000000..4c60b22 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Mongolia/data.json @@ -0,0 +1,4 @@ +{ + name:'Mongolia', + type:'country' +} diff --git a/js/dojo/dojox/data/demos/geography/Russia/data.json b/js/dojo/dojox/data/demos/geography/Russia/data.json new file mode 100644 index 0000000..5d9a6ba --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Russia/data.json @@ -0,0 +1,4 @@ +{ + name:'Russia', + type:'country' +} diff --git a/js/dojo/dojox/data/demos/geography/Spain/data.json b/js/dojo/dojox/data/demos/geography/Spain/data.json new file mode 100644 index 0000000..d9a1210 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Spain/data.json @@ -0,0 +1,4 @@ +{ + name:'Spain', + type:'country' +} diff --git a/js/dojo/dojox/data/demos/geography/Sudan/Khartoum/data.json b/js/dojo/dojox/data/demos/geography/Sudan/Khartoum/data.json new file mode 100644 index 0000000..befa3c7 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Sudan/Khartoum/data.json @@ -0,0 +1,5 @@ +{ + name:'Khartoum', + type:'city' +} + diff --git a/js/dojo/dojox/data/demos/geography/Sudan/data.json b/js/dojo/dojox/data/demos/geography/Sudan/data.json new file mode 100644 index 0000000..fe7585b --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/Sudan/data.json @@ -0,0 +1,6 @@ +{ + name:'Sudan', + type:'country', + children:{stub:'Khartoum'} +} + diff --git a/js/dojo/dojox/data/demos/geography/United States of America/data.json b/js/dojo/dojox/data/demos/geography/United States of America/data.json new file mode 100644 index 0000000..7dbdd61 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/United States of America/data.json @@ -0,0 +1,4 @@ +{ + name:'United States of America', + type:'country' +} diff --git a/js/dojo/dojox/data/demos/geography/root.json b/js/dojo/dojox/data/demos/geography/root.json new file mode 100644 index 0000000..dda74f5 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography/root.json @@ -0,0 +1,39 @@ +{ + identifier: 'name', + label: 'name', + items: [ + { name:'Africa', type:'continent', + children:[{_reference:'Egypt'}, {_reference:'Kenya'}, {_reference:'Sudan'}] }, + { name:'Egypt', type:'stub', parent: 'geography'}, + { name:'Kenya', type:'stub', parent: 'geography'}, + { name:'Sudan', type:'stub', parent: 'geography'}, + + { name:'Asia', type:'continent', + children:[{_reference:'China'}, {_reference:'India'}, {_reference:'Russia'}, {_reference:'Mongolia'}] }, + { name:'China', type:'stub', parent: 'geography'}, + { name:'India', type:'stub', parent: 'geography'}, + { name:'Russia', type:'stub', parent: 'geography'}, + { name:'Mongolia', type:'stub', parent: 'geography'}, + + { name:'Australia', type:'continent', population:'21 million', + children:{_reference:'Commonwealth of Australia'}}, + { name:'Commonwealth of Australia', type:'stub', parent:'geography'}, + + { name:'Europe', type:'continent', + children:[{_reference:'Germany'}, {_reference:'France'}, {_reference:'Spain'}, {_reference:'Italy'}] }, + { name:'Germany', type:'stub', parent: 'geography'}, + { name:'France', type:'stub', parent: 'geography'}, + { name:'Spain', type:'stub', parent: 'geography'}, + { name:'Italy', type:'stub', parent: 'geography'}, + + { name:'North America', type:'continent', + children:[{_reference:'Mexico'}, {_reference:'Canada'}, {_reference:'United States of America'}] }, + { name:'Mexico', type:'stub', parent: 'geography'}, + { name:'Canada', type:'stub', parent: 'geography'}, + { name:'United States of America', type:'stub', parent: 'geography'}, + + { name:'South America', type:'continent', + children:[{_reference:'Brazil'}, {_reference:'Argentina'}] }, + { name:'Brazil', type:'stub', parent: 'geography'}, + { name:'Argentina', type:'stub', parent: 'geography'} +]} diff --git a/js/dojo/dojox/data/demos/geography2.xml b/js/dojo/dojox/data/demos/geography2.xml new file mode 100644 index 0000000..b82c110 --- /dev/null +++ b/js/dojo/dojox/data/demos/geography2.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<geography> + <outline text="Africa" type="continent"> + <outline text="Egypt" type="country"/> + <outline text="Kenya" type="country"> + <outline text="Nairobi" type="city"/> + <outline text="Mombasa" type="city"/> + </outline> + <outline text="Sudan" type="country"> + <outline text="Khartoum" type="city"/> + </outline> + </outline> + <outline text="Asia" type="continent"> + <outline text="China" type="country"/> + <outline text="India" type="country"/> + <outline text="Russia" type="country"/> + <outline text="Mongolia" type="country"/> + </outline> + <outline text="Australia" type="continent" population="21 million"> + <outline text="Australia" type="country" population="21 million"/> + </outline> + <outline text="Europe" type="continent"> + <outline text="Germany" type="country"/> + <outline text="France" type="country"/> + <outline text="Spain" type="country"/> + <outline text="Italy" type="country"/> + </outline> + <outline text="North America" type="continent"> + <outline text="Mexico" type="country" population="108 million" area="1,972,550 sq km"> + <outline text="Mexico City" type="city" population="19 million" timezone="-6 UTC"/> + <outline text="Guadalajara" type="city" population="4 million" timezone="-6 UTC"/> + </outline> + <outline text="Canada" type="country" population="33 million" area="9,984,670 sq km"> + <outline text="Ottawa" type="city" population="0.9 million" timezone="-5 UTC"/> + <outline text="Toronto" type="city" population="2.5 million" timezone="-5 UTC"/> + </outline> + <outline text="United States of America" type="country"/> + </outline> + <outline text="South America" type="continent"> + <outline text="Brazil" type="country" population="186 million"/> + <outline text="Argentina" type="country" population="40 million"/> + </outline> +</geography> + diff --git a/js/dojo/dojox/data/demos/openSearchProxy.php b/js/dojo/dojox/data/demos/openSearchProxy.php new file mode 100644 index 0000000..4f66307 --- /dev/null +++ b/js/dojo/dojox/data/demos/openSearchProxy.php @@ -0,0 +1,33 @@ +<?php +// A simple proxy for testing the OpenSearchStore +// Note, this simple proxy requires a curl-enabled PHP install +if(!$_GET['url']){ return; } + +$url = str_replace(array(';;;;', '%%%%'), array('?', '&'), $_GET['url']); +if(stripos($url, "http://intertwingly.net/") === 0 || + stripos($url, "http://www.intertwingly.net/") === 0 || + stripos($url, "http://www.shutterpoint.com/") === 0 || + stripos($url, "http://technorati.com/") === 0){ + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $results = curl_exec($ch); + header('HTTP/1.1 ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . ' OK'); + if($_GET['osd'] === 'true'){ + $xml = new SimpleXMLElement($results); + if($xml->Url){ + foreach($xml->Url as $url){ + $url['template'] = $_SERVER['SCRIPT_NAME'].'?url='.str_replace(array('?', '&'), array(';;;;', '%%%%'), $url['template']); + } + header('Content-Type: text/xml'); + print $xml->asXML(); + } + }else{ + header('Content-Type: '.curl_getinfo($ch, CURLINFO_CONTENT_TYPE)); + print $results; + } +}else{ + header("HTTP/1.0 403 Forbidden"); + header("Status: 403 Forbidden"); + print "Provided URL not allowed by this demo proxy."; +} + diff --git a/js/dojo/dojox/data/demos/picasaDemo.css b/js/dojo/dojox/data/demos/picasaDemo.css new file mode 100644 index 0000000..e274f87 --- /dev/null +++ b/js/dojo/dojox/data/demos/picasaDemo.css @@ -0,0 +1,44 @@ +.picasaView { + padding: 3 3 3 3; + border-width: 1px; + border-style: solid; + border-color: #000000; + border-collapse: separate; + width: 100%; +} + +.picasaView th { + text-align: left; +} + +.picasaView tr { + padding: 3 3 3 3; + border-width: 1px; + border-style: solid; + border-color: #000000; +} + +.picasaView tr td { + padding: 3 3 3 3; + border-width: 1px; + border-style: solid; + border-color: #000000; +} + +.picasaView { + background-color: #EFEFEF; + float: left; + width: 250px; + height: 250px; +} + +.picasaSummary { + width: 250px; + height: 30px; + overflow: hidden; + } + +.picasaTitle { + background-color: #CCCCCC; +} + diff --git a/js/dojo/dojox/data/demos/stores/LazyLoadJSIStore.js b/js/dojo/dojox/data/demos/stores/LazyLoadJSIStore.js new file mode 100644 index 0000000..7a867a4 --- /dev/null +++ b/js/dojo/dojox/data/demos/stores/LazyLoadJSIStore.js @@ -0,0 +1,143 @@ +//>>built +// wrapped by build app +define("dojox/data/demos/stores/LazyLoadJSIStore", ["dijit","dojo","dojox","dojo/require!dojo/data/ItemFileReadStore"], function(dijit,dojo,dojox){ +dojo.provide("dojox.data.demos.stores.LazyLoadJSIStore"); +dojo.require("dojo.data.ItemFileReadStore"); + +dojo.declare("dojox.data.demos.stores.LazyLoadJSIStore", dojo.data.ItemFileReadStore, { + constructor: function(/* object */ keywordParameters){ + // LazyLoadJSIStore extends ItemFileReadStore to implement an + // example of lazy-loading/faulting in items on-demand. + // Note this is certianly not a perfect implementation, it is + // an example. + }, + + isItemLoaded: function(/*object*/ item) { + // summary: + // Overload of the isItemLoaded function to look for items of type 'stub', which indicate + // the data hasn't been loaded in yet. + // + // item: + // The item to examine. + + //For this store, if it has the value of stub for its type attribute, + //then the item basn't been fully loaded yet. It's just a placeholder. + if(this.getValue(item, "type") === "stub"){ + return false; + } + return true; + }, + + loadItem: function(keywordArgs){ + // summary: + // Overload of the loadItem function to fault in items. This assumes the data for an item is laid out + // in a RESTful sort of pattern name0/name1/data.json and so on and uses that to load the data. + // It will also detect stub items in the newly loaded item and insert the stubs into the ItemFileReadStore + // list so they can also be loaded in on-demand. + // + // item: + // The item to examine. + + var item = keywordArgs.item; + this._assertIsItem(item); + + //Build the path to the data.json for this item + //The path consists of where its parent was loaded from + //plus the item name. + var itemName = this.getValue(item, "name"); + var parent = this.getValue(item, "parent"); + var dataUrl = ""; + if (parent){ + dataUrl += (parent + "/"); + } + + //For this store, all child input data is loaded from a url that ends with data.json + dataUrl += itemName + "/data.json"; + + //Need a reference to the store to call back to its structures. + var self = this; + + // Callback for handling a successful load. + var gotData = function(data){ + //Now we need to modify the existing item a bit to take it out of stub state + //Since we extend the store and have knowledge of the internal + //structure, this can be done here. Now, is we extended + //a write store, we could call the write APIs to do this too + //But for a simple demo the diretc modification in the store function + //is sufficient. + + //Clear off the stub indicators. + delete item.type; + delete item.parent; + + //Set up the loaded values in the format ItemFileReadStore uses for attributes. + for (var i in data) { + if (dojo.isArray(data[i])) { + item[i] = data[i]; + }else{ + item[i] = [data[i]]; + } + } + + //Reset the item in the reference. + self._arrayOfAllItems[item[self._itemNumPropName]] = item; + + //Scan the new values in the item for extra stub items we need to + //add to the items array of the store so they can be lazy-loaded later... + var attributes = self.getAttributes(item); + for(i in attributes){ + var values = item[attributes[i]]; + for (var j = 0; j < values.length; j++) { + var value = values[j]; + + if(typeof value === "object"){ + if(value["stub"] ){ + //We have a stub reference here, we need to create the stub item + var stub = { + type: ["stub"], + name: [value["stub"]], // + parent: [itemName] //The child stub item is parented by this item name... + }; + if (parent) { + //Add in any parents to your parent so URL construstruction is accurate. + stub.parent[0] = parent + "/" + stub.parent[0]; + } + //Finalize the addition of the new stub item into the ItemFileReadStore list. + self._arrayOfAllItems.push(stub); + stub[self._storeRefPropName] = self; + stub[self._itemNumPropName] = (self._arrayOfAllItems.length - 1); //Last one pushed in should be the item + values[j] = stub; //Set the stub item back in its place and replace the stub notation. + } + } + } + } + + //Done processing! Call the onItem, if any. + if(keywordArgs.onItem){ + var scope = keywordArgs.scope ? keywordArgs.scope : dojo.global; + keywordArgs.onItem.call(scope, item); + } + }; + + //Callback for any errors that occur during load. + var gotError = function(error){ + //Call the onComplete, if any + if(keywordArgs.onError){ + var scope = keywordArgs.scope ? keywordArgs.scope : dojo.global; + keywordArgs.onError.call(scope, error); + } + }; + + //Fire the get and pass the proper callbacks to the deferred. + var xhrArgs = { + url: dataUrl, + handleAs: "json-comment-optional" + }; + var d = dojo.xhrGet(xhrArgs); + d.addCallback(gotData); + d.addErrback(gotError); + } +}); + + +}); diff --git a/js/dojo/dojox/data/demos/stores/filestore_dojotree.php b/js/dojo/dojox/data/demos/stores/filestore_dojotree.php new file mode 100644 index 0000000..5e19385 --- /dev/null +++ b/js/dojo/dojox/data/demos/stores/filestore_dojotree.php @@ -0,0 +1,179 @@ +<?php + //Define the root directory to use for this service. + //All file lookups are relative to this path. + $rootDir = "../../../.."; + + require_once("filestore_funcs.php"); + + //Extract the query, if any. + $query = false; + if (array_key_exists("query", $_GET)) { + $query = $_GET['query']; + $query = str_replace("\\\"", "\"", $query); + $query = json_decode($query, true); + } + //Extract relevant query options. + $queryOptions = json_decode("{}"); + $deep = false; + $ignoreCase = false; + if (array_key_exists("queryOptions", $_GET)) { + $queryOptions = $_GET['queryOptions']; + $queryOptions = str_replace("\\\"", "\"", $queryOptions); + $queryOptions = json_decode($queryOptions); + if (property_exists($queryOptions, "deep")) { + $deep = $queryOptions->deep; + } + if (property_exists($queryOptions, "ignoreCase")) { + $ignoreCase = $queryOptions->ignoreCase; + } + } + + //Extract non-dojo.data spec config options. + $expand = false; + $dirsOnly = false; + $showHiddenFiles = false; + $options = array(); + if (array_key_exists("options", $_GET)) { + $options = $_GET['options']; + $options = str_replace("\\\"", "\"", $options); + $options = json_decode($options); + if (array_search("expand", $options) > -1) { + $expand = true; + } + if (array_search("dirsOnly", $options) > -1) { + $dirsOnly = true; + } + if (array_search("showHiddenFiles", $options) > -1) { + $showHiddenFiles = true; + } + } + + + //See if a specific file was requested, or if it is just a query for files. + $path = false; + if (array_key_exists("path", $_GET)) { + $path = $_GET['path']; + } + + if (!is_string($path)) { + + $files = array(); + + //Handle query for files. Must try to generate patterns over the query + //attributes. + $patterns = array(); + if (is_array($query)) { + //Generate a series of RegExp patterns as necessary. + $keys = array_keys($query); + $total = count($keys); + if ($total > 0) { + for ($i = 0; $i < $total; $i++) { + $key = $keys[$i]; + $pattern = $query[$key]; + if (is_string($pattern)) { + $patterns[$key] = patternToRegExp($pattern); + } + } + $files = matchFiles($query, $patterns, $ignoreCase, ".", $rootDir, $deep, $dirsOnly, $expand, $showHiddenFiles); + } else { + $files = getAllFiles(".",$rootDir,$deep,$dirsOnly,$expand,$showHiddenFiles); + } + }else{ + $files = getAllFiles(".",$rootDir,$deep,$dirsOnly,$expand,$showHiddenFiles); + } + + $total = count($files); + + //Handle the sorting and paging. + $sortSpec = false; + if (array_key_exists("sort", $_GET)) { + $sortSpec = $_GET['sort']; + $sortSpec = str_replace("\\\"", "\"", $sortSpec); + $sortSpec = json_decode($sortSpec); + } + + if ($sortSpec != null) { + $comparator = createComparator($sortSpec); + usort($files,array($comparator, "compare")); + } + + //Page, if necessary. + if (array_key_exists("start", $_GET)) { + $start = $_GET['start']; + if (!is_numeric($start)) { + $start = 0; + } + $files = array_slice($files, $start); + } + if (array_key_exists("count", $_GET)) { + $count = $_GET['count']; + if (!is_numeric($count)) { + $count = $total; + } + $files = array_slice($files, 0, $count); + } + + $result = new stdClass(); + $result->total = $total; + $result->items = $files; + header("Content-Type", "text/json"); + print("/* ".json_encode($result)." */"); + } else { + //Query of a specific file (useful for fetchByIdentity and loadItem) + + //Make sure the path isn't trying to walk out of the rooted directory + //As defined by $rootDir in the top of the php script. + $rootPath = realPath($rootDir); + $fullPath = realPath($rootPath."/".$path); + + if ($fullPath !== false) { + if (strpos($fullPath,$rootPath) === 0) { + //Root the path into the tree cleaner. + if (strlen($fullPath) == strlen($rootPath)) { + $path = "."; + } else { + //Fix the path to relative of root and put back into UNIX style (even if windows). + $path = substr($fullPath,(strlen($rootPath) + 1),strlen($fullPath)); + $path = str_replace("\\", "/", $path); + } + + if (file_exists($fullPath)) { + $arr = explode("/", $path); + $size = count($arr); + + if ($size > 0) { + $fName = $arr[$size - 1]; + if ($size == 1) { + print("Setting path to: ."); + $path = "."; + } else { + $path = $arr[0]; + } + for ($i = 1; $i < ($size - 1); $i++) { + $path = $path."/".$arr[$i]; + } + $file = generateFileObj($fName, $path, $rootDir, $expand,$showHiddenFiles); + header("Content-Type", "text/json"); + print("/* ".json_encode($file)." */"); + } else { + header("HTTP/1.0 404 Not Found"); + header("Status: 404 Not Found"); + print("<b>Cannot access file: [".htmlentities($path)."]<b>"); + } + } else { + header("HTTP/1.0 404 Not Found"); + header("Status: 404 Not Found"); + print("<b>Cannot access file: [".htmlentities($path)."]<b>"); + } + } else { + header("HTTP/1.0 403 Forbidden"); + header("Status: 403 Forbidden"); + print("<b>Cannot access file: [".htmlentities($path)."]. It is outside of the root of the file service.<b>"); + } + } else { + header("HTTP/1.0 404 Not Found"); + header("Status: 404 Not Found"); + print("<b>Cannot access file: [".htmlentities($path)."]<b>"); + } + } +?> diff --git a/js/dojo/dojox/data/demos/stores/filestore_dojoxdata.php b/js/dojo/dojox/data/demos/stores/filestore_dojoxdata.php new file mode 100644 index 0000000..0360049 --- /dev/null +++ b/js/dojo/dojox/data/demos/stores/filestore_dojoxdata.php @@ -0,0 +1,179 @@ +<?php + //Define the root directory to use for this service. + //All file lookups are relative to this path. + $rootDir = "../.."; + + require_once("filestore_funcs.php"); + + //Extract the query, if any. + $query = false; + if (array_key_exists("query", $_GET)) { + $query = $_GET['query']; + $query = str_replace("\\\"", "\"", $query); + $query = json_decode($query, true); + } + //Extract relevant query options. + $queryOptions = json_decode("{}"); + $deep = false; + $ignoreCase = false; + if (array_key_exists("queryOptions", $_GET)) { + $queryOptions = $_GET['queryOptions']; + $queryOptions = str_replace("\\\"", "\"", $queryOptions); + $queryOptions = json_decode($queryOptions); + if (property_exists($queryOptions, "deep")) { + $deep = $queryOptions->deep; + } + if (property_exists($queryOptions, "ignoreCase")) { + $ignoreCase = $queryOptions->ignoreCase; + } + } + + //Extract non-dojo.data spec config options. + $expand = false; + $dirsOnly = false; + $showHiddenFiles = false; + $options = array(); + if (array_key_exists("options", $_GET)) { + $options = $_GET['options']; + $options = str_replace("\\\"", "\"", $options); + $options = json_decode($options); + if (array_search("expand", $options) > -1) { + $expand = true; + } + if (array_search("dirsOnly", $options) > -1) { + $dirsOnly = true; + } + if (array_search("showHiddenFiles", $options) > -1) { + $showHiddenFiles = true; + } + } + + + //See if a specific file was requested, or if it is just a query for files. + $path = false; + if (array_key_exists("path", $_GET)) { + $path = $_GET['path']; + } + + if (!is_string($path)) { + + $files = array(); + + //Handle query for files. Must try to generate patterns over the query + //attributes. + $patterns = array(); + if (is_array($query)) { + //Generate a series of RegExp patterns as necessary. + $keys = array_keys($query); + $total = count($keys); + if ($total > 0) { + for ($i = 0; $i < $total; $i++) { + $key = $keys[$i]; + $pattern = $query[$key]; + if (is_string($pattern)) { + $patterns[$key] = patternToRegExp($pattern); + } + } + $files = matchFiles($query, $patterns, $ignoreCase, ".", $rootDir, $deep, $dirsOnly, $expand, $showHiddenFiles); + } else { + $files = getAllFiles(".",$rootDir,$deep,$dirsOnly,$expand,$showHiddenFiles); + } + }else{ + $files = getAllFiles(".",$rootDir,$deep,$dirsOnly,$expand,$showHiddenFiles); + } + + $total = count($files); + + //Handle the sorting and paging. + $sortSpec = false; + if (array_key_exists("sort", $_GET)) { + $sortSpec = $_GET['sort']; + $sortSpec = str_replace("\\\"", "\"", $sortSpec); + $sortSpec = json_decode($sortSpec); + } + + if ($sortSpec != null) { + $comparator = createComparator($sortSpec); + usort($files,array($comparator, "compare")); + } + + //Page, if necessary. + if (array_key_exists("start", $_GET)) { + $start = $_GET['start']; + if (!is_numeric($start)) { + $start = 0; + } + $files = array_slice($files, $start); + } + if (array_key_exists("count", $_GET)) { + $count = $_GET['count']; + if (!is_numeric($count)) { + $count = $total; + } + $files = array_slice($files, 0, $count); + } + + $result; + $result->total = $total; + $result->items = $files; + header("Content-Type", "text/json"); + print("/* ".json_encode($result)." */"); + } else { + //Query of a specific file (useful for fetchByIdentity and loadItem) + + //Make sure the path isn't trying to walk out of the rooted directory + //As defined by $rootDir in the top of the php script. + $rootPath = realPath($rootDir); + $fullPath = realPath($rootPath."/".$path); + + if ($fullPath !== false) { + if (strpos($fullPath,$rootPath) === 0) { + //Root the path into the tree cleaner. + if (strlen($fullPath) == strlen($rootPath)) { + $path = "."; + } else { + //Fix the path to relative of root and put back into UNIX style (even if windows). + $path = substr($fullPath,(strlen($rootPath) + 1),strlen($fullPath)); + $path = str_replace("\\", "/", $path); + } + + if (file_exists($fullPath)) { + $arr = split("/", $path); + $size = count($arr); + + if ($size > 0) { + $fName = $arr[$size - 1]; + if ($size == 1) { + print("Setting path to: ."); + $path = "."; + } else { + $path = $arr[0]; + } + for ($i = 1; $i < ($size - 1); $i++) { + $path = $path."/".$arr[$i]; + } + $file = generateFileObj($fName, $path, $rootDir, $expand,$showHiddenFiles); + header("Content-Type", "text/json"); + print("/* ".json_encode($file)." */"); + } else { + header("HTTP/1.0 404 Not Found"); + header("Status: 404 Not Found"); + print("<b>Cannot access file: [".htmlentities($path)."]<b>"); + } + } else { + header("HTTP/1.0 404 Not Found"); + header("Status: 404 Not Found"); + print("<b>Cannot access file: [".htmlentities($path)."]<b>"); + } + } else { + header("HTTP/1.0 403 Forbidden"); + header("Status: 403 Forbidden"); + print("<b>Cannot access file: [".htmlentities($path)."]. It is outside of the root of the file service.<b>"); + } + } else { + header("HTTP/1.0 404 Not Found"); + header("Status: 404 Not Found"); + print("<b>Cannot access file: [".htmlentities($path)."]<b>"); + } + } +?> diff --git a/js/dojo/dojox/data/demos/stores/filestore_funcs.php b/js/dojo/dojox/data/demos/stores/filestore_funcs.php new file mode 100644 index 0000000..ff61139 --- /dev/null +++ b/js/dojo/dojox/data/demos/stores/filestore_funcs.php @@ -0,0 +1,366 @@ +<?php + /** + * Helper function to convert a simple pattern to a regular expression for matching. + * + * Returns a regular expression object that conforms to the defined conversion rules. + * For example: + * ca* -> /^ca.*$/ + * *ca* -> /^.*ca.*$/ + * *c\*a* -> /^.*c\*a.*$/ + * *c\*a?* -> /^.*c\*a..*$/ + * and so on. + * + * @param pattern: string + * A simple matching pattern to convert that follows basic rules: + * * Means match anything, so ca* means match anything starting with ca + * ? Means match single character. So, b?b will match to bob and bab, and so on. + * \ is an escape character. So for example, \* means do not treat * as a match, but literal character *. + * To use a \ as a character in the string, it must be escaped. So in the pattern it should be + * represented by \\ to be treated as an ordinary \ character instead of an escape. + */ + function patternToRegExp(/*String*/$pattern){ + $rxp = "^"; + $c = ""; + $len = strlen($pattern); + for ($i = 0; $i < $len; $i++) { + $c = $pattern[$i]; + switch ($c) { + case '\\': + $rxp = $rxp.$c; + $i++; + $rxp = $rxp.$pattern[$i]; + break; + case '*': + $rxp = $rxp.".*"; break; + case '?': + $rxp = $rxp."."; break; + case '$': + case '^': + case '/': + case '+': + case '.': + case '|': + case '(': + case ')': + case '{': + case '}': + case '[': + case ']': + $rxp = $rxp."\\"; //fallthrough + default: + $rxp = $rxp.$c; + } + } + return "(".$rxp."$)"; + } + + /** + * Function to load all file info from a particular directory. + * + * @param $dir The dir to seach from, relative to $rootDir. + * @param $rootDir The directory where the file service is rooted, used as separate var to allow easier checking and prevention of ../ing out of the tree. + * @param $recurse Whether or not to deep scan the dir and return all subfiles, or just return the toplevel files. + * @param $dirsOnly boolean to enote to only return directory names, not filenames. + * @param $expand boolean to indicate whether or not to inflate all children files along a path/file, or leave them as stubs. + * @param $showHiddenFiles boolean to indicate to return hidden files as part of the list. + */ + function getAllfiles($dir, $rootDir, $recurse, $dirsOnly, $expand, $showHiddenFiles) { + // summary: + // A function to obtain all the files in a particular directory (file or dir) + $files = array(); + $dirHandle = opendir($rootDir."/".$dir); + if ($dirHandle) { + while($file = readdir($dirHandle)) { + if ($file) { + if ($file != ".." && $file != ".") { + $path = $dir."/".$file; + $fileObj = generateFileObj($file, $dir, $rootDir,$expand,$showHiddenFiles); + if (is_dir($rootDir."/".$path)) { + if ($recurse) { + if ($showHiddenFiles || $fileObj["name"][0] != '.') { + $subfiles = getAllfiles($path,$rootDir,$recurse,$dirsOnly,$expand,$showHiddenFiles); + $length = count($subfiles); + for ($i = 0; $i < $length; $i++) { + $files[] = $subfiles[$i]; + } + } + } + } + if (!$dirsOnly || $fileObj["directory"]) { + if ($showHiddenFiles || $fileObj["name"][0] !== '.') { + $files[] = $fileObj; + } + } + } + } + } + } + closedir($dirHandle); + return $files; + } + + /** + * Function to generate an associative map of data about a specific file. + * @param $file The name of the file this object represents. + * @param $dir The sub-path that contains the file defined by $file + * @param $rootDir The directory from which to append dir and name to get the full path to the file. + * @param $expand boolean to denote that if the file is a directory, expand all children in the children attribute + * to a a full object + * @param $showHiddenFiles boolean to denote if hidden files should be shown in-view or not. + * + * @return Associative Map. The details about the file: + * $file["name"] - Returns the shortname of the file. + * $file["parentDir"] - Returns the relative path from the service root for the parent directory containing file $file["name"] + * $file["path"] - The relative path to the file. + * $file["directory"] - Boolean indicator if the file represents a directory. + * $file["size"] - The size of the file, in bytes. + * $file["modified] - The modified date of the file in milliseconds since Jan 1st, 1970. + * $file["children"] - Children files of a directory. Empty if a standard file. + */ + function generateFileObj($file, $dir, $rootDir, $expand, $showHiddenFiles) { + // summary: + // Function to generate an object representation of a disk file. + $path = $file; + if ($dir != "." && $dir != "./") { + $path = $dir."/".$file; + } + + $fullPath = $rootDir."/".$path; + + $atts = stat($fullPath); + + $rootPath = realPath($rootDir); + $resolvedDir = realPath($rootDir."/".$dir); + $resolvedFullPath = realPath($fullPath); + + //Try to normalize down the paths so it does a consistent return. + if (strcmp($rootPath, $resolvedDir) === 0) { + $dir = "."; + } else { + $dir = substr($resolvedDir, (strlen($rootPath) + 1), strlen($resolvedDir)); + $dir = "./".str_replace("\\","/",$dir); + } + if (strcmp($rootPath, $resolvedFullPath) === 0) { + $path = "."; + } else { + $path = substr($resolvedFullPath, (strlen($rootPath) + 1), strlen($resolvedFullPath)); + $path = "./".str_replace("\\","/",$path); + } + + $fObj = array(); + $fObj["name"] = $file; + $fObj["parentDir"] = $dir; + $fObj["path"] = $path; + $fObj["directory"] = is_dir($fullPath); + $fObj["size"] = filesize($fullPath); + $fObj["modified"] = $atts[9]; + + if (is_dir($fullPath)) { + $children = array(); + $dirHandle = opendir($fullPath); + while($cFile = readdir($dirHandle)) { + if ($cFile) { + if ($cFile != ".." && $cFile != ".") { + if ($showHiddenFiles || $cFile[0] != '.') { + if (!$expand) { + $children[] = $cFile; + }else{ + $children[] = generateFileObj($cFile, $path, $rootDir, $expand, $showHiddenFiles); + } + } + } + } + } + closedir($dirHandle); + $fObj["children"] = $children; + } + return $fObj; + } + + /** + * A field comparator class, whose role it is to define which fields on an associaive map to compare on + * and provide the comparison function to do so. + */ + class FieldComparator { + var $field; + var $descending = false; + + /** + * Constructor. + * @param $f The field of the item to compare. + * @param $d Parameter denoting whether it should be ascending or descending. Default is ascending. + */ + function FieldComparator($f, $d) { + $this->field = $f; + $this->descending = $d; + } + + /** + * Function to compare file objects A and B on the field defined by $this->field. + * @param $fileA The first file to compare. + * @param #fileB The second file to compare. + */ + function compare($fileA,$fileB){ + $f = $this->field; + $a = $fileA[$f]; + $b = $fileB[$f]; + + $ret = 0; + if (is_string($a) && is_string($b)) { + $ret = strcmp($a,$b); + } else if($a > $b || $a === null){ + $ret = 1; + }else if($a < $b || $b === null){ + $ret = -1; + } + + if (property_exists($this, "descending") && $this->descending == true) { + $ret = $ret * -1; + } + + if ($ret > 0) { + $ret = 1; + } else if ($ret < 0) { + $ret = -1; + } + return $ret; //int, {-1,0,1} + } + } + + /** + * A compound comparator class, whose role it is to sequentially call a set of comparators on two objects and + * return the combined result of the comparison. + */ + class CompoundComparator { + //Comparator chain. + var $comparators = array(); + + /** + * Function to compare two objects $a and $b, using the chain of comparators. + * @param $a The first object to compare. + * @param $b The second object to compare. + * @returns -1, 0, 1. -1 if a < b, 1 if a > b, and 0 if a = b. + */ + function compare($a, $b) { + $ret = 0; + $size = count($this->comparators); + for ($i = 0; $i < $size; $i++) { + $comp = $this->comparators[$i]; + $ret = $comp->compare($a, $b); + if ($ret != 0) { + break; + } + } + return $ret; + } + + /** + * Function to add a comparator to the chain. + * @param $comp The comparator to add. + */ + function addComparator($comp){ + $this->comparators[] = $comp; + } + } + + /** + * A function to create a Comparator class with chained comparators based off the sort specification passed into the store. + * @param $sortSpec The Sort specification, which is an array of sort objects containing ( attribute: "someStr": descending: true|fase} + * @returns The constructed comparator. + */ + function createComparator($sortSpec) { + //Function to construct the class that handles chained comparisons. + $comparator = new CompoundComparator(); + $size = count($sortSpec); + for ($i = 0; $i < $size; $i++) { + $sort = $sortSpec[$i]; + $desc = false; + if(property_exists($sort, "descending")){ + $desc = $sort->descending; + } + $fileComp = new FieldComparator($sort->attribute,$desc); + $comparator->addComparator($fileComp); + } + return $comparator; + } + + /** + * Function to match a set of queries against a directory and possibly all subfiles. + * @param query The Query send in to process and test against. + * @param patterns The set of regexp patterns generated off the query. + * @param dir the directory to search in. + * @param recurse Whether or not to recurse into subdirs and test files there too. + * + * @return Array. Returns an array of all matches of the query. + */ + function matchFiles($query, $patterns, $ignoreCase, $dir, $rootDir, $recurse, $dirsOnly, $expand, $showHiddenFiles) { + $files = array(); + $fullDir = $rootDir."/".$dir; + + if ($fullDir != null && is_dir($fullDir)) { + + $dirHandle = opendir($fullDir); + while ($file = readdir($dirHandle)) { + if ($file != "." && $file != "..") { + $item = generateFileObj($file, $dir, $rootDir, $expand,$showHiddenFiles); + $keys = array_keys($patterns); + $total = count($keys); + for ($i = 0; $i < $total; $i++) { + $key = $keys[$i]; + $pattern = $query[$key]; + $matched = containsValue($item,$key,$query[$key],$patterns[$key], $ignoreCase); + if (!$matched) { + break; + } + } + if ($matched) { + if (!$dirsOnly || $item["directory"]) { + if ($showHiddenFiles || $item["name"][0] != '.') { + $files[] = $item; + } + } + } + + if (is_dir($rootDir."/".$item["path"]) && $recurse) { + if ($showHiddenFiles || $item["name"][0] != '.') { + $files = array_merge($files, matchFiles($query, $patterns, $ignoreCase, $item["path"], $rootDir, $recurse, $dirsOnly, $expand, $showHiddenFiles)); + } + } + } + } + closedir($dirHandle); + } + return $files; + } + + /** + * Function to handle comparing the value of an attribute on a file item. + * @param item The item to examine. + * @param attr The attribute of the tem to examine. + * @parma value The value to compare it to. + * @param rExp A regular Expression pattern object generated off 'value' if any. + * + * @returns boolean denoting if the value was matched or not. + */ + function containsValue($item, $attr, $value, $rExp, $ignoreCase) { + $matched = false; + $possibleValue = $item[$attr]; + if ($possibleValue === null && $value === null) { + $matched = true; + } else { + if ($rExp != null && is_string($possibleValue)) { + if ($ignoreCase) { + $matched = eregi($rExp, $possibleValue); + } else { + $matched = ereg($rExp, $possibleValue); + } + + } else { + if ($value != null && $possibleValue != null) { + $matched = ($value == $possibleValue); + } + } + } + return $matched; + } +// No closing PHP tag on purpose. Do not want it to print whitepace and thus not allow setting headers later. diff --git a/js/dojo/dojox/data/demos/widgets/FileView.js b/js/dojo/dojox/data/demos/widgets/FileView.js new file mode 100644 index 0000000..5fa9e46 --- /dev/null +++ b/js/dojo/dojox/data/demos/widgets/FileView.js @@ -0,0 +1,45 @@ +//>>built +// wrapped by build app +define("dojox/data/demos/widgets/FileView", ["dijit","dojo","dojox","dojo/require!dijit/_Templated,dijit/_Widget"], function(dijit,dojo,dojox){ +dojo.provide("dojox.data.demos.widgets.FileView"); +dojo.require("dijit._Templated"); +dojo.require("dijit._Widget"); + +dojo.declare("dojox.data.demos.widgets.FileView", [dijit._Widget, dijit._Templated], { + //Simple demo widget for representing a view of a Flickr Item. + + templateString: dojo.cache("dojox", "data/demos/widgets/templates/FileView.html", "<div class=\"fileView\">\n\t<div class=\"fileViewTitle\">File Details:</div>\n\t<table class=\"fileViewTable\">\n\t\t<tbody>\n\t\t\t<tr class=\"fileName\">\n\t\t\t\t<td>\n\t\t\t\t\t<b>\n\t\t\t\t\t\tName:\n\t\t\t\t\t</b>\n\t\t\t\t</td>\n\t\t\t\t<td dojoAttachPoint=\"nameNode\">\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<b>\n\t\t\t\t\t\tPath:\n\t\t\t\t\t</b>\n\t\t\t\t</td>\n\t\t\t\t<td dojoAttachPoint=\"pathNode\">\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<b>\n\t\t\t\t\t\tSize:\n\t\t\t\t\t</b>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span dojoAttachPoint=\"sizeNode\"></span> bytes.\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<b>\n\t\t\t\t\t\tIs Directory:\n\t\t\t\t\t</b>\n\t\t\t\t</td>\n\t\t\t\t<td dojoAttachPoint=\"directoryNode\">\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<b>\n\t\t\t\t\t\tParent Directory:\n\t\t\t\t\t</b>\n\t\t\t\t</td>\n\t\t\t\t<td dojoAttachPoint=\"parentDirNode\">\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<b>\n\t\t\t\t\t\tChildren:\n\t\t\t\t\t</b>\n\t\t\t\t</td>\n\t\t\t\t<td dojoAttachPoint=\"childrenNode\">\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n"), + + //Attach points for reference. + titleNode: null, + descriptionNode: null, + imageNode: null, + authorNode: null, + + name: "", + path: "", + size: 0, + directory: false, + parentDir: "", + children: [], + + postCreate: function(){ + this.nameNode.appendChild(document.createTextNode(this.name)); + this.pathNode.appendChild(document.createTextNode(this.path)); + this.sizeNode.appendChild(document.createTextNode(this.size)); + this.directoryNode.appendChild(document.createTextNode(this.directory)); + this.parentDirNode.appendChild(document.createTextNode(this.parentDir)); + if (this.children && this.children.length > 0) { + var i; + for (i = 0; i < this.children.length; i++) { + var tNode = document.createTextNode(this.children[i]); + this.childrenNode.appendChild(tNode); + if (i < (this.children.length - 1)) { + this.childrenNode.appendChild(document.createElement("br")); + } + } + } + } +}); + +}); diff --git a/js/dojo/dojox/data/demos/widgets/FlickrViewList.js b/js/dojo/dojox/data/demos/widgets/FlickrViewList.js new file mode 100644 index 0000000..294a7d6 --- /dev/null +++ b/js/dojo/dojox/data/demos/widgets/FlickrViewList.js @@ -0,0 +1,35 @@ +//>>built +// wrapped by build app +define("dojox/data/demos/widgets/FlickrViewList", ["dijit","dojo","dojox","dojo/require!dojox/dtl/_Templated,dijit/_Widget"], function(dijit,dojo,dojox){ +dojo.provide("dojox.data.demos.widgets.FlickrViewList"); +dojo.require("dojox.dtl._Templated"); +dojo.require("dijit._Widget"); + +dojo.declare("dojox.data.demos.widgets.FlickrViewList", + [ dijit._Widget, dojox.dtl._Templated ], + { + store: null, + items: null, + + templateString: dojo.cache("dojox", "data/demos/widgets/templates/FlickrViewList.html", "{% load dojox.dtl.contrib.data %}\n{% bind_data items to store as flickr %}\n<div dojoAttachPoint=\"list\">\n\t{% for item in flickr %}\n\t<div style=\"display: inline-block; align: top;\">\n\t\t<h5>{{ item.title }}</h5>\n\t\t<a href=\"{{ item.link }}\" style=\"border: none;\">\n\t\t\t<img src=\"{{ item.imageUrlMedium }}\">\n\t\t</a>\n\t\t<p>{{ item.author }}</p>\n\n\t\t<!--\n\t\t<img src=\"{{ item.imageUrl }}\">\n\t\t<p>{{ item.imageUrl }}</p>\n\t\t<img src=\"{{ item.imageUrlSmall }}\">\n\t\t-->\n\t</div>\n\t{% endfor %}\n</div>\n\n"), + + fetch: function(request){ + request.onComplete = dojo.hitch(this, "onComplete"); + request.onError = dojo.hitch(this, "onError"); + return this.store.fetch(request); + }, + + onError: function(){ + console.trace(); + this.items = []; + this.render(); + }, + + onComplete: function(items, request){ + this.items = items||[]; + this.render(); + } + } +); + +}); diff --git a/js/dojo/dojox/data/demos/widgets/PicasaView.js b/js/dojo/dojox/data/demos/widgets/PicasaView.js new file mode 100644 index 0000000..79b54bf --- /dev/null +++ b/js/dojo/dojox/data/demos/widgets/PicasaView.js @@ -0,0 +1,38 @@ +//>>built +// wrapped by build app +define("dojox/data/demos/widgets/PicasaView", ["dijit","dojo","dojox","dojo/require!dijit/_Templated,dijit/_Widget"], function(dijit,dojo,dojox){ +dojo.provide("dojox.data.demos.widgets.PicasaView"); +dojo.require("dijit._Templated"); +dojo.require("dijit._Widget"); + +dojo.declare("dojox.data.demos.widgets.PicasaView", [dijit._Widget, dijit._Templated], { + //Simple demo widget for representing a view of a Picasa Item. + + templateString: dojo.cache("dojox", "data/demos/widgets/templates/PicasaView.html", "<table class=\"picasaView\">\n\t<tbody>\n\t\t<tr class=\"picasaTitle\">\n\t\t\t<td>\n\t\t\t\t<b>\n\t\t\t\t\tTitle:\n\t\t\t\t</b>\n\t\t\t</td>\n\t\t\t<td dojoAttachPoint=\"titleNode\">\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t<b>\n\t\t\t\t\tAuthor:\n\t\t\t\t</b>\n\t\t\t</td>\n\t\t\t<td dojoAttachPoint=\"authorNode\">\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td colspan=\"2\">\n\t\t\t\t<b>\n\t\t\t\t\tSummary:\n\t\t\t\t</b>\n\t\t\t\t<span class=\"picasaSummary\" dojoAttachPoint=\"descriptionNode\"></span>\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td dojoAttachPoint=\"imageNode\" colspan=\"2\">\n\t\t\t</td>\n\t\t</tr>\n\t</tbody>\n</table>\n\n"), + + //Attach points for reference. + titleNode: null, + descriptionNode: null, + imageNode: null, + authorNode: null, + + title: "", + author: "", + imageUrl: "", + iconUrl: "", + + postCreate: function(){ + this.titleNode.appendChild(document.createTextNode(this.title)); + this.authorNode.appendChild(document.createTextNode(this.author)); + this.descriptionNode.appendChild(document.createTextNode(this.description)); + var href = document.createElement("a"); + href.setAttribute("href", this.imageUrl); + href.setAttribute("target", "_blank"); + var imageTag = document.createElement("img"); + imageTag.setAttribute("src", this.iconUrl); + href.appendChild(imageTag); + this.imageNode.appendChild(href); + } +}); + +}); diff --git a/js/dojo/dojox/data/demos/widgets/PicasaViewList.js b/js/dojo/dojox/data/demos/widgets/PicasaViewList.js new file mode 100644 index 0000000..36b26dd --- /dev/null +++ b/js/dojo/dojox/data/demos/widgets/PicasaViewList.js @@ -0,0 +1,38 @@ +//>>built +// wrapped by build app +define("dojox/data/demos/widgets/PicasaViewList", ["dijit","dojo","dojox","dojo/require!dijit/_Templated,dijit/_Widget,dojox/data/demos/widgets/PicasaView"], function(dijit,dojo,dojox){ +dojo.provide("dojox.data.demos.widgets.PicasaViewList"); +dojo.require("dijit._Templated"); +dojo.require("dijit._Widget"); +dojo.require("dojox.data.demos.widgets.PicasaView"); + +dojo.declare("dojox.data.demos.widgets.PicasaViewList", [dijit._Widget, dijit._Templated], { + //Simple demo widget that is just a list of PicasaView Widgets. + + templateString: dojo.cache("dojox", "data/demos/widgets/templates/PicasaViewList.html", "<div dojoAttachPoint=\"list\"></div>\n\n"), + + //Attach points for reference. + listNode: null, + + postCreate: function(){ + this.fViewWidgets = []; + }, + + clearList: function(){ + while(this.list.firstChild){ + this.list.removeChild(this.list.firstChild); + } + for(var i = 0; i < this.fViewWidgets.length; i++){ + this.fViewWidgets[i].destroy(); + } + this.fViewWidgets = []; + }, + + addView: function(viewData){ + var newView = new dojox.data.demos.widgets.PicasaView(viewData); + this.fViewWidgets.push(newView); + this.list.appendChild(newView.domNode); + } +}); + +}); diff --git a/js/dojo/dojox/data/demos/widgets/templates/FileView.html b/js/dojo/dojox/data/demos/widgets/templates/FileView.html new file mode 100644 index 0000000..a83fd28 --- /dev/null +++ b/js/dojo/dojox/data/demos/widgets/templates/FileView.html @@ -0,0 +1,62 @@ +<div class="fileView"> + <div class="fileViewTitle">File Details:</div> + <table class="fileViewTable"> + <tbody> + <tr class="fileName"> + <td> + <b> + Name: + </b> + </td> + <td dojoAttachPoint="nameNode"> + </td> + </tr> + <tr> + <td> + <b> + Path: + </b> + </td> + <td dojoAttachPoint="pathNode"> + </td> + </tr> + <tr> + <td> + <b> + Size: + </b> + </td> + <td> + <span dojoAttachPoint="sizeNode"></span> bytes. + </td> + </tr> + <tr> + <td> + <b> + Is Directory: + </b> + </td> + <td dojoAttachPoint="directoryNode"> + </td> + </tr> + <tr> + <td> + <b> + Parent Directory: + </b> + </td> + <td dojoAttachPoint="parentDirNode"> + </td> + </tr> + <tr> + <td> + <b> + Children: + </b> + </td> + <td dojoAttachPoint="childrenNode"> + </td> + </tr> + </tbody> + </table> +</div> diff --git a/js/dojo/dojox/data/demos/widgets/templates/FlickrViewList.html b/js/dojo/dojox/data/demos/widgets/templates/FlickrViewList.html new file mode 100644 index 0000000..e9fe02f --- /dev/null +++ b/js/dojo/dojox/data/demos/widgets/templates/FlickrViewList.html @@ -0,0 +1,20 @@ +{% load dojox.dtl.contrib.data %} +{% bind_data items to store as flickr %} +<div dojoAttachPoint="list"> + {% for item in flickr %} + <div style="display: inline-block; align: top;"> + <h5>{{ item.title }}</h5> + <a href="{{ item.link }}" style="border: none;"> + <img src="{{ item.imageUrlMedium }}"> + </a> + <p>{{ item.author }}</p> + + <!-- + <img src="{{ item.imageUrl }}"> + <p>{{ item.imageUrl }}</p> + <img src="{{ item.imageUrlSmall }}"> + --> + </div> + {% endfor %} +</div> + diff --git a/js/dojo/dojox/data/demos/widgets/templates/PicasaView.html b/js/dojo/dojox/data/demos/widgets/templates/PicasaView.html new file mode 100644 index 0000000..88dbb31 --- /dev/null +++ b/js/dojo/dojox/data/demos/widgets/templates/PicasaView.html @@ -0,0 +1,35 @@ +<table class="picasaView"> + <tbody> + <tr class="picasaTitle"> + <td> + <b> + Title: + </b> + </td> + <td dojoAttachPoint="titleNode"> + </td> + </tr> + <tr> + <td> + <b> + Author: + </b> + </td> + <td dojoAttachPoint="authorNode"> + </td> + </tr> + <tr> + <td colspan="2"> + <b> + Summary: + </b> + <span class="picasaSummary" dojoAttachPoint="descriptionNode"></span> + </td> + </tr> + <tr> + <td dojoAttachPoint="imageNode" colspan="2"> + </td> + </tr> + </tbody> +</table> + diff --git a/js/dojo/dojox/data/demos/widgets/templates/PicasaViewList.html b/js/dojo/dojox/data/demos/widgets/templates/PicasaViewList.html new file mode 100644 index 0000000..3a9f565 --- /dev/null +++ b/js/dojo/dojox/data/demos/widgets/templates/PicasaViewList.html @@ -0,0 +1,2 @@ +<div dojoAttachPoint="list"></div> + |
