Author: as
Date: Fri Feb 22 16:46:08 2008
New Revision: 7441

Log:
- Better documentation for the category element of the iTunes module.

Modified:
    trunk/Feed/docs/specifications.txt
    trunk/Feed/src/modules/itunes_module.php

Modified: trunk/Feed/docs/specifications.txt
==============================================================================
--- trunk/Feed/docs/specifications.txt [iso-8859-1] (original)
+++ trunk/Feed/docs/specifications.txt [iso-8859-1] Fri Feb 22 16:46:08 2008
@@ -2157,9 +2157,45 @@
 
 Can appear multiple times. Categories can have sub-categories.
 
+The category name is specified in the attribute *text*.
+
 The ampersands (``&``) in categories must be escaped to ``&``.
 
-Valid `iTunes categories`_ values. A maximum of 3 categories are recommended.
+Valid values for categories are found in the `iTunes categories`_ section of
+the `iTunes specifications`_. A maximum of 3 categories are recommended.
+
+Create example::
+
+  // $feed is an ezcFeed object
+  $iTunes = $feed->addModule( 'iTunes' );
+
+  // add the podcast in one or more categories + sub-categories
+  $category = $iTunes->add( 'category' );
+  $category->text = 'iTunes category';
+  $subCategory = $category->add( 'category' );
+  $subCategory->text = 'iTunes sub-category';
+
+Parse example::
+
+  // $feed is an ezcFeed object
+  if ( isset( $feed->iTunes ) )
+  {
+      $iTunes = $feed->iTunes;
+      if ( isset( $iTunes->category ) )
+      {
+          foreach ( $iTunes->category as $category )
+          {
+              echo $category->text;
+              if ( isset( $category->category ) )
+              {
+                  foreach ( $category->category as $subCategory )
+                  {
+                      echo $subCategory->text;
+                  }
+              }
+          }
+      }
+  }
 
 
 iTunes-explicit
@@ -2186,7 +2222,6 @@
 The URL to the image is specified in the attribute *href*.
 
 If missing, `iTunes`_ will use the |ezcFeed-image|_ element from the feed.
-
 
 
 iTunes-keywords

Modified: trunk/Feed/src/modules/itunes_module.php
==============================================================================
--- trunk/Feed/src/modules/itunes_module.php [iso-8859-1] (original)
+++ trunk/Feed/src/modules/itunes_module.php [iso-8859-1] Fri Feb 22 16:46:08 
2008
@@ -28,13 +28,23 @@
  *
  * Parse example:
  * <code>
- * // $item is an ezcFeedItem object
- * foreach ( $item->iTunes->category as $category )
+ * // $feed is an ezcFeed object
+ * if ( isset( $feed->iTunes ) )
  * {
- *     echo $category->text;
- *     foreach ( $category->category as $subCategory )
+ *     $iTunes = $feed->iTunes;
+ *     if ( isset( $iTunes->category ) )
  *     {
- *          echo $subCategory->text;
+ *         foreach ( $iTunes->category as $category )
+ *         {
+ *             echo $category->text;
+ *             if ( isset( $category->category ) )
+ *             {
+ *                 foreach ( $category->category as $subCategory )
+ *                 {
+ *                     echo $subCategory->text;
+ *                 }
+ *             }
+ *         }
  *     }
  * }
  * </code>


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to