Plugin Directory

Changeset 808982


Ignore:
Timestamp:
11/22/2013 05:37:30 PM (12 years ago)
Author:
LordPretender
Message:

version 1.2 released.

Location:
category-class
Files:
7 added
5 edited

Legend:

Unmodified
Added
Removed
  • category-class/trunk/category-class.php

    r807831 r808982  
    66Description: This is just a class for developpers which can be used into plugins, widget, ...
    77Author: LordPretender
    8 Version: 1.0
     8Version: 1.1
    99Author URI: http://www.duy-pham.fr
    1010*/
     
    5151    */
    5252    private static $catégories = null;
     53   
     54    /**
     55    * Tableau associatif qui regroupe tous les précédents chargement de catégories en fonction des paramètres fournis.
     56    *
     57    * @var Array
     58    * @access private
     59    * @static
     60    */
     61    private static $history = null;
    5362   
    5463    /**
     
    7382        $nbPosts = is_int($nbPosts) && $nbPosts >= 0 ? $nbPosts : DEFAULT_NBPOSTS;
    7483       
    75         //Création de l'objet de départ puis chargement
    76         self::$root = new CCS_Catégorie($catID, $withSubCategories, $withPosts, $nbPosts, $withDuplicatePosts, $orderby);
     84        //Création de l'objet de départ (sauf si déjà lu plus tôt) puis chargement.
     85        if(array_key_exists($catID.$withSubCategories.$withPosts.$nbPosts.$withDuplicatePosts.$orderby, self::$history)){
     86            self::$root = self::$history[$catID.$withSubCategories.$withPosts.$nbPosts.$withDuplicatePosts.$orderby];
     87        }else{
     88            self::$root = new CCS_Catégorie($catID, $withSubCategories, $withPosts, $nbPosts, $withDuplicatePosts, $orderby);
     89           
     90            self::$history[$catID.$withSubCategories.$withPosts.$nbPosts.$withDuplicatePosts.$orderby] = self::$root;
     91        }
    7792    }
    7893   
     
    182197    }
    183198   
    184     private function __construct(){}
     199    private function __construct(){
     200        self::$history = array();
     201    }
    185202   
    186203    /**
  • category-class/trunk/inc/article.class.php

    r807831 r808982  
    66   
    77    public function __construct($WP, $catID){
    8         parent::__construct($WP->ID, $WP->post_title);
     8        parent::__construct($WP->ID, $WP->post_title, $WP);
    99       
    1010        $this->catID = $catID;
  • category-class/trunk/inc/categorie.class.php

    r807831 r808982  
    3434        }else $ID = $WP;
    3535       
    36         parent::__construct($ID, $titre);
     36        parent::__construct($ID, $titre, $WP);
    3737       
    3838        $this->sousCatégories = array();
  • category-class/trunk/inc/squelette.class.php

    r807831 r808982  
    44    protected $ID;
    55    protected $titre;
     6    protected $ObjetWP;
    67   
    7     public function __construct($ID, $titre){
     8    public function __construct($ID, $titre, $WP){
    89        $this->ID = $ID;
    910        $this->titre = $titre;
     11       
     12        //Pour rester générique, on mémorise aussi l'objet WP (de type stdClass) afin que l'on puisse utiliser d'autres paramètres
     13        $this->ObjetWP = $WP;
    1014    }
    1115   
     
    3236    }
    3337   
     38    public function getstdClass(){
     39        return $this->ObjetWP;
     40    }
     41   
     42    /**
     43    * Cette méthode sert à accéder à divers éléments de l'objet WP (de type stdClass).
     44    * @param string $param Nom de l'attribut contenu dans l'objet stdClass de WP.
     45    *
     46    * @return mixed
     47    */
     48    public function getWPElement($param){
     49        return $this->ObjetWP->$param;
     50    }
     51   
    3452    public function setTitre($titre){
    3553        $this->titre = $titre;
  • category-class/trunk/readme.txt

    r807831 r808982  
    55Requires at least: 3.6.1
    66Tested up to: 3.6.1
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88
    99Here is a library for developpers which help them to use categories and posts whithin a simple class.
     
    4141== Changelog ==
    4242
     43= 1.1 =
     44*   All request are now saved in order and will be used if needed (whereas loading them again).
     45*   stdClass objects are now saved and usable in others plugins.
     46
    4347= 1.0 =
    4448*   The first version of the plugin.
     
    4650== Upgrade Notice ==
    4751
     52= 1.1 =
     53Tested in WordPress 3.7.1
     54
    4855= 1.0 =
    4956Tested in WordPress 3.6.1
Note: See TracChangeset for help on using the changeset viewer.