forked from tag1consulting/ckeditor_comment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathckeditor_comment.controller.inc
113 lines (102 loc) · 2.82 KB
/
ckeditor_comment.controller.inc
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/**
* @file
* ckeditor_comment classes.
*/
/**
* Class CKEditorCommentController.
*/
class CKEditorCommentController extends EntityAPIController {
/**
* {@inheritdoc}
*/
public function create(array $values = array()) {
global $user;
$values += array(
'pid' => 0,
'resolved' => 0,
'bookmarks' => '',
'entity_id' => '',
'entity_vid' => '',
'entity_type' => 'node',
'entity_bundle' => '',
'field_name' => '',
'field_summary' => '',
'created' => REQUEST_TIME,
'changed' => REQUEST_TIME,
'uid' => $user->uid,
);
return parent::create($values);
}
/**
* {@inheritdoc}
*/
public function buildContent($entity, $view_mode = 'full', $langcode = NULL, $content = array()) {
$wrapper = entity_metadata_wrapper('ckeditor_comment', $entity);
$content['author'] = array('#markup' => t('Created by: !author', array('!author' => $wrapper->uid->name->value(array('sanitize' => TRUE)))));
return parent::buildContent($entity, $view_mode, $langcode, $content);
}
}
/**
* Class CKEditorCommentTypeController.
*/
class CKEditorCommentTypeController extends EntityAPIControllerExportable {
/**
* {@inheritdoc}
*/
public function create(array $values = array()) {
$values += array(
'label' => '',
'description' => '',
);
return parent::create($values);
}
/**
* Save CKEditor Comment Type.
*/
public function save($entity, DatabaseTransaction $transaction = NULL) {
parent::save($entity, $transaction);
// Rebuild menu registry. We do not call menu_rebuild directly, but set
// variable that indicates rebuild in the end.
// @see http://drupal.org/node/1399618
variable_set('menu_rebuild_needed', TRUE);
}
}
/**
* UI controller for CKEditor Comment Type.
*/
class CKEditorCommentTypeUIController extends EntityDefaultUIController {
/**
* Overrides hook_menu() defaults.
*/
public function hook_menu() {
$items = parent::hook_menu();
$items[$this->path]['description'] = 'Manage CKEditorComment types.';
return $items;
}
}
/**
* CKEditorComment class.
*/
class CKEditorComment extends Entity {
protected function defaultLabel() {
return truncate_utf8(strip_tags($this->ckeditor_comment_body[LANGUAGE_NONE][0]['value']), 50, TRUE, TRUE);
}
protected function defaultUri() {
return array('path' => 'ckeditor_comment/' . $this->identifier());
}
}
/**
* CKEditor Comment Type class.
*/
class CKEditorCommentType extends Entity {
public $type;
public $label;
public $weight = 0;
public function __construct($values = array()) {
parent::__construct($values, 'ckeditor_comment_type');
}
function isLocked() {
return isset($this->status) && empty($this->is_new) && (($this->status & ENTITY_IN_CODE) || ($this->status & ENTITY_FIXED));
}
}