-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c26ddb
commit feb813b
Showing
6 changed files
with
72 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,14 @@ | |
/** | ||
* Function arrayToObject | ||
* | ||
* @param array $array | ||
* @param array|mixed $array | ||
* | ||
* @return array|false|\stdClass | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 07/27/2021 36:10 | ||
*/ | ||
function arrayToObject(array $array = array()) | ||
function arrayToObject($array = array()) | ||
{ | ||
if (!is_array($array)) { | ||
return $array; | ||
|
@@ -43,15 +43,15 @@ function arrayToObject(array $array = array()) | |
/** | ||
* Function arrayToXml | ||
* | ||
* @param array $array | ||
* @param string $namespace | ||
* @param null $file_output | ||
* @param array|mixed $array | ||
* @param string $namespace | ||
* @param null $file_output | ||
* | ||
* @return bool|string|null | ||
* @throws \Exception | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 08/07/2021 19:29 | ||
* @time : 08/20/2021 13:21 | ||
*/ | ||
function arrayToXml($array = array(), $namespace = '', $file_output = NULL) | ||
{ | ||
|
@@ -60,7 +60,7 @@ function arrayToXml($array = array(), $namespace = '', $file_output = NULL) | |
convertArrayToXml($array, $xml_object); // function call to convert array to xml | ||
$xml_file = $file_output !== NULL ? $xml_object->asXML($file_output) : $xml_object->asXML(); // saving generated xml file | ||
|
||
return $xml_file ? $xml_file : NULL; | ||
return !empty($xml_file) ? $xml_file : NULL; | ||
} | ||
|
||
return NULL; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ | |
/** | ||
* Function assets_url | ||
* | ||
* @param string $uri | ||
* @param null $protocol | ||
* @param string $uri | ||
* @param null|string $protocol | ||
* | ||
* @return string | ||
* @author : 713uk13m <[email protected]> | ||
|
@@ -40,8 +40,8 @@ function assets_url($uri = '', $protocol = NULL) | |
/** | ||
* Function templates_url | ||
* | ||
* @param string $uri | ||
* @param null $protocol | ||
* @param string $uri | ||
* @param null|string $protocol | ||
* | ||
* @return string | ||
* @author : 713uk13m <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,9 @@ | |
/** | ||
* Function google_image_resize | ||
* | ||
* @param string $url | ||
* @param int $width | ||
* @param null $height | ||
* @param string $url | ||
* @param int $width | ||
* @param null|int $height | ||
* | ||
* @return string | ||
* @author : 713uk13m <[email protected]> | ||
|
@@ -22,22 +22,7 @@ | |
*/ | ||
function google_image_resize($url = '', $width = 100, $height = NULL) | ||
{ | ||
$proxyUrl = 'https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy'; | ||
$proxyContainer = 'focus'; | ||
$proxyRefresh = 2592000; | ||
// Start | ||
$params = array(); | ||
$params['url'] = $url; | ||
$params['resize_w'] = $width; | ||
if (!empty($height)) { | ||
$params['resize_h'] = $height; | ||
} | ||
$params['container'] = $proxyContainer; | ||
$params['refresh'] = $proxyRefresh; | ||
// Result URL | ||
$url = $proxyUrl . '?' . urldecode(http_build_query($params)); | ||
|
||
return trim($url); | ||
return nguyenanhung\CodeIgniter\BasicHelper\ImageHelper::googleGadgetsProxy($url, $width, $height); | ||
} | ||
} | ||
if (!function_exists('wordpress_proxy')) { | ||
|
@@ -54,11 +39,6 @@ function google_image_resize($url = '', $width = 100, $height = NULL) | |
*/ | ||
function wordpress_proxy($imageUrl = '', $server = 'i3') | ||
{ | ||
$imageUrl = str_replace('https://', '', $imageUrl); | ||
$imageUrl = str_replace('http://', '', $imageUrl); | ||
$imageUrl = str_replace('//', '', $imageUrl); | ||
$url = 'https://' . trim($server) . '.wp.com/' . $imageUrl; | ||
|
||
return trim($url); | ||
return nguyenanhung\CodeIgniter\BasicHelper\ImageHelper::wordpressProxy($imageUrl, $server); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
/** | ||
* Function getIPAddress | ||
* | ||
* @param false $convertToInteger | ||
* @param bool $convertToInteger | ||
* | ||
* @return false|int|string | ||
* @author : 713uk13m <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,57 @@ | |
class ImageHelper implements ProjectInterface | ||
{ | ||
use VersionTrait; | ||
|
||
/** | ||
* Function googleGadgetsProxy | ||
* | ||
* @param string $url | ||
* @param int $width | ||
* @param null|int $height | ||
* | ||
* @return string | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 08/20/2021 11:20 | ||
*/ | ||
public static function googleGadgetsProxy($url = '', $width = 100, $height = NULL) | ||
{ | ||
$proxyUrl = 'https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy'; | ||
$proxyContainer = 'focus'; | ||
$proxyRefresh = 2592000; | ||
// Start | ||
$params = array(); | ||
$params['url'] = $url; | ||
$params['resize_w'] = $width; | ||
if (!empty($height)) { | ||
$params['resize_h'] = $height; | ||
} | ||
$params['container'] = $proxyContainer; | ||
$params['refresh'] = $proxyRefresh; | ||
// Result URL | ||
$url = $proxyUrl . '?' . urldecode(http_build_query($params)); | ||
|
||
return trim($url); | ||
} | ||
|
||
/** | ||
* Function wordpressProxy | ||
* | ||
* @param string $imageUrl | ||
* @param string $server | ||
* | ||
* @return string | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 08/20/2021 11:39 | ||
*/ | ||
public static function wordpressProxy($imageUrl = '', $server = 'i3') | ||
{ | ||
$imageUrl = str_replace('https://', '', $imageUrl); | ||
$imageUrl = str_replace('http://', '', $imageUrl); | ||
$imageUrl = str_replace('//', '', $imageUrl); | ||
$url = 'https://' . trim($server) . '.wp.com/' . $imageUrl; | ||
|
||
return trim($url); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
*/ | ||
interface ProjectInterface | ||
{ | ||
const VERSION = '1.0.0'; | ||
const LAST_MODIFIED = '2021-08-07'; | ||
const VERSION = '1.0.1'; | ||
const LAST_MODIFIED = '2021-08-20'; | ||
const AUTHOR_NAME = 'Hung Nguyen'; | ||
const AUTHOR_EMAIL = '[email protected]'; | ||
const PROJECT_NAME = 'CodeIgniter - Basic Helper'; | ||
|