Changeset 2772:df84ff8c6261 for plugins/widgets
- Timestamp:
- 11/10/14 12:00:56 (11 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
plugins/widgets/_public.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/widgets/_public.php
r2566 r2772 17 17 $core->tpl->addValue('Widgets',array('publicWidgets','tplWidgets')); 18 18 $core->tpl->addBlock('Widget',array('publicWidgets','tplWidget')); 19 $core->tpl->addBlock('IfWidgets',array('publicWidgets','tplIfWidgets')); 19 20 20 21 class publicWidgets … … 66 67 echo $w->call($k); 67 68 } 69 } 70 71 public static function tplIfWidgets($attr,$content) 72 { 73 $type = isset($attr['type']) ? $attr['type'] : ''; 74 75 # widgets to disable 76 $disable = isset($attr['disable']) ? trim($attr['disable']) : ''; 77 78 if ($type == '') { 79 $res = "publicWidgets::ifWidgetsHandler('nav','".addslashes($disable)."') &&"."\n". 80 " publicWidgets::ifWidgetsHandler('extra','".addslashes($disable)."') &&"."\n". 81 " publicWidgets::ifWidgetsHandler('custom','".addslashes($disable)."')"."\n"; 82 } else { 83 if (!in_array($type, array('nav','extra','custom'))) { 84 $type = 'nav'; 85 } 86 $res = "publicWidgets::ifWidgetsHandler('".addslashes($type)."','".addslashes($disable)."')"; 87 } 88 return '<?php if('.$res.') : ?>'.$content.'<?php endif; ?>'; 89 } 90 91 public static function ifWidgetsHandler($type,$disable='') 92 { 93 $wtype = 'widgets_'.$type; 94 $GLOBALS['core']->blog->settings->addNameSpace('widgets'); 95 $widgets = $GLOBALS['core']->blog->settings->widgets->{$wtype}; 96 97 if (!$widgets) { // If widgets value is empty, get defaults 98 $widgets = self::defaultWidgets($type); 99 } else { // Otherwise, load widgets 100 $widgets = dcWidgets::load($widgets); 101 } 102 103 return (!$widgets->isEmpty()); 68 104 } 69 105
Note: See TracChangeset
for help on using the changeset viewer.
