Ignore:
Timestamp:
Sep 24, 2011, 1:00:36 PM (13 years ago)
Author:
grum
Message:

fix bugs
bug:2160 - CategorySelector : extended description are not managed
+add some functions to GPCCore

Location:
extensions/GrumPluginClasses/classes
Files:
2 edited

Legend:

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

    r7310 r12215  
    301301        $row['rank']=implode('.', $row['rank']);
    302302
     303        $row['name']=GPCCore::getUserLanguageDesc($row['name']);
     304
    303305        $returned[]=$row;
    304306      }
  • extensions/GrumPluginClasses/classes/GPCCore.class.inc.php

    r10246 r12215  
    33/* -----------------------------------------------------------------------------
    44  class name     : GPCCore
    5   class version  : 1.4.0
    6   plugin version : 3.5.0
    7   date           : 2011-04-10
     5  class version  : 1.4.1
     6  plugin version : 3.5.2
     7  date           : 2011-09-19
    88  ------------------------------------------------------------------------------
    99  author: grum at piwigo.org
     
    5555| 1.4.0   | 2011/04/10 | * Updated for piwigo 2.2
    5656|         |            |
     57| 1.4.1   | 2011/09/19 | * Add [var] and [form_mail] markup interpreter
    5758|         |            |
    5859|         |            |
     
    6970    - static function unregister
    7071    - static function BBtoHTML
     72    - static function VarToHTML
     73    - static function FormMailToHTML
    7174    - static function addHeaderCSS
    7275    - static function addHeaderJS
     
    7881    - static function formatOctet
    7982    - static function rmDir
     83    - static function applyMarkups
    8084   ---------------------------------------------------------------------- */
    8185
     
    9599  static public function init()
    96100  {
     101    global $conf;
     102
    97103    self::$piwigoSystemPath=dirname(dirname(dirname(dirname(__FILE__))));
     104
     105    if(isset($conf['gpc.script.minify'])) self::setMinifiedState($conf['gpc.script.minify']);
     106
     107    if((isset($conf['gpc.markup.bb']) && $conf['gpc.markup.bb']) ||
     108       (isset($conf['gpc.markup.var']) && $conf['gpc.markup.var']) ||
     109       (isset($conf['gpc.markup.form']) && $conf['gpc.markup.form'])
     110      )
     111    {
     112      add_event_handler('render_category_name', array('GPCCore', 'applyMarkups'), EVENT_HANDLER_PRIORITY_NEUTRAL+5);
     113      add_event_handler('render_category_description', array('GPCCore', 'applyMarkups'), EVENT_HANDLER_PRIORITY_NEUTRAL+5, 2);
     114      add_event_handler('render_element_description', array('GPCCore', 'applyMarkups'), EVENT_HANDLER_PRIORITY_NEUTRAL+5);
     115      add_event_handler('AP_render_content', array('GPCCore', 'applyMarkups'), EVENT_HANDLER_PRIORITY_NEUTRAL+5);
     116    }
    98117  }
    99118
     
    108127        Array('name' => "GPCAjax", 'version' => "3.0.0"),
    109128        Array('name' => "GPCCategorySelector", 'version' => "1.0.1"),
    110         Array('name' => "GPCCore", 'version' => "1.4.0"),
     129        Array('name' => "GPCCore", 'version' => "1.4.1"),
    111130        Array('name' => "GPCCss", 'version' => "3.1.0"),
    112131        Array('name' => "GPCPagesNavigation", 'version' => "2.0.0"),
     
    362381
    363382    return(preg_replace($patterns, $replacements, $text));
     383  }
     384
     385  /**
     386   * apply [var] tag
     387   *
     388   * [var=<name>]
     389   * with <name> :
     390   *  - USER
     391   *  - GALLERY_TITLE
     392   *  - NB_PHOTOS
     393   *  - CATEGORY
     394   *  - TOKEN
     395   *  - IP
     396   *
     397   * @param String $text : text to convert
     398   * @return String : processed text
     399   */
     400  static public function VarToHTML($text)
     401  {
     402    global $user, $page, $conf;
     403
     404    $patterns = Array(
     405      '/\[var=user\]/im',
     406      '/\[var=gallery_title\]/im',
     407      '/\[var=nb_photos\]/im',
     408      '/\[var=category\]/im',
     409      '/\[var=token\]/im',
     410      '/\[var=ip\]/im'
     411    );
     412    $replacements = Array(
     413      isset($user['username'])?$user['username']:'',
     414      isset($conf['gallery_title'])?$conf['gallery_title']:'',
     415      isset($user['nb_total_images'])?$user['nb_total_images']:'',
     416      isset($page['category']['name'])?$page['category']['name']:'',
     417      get_pwg_token(),
     418      $_SERVER['REMOTE_ADDR']
     419    );
     420
     421    return(preg_replace($patterns, $replacements, $text));
     422  }
     423
     424  /**
     425   * apply [form_mail] tag
     426   *
     427   * @param String $text : text to convert
     428   * @return String : processed text
     429   */
     430  static public function FormMailToHTML($text)
     431  {
     432    global $template;
     433
     434    $file=GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.'templates/GPCFormMsg.tpl';
     435    if(!file_exists($file)) $file=dirname(dirname(__FILE__))."/templates/GPCFormMsg.tpl";
     436
     437    $template->set_filename('gpc_form', $file);
     438
     439    $template->assign('token', get_pwg_token() );
     440
     441    $patterns = Array(
     442      '/\[form_mail\]/im'
     443    );
     444    $replacements = Array(
     445      $template->parse('gpc_form', true)
     446    );
     447
     448    if(preg_match($patterns[0], $text)>0)
     449    {
     450      GPCCore::addHeaderJS('gpc.markup.formMail', GPC_PATH.'js/markup.formMail'.self::$minified.'.js', array('jquery'));
     451      return(preg_replace($patterns, $replacements, $text));
     452    }
     453    return($text);
     454  }
     455
     456  /**
     457   * apply [tab], [/tab] and [tabs] tags
     458   *
     459   * @param String $text : text to convert
     460   * @return String : processed text
     461   */
     462  static public function TabsToHTML($text)
     463  {
     464    $result=array();
     465
     466    $tabs='';
     467    if(preg_match_all('/\[tab=([^(;\]).]*)(?:;(default))?;([^\].]*)\]/im', $text, $result, PREG_SET_ORDER)>0)
     468    {
     469      foreach($result as $val)
     470      {
     471        $tabs.="<li class='gpcTabSeparator'><a id='iGpcTab".$val[1]."' class='".($val[2]=='default'?'gpcTabSelected':'gpcTabNotSelected')."' tabId='#iGpcTabContent".$val[1]."'>".$val[3]."</a></li>";
     472      }
     473      $tabs="<div id='iGpcTabs'><ul>".$tabs."</ul></div>";
     474    }
     475    else return($text);
     476
     477    $patterns = Array(
     478      '/\[tabs\]/im',
     479      '/\[tab=([^(;\]).]*)(?!;default);.*\]/im',
     480      '/\[tab=([^(;\]).]*);default;(.*)\]/im',
     481      '/\[\/tab\]/im'
     482    );
     483    $replacements = Array(
     484      $tabs,
     485      '<div id="iGpcTabContent\1" class="gpcTabContent" style="display:none;">',
     486      '<div id="iGpcTabContent\1" class="gpcTabContent">',
     487      '</div>'
     488    );
     489
     490    if(preg_match($patterns[0], $text)>0)
     491    {
     492      GPCCore::addHeaderJS('gpc.markup.tabs', GPC_PATH.'js/markup.tabs'.self::$minified.'.js', array('jquery'));
     493      GPCCore::addHeaderCSS('gpc.markup.tabs', GPC_PATH.'css/gpcTabs.css');
     494      return(preg_replace($patterns, $replacements, $text));
     495    }
     496    return($text);
     497  }
     498
     499  static public function applyMarkups($text)
     500  {
     501    global $conf;
     502
     503    if(isset($conf['gpc.markup.form']) && $conf['gpc.markup.form'])
     504    {
     505      $text=GPCCore::FormMailToHTML($text);
     506    }
     507
     508    if(isset($conf['gpc.markup.tabs']) && $conf['gpc.markup.tabs'])
     509    {
     510      $text=GPCCore::TabsToHTML($text);
     511    }
     512
     513    if(isset($conf['gpc.markup.var']) && $conf['gpc.markup.var'])
     514    {
     515      $text=GPCCore::VarToHTML($text);
     516    }
     517
     518    if(isset($conf['gpc.markup.bb']) && $conf['gpc.markup.bb'])
     519    {
     520      $text=GPCCore::BBtoHTML($text);
     521    }
     522
     523
     524    return($text);
    364525  }
    365526
Note: See TracChangeset for help on using the changeset viewer.