Changeset 2566:9bf417837888 for plugins/widgets/_public.php
- Timestamp:
- 11/17/13 20:25:53 (12 years ago)
- Branch:
- 2.6
- Children:
- 2567:6c11245cbf04, 2568:61c67a7d17fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/widgets/_public.php
r1179 r2566 26 26 # widgets to disable 27 27 $disable = isset($attr['disable']) ? trim($attr['disable']) : ''; 28 28 29 29 if ($type == '') { 30 30 $res = "publicWidgets::widgetsHandler('nav','".addslashes($disable)."');"."\n". … … 39 39 return '<?php '.$res.' ?>'; 40 40 } 41 41 42 42 public static function widgetsHandler($type,$disable='') 43 43 { … … 45 45 $GLOBALS['core']->blog->settings->addNameSpace('widgets'); 46 46 $widgets = $GLOBALS['core']->blog->settings->widgets->{$wtype}; 47 47 48 48 if (!$widgets) { // If widgets value is empty, get defaults 49 49 $widgets = self::defaultWidgets($type); … … 51 51 $widgets = dcWidgets::load($widgets); 52 52 } 53 53 54 54 if ($widgets->isEmpty()) { // Widgets are empty, don't show anything 55 55 return; 56 56 } 57 57 58 58 $disable = preg_split('/\s*,\s*/',$disable,-1,PREG_SPLIT_NO_EMPTY); 59 59 $disable = array_flip($disable); 60 60 61 61 foreach ($widgets->elements() as $k => $w) 62 62 { … … 67 67 } 68 68 } 69 69 70 70 private static function defaultWidgets($type) 71 71 { 72 72 $widgets = new dcWidgets(); 73 73 $w = new dcWidgets(); 74 74 75 75 if (isset($GLOBALS['__default_widgets'][$type])) { 76 76 $w = $GLOBALS['__default_widgets'][$type]; 77 77 } 78 78 79 79 return $w; 80 80 } 81 81 82 82 public static function tplWidget($attr,$content) 83 83 { … … 85 85 return; 86 86 } 87 87 88 88 # We change tpl:lang syntax, we need it 89 89 $content = preg_replace('/\{\{tpl:lang\s+(.*?)\}\}/msu','{tpl:lang $1}',$content); 90 90 91 91 # We remove every {{tpl: 92 92 $content = preg_replace('/\{\{tpl:.*?\}\}/msu','',$content); 93 93 94 94 return 95 95 "<?php publicWidgets::widgetHandler('".addslashes($attr['id'])."','".str_replace("'","\\'",$content)."'); ?>"; 96 96 } 97 97 98 98 public static function widgetHandler($id,$xml) 99 99 { 100 100 $widgets =& $GLOBALS['__widgets']; 101 101 102 102 if (!($widgets->{$id} instanceof dcWidget)) { 103 103 return; 104 104 } 105 105 106 106 $xml = '<?xml version="1.0" encoding="utf-8" ?><widget>'.$xml.'</widget>'; 107 107 $xml = @simplexml_load_string($xml); … … 110 110 return; 111 111 } 112 112 113 113 $w = clone $widgets->{$id}; 114 114 115 115 foreach ($xml->setting as $e) 116 116 { … … 118 118 continue; 119 119 } 120 120 121 121 $setting = (string) $e['name']; 122 122 if (count($e->children())>0) { … … 127 127 $w->{$setting} = preg_replace_callback('/\{tpl:lang (.*?)\}/msu',array('self','widgetL10nHandler'),$text); 128 128 } 129 129 130 130 echo $w->call(0); 131 131 } 132 132 133 133 private static function widgetL10nHandler($m) 134 134 { … … 136 136 } 137 137 } 138 ?>
Note: See TracChangeset
for help on using the changeset viewer.