Example #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();
}
Example #2
0
/**
 * Display the manual pages results table
 *
 * @param array Params
 */
function items_manual_results_block($params = array())
{
    // Make sure we are not missing any param:
    $params = array_merge(array('results_param_prefix' => 'items_manual_'), $params);
    if (!is_logged_in()) {
        // Only logged in users can access to this function
        return;
    }
    global $current_User, $blog, $Blog, $admin_url, $Session;
    $result_fadeout = $Session->get('fadeout_array');
    $cat_ID = param('cat_ID', 'integer', 0);
    if (empty($Blog)) {
        // Init Blog
        $BlogCache =& get_BlogCache();
        $blog = get_param('blog');
        if (!empty($blog)) {
            // Get Blog by ID
            $Blog = $BlogCache->get_by_ID($blog, false);
        }
        if (empty($Blog) && !empty($cat_ID)) {
            // Get Blog from chapter ID
            $ChapterCache =& get_ChapterCache();
            if ($Chapter =& $ChapterCache->get_by_ID($cat_ID, false)) {
                $Blog = $Chapter->get_Blog();
                $blog = $Blog->ID;
            }
        }
    }
    if (empty($Blog) || $Blog->get('type') != 'manual') {
        // No Blog, Exit here
        return;
    }
    if (is_ajax_content()) {
        $order_action = param('order_action', 'string');
        if ($order_action == 'update') {
            // Update an order to new value
            $order_value = (int) param('order_value', 'string', 0);
            $order_data = param('order_data', 'string');
            $order_data = explode('-', $order_data);
            $order_obj_ID = (int) $order_data[2];
            if ($order_obj_ID > 0) {
                switch ($order_data[1]) {
                    case 'chapter':
                        // Update chapter order
                        $ChapterCache =& get_ChapterCache();
                        if ($updated_Chapter =& $ChapterCache->get_by_ID($order_obj_ID, false)) {
                            if ($current_User->check_perm('blog_cats', '', false, $updated_Chapter->blog_ID)) {
                                // Check permission to edit this Chapter
                                $updated_Chapter->set('order', $order_value);
                                $updated_Chapter->dbupdate();
                                $ChapterCache->clear();
                            }
                        }
                        break;
                    case 'item':
                        // Update item order
                        $ItemCache =& get_ItemCache();
                        if ($updated_Item =& $ItemCache->get_by_ID($order_obj_ID, false)) {
                            if ($current_User->check_perm('item_post!CURSTATUS', 'edit', false, $updated_Item)) {
                                // Check permission to edit this Item
                                $updated_Item->set('order', $order_value);
                                $updated_Item->dbupdate();
                            }
                        }
                        break;
                }
            }
        }
    }
    load_class('_core/ui/_uiwidget.class.php', 'Table');
    $Table = new Table(NULL, $params['results_param_prefix']);
    $Table->title = T_('Manual Pages');
    // Redirect to manual pages after adding chapter
    $redirect_page = '&amp;redirect_page=manual';
    $Table->global_icon(T_('Add new chapter...'), 'add', $admin_url . '?ctrl=chapters&amp;action=new&amp;blog=' . $blog . $redirect_page, ' ' . T_('Add top level chapter') . ' &raquo;', 3, 4);
    $Table->cols[] = array('th' => T_('Name'));
    $Table->cols[] = array('th' => T_('URL "slug"'));
    $Table->cols[] = array('th' => T_('Order'), 'th_class' => 'shrinkwrap');
    $Table->cols[] = array('th' => T_('Actions'));
    if (is_ajax_content()) {
        // init results param by template name
        if (!isset($params['skin_type']) || !isset($params['skin_name'])) {
            debug_die('Invalid ajax results request!');
        }
        $Table->init_params_by_skin($params['skin_type'], $params['skin_name']);
    }
    $Table->display_init(NULL, $result_fadeout);
    $Table->display_head();
    echo $Table->replace_vars($Table->params['content_start']);
    $Table->display_list_start();
    $Table->display_col_headers();
    $Table->display_body_start();
    manual_display_chapters();
    $Table->display_body_end();
    $Table->display_list_end();
    // Flush fadeout
    $Session->delete('fadeout_array');
    echo $Table->params['content_end'];
    if (!is_ajax_content()) {
        // Create this hidden div to get a function name for AJAX request
        echo '<div id="' . $params['results_param_prefix'] . 'ajax_callback" style="display:none">' . __FUNCTION__ . '</div>';
    }
}
Example #3
0
     }
     if (isset($cron_messages_data['table_cols'], $cron_messages_data['table_data']) && !empty($cron_messages_data['table_data'])) {
         // Display table with report
         $Table = new Table(NULL, 'cron_');
         $Table->cols = array();
         if (!empty($cron_messages_data['table_cols'])) {
             foreach ($cron_messages_data['table_cols'] as $col_name) {
                 $Table->cols[] = array('th' => $col_name);
             }
         }
         $Table->display_init();
         $Table->display_list_start();
         // COLUMN HEADERS:
         $Table->display_col_headers();
         // BODY START:
         $Table->display_body_start();
         // Display table rows
         foreach ($cron_messages_data['table_data'] as $data_row) {
             $Table->display_line_start(false, false);
             foreach ($data_row as $row_value) {
                 $Table->display_col_start();
                 echo $row_value;
                 $Table->display_col_end();
             }
             $Table->display_line_end();
         }
         // BODY END:
         $Table->display_body_end();
         $Table->display_list_end();
     }
 }
/**
 * @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();
}