Overview

Packages

  • ClipIt
    • clipit
      • api
    • urjc
      • backend
  • Elgg
    • Core
      • Access
      • Authentication
      • Cache
      • Caches
      • Core
      • DataMode
        • Site
      • DataModel
        • Annotations
        • Entities
        • Extender
        • File
        • Importable
        • Loggable
        • Notable
        • Object
        • User
      • DataStorage
      • Exception
      • Exceptions
        • Stub
      • FileStore
        • Disk
      • Groups
      • Helpers
      • HMAC
      • Memcache
      • Metadata
      • Navigation
      • ODD
      • Output
      • Plugins
        • Settings
      • Sessions
      • SocialModel
        • Friendable
        • Locatable
      • WebServicesAPI
      • Widgets
      • XML
      • XMLRPC
    • Exceptions
      • Stub
  • None
  • PHP

Classes

  • ClipitActivity
  • ClipitChat
  • ClipitComment
  • ClipitEvent
  • ClipitExample
  • ClipitFile
  • ClipitGroup
  • ClipitLA
  • ClipitLabel
  • ClipitPerformanceItem
  • ClipitPerformanceRating
  • ClipitPost
  • ClipitQuiz
  • ClipitQuizQuestion
  • ClipitQuizResult
  • ClipitRating
  • ClipitRemoteTrickyTopic
  • ClipitRemoteVideo
  • ClipitResource
  • ClipitSite
  • ClipitStoryboard
  • ClipitTag
  • ClipitTagRating
  • ClipitTask
  • ClipitTrickyTopic
  • ClipitUser
  • ClipitVideo
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * ClipIt - JuxtaLearn Web Space
  4:  * PHP version:     >= 5.2
  5:  * Creation date:   2013-10-10
  6:  * Last update:     $Date$
  7:  * @author          Pablo LlinĂ¡s Arnaiz <pebs74@gmail.com>, URJC JuxtaLearn Team
  8:  * @version         $Version$
  9:  * @link            http://www.juxtalearn.eu
 10:  * @license         GNU Affero General Public License v3
 11:  * @package         ClipIt
 12:  * @subpackage      clipit_api
 13:  */
 14: 
 15: /**
 16:  * An Example experience in which students have trouble understanding a Stumbling Block (or Tag).
 17:  */
 18: class ClipitExample extends UBItem {
 19:     /**
 20:      * @const string Elgg entity SUBTYPE for this class
 21:      */
 22:     const SUBTYPE = "ClipitExample";
 23:     const REL_EXAMPLE_TAG = "ClipitExample-ClipitTag";
 24:     const REL_EXAMPLE_EXAMPLETYPE = "ClipitExample-ClipitExampleType";
 25:     const REL_EXAMPLE_STORYBOARD = "ClipitExample-ClipitStoryboard";
 26:     const REL_EXAMPLE_VIDEO = "ClipitExample-ClipitVideo";
 27:     const REL_EXAMPLE_FILE = "ClipitExample-ClipitFile";
 28:     public $tricky_topic = 0;
 29:     public $tag_array = array();
 30:     public $example_type_array = array();
 31:     public $country = "";
 32:     public $location = "";
 33:     // Example Resources
 34:     public $storyboard_array = array();
 35:     public $video_array = array();
 36:     public $file_array = array();
 37: 
 38:     /**
 39:      * Loads object parameters stored in Elgg
 40:      *
 41:      * @param ElggEntity $elgg_entity Elgg Object to load parameters from.
 42:      */
 43:     protected function copy_from_elgg($elgg_entity) {
 44:         parent::copy_from_elgg($elgg_entity);
 45:         $this->tricky_topic = (int)static::get_tricky_topic($this->id);
 46:         $this->tag_array = (array)static::get_tags($this->id);
 47:         $this->example_type_array = (array)static::get_example_types($this->id);
 48:         $this->country = (string)$elgg_entity->get("country");
 49:         $this->location = (string)$elgg_entity->get("location");
 50:         $this->video_array = static::get_videos($this->id);
 51:         $this->storyboard_array = static::get_storyboards($this->id);
 52:         $this->file_array = static::get_files($this->id);
 53:     }
 54: 
 55:     /**
 56:      * Copy $this object's parameters into an Elgg entity.
 57:      *
 58:      * @param ElggEntity $elgg_entity Elgg object instance to save $this to
 59:      */
 60:     protected function copy_to_elgg($elgg_entity) {
 61:         parent::copy_to_elgg($elgg_entity);
 62:         $elgg_entity->set("country", (string)$this->country);
 63:         $elgg_entity->set("location", (string)$this->location);
 64:     }
 65: 
 66:     protected function save($double_save=false) {
 67:         parent::save($double_save);
 68:         static::set_tricky_topic($this->id, (int)$this->tricky_topic);
 69:         static::set_tags($this->id, (array)$this->tag_array);
 70:         static::set_example_types($this->id, (array)$this->example_type_array);
 71:         static::set_videos($this->id, $this->video_array);
 72:         static::set_storyboards($this->id, $this->storyboard_array);
 73:         static::set_files($this->id, $this->file_array);
 74:         return $this->id;
 75:     }
 76: 
 77:     static function get_by_tags($tag_array){
 78:         $return_examples = array();
 79:         $example_array = static::get_all(0);
 80:         if(empty($example_array) || empty($tag_array)){
 81:             return $return_examples;
 82:         }
 83:         foreach($example_array as $example){
 84:             foreach($example->tag_array as $tag){
 85:                 if(array_search($tag, $tag_array) !== false){
 86:                     $return_examples[] = $example;
 87:                     break;
 88:                 }
 89:             }
 90:         }
 91:         return $return_examples;
 92:     }
 93: 
 94:     static function get_tricky_topic($id) {
 95:         $ret_array = UBCollection::get_items($id, ClipitTrickyTopic::REL_TRICKYTOPIC_EXAMPLE, true);
 96:         if(!empty($ret_array)){
 97:             return array_pop($ret_array);
 98:         }
 99:         return 0;
100:     }
101: 
102:     static function set_tricky_topic($id, $tricky_topic_id) {
103:         return ClipitTrickyTopic::add_examples($tricky_topic_id, array($id));
104:     }
105: 
106:     static function get_from_tricky_topic($tricky_topic_id) {
107:         return ClipitExample::get_by_id(ClipitTrickyTopic::get_examples($tricky_topic_id));
108:     }
109: 
110:     /**
111:      * Adds Tags to an Example, referenced by Id.
112:      *
113:      * @param int   $id        Id from the Example to add Tags to
114:      * @param array $tag_array Array of Tag Ids to be added to the Example
115:      *
116:      * @return bool Returns true if success, false if error
117:      */
118:     static function add_tags($id, $tag_array) {
119:         return UBCollection::add_items($id, $tag_array, static::REL_EXAMPLE_TAG);
120:     }
121: 
122:     /**
123:      * Sets Tags to an Example, referenced by Id.
124:      *
125:      * @param int   $id        Id from the Example to set Tags to
126:      * @param array $tag_array Array of Tag Ids to be set to the Example
127:      *
128:      * @return bool Returns true if success, false if error
129:      */
130:     static function set_tags($id, $tag_array) {
131:         return UBCollection::set_items($id, $tag_array, static::REL_EXAMPLE_TAG);
132:     }
133: 
134:     /**
135:      * Remove Tags from an Example.
136:      *
137:      * @param int   $id        Id from Example to remove Tags from
138:      * @param array $tag_array Array of Tag Ids to remove from Example
139:      *
140:      * @return bool Returns true if success, false if error
141:      */
142:     static function remove_tags($id, $tag_array) {
143:         return UBCollection::remove_items($id, $tag_array, static::REL_EXAMPLE_TAG);
144:     }
145: 
146:     /**
147:      * Get all Tags from an Example
148:      *
149:      * @param int $id Id of the Example to get Tags from
150:      *
151:      * @return array|bool Returns an array of Tag IDs, or false if error
152:      */
153:     static function get_tags($id) {
154:         return UBCollection::get_items($id, static::REL_EXAMPLE_TAG);
155:     }
156: 
157:     /**
158:      * Adds Example Types to an Example, referenced by Id.
159:      *
160:      * @param int   $id                     Id from the Example to add Example Types to
161:      * @param array $example_type_array     Array of Example Type Ids to be added to the Example
162:      *
163:      * @return bool Returns true if success, false if error
164:      */
165:     static function add_example_types($id, $example_type_array) {
166:         return UBCollection::add_items($id, $example_type_array, static::REL_EXAMPLE_EXAMPLETYPE);
167:     }
168: 
169:     /**
170:      * Sets Example Types to an Example, referenced by Id.
171:      *
172:      * @param int   $id                     Id from the Example to set Example Types to
173:      * @param array $example_type_array     Array of Example Type Ids to be set to the Example
174:      *
175:      * @return bool Returns true if success, false if error
176:      */
177:     static function set_example_types($id, $example_type_array) {
178:         return UBCollection::set_items($id, $example_type_array, static::REL_EXAMPLE_EXAMPLETYPE);
179:     }
180: 
181:     /**
182:      * Remove Example Types from an Example.
183:      *
184:      * @param int   $id                         Id from Example to remove Example Types from
185:      * @param array $example_type_array      Array of Example Type Ids to remove from Example
186:      *
187:      * @return bool Returns true if success, false if error
188:      */
189:     static function remove_example_types($id, $example_type_array) {
190:         return UBCollection::remove_items($id, $example_type_array, static::REL_EXAMPLE_EXAMPLETYPE);
191:     }
192: 
193:     /**
194:      * Get all Example Types from an Example
195:      *
196:      * @param int $id Id of the Example to get Example Types from
197:      *
198:      * @return array|bool Returns an array of Example Type IDs, or false if error
199:      */
200:     static function get_example_types($id) {
201:         return UBCollection::get_items($id, static::REL_EXAMPLE_EXAMPLETYPE);
202:     }
203: 
204:     // Videos methods
205:     static function add_videos($id, $video_array) {
206:         return UBCollection::add_items($id, $video_array, static::REL_EXAMPLE_VIDEO);
207:     }
208: 
209:     static function set_videos($id, $video_array) {
210:         return UBCollection::set_items($id, $video_array, static::REL_EXAMPLE_VIDEO);
211:     }
212: 
213:     static function remove_videos($id, $video_array) {
214:         return UBCollection::remove_items($id, $video_array, static::REL_EXAMPLE_VIDEO);
215:     }
216:     
217:     static function get_videos($id) {
218:         return UBCollection::get_items($id, static::REL_EXAMPLE_VIDEO);
219:     }
220: 
221:     // Storyboards methods
222:     static function add_storyboards($id, $storyboard_array) {
223:         return UBCollection::add_items($id, $storyboard_array, static::REL_EXAMPLE_STORYBOARD);
224:     }
225: 
226:     static function set_storyboards($id, $storyboard_array) {
227:         return UBCollection::set_items($id, $storyboard_array, static::REL_EXAMPLE_STORYBOARD);
228:     }
229: 
230:     static function remove_storyboards($id, $storyboard_array) {
231:         return UBCollection::remove_items($id, $storyboard_array, static::REL_EXAMPLE_STORYBOARD);
232:     }
233: 
234:     static function get_storyboards($id) {
235:         return UBCollection::get_items($id, static::REL_EXAMPLE_STORYBOARD);
236:     }
237: 
238:     // Files methods
239:     static function add_files($id, $file_array) {
240:         return UBCollection::add_items($id, $file_array, static::REL_EXAMPLE_FILE);
241:     }
242: 
243:     static function set_files($id, $file_array) {
244:         return UBCollection::set_items($id, $file_array, static::REL_EXAMPLE_FILE);
245:     }
246: 
247:     static function remove_files($id, $file_array) {
248:         return UBCollection::remove_items($id, $file_array, static::REL_EXAMPLE_FILE);
249:     }
250:     
251:     static function get_files($id) {
252:         return UBCollection::get_items($id, static::REL_EXAMPLE_FILE);
253:     }
254: }
API documentation generated by ApiGen 2.8.0