home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Services / Blogging / Driver.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  3.7 KB  |  132 lines

  1. <?php
  2. require_once 'Services/Blogging/Post.php';
  3.  
  4. /**
  5. * A PHP interface to blogging APIs
  6. *
  7. * @category Services
  8. * @package  Services_Blogging
  9. * @author   Anant Narayanan <anant@php.net>
  10. * @author   Christian Weiske <cweiske@php.net>
  11. * @license  http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  12. * @link     http://pear.php.net/package/Services_Blogging
  13. */
  14. abstract class Services_Blogging_Driver
  15. {
  16.     /**
  17.     * Error code: Username or password doesn't exist/are wrong
  18.     */
  19.     const ERROR_USERIDPASS = 102;
  20.  
  21.     /**
  22.     * Error code: Unsupported post type used in createPost()
  23.     */
  24.     const ERROR_WRONGPOSTTYPE = 103;
  25.  
  26.  
  27.  
  28.     /**
  29.     * Save a new post into the blog.
  30.     *
  31.     * @param Services_Blogging_Post $post Post object to put online
  32.     *
  33.     * @return string The ID assigned to the post
  34.     */
  35.     abstract public function savePost(Services_Blogging_Post $post);
  36.  
  37.  
  38.  
  39.     /**
  40.     * Delete a given post
  41.     *
  42.     * @param mixed $post Services_Blogging_Post object to delete,
  43.     *                     or post id (integer) to delete
  44.     *
  45.     * @return boolean True if deleted, false if not.
  46.     */
  47.     abstract public function deletePost($post);
  48.  
  49.  
  50.  
  51.     /**
  52.     * Returns an array of strings thay define
  53.     * the properties that a post to this blog may have.
  54.     *
  55.     * @param string $strPostType Type of post to create.
  56.     *                            @see getSupportedPostTypes()
  57.     *
  58.     * @return array Array of strings
  59.     */
  60.     abstract public function getSupportedPostProperties($strPostType = 'post');
  61.  
  62.  
  63.  
  64.     /**
  65.     * Checks if the given property name/id is supported
  66.     * for this driver.
  67.     *
  68.     * @param string $strProperty Property name/id to check
  69.     * @param string $strPostType Type of post to create.
  70.     *                            @see getSupportedPostTypes()
  71.     *
  72.     * @return boolean If the property is supported
  73.     */
  74.     abstract public function isPostPropertySupported(
  75.         $strProperty, $strPostType = 'post'
  76.     );
  77.  
  78.  
  79.  
  80.     /**
  81.     * Creates a new post object and returns that.
  82.     * Automatically sets the driver object in the post.
  83.     *
  84.     * Needs to be overwritten by drivers supporting multiple post types.
  85.     *
  86.     * @param string $strPostType Type of post to create.
  87.     *                            @see getSupportedPostTypes()
  88.     *
  89.     * @return Services_Blogging_Post New post object
  90.     *
  91.     * @throws Services_Blogging_Driver_Exception When an unsupported post
  92.     *  type is used.
  93.     */
  94.     public function createNewPost($strPostType = 'post')
  95.     {
  96.         //this does not make much sense for drivers with only one
  97.         // post type, but it helps to keep apps consistent by
  98.         // validating parameters
  99.         $arSupportedTypes = $this->getSupportedPostTypes();
  100.         if (!in_array($strPostType, $arSupportedTypes)) {
  101.             throw new Services_Blogging_Driver_Exception(
  102.                 'Unsupported post type "' . $strPostType . '"',
  103.                 self::ERROR_WRONGPOSTTYPE
  104.             );
  105.         }
  106.  
  107.         //when overwriting this method, create the different post instances
  108.         // here
  109.         return new Services_Blogging_Post($this);
  110.     }//public function createNewPost(..)
  111.  
  112.  
  113.  
  114.     /**
  115.     * Returns an array of supported post types. Pass one of them
  116.     * to createNewPost() to instantiate such a post object.
  117.     *
  118.     * Useful for drivers that support multiple post types like
  119.     * normal post ("post"), video and such. Most drivers support posts
  120.     * only.
  121.     *
  122.     * Needs to be overwritten by drivers supporting post types.
  123.     *
  124.     * @return array Array of strings (post types)
  125.     */
  126.     public function getSupportedPostTypes()
  127.     {
  128.         return array('post');
  129.     }//public function getSupportedPostTypes()
  130.  
  131. }//abstract class Services_Blogging_Driver
  132. ?>