<plugin name="cordova-plugin-device" spec="2.0.2" /> 100
+    <plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
101
+    <plugin name="cordova-plugin-ionic-webview" spec="^5.0.0" />
102
+    <plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
103
+</widget>

+ 4 - 1
ionic.config.json

@@ -1,7 +1,10 @@
1 1
 {
2 2
   "name": "farmr3",
3 3
   "integrations": {
4
-    "capacitor": {}
4
+    "capacitor": {
5
+      "enabled": false
6
+    },
7
+    "cordova": {}
5 8
   },
6 9
   "type": "angular"
7 10
 }

Разлика између датотеке није приказан због своје велике величине
+ 1698 - 17353
package-lock.json


+ 97 - 2
package.json

@@ -19,13 +19,43 @@
19 19
     "@angular/platform-browser": "~13.2.2",
20 20
     "@angular/platform-browser-dynamic": "~13.2.2",
21 21
     "@angular/router": "~13.2.2",
22
+    "@awesome-cordova-plugins/barcode-scanner": "^5.37.1",
23
+    "@awesome-cordova-plugins/core": "^5.37.1",
24
+    "@awesome-cordova-plugins/file-transfer": "^5.37.1",
25
+    "@awesome-cordova-plugins/native-geocoder": "^5.41.0",
26
+    "@awesome-cordova-plugins/push": "^5.37.1",
27
+    "@awesome-cordova-plugins/status-bar": "^5.37.2",
28
+    "@awesome-cordova-plugins/stripe": "^5.37.1",
22 29
     "@capacitor/app": "1.1.1",
23 30
     "@capacitor/core": "3.5.0",
24 31
     "@capacitor/haptics": "1.1.4",
32
+    "@capacitor/ios": "3.5.0",
25 33
     "@capacitor/keyboard": "1.2.2",
26 34
     "@capacitor/status-bar": "1.0.8",
35
+    "@fortawesome/angular-fontawesome": "^0.10.1",
36
+    "@fortawesome/fontawesome-free": "^5.15.4",
37
+    "@fortawesome/fontawesome-svg-core": "^1.2.36",
38
+    "@fortawesome/free-brands-svg-icons": "^5.15.4",
39
+    "@fortawesome/free-regular-svg-icons": "^5.15.4",
40
+    "@fortawesome/free-solid-svg-icons": "^5.15.4",
41
+    "@ionic-native/android-permissions": "^5.30.0",
42
+    "@ionic-native/call-number": "^5.36.0",
43
+    "@ionic-native/core": "^5.36.0",
44
+    "@ionic-native/device": "^5.30.0",
45
+    "@ionic-native/email-composer": "^5.36.0",
46
+    "@ionic-native/facebook": "^5.36.0",
47
+    "@ionic-native/geolocation": "^5.36.0",
48
+    "@ionic-native/http": "^5.36.0",
49
+    "@ionic-native/in-app-browser": "^5.36.0",
50
+    "@ionic-native/native-geocoder": "^5.36.0",
51
+    "@ionic-native/paypal": "^5.30.0",
52
+    "@ionic-native/push": "^5.36.0",
53
+    "@ionic-native/sign-in-with-apple": "^5.36.0",
54
+    "@ionic-native/uid": "^5.30.0",
27 55
     "@ionic/angular": "^6.0.0",
56
+    "@ionic/cordova-builders": "^6.1.0",
28 57
     "rxjs": "~6.6.0",
58
+    "sharp": "^0.30.4",
29 59
     "tslib": "^2.2.0",
30 60
     "zone.js": "~0.11.4"
31 61
   },
@@ -41,11 +71,36 @@
41 71
     "@angular/language-service": "~13.2.2",
42 72
     "@capacitor/cli": "3.5.0",
43 73
     "@ionic/angular-toolkit": "^6.0.0",
74
+    "@ionic/storage-angular": "^3.0.6",
44 75
     "@types/jasmine": "~3.6.0",
45 76
     "@types/jasminewd2": "~2.0.3",
46 77
     "@types/node": "^12.11.1",
47 78
     "@typescript-eslint/eslint-plugin": "5.3.0",
48 79
     "@typescript-eslint/parser": "5.3.0",
80
+    "cordova-ios": "^6.2.0",
81
+    "cordova-plugin-add-swift-support": "^2.0.2",
82
+    "cordova-plugin-advanced-http": "^3.2.2",
83
+    "cordova-plugin-android-permissions": "^1.1.2",
84
+    "cordova-plugin-androidx": "^3.0.0",
85
+    "cordova-plugin-androidx-adapter": "^1.1.3",
86
+    "cordova-plugin-device": "2.0.2",
87
+    "cordova-plugin-email-composer": "^0.10.0",
88
+    "cordova-plugin-facebook-connect": "^3.2.0",
89
+    "cordova-plugin-file": "^6.0.2",
90
+    "cordova-plugin-file-transfer": "^1.7.1",
91
+    "cordova-plugin-geolocation": "^4.1.0",
92
+    "cordova-plugin-googlemaps": "^2.7.1",
93
+    "cordova-plugin-googlemaps-sdk": "github:mapsplugin/cordova-plugin-googlemaps-sdk",
94
+    "cordova-plugin-inappbrowser": "^5.0.0",
95
+    "cordova-plugin-ionic-keyboard": "^2.2.0",
96
+    "cordova-plugin-ionic-webview": "^5.0.0",
97
+    "cordova-plugin-nativegeocoder": "^3.4.1",
98
+    "cordova-plugin-sign-in-with-apple": "^0.1.2",
99
+    "cordova-plugin-splashscreen": "5.0.2",
100
+    "cordova-plugin-statusbar": "2.4.2",
101
+    "cordova-plugin-stripe": "^1.5.3",
102
+    "cordova-plugin-uid": "^1.3.0",
103
+    "cordova-support-google-services": "^1.4.1",
49 104
     "eslint": "^7.6.0",
50 105
     "eslint-plugin-import": "2.22.1",
51 106
     "eslint-plugin-jsdoc": "30.7.6",
@@ -58,9 +113,49 @@
58 113
     "karma-coverage-istanbul-reporter": "~3.0.2",
59 114
     "karma-jasmine": "~4.0.0",
60 115
     "karma-jasmine-html-reporter": "^1.5.0",
116
+    "mx.ferreyra.callnumber": "0.0.2",
61 117
     "protractor": "~7.0.0",
62 118
     "ts-node": "~8.3.0",
63 119
     "typescript": "~4.4.4"
64 120
   },
65
-  "description": "An Ionic project"
66
-}
121
+  "description": "An Ionic project",
122
+  "cordova": {
123
+    "plugins": {
124
+      "cordova-plugin-statusbar": {},
125
+      "cordova-plugin-device": {},
126
+      "cordova-plugin-splashscreen": {},
127
+      "cordova-plugin-ionic-webview": {},
128
+      "cordova-plugin-ionic-keyboard": {},
129
+      "cordova-plugin-geolocation": {},
130
+      "cordova-plugin-nativegeocoder": {
131
+        "LOCATION_WHEN_IN_USE_DESCRIPTION": "Use geocoder service"
132
+      },
133
+      "mx.ferreyra.callnumber": {},
134
+      "cordova-plugin-email-composer": {},
135
+      "call-number": {},
136
+      "cordova-plugin-inappbrowser": {},
137
+      "cordova-plugin-sign-in-with-apple": {},
138
+      "cordova-plugin-androidx": {},
139
+      "cordova-plugin-androidx-adapter": {},
140
+      "phonegap-plugin-push": {},
141
+      "cordova-plugin-file-transfer": {},
142
+      "cordova-plugin-stripe": {},
143
+      "com.paypal.cordova.mobilesdk": {},
144
+      "cordova-plugin-facebook-connect": {
145
+        "APP_ID": "4746807965342529",
146
+        "APP_NAME": "FarmSter",
147
+        "FACEBOOK_URL_SCHEME_SUFFIX": " ",
148
+        "OTHER_APP_SCHEMES": " ",
149
+        "FACEBOOK_AUTO_LOG_APP_EVENTS": "true",
150
+        "FACEBOOK_HYBRID_APP_EVENTS": "false",
151
+        "FACEBOOK_ADVERTISER_ID_COLLECTION": "true",
152
+        "FACEBOOK_ANDROID_SDK_VERSION": "11.3.0",
153
+        "FACEBOOK_IOS_SDK_VERSION": "11.1.0",
154
+        "FACEBOOK_BROWSER_SDK_VERSION": "v11.0"
155
+      }
156
+    },
157
+    "platforms": [
158
+      "ios"
159
+    ]
160
+  }
161
+}

+ 8 - 0
resources/README.md

@@ -0,0 +1,8 @@
1
+These are Cordova resources. You can replace icon.png and splash.png and run
2
+`ionic cordova resources` to generate custom icons and splash screens for your
3
+app. See `ionic cordova resources --help` for details.
4
+
5
+Cordova reference documentation:
6
+
7
+- Icons: https://cordova.apache.org/docs/en/latest/config_ref/images.html
8
+- Splash Screens: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/

BIN
resources/android/icon/drawable-hdpi-icon.png


BIN
resources/android/icon/drawable-ldpi-icon.png


BIN
resources/android/icon/drawable-mdpi-icon.png


BIN
resources/android/icon/drawable-xhdpi-icon.png


BIN
resources/android/icon/drawable-xxhdpi-icon.png


BIN
resources/android/icon/drawable-xxxhdpi-icon.png


BIN
resources/android/splash/drawable-land-hdpi-screen.png


BIN
resources/android/splash/drawable-land-ldpi-screen.png


BIN
resources/android/splash/drawable-land-mdpi-screen.png


BIN
resources/android/splash/drawable-land-xhdpi-screen.png


BIN
resources/android/splash/drawable-land-xxhdpi-screen.png


BIN
resources/android/splash/drawable-land-xxxhdpi-screen.png


BIN
resources/android/splash/drawable-port-hdpi-screen.png


BIN
resources/android/splash/drawable-port-ldpi-screen.png


BIN
resources/android/splash/drawable-port-mdpi-screen.png


BIN
resources/android/splash/drawable-port-xhdpi-screen.png


BIN
resources/android/splash/drawable-port-xxhdpi-screen.png


BIN
resources/android/splash/drawable-port-xxxhdpi-screen.png


+ 7 - 0
resources/android/xml/network_security_config.xml

@@ -0,0 +1,7 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<network-security-config>
3
+    <domain-config cleartextTrafficPermitted="true">
4
+        <domain includeSubdomains="true">localhost</domain>
5
+        <domain includeSubdomains="true">tamtime.iamarray.xyz</domain>
6
+    </domain-config>
7
+</network-security-config>

BIN
resources/icon.png


BIN
resources/ios/icon/icon-1024.png


BIN
resources/ios/icon/icon-108@2x.png


BIN
resources/ios/icon/icon-20.png


BIN
resources/ios/icon/icon-20@2x.png


BIN
resources/ios/icon/icon-20@3x.png


BIN
resources/ios/icon/icon-24@2x.png


BIN
resources/ios/icon/icon-27.5@2x.png


BIN
resources/ios/icon/icon-29.png


BIN
resources/ios/icon/icon-29@2x.png


BIN
resources/ios/icon/icon-29@3x.png


BIN
resources/ios/icon/icon-40.png


BIN
resources/ios/icon/icon-40@2x.png


BIN
resources/ios/icon/icon-40@3x.png


BIN
resources/ios/icon/icon-44@2x.png


BIN
resources/ios/icon/icon-50.png


BIN
resources/ios/icon/icon-50@2x.png


BIN
resources/ios/icon/icon-60.png


BIN
resources/ios/icon/icon-60@2x.png


BIN
resources/ios/icon/icon-60@3x.png


BIN
resources/ios/icon/icon-72.png


BIN
resources/ios/icon/icon-72@2x.png


BIN
resources/ios/icon/icon-76.png


BIN
resources/ios/icon/icon-76@2x.png


BIN
resources/ios/icon/icon-83.5@2x.png


BIN
resources/ios/icon/icon-86@2x.png


BIN
resources/ios/icon/icon-98@2x.png


BIN
resources/ios/icon/icon.png


BIN
resources/ios/icon/icon@2x.png


BIN
resources/ios/splash/Default-1792h~iphone.png


BIN
resources/ios/splash/Default-2436h.png


BIN
resources/ios/splash/Default-2688h~iphone.png


BIN
resources/ios/splash/Default-568h@2x~iphone.png


BIN
resources/ios/splash/Default-667h.png


BIN
resources/ios/splash/Default-736h.png


BIN
resources/ios/splash/Default-Landscape-1792h~iphone.png


BIN
resources/ios/splash/Default-Landscape-2436h.png


BIN
resources/ios/splash/Default-Landscape-2688h~iphone.png


BIN
resources/ios/splash/Default-Landscape-736h.png


BIN
resources/ios/splash/Default-Landscape@2x~ipad.png


BIN
resources/ios/splash/Default-Landscape@~ipadpro.png


BIN
resources/ios/splash/Default-Landscape~ipad.png


BIN
resources/ios/splash/Default-Portrait@2x~ipad.png


BIN
resources/ios/splash/Default-Portrait@~ipadpro.png


BIN
resources/ios/splash/Default-Portrait~ipad.png


BIN
resources/ios/splash/Default@2x~iphone.png


BIN
resources/ios/splash/Default@2x~universal~anyany.png


BIN
resources/ios/splash/Default~iphone.png


BIN
resources/splash.png


+ 76 - 0
src/app/app-routing.module.ts

@@ -5,6 +5,82 @@ const routes: Routes = [
5 5
   {
6 6
     path: '',
7 7
     loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule)
8
+  },
9
+  {
10
+    path: 'home',
11
+    loadChildren: () => import('./home/home.module').then( m => m.HomePageModule)
12
+  },
13
+  {
14
+    path: 'register',
15
+    loadChildren: () => import('./register/register.module').then( m => m.RegisterPageModule)
16
+  },
17
+  {
18
+    path: 'login',
19
+    loadChildren: () => import('./login/login.module').then( m => m.LoginPageModule)
20
+  },
21
+  {
22
+    path: 'forgot-password',
23
+    loadChildren: () => import('./forgot-password/forgot-password.module').then( m => m.ForgotPasswordPageModule)
24
+  },
25
+  {
26
+    path: 'register-form',
27
+    loadChildren: () => import('./register-form/register-form.module').then( m => m.RegisterFormPageModule)
28
+  },
29
+  {
30
+    path: 'profile',
31
+    loadChildren: () => import('./profile/profile.module').then( m => m.ProfilePageModule)
32
+  },
33
+  {
34
+    path: 'reset-password',
35
+    loadChildren: () => import('./reset-password/reset-password.module').then( m => m.ResetPasswordPageModule)
36
+  },
37
+  {
38
+    path: 'placedetail',
39
+    loadChildren: () => import('./placedetail/placedetail.module').then( m => m.PlacedetailPageModule)
40
+  },
41
+  {
42
+    path: 'place',
43
+    loadChildren: () => import('./place/place.module').then( m => m.PlacePageModule)
44
+  },
45
+  {
46
+    path: 'province',
47
+    loadChildren: () => import('./province/province.module').then( m => m.ProvincePageModule)
48
+  },
49
+  {
50
+    path: 'gmap',
51
+    loadChildren: () => import('./gmap/gmap.module').then( m => m.GmapPageModule)
52
+  },
53
+  {
54
+    path: 'nearme',
55
+    loadChildren: () => import('./nearme/nearme.module').then( m => m.NearmePageModule)
56
+  },
57
+  {
58
+    path: 'sample',
59
+    loadChildren: () => import('./sample/sample.module').then( m => m.SamplePageModule)
60
+  },
61
+  {
62
+    path: 'product',
63
+    loadChildren: () => import('./product/product.module').then( m => m.ProductPageModule)
64
+  },
65
+  {
66
+    path: 'product-detail',
67
+    loadChildren: () => import('./product-detail/product-detail.module').then( m => m.ProductDetailPageModule)
68
+  },
69
+  {
70
+    path: 'tracking',
71
+    loadChildren: () => import('./tracking/tracking.module').then( m => m.TrackingPageModule)
72
+  },
73
+  {
74
+    path: 'news',
75
+    loadChildren: () => import('./news/news.module').then( m => m.NewsPageModule)
76
+  },
77
+  {
78
+    path: 'checkout',
79
+    loadChildren: () => import('./checkout/checkout.module').then( m => m.CheckoutPageModule)
80
+  },
81
+  {
82
+    path: 'pay',
83
+    loadChildren: () => import('./pay/pay.module').then( m => m.PayPageModule)
8 84
   }
9 85
 ];
10 86
 @NgModule({

+ 4 - 0
src/app/app.component.scss

@@ -0,0 +1,4 @@
1
+.product-title {
2
+    font-weight:bold;
3
+    font-size:20px;
4
+}

+ 43 - 1
src/app/app.component.ts

@@ -1,4 +1,9 @@
1 1
 import { Component } from '@angular/core';
2
+import { Storage } from '@ionic/storage-angular';
3
+import { StatusBar } from '@awesome-cordova-plugins/status-bar/ngx';
4
+import { Uid } from '@ionic-native/uid/ngx';
5
+import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
6
+
2 7
 
3 8
 @Component({
4 9
   selector: 'app-root',
@@ -6,5 +11,42 @@ import { Component } from '@angular/core';
6 11
   styleUrls: ['app.component.scss'],
7 12
 })
8 13
 export class AppComponent {
9
-  constructor() {}
14
+    constructor(private storage: Storage, private statusBar:StatusBar, private uid: Uid, private androidPermissions: AndroidPermissions) {
15
+
16
+        this.statusBar.overlaysWebView(true);
17
+
18
+
19
+    }
20
+    openQRCode() {
21
+        console.log("open QR Code");
22
+    }
23
+    async ngOnInit() {
24
+        // If using a custom driver:
25
+        // await this.storage.defineDriver(MyCustomDriver)
26
+        await this.storage.create();
27
+        //await this.getImei();
28
+    }
29
+    async getImei() {
30
+        const { hasPermission } = await this.androidPermissions.checkPermission(
31
+            this.androidPermissions.PERMISSION.READ_PHONE_STATE
32
+        );
33
+        console.log(hasPermission);
34
+
35
+        if (!hasPermission) {
36
+            const result = await this.androidPermissions.requestPermission(
37
+                this.androidPermissions.PERMISSION.READ_PHONE_STATE
38
+            );
39
+
40
+            if (!result.hasPermission) {
41
+                throw new Error('Permissions required');
42
+            }
43
+
44
+            // ok, a user gave us permission, we can get him identifiers after restart app
45
+            return;
46
+        }
47
+        console.log("UUID");
48
+        console.log(this.uid.UUID);
49
+        await this.storage.set('uid', this.uid.UUID);
50
+        return this.uid.IMEI
51
+    }
10 52
 }

+ 66 - 6
src/app/app.module.ts

@@ -7,11 +7,71 @@ import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
7 7
 import { AppRoutingModule } from './app-routing.module';
8 8
 import { AppComponent } from './app.component';
9 9
 
10
+import { HttpClientModule, HttpClient} from '@angular/common/http';
11
+
12
+// import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
13
+// import { library } from '@fortawesome/fontawesome-svg-core';
14
+import { FontAwesomeModule, FaIconLibrary } from '@fortawesome/angular-fontawesome';
15
+import { fas } from '@fortawesome/free-solid-svg-icons';
16
+import { far } from '@fortawesome/free-regular-svg-icons';
17
+import { fab } from '@fortawesome/free-brands-svg-icons';
18
+
19
+import { Geolocation } from '@ionic-native/geolocation/ngx';
20
+import { NativeGeocoder } from '@ionic-native/native-geocoder/ngx';
21
+
22
+import { CallNumber } from '@ionic-native/call-number/ngx';
23
+import { EmailComposer } from '@ionic-native/email-composer/ngx';
24
+import { HTTP } from '@ionic-native/http/ngx';
25
+import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
26
+
27
+import { IonicStorageModule } from '@ionic/storage-angular';
28
+import { SignInWithApple } from '@ionic-native/sign-in-with-apple/ngx';
29
+
30
+import { PipeModule } from './pipe/pipe.module';
31
+import { Facebook } from '@ionic-native/facebook/ngx';
32
+
33
+import { BarcodeScanner } from '@awesome-cordova-plugins/barcode-scanner/ngx';
34
+import { PayPal } from '@ionic-native/paypal/ngx';
35
+import { StatusBar } from '@awesome-cordova-plugins/status-bar/ngx';
36
+import { Uid } from '@ionic-native/uid/ngx';
37
+import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
38
+import { Device } from '@ionic-native/device/ngx';
39
+
40
+//import { Stripe } from '@awesome-cordova-plugins/stripe/ngx';
41
+
42
+
43
+// import { IonicImageViewerModule } from 'ionic-img-viewer';
44
+
45
+
46
+// library.add(fas,far,fab);
47
+
10 48
 @NgModule({
11
-  declarations: [AppComponent],
12
-  entryComponents: [],
13
-  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
14
-  providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
15
-  bootstrap: [AppComponent],
49
+    declarations: [AppComponent],
50
+    entryComponents: [],
51
+    imports: [HttpClientModule, BrowserModule, PipeModule,IonicModule.forRoot({_forceStatusbarPadding: true}), AppRoutingModule, FontAwesomeModule,   IonicStorageModule.forRoot()],
52
+    providers: [
53
+        Geolocation,
54
+        NativeGeocoder,
55
+        CallNumber,
56
+        EmailComposer,
57
+        InAppBrowser,
58
+        HTTP,
59
+        Facebook, 
60
+        StatusBar,
61
+        BarcodeScanner,
62
+        SignInWithApple,
63
+        PayPal,
64
+        AndroidPermissions,
65
+        Uid,
66
+        Device,
67
+        //Stripe,
68
+        { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
69
+    ],
70
+    bootstrap: [AppComponent],
16 71
 })
17
-export class AppModule {}
72
+export class AppModule {
73
+    constructor(library: FaIconLibrary) {
74
+        library.addIconPacks(fas, fab, far);
75
+    }
76
+
77
+}

+ 17 - 0
src/app/checkout/checkout-routing.module.ts

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+
4
+import { CheckoutPage } from './checkout.page';
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: CheckoutPage
10
+  }
11
+];
12
+
13
+@NgModule({
14
+  imports: [RouterModule.forChild(routes)],
15
+  exports: [RouterModule],
16
+})
17
+export class CheckoutPageRoutingModule {}

+ 20 - 0
src/app/checkout/checkout.module.ts

@@ -0,0 +1,20 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { FormsModule } from '@angular/forms';
4
+
5
+import { IonicModule } from '@ionic/angular';
6
+
7
+import { CheckoutPageRoutingModule } from './checkout-routing.module';
8
+
9
+import { CheckoutPage } from './checkout.page';
10
+
11
+@NgModule({
12
+  imports: [
13
+    CommonModule,
14
+    FormsModule,
15
+    IonicModule,
16
+    CheckoutPageRoutingModule
17
+  ],
18
+  declarations: [CheckoutPage]
19
+})
20
+export class CheckoutPageModule {}

+ 81 - 0
src/app/checkout/checkout.page.html

@@ -0,0 +1,81 @@
1
+<ion-header>
2
+  <ion-toolbar class='new-background-color'>
3
+    <ion-title>Checkout</ion-title>
4
+      <ion-buttons slot="end">
5
+          <ion-button (click)="dismiss()" color="light">
6
+            <ion-icon name="close-circle-outline"></ion-icon>
7
+          </ion-button>
8
+      </ion-buttons>
9
+  </ion-toolbar>
10
+</ion-header>
11
+
12
+<ion-content>
13
+    <ion-list>
14
+        <ion-list-header>
15
+            Recent Items
16
+        </ion-list-header>
17
+
18
+        <ion-item-sliding>
19
+            <ion-item>
20
+            <ion-avatar slot="start">
21
+                <img src="assets/images/fresh-durian.jpeg">
22
+            </ion-avatar>
23
+            <ion-label>
24
+                <h2>Durian</h2>
25
+                <p>Size M</p>
26
+            </ion-label>
27
+            <ion-label slot='end'>
28
+                3 * 100.00 = 
29
+            </ion-label>
30
+            <ion-label slot='end'>
31
+                300.00 THB
32
+            </ion-label>
33
+            </ion-item>
34
+            <ion-item-options side="end">
35
+                <ion-item-option (click)="unread(item)" color='danger'>Remove</ion-item-option>
36
+            </ion-item-options>
37
+        </ion-item-sliding>
38
+        <ion-item>
39
+            <ion-avatar slot="start">
40
+                <img src="assets/images/fresh-durian.jpeg">
41
+            </ion-avatar>
42
+            <ion-label>
43
+                <h2>Durian</h2>
44
+                <p>Size M</p>
45
+            </ion-label>
46
+            <ion-label slot='end'>
47
+                3 * 100 = 
48
+            </ion-label>
49
+            <ion-label slot='end'>
50
+                300.00 THB
51
+            </ion-label>
52
+        </ion-item>
53
+        <ion-item>
54
+            <ion-label slot="end">
55
+                <h2>Sub Total = </h2>
56
+            </ion-label>
57
+            <ion-label slot='end'>
58
+               600.00 THB
59
+            </ion-label>
60
+        </ion-item>
61
+        <ion-item>
62
+            <ion-label slot="end">
63
+                <h2>Vat 7%  = </h2>
64
+            </ion-label>
65
+            <ion-label slot='end'>
66
+               42.00 THB
67
+            </ion-label>
68
+        </ion-item>
69
+        <ion-item>
70
+            <ion-label slot="end">
71
+                <h2>Total = </h2>
72
+            </ion-label>
73
+            <ion-label slot='end'>
74
+               642.00 THB
75
+            </ion-label>
76
+        </ion-item>
77
+    </ion-list>
78
+    <ion-button expand="full" color="success" (click)="payWithPaypal()">Pay with PayPal</ion-button>
79
+
80
+
81
+</ion-content>

+ 0 - 0
src/app/checkout/checkout.page.scss


+ 24 - 0
src/app/checkout/checkout.page.spec.ts

@@ -0,0 +1,24 @@
1
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2
+import { IonicModule } from '@ionic/angular';
3
+
4
+import { CheckoutPage } from './checkout.page';
5
+
6
+describe('CheckoutPage', () => {
7
+  let component: CheckoutPage;
8
+  let fixture: ComponentFixture<CheckoutPage>;
9
+
10
+  beforeEach(waitForAsync(() => {
11
+    TestBed.configureTestingModule({
12
+      declarations: [ CheckoutPage ],
13
+      imports: [IonicModule.forRoot()]
14
+    }).compileComponents();
15
+
16
+    fixture = TestBed.createComponent(CheckoutPage);
17
+    component = fixture.componentInstance;
18
+    fixture.detectChanges();
19
+  }));
20
+
21
+  it('should create', () => {
22
+    expect(component).toBeTruthy();
23
+  });
24
+});

+ 56 - 0
src/app/checkout/checkout.page.ts

@@ -0,0 +1,56 @@
1
+import { Component, OnInit } from '@angular/core';
2
+import { ModalController, Platform } from '@ionic/angular';
3
+import { PayPal, PayPalPayment, PayPalConfiguration } from '@ionic-native/paypal/ngx';
4
+
5
+@Component({
6
+    selector: 'app-checkout',
7
+    templateUrl: './checkout.page.html',
8
+    styleUrls: ['./checkout.page.scss'],
9
+})
10
+export class CheckoutPage implements OnInit {
11
+
12
+    constructor(public modalController: ModalController, private payPal: PayPal) { }
13
+
14
+    ngOnInit() {
15
+    }
16
+
17
+    dismiss() {
18
+        // using the injected ModalController this page
19
+        // can "dismiss" itself and optionally pass back data
20
+        this.modalController.dismiss({
21
+            'dismissed': true
22
+        });
23
+    }
24
+
25
+    paymentAmount: string = '640';
26
+    currency: string = 'USD';
27
+    currencyIcon: string = 'USD';
28
+
29
+    payWithPaypal() {
30
+        this.payPal.init({
31
+            PayPalEnvironmentProduction: 'YOUR_PRODUCTION_CLIENT_ID',
32
+            PayPalEnvironmentSandbox: 'AVszPxWCuK3FGXKlgOCFu3gVXr8lFkKj9z1wUo9BYdestZbGRg5vDqWm_pqlLkhEu8KHsjP8NmfPhc_o'
33
+        }).then(() => {
34
+            // Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction
35
+            this.payPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({
36
+                // Only needed if you get an "Internal Service Error" after PayPal login!
37
+                //payPalShippingAddressOption: 2 // PayPalShippingAddressOptionPayPal
38
+            })).then(() => {
39
+                let payment = new PayPalPayment(this.paymentAmount, this.currency, 'Description', 'sale');
40
+                this.payPal.renderSinglePaymentUI(payment).then((res) => {
41
+                    console.log(res);
42
+                    // Successfully paid
43
+                }, (error) => {
44
+                    console.log(error);
45
+                    // Error or render dialog closed without being successful
46
+                });
47
+            }, (error) => {
48
+                console.log(error);
49
+                // Error in configuration
50
+            });
51
+        }, (error) => {
52
+            console.log(error);
53
+            // Error in initialization, maybe PayPal isn't supported or something else
54
+        });
55
+    }
56
+}

+ 3 - 1
src/app/explore-container/explore-container.component.html

@@ -1,4 +1,6 @@
1 1
 <div id="container">
2 2
   <strong>{{ name }}</strong>
3 3
   <p>Explore <a target="_blank" rel="noopener noreferrer" href="https://ionicframework.com/docs/components">UI Components</a></p>
4
-</div>
4
+</div>
5
+<ion-title size="large">wellnessroute.info</ion-title>
6
+  <ion-title size="large">แผนที่สุขภาพ</ion-title>

+ 17 - 0
src/app/forgot-password/forgot-password-routing.module.ts

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+
4
+import { ForgotPasswordPage } from './forgot-password.page';
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: ForgotPasswordPage
10
+  }
11
+];
12
+
13
+@NgModule({
14
+  imports: [RouterModule.forChild(routes)],
15
+  exports: [RouterModule],
16
+})
17
+export class ForgotPasswordPageRoutingModule {}

+ 20 - 0
src/app/forgot-password/forgot-password.module.ts

@@ -0,0 +1,20 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { FormsModule } from '@angular/forms';
4
+
5
+import { IonicModule } from '@ionic/angular';
6
+
7
+import { ForgotPasswordPageRoutingModule } from './forgot-password-routing.module';
8
+
9
+import { ForgotPasswordPage } from './forgot-password.page';
10
+
11
+@NgModule({
12
+  imports: [
13
+    CommonModule,
14
+    FormsModule,
15
+    IonicModule,
16
+    ForgotPasswordPageRoutingModule
17
+  ],
18
+  declarations: [ForgotPasswordPage]
19
+})
20
+export class ForgotPasswordPageModule {}

+ 37 - 0
src/app/forgot-password/forgot-password.page.html

@@ -0,0 +1,37 @@
1
+<ion-header>
2
+  <ion-toolbar class="new-background-color">
3
+    <ion-buttons slot="end">
4
+      <ion-button (click)="dismiss()" color="light">ปิด</ion-button>
5
+    </ion-buttons>
6
+    <div class="hcs">
7
+      <img src="/assets/images/wellnessbar.svg" height="50" />    
8
+    </div>
9
+  </ion-toolbar>
10
+</ion-header>
11
+<ion-content>
12
+  <div><img src="/assets/images/image-006.jpg"></div>
13
+  <ion-grid>
14
+    <ion-row>
15
+      <ion-col>
16
+        <div class="ion-text-center">
17
+          <h1>ลืมรหัสผ่าน</h1>
18
+        </div>
19
+      </ion-col>
20
+    </ion-row>
21
+    <form>
22
+      <ion-row>
23
+        <ion-col>
24
+          <ion-item lines="full">
25
+            <ion-label position="floating">อีเมล์</ion-label>
26
+            <ion-input type="email" name="email" [(ngModel)]="email" inputmode="email"></ion-input>
27
+          </ion-item>
28
+        </ion-col>
29
+      </ion-row>
30
+      <ion-row>
31
+        <ion-col>
32
+          <ion-button type="submit" color="danger" expand="block" (click)="resetPassword()">ส่งรหัสผ่าน</ion-button>
33
+        </ion-col>
34
+      </ion-row>
35
+    </form>
36
+  </ion-grid>
37
+</ion-content>

+ 0 - 0
src/app/forgot-password/forgot-password.page.scss


+ 24 - 0
src/app/forgot-password/forgot-password.page.spec.ts

@@ -0,0 +1,24 @@
1
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2
+import { IonicModule } from '@ionic/angular';
3
+
4
+import { ForgotPasswordPage } from './forgot-password.page';
5
+
6
+describe('ForgotPasswordPage', () => {
7
+  let component: ForgotPasswordPage;
8
+  let fixture: ComponentFixture<ForgotPasswordPage>;
9
+
10
+  beforeEach(waitForAsync(() => {
11
+    TestBed.configureTestingModule({
12
+      declarations: [ ForgotPasswordPage ],
13
+      imports: [IonicModule.forRoot()]
14
+    }).compileComponents();
15
+
16
+    fixture = TestBed.createComponent(ForgotPasswordPage);
17
+    component = fixture.componentInstance;
18
+    fixture.detectChanges();
19
+  }));
20
+
21
+  it('should create', () => {
22
+    expect(component).toBeTruthy();
23
+  });
24
+});

+ 36 - 0
src/app/forgot-password/forgot-password.page.ts

@@ -0,0 +1,36 @@
1
+import { Component, OnInit } from '@angular/core';
2
+import { ModalController } from '@ionic/angular';
3
+import { WpServiceService } from '../wp-service.service';
4
+
5
+@Component({
6
+    selector: 'app-forgot-password',
7
+    templateUrl: './forgot-password.page.html',
8
+    styleUrls: ['./forgot-password.page.scss'],
9
+})
10
+export class ForgotPasswordPage implements OnInit {
11
+
12
+    email = "";
13
+
14
+    constructor(public modalController: ModalController, private wp:WpServiceService) { }
15
+
16
+    ngOnInit() {
17
+    }
18
+
19
+    async resetPassword() {
20
+        if( this.email == "" ) {
21
+            alert("Please Enter Valid Email");
22
+            return;
23
+        }
24
+        let r = await this.wp.resetPassword(this.email);
25
+        alert(r.msg);
26
+    }
27
+
28
+    dismiss() {
29
+        // using the injected ModalController this page
30
+        // can "dismiss" itself and optionally pass back data
31
+        this.modalController.dismiss({
32
+            'dismissed': true
33
+        });
34
+    }
35
+
36
+}

+ 17 - 0
src/app/gmap/gmap-routing.module.ts

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+
4
+import { GmapPage } from './gmap.page';
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: GmapPage
10
+  }
11
+];
12
+
13
+@NgModule({
14
+  imports: [RouterModule.forChild(routes)],
15
+  exports: [RouterModule],
16
+})
17
+export class GmapPageRoutingModule {}

+ 20 - 0
src/app/gmap/gmap.module.ts

@@ -0,0 +1,20 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { FormsModule } from '@angular/forms';
4
+
5
+import { IonicModule } from '@ionic/angular';
6
+
7
+import { GmapPageRoutingModule } from './gmap-routing.module';
8
+
9
+import { GmapPage } from './gmap.page';
10
+
11
+@NgModule({
12
+  imports: [
13
+    CommonModule,
14
+    FormsModule,
15
+    IonicModule,
16
+    GmapPageRoutingModule
17
+  ],
18
+  declarations: [GmapPage]
19
+})
20
+export class GmapPageModule {}

+ 9 - 0
src/app/gmap/gmap.page.html

@@ -0,0 +1,9 @@
1
+<ion-header>
2
+  <ion-toolbar>
3
+    <ion-title>gmap</ion-title>
4
+  </ion-toolbar>
5
+</ion-header>
6
+
7
+<ion-content>..
8
+<div #map id="map"></div>
9
+</ion-content>

+ 3 - 0
src/app/gmap/gmap.page.scss

@@ -0,0 +1,3 @@
1
+#map {
2
+    height: 300px;
3
+}

+ 24 - 0
src/app/gmap/gmap.page.spec.ts

@@ -0,0 +1,24 @@
1
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2
+import { IonicModule } from '@ionic/angular';
3
+
4
+import { GmapPage } from './gmap.page';
5
+
6
+describe('GmapPage', () => {
7
+  let component: GmapPage;
8
+  let fixture: ComponentFixture<GmapPage>;
9
+
10
+  beforeEach(waitForAsync(() => {
11
+    TestBed.configureTestingModule({
12
+      declarations: [ GmapPage ],
13
+      imports: [IonicModule.forRoot()]
14
+    }).compileComponents();
15
+
16
+    fixture = TestBed.createComponent(GmapPage);
17
+    component = fixture.componentInstance;
18
+    fixture.detectChanges();
19
+  }));
20
+
21
+  it('should create', () => {
22
+    expect(component).toBeTruthy();
23
+  });
24
+});

+ 72 - 0
src/app/gmap/gmap.page.ts

@@ -0,0 +1,72 @@
1
+import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
2
+import { ActivatedRoute, Router } from '@angular/router';
3
+import { WpServiceService } from '../wp-service.service';
4
+import { Geolocation } from '@ionic-native/geolocation/ngx';
5
+import { NativeGeocoder, NativeGeocoderResult, NativeGeocoderOptions } from '@ionic-native/native-geocoder/ngx';
6
+
7
+declare var google: any;
8
+
9
+@Component({
10
+  selector: 'app-gmap',
11
+  templateUrl: './gmap.page.html',
12
+  styleUrls: ['./gmap.page.scss'],
13
+})
14
+export class GmapPage implements OnInit {
15
+  @Input() id: string;
16
+  data: any;
17
+  placelist: any;
18
+  latdynamic: any;
19
+  londynamic: any;
20
+  xxx: any;
21
+  yyy: any;
22
+  placeL: any;
23
+  map: any;
24
+  // @ViewChild('map', { static: false }) mapElement: ElementRef;
25
+  @ViewChild('map', { static: true }) mapRef: ElementRef;
26
+  // @ViewChild('map', { static: false }) mapElement: ElementRef;
27
+
28
+
29
+  constructor(private wpservice: WpServiceService, private route: ActivatedRoute, private router: Router, private geolocation: Geolocation) { }
30
+
31
+  ngOnInit() {
32
+    this.showMap();
33
+    // this.loadMap() 
34
+    let id = this.route.snapshot.paramMap.get('id') || this.id;
35
+    this.wpservice.getPlaceDetail(173).subscribe((data) => {
36
+      this.placelist = data;
37
+      this.latdynamic = data['acf']['gmap']['lat'];
38
+      this.londynamic = data['acf']['gmap']['lng'];
39
+
40
+      console.log("load Place Detail ...");
41
+      console.log(this.latdynamic);
42
+      console.log("load Lati ...");
43
+      console.log(this.londynamic);
44
+      console.log("load Lon ...");
45
+      console.log(data);
46
+      let xxx = this.londynamic;
47
+      const yyy = this.latdynamic;
48
+    }, error => {
49
+      console.log("errror ", error);
50
+    });
51
+
52
+    let watch = this.geolocation.watchPosition();
53
+    watch.subscribe((data) => {
54
+      // data can be a set of coordinates, or an error (if an error occurred).
55
+      // data.coords.latitude
56
+      // data.coords.longitude
57
+      console.log(data);
58
+    });
59
+  }
60
+
61
+  showMap() {
62
+    let location = new google.maps.LatLng(13.7643439, 100.6899729);
63
+    let options = {
64
+      center: location,
65
+      zoom: 15,
66
+      disableDefaultUI: true
67
+    }
68
+    this.map = new google.maps.Map(this.mapRef.nativeElement, options);
69
+    //this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
70
+  }
71
+
72
+}

+ 17 - 0
src/app/home/home-routing.module.ts

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+
4
+import { HomePage } from './home.page';
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: HomePage
10
+  }
11
+];
12
+
13
+@NgModule({
14
+  imports: [RouterModule.forChild(routes)],
15
+  exports: [RouterModule],
16
+})
17
+export class HomePageRoutingModule {}

+ 26 - 0
src/app/home/home.module.ts

@@ -0,0 +1,26 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { FormsModule } from '@angular/forms';
4
+
5
+import { IonicModule } from '@ionic/angular';
6
+
7
+import { HomePageRoutingModule } from './home-routing.module';
8
+
9
+import { HomePage } from './home.page';
10
+import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
11
+import { IonSlides } from '@ionic/angular';
12
+
13
+import { PipeModule } from '../pipe/pipe.module';
14
+
15
+@NgModule({
16
+  imports: [
17
+    CommonModule,
18
+    FormsModule,
19
+    IonicModule,
20
+      PipeModule,
21
+    HomePageRoutingModule,
22
+    FontAwesomeModule
23
+  ],
24
+  declarations: [HomePage]
25
+})
26
+export class HomePageModule {}

+ 0 - 0
src/app/home/home.page.290921.html


Неке датотеке нису приказане због велике количине промена

tum/whitesports - Gogs: Simplico Git Service

Нет описания

rss.php 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. <?php
  2. /**
  3. * MagpieRSS: a simple RSS integration tool
  4. *
  5. * A compiled file for RSS syndication
  6. *
  7. * @author Kellan Elliott-McCrea <kellan@protest.net>
  8. * @version 0.51
  9. * @license GPL
  10. *
  11. * @package External
  12. * @subpackage MagpieRSS
  13. * @deprecated 3.0.0 Use SimplePie instead.
  14. */
  15. /**
  16. * Deprecated. Use SimplePie (class-simplepie.php) instead.
  17. */
  18. _deprecated_file( basename( __FILE__ ), '3.0.0', WPINC . '/class-simplepie.php' );
  19. /**
  20. * Fires before MagpieRSS is loaded, to optionally replace it.
  21. *
  22. * @since 2.3.0
  23. * @deprecated 3.0.0
  24. */
  25. do_action( 'load_feed_engine' );
  26. /** RSS feed constant. */
  27. define('RSS', 'RSS');
  28. define('ATOM', 'Atom');
  29. define('MAGPIE_USER_AGENT', 'WordPress/' . $GLOBALS['wp_version']);
  30. class MagpieRSS {
  31. var $parser;
  32. var $current_item = array(); // item currently being parsed
  33. var $items = array(); // collection of parsed items
  34. var $channel = array(); // hash of channel fields
  35. var $textinput = array();
  36. var $image = array();
  37. var $feed_type;
  38. var $feed_version;
  39. // parser variables
  40. var $stack = array(); // parser stack
  41. var $inchannel = false;
  42. var $initem = false;
  43. var $incontent = false; // if in Atom <content mode="xml"> field
  44. var $intextinput = false;
  45. var $inimage = false;
  46. var $current_field = '';
  47. var $current_namespace = false;
  48. //var $ERROR = "";
  49. var $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright');
  50. /**
  51. * PHP5 constructor.
  52. */
  53. function __construct( $source ) {
  54. # Check if PHP xml isn't compiled
  55. #
  56. if ( ! function_exists('xml_parser_create') ) {
  57. return trigger_error( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." );
  58. }
  59. $parser = xml_parser_create();
  60. $this->parser = $parser;
  61. # pass in parser, and a reference to this object
  62. # set up handlers
  63. #
  64. xml_set_object( $this->parser, $this );
  65. xml_set_element_handler($this->parser,
  66. 'feed_start_element', 'feed_end_element' );
  67. xml_set_character_data_handler( $this->parser, 'feed_cdata' );
  68. $status = xml_parse( $this->parser, $source );
  69. if (! $status ) {
  70. $errorcode = xml_get_error_code( $this->parser );
  71. if ( $errorcode != XML_ERROR_NONE ) {
  72. $xml_error = xml_error_string( $errorcode );
  73. $error_line = xml_get_current_line_number($this->parser);
  74. $error_col = xml_get_current_column_number($this->parser);
  75. $errormsg = "$xml_error at line $error_line, column $error_col";
  76. $this->error( $errormsg );
  77. }
  78. }
  79. xml_parser_free( $this->parser );
  80. unset( $this->parser );
  81. $this->normalize();
  82. }
  83. /**
  84. * PHP4 constructor.
  85. */
  86. public function MagpieRSS( $source ) {
  87. self::__construct( $source );
  88. }
  89. function feed_start_element($p, $element, &$attrs) {
  90. $el = $element = strtolower($element);
  91. $attrs = array_change_key_case($attrs, CASE_LOWER);
  92. // check for a namespace, and split if found
  93. $ns = false;
  94. if ( strpos( $element, ':' ) ) {
  95. list($ns, $el) = explode( ':', $element, 2);
  96. }
  97. if ( $ns and $ns != 'rdf' ) {
  98. $this->current_namespace = $ns;
  99. }
  100. # if feed type isn't set, then this is first element of feed
  101. # identify feed from root element
  102. #
  103. if (!isset($this->feed_type) ) {
  104. if ( $el == 'rdf' ) {
  105. $this->feed_type = RSS;
  106. $this->feed_version = '1.0';
  107. }
  108. elseif ( $el == 'rss' ) {
  109. $this->feed_type = RSS;
  110. $this->feed_version = $attrs['version'];
  111. }
  112. elseif ( $el == 'feed' ) {
  113. $this->feed_type = ATOM;
  114. $this->feed_version = $attrs['version'];
  115. $this->inchannel = true;
  116. }
  117. return;
  118. }
  119. if ( $el == 'channel' )
  120. {
  121. $this->inchannel = true;
  122. }
  123. elseif ($el == 'item' or $el == 'entry' )
  124. {
  125. $this->initem = true;
  126. if ( isset($attrs['rdf:about']) ) {
  127. $this->current_item['about'] = $attrs['rdf:about'];
  128. }
  129. }
  130. // if we're in the default namespace of an RSS feed,
  131. // record textinput or image fields
  132. elseif (
  133. $this->feed_type == RSS and
  134. $this->current_namespace == '' and
  135. $el == 'textinput' )
  136. {
  137. $this->intextinput = true;
  138. }
  139. elseif (
  140. $this->feed_type == RSS and
  141. $this->current_namespace == '' and
  142. $el == 'image' )
  143. {
  144. $this->inimage = true;
  145. }
  146. # handle atom content constructs
  147. elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
  148. {
  149. // avoid clashing w/ RSS mod_content
  150. if ($el == 'content' ) {
  151. $el = 'atom_content';
  152. }
  153. $this->incontent = $el;
  154. }
  155. // if inside an Atom content construct (e.g. content or summary) field treat tags as text
  156. elseif ($this->feed_type == ATOM and $this->incontent )
  157. {
  158. // if tags are inlined, then flatten
  159. $attrs_str = join(' ',
  160. array_map(array('MagpieRSS', 'map_attrs'),
  161. array_keys($attrs),
  162. array_values($attrs) ) );
  163. $this->append_content( "<$element $attrs_str>" );
  164. array_unshift( $this->stack, $el );
  165. }
  166. // Atom support many links per containging element.
  167. // Magpie treats link elements of type rel='alternate'
  168. // as being equivalent to RSS's simple link element.
  169. //
  170. elseif ($this->feed_type == ATOM and $el == 'link' )
  171. {
  172. if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' )
  173. {
  174. $link_el = 'link';
  175. }
  176. else {
  177. $link_el = 'link_' . $attrs['rel'];
  178. }
  179. $this->append($link_el, $attrs['href']);
  180. }
  181. // set stack[0] to current element
  182. else {
  183. array_unshift($this->stack, $el);
  184. }
  185. }
  186. function feed_cdata ($p, $text) {
  187. if ($this->feed_type == ATOM and $this->incontent)
  188. {
  189. $this->append_content( $text );
  190. }
  191. else {
  192. $current_el = join('_', array_reverse($this->stack));
  193. $this->append($current_el, $text);
  194. }
  195. }
  196. function feed_end_element ($p, $el) {
  197. $el = strtolower($el);
  198. if ( $el == 'item' or $el == 'entry' )
  199. {
  200. $this->items[] = $this->current_item;
  201. $this->current_item = array();
  202. $this->initem = false;
  203. }
  204. elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' )
  205. {
  206. $this->intextinput = false;
  207. }
  208. elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' )
  209. {
  210. $this->inimage = false;
  211. }
  212. elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
  213. {
  214. $this->incontent = false;
  215. }
  216. elseif ($el == 'channel' or $el == 'feed' )
  217. {
  218. $this->inchannel = false;
  219. }
  220. elseif ($this->feed_type == ATOM and $this->incontent ) {
  221. // balance tags properly
  222. // note: This may not actually be necessary
  223. if ( $this->stack[0] == $el )
  224. {
  225. $this->append_content("</$el>");
  226. }
  227. else {
  228. $this->append_content("<$el />");
  229. }
  230. array_shift( $this->stack );
  231. }
  232. else {
  233. array_shift( $this->stack );
  234. }
  235. $this->current_namespace = false;
  236. }
  237. function concat (&$str1, $str2="") {
  238. if (!isset($str1) ) {
  239. $str1="";
  240. }
  241. $str1 .= $str2;
  242. }
  243. function append_content($text) {
  244. if ( $this->initem ) {
  245. $this->concat( $this->current_item[ $this->incontent ], $text );
  246. }
  247. elseif ( $this->inchannel ) {
  248. $this->concat( $this->channel[ $this->incontent ], $text );
  249. }
  250. }
  251. // smart append - field and namespace aware
  252. function append($el, $text) {
  253. if (!$el) {
  254. return;
  255. }
  256. if ( $this->current_namespace )
  257. {
  258. if ( $this->initem ) {
  259. $this->concat(
  260. $this->current_item[ $this->current_namespace ][ $el ], $text);
  261. }
  262. elseif ($this->inchannel) {
  263. $this->concat(
  264. $this->channel[ $this->current_namespace][ $el ], $text );
  265. }
  266. elseif ($this->intextinput) {
  267. $this->concat(
  268. $this->textinput[ $this->current_namespace][ $el ], $text );
  269. }
  270. elseif ($this->inimage) {
  271. $this->concat(
  272. $this->image[ $this->current_namespace ][ $el ], $text );
  273. }
  274. }
  275. else {
  276. if ( $this->initem ) {
  277. $this->concat(
  278. $this->current_item[ $el ], $text);
  279. }
  280. elseif ($this->intextinput) {
  281. $this->concat(
  282. $this->textinput[ $el ], $text );
  283. }
  284. elseif ($this->inimage) {
  285. $this->concat(
  286. $this->image[ $el ], $text );
  287. }
  288. elseif ($this->inchannel) {
  289. $this->concat(
  290. $this->channel[ $el ], $text );
  291. }
  292. }
  293. }
  294. function normalize () {
  295. // if atom populate rss fields
  296. if ( $this->is_atom() ) {
  297. $this->channel['descripton'] = $this->channel['tagline'];
  298. for ( $i = 0; $i < count($this->items); $i++) {
  299. $item = $this->items[$i];
  300. if ( isset($item['summary']) )
  301. $item['description'] = $item['summary'];
  302. if ( isset($item['atom_content']))
  303. $item['content']['encoded'] = $item['atom_content'];
  304. $this->items[$i] = $item;
  305. }
  306. }
  307. elseif ( $this->is_rss() ) {
  308. $this->channel['tagline'] = $this->channel['description'];
  309. for ( $i = 0; $i < count($this->items); $i++) {
  310. $item = $this->items[$i];
  311. if ( isset($item['description']))
  312. $item['summary'] = $item['description'];
  313. if ( isset($item['content']['encoded'] ) )
  314. $item['atom_content'] = $item['content']['encoded'];
  315. $this->items[$i] = $item;
  316. }
  317. }
  318. }
  319. function is_rss () {
  320. if ( $this->feed_type == RSS ) {
  321. return $this->feed_version;
  322. }
  323. else {
  324. return false;
  325. }
  326. }
  327. function is_atom() {
  328. if ( $this->feed_type == ATOM ) {
  329. return $this->feed_version;
  330. }
  331. else {
  332. return false;
  333. }
  334. }
  335. function map_attrs($k, $v) {
  336. return "$k=\"$v\"";
  337. }
  338. function error( $errormsg, $lvl = E_USER_WARNING ) {
  339. if ( MAGPIE_DEBUG ) {
  340. trigger_error( $errormsg, $lvl);
  341. } else {
  342. error_log( $errormsg, 0);
  343. }
  344. }
  345. }
  346. if ( !function_exists('fetch_rss') ) :
  347. /**
  348. * Build Magpie object based on RSS from URL.
  349. *
  350. * @since 1.5.0
  351. * @package External
  352. * @subpackage MagpieRSS
  353. *
  354. * @param string $url URL to retrieve feed.
  355. * @return MagpieRSS|false MagpieRSS object on success, false on failure.
  356. */
  357. function fetch_rss ($url) {
  358. // initialize constants
  359. init();
  360. if ( !isset($url) ) {
  361. // error("fetch_rss called without a url");
  362. return false;
  363. }
  364. // if cache is disabled
  365. if ( !MAGPIE_CACHE_ON ) {
  366. // fetch file, and parse it
  367. $resp = _fetch_remote_file( $url );
  368. if ( is_success( $resp->status ) ) {
  369. return _response_to_rss( $resp );
  370. }
  371. else {
  372. // error("Failed to fetch $url and cache is off");
  373. return false;
  374. }
  375. }
  376. // else cache is ON
  377. else {
  378. // Flow
  379. // 1. check cache
  380. // 2. if there is a hit, make sure it's fresh
  381. // 3. if cached obj fails freshness check, fetch remote
  382. // 4. if remote fails, return stale object, or error
  383. $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
  384. if (MAGPIE_DEBUG and $cache->ERROR) {
  385. debug($cache->ERROR, E_USER_WARNING);
  386. }
  387. $cache_status = 0; // response of check_cache
  388. $request_headers = array(); // HTTP headers to send with fetch
  389. $rss = 0; // parsed RSS object
  390. $errormsg = 0; // errors, if any
  391. if (!$cache->ERROR) {
  392. // return cache HIT, MISS, or STALE
  393. $cache_status = $cache->check_cache( $url );
  394. }
  395. // if object cached, and cache is fresh, return cached obj
  396. if ( $cache_status == 'HIT' ) {
  397. $rss = $cache->get( $url );
  398. if ( isset($rss) and $rss ) {
  399. $rss->from_cache = 1;
  400. if ( MAGPIE_DEBUG > 1) {
  401. debug("MagpieRSS: Cache HIT", E_USER_NOTICE);
  402. }
  403. return $rss;
  404. }
  405. }
  406. // else attempt a conditional get
  407. // set up headers
  408. if ( $cache_status == 'STALE' ) {
  409. $rss = $cache->get( $url );
  410. if ( isset($rss->etag) and $rss->last_modified ) {
  411. $request_headers['If-None-Match'] = $rss->etag;
  412. $request_headers['If-Last-Modified'] = $rss->last_modified;
  413. }
  414. }
  415. $resp = _fetch_remote_file( $url, $request_headers );
  416. if (isset($resp) and $resp) {
  417. if ($resp->status == '304' ) {
  418. // we have the most current copy
  419. if ( MAGPIE_DEBUG > 1) {
  420. debug("Got 304 for $url");
  421. }
  422. // reset cache on 304 (at minutillo insistent prodding)
  423. $cache->set($url, $rss);
  424. return $rss;
  425. }
  426. elseif ( is_success( $resp->status ) ) {
  427. $rss = _response_to_rss( $resp );
  428. if ( $rss ) {
  429. if (MAGPIE_DEBUG > 1) {
  430. debug("Fetch successful");
  431. }
  432. // add object to cache
  433. $cache->set( $url, $rss );
  434. return $rss;
  435. }
  436. }
  437. else {
  438. $errormsg = "Failed to fetch $url. ";
  439. if ( $resp->error ) {
  440. # compensate for Snoopy's annoying habbit to tacking
  441. # on '\n'
  442. $http_error = substr($resp->error, 0, -2);
  443. $errormsg .= "(HTTP Error: $http_error)";
  444. }
  445. else {
  446. $errormsg .= "(HTTP Response: " . $resp->response_code .')';
  447. }
  448. }
  449. }
  450. else {
  451. $errormsg = "Unable to retrieve RSS file for unknown reasons.";
  452. }
  453. // else fetch failed
  454. // attempt to return cached object
  455. if ($rss) {
  456. if ( MAGPIE_DEBUG ) {
  457. debug("Returning STALE object for $url");
  458. }
  459. return $rss;
  460. }
  461. // else we totally failed
  462. // error( $errormsg );
  463. return false;
  464. } // end if ( !MAGPIE_CACHE_ON ) {
  465. } // end fetch_rss()
  466. endif;
  467. /**
  468. * Retrieve URL headers and content using WP HTTP Request API.
  469. *
  470. * @since 1.5.0
  471. * @package External
  472. * @subpackage MagpieRSS
  473. *
  474. * @param string $url URL to retrieve
  475. * @param array $headers Optional. Headers to send to the URL.
  476. * @return Snoopy style response
  477. */
  478. function _fetch_remote_file($url, $headers = "" ) {
  479. $resp = wp_safe_remote_request( $url, array( 'headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT ) );
  480. if ( is_wp_error($resp) ) {
  481. $error = array_shift($resp->errors);
  482. $resp = new stdClass;
  483. $resp->status = 500;
  484. $resp->response_code = 500;
  485. $resp->error = $error[0] . "\n"; //\n = Snoopy compatibility
  486. return $resp;
  487. }
  488. // Snoopy returns headers unprocessed.
  489. // Also note, WP_HTTP lowercases all keys, Snoopy did not.
  490. $return_headers = array();
  491. foreach ( wp_remote_retrieve_headers( $resp ) as $key => $value ) {
  492. if ( !is_array($value) ) {
  493. $return_headers[] = "$key: $value";
  494. } else {
  495. foreach ( $value as $v )
  496. $return_headers[] = "$key: $v";
  497. }
  498. }
  499. $response = new stdClass;
  500. $response->status = wp_remote_retrieve_response_code( $resp );
  501. $response->response_code = wp_remote_retrieve_response_code( $resp );
  502. $response->headers = $return_headers;
  503. $response->results = wp_remote_retrieve_body( $resp );
  504. return $response;
  505. }
  506. /**
  507. * Retrieve
  508. *
  509. * @since 1.5.0
  510. * @package External
  511. * @subpackage MagpieRSS
  512. *
  513. * @param array $resp
  514. * @return MagpieRSS|bool
  515. */
  516. function _response_to_rss ($resp) {
  517. $rss = new MagpieRSS( $resp->results );
  518. // if RSS parsed successfully
  519. if ( $rss && (!isset($rss->ERROR) || !$rss->ERROR) ) {
  520. // find Etag, and Last-Modified
  521. foreach ( (array) $resp->headers as $h) {
  522. // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
  523. if (strpos($h, ": ")) {
  524. list($field, $val) = explode(": ", $h, 2);
  525. }
  526. else {
  527. $field = $h;
  528. $val = "";
  529. }
  530. if ( $field == 'etag' ) {
  531. $rss->etag = $val;
  532. }
  533. if ( $field == 'last-modified' ) {
  534. $rss->last_modified = $val;
  535. }
  536. }
  537. return $rss;
  538. } // else construct error message
  539. else {
  540. $errormsg = "Failed to parse RSS file.";
  541. if ($rss) {
  542. $errormsg .= " (" . $rss->ERROR . ")";
  543. }
  544. // error($errormsg);
  545. return false;
  546. } // end if ($rss and !$rss->error)
  547. }
  548. /**
  549. * Set up constants with default values, unless user overrides.
  550. *
  551. * @since 1.5.0
  552. * @package External
  553. * @subpackage MagpieRSS
  554. */
  555. function init () {
  556. if ( defined('MAGPIE_INITALIZED') ) {
  557. return;
  558. }
  559. else {
  560. define('MAGPIE_INITALIZED', 1);
  561. }
  562. if ( !defined('MAGPIE_CACHE_ON') ) {
  563. define('MAGPIE_CACHE_ON', 1);
  564. }
  565. if ( !defined('MAGPIE_CACHE_DIR') ) {
  566. define('MAGPIE_CACHE_DIR', './cache');
  567. }
  568. if ( !defined('MAGPIE_CACHE_AGE') ) {
  569. define('MAGPIE_CACHE_AGE', 60*60); // one hour
  570. }
  571. if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) {
  572. define('MAGPIE_CACHE_FRESH_ONLY', 0);
  573. }
  574. if ( !defined('MAGPIE_DEBUG') ) {
  575. define('MAGPIE_DEBUG', 0);
  576. }
  577. if ( !defined('MAGPIE_USER_AGENT') ) {
  578. $ua = 'WordPress/' . $GLOBALS['wp_version'];
  579. if ( MAGPIE_CACHE_ON ) {
  580. $ua = $ua . ')';
  581. }
  582. else {
  583. $ua = $ua . '; No cache)';
  584. }
  585. define('MAGPIE_USER_AGENT', $ua);
  586. }
  587. if ( !defined('MAGPIE_FETCH_TIME_OUT') ) {
  588. define('MAGPIE_FETCH_TIME_OUT', 2); // 2 second timeout
  589. }
  590. // use gzip encoding to fetch rss files if supported?
  591. if ( !defined('MAGPIE_USE_GZIP') ) {
  592. define('MAGPIE_USE_GZIP', true);
  593. }
  594. }
  595. function is_info ($sc) {
  596. return $sc >= 100 && $sc < 200;
  597. }
  598. function is_success ($sc) {
  599. return $sc >= 200 && $sc < 300;
  600. }
  601. function is_redirect ($sc) {
  602. return $sc >= 300 && $sc < 400;
  603. }
  604. function is_error ($sc) {
  605. return $sc >= 400 && $sc < 600;
  606. }
  607. function is_client_error ($sc) {
  608. return $sc >= 400 && $sc < 500;
  609. }
  610. function is_server_error ($sc) {
  611. return $sc >= 500 && $sc < 600;
  612. }
  613. class RSSCache {
  614. var $BASE_CACHE; // where the cache files are stored
  615. var $MAX_AGE = 43200; // when are files stale, default twelve hours
  616. var $ERROR = ''; // accumulate error messages
  617. /**
  618. * PHP5 constructor.
  619. */
  620. function __construct( $base = '', $age = '' ) {
  621. $this->BASE_CACHE = WP_CONTENT_DIR . '/cache';
  622. if ( $base ) {
  623. $this->BASE_CACHE = $base;
  624. }
  625. if ( $age ) {
  626. $this->MAX_AGE = $age;
  627. }
  628. }
  629. /**
  630. * PHP4 constructor.
  631. */
  632. public function RSSCache( $base = '', $age = '' ) {
  633. self::__construct( $base, $age );
  634. }
  635. /*=======================================================================*\
  636. Function: set
  637. Purpose: add an item to the cache, keyed on url
  638. Input: url from which the rss file was fetched
  639. Output: true on success
  640. \*=======================================================================*/
  641. function set ($url, $rss) {
  642. $cache_option = 'rss_' . $this->file_name( $url );
  643. set_transient($cache_option, $rss, $this->MAX_AGE);
  644. return $cache_option;
  645. }
  646. /*=======================================================================*\
  647. Function: get
  648. Purpose: fetch an item from the cache
  649. Input: url from which the rss file was fetched
  650. Output: cached object on HIT, false on MISS
  651. \*=======================================================================*/
  652. function get ($url) {
  653. $this->ERROR = "";
  654. $cache_option = 'rss_' . $this->file_name( $url );
  655. if ( ! $rss = get_transient( $cache_option ) ) {
  656. $this->debug(
  657. "Cache does not contain: $url (cache option: $cache_option)"
  658. );
  659. return 0;
  660. }
  661. return $rss;
  662. }
  663. /*=======================================================================*\
  664. Function: check_cache
  665. Purpose: check a url for membership in the cache
  666. and whether the object is older then MAX_AGE (ie. STALE)
  667. Input: url from which the rss file was fetched
  668. Output: cached object on HIT, false on MISS
  669. \*=======================================================================*/
  670. function check_cache ( $url ) {
  671. $this->ERROR = "";
  672. $cache_option = 'rss_' . $this->file_name( $url );
  673. if ( get_transient($cache_option) ) {
  674. // object exists and is current
  675. return 'HIT';
  676. } else {
  677. // object does not exist
  678. return 'MISS';
  679. }
  680. }
  681. /*=======================================================================*\
  682. Function: serialize
  683. \*=======================================================================*/
  684. function serialize ( $rss ) {
  685. return serialize( $rss );
  686. }
  687. /*=======================================================================*\
  688. Function: unserialize
  689. \*=======================================================================*/
  690. function unserialize ( $data ) {
  691. return unserialize( $data );
  692. }
  693. /*=======================================================================*\
  694. Function: file_name
  695. Purpose: map url to location in cache
  696. Input: url from which the rss file was fetched
  697. Output: a file name
  698. \*=======================================================================*/
  699. function file_name ($url) {
  700. return md5( $url );
  701. }
  702. /*=======================================================================*\
  703. Function: error
  704. Purpose: register error
  705. \*=======================================================================*/
  706. function error ($errormsg, $lvl=E_USER_WARNING) {
  707. $this->ERROR = $errormsg;
  708. if ( MAGPIE_DEBUG ) {
  709. trigger_error( $errormsg, $lvl);
  710. }
  711. else {
  712. error_log( $errormsg, 0);
  713. }
  714. }
  715. function debug ($debugmsg, $lvl=E_USER_NOTICE) {
  716. if ( MAGPIE_DEBUG ) {
  717. $this->error("MagpieRSS [debug] $debugmsg", $lvl);
  718. }
  719. }
  720. }
  721. if ( !function_exists('parse_w3cdtf') ) :
  722. function parse_w3cdtf ( $date_str ) {
  723. # regex to match wc3dtf
  724. $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
  725. if ( preg_match( $pat, $date_str, $match ) ) {
  726. list( $year, $month, $day, $hours, $minutes, $seconds) =
  727. array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[7]);
  728. # calc epoch for current date assuming GMT
  729. $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year);
  730. $offset = 0;
  731. if ( $match[11] == 'Z' ) {
  732. # zulu time, aka GMT
  733. }
  734. else {
  735. list( $tz_mod, $tz_hour, $tz_min ) =
  736. array( $match[8], $match[9], $match[10]);
  737. # zero out the variables
  738. if ( ! $tz_hour ) { $tz_hour = 0; }
  739. if ( ! $tz_min ) { $tz_min = 0; }
  740. $offset_secs = (($tz_hour*60)+$tz_min)*60;
  741. # is timezone ahead of GMT? then subtract offset
  742. #
  743. if ( $tz_mod == '+' ) {
  744. $offset_secs = $offset_secs * -1;
  745. }
  746. $offset = $offset_secs;
  747. }
  748. $epoch = $epoch + $offset;
  749. return $epoch;
  750. }
  751. else {
  752. return -1;
  753. }
  754. }
  755. endif;
  756. if ( !function_exists('wp_rss') ) :
  757. /**
  758. * Display all RSS items in a HTML ordered list.
  759. *
  760. * @since 1.5.0
  761. * @package External
  762. * @subpackage MagpieRSS
  763. *
  764. * @param string $url URL of feed to display. Will not auto sense feed URL.
  765. * @param int $num_items Optional. Number of items to display, default is all.
  766. */
  767. function wp_rss( $url, $num_items = -1 ) {
  768. if ( $rss = fetch_rss( $url ) ) {
  769. echo '<ul>';
  770. if ( $num_items !== -1 ) {
  771. $rss->items = array_slice( $rss->items, 0, $num_items );
  772. }
  773. foreach ( (array) $rss->items as $item ) {
  774. printf(
  775. '<li><a href="%1$s" title="%2$s">%3$s</a></li>',
  776. esc_url( $item['link'] ),
  777. esc_attr( strip_tags( $item['description'] ) ),
  778. esc_html( $item['title'] )
  779. );
  780. }
  781. echo '</ul>';
  782. } else {
  783. _e( 'An error has occurred, which probably means the feed is down. Try again later.' );
  784. }
  785. }
  786. endif;
  787. if ( !function_exists('get_rss') ) :
  788. /**
  789. * Display RSS items in HTML list items.
  790. *
  791. * You have to specify which HTML list you want, either ordered or unordered
  792. * before using the function. You also have to specify how many items you wish
  793. * to display. You can't display all of them like you can with wp_rss()
  794. * function.
  795. *
  796. * @since 1.5.0
  797. * @package External
  798. * @subpackage MagpieRSS
  799. *
  800. * @param string $url URL of feed to display. Will not auto sense feed URL.
  801. * @param int $num_items Optional. Number of items to display, default is all.
  802. * @return bool False on failure.
  803. */
  804. function get_rss ($url, $num_items = 5) { // Like get posts, but for RSS
  805. $rss = fetch_rss($url);
  806. if ( $rss ) {
  807. $rss->items = array_slice($rss->items, 0, $num_items);
  808. foreach ( (array) $rss->items as $item ) {
  809. echo "<li>\n";
  810. echo "<a href='$item[link]' title='$item[description]'>";
  811. echo esc_html($item['title']);
  812. echo "</a><br />\n";
  813. echo "</li>\n";
  814. }
  815. } else {
  816. return false;
  817. }
  818. }
  819. endif;