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:  * An class which holds properties for Remote Video objects.
 16:  */
 17: class ClipitRemoteVideo extends UBItem {
 18:     const SUBTYPE = "ClipitRemoteVideo";
 19:     public $remote_id;
 20:     public $remote_site = 0;
 21:     public $tag_array = array();
 22:     /**
 23:      * Loads object parameters stored in Elgg
 24:      *
 25:      * @param ElggEntity $elgg_entity Elgg Object to load parameters from.
 26:      */
 27:     protected function copy_from_elgg($elgg_entity) {
 28:         parent::copy_from_elgg($elgg_entity);
 29:         $this->remote_id = (int)$elgg_entity->get("remote_id");
 30:         $this->remote_site = (int)$elgg_entity->get("remote_site");
 31:         $this->tag_array = (array)$elgg_entity->get("tag_array");
 32:     }
 33:     /**
 34:      * Copy $this object parameters into an Elgg entity.
 35:      *
 36:      * @param ElggEntity $elgg_entity Elgg object instance to save $this to
 37:      */
 38:     protected function copy_to_elgg($elgg_entity) {
 39:         parent::copy_to_elgg($elgg_entity);
 40:         $elgg_entity->set("remote_id", (int)$this->remote_id);
 41:         $elgg_entity->set("remote_site", (int)$this->remote_site);
 42:         $elgg_entity->set("tag_array", (array)$this->tag_array);
 43:     }
 44:     static function create($prop_value_array){
 45:         // convert "remote_site" from string to local ID
 46:         $remote_site_url = base64_decode($prop_value_array["remote_site"]);
 47:         $remote_site_id = ClipitRemoteSite::get_from_url($remote_site_url, true);
 48:         $prop_value_array["remote_site"] = $remote_site_id;
 49:         // Base64 decode some properties which can contain special characters
 50:         $prop_value_array["name"] = base64_decode($prop_value_array["name"]);
 51:         $prop_value_array["description"] = base64_decode($prop_value_array["description"]);
 52:         $prop_value_array["url"] = base64_decode($prop_value_array["url"]);
 53:         // convert tag_array from array of names to array of local IDs
 54:         $tag_name_array = json_decode(base64_decode($prop_value_array["tag_array"]));
 55:         $tag_array = array();
 56:         foreach($tag_name_array as $tag_name){
 57:             $tag_array[] = (int)ClipitTag::create(array("name" => $tag_name));
 58:         }
 59:         $prop_value_array["tag_array"] = (array)$tag_array;
 60:         $id = parent::create($prop_value_array);
 61:         ClipitRemoteSite::add_videos($remote_site_id, array($id));
 62:         return $id;
 63:     }
 64:     static function get_by_tags($tag_array){
 65:         $video_array = static::get_all();
 66:         $return_array = array();
 67:         foreach($video_array as $video){
 68:             $intersection = array_intersect($video->tag_array, $tag_array);
 69:             if(!empty($intersection)){
 70:                 $return_array[] = $video;
 71:             }
 72:         }
 73:         return $return_array;
 74:     }
 75:     // FOR REST API CALLS (remote_site comes as an URL)
 76:     static function get_by_remote_id($remote_site, $remote_id_array){
 77:         $remote_site_id = ClipitRemoteSite::get_from_url(base64_decode($remote_site), true);
 78:         $remote_videos = ClipitRemoteVideo::get_all();
 79:         $remote_video_array = array();
 80:         foreach($remote_videos as $remote_video){
 81:             if($remote_video->remote_site == $remote_site_id && array_search($remote_video->remote_id,  $remote_id_array) !== false){
 82:                 $remote_video_array[] = $remote_video;
 83:             }
 84:         }
 85:         return $remote_video_array;
 86:     }
 87:     static function delete_by_remote_id($remote_site, $remote_id_array){
 88:         $remote_site_id = ClipitRemoteSite::get_from_url(base64_decode($remote_site), true);
 89:         $remote_video_array = static::get_by_remote_id($remote_site_id, $remote_id_array);
 90:         $remote_video_id_array = array();
 91:         foreach($remote_video_array as $video){
 92:             $remote_video_id_array[] = $video->id;
 93:         }
 94:         static::delete_by_id($remote_video_id_array);
 95:         return true;
 96:     }
 97:     static function get_from_site($remote_site, $remote_ids_only = false){
 98:         $remote_site_id = ClipitRemoteSite::get_from_url(base64_decode($remote_site), true);
 99:         $video_array = static::get_all();
100:         $return_array = array();
101:         foreach($video_array as $video){
102:             if((int)$video->remote_site == $remote_site_id) {
103:                 if($remote_ids_only) {
104:                     $return_array[] = $video->remote_id;
105:                 } else{
106:                     $return_array[] = $video;
107:                 }
108:             }
109:         }
110:         return $return_array;
111:     }
112:     static function delete_from_site($remote_site){
113:         $remote_site_id = ClipitRemoteSite::get_from_url(base64_decode($remote_site), true);
114:         $video_array = static::get_all();
115:         $delete_array = array();
116:         foreach($video_array as $video){
117:             if((int)$video->remote_site == $remote_site_id){
118:                 $delete_array[] = $video->id;
119:             }
120:         }
121:         return static::delete_by_id($delete_array);
122:     }
123: }
API documentation generated by ApiGen 2.8.0