362 $db->_die('lang.php - can\'t import language file: string file doesn\'t exist'); |
362 $db->_die('lang.php - can\'t import language file: string file doesn\'t exist'); |
363 |
363 |
364 if ( $this->lang_id == 0 ) |
364 if ( $this->lang_id == 0 ) |
365 $db->_die('lang.php - BUG: trying to perform import when $lang->lang_id == 0'); |
365 $db->_die('lang.php - BUG: trying to perform import when $lang->lang_id == 0'); |
366 |
366 |
367 $contents = trim(@file_get_contents($file)); |
367 $block = pluginLoader::parse_plugin_blocks($file, 'language'); |
368 |
368 if ( !is_array($block) ) |
369 if ( empty($contents) ) |
369 return false; |
370 $db->_die('lang.php - can\'t load the contents of the language file'); |
370 if ( !isset($block[0]) ) |
371 |
371 return false; |
372 // If there isn't a specially formed comment block, bail out quietly. |
372 |
373 if ( !strpos($contents, PLUGIN_METABLOCK_LANGUAGE_START) || !strpos($contents, PLUGIN_METABLOCK_LANGUAGE_END) ) |
373 $contents =& $block[0]['value']; |
374 return null; |
|
375 |
|
376 // Get all data in the language block |
|
377 $block_start = strpos($contents, PLUGIN_METABLOCK_LANGUAGE_START) + strlen(PLUGIN_METABLOCK_LANGUAGE_START); |
|
378 $block_end = strpos($contents, PLUGIN_METABLOCK_LANGUAGE_END); |
|
379 $block_len = $block_end - $block_start; |
|
380 if ( $block_len < 1 ) |
|
381 $db->_die('lang.php - plugin file contains corrupt language data'); |
|
382 |
|
383 $contents = substr($contents, $block_start, $block_len); |
|
384 |
374 |
385 // Trim off all text before and after the starting and ending braces |
375 // Trim off all text before and after the starting and ending braces |
386 $contents = preg_replace('/^([^{]+)\{/', '{', $contents); |
376 $contents = preg_replace('/^([^{]+)\{/', '{', $contents); |
387 $contents = preg_replace('/\}([^}]+)$/', '}', $contents); |
377 $contents = preg_replace('/\}([^}]+)$/', '}', $contents); |
388 |
378 |