Overview
Comment:Donner l'URL vers un plugin
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e57c4023d7e180a6d4153143df0a1319ba3601e2
User & Date: bohwaz on 2014-03-21 03:45:09
Other Links: manifest | tags
Context
2014-03-21
04:15
Affichage partie admin/privée des plugins check-in: 514f512510 user: bohwaz tags: trunk
03:45
Donner l'URL vers un plugin check-in: e57c4023d7 user: bohwaz tags: trunk
03:44
rendre publique ces méthodes bien utiles check-in: 9e037ff854 user: bohwaz tags: trunk
Changes

Modified src/include/lib.template.php from [63482205cb] to [24cd7e84eb].

   505    505   
   506    506   $tpl->register_function('format_droits', 'Garradin\tpl_format_droits');
   507    507   
   508    508   $tpl->register_function('pagination', 'Garradin\tpl_pagination');
   509    509   
   510    510   $tpl->register_function('diff', 'Garradin\tpl_diff');
   511    511   $tpl->register_function('html_champ_membre', 'Garradin\tpl_html_champ_membre');
          512  +
          513  +$tpl->register_function('plugin_url', ['Garradin\utils', 'plugin_url']);
   512    514   
   513    515   $tpl->register_modifier('get_country_name', ['Garradin\utils', 'getCountryName']);
   514    516   $tpl->register_modifier('format_tel', 'Garradin\tpl_format_tel');
   515    517   $tpl->register_modifier('format_wiki', 'Garradin\tpl_format_wiki');
   516    518   $tpl->register_modifier('liens_wiki', 'Garradin\tpl_liens_wiki');
   517    519   $tpl->register_modifier('escape_money', 'Garradin\escape_money');
   518    520   $tpl->register_modifier('html_money', 'Garradin\tpl_html_money');
................................................................................
   541    543           return implode(', ', $out);
   542    544       } else {
   543    545           return $v;
   544    546       }
   545    547   
   546    548   });
   547    549   
   548         -$tpl->register_modifier('format_sqlite_date_to_french', function ($d) {
   549         -    if (strlen($d) == 10)
   550         -        return \DateTime::createFromFormat('Y-m-d', $d)->format('d/m/Y');
          550  +$tpl->register_modifier('format_sqlite_date_to_french', function ($d, $short = false) {
          551  +    if (strlen($d) == 10 || $short)
          552  +        return \DateTime::createFromFormat('Y-m-d', substr($d, 0, 10))->format('d/m/Y');
          553  +    elseif (strlen($d) == 16)
          554  +        return \DateTime::createFromFormat('Y-m-d H:i', $d)->format('d/m/Y H:i');
   551    555       else
   552    556           return \DateTime::createFromFormat('Y-m-d H:i:s', $d)->format('d/m/Y H:i');
   553    557   });
   554    558   
   555    559   $tpl->register_modifier('format_bytes', function ($size) {
   556    560       if ($size > (1024 * 1024))
   557    561           return round($size / 1024 / 1024, 2) . ' Mo';
   558    562       elseif ($size > 1024)
   559    563           return round($size / 1024, 2) . ' Ko';
   560    564       else
   561    565           return $size . ' ob_get_contents(oid)';
   562    566   });
   563    567   
   564         -//$tpl->register_modifier('retard_cotisation', array('Membres', 'checkCotisation'));
   565         -
   566    568   $tpl->register_modifier('strftime_fr', 'Garradin\tpl_strftime_fr');
   567    569   $tpl->register_modifier('date_fr', 'Garradin\tpl_date_fr');
   568    570   
   569    571   ?>

Modified src/include/lib.utils.php from [e9a05b7ff3] to [e305029466].

   593    593           }
   594    594   
   595    595           $dir->close();
   596    596           rmdir($path);
   597    597   
   598    598           return true;
   599    599       }
          600  +
          601  +    static public function plugin_url($params)
          602  +    {
          603  +        if (!defined('Garradin\PLUGIN_URL'))
          604  +        {
          605  +            $url = WWW_URL . 'admin/plugin/' . $params['id'] . '/';
          606  +        }
          607  +        else
          608  +        {
          609  +            $url = PLUGIN_URL;
          610  +        }
          611  +
          612  +        if (!empty($params['file']))
          613  +            $url .= $params['file'];
          614  +
          615  +        if (!empty($params['query']))
          616  +        {
          617  +            $url .= '?';
          618  +            
          619  +            if (!(is_numeric($params['query']) && (int)$params['query'] === 1) && $params['query'] !== true)
          620  +                $url .= $params['query'];
          621  +        }
          622  +
          623  +        return $url;
          624  +    }
          625  +
   600    626   }