Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordave@33eels.com <dave@33eels.com@4eb1ac78-321c-0410-a911-ec516a8615a5>2009-03-09 12:28:15 (GMT)
committer dave@33eels.com <dave@33eels.com@4eb1ac78-321c-0410-a911-ec516a8615a5>2009-03-09 12:28:15 (GMT)
commit0bd20ee1088db16225d4ab6a0ad6d30aad4862c3 (patch)
tree81d72693383875d7c00730a328ce10cebf930f31
parent0544c48df147b9594a99dbd5c60562b008e50707 (diff)
- Retrieving, storing, displaying addon author(s).
git-svn-id: http://svn.mozilla.org/addons/trunk@23009 4eb1ac78-321c-0410-a911-ec516a8615a5
-rw-r--r--bandwagon/components/bandwagon-service.js13
-rw-r--r--bandwagon/content/scripts/factory/collectionFactory.js59
-rw-r--r--bandwagon/content/ui/bindings/bandwagon.xml44
-rw-r--r--bandwagon/content/ui/collectionsPaneController.js2
4 files changed, 108 insertions, 10 deletions
diff --git a/bandwagon/components/bandwagon-service.js b/bandwagon/components/bandwagon-service.js
index bf3eb57..3d3d288 100644
--- a/bandwagon/components/bandwagon-service.js
+++ b/bandwagon/components/bandwagon-service.js
@@ -495,6 +495,12 @@ BandwagonService.prototype = {
}
},
+ forceCheckAllForUpdatesAndUpdateCollectionsList: function()
+ {
+ this.forceCheckAllForUpdates();
+ this.updateCollectionsList();
+ },
+
/** OBSOLETE
subscribe: function(collection)
{
@@ -693,7 +699,7 @@ BandwagonService.prototype = {
if (cookie instanceof Ci.nsICookie)
{
- if (cookie.host == Bandwagon.AMO_AUTH_COOKIE_HOST && cookie.name == AMO_AUTH_COOKIE_NAME)
+ if (cookie.host == Bandwagon.AMO_AUTH_COOKIE_HOST && cookie.name == Bandwagon.AMO_AUTH_COOKIE_NAME)
return true;
}
}
@@ -837,6 +843,11 @@ BandwagonService.prototype = {
+ "comment TEXT NOT NULL, "
+ "author TEXT NOT NULL)"
);
+ this._storageConnection.executeSimpleSQL(
+ "CREATE TABLE IF NOT EXISTS addonAuthors "
+ + "(addon INTEGER NOT NULL, "
+ + "author TEXT NOT NULL)"
+ );
}
catch (e)
{
diff --git a/bandwagon/content/scripts/factory/collectionFactory.js b/bandwagon/content/scripts/factory/collectionFactory.js
index 58372c8..b237d19 100644
--- a/bandwagon/content/scripts/factory/collectionFactory.js
+++ b/bandwagon/content/scripts/factory/collectionFactory.js
@@ -244,6 +244,7 @@ Bandwagon.Factory.CollectionFactory.prototype._openAddons = function(collection)
addon.compatibleOS = this._openAddonCompatibleOS(addon);
addon.installs = this._openAddonInstalls(addon);
addon.comments = this._openAddonComments(addon);
+ addon.authors = this._openAddonAuthors(addon);
addons[addon.guid] = addon;
}
@@ -372,6 +373,29 @@ Bandwagon.Factory.CollectionFactory.prototype._openAddonComments = function(addo
return comments;
}
+Bandwagon.Factory.CollectionFactory.prototype._openAddonAuthors = function(addon)
+{
+ var authors = [];
+
+ var statement = this.connection.createStatement("SELECT * FROM addonAuthors WHERE addon = ?1");
+
+ try
+ {
+ statement.bindInt32Parameter(0, addon.storageID);
+
+ while (statement.executeStep())
+ {
+ authors.push(statement.getUTF8String(1));
+ }
+ }
+ finally
+ {
+ statement.reset();
+ }
+
+ return authors;
+}
+
Bandwagon.Factory.CollectionFactory.prototype._commitAddon = function(collection, addon)
{
if (!this.connection)
@@ -467,6 +491,11 @@ Bandwagon.Factory.CollectionFactory.prototype._commitAddon = function(collection
this._commitAddonComment(addonStorageID, addon.comments[i]);
}
+ for (var id in addon.authors)
+ {
+ this._commitAddonAuthor(addonStorageID, addon.authors[id]);
+ }
+
// add the addon connector
var statement3 = this.connection.createStatement("REPLACE INTO collectionsAddons VALUES (?1, ?2, ?3, ?4)");
@@ -624,3 +653,33 @@ Bandwagon.Factory.CollectionFactory.prototype._commitAddonComment = function(add
}
}
+Bandwagon.Factory.CollectionFactory.prototype._commitAddonAuthor = function(addonStorageID, author)
+{
+ var statement = this.connection.createStatement("DELETE FROM addonAuthors WHERE addon = ?1");
+
+ try
+ {
+ statement.bindInt32Parameter(0, addonStorageID);
+ statement.execute();
+ }
+ finally
+ {
+ statement.reset();
+ }
+
+ var statement2 = this.connection.createStatement("INSERT INTO addonAuthors VALUES (?1, ?2)");
+
+ try
+ {
+ statement2.bindInt32Parameter(0, addonStorageID);
+ statement2.bindUTF8StringParameter(1, author);
+
+ statement2.execute();
+ }
+ finally
+ {
+ statement2.reset();
+ }
+}
+
+
diff --git a/bandwagon/content/ui/bindings/bandwagon.xml b/bandwagon/content/ui/bindings/bandwagon.xml
index 93cac05..47ef4aa 100644
--- a/bandwagon/content/ui/bindings/bandwagon.xml
+++ b/bandwagon/content/ui/bindings/bandwagon.xml
@@ -197,15 +197,43 @@
</setter>
</property>
- <property name="author"
- onget="return (document.getAnonymousElementByAttribute(this, 'anonid', 'author')?document.getAnonymousElementByAttribute(this, 'anonid', 'author').value:'')"
- onset="if (document.getAnonymousElementByAttribute(this, 'anonid', 'author')) document.getAnonymousElementByAttribute(this, 'anonid', 'author').value = this._stringBundle.getFormattedString('bandwagon.addon.author', [val])"
- />
+ <property name="authors"
+ onget="return (document.getAnonymousElementByAttribute(this, 'anonid', 'author')?document.getAnonymousElementByAttribute(this, 'anonid', 'author').value:'')">
+ <setter>
+ <![CDATA[
+ if (document.getAnonymousElementByAttribute(this, 'anonid', 'authors'))
+ {
+ var authors = "";
+
+ if (!val || val.length == 0)
+ {
+ authors = "?";
+ }
+ else
+ {
+ for each (var item in val)
+ {
+ authors += item + ", ";
+ }
+
+ if (authors.substring(authors.length-2) == ", ")
+ {
+ authors = authors.substring(0, authors.length-2);
+ }
+ }
+
+ document.getAnonymousElementByAttribute(this, 'anonid', 'authors').value = this._stringBundle.getFormattedString('bandwagon.addon.author', [authors]);
+ }
+ ]]>
+ </setter>
+ </property>
+ <!--
<property name="category"
onget="return (document.getAnonymousElementByAttribute(this, 'anonid', 'category')?document.getAnonymousElementByAttribute(this, 'anonid', 'category').value:'')"
onset="if (document.getAnonymousElementByAttribute(this, 'anonid', 'category')) document.getAnonymousElementByAttribute(this, 'anonid', 'category').value = this._stringBundle.getFormattedString('bandwagon.addon.category', [val])"
/>
+ -->
<property name="read"
onget="return this.getAttribute('read')"
@@ -301,8 +329,8 @@
this.description = addon.summary; // Use summary and not description
this.iconURL = addon.icon;
this.thumbnailURL = addon.thumbnail;
- this.author = (addon.author?addon.author:"Unknown");
- this.category = (addon.category?addon.category:"Unknown");
+ this.authors = addon.authors;
+ //this.category = (addon.category?addon.category:"Unknown");
this.dateAdded = addon.dateAdded;
this.read = addon.read;
@@ -466,9 +494,9 @@
<xul:label anonid="dateadded"/>
</xul:hbox>
<xul:hbox anonid="byline" flex="1">
- <xul:label anonid="author"/>
+ <xul:label anonid="authors"/>
<xul:spacer flex="1"/>
- <xul:label anonid="category"/>
+ <!--<xul:label anonid="category"/>-->
</xul:hbox>
</xul:vbox>
</xul:hbox>
diff --git a/bandwagon/content/ui/collectionsPaneController.js b/bandwagon/content/ui/collectionsPaneController.js
index 272b837..b3fb34c 100644
--- a/bandwagon/content/ui/collectionsPaneController.js
+++ b/bandwagon/content/ui/collectionsPaneController.js
@@ -246,7 +246,7 @@ Bandwagon.Controller.CollectionsPane.doUpdateAll = function(event)
{
Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionDeck.selectedIndex = 1;
- bandwagonService.forceCheckAllForUpdates();
+ bandwagonService.forceCheckAllForUpdatesAndUpdateCollectionsList();
}
Bandwagon.Controller.CollectionsPane.doSubscribe = function(event)