function content_display_content_admin_list

6.x content.module content_display_content_admin_list()
4.x content.module content_display_content_admin_list()
5.x content.module content_display_content_admin_list()

Display a list of content for the administrator

File

modules/content/content.module, line 2415

Code

function content_display_content_admin_list() {
  global $user;

  $rtn = "";

  //fp_add_css(fp_get_module_path("content") . "/css/content.css");

  fp_set_title('');


  $rtn .= "<br><b>" . t("Create new content:") . "</b>
            <table border='1' width='100%' cellpadding='4'>";
  // Go through all available content types and provide a link.
  $types = content_get_types();
  // We expect types to be returned like this:
  // ["page"]["title"] = "Basic Page";
  // ["page"]["description"] = "This is a standard page.";
  foreach ($types as $type => $details) {
    if (user_has_permission("add_$type" . "_content")) {
      $rtn .= "<tr>
                <td>" . l($details ["title"], "content/add/$type") . "</td>
                <td>" . $details ["description"] . "</td></tr>";
    }
  }



  $rtn .= "</table>
          
          <hr>";

  // Show a table of current content in the system.
  $rtn .= "<b>" . t("Existing content:") . "</b>";
  @$filter = $_GET ["filter"];

  $rtn .= "<form action='" . fp_url("admin-tools/content") . "' method='GET'>
              " . t("Display type:") . " &nbsp; <select name='filter'>
                  <option value=''>" . t(" -- Any --") . "</option>";
  foreach ($types as $type => $details) {
    $sel = ($type == $filter) ? "selected" : "";
    $rtn .= "<option value='$type' $sel>" . $details ["title"] . "</option>";
  }
  $rtn .= "</select><input type='submit' value='-&gt;'> </form>";



  $table_headers = array();
  $table_headers [] = array("label" => "Actions");
  $table_headers [] = array("label" => "Title", "field" => "n.title");
  $table_headers [] = array("label" => "Type", "field" => "n.type");
  $table_headers [] = array("label" => "Published", "field" => "n.published");
  $table_headers [] = array("label" => "Author");
  $table_headers [] = array("label" => "Updated", "field" => "n.updated");

  // Set our initial sort, if none is already set.   
  theme_table_header_sortable_set_initial_sort('n.updated', 'DESC');

  $rtn .= "<table width='100%' border='1'>";
  // Draw our our table headers, with links....
  $rtn .= theme_table_header_sortable($table_headers);

  $params = array();
  $filter_line = "";
  if ($filter != "") {
    $filter_line = "AND type = :ftype";
    $params [":ftype"] = $filter;

  }

  $content_types = content_get_types();

  // Only look for types which have been defined (nothing for modules we have since disabled)
  $types_line = "AND `type` IN ('" . join("','", array_keys($content_types)) . "')";


  // Get our order by clause based on selected table header, if any.    
  $order_by = theme_table_header_sortable_order_by($table_headers);
  $res = pager_query("SELECT DISTINCT(cid) FROM content n
                      WHERE delete_flag = 0
                      $types_line
                      $filter_line                                                       
                      $order_by", $params, 20, 0, "SELECT COUNT(DISTINCT(cid)) FROM content n
                                                        WHERE delete_flag = 0
                                                        $types_line
                                                        $filter_line                                                       
                                                        $order_by", $params);



  while ($cur = db_fetch_array($res)) {

    $content = content_load($cur ['cid']);

    $author = fp_load_user($content->user_id);
    $author_name = "";
    if ($author && isset($author->name)) {
      $author_name = $author->name;
    }

    $updated = format_date(convert_time($content->updated));

    $view_link = $edit_link = "";
    $view_link = l("<i class='fa fa-eye'></i>", "content/$content->cid");

    if ((user_has_permission("edit_any_{$content->type}" . "_content")) || (user_has_permission("edit_own_{$content->type}" . "_content") && intval($content->user_id) === intval($user->id) && intval($user->id) > 0)) {
      $edit_link = l("<i class='fa fa-pencil'></i>", "content/{$cur ["cid"]}/edit");
    }



    $rtn .= "<tr>
                <td>$view_link &nbsp; $edit_link</td>
                <td valign='top'>" . $content->title . "</td>";

    $rtn .= "
                <td valign='top'>" . $content->type . "</td>
                <td valign='top'>" . $content->published . "</td>
                <td valign='top'>" . $author_name . "</td>
                <td valign='top'>" . $updated . "</td>
             </tr>";
  }

  $rtn .= "</table>";

  // Display the pager that was generated by the pager_query above!  
  $rtn .= theme_pager();


  return $rtn;
}