This repository was archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcms-hax-examples.php
More file actions
77 lines (72 loc) · 1.44 KB
/
cms-hax-examples.php
File metadata and controls
77 lines (72 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* Example for Drupal 6.x
*/
function _cms_hax_drupal6x($nid, $body) {
$return = array();
$node = node_load($nid);
$node->body = $body;
node_save($node);
return array(
'status' => 200,
'message' => t('Save successful!'),
'data' => $node,
);
}
/**
* Example for Drupal 7.x
*/
function _cms_hax_drupal7x($nid, $body) {
$return = array();
$node = node_load($nid);
$node->body['und'][0]['value'] = $body;
node_save($node);
return array(
'status' => 200,
'message' => t('Save successful!'),
'data' => $node,
);
}
/**
* Example for Drupal 8.x.x
*/
use Drupal\node\Entity\Node;
function _cms_hax_drupal8xx($nid, $body) {
$return = array();
$node = Node::load($nid);
$node->body->value = $body;
$node->save();
return array(
'status' => 200,
'message' => t('Save successful!'),
'data' => $node,
);
}
/**
* Example for Wordpress 4.x.x
*/
function _cms_hax_wordpress4xx($pid, $body) {
$return = array();
$post = get_post($pid);
$post->post_content = $body;
wp_insert_post($node);
return array(
'status' => 200,
'message' => t('Save successful!'),
'data' => $post,
);
}
/**
* Example for Backdrop 1xx
*/
function _cms_hax_backdrop1xx($nid, $body) {
$return = array();
$node = node_load($nid);
$node->body['und'][0]['value'] = $body;
node_save($node);
return array(
'status' => 200,
'message' => t('Save successful!'),
'data' => $node,
);
}