@@ -26,6 +26,6 @@ |
||
| 26 | 26 | protected function schedule(Schedule $schedule) |
| 27 | 27 | { |
| 28 | 28 | $schedule->command('inspire') |
| 29 | - ->hourly(); |
|
| 29 | + ->hourly(); |
|
| 30 | 30 | } |
| 31 | 31 | } |
@@ -207,7 +207,6 @@ |
||
| 207 | 207 | * |
| 208 | 208 | * @since 1.0.0 |
| 209 | 209 | * @param string $gallery_url URL of the Gallery |
| 210 | - * @param int $item_count number of photos to pull |
|
| 211 | 210 | */ |
| 212 | 211 | public function get_gallery_from_url($gallery_url){ |
| 213 | 212 | //gallery params |
@@ -12,254 +12,254 @@ |
||
| 12 | 12 | |
| 13 | 13 | class TP_flickr { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * API key |
|
| 17 | - * |
|
| 18 | - * @since 1.0.0 |
|
| 19 | - * @access private |
|
| 20 | - * @var string $api_key flickr API key |
|
| 21 | - */ |
|
| 22 | - private $api_key; |
|
| 15 | + /** |
|
| 16 | + * API key |
|
| 17 | + * |
|
| 18 | + * @since 1.0.0 |
|
| 19 | + * @access private |
|
| 20 | + * @var string $api_key flickr API key |
|
| 21 | + */ |
|
| 22 | + private $api_key; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * API params |
|
| 26 | - * |
|
| 27 | - * @since 1.0.0 |
|
| 28 | - * @access private |
|
| 29 | - * @var array $api_param_defaults Basic params to call with API |
|
| 30 | - */ |
|
| 31 | - private $api_param_defaults; |
|
| 24 | + /** |
|
| 25 | + * API params |
|
| 26 | + * |
|
| 27 | + * @since 1.0.0 |
|
| 28 | + * @access private |
|
| 29 | + * @var array $api_param_defaults Basic params to call with API |
|
| 30 | + */ |
|
| 31 | + private $api_param_defaults; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Basic URL |
|
| 35 | - * |
|
| 36 | - * @since 1.0.0 |
|
| 37 | - * @access private |
|
| 38 | - * @var string $url Url to fetch user from |
|
| 39 | - */ |
|
| 40 | - private $flickr_url; |
|
| 33 | + /** |
|
| 34 | + * Basic URL |
|
| 35 | + * |
|
| 36 | + * @since 1.0.0 |
|
| 37 | + * @access private |
|
| 38 | + * @var string $url Url to fetch user from |
|
| 39 | + */ |
|
| 40 | + private $flickr_url; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Initialize the class and set its properties. |
|
| 44 | - * |
|
| 45 | - * @since 1.0.0 |
|
| 46 | - * @param string $api_key flickr API key. |
|
| 47 | - */ |
|
| 48 | - public function __construct($api_key) { |
|
| 49 | - $this->api_key = $api_key; |
|
| 50 | - $this->api_param_defaults = array( |
|
| 51 | - 'api_key' => $this->api_key, |
|
| 52 | - 'format' => 'json', |
|
| 53 | - 'nojsoncallback' => 1, |
|
| 54 | - ); |
|
| 55 | - } |
|
| 42 | + /** |
|
| 43 | + * Initialize the class and set its properties. |
|
| 44 | + * |
|
| 45 | + * @since 1.0.0 |
|
| 46 | + * @param string $api_key flickr API key. |
|
| 47 | + */ |
|
| 48 | + public function __construct($api_key) { |
|
| 49 | + $this->api_key = $api_key; |
|
| 50 | + $this->api_param_defaults = array( |
|
| 51 | + 'api_key' => $this->api_key, |
|
| 52 | + 'format' => 'json', |
|
| 53 | + 'nojsoncallback' => 1, |
|
| 54 | + ); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Calls Flicker API with set of params, returns json |
|
| 59 | - * |
|
| 60 | - * @since 1.0.0 |
|
| 61 | - * @param array $params Parameter build for API request |
|
| 62 | - */ |
|
| 63 | - private function call_flickr_api($params){ |
|
| 64 | - //build url |
|
| 65 | - $encoded_params = array(); |
|
| 66 | - foreach ($params as $k => $v){ |
|
| 67 | - $encoded_params[] = urlencode($k).'='.urlencode($v); |
|
| 68 | - } |
|
| 57 | + /** |
|
| 58 | + * Calls Flicker API with set of params, returns json |
|
| 59 | + * |
|
| 60 | + * @since 1.0.0 |
|
| 61 | + * @param array $params Parameter build for API request |
|
| 62 | + */ |
|
| 63 | + private function call_flickr_api($params){ |
|
| 64 | + //build url |
|
| 65 | + $encoded_params = array(); |
|
| 66 | + foreach ($params as $k => $v){ |
|
| 67 | + $encoded_params[] = urlencode($k).'='.urlencode($v); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - //call the API and decode the response |
|
| 71 | - $url = "https://api.flickr.com/services/rest/?".implode('&', $encoded_params); |
|
| 72 | - $rsp = json_decode(file_get_contents($url)); |
|
| 73 | - return $rsp; |
|
| 74 | - } |
|
| 70 | + //call the API and decode the response |
|
| 71 | + $url = "https://api.flickr.com/services/rest/?".implode('&', $encoded_params); |
|
| 72 | + $rsp = json_decode(file_get_contents($url)); |
|
| 73 | + return $rsp; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Get User ID from its URL |
|
| 78 | - * |
|
| 79 | - * @since 1.0.0 |
|
| 80 | - * @param string $user_url URL of the Gallery |
|
| 81 | - */ |
|
| 82 | - public function get_user_from_url($user_url){ |
|
| 83 | - //gallery params |
|
| 84 | - $user_params = $this->api_param_defaults + array( |
|
| 85 | - 'method' => 'flickr.urls.lookupUser', |
|
| 86 | - 'url' => $user_url, |
|
| 87 | - ); |
|
| 76 | + /** |
|
| 77 | + * Get User ID from its URL |
|
| 78 | + * |
|
| 79 | + * @since 1.0.0 |
|
| 80 | + * @param string $user_url URL of the Gallery |
|
| 81 | + */ |
|
| 82 | + public function get_user_from_url($user_url){ |
|
| 83 | + //gallery params |
|
| 84 | + $user_params = $this->api_param_defaults + array( |
|
| 85 | + 'method' => 'flickr.urls.lookupUser', |
|
| 86 | + 'url' => $user_url, |
|
| 87 | + ); |
|
| 88 | 88 | |
| 89 | - //set User Url |
|
| 90 | - $this->flickr_url = $user_url; |
|
| 89 | + //set User Url |
|
| 90 | + $this->flickr_url = $user_url; |
|
| 91 | 91 | |
| 92 | - //get gallery info |
|
| 93 | - $user_info = $this->call_flickr_api($user_params); |
|
| 94 | - return $user_info->user->id; |
|
| 95 | - } |
|
| 92 | + //get gallery info |
|
| 93 | + $user_info = $this->call_flickr_api($user_params); |
|
| 94 | + return $user_info->user->id; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Get Group ID from its URL |
|
| 99 | - * |
|
| 100 | - * @since 1.0.0 |
|
| 101 | - * @param string $group_url URL of the Gallery |
|
| 102 | - */ |
|
| 103 | - public function get_group_from_url($group_url){ |
|
| 104 | - //gallery params |
|
| 105 | - $group_params = $this->api_param_defaults + array( |
|
| 106 | - 'method' => 'flickr.urls.lookupGroup', |
|
| 107 | - 'url' => $group_url, |
|
| 108 | - ); |
|
| 97 | + /** |
|
| 98 | + * Get Group ID from its URL |
|
| 99 | + * |
|
| 100 | + * @since 1.0.0 |
|
| 101 | + * @param string $group_url URL of the Gallery |
|
| 102 | + */ |
|
| 103 | + public function get_group_from_url($group_url){ |
|
| 104 | + //gallery params |
|
| 105 | + $group_params = $this->api_param_defaults + array( |
|
| 106 | + 'method' => 'flickr.urls.lookupGroup', |
|
| 107 | + 'url' => $group_url, |
|
| 108 | + ); |
|
| 109 | 109 | |
| 110 | - //set User Url |
|
| 111 | - $this->flickr_url = $group_url; |
|
| 110 | + //set User Url |
|
| 111 | + $this->flickr_url = $group_url; |
|
| 112 | 112 | |
| 113 | - //get gallery info |
|
| 114 | - $group_info = $this->call_flickr_api($group_params); |
|
| 115 | - return $group_info->group->id; |
|
| 116 | - } |
|
| 113 | + //get gallery info |
|
| 114 | + $group_info = $this->call_flickr_api($group_params); |
|
| 115 | + return $group_info->group->id; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Get Public Photos |
|
| 120 | - * |
|
| 121 | - * @since 1.0.0 |
|
| 122 | - * @param string $user_id flicker User id (not name) |
|
| 123 | - * @param int $item_count number of photos to pull |
|
| 124 | - */ |
|
| 125 | - public function get_public_photos($user_id,$item_count=10){ |
|
| 126 | - //public photos params |
|
| 127 | - $public_photo_params = $this->api_param_defaults + array( |
|
| 128 | - 'method' => 'flickr.people.getPublicPhotos', |
|
| 129 | - 'user_id' => $user_id, |
|
| 130 | - 'extras' => 'description, license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o', |
|
| 131 | - 'per_page'=> $item_count, |
|
| 132 | - 'page' => 1 |
|
| 133 | - ); |
|
| 118 | + /** |
|
| 119 | + * Get Public Photos |
|
| 120 | + * |
|
| 121 | + * @since 1.0.0 |
|
| 122 | + * @param string $user_id flicker User id (not name) |
|
| 123 | + * @param int $item_count number of photos to pull |
|
| 124 | + */ |
|
| 125 | + public function get_public_photos($user_id,$item_count=10){ |
|
| 126 | + //public photos params |
|
| 127 | + $public_photo_params = $this->api_param_defaults + array( |
|
| 128 | + 'method' => 'flickr.people.getPublicPhotos', |
|
| 129 | + 'user_id' => $user_id, |
|
| 130 | + 'extras' => 'description, license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o', |
|
| 131 | + 'per_page'=> $item_count, |
|
| 132 | + 'page' => 1 |
|
| 133 | + ); |
|
| 134 | 134 | |
| 135 | - //get photo list |
|
| 136 | - $public_photos_list = $this->call_flickr_api($public_photo_params); |
|
| 137 | - return $public_photos_list->photos->photo; |
|
| 138 | - } |
|
| 135 | + //get photo list |
|
| 136 | + $public_photos_list = $this->call_flickr_api($public_photo_params); |
|
| 137 | + return $public_photos_list->photos->photo; |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * Get Photosets List from User |
|
| 142 | - * |
|
| 143 | - * @since 1.0.0 |
|
| 144 | - * @param string $user_id flicker User id (not name) |
|
| 145 | - * @param int $item_count number of photos to pull |
|
| 146 | - */ |
|
| 147 | - public function get_photo_sets($user_id,$item_count=10){ |
|
| 148 | - //photoset params |
|
| 149 | - $photo_set_params = $this->api_param_defaults + array( |
|
| 150 | - 'method' => 'flickr.photosets.getList', |
|
| 151 | - 'user_id' => $user_id, |
|
| 152 | - 'per_page'=> $item_count, |
|
| 153 | - 'page' => 1 |
|
| 154 | - ); |
|
| 140 | + /** |
|
| 141 | + * Get Photosets List from User |
|
| 142 | + * |
|
| 143 | + * @since 1.0.0 |
|
| 144 | + * @param string $user_id flicker User id (not name) |
|
| 145 | + * @param int $item_count number of photos to pull |
|
| 146 | + */ |
|
| 147 | + public function get_photo_sets($user_id,$item_count=10){ |
|
| 148 | + //photoset params |
|
| 149 | + $photo_set_params = $this->api_param_defaults + array( |
|
| 150 | + 'method' => 'flickr.photosets.getList', |
|
| 151 | + 'user_id' => $user_id, |
|
| 152 | + 'per_page'=> $item_count, |
|
| 153 | + 'page' => 1 |
|
| 154 | + ); |
|
| 155 | 155 | |
| 156 | - //get photoset list |
|
| 157 | - $photo_sets_list = $this->call_flickr_api($photo_set_params); |
|
| 158 | - return $photo_sets_list->photosets->photoset; |
|
| 159 | - } |
|
| 156 | + //get photoset list |
|
| 157 | + $photo_sets_list = $this->call_flickr_api($photo_set_params); |
|
| 158 | + return $photo_sets_list->photosets->photoset; |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * Get Photoset Photos |
|
| 163 | - * |
|
| 164 | - * @since 1.0.0 |
|
| 165 | - * @param string $photo_set_id Photoset ID |
|
| 166 | - * @param int $item_count number of photos to pull |
|
| 167 | - */ |
|
| 168 | - public function get_photo_set_photos($photo_set_id,$item_count=10){ |
|
| 169 | - //photoset photos params |
|
| 170 | - $photo_set_params = $this->api_param_defaults + array( |
|
| 171 | - 'method' => 'flickr.photosets.getPhotos', |
|
| 172 | - 'photoset_id' => $photo_set_id, |
|
| 173 | - 'per_page' => $item_count, |
|
| 174 | - 'page' => 1, |
|
| 175 | - 'extras' => 'license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o' |
|
| 176 | - ); |
|
| 161 | + /** |
|
| 162 | + * Get Photoset Photos |
|
| 163 | + * |
|
| 164 | + * @since 1.0.0 |
|
| 165 | + * @param string $photo_set_id Photoset ID |
|
| 166 | + * @param int $item_count number of photos to pull |
|
| 167 | + */ |
|
| 168 | + public function get_photo_set_photos($photo_set_id,$item_count=10){ |
|
| 169 | + //photoset photos params |
|
| 170 | + $photo_set_params = $this->api_param_defaults + array( |
|
| 171 | + 'method' => 'flickr.photosets.getPhotos', |
|
| 172 | + 'photoset_id' => $photo_set_id, |
|
| 173 | + 'per_page' => $item_count, |
|
| 174 | + 'page' => 1, |
|
| 175 | + 'extras' => 'license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o' |
|
| 176 | + ); |
|
| 177 | 177 | |
| 178 | - //get photo list |
|
| 179 | - $photo_set_photos = $this->call_flickr_api($photo_set_params); |
|
| 180 | - return $photo_set_photos->photoset->photo; |
|
| 181 | - } |
|
| 178 | + //get photo list |
|
| 179 | + $photo_set_photos = $this->call_flickr_api($photo_set_params); |
|
| 180 | + return $photo_set_photos->photoset->photo; |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * Get Groop Pool Photos |
|
| 185 | - * |
|
| 186 | - * @since 1.0.0 |
|
| 187 | - * @param string $group_id Photoset ID |
|
| 188 | - * @param int $item_count number of photos to pull |
|
| 189 | - */ |
|
| 190 | - public function get_group_photos($group_id,$item_count=10){ |
|
| 191 | - //photoset photos params |
|
| 192 | - $group_pool_params = $this->api_param_defaults + array( |
|
| 193 | - 'method' => 'flickr.groups.pools.getPhotos', |
|
| 194 | - 'group_id' => $group_id, |
|
| 195 | - 'per_page' => $item_count, |
|
| 196 | - 'page' => 1, |
|
| 197 | - 'extras' => 'license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o' |
|
| 198 | - ); |
|
| 183 | + /** |
|
| 184 | + * Get Groop Pool Photos |
|
| 185 | + * |
|
| 186 | + * @since 1.0.0 |
|
| 187 | + * @param string $group_id Photoset ID |
|
| 188 | + * @param int $item_count number of photos to pull |
|
| 189 | + */ |
|
| 190 | + public function get_group_photos($group_id,$item_count=10){ |
|
| 191 | + //photoset photos params |
|
| 192 | + $group_pool_params = $this->api_param_defaults + array( |
|
| 193 | + 'method' => 'flickr.groups.pools.getPhotos', |
|
| 194 | + 'group_id' => $group_id, |
|
| 195 | + 'per_page' => $item_count, |
|
| 196 | + 'page' => 1, |
|
| 197 | + 'extras' => 'license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o' |
|
| 198 | + ); |
|
| 199 | 199 | |
| 200 | - //get photo list |
|
| 201 | - $group_pool_photos = $this->call_flickr_api($group_pool_params); |
|
| 202 | - return $group_pool_photos->photos->photo; |
|
| 203 | - } |
|
| 200 | + //get photo list |
|
| 201 | + $group_pool_photos = $this->call_flickr_api($group_pool_params); |
|
| 202 | + return $group_pool_photos->photos->photo; |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - /** |
|
| 206 | - * Get Gallery ID from its URL |
|
| 207 | - * |
|
| 208 | - * @since 1.0.0 |
|
| 209 | - * @param string $gallery_url URL of the Gallery |
|
| 210 | - * @param int $item_count number of photos to pull |
|
| 211 | - */ |
|
| 212 | - public function get_gallery_from_url($gallery_url){ |
|
| 213 | - //gallery params |
|
| 214 | - $gallery_params = $this->api_param_defaults + array( |
|
| 215 | - 'method' => 'flickr.urls.lookupGallery', |
|
| 216 | - 'url' => $gallery_url, |
|
| 217 | - ); |
|
| 205 | + /** |
|
| 206 | + * Get Gallery ID from its URL |
|
| 207 | + * |
|
| 208 | + * @since 1.0.0 |
|
| 209 | + * @param string $gallery_url URL of the Gallery |
|
| 210 | + * @param int $item_count number of photos to pull |
|
| 211 | + */ |
|
| 212 | + public function get_gallery_from_url($gallery_url){ |
|
| 213 | + //gallery params |
|
| 214 | + $gallery_params = $this->api_param_defaults + array( |
|
| 215 | + 'method' => 'flickr.urls.lookupGallery', |
|
| 216 | + 'url' => $gallery_url, |
|
| 217 | + ); |
|
| 218 | 218 | |
| 219 | - //get gallery info |
|
| 220 | - $gallery_info = $this->call_flickr_api($gallery_params); |
|
| 221 | - return $gallery_info->gallery->id; |
|
| 222 | - } |
|
| 219 | + //get gallery info |
|
| 220 | + $gallery_info = $this->call_flickr_api($gallery_params); |
|
| 221 | + return $gallery_info->gallery->id; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - /** |
|
| 225 | - * Get Gallery Photos |
|
| 226 | - * |
|
| 227 | - * @since 1.0.0 |
|
| 228 | - * @param string $gallery_id flicker Gallery id (not name) |
|
| 229 | - * @param int $item_count number of photos to pull |
|
| 230 | - */ |
|
| 231 | - public function get_gallery_photos($gallery_id,$item_count=10){ |
|
| 232 | - //gallery photos params |
|
| 233 | - $gallery_photo_params = $this->api_param_defaults + array( |
|
| 234 | - 'method' => 'flickr.galleries.getPhotos', |
|
| 235 | - 'gallery_id' => $gallery_id, |
|
| 236 | - 'extras' => 'description, license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o', |
|
| 237 | - 'per_page'=> $item_count, |
|
| 238 | - 'page' => 1 |
|
| 239 | - ); |
|
| 224 | + /** |
|
| 225 | + * Get Gallery Photos |
|
| 226 | + * |
|
| 227 | + * @since 1.0.0 |
|
| 228 | + * @param string $gallery_id flicker Gallery id (not name) |
|
| 229 | + * @param int $item_count number of photos to pull |
|
| 230 | + */ |
|
| 231 | + public function get_gallery_photos($gallery_id,$item_count=10){ |
|
| 232 | + //gallery photos params |
|
| 233 | + $gallery_photo_params = $this->api_param_defaults + array( |
|
| 234 | + 'method' => 'flickr.galleries.getPhotos', |
|
| 235 | + 'gallery_id' => $gallery_id, |
|
| 236 | + 'extras' => 'description, license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o', |
|
| 237 | + 'per_page'=> $item_count, |
|
| 238 | + 'page' => 1 |
|
| 239 | + ); |
|
| 240 | 240 | |
| 241 | - //get photo list |
|
| 242 | - $gallery_photos_list = $this->call_flickr_api($gallery_photo_params); |
|
| 243 | - return $gallery_photos_list->photos->photo; |
|
| 244 | - } |
|
| 241 | + //get photo list |
|
| 242 | + $gallery_photos_list = $this->call_flickr_api($gallery_photo_params); |
|
| 243 | + return $gallery_photos_list->photos->photo; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - /** |
|
| 247 | - * Encode the flickr ID for URL (base58) |
|
| 248 | - * |
|
| 249 | - * @since 1.0.0 |
|
| 250 | - * @param string $num flickr photo id |
|
| 251 | - */ |
|
| 252 | - public static function base_encode($num, $alphabet='123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ') { |
|
| 253 | - $base_count = strlen($alphabet); |
|
| 254 | - $encoded = ''; |
|
| 255 | - while ($num >= $base_count) { |
|
| 256 | - $div = $num/$base_count; |
|
| 257 | - $mod = ($num-($base_count*intval($div))); |
|
| 258 | - $encoded = $alphabet[$mod] . $encoded; |
|
| 259 | - $num = intval($div); |
|
| 260 | - } |
|
| 261 | - if ($num) $encoded = $alphabet[$num] . $encoded; |
|
| 262 | - return $encoded; |
|
| 263 | - } |
|
| 246 | + /** |
|
| 247 | + * Encode the flickr ID for URL (base58) |
|
| 248 | + * |
|
| 249 | + * @since 1.0.0 |
|
| 250 | + * @param string $num flickr photo id |
|
| 251 | + */ |
|
| 252 | + public static function base_encode($num, $alphabet='123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ') { |
|
| 253 | + $base_count = strlen($alphabet); |
|
| 254 | + $encoded = ''; |
|
| 255 | + while ($num >= $base_count) { |
|
| 256 | + $div = $num/$base_count; |
|
| 257 | + $mod = ($num-($base_count*intval($div))); |
|
| 258 | + $encoded = $alphabet[$mod] . $encoded; |
|
| 259 | + $num = intval($div); |
|
| 260 | + } |
|
| 261 | + if ($num) $encoded = $alphabet[$num] . $encoded; |
|
| 262 | + return $encoded; |
|
| 263 | + } |
|
| 264 | 264 | } |
| 265 | 265 | ?> |
| 266 | 266 | \ No newline at end of file |
@@ -258,7 +258,9 @@ |
||
| 258 | 258 | $encoded = $alphabet[$mod] . $encoded; |
| 259 | 259 | $num = intval($div); |
| 260 | 260 | } |
| 261 | - if ($num) $encoded = $alphabet[$num] . $encoded; |
|
| 261 | + if ($num) { |
|
| 262 | + $encoded = $alphabet[$num] . $encoded; |
|
| 263 | + } |
|
| 262 | 264 | return $encoded; |
| 263 | 265 | } |
| 264 | 266 | } |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | * @since 1.0.0 |
| 61 | 61 | * @param array $params Parameter build for API request |
| 62 | 62 | */ |
| 63 | - private function call_flickr_api($params){ |
|
| 63 | + private function call_flickr_api($params) { |
|
| 64 | 64 | //build url |
| 65 | 65 | $encoded_params = array(); |
| 66 | - foreach ($params as $k => $v){ |
|
| 66 | + foreach ($params as $k => $v) { |
|
| 67 | 67 | $encoded_params[] = urlencode($k).'='.urlencode($v); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @since 1.0.0 |
| 80 | 80 | * @param string $user_url URL of the Gallery |
| 81 | 81 | */ |
| 82 | - public function get_user_from_url($user_url){ |
|
| 82 | + public function get_user_from_url($user_url) { |
|
| 83 | 83 | //gallery params |
| 84 | 84 | $user_params = $this->api_param_defaults + array( |
| 85 | 85 | 'method' => 'flickr.urls.lookupUser', |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @since 1.0.0 |
| 101 | 101 | * @param string $group_url URL of the Gallery |
| 102 | 102 | */ |
| 103 | - public function get_group_from_url($group_url){ |
|
| 103 | + public function get_group_from_url($group_url) { |
|
| 104 | 104 | //gallery params |
| 105 | 105 | $group_params = $this->api_param_defaults + array( |
| 106 | 106 | 'method' => 'flickr.urls.lookupGroup', |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @param string $user_id flicker User id (not name) |
| 123 | 123 | * @param int $item_count number of photos to pull |
| 124 | 124 | */ |
| 125 | - public function get_public_photos($user_id,$item_count=10){ |
|
| 125 | + public function get_public_photos($user_id, $item_count = 10) { |
|
| 126 | 126 | //public photos params |
| 127 | 127 | $public_photo_params = $this->api_param_defaults + array( |
| 128 | 128 | 'method' => 'flickr.people.getPublicPhotos', |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param string $user_id flicker User id (not name) |
| 145 | 145 | * @param int $item_count number of photos to pull |
| 146 | 146 | */ |
| 147 | - public function get_photo_sets($user_id,$item_count=10){ |
|
| 147 | + public function get_photo_sets($user_id, $item_count = 10) { |
|
| 148 | 148 | //photoset params |
| 149 | 149 | $photo_set_params = $this->api_param_defaults + array( |
| 150 | 150 | 'method' => 'flickr.photosets.getList', |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @param string $photo_set_id Photoset ID |
| 166 | 166 | * @param int $item_count number of photos to pull |
| 167 | 167 | */ |
| 168 | - public function get_photo_set_photos($photo_set_id,$item_count=10){ |
|
| 168 | + public function get_photo_set_photos($photo_set_id, $item_count = 10) { |
|
| 169 | 169 | //photoset photos params |
| 170 | 170 | $photo_set_params = $this->api_param_defaults + array( |
| 171 | 171 | 'method' => 'flickr.photosets.getPhotos', |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * @param string $group_id Photoset ID |
| 188 | 188 | * @param int $item_count number of photos to pull |
| 189 | 189 | */ |
| 190 | - public function get_group_photos($group_id,$item_count=10){ |
|
| 190 | + public function get_group_photos($group_id, $item_count = 10) { |
|
| 191 | 191 | //photoset photos params |
| 192 | 192 | $group_pool_params = $this->api_param_defaults + array( |
| 193 | 193 | 'method' => 'flickr.groups.pools.getPhotos', |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @param string $gallery_url URL of the Gallery |
| 210 | 210 | * @param int $item_count number of photos to pull |
| 211 | 211 | */ |
| 212 | - public function get_gallery_from_url($gallery_url){ |
|
| 212 | + public function get_gallery_from_url($gallery_url) { |
|
| 213 | 213 | //gallery params |
| 214 | 214 | $gallery_params = $this->api_param_defaults + array( |
| 215 | 215 | 'method' => 'flickr.urls.lookupGallery', |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * @param string $gallery_id flicker Gallery id (not name) |
| 229 | 229 | * @param int $item_count number of photos to pull |
| 230 | 230 | */ |
| 231 | - public function get_gallery_photos($gallery_id,$item_count=10){ |
|
| 231 | + public function get_gallery_photos($gallery_id, $item_count = 10) { |
|
| 232 | 232 | //gallery photos params |
| 233 | 233 | $gallery_photo_params = $this->api_param_defaults + array( |
| 234 | 234 | 'method' => 'flickr.galleries.getPhotos', |
@@ -249,16 +249,16 @@ discard block |
||
| 249 | 249 | * @since 1.0.0 |
| 250 | 250 | * @param string $num flickr photo id |
| 251 | 251 | */ |
| 252 | - public static function base_encode($num, $alphabet='123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ') { |
|
| 252 | + public static function base_encode($num, $alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ') { |
|
| 253 | 253 | $base_count = strlen($alphabet); |
| 254 | 254 | $encoded = ''; |
| 255 | 255 | while ($num >= $base_count) { |
| 256 | - $div = $num/$base_count; |
|
| 257 | - $mod = ($num-($base_count*intval($div))); |
|
| 258 | - $encoded = $alphabet[$mod] . $encoded; |
|
| 256 | + $div = $num / $base_count; |
|
| 257 | + $mod = ($num - ($base_count * intval($div))); |
|
| 258 | + $encoded = $alphabet[$mod].$encoded; |
|
| 259 | 259 | $num = intval($div); |
| 260 | 260 | } |
| 261 | - if ($num) $encoded = $alphabet[$num] . $encoded; |
|
| 261 | + if ($num) $encoded = $alphabet[$num].$encoded; |
|
| 262 | 262 | return $encoded; |
| 263 | 263 | } |
| 264 | 264 | } |
@@ -35,7 +35,6 @@ |
||
| 35 | 35 | * Get Instagram Pictures |
| 36 | 36 | * |
| 37 | 37 | * @since 1.0.0 |
| 38 | - * @param string $user_id Instagram User id (not name) |
|
| 39 | 38 | */ |
| 40 | 39 | public function get_public_photos($search_user_id){ |
| 41 | 40 | //call the API and decode the response |
@@ -12,37 +12,37 @@ |
||
| 12 | 12 | |
| 13 | 13 | class TP_instagram { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * API key |
|
| 17 | - * |
|
| 18 | - * @since 1.0.0 |
|
| 19 | - * @access private |
|
| 20 | - * @var string $api_key Instagram API key |
|
| 21 | - */ |
|
| 22 | - private $api_key; |
|
| 15 | + /** |
|
| 16 | + * API key |
|
| 17 | + * |
|
| 18 | + * @since 1.0.0 |
|
| 19 | + * @access private |
|
| 20 | + * @var string $api_key Instagram API key |
|
| 21 | + */ |
|
| 22 | + private $api_key; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Initialize the class and set its properties. |
|
| 26 | - * |
|
| 27 | - * @since 1.0.0 |
|
| 28 | - * @param string $api_key Instagram API key. |
|
| 29 | - */ |
|
| 30 | - public function __construct($api_key) { |
|
| 31 | - $this->api_key = $api_key; |
|
| 32 | - } |
|
| 24 | + /** |
|
| 25 | + * Initialize the class and set its properties. |
|
| 26 | + * |
|
| 27 | + * @since 1.0.0 |
|
| 28 | + * @param string $api_key Instagram API key. |
|
| 29 | + */ |
|
| 30 | + public function __construct($api_key) { |
|
| 31 | + $this->api_key = $api_key; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Get Instagram Pictures |
|
| 36 | - * |
|
| 37 | - * @since 1.0.0 |
|
| 38 | - * @param string $user_id Instagram User id (not name) |
|
| 39 | - */ |
|
| 40 | - public function get_public_photos($search_user_id){ |
|
| 41 | - //call the API and decode the response |
|
| 42 | - $url = "https://api.instagram.com/v1/users/".$search_user_id."/media/recent?access_token=".$this->api_key."&client_id=".$search_user_id; |
|
| 43 | - $rsp = json_decode(file_get_contents($url)); |
|
| 44 | - return $rsp->data; |
|
| 45 | - } |
|
| 34 | + /** |
|
| 35 | + * Get Instagram Pictures |
|
| 36 | + * |
|
| 37 | + * @since 1.0.0 |
|
| 38 | + * @param string $user_id Instagram User id (not name) |
|
| 39 | + */ |
|
| 40 | + public function get_public_photos($search_user_id){ |
|
| 41 | + //call the API and decode the response |
|
| 42 | + $url = "https://api.instagram.com/v1/users/".$search_user_id."/media/recent?access_token=".$this->api_key."&client_id=".$search_user_id; |
|
| 43 | + $rsp = json_decode(file_get_contents($url)); |
|
| 44 | + return $rsp->data; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | } |
| 48 | 48 | ?> |
| 49 | 49 | \ No newline at end of file |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | * @since 1.0.0 |
| 38 | 38 | * @param string $user_id Instagram User id (not name) |
| 39 | 39 | */ |
| 40 | - public function get_public_photos($search_user_id){ |
|
| 40 | + public function get_public_photos($search_user_id) { |
|
| 41 | 41 | //call the API and decode the response |
| 42 | 42 | $url = "https://api.instagram.com/v1/users/".$search_user_id."/media/recent?access_token=".$this->api_key."&client_id=".$search_user_id; |
| 43 | 43 | $rsp = json_decode(file_get_contents($url)); |
@@ -52,7 +52,6 @@ discard block |
||
| 52 | 52 | * Initialize the class and set its properties. |
| 53 | 53 | * |
| 54 | 54 | * @since 1.0.0 |
| 55 | - * @param string $api_key flickr API key. |
|
| 56 | 55 | */ |
| 57 | 56 | public function __construct($consumer_key,$consumer_secret,$access_token,$access_token_secret) { |
| 58 | 57 | $this->consumer_key = $consumer_key; |
@@ -112,7 +111,6 @@ discard block |
||
| 112 | 111 | * Prepare output array $stream |
| 113 | 112 | * |
| 114 | 113 | * @since 1.0.0 |
| 115 | - * @param string $tweets Twitter Output Data |
|
| 116 | 114 | */ |
| 117 | 115 | public static function makeClickableLinks($s) { |
| 118 | 116 | return preg_replace('@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '<a href="$1" target="_blank">$1</a>', $s); |
@@ -12,62 +12,62 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class TP_twitter { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Consumer Key |
|
| 17 | - * |
|
| 18 | - * @since 1.0.0 |
|
| 19 | - * @access private |
|
| 20 | - * @var string $consumer_key Consumer Key |
|
| 21 | - */ |
|
| 22 | - private $consumer_key; |
|
| 15 | + /** |
|
| 16 | + * Consumer Key |
|
| 17 | + * |
|
| 18 | + * @since 1.0.0 |
|
| 19 | + * @access private |
|
| 20 | + * @var string $consumer_key Consumer Key |
|
| 21 | + */ |
|
| 22 | + private $consumer_key; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Consumer Secret |
|
| 26 | - * |
|
| 27 | - * @since 1.0.0 |
|
| 28 | - * @access private |
|
| 29 | - * @var string $consumer_secret Consumer Secret |
|
| 30 | - */ |
|
| 31 | - private $consumer_secret; |
|
| 24 | + /** |
|
| 25 | + * Consumer Secret |
|
| 26 | + * |
|
| 27 | + * @since 1.0.0 |
|
| 28 | + * @access private |
|
| 29 | + * @var string $consumer_secret Consumer Secret |
|
| 30 | + */ |
|
| 31 | + private $consumer_secret; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Access Token |
|
| 35 | - * |
|
| 36 | - * @since 1.0.0 |
|
| 37 | - * @access private |
|
| 38 | - * @var string $access_token Access Token |
|
| 39 | - */ |
|
| 40 | - private $access_token; |
|
| 33 | + /** |
|
| 34 | + * Access Token |
|
| 35 | + * |
|
| 36 | + * @since 1.0.0 |
|
| 37 | + * @access private |
|
| 38 | + * @var string $access_token Access Token |
|
| 39 | + */ |
|
| 40 | + private $access_token; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Access Token Secret |
|
| 44 | - * |
|
| 45 | - * @since 1.0.0 |
|
| 46 | - * @access private |
|
| 47 | - * @var string $access_token_secret Access Token Secret |
|
| 48 | - */ |
|
| 49 | - private $access_token_secret; |
|
| 42 | + /** |
|
| 43 | + * Access Token Secret |
|
| 44 | + * |
|
| 45 | + * @since 1.0.0 |
|
| 46 | + * @access private |
|
| 47 | + * @var string $access_token_secret Access Token Secret |
|
| 48 | + */ |
|
| 49 | + private $access_token_secret; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Initialize the class and set its properties. |
|
| 53 | - * |
|
| 54 | - * @since 1.0.0 |
|
| 55 | - * @param string $api_key flickr API key. |
|
| 56 | - */ |
|
| 57 | - public function __construct($consumer_key,$consumer_secret,$access_token,$access_token_secret) { |
|
| 51 | + /** |
|
| 52 | + * Initialize the class and set its properties. |
|
| 53 | + * |
|
| 54 | + * @since 1.0.0 |
|
| 55 | + * @param string $api_key flickr API key. |
|
| 56 | + */ |
|
| 57 | + public function __construct($consumer_key,$consumer_secret,$access_token,$access_token_secret) { |
|
| 58 | 58 | $this->consumer_key = $consumer_key; |
| 59 | 59 | $this->consumer_secret = $consumer_secret; |
| 60 | 60 | $this->access_token = $access_token; |
| 61 | 61 | $this->access_token_secret = $access_token_secret; |
| 62 | - } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Get Tweets |
|
| 66 | - * |
|
| 67 | - * @since 1.0.0 |
|
| 68 | - * @param string $twitter_account Twitter account without trailing @ char |
|
| 69 | - */ |
|
| 70 | - public function get_public_photos($twitter_account){ |
|
| 64 | + /** |
|
| 65 | + * Get Tweets |
|
| 66 | + * |
|
| 67 | + * @since 1.0.0 |
|
| 68 | + * @param string $twitter_account Twitter account without trailing @ char |
|
| 69 | + */ |
|
| 70 | + public function get_public_photos($twitter_account){ |
|
| 71 | 71 | $twitter = new \TwitterPhp\RestApi($this->consumer_key,$this->consumer_secret,$this->access_token,$this->access_token_secret); |
| 72 | 72 | /* |
| 73 | 73 | * Connect as application |
@@ -82,41 +82,41 @@ discard block |
||
| 82 | 82 | $tweets = $connection->get('/statuses/user_timeline',array('screen_name' => $twitter_account, 'entities' => 1, 'trim_user' => 0 , 'exclude_replies' => 'true')); |
| 83 | 83 | //var_dump($tweets); |
| 84 | 84 | return $tweets; |
| 85 | - } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Find Key in array and return value (multidim array possible) |
|
| 90 | - * |
|
| 91 | - * @since 1.0.0 |
|
| 92 | - * @param string $key Needle |
|
| 93 | - * @param array $form Haystack |
|
| 94 | - */ |
|
| 95 | - public static function array_find_element_by_key($key, $form) { |
|
| 96 | - if (array_key_exists($key, $form)) { |
|
| 88 | + /** |
|
| 89 | + * Find Key in array and return value (multidim array possible) |
|
| 90 | + * |
|
| 91 | + * @since 1.0.0 |
|
| 92 | + * @param string $key Needle |
|
| 93 | + * @param array $form Haystack |
|
| 94 | + */ |
|
| 95 | + public static function array_find_element_by_key($key, $form) { |
|
| 96 | + if (array_key_exists($key, $form)) { |
|
| 97 | 97 | $ret =& $form[$key]; |
| 98 | 98 | return $ret; |
| 99 | - } |
|
| 100 | - foreach ($form as $k => $v) { |
|
| 99 | + } |
|
| 100 | + foreach ($form as $k => $v) { |
|
| 101 | 101 | if (is_array($v)) { |
| 102 | - $ret =TP_twitter::array_find_element_by_key($key, $form[$k]); |
|
| 103 | - if ($ret) { |
|
| 102 | + $ret =TP_twitter::array_find_element_by_key($key, $form[$k]); |
|
| 103 | + if ($ret) { |
|
| 104 | 104 | return $ret; |
| 105 | - } |
|
| 105 | + } |
|
| 106 | 106 | } |
| 107 | - } |
|
| 108 | - return FALSE; |
|
| 109 | - } |
|
| 107 | + } |
|
| 108 | + return FALSE; |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * Prepare output array $stream |
|
| 113 | - * |
|
| 114 | - * @since 1.0.0 |
|
| 115 | - * @param string $tweets Twitter Output Data |
|
| 116 | - */ |
|
| 117 | - public static function makeClickableLinks($s) { |
|
| 111 | + /** |
|
| 112 | + * Prepare output array $stream |
|
| 113 | + * |
|
| 114 | + * @since 1.0.0 |
|
| 115 | + * @param string $tweets Twitter Output Data |
|
| 116 | + */ |
|
| 117 | + public static function makeClickableLinks($s) { |
|
| 118 | 118 | return preg_replace('@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '<a href="$1" target="_blank">$1</a>', $s); |
| 119 | - } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | } |
| 122 | 122 | ?> |
| 123 | 123 | \ No newline at end of file |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | * @since 1.0.0 |
| 55 | 55 | * @param string $api_key flickr API key. |
| 56 | 56 | */ |
| 57 | - public function __construct($consumer_key,$consumer_secret,$access_token,$access_token_secret) { |
|
| 58 | - $this->consumer_key = $consumer_key; |
|
| 59 | - $this->consumer_secret = $consumer_secret; |
|
| 60 | - $this->access_token = $access_token; |
|
| 61 | - $this->access_token_secret = $access_token_secret; |
|
| 57 | + public function __construct($consumer_key, $consumer_secret, $access_token, $access_token_secret) { |
|
| 58 | + $this->consumer_key = $consumer_key; |
|
| 59 | + $this->consumer_secret = $consumer_secret; |
|
| 60 | + $this->access_token = $access_token; |
|
| 61 | + $this->access_token_secret = $access_token_secret; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | * @since 1.0.0 |
| 68 | 68 | * @param string $twitter_account Twitter account without trailing @ char |
| 69 | 69 | */ |
| 70 | - public function get_public_photos($twitter_account){ |
|
| 71 | - $twitter = new \TwitterPhp\RestApi($this->consumer_key,$this->consumer_secret,$this->access_token,$this->access_token_secret); |
|
| 70 | + public function get_public_photos($twitter_account) { |
|
| 71 | + $twitter = new \TwitterPhp\RestApi($this->consumer_key, $this->consumer_secret, $this->access_token, $this->access_token_secret); |
|
| 72 | 72 | /* |
| 73 | 73 | * Connect as application |
| 74 | 74 | * https://dev.twitter.com/docs/auth/application-only-auth |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * Collection of the most recent Tweets posted by the user indicated by the screen_name, without replies |
| 80 | 80 | * https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline |
| 81 | 81 | */ |
| 82 | - $tweets = $connection->get('/statuses/user_timeline',array('screen_name' => $twitter_account, 'entities' => 1, 'trim_user' => 0 , 'exclude_replies' => 'true')); |
|
| 82 | + $tweets = $connection->get('/statuses/user_timeline', array('screen_name' => $twitter_account, 'entities' => 1, 'trim_user' => 0, 'exclude_replies' => 'true')); |
|
| 83 | 83 | //var_dump($tweets); |
| 84 | 84 | return $tweets; |
| 85 | 85 | } |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public static function array_find_element_by_key($key, $form) { |
| 96 | 96 | if (array_key_exists($key, $form)) { |
| 97 | - $ret =& $form[$key]; |
|
| 97 | + $ret = & $form[$key]; |
|
| 98 | 98 | return $ret; |
| 99 | 99 | } |
| 100 | 100 | foreach ($form as $k => $v) { |
| 101 | 101 | if (is_array($v)) { |
| 102 | - $ret =TP_twitter::array_find_element_by_key($key, $form[$k]); |
|
| 102 | + $ret = TP_twitter::array_find_element_by_key($key, $form[$k]); |
|
| 103 | 103 | if ($ret) { |
| 104 | 104 | return $ret; |
| 105 | 105 | } |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | * @param string $url |
| 35 | 35 | * @param array $parameters |
| 36 | 36 | * @param $method |
| 37 | - * @return array |
|
| 37 | + * @return string[] |
|
| 38 | 38 | */ |
| 39 | 39 | protected function _buildHeaders($url,array $parameters = null,$method) |
| 40 | 40 | { |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @param string $consumerKey |
| 25 | 25 | * @param string $consumerSecret |
| 26 | 26 | */ |
| 27 | - public function __construct($consumerKey,$consumerSecret) |
|
| 27 | + public function __construct($consumerKey, $consumerSecret) |
|
| 28 | 28 | { |
| 29 | 29 | $this->_consumerKey = $consumerKey; |
| 30 | 30 | $this->_consumerSecret = $consumerSecret; |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | * @param $method |
| 37 | 37 | * @return array |
| 38 | 38 | */ |
| 39 | - protected function _buildHeaders($url,array $parameters = null,$method) |
|
| 39 | + protected function _buildHeaders($url, array $parameters = null, $method) |
|
| 40 | 40 | { |
| 41 | 41 | return $headers = array( |
| 42 | - "Authorization: Bearer " . $this->_getBearerToken() |
|
| 42 | + "Authorization: Bearer ".$this->_getBearerToken() |
|
| 43 | 43 | ); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | private function _getBearerToken() { |
| 55 | 55 | if (!$this->_bearersToken) { |
| 56 | - $token = urlencode($this->_consumerKey) . ':' . urlencode($this->_consumerSecret); |
|
| 56 | + $token = urlencode($this->_consumerKey).':'.urlencode($this->_consumerSecret); |
|
| 57 | 57 | $token = base64_encode($token); |
| 58 | 58 | |
| 59 | 59 | $headers = array( |
| 60 | - "Authorization: Basic " . $token |
|
| 60 | + "Authorization: Basic ".$token |
|
| 61 | 61 | ); |
| 62 | 62 | |
| 63 | - $options = array ( |
|
| 63 | + $options = array( |
|
| 64 | 64 | CURLOPT_URL => self::TWITTER_API_AUTH_URL, |
| 65 | 65 | CURLOPT_HTTPHEADER => $headers, |
| 66 | 66 | CURLOPT_POST => 1, |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param string $url |
| 42 | 42 | * @param array $parameters |
| 43 | 43 | * @param $method |
| 44 | - * @return array |
|
| 44 | + * @return string[] |
|
| 45 | 45 | */ |
| 46 | 46 | protected function _buildHeaders($url,array $parameters = null,$method) |
| 47 | 47 | { |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * @param $url |
|
| 74 | + * @param string $url |
|
| 75 | 75 | * @param array $params |
| 76 | 76 | * @param $method |
| 77 | 77 | * @return string |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param string $accessToken |
| 30 | 30 | * @param string $accessTokenSecret |
| 31 | 31 | */ |
| 32 | - public function __construct($consumerKey,$consumerSecret,$accessToken,$accessTokenSecret) |
|
| 32 | + public function __construct($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret) |
|
| 33 | 33 | { |
| 34 | 34 | $this->_consumerKey = $consumerKey; |
| 35 | 35 | $this->_consumerSecret = $consumerSecret; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param $method |
| 44 | 44 | * @return array |
| 45 | 45 | */ |
| 46 | - protected function _buildHeaders($url,array $parameters = null,$method) |
|
| 46 | + protected function _buildHeaders($url, array $parameters = null, $method) |
|
| 47 | 47 | { |
| 48 | 48 | $oauthHeaders = array( |
| 49 | 49 | 'oauth_version' => '1.0', |
@@ -56,17 +56,17 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $data = $oauthHeaders; |
| 58 | 58 | if ($method == self::METHOD_GET) { |
| 59 | - $data = array_merge($oauthHeaders,$parameters); |
|
| 59 | + $data = array_merge($oauthHeaders, $parameters); |
|
| 60 | 60 | } |
| 61 | - $oauthHeaders['oauth_signature'] = $this->_buildOauthSignature($url,$data,$method); |
|
| 61 | + $oauthHeaders['oauth_signature'] = $this->_buildOauthSignature($url, $data, $method); |
|
| 62 | 62 | ksort($oauthHeaders); |
| 63 | 63 | $oauthHeader = array(); |
| 64 | 64 | |
| 65 | - foreach($oauthHeaders as $key => $value) { |
|
| 66 | - $oauthHeader[] = $key . '="' . rawurlencode($value) . '"'; |
|
| 65 | + foreach ($oauthHeaders as $key => $value) { |
|
| 66 | + $oauthHeader[] = $key.'="'.rawurlencode($value).'"'; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $headers[] = 'Authorization: OAuth ' . implode(', ', $oauthHeader); |
|
| 69 | + $headers[] = 'Authorization: OAuth '.implode(', ', $oauthHeader); |
|
| 70 | 70 | return $headers; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -76,17 +76,17 @@ discard block |
||
| 76 | 76 | * @param $method |
| 77 | 77 | * @return string |
| 78 | 78 | */ |
| 79 | - private function _buildOauthSignature($url,array $params,$method) |
|
| 79 | + private function _buildOauthSignature($url, array $params, $method) |
|
| 80 | 80 | { |
| 81 | 81 | ksort($params); |
| 82 | 82 | $sortedParams = array(); |
| 83 | 83 | |
| 84 | - foreach($params as $key=>$value) { |
|
| 85 | - $sortedParams[] = $key . '=' . $value; |
|
| 84 | + foreach ($params as $key=>$value) { |
|
| 85 | + $sortedParams[] = $key.'='.$value; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - $signatureBaseString = $method . "&" . rawurlencode($url) . '&' . rawurlencode(implode('&', $sortedParams)); |
|
| 89 | - $compositeKey = rawurlencode($this->_consumerSecret) . '&' . rawurlencode($this->_accessTokenSecret); |
|
| 88 | + $signatureBaseString = $method."&".rawurlencode($url).'&'.rawurlencode(implode('&', $sortedParams)); |
|
| 89 | + $compositeKey = rawurlencode($this->_consumerSecret).'&'.rawurlencode($this->_accessTokenSecret); |
|
| 90 | 90 | return base64_encode(hash_hmac('sha1', $signatureBaseString, $compositeKey, true)); |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | \ No newline at end of file |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * @param $collection |
|
| 27 | + * @param \Illuminate\Support\Collection $collection |
|
| 28 | 28 | * @return \Chumper\Datatable\Engines\CollectionEngine |
| 29 | 29 | */ |
| 30 | 30 | public function collection($collection) |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | use Chumper\Datatable\Engines\CollectionEngine; |
| 4 | 4 | use Chumper\Datatable\Engines\QueryEngine; |
| 5 | 5 | use Input; |
| 6 | -use Request; |
|
| 7 | 6 | |
| 8 | 7 | /** |
| 9 | 8 | * Class Datatable |
@@ -47,8 +47,8 @@ |
||
| 47 | 47 | */ |
| 48 | 48 | public function shouldHandle() |
| 49 | 49 | { |
| 50 | - $echo = Input::get('sEcho',null); |
|
| 51 | - if(/*Request::ajax() && */!is_null($echo) && is_numeric($echo)) |
|
| 50 | + $echo = Input::get('sEcho', null); |
|
| 51 | + if (/*Request::ajax() && */!is_null($echo) && is_numeric($echo)) |
|
| 52 | 52 | { |
| 53 | 53 | return true; |
| 54 | 54 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | /** |
| 49 | 49 | * Get the services provided by the provider. |
| 50 | 50 | * |
| 51 | - * @return array |
|
| 51 | + * @return string[] |
|
| 52 | 52 | */ |
| 53 | 53 | public function provides() |
| 54 | 54 | { |
@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php namespace Chumper\Datatable; |
| 2 | 2 | |
| 3 | 3 | use Illuminate\Support\ServiceProvider; |
| 4 | -use View; |
|
| 5 | 4 | |
| 6 | 5 | class DatatableServiceProvider extends ServiceProvider { |
| 7 | 6 | |
@@ -5,12 +5,12 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | class DatatableServiceProvider extends ServiceProvider { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * Indicates if loading of the provider is deferred. |
|
| 10 | - * |
|
| 11 | - * @var bool |
|
| 12 | - */ |
|
| 13 | - protected $defer = false; |
|
| 8 | + /** |
|
| 9 | + * Indicates if loading of the provider is deferred. |
|
| 10 | + * |
|
| 11 | + * @var bool |
|
| 12 | + */ |
|
| 13 | + protected $defer = false; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Bootstrap the application events. |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * Register the service provider. |
|
| 33 | - * |
|
| 34 | - * @return void |
|
| 35 | - */ |
|
| 32 | + * Register the service provider. |
|
| 33 | + * |
|
| 34 | + * @return void |
|
| 35 | + */ |
|
| 36 | 36 | public function register() |
| 37 | 37 | { |
| 38 | 38 | |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | __DIR__.'/../../views' => base_path('resources/views/vendor/chumper.datatable'), |
| 25 | 25 | ]); |
| 26 | 26 | |
| 27 | - $this->loadViewsFrom(__DIR__ . '/../../views', 'chumper.datatable'); |
|
| 27 | + $this->loadViewsFrom(__DIR__.'/../../views', 'chumper.datatable'); |
|
| 28 | 28 | |
| 29 | 29 | } |
| 30 | 30 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
| 161 | - * @param $name |
|
| 161 | + * @param string $name |
|
| 162 | 162 | * @return mixed |
| 163 | 163 | */ |
| 164 | 164 | public function getColumn($name) |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | |
| 506 | 506 | /** |
| 507 | 507 | * @param string $columnName |
| 508 | - * @param mixed $value |
|
| 508 | + * @param string $value |
|
| 509 | 509 | */ |
| 510 | 510 | protected function searchOnColumn($columnName, $value) |
| 511 | 511 | { |
@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php namespace Chumper\Datatable\Engines; |
| 2 | 2 | |
| 3 | 3 | use Exception; |
| 4 | -use Assetic\Extension\Twig\AsseticFilterFunction; |
|
| 5 | 4 | use Chumper\Datatable\Columns\DateColumn; |
| 6 | 5 | use Chumper\Datatable\Columns\FunctionColumn; |
| 7 | 6 | use Chumper\Datatable\Columns\TextColumn; |
@@ -324,10 +324,10 @@ |
||
| 324 | 324 | */ |
| 325 | 325 | public function setExactMatchColumns($columnNames) |
| 326 | 326 | { |
| 327 | - foreach($columnNames as $columnIndex) |
|
| 327 | + foreach($columnNames as $columnIndex) |
|
| 328 | 328 | $this->columnSearchExact[ $columnIndex ] = true; |
| 329 | 329 | |
| 330 | - return $this; |
|
| 330 | + return $this; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | public function getRowClass() |
@@ -138,19 +138,18 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function addColumn() |
| 140 | 140 | { |
| 141 | - if(func_num_args() != 2 && func_num_args() != 1) |
|
| 142 | - throw new Exception('Invalid number of arguments'); |
|
| 141 | + if(func_num_args() != 2 && func_num_args() != 1) { |
|
| 142 | + throw new Exception('Invalid number of arguments'); |
|
| 143 | + } |
|
| 143 | 144 | |
| 144 | 145 | if(func_num_args() == 1) |
| 145 | 146 | { |
| 146 | 147 | //add a predefined column |
| 147 | 148 | $this->columns->put(func_get_arg(0)->getName(), func_get_arg(0)); |
| 148 | - } |
|
| 149 | - else if(is_callable(func_get_arg(1))) |
|
| 149 | + } else if(is_callable(func_get_arg(1))) |
|
| 150 | 150 | { |
| 151 | 151 | $this->columns->put(func_get_arg(0), new FunctionColumn(func_get_arg(0), func_get_arg(1))); |
| 152 | - } |
|
| 153 | - else |
|
| 152 | + } else |
|
| 154 | 153 | { |
| 155 | 154 | $this->columns->put(func_get_arg(0), new TextColumn(func_get_arg(0),func_get_arg(1))); |
| 156 | 155 | } |
@@ -214,11 +213,10 @@ discard block |
||
| 214 | 213 | if(in_array($property, array('created_at', 'updated_at'))) |
| 215 | 214 | { |
| 216 | 215 | $this->columns->put($property, new DateColumn($property, DateColumn::DAY_DATE)); |
| 217 | - } |
|
| 218 | - else |
|
| 216 | + } else |
|
| 219 | 217 | { |
| 220 | 218 | $this->columns->put($property, new FunctionColumn($property, function($model) use($property){ |
| 221 | - try{return is_array($model)?$model[$property]:$model->$property;}catch(Exception $e){return null;} |
|
| 219 | + try{return is_array($model)?$model[$property]:$model->$property;} catch(Exception $e){return null;} |
|
| 222 | 220 | })); |
| 223 | 221 | } |
| 224 | 222 | $this->showColumns[] = $property; |
@@ -269,8 +267,9 @@ discard block |
||
| 269 | 267 | $cols = func_get_args(); |
| 270 | 268 | } |
| 271 | 269 | |
| 272 | - if (count($cols) == 1 && $cols[0] == '*') |
|
| 273 | - $cols = $this->showColumns; |
|
| 270 | + if (count($cols) == 1 && $cols[0] == '*') { |
|
| 271 | + $cols = $this->showColumns; |
|
| 272 | + } |
|
| 274 | 273 | |
| 275 | 274 | $this->orderColumns = $cols; |
| 276 | 275 | return $this; |
@@ -324,8 +323,9 @@ discard block |
||
| 324 | 323 | */ |
| 325 | 324 | public function setExactMatchColumns($columnNames) |
| 326 | 325 | { |
| 327 | - foreach($columnNames as $columnIndex) |
|
| 328 | - $this->columnSearchExact[ $columnIndex ] = true; |
|
| 326 | + foreach($columnNames as $columnIndex) { |
|
| 327 | + $this->columnSearchExact[ $columnIndex ] = true; |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | 330 | return $this; |
| 331 | 331 | } |
@@ -393,10 +393,11 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | protected function handleiSortCol_0($value) |
| 395 | 395 | { |
| 396 | - if(Input::get('sSortDir_0') == 'desc') |
|
| 397 | - $direction = BaseEngine::ORDER_DESC; |
|
| 398 | - else |
|
| 399 | - $direction = BaseEngine::ORDER_ASC; |
|
| 396 | + if(Input::get('sSortDir_0') == 'desc') { |
|
| 397 | + $direction = BaseEngine::ORDER_DESC; |
|
| 398 | + } else { |
|
| 399 | + $direction = BaseEngine::ORDER_ASC; |
|
| 400 | + } |
|
| 400 | 401 | |
| 401 | 402 | //check if order is allowed |
| 402 | 403 | if(empty($this->orderColumns)) |
@@ -412,8 +413,7 @@ discard block |
||
| 412 | 413 | if(strpos($c,':') !== FALSE) |
| 413 | 414 | { |
| 414 | 415 | $cleanNames[] = substr($c, 0, strpos($c,':')); |
| 415 | - } |
|
| 416 | - else |
|
| 416 | + } else |
|
| 417 | 417 | { |
| 418 | 418 | $cleanNames[] = $c; |
| 419 | 419 | } |
@@ -440,8 +440,12 @@ discard block |
||
| 440 | 440 | protected function handleSingleColumnSearch($columnIndex, $searchValue) |
| 441 | 441 | { |
| 442 | 442 | //dd($columnIndex, $searchValue, $this->searchColumns); |
| 443 | - if (!isset($this->searchColumns[$columnIndex])) return; |
|
| 444 | - if (empty($searchValue) && $searchValue !== '0') return; |
|
| 443 | + if (!isset($this->searchColumns[$columnIndex])) { |
|
| 444 | + return; |
|
| 445 | + } |
|
| 446 | + if (empty($searchValue) && $searchValue !== '0') { |
|
| 447 | + return; |
|
| 448 | + } |
|
| 445 | 449 | |
| 446 | 450 | $columnName = $this->searchColumns[$columnIndex]; |
| 447 | 451 | $this->searchOnColumn($columnName, $searchValue); |
@@ -463,8 +467,9 @@ discard block |
||
| 463 | 467 | continue; |
| 464 | 468 | } |
| 465 | 469 | |
| 466 | - if(method_exists($this, $function = 'handle'.$key)) |
|
| 467 | - $this->$function($input); |
|
| 470 | + if(method_exists($this, $function = 'handle'.$key)) { |
|
| 471 | + $this->$function($input); |
|
| 472 | + } |
|
| 468 | 473 | } |
| 469 | 474 | } |
| 470 | 475 | |
@@ -481,8 +486,9 @@ discard block |
||
| 481 | 486 | |
| 482 | 487 | protected function prepareSearchColumns() |
| 483 | 488 | { |
| 484 | - if(count($this->searchColumns) == 0 || empty($this->searchColumns)) |
|
| 485 | - $this->searchColumns = $this->showColumns; |
|
| 489 | + if(count($this->searchColumns) == 0 || empty($this->searchColumns)) { |
|
| 490 | + $this->searchColumns = $this->showColumns; |
|
| 491 | + } |
|
| 486 | 492 | } |
| 487 | 493 | |
| 488 | 494 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | { |
| 129 | 129 | $this->columns = new Collection(); |
| 130 | 130 | $this->config = Config::get('chumper.datatable.engine'); |
| 131 | - $this->setExactWordSearch( $this->config['exactWordSearch'] ); |
|
| 131 | + $this->setExactWordSearch($this->config['exactWordSearch']); |
|
| 132 | 132 | return $this; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -138,21 +138,21 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function addColumn() |
| 140 | 140 | { |
| 141 | - if(func_num_args() != 2 && func_num_args() != 1) |
|
| 141 | + if (func_num_args() != 2 && func_num_args() != 1) |
|
| 142 | 142 | throw new Exception('Invalid number of arguments'); |
| 143 | 143 | |
| 144 | - if(func_num_args() == 1) |
|
| 144 | + if (func_num_args() == 1) |
|
| 145 | 145 | { |
| 146 | 146 | //add a predefined column |
| 147 | 147 | $this->columns->put(func_get_arg(0)->getName(), func_get_arg(0)); |
| 148 | 148 | } |
| 149 | - else if(is_callable(func_get_arg(1))) |
|
| 149 | + else if (is_callable(func_get_arg(1))) |
|
| 150 | 150 | { |
| 151 | 151 | $this->columns->put(func_get_arg(0), new FunctionColumn(func_get_arg(0), func_get_arg(1))); |
| 152 | 152 | } |
| 153 | 153 | else |
| 154 | 154 | { |
| 155 | - $this->columns->put(func_get_arg(0), new TextColumn(func_get_arg(0),func_get_arg(1))); |
|
| 155 | + $this->columns->put(func_get_arg(0), new TextColumn(func_get_arg(0), func_get_arg(1))); |
|
| 156 | 156 | } |
| 157 | 157 | return $this; |
| 158 | 158 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function getColumn($name) |
| 165 | 165 | { |
| 166 | - return $this->columns->get($name,null); |
|
| 166 | + return $this->columns->get($name, null); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -205,20 +205,20 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function showColumns($cols) |
| 207 | 207 | { |
| 208 | - if ( ! is_array($cols)) { |
|
| 208 | + if (!is_array($cols)) { |
|
| 209 | 209 | $cols = func_get_args(); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | foreach ($cols as $property) { |
| 213 | 213 | //quick fix for created_at and updated_at columns |
| 214 | - if(in_array($property, array('created_at', 'updated_at'))) |
|
| 214 | + if (in_array($property, array('created_at', 'updated_at'))) |
|
| 215 | 215 | { |
| 216 | 216 | $this->columns->put($property, new DateColumn($property, DateColumn::DAY_DATE)); |
| 217 | 217 | } |
| 218 | 218 | else |
| 219 | 219 | { |
| 220 | 220 | $this->columns->put($property, new FunctionColumn($property, function($model) use($property){ |
| 221 | - try{return is_array($model)?$model[$property]:$model->$property;}catch(Exception $e){return null;} |
|
| 221 | + try {return is_array($model) ? $model[$property] : $model->$property; } catch (Exception $e) {return null; } |
|
| 222 | 222 | })); |
| 223 | 223 | } |
| 224 | 224 | $this->showColumns[] = $property; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | public function searchColumns($cols) |
| 252 | 252 | { |
| 253 | - if ( ! is_array($cols)) { |
|
| 253 | + if (!is_array($cols)) { |
|
| 254 | 254 | $cols = func_get_args(); |
| 255 | 255 | } |
| 256 | 256 | |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | */ |
| 266 | 266 | public function orderColumns($cols) |
| 267 | 267 | { |
| 268 | - if ( ! is_array($cols)) { |
|
| 268 | + if (!is_array($cols)) { |
|
| 269 | 269 | $cols = func_get_args(); |
| 270 | 270 | } |
| 271 | 271 | |
@@ -324,8 +324,8 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | public function setExactMatchColumns($columnNames) |
| 326 | 326 | { |
| 327 | - foreach($columnNames as $columnIndex) |
|
| 328 | - $this->columnSearchExact[ $columnIndex ] = true; |
|
| 327 | + foreach ($columnNames as $columnIndex) |
|
| 328 | + $this->columnSearchExact[$columnIndex] = true; |
|
| 329 | 329 | |
| 330 | 330 | return $this; |
| 331 | 331 | } |
@@ -393,13 +393,13 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | protected function handleiSortCol_0($value) |
| 395 | 395 | { |
| 396 | - if(Input::get('sSortDir_0') == 'desc') |
|
| 396 | + if (Input::get('sSortDir_0') == 'desc') |
|
| 397 | 397 | $direction = BaseEngine::ORDER_DESC; |
| 398 | 398 | else |
| 399 | 399 | $direction = BaseEngine::ORDER_ASC; |
| 400 | 400 | |
| 401 | 401 | //check if order is allowed |
| 402 | - if(empty($this->orderColumns)) |
|
| 402 | + if (empty($this->orderColumns)) |
|
| 403 | 403 | { |
| 404 | 404 | $this->order(array(0 => $value, 1 => $this->getNameByIndex($value)), $direction); |
| 405 | 405 | return; |
@@ -407,11 +407,11 @@ discard block |
||
| 407 | 407 | |
| 408 | 408 | //prepare order array |
| 409 | 409 | $cleanNames = array(); |
| 410 | - foreach($this->orderColumns as $c) |
|
| 410 | + foreach ($this->orderColumns as $c) |
|
| 411 | 411 | { |
| 412 | - if(strpos($c,':') !== FALSE) |
|
| 412 | + if (strpos($c, ':') !== FALSE) |
|
| 413 | 413 | { |
| 414 | - $cleanNames[] = substr($c, 0, strpos($c,':')); |
|
| 414 | + $cleanNames[] = substr($c, 0, strpos($c, ':')); |
|
| 415 | 415 | } |
| 416 | 416 | else |
| 417 | 417 | { |
@@ -420,11 +420,11 @@ discard block |
||
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | $i = 0; |
| 423 | - foreach($this->columns as $name => $column) |
|
| 423 | + foreach ($this->columns as $name => $column) |
|
| 424 | 424 | { |
| 425 | - if($i == $value && in_array($name, $cleanNames)) |
|
| 425 | + if ($i == $value && in_array($name, $cleanNames)) |
|
| 426 | 426 | { |
| 427 | - $this->order(array(0 => $value, 1 => $this->orderColumns[array_search($name,$cleanNames)]), $direction); |
|
| 427 | + $this->order(array(0 => $value, 1 => $this->orderColumns[array_search($name, $cleanNames)]), $direction); |
|
| 428 | 428 | return; |
| 429 | 429 | } |
| 430 | 430 | $i++; |
@@ -458,12 +458,12 @@ discard block |
||
| 458 | 458 | // handle single column search |
| 459 | 459 | if ($this->isParameterForSingleColumnSearch($key)) |
| 460 | 460 | { |
| 461 | - $columnIndex = str_replace('sSearch_','',$key); |
|
| 461 | + $columnIndex = str_replace('sSearch_', '', $key); |
|
| 462 | 462 | $this->handleSingleColumnSearch($columnIndex, $input); |
| 463 | 463 | continue; |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - if(method_exists($this, $function = 'handle'.$key)) |
|
| 466 | + if (method_exists($this, $function = 'handle'.$key)) |
|
| 467 | 467 | $this->$function($input); |
| 468 | 468 | } |
| 469 | 469 | } |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | |
| 482 | 482 | protected function prepareSearchColumns() |
| 483 | 483 | { |
| 484 | - if(count($this->searchColumns) == 0 || empty($this->searchColumns)) |
|
| 484 | + if (count($this->searchColumns) == 0 || empty($this->searchColumns)) |
|
| 485 | 485 | $this->searchColumns = $this->showColumns; |
| 486 | 486 | } |
| 487 | 487 | |
@@ -532,9 +532,9 @@ discard block |
||
| 532 | 532 | public function getNameByIndex($index) |
| 533 | 533 | { |
| 534 | 534 | $i = 0; |
| 535 | - foreach($this->columns as $name => $col) |
|
| 535 | + foreach ($this->columns as $name => $col) |
|
| 536 | 536 | { |
| 537 | - if($index == $i) |
|
| 537 | + if ($index == $i) |
|
| 538 | 538 | { |
| 539 | 539 | return $name; |
| 540 | 540 | } |