@@ -897,6 +897,26 @@ function getThemeFolderList($theme = false) {
897
897
return $ pages ;
898
898
}
899
899
900
+ function getDefaultTemplateList () {
901
+ return [
902
+ 'index.html ' ,
903
+ 'index.coming-soon.html ' ,
904
+ 'index.maintenance.html ' ,
905
+ 'blank.html ' ,
906
+ 'error404.html ' ,
907
+ 'error500.html ' ,
908
+ 'contact.html ' ,
909
+ 'search/index.html ' ,
910
+ 'content/post.html ' ,
911
+ 'content/page.html ' ,
912
+ 'content/index.html ' ,
913
+ 'content/category.html ' ,
914
+ 'product/index.html ' ,
915
+ 'product/product.html ' ,
916
+ 'product/category.html ' ,
917
+ ];
918
+ }
919
+
900
920
function getTemplateList ($ theme = null , $ skip = []) {
901
921
$ friendlyNames = [
902
922
'index ' => ['name ' => __ ('Home page ' ), 'description ' => __ ('Website homepage ' ), 'global ' => true ],
@@ -1487,11 +1507,14 @@ function download($url) {
1487
1507
1488
1508
if (function_exists ('curl_init ' )) {
1489
1509
$ ch = curl_init ($ url );
1490
- curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
1491
- curl_setopt ($ ch , CURLOPT_FAILONERROR , true );
1492
- curl_setopt ($ ch , CURLOPT_USERAGENT , $ _SERVER ['HTTP_USER_AGENT ' ] ?? 'Vvveb ' . V_VERSION );
1493
- $ result = curl_exec ($ ch );
1494
- curl_close ($ ch );
1510
+
1511
+ if ($ ch ) {
1512
+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
1513
+ curl_setopt ($ ch , CURLOPT_FAILONERROR , true );
1514
+ curl_setopt ($ ch , CURLOPT_USERAGENT , $ _SERVER ['HTTP_USER_AGENT ' ] ?? 'Vvveb ' . V_VERSION );
1515
+ $ result = curl_exec ($ ch );
1516
+ curl_close ($ ch );
1517
+ }
1495
1518
} else {
1496
1519
if (ini_get ('allow_url_fopen ' ) == '1 ' ) {
1497
1520
$ context_options = [
@@ -1533,7 +1556,6 @@ function getUrl($url, $cache = true, $expire = 604800, $timeout = 5, $exception
1533
1556
curl_setopt ($ ch , CURLOPT_STDERR , $ streamVerboseHandle );
1534
1557
}
1535
1558
$ result = curl_exec ($ ch );
1536
- curl_close ($ ch );
1537
1559
1538
1560
if ($ result ) {
1539
1561
if ($ cache ) {
@@ -1554,6 +1576,8 @@ function getUrl($url, $cache = true, $expire = 604800, $timeout = 5, $exception
1554
1576
throw new \Exception ($ message );
1555
1577
}
1556
1578
}
1579
+
1580
+ curl_close ($ ch );
1557
1581
} else {
1558
1582
//try with file get contents
1559
1583
if (ini_get ('allow_url_fopen ' ) == '1 ' ) {
@@ -1768,7 +1792,8 @@ function array2xml($array, $xml = false) {
1768
1792
}
1769
1793
1770
1794
if ($ name ) {
1771
- $ attributes [$ name ] = '' ;
1795
+ $ name = explode ('= ' , $ name );
1796
+ $ attributes [$ name [0 ]] = trim ($ name [1 ] ?? '' , '\'" ' );
1772
1797
}
1773
1798
}
1774
1799
@@ -1806,6 +1831,12 @@ function array2xml($array, $xml = false) {
1806
1831
return $ xml ->asXML ();
1807
1832
}
1808
1833
1834
+ function removeJsonComments ($ json ) {
1835
+ $ json = preg_replace ('@^\s*//.*([\r\n]|\s)*|^\s*/\*([\r\n]|.)*?\*/([\r\n]|\s)*@m ' , '' , $ json );
1836
+
1837
+ return $ json ;
1838
+ }
1839
+
1809
1840
function prepareJson ($ array ) {
1810
1841
if (! is_array ($ array )) {
1811
1842
return ;
@@ -1834,14 +1865,18 @@ function prepareJson($array) {
1834
1865
return $ helper ;
1835
1866
}
1836
1867
1837
- function reconstructJson ($ array ) {
1868
+ function reconstructJson (& $ array, $ removeAttrs = false ) {
1838
1869
if (! is_iterable ($ array )) {
1839
1870
return ;
1840
1871
}
1841
1872
$ helper = [];
1842
1873
$ array = (array )$ array ;
1843
1874
1844
1875
foreach ($ array as $ key => $ value ) {
1876
+ if ($ removeAttrs && $ key == '@attributes ' ) {
1877
+ continue ;
1878
+ }
1879
+
1845
1880
if (substr_compare ($ key , 'n-- ' , 0 , 3 ) === 0 ) {
1846
1881
$ newkey = substr ($ key , 3 );
1847
1882
@@ -1858,7 +1893,7 @@ function reconstructJson($array) {
1858
1893
$ key = '@ ' . substr ($ key , 0 , -6 );
1859
1894
}
1860
1895
1861
- $ helper [$ key ] = (is_iterable ($ value )) ? reconstructJson ($ value ) : $ value ;
1896
+ $ helper [$ key ] = (is_iterable ($ value )) ? reconstructJson ($ value, $ removeAttrs ) : $ value ;
1862
1897
}
1863
1898
1864
1899
return $ helper ;
0 commit comments