1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: 16: 17:
18: class ClipitTrickyTopic extends UBItem {
19: 20: 21:
22: const SUBTYPE = "ClipitTrickyTopic";
23: const REL_TRICKYTOPIC_TAG = "ClipitTrickyTopic-ClipitTag";
24: const REL_TRICKYTOPIC_FILE = "ClipitTrickyTopic-ClipitFile";
25: const REL_TRICKYTOPIC_STORYBOARD = "ClipitTrickyTopic-ClipitStoryboard";
26: const REL_TRICKYTOPIC_VIDEO = "ClipitTrickyTopic-ClipitVideo";
27: const REL_TRICKYTOPIC_EXAMPLE = "ClipitTrickyTopic-ClipitExample";
28: const EDUCATION_LEVEL_PRIMARY = "primary";
29: const EDUCATION_LEVEL_GCSE = "gcse";
30: const EDUCATION_LEVEL_ALEVEL = "alevel";
31: const EDUCATION_LEVEL_VOCATIONAL = "vocational";
32: const EDUCATION_LEVEL_UNIVERSITY = "university";
33: public $tag_array = array();
34: public $subject = "";
35: public $education_level = "";
36:
37: public $storyboard_array = array();
38: public $video_array = array();
39: public $file_array = array();
40:
41: public $example_array = array();
42:
43:
44: public $ontologylink = "";
45:
46:
47: 48: 49: 50: 51:
52: protected function copy_from_elgg($elgg_entity) {
53: parent::copy_from_elgg($elgg_entity);
54: $this->subject = (string)$elgg_entity->get("subject");
55: $this->education_level = (string)$elgg_entity->get("education_level");
56: $this->tag_array = (array)static::get_tags((int)$this->id);
57: $this->file_array = (array)static::get_files((int)$this->id);
58: $this->storyboard_array = (array)static::get_storyboards((int)$this->id);
59: $this->video_array = (array)static::get_videos((int)$this->id);
60: $this->example_array = (array)static::get_examples((int)$this->id);
61:
62: $this->ontologylink = (string)$elgg_entity->get("ontologylink");
63: }
64:
65: 66: 67: 68: 69:
70: protected function copy_to_elgg($elgg_entity) {
71: parent::copy_to_elgg($elgg_entity);
72: $elgg_entity->set("subject", (string)$this->subject);
73: $elgg_entity->set("education_level", (string)$this->education_level);
74:
75:
76: if (!empty($this->ontologylink)) {
77: $elgg_entity->set("ontologylink", (string)$this->ontologylink);
78: } else {
79: $elgg_entity->set("ontologylink", "");
80: }
81: }
82:
83: 84: 85: 86: 87:
88: public function save($double_save=false) {
89: parent::save($double_save);
90: static::set_tags((int)$this->id, (array)$this->tag_array);
91: static::set_files((int)$this->id, (array)$this->file_array);
92: static::set_storyboards((int)$this->id, (array)$this->storyboard_array);
93: static::set_videos((int)$this->id, (array)$this->video_array);
94: static::set_examples((int)$this->id, (array)$this->example_array);
95: return (int)$this->id;
96: }
97:
98: 99: 100: 101: 102: 103: 104: 105: 106:
107: static function create_clone($id, $linked = true, $keep_owner = false) {
108: $prop_value_array = static::get_properties($id);
109: if($keep_owner === false){
110: $prop_value_array["owner_id"] = elgg_get_logged_in_user_guid();
111: }
112: $example_array = $prop_value_array["example_array"];
113: if(!empty($example_array)){
114: $new_example_array = array();
115: foreach($example_array as $example_id){
116: $new_example_array[] = ClipitExample::create_clone($example_id);
117: }
118: $prop_value_array["example_array"] = $new_example_array;
119: }
120: $clone_id = static::create($prop_value_array);
121: if($linked) {
122: static::link_parent_clone($id, $clone_id);
123: }
124: return $clone_id;
125: }
126:
127: 128: 129: 130: 131: 132: 133: 134:
135: static function add_tags($id, $tag_array) {
136: return UBCollection::add_items($id, $tag_array, static::REL_TRICKYTOPIC_TAG);
137: }
138:
139: 140: 141: 142: 143: 144: 145: 146:
147: static function set_tags($id, $tag_array) {
148: return UBCollection::set_items($id, $tag_array, static::REL_TRICKYTOPIC_TAG);
149: }
150:
151: 152: 153: 154: 155: 156: 157: 158:
159: static function remove_tags($id, $tag_array) {
160: return UBCollection::remove_items($id, $tag_array, static::REL_TRICKYTOPIC_TAG);
161: }
162:
163: 164: 165: 166: 167: 168: 169:
170: static function get_tags($id) {
171: return UBCollection::get_items($id, static::REL_TRICKYTOPIC_TAG);
172: }
173:
174:
175: static function add_storyboards($id, $storyboard_array) {
176: return UBCollection::add_items($id, $storyboard_array, static::REL_TRICKYTOPIC_STORYBOARD);
177: }
178:
179: static function set_storyboards($id, $storyboard_array) {
180: return UBCollection::set_items($id, $storyboard_array, static::REL_TRICKYTOPIC_STORYBOARD);
181: }
182:
183: static function remove_storyboards($id, $storyboard_array) {
184: return UBCollection::remove_items($id, $storyboard_array, static::REL_TRICKYTOPIC_STORYBOARD);
185: }
186:
187: static function get_storyboards($id) {
188: return UBCollection::get_items($id, static::REL_TRICKYTOPIC_STORYBOARD);
189: }
190:
191:
192: static function add_videos($id, $video_array) {
193: return UBCollection::add_items($id, $video_array, static::REL_TRICKYTOPIC_VIDEO);
194: }
195:
196: static function set_videos($id, $video_array) {
197: return UBCollection::set_items($id, $video_array, static::REL_TRICKYTOPIC_VIDEO);
198: }
199:
200: static function remove_videos($id, $video_array) {
201: return UBCollection::remove_items($id, $video_array, static::REL_TRICKYTOPIC_VIDEO);
202: }
203:
204: static function get_videos($id) {
205: return UBCollection::get_items($id, static::REL_TRICKYTOPIC_VIDEO);
206: }
207:
208:
209: static function add_files($id, $file_array) {
210: return UBCollection::add_items($id, $file_array, static::REL_TRICKYTOPIC_FILE);
211: }
212:
213: static function set_files($id, $file_array) {
214: return UBCollection::set_items($id, $file_array, static::REL_TRICKYTOPIC_FILE);
215: }
216:
217: static function remove_files($id, $file_array) {
218: return UBCollection::remove_items($id, $file_array, static::REL_TRICKYTOPIC_FILE);
219: }
220:
221: static function get_files($id) {
222: return UBCollection::get_items($id, static::REL_TRICKYTOPIC_FILE);
223: }
224:
225:
226: static function add_examples($id, $example_array) {
227: return UBCollection::add_items($id, $example_array, static::REL_TRICKYTOPIC_EXAMPLE, true);
228: }
229:
230: static function set_examples($id, $example_array) {
231: return UBCollection::set_items($id, $example_array, static::REL_TRICKYTOPIC_EXAMPLE, true);
232: }
233:
234: static function remove_examples($id, $example_array) {
235: return UBCollection::remove_items($id, $example_array, static::REL_TRICKYTOPIC_EXAMPLE);
236: }
237:
238: static function get_examples($id) {
239: return UBCollection::get_items($id, static::REL_TRICKYTOPIC_EXAMPLE);
240: }
241: }