/[drupal]/contributions/modules/index/includes/index.classes.inc
ViewVC logotype

Diff of /contributions/modules/index/includes/index.classes.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.9, Fri Apr 24 19:31:10 2009 UTC revision 1.1.2.10, Mon Oct 19 01:19:46 2009 UTC
# Line 6  Line 6 
6   */   */
7    
8  class index {  class index {
9      public $iid = 0;
10    public $title = '';    public $title = '';
11    public $description = '';    public $description = '';
12      public $page_enabled = '';
13    public $page_mode = '';    public $page_mode = '';
14    public $page_path = '';    public $page_path = '';
15      public $block_enabled = '';
16    public $block_mode = '';    public $block_mode = '';
17    public $layers = array();    public $layers = array();
18    
# Line 28  class index { Line 31  class index {
31          $this->$property = $value;          $this->$property = $value;
32        }        }
33      }      }
34        $result = db_query("SELECT * FROM {index_layer} WHERE iid = %d", $this->iid);
35        while ($layer = db_fetch_object($result)) {
36          $this->layers[$layer->depth] = array(
37            'type' => $layer->type,
38            'count' => $layer->count,
39          );
40        }
41    }    }
42    
43    /**    /**
44     * Insert a new index into the database.     * Insert a new index into the database.
45     */     */
46    function insert() {    function insert() {
47      return drupal_write_record('index_index', $this);      $status = drupal_write_record('index_index', $this);
48        $this->updateLayers();
49    
50        return $status;
51    }    }
52    
53    /**    /**
54     * Update an existing index.     * Update an existing index.
55     */     */
56    function update() {    function update() {
57        $this->updateLayers();
58    
59      return drupal_write_record('index_index', $this, 'iid');      return drupal_write_record('index_index', $this, 'iid');
60    }    }
61    
62      private function updateLayers() {
63        db_query("DELETE FROM {index_layer} WHERE iid = %d", $this->iid);
64        foreach ($this->layers as $depth => $layer) {
65          db_query("INSERT INTO {index_layer} (iid, depth, type, count) VALUES (%d, %d, '%s', %d)", $this->iid, $depth, $layer['type'], $layer['count']);
66        }
67      }
68    
69    /**    /**
70     * Delete the index.     * Delete the index.
71     */     */
# Line 61  class index { Line 83  class index {
83     * @return     * @return
84     *   The rendered index.     *   The rendered index.
85     */     */
86    function view($type) {    function view() {
87      index_load_include('view');      index_load_include('view');
88    
89      // Render the list of items.      // Render the list of items.
     $modes = index_modes_get();  
     $callback .= '_mode';  
     $mode = $modes[$this->$callback];  
     if (isset($mode['file'])) {  
       module_load_include('', $mode['module'], $mode['file']);  
     }  
90      // There are no rendering functions yet, so display a simple message in the meantime.      // There are no rendering functions yet, so display a simple message in the meantime.
     // $list = call_user_func($callback, $this);  
91      $list = '<p class="warning">There are no rendering functions yet. However, this text gives you an example of what the index would have looked like if it could have been rendered.</p>';      $list = '<p class="warning">There are no rendering functions yet. However, this text gives you an example of what the index would have looked like if it could have been rendered.</p>';
92    
93      return theme('index', check_plain($this->description), $list);      return theme('index', check_plain($this->description), $list);

Legend:
Removed from v.1.1.2.9  
changed lines
  Added in v.1.1.2.10

  ViewVC Help
Powered by ViewVC 1.1.2