@@ -56,31 +56,6 @@ function ddbasic_preprocess_html(&$vars) {
56
56
function ddbasic_process_html (&$ vars ) {
57
57
$ theme_name = 'ddbasic ' ;
58
58
59
- // Build an array of poly-filling scripts.
60
- $ vars ['polyfills_array ' ] = ddbasic_load_polyfills ($ theme_name , $ vars );
61
-
62
- // This code is copied from Adaptive Theme, at_core/inc/process.inc.
63
- // It wraps the required polyfills scripts into a conditional comment.
64
- if (!empty ($ vars ['polyfills_array ' ])) {
65
- $ vars ['polyfills ' ] = drupal_static ('ddbasic_process_html_polyfills ' );
66
- if (empty ($ vars ['polyfills ' ])) {
67
- $ polyfills = array ();
68
- foreach ($ vars ['polyfills_array ' ] as $ key => $ value ) {
69
- foreach ($ value as $ k => $ v ) {
70
- $ polyfills [$ k ][] = implode ("\n" , $ v );
71
- }
72
- }
73
- $ polyfills_scripts = array ();
74
- foreach ($ polyfills as $ kv => $ kvp ) {
75
- $ polyfills_scripts [$ kv ] = implode ("\n" , $ kvp );
76
- }
77
- $ vars ['polyfills ' ] = ddbasic_theme_conditional_scripts ($ polyfills_scripts );
78
- }
79
- }
80
- else {
81
- $ vars ['polyfills ' ] = '' ;
82
- }
83
-
84
59
// Classes for body element. Allows advanced theming based on context
85
60
// (home page, node of certain type, etc.)
86
61
if (!$ vars ['is_front ' ]) {
@@ -746,147 +721,6 @@ function ddbasic_theme_script($filepath) {
746
721
}
747
722
748
723
749
- /**
750
- * Return themed scripts in Conditional Comments.
751
- *
752
- * Since Drupal 7 does not (yet) support the 'browser' option in drupal_add_js()
753
- * Adaptivetheme provides a way to load scripts inside conditional comments.
754
- * This function will return a string for printing into a template, its
755
- * akin to a real theme_function but its not.
756
- *
757
- * @param array $ie_scripts
758
- * An array of themed scripts.
759
- *
760
- * @return string
761
- * Themed scripts.
762
- */
763
- function ddbasic_theme_conditional_scripts ($ ie_scripts ) {
764
- $ themed_scripts = drupal_static (__FUNCTION__ , array ());
765
- if (empty ($ themed_scripts )) {
766
- $ cc_scripts = array ();
767
-
768
- foreach ($ ie_scripts as $ conditional_comment => $ conditional_scripts ) {
769
- $ cc_scripts [] = '<!--[if ' . $ conditional_comment . ']> ' . "\n" . $ conditional_scripts . "\n" . '<![endif]--> ' . "\n" ;
770
- }
771
- $ themed_scripts = implode ("\n" , $ cc_scripts );
772
- }
773
-
774
- return $ themed_scripts ;
775
- }
776
-
777
-
778
- /**
779
- * Polyfill is used to enable HTML5 on browsers who doesn't natively support it.
780
- *
781
- * Polyfill adds the missing functionality by 'filling' in scripts that add the
782
- * HTML5 functionality the browser doesn't offer.
783
- *
784
- * Return an array of filenames (scripts) to include.
785
- *
786
- * @param string $theme_name
787
- * Name of the theme.
788
- */
789
- function ddbasic_load_polyfills ($ theme_name ) {
790
- // Get the info file data.
791
- $ info = ddbasic_get_info ($ theme_name );
792
-
793
- // Build an array of polyfilling scripts.
794
- $ polyfills_array = drupal_static ('ddbasic_preprocess_html_polyfills_array ' );
795
- if (empty ($ polyfills_array )) {
796
- // Info file loaded conditional scripts.
797
- $ theme_path = drupal_get_path ('theme ' , $ theme_name );
798
- if (array_key_exists ('ie_scripts ' , $ info )) {
799
- foreach ($ info ['ie_scripts ' ] as $ condition => $ ie_scripts_path ) {
800
- foreach ($ ie_scripts_path as $ key => $ value ) {
801
- $ filepath = $ theme_path . '/ ' . $ value ;
802
- $ polyfills_array ['info ' ][$ condition ][] = ddbasic_theme_script ($ filepath );
803
- }
804
- }
805
- }
806
-
807
- // Ddbasic Core Polyfills.
808
- $ theme_path = drupal_get_path ('theme ' , 'ddbasic ' );
809
- $ polly = '' ;
810
- $ polly_settings_array = array (
811
- 'load_html5js ' ,
812
- 'load_selectivizr ' ,
813
- // Loaded directly by polly_wants_a_cracker(), its never returned.
814
- 'load_scalefixjs ' ,
815
- );
816
- foreach ($ polly_settings_array as $ polly_setting ) {
817
- $ polly [$ polly_setting ] = theme_get_setting ($ polly_setting , $ theme_name );
818
- }
819
- $ backed_crackers = ddbasic_polly_wants_a_cracker ($ polly );
820
- foreach ($ backed_crackers as $ cupboard => $ flavors ) {
821
- foreach ($ flavors as $ key => $ value ) {
822
- $ filepath = $ theme_path . '/ ' . $ value ;
823
- $ polyfills_array ['ddbasic ' ][$ cupboard ][] = ddbasic_theme_script ($ filepath );
824
- }
825
- }
826
- }
827
-
828
- return $ polyfills_array ;
829
- }
830
-
831
-
832
- /**
833
- * Polyfills.
834
- *
835
- * This function does two seperate operations. First it attaches a condition
836
- * to each Polyfill which can be either an IE conditional comment or 'all'.
837
- * Polyfills with 'all' are loaded immediatly via drupal_add_js(), those with
838
- * an IE CC are returned for further processing. This function is hard coded
839
- * to support only those scripts supplied by the core theme, if you need to load
840
- * a script for IE use the info file feature.
841
- *
842
- * @param array $polly
843
- * Array of ?.
844
- */
845
- function ddbasic_polly_wants_a_cracker ($ polly ) {
846
- $ theme_path = drupal_get_path ('theme ' , 'ddbasic ' );
847
-
848
- $ baked_crackers = drupal_static (__FUNCTION__ , array ());
849
- if (empty ($ baked_crackers )) {
850
- if (in_array (1 , $ polly )) {
851
-
852
- $ crackers = array ();
853
-
854
- // HTML5 Shiv.
855
- if ($ polly ['load_html5js ' ] === 1 ) {
856
- $ crackers ['all ' ][] = 'scripts/html5shiv.js ' ;
857
- }
858
- // Selectivizr.
859
- if ($ polly ['load_selectivizr ' ] === 1 ) {
860
- $ crackers ['all ' ][] = 'scripts/selectivizr-min.js ' ;
861
- }
862
- // Scalefix.js.
863
- if ($ polly ['load_scalefixjs ' ] === 1 ) {
864
- $ crackers ['all ' ][] = 'scripts/scalefix.js ' ;
865
- }
866
-
867
- // Load Polyfills.
868
- if (!empty ($ crackers )) {
869
- // "all" - no conditional comment needed, use drupal_add_js().
870
- if (isset ($ crackers ['all ' ])) {
871
- foreach ($ crackers ['all ' ] as $ script ) {
872
- drupal_add_js ($ theme_path . '/ ' . $ script , array (
873
- 'type ' => 'file ' ,
874
- 'scope ' => 'header ' ,
875
- 'group ' => JS_THEME ,
876
- 'preprocess ' => TRUE ,
877
- 'cache ' => TRUE ,
878
- )
879
- );
880
- }
881
- }
882
- }
883
- }
884
- }
885
-
886
- return $ baked_crackers ;
887
- }
888
-
889
-
890
724
/**
891
725
* Return the info file array for a particular theme, usually the active theme.
892
726
*
0 commit comments