Révision ba3b3627
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/advanced_help/advanced_help.module | ||
---|---|---|
593 | 593 |
return "./$info[path]/$info[file]"; |
594 | 594 |
} |
595 | 595 |
} |
596 |
|
|
597 |
/** |
|
598 |
* Get the module type (theme or module). |
|
599 |
*/ |
|
600 |
function _advanced_help_get_module_type($module) { |
|
601 |
$theme_list = array_keys(list_themes()); |
|
602 |
$is_theme = in_array($module, $theme_list); |
|
603 |
return $is_theme ? 'theme' : 'module'; |
|
604 |
} |
|
605 |
|
|
596 | 606 |
/** |
597 | 607 |
* Load and render a help topic. |
598 | 608 |
*/ |
... | ... | |
605 | 615 |
} |
606 | 616 |
|
607 | 617 |
// Search paths: |
618 |
$module_type = _advanced_help_get_module_type($module); |
|
608 | 619 |
$paths = array( |
609 | 620 |
// Allow theme override. |
610 | 621 |
path_to_theme() . '/help', |
611 | 622 |
// Translations. |
612 |
drupal_get_path('module', $module) . "/translations/help/$language->language",
|
|
623 |
drupal_get_path($module_type, $module) . "/translations/help/$language->language",
|
|
613 | 624 |
// In same directory as .inc file. |
614 | 625 |
$info['path'], |
615 | 626 |
); |
... | ... | |
640 | 651 |
$info = advanced_help_get_topic($module, $topic); |
641 | 652 |
$file = "./$file_info[path]/$file_info[file]"; |
642 | 653 |
|
654 |
// Fix invalid byte sequences (Issue #1330056). |
|
643 | 655 |
$output = file_get_contents($file); |
656 |
mb_substitute_character(0xfffd); |
|
657 |
$output = mb_convert_encoding($output, 'UTF-8', 'UTF-8'); |
|
658 |
|
|
644 | 659 |
if (isset($info['readme file']) && $info['readme file']) { |
645 | 660 |
$ext = pathinfo($file, PATHINFO_EXTENSION); |
646 | 661 |
if ('md' == $ext && module_exists('markdown')) { |
647 | 662 |
$filters = module_invoke('markdown', 'filter_info'); |
648 | 663 |
$md_info = $filters['filter_markdown']; |
649 |
|
|
650 | 664 |
if (function_exists($md_info['process callback'])) { |
651 | 665 |
$function = $md_info['process callback']; |
652 | 666 |
$output = '<div class="advanced-help-topic">' . filter_xss_admin($function($output, NULL)) . '</div>'; |
... | ... | |
660 | 674 |
if ('md' == $ext) { |
661 | 675 |
$readme .= |
662 | 676 |
'<p>' . |
663 |
t('If you install the !module module, the text below will be filtered by the module, producing rich text.', |
|
664 |
array('!module' => l(t('Markdown filter'), |
|
665 |
'https://www.drupal.org/project/markdown', |
|
666 |
array('attributes' => array('title' => t('Link to project.')))))) . '</p>'; |
|
667 |
} |
|
677 |
t('If you install the !module module, the text below will be filtered by the module, producing rich text.', |
|
678 |
array( |
|
679 |
'!module' => l(t('Markdown filter'), |
|
680 |
'https://www.drupal.org/project/markdown', |
|
681 |
array('attributes' => array('title' => t('Link to project.')))) |
|
682 |
)) . '</p>'; |
|
683 |
} |
|
668 | 684 |
$readme .= |
669 | 685 |
'<div class="advanced-help-topic"><pre class="readme">' . check_plain($output) . '</pre></div>'; |
670 |
$output = $readme;
|
|
686 |
$output = $readme;
|
|
671 | 687 |
} |
672 | 688 |
return $output; |
673 | 689 |
} |
... | ... | |
803 | 819 |
} |
804 | 820 |
|
805 | 821 |
/** |
806 |
* Funtion to parse ini / txt files. |
|
822 |
* Function to parse ini / txt files.
|
|
807 | 823 |
*/ |
808 | 824 |
function _advanced_help_parse_ini() { |
809 | 825 |
global $language; |
Formats disponibles : Unified diff
Weekly update of contrib modules