| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  *@author nicolaas[at]sunnysideup.co.nz | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  **/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | class VimeoDataObject extends DataObject | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     private static $db = array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |         "Title" => "Varchar(100)", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |         "VimeoCode" => "Int", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |         "HTMLSnippet" => "HTMLText", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |         "Data" => "Text" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     private static $casting = array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         "FullName" => "Text", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         "Icon" => "HTMLText", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         "IconLink" => "Varchar", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         "FullImage" => "HTMLText", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         "FullImageLink" => "Varchar" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     private static $searchable_fields = array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         "Title" => "PartialMatchFilter", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         "VimeoCode" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     private static $summary_fields = array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         "Icon" => "Icon", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         "Title" => "Title", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     private static $singular_name = "Vimeo Video"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     private static $plural_name = "Vimeo Videos"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     private static $default_sort = "Title ASC"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     private static $vimeo_base_url = "http://vimeo.com/api/oembed.xml?url=http%3A//vimeo.com/";//The exact width of the video. Defaults to original size. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     private static $width = null;//The exact width of the video. Defaults to original size. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     private static $maxwidth = null;////Same as width, but video will not exceed original size. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     private static $height = null;//The exact height of the video. Defaults to original size. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     private static $maxheight = null;//Same as height, but video will not exceed original size. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     private static $byline = null;//Show the byline on the video. Defaults to true. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     private static $title = null;//Show the title on the video. Defaults to true. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     private static $portrait = null;//// Show the user's portrait on the video. Defaults to true. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     private static $color = null;// Specify the color of the video controls. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     private static $callback = null;//When returning JSON, wrap in this function. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     private static $autoplay = null;//Automatically start playback of the video. Defaults to false. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     private static $xhtml = null;// Make the embed code XHTML compliant. Defaults to true. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     private static $api = null;// Enable the Javascript API for Moogaloop. Defaults to false. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     private static $wmode = null;//add the "wmode" parameter. Can be either transparent or opaque. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     private static $iframe;// Use our new embed code. Defaults to true. NEW! | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     protected $dataAsArray = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     protected $variables = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         "type", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         "version", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         "provider_name", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         "provider_url", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         "title", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         "author_name", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         "author_url", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         "is_plus", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         "html", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         "width", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         "height", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         "duration", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         "description", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         "thumbnail_url", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         "thumbnail_width", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         "thumbnail_height", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         "video_id" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * do not retrieve data from vimeo server ... | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * for internal use only | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * @var Boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     private $doNotRetrieveData = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     public function getCMSFields() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $fields = parent::getCMSFields(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $fields->removeByName("HTMLSnippet"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $fields->removeByName("Data"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         $fields->addFieldToTab("Root.Main", new LiteralField("HTMLSnippet", $this->HTML($noCaching = false))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         $this->getDataAsArray(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         if (is_array($this->dataAsArray) && count($this->dataAsArray)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             foreach ($this->dataAsArray as $name => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |                 $fields->addFieldToTab("Root.Details", new ReadOnlyField($name, $name, $value)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         return $fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |      * casted variable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     public function getFullName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         return $this->Title." (".$this->VimeoCode.")"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |      * alias for getVariable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |      * @param String $name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |      * @return Varchar | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     public function MetaDataVariable($name) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         return $this->getMetaDataVariable($name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      * @param String - name of variable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |      * @return Varchar Object | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 141 |  | View Code Duplication |     public function getMetaDataVariable($name) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         $this->getDataAsArray(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         if (!empty($this->dataAsArray[$name])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |             return DBField::create_field("Varchar", $this->dataAsArray[$name]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |      * return icon as <img tag> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |      * @return String | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     public function getIcon() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 156 |  | View Code Duplication |         if (!count($this->dataAsArray)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |             //remove non-ascii characters as they were causing havoc... | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |             $this->Data = preg_replace('/[^(\x20-\x7F)]*/', '', $this->Data); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |             $this->dataAsArray = $this->safelyUnserialize($this->Data); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |         if (!empty($this->dataAsArray["thumbnail_url"])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |             $v = "<img src=\"".$this->dataAsArray["thumbnail_url"]."\" width=\"".$this->dataAsArray["thumbnail_width"]."\" height=\"".$this->dataAsArray["thumbnail_height"]."\" alt=\"".Convert::raw2att($this->Title)."\"/>"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |             $v = "[".$this->Title."]"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         return DBField::create_field("HTMLText", $v); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * returns icon as myimage.png | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * @return String | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 173 |  | View Code Duplication |     public function getIconLink() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |         $this->getDataAsArray(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         if (!empty($this->dataAsArray["thumbnail_url"])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |             return DBField::create_field("Varchar", $this->dataAsArray["thumbnail_url"]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |      * return icon as <img tag> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |      * @return String | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |     public function getFullImage() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 188 |  | View Code Duplication |         if (!count($this->dataAsArray)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |             //remove non-ascii characters as they were causing havoc... | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |             $this->Data = preg_replace('/[^(\x20-\x7F)]*/', '', $this->Data); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |             $this->dataAsArray = $this->safelyUnserialize($this->Data); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         if (!empty($this->dataAsArray["thumbnail_url"])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |             $imageLink = str_replace("_295x166", "", $this->dataAsArray["thumbnail_url"]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             $v = "<img src=\"".$imageLink."\" alt=\"".Convert::raw2att($this->Title)."\"/>"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             $v = "[".$this->Title."]"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |         return DBField::create_field("HTMLText", $v); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |      * returns icon as myimage.png | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |      * @return String | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |     public function getFullImageLink() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |         $this->getDataAsArray(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         if (!empty($this->dataAsArray["thumbnail_url"])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |             $imageLink = str_replace("_295x166", "", $this->dataAsArray["thumbnail_url"]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |             return DBField::create_field("Varchar", $imageLink); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |      * returns the HTML Embed code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |      * @return String | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |     public function HTML($noCaching = false) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         if ($noCaching || strlen($this->HTMLSnippet) < 17 || !$this->Data || isset($_GET["flush"])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |             $this->updateData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         return $this->HTMLSnippet; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |      * turns the saved serialized data into an array to return | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |      * if there is no data then it will try to retrieve and save it | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |      * then return it. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |      * @return Array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     protected function getDataAsArray() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |         if ($this->dataAsArray) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |             return $this->dataAsArray; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |         if (!$this->Data) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |             $this->updateData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |         $this->dataAsArray = $this->safelyUnserialize($this->Data); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |         return $this->dataAsArray; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |      * retrieves data from Vimeo Site | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |      * @return Array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |     protected function updateData($writeToDatabase = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |         if ($this->doNotRetrieveData) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |             //do nothing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |         } elseif ($this->VimeoCode) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |             $get = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |             if ($width = $this->Config()->get("width")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |                 $get["width"] = $width; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |             if ($max_width = $this->Config()->get("maxwidth")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |                 $get["maxwidth"] = $max_width; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |             if ($height = $this->Config()->get("height")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |                 $get["height"] = $height; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |             if ($maxheight = $this->Config()->get("maxheight")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |                 $get["maxheight"] = $maxheight; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |             if ($byline = $this->Config()->get("byline")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |                 $get["byline"] = $byline; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |             if ($title = $this->Config()->get("title")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |                 $get["title"] = $title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |             if ($portrait = $this->Config()->get("portrait")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |                 $get["portrait"] = $portrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |             if ($color = $this->Config()->get("color")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |                 $get["color"] = $color; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |             if ($callback = $this->Config()->get("callback")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |                 $get["callback"] = $callback; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |             if ($autoplay = $this->Config()->get("autoplay ")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |                 $get["autoplay"] = $autoplay; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |             if ($xhtml = $this->Config()->get("xhtml")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |                 $get["xhtml"] = $xhtml; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |             if ($api = $this->Config()->get("api")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |                 $get["api"] = $api; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |             if ($wmode = $this->Config()->get("wmode")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |                 $get["wmode"] = $wmode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |             if ($iframe = $this->Config()->get("iframe")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |                 $get["iframe"] = $iframe; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |             $url = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |             $url .= $this->Config()->get("vimeo_base_url").$this->VimeoCode; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |             if (is_array($get) && count($get)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |                 foreach ($get as $key => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |                     $get[$key] = $key."=".urlencode($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |                 $url .= "?".implode("&", $get); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |             $ch = curl_init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |             curl_setopt($ch, CURLOPT_URL, $url); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |             curl_setopt($ch, CURLOPT_HEADER, 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |             $data = curl_exec($ch); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |             $array = $this->my_xml2array($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |             foreach ($this->variables as $variable) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |                 $data_array = $this->get_value_by_path($array, 'oembed/'.$variable); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |                 if (isset($data_array["name"]) && isset($data_array["value"])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |                     $this->dataAsArray[$data_array["name"]] = $data_array["value"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |                     $this->dataAsArray[$variable] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |             $this->Data = $this->safelySerialize($this->dataAsArray); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |             $this->HTMLSnippet = $this->dataAsArray["html"]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |             if ($writeToDatabase) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |                 $this->write(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |         return $this->Data; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |     public function onBeforeWrite() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |         parent::onBeforeWrite(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |         $this->VimeoCode = intval($this->VimeoCode); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |         $this->updateData(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 340 |  |  |     //SOURCE: http://php.net/manual/en/function.xml-parse.php | 
            
                                                                        
                            
            
                                    
            
            
                | 341 |  |  |     private function my_xml2array($contents) | 
            
                                                                        
                            
            
                                    
            
            
                | 342 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 343 |  |  |         $parser = xml_parser_create(''); | 
            
                                                                        
                            
            
                                    
            
            
                | 344 |  |  |         if (!$parser) { | 
            
                                                                        
                            
            
                                    
            
            
                | 345 |  |  |             return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 346 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 347 |  |  |         xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); | 
            
                                                                        
                            
            
                                    
            
            
                | 348 |  |  |         xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); | 
            
                                                                        
                            
            
                                    
            
            
                | 349 |  |  |         xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); | 
            
                                                                        
                            
            
                                    
            
            
                | 350 |  |  |         xml_parse_into_struct($parser, trim($contents), $xml_values); | 
            
                                                                        
                            
            
                                    
            
            
                | 351 |  |  |         xml_parser_free($parser); | 
            
                                                                        
                            
            
                                    
            
            
                | 352 |  |  |         if (!$xml_values) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 353 |  |  |             return array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 354 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 355 |  |  |         $xml_array = array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 356 |  |  |         $last_tag_ar =& $xml_array; | 
            
                                                                        
                            
            
                                    
            
            
                | 357 |  |  |         $parents = array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 358 |  |  |         $last_counter_in_tag = array(1=>0); | 
            
                                                                        
                            
            
                                    
            
            
                | 359 |  |  |         foreach ($xml_values as $data) { | 
            
                                                                        
                            
            
                                    
            
            
                | 360 |  |  |             switch ($data['type']) { | 
            
                                                                        
                            
            
                                    
            
            
                | 361 |  |  |                 case 'open': | 
            
                                                                        
                            
            
                                    
            
            
                | 362 |  |  |                     $last_counter_in_tag[$data['level']+1] = 0; | 
            
                                                                        
                            
            
                                    
            
            
                | 363 |  |  |                     $new_tag = array('name' => $data['tag']); | 
            
                                                                        
                            
            
                                    
            
            
                | 364 |  |  |                     if (isset($data['attributes'])) { | 
            
                                                                        
                            
            
                                    
            
            
                | 365 |  |  |                         $new_tag['attributes'] = $data['attributes']; | 
            
                                                                        
                            
            
                                    
            
            
                | 366 |  |  |                     } | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 367 |  | View Code Duplication |                     if (isset($data['value']) && trim($data['value'])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 368 |  |  |                         $new_tag['value'] = trim($data['value']); | 
            
                                                                        
                            
            
                                    
            
            
                | 369 |  |  |                     } | 
            
                                                                        
                            
            
                                    
            
            
                | 370 |  |  |                     $last_tag_ar[$last_counter_in_tag[$data['level']]] = $new_tag; | 
            
                                                                        
                            
            
                                    
            
            
                | 371 |  |  |                     $parents[$data['level']] =& $last_tag_ar; | 
            
                                                                        
                            
            
                                    
            
            
                | 372 |  |  |                     $last_tag_ar =& $last_tag_ar[$last_counter_in_tag[$data['level']]++]; | 
            
                                                                        
                            
            
                                    
            
            
                | 373 |  |  |                     break; | 
            
                                                                        
                            
            
                                    
            
            
                | 374 |  |  |                 case 'complete': | 
            
                                                                        
                            
            
                                    
            
            
                | 375 |  |  |                     $new_tag = array('name' => $data['tag']); | 
            
                                                                        
                            
            
                                    
            
            
                | 376 |  |  |                     if (isset($data['attributes'])) { | 
            
                                                                        
                            
            
                                    
            
            
                | 377 |  |  |                         $new_tag['attributes'] = $data['attributes']; | 
            
                                                                        
                            
            
                                    
            
            
                | 378 |  |  |                     } | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 379 |  | View Code Duplication |                     if (isset($data['value']) && trim($data['value'])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 380 |  |  |                         $new_tag['value'] = trim($data['value']); | 
            
                                                                        
                            
            
                                    
            
            
                | 381 |  |  |                     } | 
            
                                                                        
                            
            
                                    
            
            
                | 382 |  |  |                     $last_count = count($last_tag_ar)-1; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 383 |  |  |                     $last_tag_ar[$last_counter_in_tag[$data['level']]++] = $new_tag; | 
            
                                                                        
                            
            
                                    
            
            
                | 384 |  |  |                     break; | 
            
                                                                        
                            
            
                                    
            
            
                | 385 |  |  |                 case 'close': | 
            
                                                                        
                            
            
                                    
            
            
                | 386 |  |  |                     $last_tag_ar =& $parents[$data['level']]; | 
            
                                                                        
                            
            
                                    
            
            
                | 387 |  |  |                     break; | 
            
                                                                        
                            
            
                                    
            
            
                | 388 |  |  |                 default: | 
            
                                                                        
                            
            
                                    
            
            
                | 389 |  |  |                     break; | 
            
                                                                        
                            
            
                                    
            
            
                | 390 |  |  |             }; | 
            
                                                                        
                            
            
                                    
            
            
                | 391 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 392 |  |  |         return $xml_array; | 
            
                                                                        
                            
            
                                    
            
            
                | 393 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |     // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |     // use this to get node of tree by path with '/' terminator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |     // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |     //SOURCE: http://php.net/manual/en/function.xml-parse.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |     private function get_value_by_path($__xml_tree, $__tag_path) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |         $tmp_arr =& $__xml_tree; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |         $tag_path = explode('/', $__tag_path); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |         foreach ($tag_path as $tag_name) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |             $res = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |             foreach ($tmp_arr as $key => $node) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |                 if (is_int($key) && $node['name'] == $tag_name) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |                     $tmp_arr = $node; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |                     $res = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |                     break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |             if (!$res) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |                 return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |         return $tmp_arr; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |      * @param String $serializedData | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |      * @return Array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |     public function safelyUnserialize($serializedData) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |         return unserialize(base64_decode($serializedData)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |         //this code needs checking. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |         try { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |             $fixed = unserialize(base64_decode($serializedData)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |             if (is_array($fixed)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |                 return $fixed; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |                 return unserialize($serializedData); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |         } catch (Exception $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |             $fixed = preg_replace_callback( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |                 '!s:(\d+):"(.*?)";!', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |                 function ($match) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |                     return ($match[1] == strlen($match[2])) ? $match[0] : 's:' . strlen($match[2]) . ':"' . $match[2] . '";'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |                 }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |                 $serializedData | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |         return $fixed; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |      * @param Array $dataAsArray | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |      * @return String | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |     public function safelySerialize($dataAsArray) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |         return base64_encode(serialize($dataAsArray)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 459 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 460 |  |  |  | 
            
                        
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.