Ignore:
Timestamp:
Jun 23, 2013, 4:11:29 PM (11 years ago)
Author:
mistic100
Message:

allow multiple language files in a plugin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/plugin_lang_analysis/include/functions.inc.php

    r23449 r23467  
    44/**
    55 * list files of a plugin
     6 * @param: string $id, plugin id
     7 * @return: array of paths relative to plugin root
    68 */
    79function list_plugin_files($id, $path=null)
     
    2224  }
    2325 
    24   if (($handle = opendir(PHPWG_PLUGINS_PATH.$id.$path)) === false)
     26  if (($handle = @opendir(PHPWG_PLUGINS_PATH.$id.$path)) === false)
    2527  {
    2628    return array();
     
    5355
    5456/**
     57 * list language files of a plugin
     58 * @param: string $id, plugin id
     59 * @return: array, keys are basenames, values are paths relative to plugin root
     60 */
     61function list_plugin_languages_files($id)
     62{
     63  $path = '/language/en_UK/';
     64 
     65  if (($handle = @opendir(PHPWG_PLUGINS_PATH.$id.$path)) === false)
     66  {
     67    return array();
     68  }
     69 
     70  $data = array();
     71 
     72  while ($entry = readdir($handle))
     73  {
     74    if ($entry=='.' || $entry=='..' || $entry=='.svn' || $entry=='index.php') continue;
     75   
     76    if (!is_dir(PHPWG_PLUGINS_PATH.$id.$path.$entry))
     77    {
     78      $ext = strtolower(get_extension($entry));
     79      if ($ext == 'php')
     80      {
     81        $data[ basename($entry, '.php') ] = $path.$entry;
     82      }
     83    }
     84  }
     85 
     86  closedir($handle);
     87 
     88  return $data;
     89}
     90
     91/**
    5592 * list translated strings of a file
     93 * @param: string $path, file $path relative to main plugins folder
     94 * @return: array, keys are language strings, values are arrays of lines
    5695 */
    5796function analyze_file($path)
     
    113152
    114153/**
     154 * get language files loaded in main.inc.php
     155 * @param: string $id, plugin id
     156 * @return: array of file basenames
     157 */
     158function get_loaded_in_main($id)
     159{
     160  $content = file_get_contents(PHPWG_PLUGINS_PATH.$id.'/main.inc.php');
     161 
     162  $files = array();
     163 
     164  if (preg_match_all('#load_language\((?:\s*)(?:["\']{1})(.*?)(?:["\']{1})#', $content, $matches))
     165  {
     166    $files = $matches[1];
     167  }
     168 
     169  return $files;
     170}
     171
     172/**
    115173 * load a language file
    116174 */
Note: See TracChangeset for help on using the changeset viewer.