/[drupal]/contributions/sandbox/unconed/soc/inlineedit.module
ViewVC logotype

Contents of /contributions/sandbox/unconed/soc/inlineedit.module

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


Revision 1.1 - (show annotations) (download) (as text)
Wed Aug 31 23:05:05 2005 UTC (4 years, 2 months ago) by unconed
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-php
- Putting SoC stuff up
1 <?php
2
3 function inlineedit_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
4 if ($op == 'view') {
5 drupal_add_js('misc/inlineedit.js');
6
7 $unprocessed = node_load(array('nid' => $node->nid));
8
9 $field = $teaser ? 'teaser' : 'body';
10 $node->$field = '<div class="inlineedit" id="edit-inlineedit-'. $node->nid .'">'. $node->$field .'</div>';
11 $form = form_textarea('', 'inlineedit-'. $node->nid . '-textarea', $unprocessed->body, 0, 0);
12 $node->$field .= form($form, 'post', url('inlineedit', 'nid='. $node->nid .'&teaser='. $teaser .'&page='. $page), array('style' => 'display: none; margin: 0px; padding: 0px;'));
13
14 if ($_GET['q'] != 'inlineedit') {
15 $node->$field = '<div>'. $node->$field .'</div>';
16 }
17 }
18 }
19
20 function inlineedit_menu($may_cache) {
21 if (!$may_cache) {
22 return array(array('path' => 'inlineedit', 'callback' => 'inlineedit_ajax', 'type' => MENU_CALLBACK, 'access' => true));
23 }
24 }
25
26 function inlineedit_ajax() {
27 $data = $_POST['value'];
28 $nid = $_GET['nid'];
29 $page = $_GET['page'];
30 $teaser = $_GET['teaser'];
31
32 $node = node_load(array('nid' => $nid));
33 $node->teaser = '';
34 $node->body = $data;
35 node_save($node);
36
37 $node = node_load(array('nid' => $nid), NULL, TRUE);
38 $node->body = str_replace('<!--break-->', '', $node->body);
39 if (node_hook($node, 'view')) {
40 node_invoke($node, 'view', $teaser, $page);
41 }
42 else {
43 $node = node_prepare($node, $teaser);
44 }
45 node_invoke_nodeapi($node, 'view', $teaser, $page);
46
47 $field = $teaser ? 'teaser' : 'body';
48 print $node->$field;
49 exit();
50 }
51
52 ?>

  ViewVC Help
Powered by ViewVC 1.1.2