Ignore:
Timestamp:
Jan 28, 2011, 4:54:02 PM (13 years ago)
Author:
grum
Message:

release 3.4.0
fix bug:1984, bug:2109
js file are minified, remove packed files

Location:
extensions/GrumPluginClasses/classes
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/GrumPluginClasses/classes/CommonPlugin.class.inc.php

    r7310 r8961  
    88  ------------------------------------------------------------------------------
    99  Author     : Grum
    10     email    : grum@grum.dnsalias.com
    11     website  : http://photos.grum.dnsalias.com
     10    email    : grum@piwigo.org
     11    website  : http://photos.grum.fr
    1212    PWG user : http://forum.phpwebgallery.net/profile.php?id=3706
    1313
  • extensions/GrumPluginClasses/classes/GPCCore.class.inc.php

    r7387 r8961  
    33/* -----------------------------------------------------------------------------
    44  class name     : GPCCore
    5   class version  : 1.3.1
    6   plugin version : 3.3.2
    7   date           : 2010-10-20
     5  class version  : 1.3.2
     6  plugin version : 3.4.0
     7  date           : 2011-01-28
    88  ------------------------------------------------------------------------------
    99  author: grum at piwigo.org
     
    2828|         |            |   extended description function if present
    2929|         |            |
    30 |         |            | * implement the getPiwigoSystemPath function
    31 |         |            |
    32 |         |            | * implement the rmDir function
     30|         |            | * implement the getPiwigoSystemPath() function
     31|         |            |
     32|         |            | * implement the rmDir() function
     33|         |            |
     34| 1.3.2   | 2011/01/28 | * implement the addUI() function
     35|         |            |
     36|         |            | * implement getMinified() & setMinifiedState() functions
     37|         |            |
    3338|         |            |
    3439|         |            |
     
    4752    - static function addHeaderCSS
    4853    - static function addHeaderJS
     54    - static function addUI
     55    - static function getMinified
     56    - static function setMinifiedState
    4957    - static function getUserLanguageDesc
    5058    - static function getPiwigoSystemPath
     
    5866{
    5967  static private $piwigoSystemPath;
     68  static private $minified='.min';
    6069
    6170  static public $pluginName = "GPCCore";
     
    7988        Array('name' => "CommonPlugin", 'version' => "2.2.0"),
    8089        Array('name' => "GPCAjax", 'version' => "3.0.0"),
    81         Array('name' => "GPCCore", 'version' => "1.3.1"),
     90        Array('name' => "GPCCategorySelector", 'version' => "1.0.1"),
     91        Array('name' => "GPCCore", 'version' => "1.3.2"),
    8292        Array('name' => "GPCCss", 'version' => "3.0.0"),
    83         Array('name' => "GPCPagesNavigations", 'version' => "2.0.0"),
     93        Array('name' => "GPCPagesNavigation", 'version' => "2.0.0"),
    8494        Array('name' => "GPCPublicIntegration", 'version' => "2.0.0"),
    85         Array('name' => "GPCRequestBuilder", 'version' => "1.1.0"),
     95        Array('name' => "GPCRequestBuilder", 'version' => "1.1.2"),
    8696        Array('name' => "GPCTables", 'version' => "1.5.0"),
    8797        Array('name' => "GPCTabSheet", 'version' => "1.1.1"),
    88         Array('name' => "GPCTranslate", 'version' => "2.1.0"),
    89         Array('name' => "GPCUsersGroups", 'version' => "2.0.0"),
     98        Array('name' => "GPCTranslate", 'version' => "2.1.1"),
     99        Array('name' => "GPCUsersGroups", 'version' => "2.1.0")
    90100      )
    91101    );
     
    365375  {
    366376    global $template;
     377    $dummy1=null;
     378    $dummy2=null;
    367379
    368380    foreach(self::$headerItems['css'] as $file)
     
    373385    foreach(self::$headerItems['js'] as $file)
    374386    {
    375       $template->append('head_elements', '<script type="text/javascript" src="'.$file.'"></script>');
    376     }
    377   }
     387      //$template->append('head_elements', '<script type="text/javascript" src="'.$file.'"></script>');
     388      $template->block_html_head(null, '<script type="text/javascript" src="'.$file.'"></script>', $dummy1, $dummy2);
     389    }
     390  }
     391
     392  /**
     393   * add a ui component ; css & js dependencies are managed
     394   *
     395   * @param Array $list : possibles values are
     396   *                        - inputCheckbox
     397   *                        - inputColorPicker
     398   *                        - inputColorsFB
     399   *                        - inputConsole
     400   *                        - inputDotArea
     401   *                        - inputList
     402   *                        - inputNum
     403   *                        - inputPosition
     404   *                        - inputRadio
     405   *                        - inputStatusBar
     406   *                        - inputText
     407   *                        - categorySelector
     408   */
     409  static public function addUI($list)
     410  {
     411    global $template;
     412
     413    if(is_string($list)) $list=explode(',', $list);
     414    if(!is_array($list)) return(false);
     415
     416    if(defined('IN_ADMIN'))
     417    {
     418      $themeFile=GPC_PATH.'css/%s_'.$template->get_themeconf('name').'.css';
     419    }
     420    else
     421    {
     422      $themeFile='themes/'.$template->get_themeconf('name').'/css/GPC%s.css';
     423    }
     424
     425    foreach($list as $ui)
     426    {
     427      switch($ui)
     428      {
     429        case 'googleTranslate':
     430          self::addHeaderJS('google.jsapi', 'http://www.google.com/jsapi');
     431          self::addHeaderJS('gpc.googleTranslate', 'plugins/GrumPluginClasses/js/google_translate'.self::$minified.'.js');
     432        case 'categorySelector':
     433          self::addHeaderCSS('gpc.categorySelector', GPC_PATH.'css/categorySelector.css');
     434          self::addHeaderCSS('gpc.categorySelectorT', sprintf($themeFile, 'categorySelector'));
     435          self::addHeaderJS('gpc.categorySelector', GPC_PATH.'js/ui.categorySelector'.self::$minified.'.js');
     436          break;
     437        case 'inputCheckbox':
     438          self::addHeaderCSS('gpc.inputCheckbox', GPC_PATH.'css/inputCheckbox.css');
     439          self::addHeaderJS('gpc.inputCheckbox', GPC_PATH.'js/ui.inputCheckbox'.self::$minified.'.js');
     440          break;
     441        case 'inputColorPicker':
     442          self::addHeaderCSS('gpc.inputText', GPC_PATH.'css/inputText.css');
     443          self::addHeaderCSS('gpc.inputNum', GPC_PATH.'css/inputNum.css');
     444          self::addHeaderCSS('gpc.inputColorsFB', GPC_PATH.'css/inputColorsFB.css');
     445          self::addHeaderCSS('gpc.inputDotArea', GPC_PATH.'css/inputDotArea.css');
     446          self::addHeaderCSS('gpc.inputColorPicker', GPC_PATH.'css/inputColorPicker.css');
     447          self::addHeaderCSS('gpc.inputTextT', sprintf($themeFile, 'inputText'));
     448          self::addHeaderCSS('gpc.inputNumT', sprintf($themeFile, 'inputNum'));
     449          self::addHeaderCSS('gpc.inputColorsFBT', sprintf($themeFile, 'inputColorsFB'));
     450          self::addHeaderCSS('gpc.inputDotAreaT', sprintf($themeFile, 'inputDotArea'));
     451          self::addHeaderCSS('gpc.inputColorPickerT', sprintf($themeFile, 'inputColorPicker'));
     452          self::addHeaderJS('jquery.ui', 'themes/default/js/ui/packed/ui.core.packed.js');
     453          self::addHeaderJS('jquery.ui.slider', 'themes/default/js/ui/packed/ui.slider.packed.js');
     454          self::addHeaderJS('jquery.ui.draggable', 'themes/default/js/ui/packed/ui.draggable.packed.js');
     455          self::addHeaderJS('jquery.ui.dialog', 'themes/default/js/ui/packed/ui.slider.dialog.js');
     456          self::addHeaderJS('gpc.inputText', GPC_PATH.'js/ui.inputText'.self::$minified.'.js');
     457          self::addHeaderJS('gpc.inputNum', GPC_PATH.'js/ui.inputNum'.self::$minified.'.js');
     458          self::addHeaderJS('gpc.inputColorsFB', GPC_PATH.'js/ui.inputColorsFB'.self::$minified.'.js');
     459          self::addHeaderJS('gpc.inputDotArea', GPC_PATH.'js/ui.inputDotArea'.self::$minified.'.js');
     460          self::addHeaderJS('gpc.inputColorPicker', GPC_PATH.'js/ui.inputColorPicker'.self::$minified.'.js');
     461          break;
     462        case 'inputColorsFB':
     463          self::addHeaderCSS('gpc.inputColorsFB', GPC_PATH.'css/inputColorsFB.css');
     464          self::addHeaderCSS('gpc.inputColorsFBT', sprintf($themeFile, 'inputColorsFB'));
     465          self::addHeaderJS('gpc.inputColorsFB', GPC_PATH.'js/ui.inputColorsFB'.self::$minified.'.js');
     466          break;
     467        case 'inputConsole':
     468          self::addHeaderCSS('gpc.inputConsole', GPC_PATH.'css/inputConsole.css');
     469          self::addHeaderCSS('gpc.inputConsoleT', sprintf($themeFile, 'inputConsole'));
     470          self::addHeaderJS('gpc.inputConsole', GPC_PATH.'js/ui.inputConsole'.self::$minified.'.js');
     471          break;
     472        case 'inputDotArea':
     473          self::addHeaderCSS('gpc.inputDotArea', GPC_PATH.'css/inputDotArea.css');
     474          self::addHeaderCSS('gpc.inputDotAreaT', sprintf($themeFile, 'inputDotArea'));
     475          self::addHeaderJS('gpc.inputDotArea', GPC_PATH.'js/ui.inputDotArea'.self::$minified.'.js');
     476          break;
     477        case 'inputList':
     478          self::addHeaderCSS('gpc.inputList', GPC_PATH.'css/inputList.css');
     479          self::addHeaderCSS('gpc.inputListT', sprintf($themeFile, 'inputList'));
     480          self::addHeaderJS('gpc.inputList', GPC_PATH.'js/ui.inputList'.self::$minified.'.js');
     481          break;
     482        case 'inputNum':
     483          self::addHeaderCSS('gpc.inputNum', GPC_PATH.'css/inputNum.css');
     484          self::addHeaderCSS('gpc.inputNumT', sprintf($themeFile, 'inputNum'));
     485          self::addHeaderJS('jquery.ui', 'themes/default/js/ui/packed/ui.core.packed.js');
     486          self::addHeaderJS('jquery.ui.slider', 'themes/default/js/ui/packed/ui.slider.packed.js');
     487          self::addHeaderJS('gpc.inputNum', GPC_PATH.'js/ui.inputNum'.self::$minified.'.js');
     488          break;
     489        case 'inputPosition':
     490          self::addHeaderCSS('gpc.inputPosition', GPC_PATH.'css/inputPosition.css');
     491          self::addHeaderCSS('gpc.inputPositionT', sprintf($themeFile, 'inputPosition'));
     492          self::addHeaderJS('gpc.inputPosition', GPC_PATH.'js/ui.inputPosition'.self::$minified.'.js');
     493          break;
     494        case 'inputRadio':
     495          self::addHeaderJS('gpc.inputRadio', GPC_PATH.'js/ui.inputRadio'.self::$minified.'.js');
     496          break;
     497        case 'inputStatusBar':
     498          self::addHeaderCSS('gpc.inputStatusBar', GPC_PATH.'css/inputStatusBar.css');
     499          self::addHeaderCSS('gpc.inputStatusBarT', sprintf($themeFile, 'inputStatusBar'));
     500          self::addHeaderJS('gpc.inputStatusBar', GPC_PATH.'js/ui.inputStatusBar'.self::$minified.'.js');
     501          break;
     502        case 'inputText':
     503          self::addHeaderCSS('gpc.inputText', GPC_PATH.'css/inputText.css');
     504          self::addHeaderCSS('gpc.inputTextT', sprintf($themeFile, 'inputText'));
     505          self::addHeaderJS('gpc.inputText', GPC_PATH.'js/ui.inputText'.self::$minified.'.js');
     506          break;
     507      }
     508    }
     509  }
     510
     511  /**
     512   * return the minified value
     513   *
     514   * @return String
     515   */
     516  static public function getMinified()
     517  {
     518    return(self::$minified);
     519  }
     520
     521  /**
     522   * set the minified state
     523   *
     524   * @param Bool $state
     525   * @return Bool
     526   */
     527  static public function setMinifiedState($state)
     528  {
     529    if($state)
     530    {
     531      self::$minified='.min';
     532    }
     533    else
     534    {
     535      self::$minified='';
     536    }
     537    return(self::$minified!='');
     538  }
     539
    378540
    379541  /**
  • extensions/GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php

    r7451 r8961  
    22/* -----------------------------------------------------------------------------
    33  class name: GCPRequestBuilder
    4   class version  : 1.1.1
    5   plugin version : 3.3.2
     4  class version  : 1.1.2
     5  plugin version : 3.3.3
    66  date           : 2010-09-08
    77
     
    7575|         |            | * fix bug on user level access to picture
    7676|         |            |
    77 |         |            |
    78 |         |            |
     77| 1.1.2   | 2010/11/01 | * mantis bug:1984
     78|         |            |   . RBuilder returns an error message when one picture
     79|         |            |     have multiple categories
    7980|         |            |
    8081|         |            |
     
    522523    GPCCore::addHeaderJS('gpc.interface', 'plugins/'.$baseName.'external/interface/interface.js');
    523524    GPCCore::addHeaderJS('gpc.inestedsortable', 'plugins/'.$baseName.'external/inestedsortable.pack.js');
    524     GPCCore::addHeaderJS('gpc.rbCriteriaBuilder', 'plugins/'.$baseName.'rbCriteriaBuilder.packed.js');
     525    GPCCore::addHeaderJS('gpc.rbCriteriaBuilder', 'plugins/'.$baseName.'rbCriteriaBuilder'.GPCCore::getMinified().'.js');
    525526
    526527    $template->append('head_elements',
     
    829830      'SELECT' => Array(
    830831        'RB_PIT' => "pit.id AS imageId, pit.name AS imageName, pit.path AS imagePath", // from the piwigo's image table
    831         'RB_PIC' => "GROUP_CONCAT(DISTINCT pic.category_id SEPARATOR ',') AS imageCategoriesId",     // from the piwigo's image_category table
    832         'RB_PCT' => "GROUP_CONCAT(DISTINCT CASE WHEN pct.name IS NULL THEN '' ELSE pct.name END SEPARATOR '#sep#') AS imageCategoriesNames,
    833                      GROUP_CONCAT(DISTINCT CASE WHEN pct.permalink IS NULL THEN '' ELSE pct.permalink END SEPARATOR '#sep#') AS imageCategoriesPLink,
    834                      GROUP_CONCAT(DISTINCT CASE WHEN pct.dir IS NULL THEN 'V' ELSE 'P' END) AS imageCategoriesDir",   //from the piwigo's categories table
     832        'RB_PIC' => "GROUP_CONCAT( pic.category_id SEPARATOR ',') AS imageCategoriesId",     // from the piwigo's image_category table
     833        'RB_PCT' => "GROUP_CONCAT( CASE WHEN pct.name IS NULL THEN '' ELSE pct.name END SEPARATOR '#sep#') AS imageCategoriesNames,
     834                     GROUP_CONCAT( CASE WHEN pct.permalink IS NULL THEN '' ELSE pct.permalink END SEPARATOR '#sep#') AS imageCategoriesPLink,
     835                     GROUP_CONCAT( CASE WHEN pct.dir IS NULL THEN 'V' ELSE 'P' END) AS imageCategoriesDir",   //from the piwigo's categories table
    835836      ),
    836837      'FROM' => Array(
     
    13741375    $filter=array_flip($filter);
    13751376
     1377    GPCCore::addHeaderJS('jquery.ui', 'themes/default/js/ui/packed/ui.core.packed.js');
     1378    GPCCore::addHeaderJS('jquery.ui.dialog', 'themes/default/js/ui/packed/ui.dialog.packed.js');
     1379    GPCCore::addHeaderJS('gpc.pagesNavigator', 'plugins/'.$baseName.'/js/pagesNavigator'.GPCCore::getMinified().'.js');
     1380    GPCCore::addHeaderJS('gpc.rbSearch', 'plugins/'.$baseName.'/js/rbSearch'.GPCCore::getMinified().'.js');
     1381
     1382
    13761383    $template->set_filename('gpc_search_page',
    13771384                dirname(dirname(__FILE__)).'/templates/GPCRequestBuilder_search.tpl');
  • extensions/GrumPluginClasses/classes/GPCTranslate.class.inc.php

    r5550 r8961  
    33/* -----------------------------------------------------------------------------
    44  class name     : GPCTranslate
    5   class version  : 2.1.0
    6   plugin version : 3.0.0
    7   date           : 2010-03-31
     5  class version  : 2.1.1
     6  plugin version : 3.4.0
     7  date           : 2011-01-28
    88  ------------------------------------------------------------------------------
    99  author: grum at piwigo.org
    1010  << May the Little SpaceFrog be with you >>
    1111  ------------------------------------------------------------------------------
    12 
    1312
    1413  ------------------------------------------------------------------------------
     
    1918| 2.1.0   | 2010/03/31 | * update class & functions names
    2019|         |            |
     20| 2.1.1   | 2011/01/09 | * fixbug on js loading
    2121|         |            |
    22 |         |            |
     22|         |            | * use GPCCore::addUI function (the class is kept for
     23|         |            |   compatibility with older plugins)
    2324|         |            |
    2425|         |            |
    2526
    2627  ------------------------------------------------------------------------------
    27 
    28 
    2928   class call API in HTML header, and provide a .js file manage API call
    3029        >>  http://code.google.com/apis/ajaxlanguage/
    3130
    3231    - constructor
    33 
    3432   ---------------------------------------------------------------------- */
    3533class GPCTranslate
     
    3735  public function __construct()
    3836  {
    39     add_event_handler('loc_end_page_header', array(&$this, 'loadJS'));
     37    GPCCore::addUI('googleTranslate');
    4038  }
    41 
    42   public function loadJS()
    43   {
    44     global $template;
    45 
    46     $googleload='
    47 <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    48 <script type="text/javascript" src="plugins/'.basename(dirname(__FILE__)).'/google_translate.js"></script>';
    49 
    50     $template->append('head_elements', $googleload);
    51   }
    52 
    5339} //class
    5440
  • extensions/GrumPluginClasses/classes/GPCUsersGroups.class.inc.php

    r5550 r8961  
    33/* -----------------------------------------------------------------------------
    44  class name: GPCAllowedAccess, GPCGroups, GPCUsers
    5   class version  : 2.0.0
    6   plugin version : 3.0.0
     5  class version  : 2.1.0
     6  plugin version : 3.4.0
    77  date           : 2010-03-30
    88  ------------------------------------------------------------------------------
     
    1414  groups and users classes extends GPCAllowedAccess classes
    1515
    16     - constructor GPCAllowedAccess($alloweds="")
    17     - constructor groups($alloweds="")
    18     - constructor users($alloweds="")
     16    - constructor GPCAllowedAccess($alloweds = array(), $accessMode='a')
     17    - constructor groups($alloweds = array(), $accessMode='a')
     18    - constructor users($alloweds = array(), $accessMode='a')
    1919    - (public) function getList()
    2020    - (public) function setAllowed($id, $allowed)
    21     - (public) function setAlloweds()
    22     - (public) function getAlloweds($return_type)
     21    - (public) function setAlloweds($idList, $allowed)
     22    - (public) function getAlloweds()
    2323    - (public) function isAllowed($id)
    24     - (public) function htmlView($sep=", ", $empty="")
    25     - (public) function htmlForm($basename)
    2624    - (private) function initList()
    2725
     
    3432|         |            | * update classes & functions names
    3533|         |            |
     34| 2.1.0   | 2011/01/15 | * remove html function
     35|         |            |
     36|         |            | * implement accessMode
     37|         |            |
    3638|         |            |
    3739
     
    3941class GPCAllowedAccess
    4042{
    41   public $access_list;
    42 
    43   /*
    44     constructor initialize the groups_getListgetListlist
    45   */
    46   public function __construct($alloweds = "")
     43  protected $accessList;
     44  protected $accessMode='a'; // 'a' : allowed, 'n' : not allowed
     45
     46  /**
     47   * constructor initialize default values
     48   *
     49   * @param Array $alloweds  : list of items
     50   *        String $alloweds : list of items (separator : '/')
     51   *
     52   * @param String $accessMode : 'a' = access is allowed by default for all values, $allowed param is a list of not allowed values
     53   *                             'n' = access is not allowed by default for all values, $allowed param is a list of allowed values
     54   *                             priority is given to the $allowed value
     55   */
     56  public function __construct($alloweds = array(), $accessMode='a')
    4757  {
    4858    $this->initList();
    49     $this->setAlloweds($alloweds);
     59    $this->setAlloweds($alloweds, $accessMode=='n');
    5060  }
    5161
    5262  public function __destruct()
    5363  {
    54     unset($this->access_list);
    55   }
    56 
    57   /*
    58     initialize the groups list
    59   */
     64    unset($this->accessList);
     65  }
     66
     67  /**
     68   * destroy the groups list
     69   */
    6070  protected function initList()
    6171  {
    62     $this->access_list=array();
    63   }
    64 
    65   /*
    66     returns list (as an array)
    67   */
     72    $this->accessList=array();
     73  }
     74
     75  /**
     76   * returns list of items (as an array)
     77   * each array item is an array :
     78   *  'id'      : (String) id of item
     79   *  'name'    : (String) name of item
     80   *  'allowed' : (Bool)   access is allowed or not
     81   *
     82   * @return Array
     83   */
    6884  function getList()
    6985  {
    70     return($this->access_list);
    71   }
    72 
    73   /*
    74     set element an allowed state
    75   */
     86    return($this->accessList);
     87  }
     88
     89  /**
     90   * set allowed value for an item
     91   *
     92   * @param String $id : id of item
     93   * @param Bool $allowed : access allowed or not
     94   */
    7695  function setAllowed($id, $allowed)
    7796  {
    78     if(isset($this->access_list[$id]))
    79     {
    80       $this->access_list[$id]['allowed']=$allowed;
    81     }
    82   }
    83 
    84   /*
    85     set a group enabled/disabled state
    86   */
    87   function setState($id, $enabled)
    88   {
    89     if(isset($this->access_list[$id]))
    90     {
    91       $this->access_list[$id]['enabled']=$enabled;
    92     }
    93   }
    94 
    95   /*
    96     set alloweds list
    97     $list is string of id, separated with "/"
    98   */
    99   function setAlloweds($list)
    100   {
    101     $alloweds=explode("/", $list);
    102     $alloweds=array_flip($alloweds);
    103     foreach($this->access_list as $key => $val)
    104     {
    105       if(isset($alloweds[$key]))
     97    if(isset($this->accessList[$id]))
     98    {
     99      $this->accessList[$id]['allowed']=$allowed;
     100    }
     101  }
     102
     103
     104  /**
     105   * set alloweds items (can be given as an array or a string with separator '/')
     106   * according to the
     107   *
     108   * @param Array $idList  : list of items to set
     109   * @param String $idList
     110   * @param Bool $allowed : access allowed or not
     111   */
     112  function setAlloweds($idList, $allowed)
     113  {
     114    if(!is_array($idList)) $idList=explode("/", $idList);
     115
     116    $idList=array_flip($idList);
     117
     118    foreach($this->accessList as $key => $val)
     119    {
     120      if(isset($idList[$key]))
    106121      {
    107         $this->access_list[$key]['allowed']=true;
     122        $this->accessList[$key]['allowed']=$allowed;
    108123      }
    109124      else
    110125      {
    111         $this->access_list[$key]['allowed']=false;
     126        $this->accessList[$key]['allowed']=!$allowed;
    112127      }
    113128    }
    114129  }
    115130
    116   /*
    117     get alloweds list
    118     return a string of groups, separated with "/"
    119   */
    120   function getAlloweds($return_type = 'name')
    121   {
    122     $returned="";
    123     foreach($this->access_list as $key => $val)
    124     {
    125       if($val['allowed'])
    126       { $returned.=$val[$return_type]."/"; }
     131
     132  /**
     133   * return list of alloweds items
     134   *
     135   * @return Array
     136   */
     137  function getAlloweds()
     138  {
     139    $returned=Array();
     140
     141    foreach($this->accessList as $key => $val)
     142    {
     143      if($val['allowed']) $returned[]=$val;
    127144    }
    128145    return($returned);
     
    130147
    131148
    132   /*
    133     returns true if is allowed
    134   */
     149  /**
     150   * returns true if is allowed
     151   *
     152   * @param String $id : item id
     153   * @retrun Bool
     154   */
    135155  function isAllowed($id)
    136156  {
    137     if(isset($this->access_list[$id]))
    138     { return($this->access_list[$id]['allowed']); }
     157    if(isset($this->accessList[$id]))
     158    {
     159      return($this->accessList[$id]['allowed']);
     160    }
    139161    else
    140     { return(false); }
    141   }
    142 
    143   /*
    144     returns true if all or one is allowed
    145       ids is an array
    146   */
    147   function areAllowed($ids, $all=false)
    148   {
    149     foreach($ids as $val)
    150     {
    151       if($all)
    152       {
    153         if(!$this->isAllowed($val))
    154         {
    155           return(false);
    156         }
    157       }
    158       else
    159       {
    160         if($this->isAllowed($val))
    161         {
    162           return(true);
    163         }
    164       }
    165     }
    166     return(false);
    167   }
    168 
    169   /*
    170     returns an HTML list with label rather than id
    171   */
    172   function htmlView($sep=", ", $empty="")
    173   {
    174     $returned="";
    175     foreach($this->access_list as $key => $val)
    176     {
    177       if($val['allowed'])
    178       {
    179         if($returned!="")
    180         {
    181           $returned.=$sep;
    182         }
    183         $returned.=$val['name'];
    184       }
    185     }
    186     if($returned=="")
    187     {
    188       $returned=$empty;
    189     }
    190     return($returned);
    191   }
    192   /*
    193     returns a generic HTML form to manage the groups access
    194   */
    195   function htmlForm($basename)
    196   {
    197     /*
    198     <!-- BEGIN allowed_group_row -->
    199     <label><input type="checkbox" name="fmypolls_att_allowed_groups_{allowed_group_row.ID}" {allowed_group_row.CHECKED}/>&nbsp;{allowed_group_row.NAME}</label>
    200     <!-- END allowed_group_row -->
    201     */
    202     $text='';
    203     foreach($this->access_list as $key => $val)
    204     {
    205       if($val['allowed'])
    206       {
    207         $checked=' checked';
    208       }
    209       else
    210       {
    211         $checked='';
    212       }
    213 
    214       if($val['enabled'])
    215       {
    216         $enabled='';
    217       }
    218       else
    219       {
    220         $enabled=' disabled';
    221       }
    222 
    223       $text.='<label><input type="checkbox" name="'.$basename.$val['id'].'" '.$checked.$enabled.'/>
    224           &nbsp;'.$val['name'].'</label>&nbsp;';
    225     }
    226     return($text);
    227   }
     162    {
     163      return($this->accessMode=='a');
     164    }
     165  }
     166
    228167} //GPCAllowedAccess
    229168
     
    235174
    236175
    237 /* ----------------------------------------------------------------------
    238    this class provides base functions to manage groups access
    239     initList redefined to initialize access_list from database GROUPS
    240    ---------------------------------------------------------------------- */
     176/**
     177 * ----------------------------------------------------------------------------
     178 *  this class provides base functions to manage groups access
     179 *  initList redefined to initialize accessList from database GROUPS
     180 * ----------------------------------------------------------------------------
     181 */
    241182class GPCGroups extends GPCAllowedAccess
    242183{
    243   /*
    244     initialize the groups list
    245   */
     184  /**
     185   * initialize the groups list
     186   */
    246187  protected  function initList()
    247188  {
    248     $this->access_list=array();
     189    $this->accessList=array();
    249190    $sql="SELECT id, name FROM ".GROUPS_TABLE." ORDER BY name";
    250191    $result=pwg_query($sql);
     
    253194      while($row=pwg_db_fetch_assoc($result))
    254195      {
    255         $this->access_list[$row['id']] =
    256                    array('id' => $row['id'],
    257                          'name' => $row['name'],
    258                          'allowed' => false,
    259                          'enabled' => true);
     196        $this->accessList[$row['id']]=array(
     197            'id' => $row['id'],
     198            'name' => $row['name'],
     199            'allowed' => ($this->accessMode=='a')
     200          );
    260201      }
    261202    }
     
    270211
    271212
    272 /* -----------------------------------------------------------------------------
    273    this class provides base functions to manage users access
    274 ----------------------------------------------------------------------------- */
     213/**
     214 * ----------------------------------------------------------------------------
     215 *  this class provides base functions to manage users access
     216 *  initList redefined to initialize accessList from piwigo's predefined values
     217 * ----------------------------------------------------------------------------
     218 */
    275219class GPCUsers extends GPCAllowedAccess
    276220{
    277   /*
    278     constructor
    279   */
    280   public function __construct($alloweds = "")
    281   {
    282     parent::__construct($alloweds);
    283     $this->setState('admin', false);
    284     $this->setAllowed('admin', true);
    285   }
    286 
    287   /*
    288     initialize the groups list
    289   */
     221  /**
     222   * initialize the users list
     223   */
    290224  protected function initList()
    291225  {
    292     $users_list = array('guest', 'generic', 'normal', 'webmaster', 'admin');
    293     $this->access_list=array();
    294     foreach($users_list as $val)
    295     {
    296       $this->access_list[$val] =
    297                   array('id' => $val,
    298                         'name' => l10n('user_status_'.$val),
    299                         'allowed' => false,
    300                         'enabled' => true);
     226    $usersList = array('guest', 'generic', 'normal', 'webmaster', 'admin');
     227    $this->accessList=array();
     228    foreach($usersList as $val)
     229    {
     230      $this->accessList[$val]=array(
     231          'id' => $val,
     232          'name' => l10n('user_status_'.$val),
     233          'allowed' => ($this->accessMode=='a')
     234        );
    301235    }
    302236  }
  • extensions/GrumPluginClasses/classes/genericjs.class.inc.php

    r5958 r8961  
    11<?php
    2 
    3 /* -----------------------------------------------------------------------------
    4   class name: genericjs
    5   class version: 2.0
    6   date: 2008-07-20
    7   ------------------------------------------------------------------------------
    8   author: grum at grum.dnsalias.com
    9   << May the Little SpaceFrog be with you >>
    10   ------------------------------------------------------------------------------
    11 
    12    this classes provides base functions to add genericjs.js file into html page
    13 
    14    > see genericjs.js file to know javascript functions added
    15 
    16     - constructor genericjs()
    17    ---------------------------------------------------------------------- */
    18 
    19 
    20 class genericjs
    21 {
    22   function genericjs()
    23   {
    24     add_event_handler('loc_end_page_header', array(&$this, 'load_JS'));
    25   }
    26 
    27   function load_JS()
    28   {
    29     global $template;
    30 
    31     $name='plugins/'.basename(dirname(dirname(__FILE__))).'/js/genericjs.js';
    32 
    33     $template->append('head_elements', '<script src="'.$name.'" type="text/javascript"></script>');
    34 
    35   }
    36 
    37 } //class
    38 
    39 $genericjs=new genericjs();
    40 
     2/*
     3 * dummy file to avoid compatibility problem with older plugin.
     4 *
     5 * this file have to be removed on the next release.
     6 */
    417?>
Note: See TracChangeset for help on using the changeset viewer.