dojox/data/PicasaStore.js

  • Provides:

    • dojox.data.PicasaStore
  • dojox.data.PicasaStore

    • type
      Function
    • parameters:
      • args: (typeof Object)
    • source: [view]
        if(args && args.label){
         this.label = args.label;
        }
        if(args && "urlPreventCache" in args){
         this.urlPreventCache = args.urlPreventCache?true:false;
        }
        if(args && "maxResults" in args){
         this.maxResults = parseInt(args.maxResults);
         if(!this.maxResults){
          this.maxResults = 20;
         }
        }
    • summary
      Initializer for the PicasaStore store.
    • description
      The PicasaStore is a Datastore interface to one of the basic services
      of the Picasa service, the public photo feed.  This does not provide
      access to all the services of Picasa.
      This store cannot do * and ? filtering as the picasa service
      provides no interface for wildcards.
    • mixins:
      • dojo.data.util.simpleFetch: (prototype)
  • dojox.data.PicasaStore._picasaUrl

    • summary
  • dojox.data.PicasaStore._storeRef

    • summary
  • dojox.data.PicasaStore.label

    • type
      string
    • summary
      The attribute to use from the picasa item as its label.
  • dojox.data.PicasaStore.urlPreventCache

    • type
      boolean
    • summary
      Flag denoting if preventCache should be passed to dojo.io.script.
  • dojox.data.PicasaStore.maxResults

    • type
      Define
    • summary
      out how many results to return for a fetch.
  • dojox.data.PicasaStore._assertIsItem

    • type
      Function
    • parameters:
      • item: (typeof item)
        The item to test for being contained by the store.
    • source: [view]
        if(!this.isItem(item)){
         throw new Error("dojox.data.PicasaStore: a function was passed an item argument that was not an item");
        }
    • summary
      This function tests whether the item passed in is indeed an item in the store.
  • dojox.data.PicasaStore._assertIsAttribute

    • type
      Function
    • parameters:
      • attribute: (typeof attribute-name-string)
        The attribute to test for being contained by the store.
    • source: [view]
        if(typeof attribute !== "string"){
         throw new Error("dojox.data.PicasaStore: a function was passed an attribute argument that was not an attribute name string");
        }
    • summary
      This function tests whether the item passed in is indeed a valid 'attribute' like type for the store.
  • dojox.data.PicasaStore.getFeatures

    • type
      Function
    • source: [view]
        return {
         'dojo.data.api.Read': true
        };
    • summary
      See dojo.data.api.Read.getFeatures()
  • dojox.data.PicasaStore.getValue

    • type
      Function
    • parameters:
      • item: (typeof )
      • attribute: (typeof )
      • defaultValue: (typeof )
    • source: [view]
        var values = this.getValues(item, attribute);
        if(values && values.length > 0){
         return values[0];
        }
        return defaultValue;
    • summary
      See dojo.data.api.Read.getValue()
  • dojox.data.PicasaStore.getAttributes

    • type
      Function
    • parameters:
      • item: (typeof )
    • source: [view]
         return ["id", "published", "updated", "category", "title$type", "title",
          "summary$type", "summary", "rights$type", "rights", "link", "author",
          "gphoto$id", "gphoto$name", "location", "imageUrlSmall", "imageUrlMedium",
          "imageUrl", "datePublished", "dateTaken","description"];
    • summary
      See dojo.data.api.Read.getAttributes()
  • dojox.data.PicasaStore.hasAttribute

    • type
      Function
    • parameters:
      • item: (typeof )
      • attribute: (typeof )
    • source: [view]
        if(this.getValue(item,attribute)){
         return true;
        }
        return false;
    • summary
      See dojo.data.api.Read.hasAttributes()
  • dojox.data.PicasaStore.isItemLoaded

    • type
      Function
    • parameters:
      • item: (typeof )
    • source: [view]
         return this.isItem(item);
    • summary
      See dojo.data.api.Read.isItemLoaded()
  • dojox.data.PicasaStore.loadItem

    • type
      Function
    • parameters:
      • keywordArgs: (typeof )
    • source: [view]
        // summary:
        // See dojo.data.api.Read.loadItem()
    • summary
      See dojo.data.api.Read.loadItem()
  • dojox.data.PicasaStore.getLabel

    • type
      Function
    • parameters:
      • item: (typeof )
    • source: [view]
        return this.getValue(item,this.label);
    • summary
      See dojo.data.api.Read.getLabel()
  • dojox.data.PicasaStore.getLabelAttributes

    • type
      Function
    • parameters:
      • item: (typeof )
    • source: [view]
        return [this.label];
    • summary
      See dojo.data.api.Read.getLabelAttributes()
  • dojox.data.PicasaStore.containsValue

    • type
      Function
    • parameters:
      • item: (typeof )
      • attribute: (typeof )
      • value: (typeof )
    • source: [view]
        var values = this.getValues(item,attribute);
        for(var i = 0; i < values.length; i++){
         if(values[i] === value){
          return true;
         }
        }
        return false;
    • summary
      See dojo.data.api.Read.containsValue()
  • dojox.data.PicasaStore.getValues

    • type
      Function
    • parameters:
      • item: (typeof )
      • attribute: (typeof )
    • source: [view]
        this._assertIsItem(item);
        this._assertIsAttribute(attribute);
        if(attribute === "title"){
         return [this._unescapeHtml(item.title)];
        }else if(attribute === "author"){
         return [this._unescapeHtml(item.author[0].name)];
        }else if(attribute === "datePublished"){
         return [dojo.date.stamp.fromISOString(item.published)];
        }else if(attribute === "dateTaken"){
         return [dojo.date.stamp.fromISOString(item.published)];
        }else if(attribute === "updated"){
         return [dojo.date.stamp.fromISOString(item.updated)];
        }else if(attribute === "imageUrlSmall"){
         return [item.media.thumbnail[1].url];
        }else if(attribute === "imageUrl"){
         return [item.content$src];
        }else if(attribute === "imageUrlMedium"){
         return [item.media.thumbnail[2].url];
        }else if(attribute === "link"){
         return [item.link[1]];
        }else if(attribute === "tags"){
         return item.tags.split(" ");
        }else if(attribute === "description"){
         return [this._unescapeHtml(item.summary)];
        }
        return [];
    • summary
      See dojo.data.api.Read.getValue()
  • dojox.data.PicasaStore.isItem

    • type
      Function
    • parameters:
      • item: (typeof )
    • source: [view]
        if(item && item[this._storeRef] === this){
         return true;
        }
        return false;
    • summary
      See dojo.data.api.Read.isItem()
  • dojox.data.PicasaStore.close

    • type
      Function
    • parameters:
      • request: (typeof )
    • source: [view]
        // summary:
        // See dojo.data.api.Read.close()
    • summary
      See dojo.data.api.Read.close()
  • dojox.data.PicasaStore._fetchItems

    • type
      Function
    • parameters:
      • request: (typeof A)
        request object
      • fetchHandler: (typeof A)
        function to call for fetched items
      • errorHandler: (typeof A)
        function to call on error
    • source: [view]
        if(!request.query){
         request.query={};
        }


        //Build up the content to send the request for.
        var content = {alt: "jsonm", pp: "1", psc: "G"};


        content['start-index'] = "1";
        if(request.query.start){
         content['start-index'] = request.query.start;
        }
        if(request.query.tags){
         content.q = request.query.tags;
        }
        if(request.query.userid){
         content.uname = request.query.userid;
        }
        if(request.query.userids){
         content.ids = request.query.userids;
        }
        if(request.query.lang){
         content.hl = request.query.lang;
        }
        content['max-results'] = this.maxResults;


        //Linking this up to Picasa is a JOY!
        var self = this;
        var handle = null;
        var myHandler = function(data){
         if(handle !== null){
          dojo.disconnect(handle);
         }


         //Process the items...
         fetchHandler(self._processPicasaData(data), request);
        };
        var getArgs = {
         url: this._picasaUrl,
         preventCache: this.urlPreventCache,
         content: content,
         callbackParamName: 'callback',
         handle: myHandler
        };
        var deferred = dojo.io.script.get(getArgs);

        
        deferred.addErrback(function(error){
         dojo.disconnect(handle);
         errorHandler(error, request);
        });
    • summary
      Fetch picasa items that match to a query
  • dojox.data.PicasaStore._processPicasaData

    • type
      Function
    • parameters:
      • data: (typeof )
    • source: [view]
        var items = [];
        if(data.feed){
         items = data.feed.entry;
         //Add on the store ref so that isItem can work.
         for(var i = 0; i < items.length; i++){
          var item = items[i];
          item[this._storeRef] = this;
         }
        }
        return items;
    • summary
  • dojox.data.PicasaStore._unescapeHtml

    • type
      Function
    • parameters:
      • str: (typeof String.)
        The string to un-escape
    • source: [view]
        if(str){
         str = str.replace(/&/gm, "&").replace(/</gm, "<").replace(/>/gm, ">").replace(/"/gm, "\"");
         str = str.replace(/'/gm, "'");
        }
        return str;
    • summary
      Utility function to un-escape XML special characters in an HTML string.
    • description
      Utility function to un-escape XML special characters in an HTML string.
    • return_summary
      HTML String converted back to the normal text (unescaped) characters (<,>,&, ", etc,).
      
      TODO: Check to see if theres already compatible escape() in dojo.string or dojo.html
  • dojox.data

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary