. */ function uwa_load_exposition() { define('EXPOSITION', dirname(__FILE__) . '/Exposition/'); set_include_path(get_include_path() . PATH_SEPARATOR . EXPOSITION); include 'Exposition.php'; include 'Parser/Factory.php'; Exposition::load(false); return true; } function uwa_init_dashboard() { if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) return; foreach ($widget_options as $id => $options) { if ( !empty($options) && !empty($options['moduleUrl']) ) { wp_add_dashboard_widget($id, $options['title'], 'uwa_widget', 'uwa_widget_configure'); } } } function uwa_widget($widget_id = '', $array) { $widget_id = $array['id']; if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) $widget_options = array(); if ( !isset($widget_options[$widget_id]) ) $widget_options[$widget_id] = array(); $uwaUrl = $widget_options[$widget_id]['moduleUrl']; $ifproxyUrl = get_option( 'siteurl' ) . '/wp-content/plugins/' . plugin_basename(dirname(__FILE__)) . '/ifproxy.html'; $iframeUrl = 'http://nvmodules.netvibes.com/widget/frame?uwaUrl=' . urlencode($uwaUrl); $iframeUrl .= '&id=' . $widget_id . '&status=1'; $iframeUrl .= '&ifproxyUrl=' . urlencode($ifproxyUrl); foreach ($widget_options[$widget_id] as $key => $value) { $iframeUrl .= '&' . $key . '=' . urlencode($value); } echo ''; } function uwa_widget_configure($widgetId = '', $array) { $widget_id = $array['id']; if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) $widget_options = array(); if ( !isset($widget_options[$widget_id]) ) $widget_options[$widget_id] = array(); if ('POST' == $_SERVER['REQUEST_METHOD']) { foreach ($_POST as $key => $value) { if ($value == 'on') { $value = 'true'; } $widget_options[$widget_id][$key] = $value; } update_option( 'dashboard_widget_options', $widget_options ); return; } $uwaUrl = $widget_options[$widget_id]['moduleUrl']; uwa_load_exposition(); $parser = Parser_Factory::getParser('uwa', $uwaUrl); $widget = $parser->buildWidget(); echo ''; foreach ($widget->getPreferences() as $preference) { $name = $preference->getName(); $value = !empty($widget_options[$widget_id][$name]) ? $widget_options[$widget_id][$name] : ''; if (empty($value)) { $defaultValue = $preference->getDefaultValue(); if ($defaultValue) { $value = $defaultValue; } } echo ''; } echo '
'; switch ($preference->getType()) { case 'text': echo ''; break; case 'boolean': $checked = $value == 'true' ? ' checked="checked"' : ''; echo ''; break; case 'password': echo ''; break; case 'range': $opt = $preference->getRangeOptions(); echo ''; break; case 'list': $options = $preference->getListOptions(); echo ''; break; case 'hidden': break; default: echo 'Unknown type: ' . $preference->getType() . '
'; } echo '
'; }