/** * @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&container=' . rawurlencode($container)), T_('Add widget') . ' »', 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&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&wi_ID=' . $ComponentWidget->ID . '&' . 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&wi_ID=' . $ComponentWidget->ID . '&' . 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&wi_ID=' . $ComponentWidget->ID . '&' . url_crumb('widget'))); } else { echo action_icon(T_('Enable this widget!'), 'activate', regenerate_url('blog', 'action=toggle&wi_ID=' . $ComponentWidget->ID . '&' . url_crumb('widget'))); } echo '<span class="edit_icon_hook">' . action_icon(T_('Edit widget settings!'), 'edit', regenerate_url('blog', 'action=edit&wi_ID=' . $ComponentWidget->ID)) . '</span>'; echo '<span class="delete_icon_hook">' . action_icon(T_('Remove this widget!'), 'delete', regenerate_url('blog', 'action=delete&wi_ID=' . $ComponentWidget->ID . '&' . url_crumb('widget'))) . '</span>'; $Table->display_col_end(); $Table->display_line_end(); } } // BODY END: $Table->display_body_end(); $Table->display_list_end(); }
$Table->cols[] = array('th' => T_('Posts'), 'th_class' => 'shrinkwrap'); if ($permission_to_edit) { // We have permission permission to edit, so display action column: $Table->cols[] = array('th' => T_('Actions')); } // Get # of posts for each category global $number_of_posts_in_cat; $number_of_posts_in_cat = $DB->get_assoc(' SELECT cat_ID, count(postcat_post_ID) c FROM T_categories LEFT JOIN T_postcats ON postcat_cat_ID = cat_id WHERE cat_blog_ID = ' . $DB->quote($subset_ID) . ' GROUP BY cat_ID'); $Table->display_init(array('list_attrib' => 'id="chapter_list"'), $result_fadeout); $results_params = $AdminUI->get_template('Results'); echo $results_params['before']; $Table->display_head(); echo $Table->params['content_start']; $Table->display_list_start(); $Table->display_col_headers(); $Table->display_body_start(); echo $ChapterCache->recurse($callbacks, $subset_ID, NULL, 0, 0, array('sorted' => true)); $Table->display_body_end(); $Table->display_list_end(); echo $Table->params['content_end']; echo $results_params['after']; /* fp> TODO: maybe... (a general group move of posts would be more useful actually) echo '<p class="note">'.T_('<strong>Note:</strong> Deleting a category does not delete posts from that category. It will just assign them to the parent category. When deleting a root category, posts will be assigned to the oldest remaining category in the same collection (smallest category number).').'</p>'; */ global $Settings, $dispatcher; // Use a wrapper div to have margin around the form echo '<div id="form_wrapper" style="margin: 2ex auto 1ex">';
/** * @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&container=' . rawurlencode($container)), T_('Add widget') . ' »', 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&wi_ID=' . $ComponentWidget->ID . '&' . url_crumb('widget'))); echo '</span>'; } else { echo action_icon(T_('The widget is disabled.'), 'bullet_empty_grey', regenerate_url('blog', 'action=toggle&wi_ID=' . $ComponentWidget->ID . '&' . url_crumb('widget'))); } $Table->display_col_end(); $Table->display_col_start(); $ComponentWidget->init_display(array()); echo '<a href="' . regenerate_url('blog', 'action=edit&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&wi_ID=' . $ComponentWidget->ID . '&' . 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&wi_ID=' . $ComponentWidget->ID . '&' . 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&tab=advanced&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&wi_ID=' . $ComponentWidget->ID . '&' . 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&wi_ID=' . $ComponentWidget->ID . '&' . 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&wi_ID=' . $ComponentWidget->ID . '&' . url_crumb('widget'))); } else { echo action_icon(T_('Enable this widget!'), 'activate', regenerate_url('blog', 'action=toggle&wi_ID=' . $ComponentWidget->ID . '&' . url_crumb('widget'))); } echo '<span class="edit_icon_hook">' . action_icon(T_('Edit widget settings!'), 'edit', regenerate_url('blog', 'action=edit&wi_ID=' . $ComponentWidget->ID)) . '</span>'; echo '<span class="delete_icon_hook">' . action_icon(T_('Remove this widget!'), 'delete', regenerate_url('blog', 'action=delete&wi_ID=' . $ComponentWidget->ID . '&' . url_crumb('widget'))) . '</span>'; $Table->display_col_end(); $Table->display_line_end(); } } // BODY END: $Table->display_body_end(); $Table->display_list_end(); }
/** * 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 = '&redirect_page=manual'; $Table->global_icon(T_('Add new chapter...'), 'add', $admin_url . '?ctrl=chapters&action=new&blog=' . $blog . $redirect_page, ' ' . T_('Add top level chapter') . ' »', 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>'; } }
/** * Display threads results table * * @param array Params */ function threads_results_block($params = array()) { // Make sure we are not missing any param: $params = array_merge(array('edited_User' => NULL, 'results_param_prefix' => 'actv_thrd_', 'results_title' => T_('Threads with private messages sent by the user'), 'results_no_text' => T_('User has not sent any private messages')), $params); if (!is_logged_in()) { // Only logged in users can access to this function return; } global $current_User; if (!$current_User->check_perm('users', 'moderate') || !$current_User->check_perm('perm_messaging', 'reply')) { // Check minimum permission: return; } $edited_User = $params['edited_User']; if (!$edited_User) { // No defined User, probably the function is calling from AJAX request $user_ID = param('user_ID', 'integer', 0); if (empty($user_ID)) { // Bad request, Exit here return; } $UserCache =& get_UserCache(); if (($edited_User =& $UserCache->get_by_ID($user_ID, false)) === false) { // Bad request, Exit here return; } } global $DB, $current_User, $AdminUI; param('user_tab', 'string', '', true); param('user_ID', 'integer', 0, true); $results_params = $AdminUI->get_template('Results'); $display_params = array('before' => str_replace('>', ' style="margin-top:25px" id="threads_result">', $results_params['before']), 'after' => $results_params['after']); // Check permission: if ($current_User->check_perm('perm_messaging', 'abuse')) { // Create result set: $threads_Results = get_threads_results(array('results_param_prefix' => $params['results_param_prefix'], 'user_ID' => $edited_User->ID, 'sent_user_ID' => $edited_User->ID)); $threads_Results->Cache =& get_ThreadCache(); $threads_Results->title = $params['results_title']; $threads_Results->no_results_text = $params['results_no_text']; if ($threads_Results->get_total_rows() > 0) { // Display action icon to delete all records if at least one record exists $threads_Results->global_icon(sprintf(T_('Delete all private messages sent by %s'), $edited_User->login), 'delete', '?ctrl=user&user_tab=activity&action=delete_all_messages&user_ID=' . $edited_User->ID . '&' . url_crumb('user'), ' ' . T_('Delete all'), 3, 4); } // Load classes load_class('messaging/model/_thread.class.php', 'Thread'); // Initialize Results object threads_results($threads_Results, array('abuse_management' => 1, 'show_only_date' => 1)); 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!'); } $threads_Results->init_params_by_skin($params['skin_type'], $params['skin_name']); } $threads_Results->display($display_params); 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>'; } } else { // No permission for abuse management $Table = new Table(); $Table->title = T_('Messaging'); $Table->no_results_text = sprintf(T_('User has sent %s private messages'), $edited_User->get_num_messages('sent')); $Table->display_init(); $Table->total_pages = 0; echo $display_params['before']; $Table->display_head(); echo $Table->params['content_start']; $Table->display_list_start(); $Table->display_list_end(); echo $Table->params['content_end']; echo $display_params['after']; } }