コード例 #1
0
/**
 * @param string Title of the container. This gets passed to T_()!
 * @param string Suffix of legend
 */
function display_container($container, $legend_suffix = '')
{
    global $Blog;
    global $Session;
    $Table = new Table();
    $Table->title = '<span class="container_name">' . T_($container) . '</span>' . $legend_suffix;
    // Table ID - fp> needs to be handled cleanly by Table object
    $table_id = str_replace(' ', '_', $container);
    // fp> Using the container name which has special chars is a bad idea. Counter would be better
    $Table->global_icon(T_('Add a widget...'), 'new', regenerate_url('', 'action=new&amp;container=' . rawurlencode($container)), T_('Add widget') . ' &raquo;', 3, 4, array('id' => 'add_new_' . $table_id));
    $Table->cols = array(array('th' => T_('En'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap'), array('th' => T_('Widget')), array('th' => T_('Type')), array('th' => T_('Move'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap'), array('th' => T_('Actions'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap'));
    //enable fadeouts here
    $Table->display_init(NULL, array('fadeouts' => true));
    // add ID for jQuery
    // TODO: fp> Awfully dirty. This should be handled by the Table object
    $Table->params['list_start'] = str_replace('<table', '<table id="' . $table_id . '"', $Table->params['list_start']);
    /*
    if( $legend_suffix )
    {	// add jQuery no-drop -- fp> what do we need this one for?
    	$Table->params['head_title'] = str_replace( 'class="grouped"', 'class="grouped no-drop"', $Table->params['head_title'] );
    }
    */
    $Table->display_list_start();
    // TITLE / COLUMN HEADERS:
    $Table->display_head();
    // BODY START:
    $Table->display_body_start();
    /**
     * @var WidgetCache
     */
    $WidgetCache =& get_WidgetCache();
    $Widget_array =& $WidgetCache->get_by_coll_container($Blog->ID, $container);
    if (empty($Widget_array)) {
        // TODO: cleanup
        $Table->display_line_start(true);
        $Table->display_col_start(array('colspan' => 5));
        echo '<span class="new_widget">' . T_('There is no widget in this container yet.') . '</span>';
        $Table->display_col_end();
        $Table->display_line_end();
    } else {
        $widget_count = 0;
        foreach ($Widget_array as $ComponentWidget) {
            $widget_count++;
            $enabled = $ComponentWidget->get('enabled');
            $fadeout_id = $Session->get('fadeout_id');
            if (isset($fadeout_id) && $ComponentWidget->ID == $fadeout_id) {
                $fadeout = true;
                $Session->delete('fadeout_id');
            } else {
                $fadeout = false;
            }
            $Table->display_line_start(false, $fadeout);
            $Table->display_col_start();
            if ($enabled) {
                // Indicator for the JS UI:
                echo '<span class="widget_is_enabled">';
                echo get_icon('enabled', 'imgtag', array('title' => T_('The widget is enabled.')));
                echo '</span>';
            } else {
                echo get_icon('disabled', 'imgtag', array('title' => T_('The widget is disabled.')));
            }
            $Table->display_col_end();
            $Table->display_col_start();
            $ComponentWidget->init_display(array());
            echo '<a href="' . regenerate_url('blog', 'action=edit&amp;wi_ID=' . $ComponentWidget->ID) . '" class="widget_name">' . $ComponentWidget->get_desc_for_list() . '</a>';
            $Table->display_col_end();
            // Note: this is totally useless, but we need more cols for the screen to feel "right":
            $Table->display_col_start();
            echo $ComponentWidget->type;
            $Table->display_col_end();
            // Move
            $Table->display_col_start();
            //echo $ComponentWidget->order.' ';
            if ($widget_count > 1) {
                echo action_icon(T_('Move up!'), 'move_up', regenerate_url('blog', 'action=move_up&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
            } else {
                echo get_icon('nomove', 'imgtag', array('class' => 'action_icon'));
            }
            if ($widget_count < count($Widget_array)) {
                echo action_icon(T_('Move down!'), 'move_down', regenerate_url('blog', 'action=move_down&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
            } else {
                echo get_icon('nomove', 'imgtag', array('class' => 'action_icon'));
            }
            $Table->display_col_end();
            // Actions
            $Table->display_col_start();
            if ($enabled) {
                echo action_icon(T_('Disable this widget!'), 'deactivate', regenerate_url('blog', 'action=toggle&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
            } else {
                echo action_icon(T_('Enable this widget!'), 'activate', regenerate_url('blog', 'action=toggle&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
            }
            echo '<span class="edit_icon_hook">' . action_icon(T_('Edit widget settings!'), 'edit', regenerate_url('blog', 'action=edit&amp;wi_ID=' . $ComponentWidget->ID)) . '</span>';
            echo '<span class="delete_icon_hook">' . action_icon(T_('Remove this widget!'), 'delete', regenerate_url('blog', 'action=delete&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget'))) . '</span>';
            $Table->display_col_end();
            $Table->display_line_end();
        }
    }
    // BODY END:
    $Table->display_body_end();
    $Table->display_list_end();
}
コード例 #2
0
 function display_footer_container()
 {
     global $Blog, $app_version;
     if (version_compare($app_version, '4.0') < 0) {
         // b2evo 3
         $WidgetCache =& get_Cache('WidgetCache');
     } else {
         // b2evo 4 and up
         $WidgetCache =& get_WidgetCache();
     }
     $fwcount = 0;
     if ($Widget_array = $WidgetCache->get_by_coll_container($Blog->ID, 'Footer')) {
         foreach ($Widget_array as $ComponentWidget) {
             if ($ComponentWidget->enabled) {
                 $fwcount++;
             }
         }
     }
     if ($fwcount < 1) {
         $fwcount = 1;
     }
     echo '<ul class="blocks widgetcount-' . $fwcount . '">';
     // "Footer" CONTAINER EMBEDDED HERE
     skin_container(NT_('Footer'), array('block_start' => '<li class="block"><div class="block-content clearfix">', 'block_end' => '</div></li>', 'block_title_start' => '<h4 class="title">', 'block_title_end' => '</h4>', 'list_start' => '<ul>', 'list_end' => '</ul>', 'item_start' => '<li class="page_item">', 'item_end' => '</li>', 'group_start' => '<ul>', 'group_end' => '</ul>', 'notes_start' => '<div class="notes">', 'notes_end' => '</div>'));
     echo '</ul>';
 }
コード例 #3
0
ファイル: register.php プロジェクト: Ariflaw/b2evolution
 // Use this boolean var to know when quick registration is used
 $is_quick = $action == 'quick_register';
 if ($is_quick) {
     // Check if we can use a quick registration now:
     if ($Settings->get('newusers_canregister') != 'yes' || !$Settings->get('quick_registration')) {
         // Display error message when quick registration is disabled
         $Messages->add(T_('Quick registration is currently disabled on this system.'), 'error');
         break;
     }
     param('widget', 'integer', 0);
     if (empty($Blog) || empty($widget)) {
         // Don't use a quick registration if the request goes from not blog page
         $Messages->add(T_('Quick registration is currently disabled on this system.'), 'error');
         break;
     }
     $WidgetCache =& get_WidgetCache();
     if (!($user_register_Widget =& $WidgetCache->get_by_ID($widget, false, false)) || $user_register_Widget->code != 'user_register' || $user_register_Widget->get('coll_ID') != $Blog->ID) {
         // Wrong or hacked request!
         $Messages->add(T_('Quick registration is currently disabled on this system.'), 'error');
         break;
     }
     if ($DB->get_var('SELECT user_ID FROM T_users WHERE user_email = ' . $DB->quote(utf8_strtolower($email)))) {
         // Don't allow the duplicate emails
         $Messages->add(sprintf(T_('You already registered on this site. You can <a %s>log in here</a>. If you don\'t know or have forgotten it, you can <a %s>set your password here</a>.'), 'href="' . $Blog->get('loginurl') . '"', 'href="' . $Blog->get('lostpasswordurl') . '"'), 'warning');
         break;
     }
     // Initialize the widget settings
     $user_register_Widget->init_display(array());
     // Get a source from widget setting
     $source = $user_register_Widget->disp_params['source'];
     // Check what fields should be required by current widget
コード例 #4
0
/**
 * @param string Title of the container. This gets passed to T_()!
 * @param string Suffix of legend
 */
function display_container($container, $legend_suffix = '')
{
    global $Blog, $admin_url;
    global $Session;
    $Table = new Table();
    $Table->title = '<span class="container_name">' . T_($container) . '</span>' . $legend_suffix;
    // Table ID - fp> needs to be handled cleanly by Table object
    $table_id = str_replace(array(' ', ':'), array('_', '-'), $container);
    // fp> Using the container name which has special chars is a bad idea. Counter would be better
    $Table->global_icon(T_('Add a widget...'), 'new', regenerate_url('', 'action=new&amp;container=' . rawurlencode($container)), T_('Add widget') . ' &raquo;', 3, 4, array('id' => 'add_new_' . $table_id, 'class' => 'action_icon btn-primary'));
    $Table->cols = array(array('th' => '', 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap'), array('th' => T_('En'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap'), array('th' => T_('Widget')), array('th' => T_('Type')), array('th' => T_('Move'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap'), array('th' => T_('Cache'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap widget_cache_status'), array('th' => T_('Actions'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap'));
    //enable fadeouts here
    $Table->display_init(array('list_attrib' => 'id="' . $table_id . '"', 'list_class' => 'widget_container_list'), array('fadeouts' => true));
    /*
    if( $legend_suffix )
    {	// add jQuery no-drop -- fp> what do we need this one for?
    	$Table->params['head_title'] = str_replace( 'class="grouped"', 'class="grouped no-drop"', $Table->params['head_title'] );
    }
    */
    // Dirty hack for bootstrap skin
    $Table->params['list_start'] = str_replace('<div class="', '<div class="panel panel-default ', $Table->params['list_start']);
    $Table->display_list_start();
    // TITLE / COLUMN HEADERS:
    $Table->display_head();
    // BODY START:
    $Table->display_body_start();
    /**
     * @var WidgetCache
     */
    $WidgetCache =& get_WidgetCache();
    $Widget_array =& $WidgetCache->get_by_coll_container($Blog->ID, $container);
    if (empty($Widget_array)) {
        // TODO: cleanup
        $Table->display_line_start(true);
        $Table->display_col_start(array('colspan' => 6));
        echo '<span class="new_widget">' . T_('There is no widget in this container yet.') . '</span>';
        $Table->display_col_end();
        $Table->display_line_end();
    } else {
        $widget_count = 0;
        foreach ($Widget_array as $ComponentWidget) {
            $widget_count++;
            $enabled = $ComponentWidget->get('enabled');
            $fadeout_id = $Session->get('fadeout_id');
            if (isset($fadeout_id) && $ComponentWidget->ID == $fadeout_id) {
                $fadeout = true;
                $Session->delete('fadeout_id');
            } else {
                $fadeout = false;
            }
            $Table->display_line_start(false, $fadeout);
            $Table->display_col_start();
            echo '<input type="checkbox" name="widgets[]" value="' . $ComponentWidget->ID . '" />';
            $Table->display_col_end();
            $Table->display_col_start();
            if ($enabled) {
                // Indicator for the JS UI:
                echo '<span class="widget_is_enabled">';
                echo action_icon(T_('The widget is enabled.'), 'bullet_green', regenerate_url('blog', 'action=toggle&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
                echo '</span>';
            } else {
                echo action_icon(T_('The widget is disabled.'), 'bullet_empty_grey', regenerate_url('blog', 'action=toggle&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
            }
            $Table->display_col_end();
            $Table->display_col_start();
            $ComponentWidget->init_display(array());
            echo '<a href="' . regenerate_url('blog', 'action=edit&amp;wi_ID=' . $ComponentWidget->ID) . '" class="widget_name">' . $ComponentWidget->get_desc_for_list() . '</a> ' . $ComponentWidget->get_help_link();
            $Table->display_col_end();
            // Note: this is totally useless, but we need more cols for the screen to feel "right":
            $Table->display_col_start();
            echo $ComponentWidget->type;
            $Table->display_col_end();
            // Move
            $Table->display_col_start();
            //echo $ComponentWidget->order.' ';
            if ($widget_count > 1) {
                echo action_icon(T_('Move up!'), 'move_up', regenerate_url('blog', 'action=move_up&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
            } else {
                echo get_icon('nomove', 'imgtag', array('class' => 'action_icon'));
            }
            if ($widget_count < count($Widget_array)) {
                echo action_icon(T_('Move down!'), 'move_down', regenerate_url('blog', 'action=move_down&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
            } else {
                echo get_icon('nomove', 'imgtag', array('class' => 'action_icon'));
            }
            $Table->display_col_end();
            // Cache
            $Table->display_col_start();
            $widget_cache_status = $ComponentWidget->get_cache_status(true);
            switch ($widget_cache_status) {
                case 'disallowed':
                    echo get_icon('block_cache_disabled', 'imgtag', array('title' => T_('This widget cannot be cached.'), 'rel' => $widget_cache_status));
                    break;
                case 'denied':
                    echo action_icon(T_('This widget could be cached but the block cache is OFF. Click to enable.'), 'block_cache_denied', $admin_url . '?ctrl=coll_settings&amp;tab=advanced&amp;blog=' . $Blog->ID . '#fieldset_wrapper_caching', NULL, NULL, NULL, array('rel' => $widget_cache_status));
                    break;
                case 'enabled':
                    echo action_icon(T_('Caching is enabled. Click to disable.'), 'block_cache_on', regenerate_url('blog', 'action=cache_disable&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')), NULL, NULL, NULL, array('rel' => $widget_cache_status));
                    break;
                case 'disabled':
                    echo action_icon(T_('Caching is disabled. Click to enable.'), 'block_cache_off', regenerate_url('blog', 'action=cache_enable&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')), NULL, NULL, NULL, array('rel' => $widget_cache_status));
                    break;
            }
            $Table->display_col_end();
            // Actions
            $Table->display_col_start();
            if ($enabled) {
                echo action_icon(T_('Disable this widget!'), 'deactivate', regenerate_url('blog', 'action=toggle&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
            } else {
                echo action_icon(T_('Enable this widget!'), 'activate', regenerate_url('blog', 'action=toggle&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
            }
            echo '<span class="edit_icon_hook">' . action_icon(T_('Edit widget settings!'), 'edit', regenerate_url('blog', 'action=edit&amp;wi_ID=' . $ComponentWidget->ID)) . '</span>';
            echo '<span class="delete_icon_hook">' . action_icon(T_('Remove this widget!'), 'delete', regenerate_url('blog', 'action=delete&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget'))) . '</span>';
            $Table->display_col_end();
            $Table->display_line_end();
        }
    }
    // BODY END:
    $Table->display_body_end();
    $Table->display_list_end();
}