Skip to content
Snippets Groups Projects
Select Git revision
  • 73ad4c765889050c1bf91b93b50b5b3cac5ecd40
  • 11.x default protected
  • 10.5.x protected
  • 10.6.x protected
  • 11.2.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
  • 10.4.5 protected
  • 11.0.13 protected
41 results

page.module

Blame
  • Dries Buytaert's avatar
    Dries Buytaert authored
    - fixed bug in page.module: $theme->header() got called twice.
    73ad4c76
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    page.module 2.79 KiB
    <?php
    
    $module = array("type" => "page_type",
                    "page" => "page_page",
                    "admin" => "page_admin");
    
    $format = array(0 => HTML, 1 => PHP, 2 => text);
    
    function page_type() {
      return array("page", "static page");
    }
    
    function page_view($node, $main = 0) {
      global $format, $theme;
    
      switch ($format[$node->format]) {
        case "PHP":
          $output = eval($node->body);
          break;
        case "text":
          $output = nl2br(htmlentities($node->body));
          break;
        default:
          $output = check_output($node->body, 1);
      }
    
      $theme->box(check_output($node->title), $output);
    }
    
    function page_status() {
      return array(dumped, posted);
    }
    
    function page_form($edit = array()) {
      global $format;
    
      $output .= "<FORM ACTION=\"admin.php?mod=page\" METHOD=\"post\">\n";
    
      $output .= "<B>Name:</B><BR>\n";
      $output .= "<INPUT NAME=\"edit[title]\" SIZE=\"55\" VALUE=\"". check_textfield($edit[title]) ."\"><P>\n";
    
      $output .= "<B>Body:</B><BR>\n";
      $output .= "<TEXTAREA NAME=\"edit[body]\" COLS=\"55\" ROWS=\"10\" WRAP=\"virtual\">". check_textarea($edit[body]) ."</TEXTAREA><P>\n";
    
      $output .= "<B>Type:</B><BR>\n";
      foreach ($format as $key=>$value) $options .= "<OPTION VALUE=\"$key\"". ($edit[format] == $key ? " SELECTED" : "") .">$value</OPTION>\n";
      $output .= "<SELECT NAME=\"edit[format]\">$options</SELECT><P>\n";
    
      $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\n";
    
      $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save page\">\n";
      $output .= "</FORM>\n";
    
      return $output;
    }
    
    function page_save($edit) {
      global $status;
      node_save(array_merge($edit, array(type => "page", status => $status[posted])));
    }
    
    function page_query($type = "") {
      global $status;
      $queries =  array(array("recent pages", "WHERE n.type = 'page' ORDER BY n.timestamp DESC"), array("posted pages", "WHERE n.type = 'page' AND n.status = '$status[posted]' ORDER BY n.timestamp DESC"), array("dumped pages", "WHERE n.type = 'page' AND n.status = '$status[dumped]' ORDER BY n.timestamp DESC"));
      return ($queries[$type] ? $queries[$type] : $queries);
    }
    
    function page_overview($query = array()) {
      return node_overview($query);
    }
    
    function page_admin() {
      global $id, $op, $edit, $type;
    
      print "<SMALL><A HREF=\"admin.php?mod=page&op=add\">add new page</A> | <A HREF=\"admin.php?mod=page&op=listing\">page listing</A> | <A HREF=\"admin.php?mod=page\">overview</A></SMALL><HR>\n";
    
      $type = ($type ? $type : 0);
    
      switch ($op) {
        case "add":
          print page_form();
          break;
        case "edit":
          print page_form(node_get_array(nid, $id));
          break;
        case "listing":
          print node_listing(page_query());
          break;
       case "Save page":
          print status(page_save($edit));
          // fall through:
        default:
          print page_overview(page_query($type));
      }
    }
    
    ?>