├── .gitattributes
├── .gitignore
├── README.md
├── api-template-snippets
└── api-prepend-repeater-item.php
├── api
├── README.md
├── api-create-new-superuser.php
├── api-create-page.php
├── api-create-shortlinks-for-jumplinks-module.php
├── api-formbuilder-entries-to-mailchimp.php
├── api-get-formbuilder-entries.php
├── api-limit-repeater-results.php
├── api-move-field-data-to-another-field.php
├── api-page-subselect.php
├── api-reset-password.php
├── api-set-value-multilanguage.php
└── api-update-created-date.php
├── backup-full-local
├── Modules
│ ├── wbmnfktrAmazonUpdater
│ │ ├── _amz
│ │ │ ├── amz-action.php
│ │ │ ├── amz-func.php
│ │ │ └── amz-vars.php
│ │ ├── amazon.php
│ │ └── wbmnfktrAmazonUpdater.module
│ ├── wbmnfktrGoogleMapsUpdater
│ │ └── wbmnfktrGoogleMapsUpdater.module
│ └── wbmnfktrInventoryChecker
│ │ └── wbmnfktrInventoryChecker.module
├── Snippets
│ ├── _functions.php
│ ├── api-create-page.php
│ ├── api-create-shortlinks-for-jumplinks-module.php
│ ├── api-formbuilder-entries.php
│ ├── api-move-field-data-to-another-field.php
│ ├── api-page-subselect.php
│ ├── api-reset-password.php
│ ├── api-set-value-by-language.php
│ ├── api-update-created-date.php
│ ├── ckeditor-text-align.txt
│ ├── config-serial-key-procache.txt
│ ├── config-session-allow.php
│ ├── delete-form-builder-entries-after-time.php
│ ├── form-refocus.js
│ ├── google-analytics-opt-out.js
│ ├── init.php
│ ├── mailer.php
│ ├── module-default-language.php
│ ├── module-page-edit-only-by-creator.php
│ ├── pages2pdf-custom.php
│ ├── paypal-payment.txt
│ ├── ready-automatite-cron-site-check.php
│ ├── ready-formbuilder-renderReady.php
│ ├── ready-google-maps-adress-lat-long.php
│ ├── ready-log-outgoing-emails.php
│ ├── ready-loginregister-mailchimp.php
│ ├── ready-redirect-to-formbuilder-page.php
│ ├── ready-set-session-variable.php
│ ├── ready-sort-templates-by-label.php
│ ├── ready-submit-to-mailchimp-from-formbuilder-entries.php
│ ├── ready-submit-to-mailchimp.php
│ ├── ready-validate-formbuilder-fields.php
│ ├── snippet-check-ip-country.php
│ └── template-breadcrumb.php
└── dnt.js
├── hannacode
├── README.md
├── hannacode-embed-rumble-privacywire.php
├── hannacode-embed-rumble.php
└── hannacode-table-of-contents-jumplinks-demo.php
├── hooks-ready-php
├── README.md
├── ready-automate-cron-site-check.php
├── ready-clean-youtube-url.php
├── ready-formbuilder-newsletter-subscription.php
├── ready-google-maps-adress-lat-long.php
├── ready-log-outgoing-emails.php
├── ready-set-session-variable.php
└── ready-sort-templates-by-label.php
├── hooks
├── README.md
├── hook-ready-formbuilder-from.php
├── hook-ready-formbuilder-redirect-created-page.php
├── hook-ready-formbuilder-subject.php
├── hook-ready-formbuilder-submit-to-mailchimp.php
├── hook-ready-formbuilder-validate-fields.php
└── hook-ready-loginregister-to-mailchimp.php
└── ready-hook-on-demand-mirroring-web-files.php
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 |
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 |
17 | # Windows shortcuts
18 | *.lnk
19 |
20 | # =========================
21 | # Operating System Files
22 | # =========================
23 |
24 | # OSX
25 | # =========================
26 |
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 |
31 | # Thumbnails
32 | ._*
33 |
34 | # Files that might appear in the root of a volume
35 | .DocumentRevisions-V100
36 | .fseventsd
37 | .Spotlight-V100
38 | .TemporaryItems
39 | .Trashes
40 | .VolumeIcon.icns
41 |
42 | # Directories potentially created on remote AFP share
43 | .AppleDB
44 | .AppleDesktop
45 | Network Trash Folder
46 | Temporary Items
47 | .apdisk
48 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ProcessWire Snippets
2 |
3 | A curated collection of various ProcessWire-related code snippets collected throughout the years and projects.
4 |
5 | ## Various flavours of snippets
6 |
7 | 1. ready.php Hooks
8 | 2. API/Template Snippets
9 | 3. Snippets for Snippets Module
10 |
11 | ## Update in progress
12 |
13 | The whole collection of snippets is under maintenance and rebuild now.
14 |
--------------------------------------------------------------------------------
/api-template-snippets/api-prepend-repeater-item.php:
--------------------------------------------------------------------------------
1 | of(false);
8 | $newItem = $thatPage->my_repeater->getNew();
9 | $newItem->foo = 'bar';
10 | $newItem->save();
11 | $thatPage->my_repeater->add($newItem);
12 | $thatPage->save();
13 | // Set the sort value of the new item to 0 and adjust sibling sort values
14 | $pages->sort($newItem, 0);
15 |
--------------------------------------------------------------------------------
/api/README.md:
--------------------------------------------------------------------------------
1 | # ProcessWire API snippets
--------------------------------------------------------------------------------
/api/api-create-new-superuser.php:
--------------------------------------------------------------------------------
1 | of(false);
9 | $newadmin->name = "newCmsAdminUser";
10 | $newadmin->email = "user@domain.tld";
11 | $newadmin->pass = "aSecurePasswordHere";
12 | $newadmin->addRole("superuser");
13 | $newadmin->save();
14 | $newadmin->of(true);
15 |
16 | ?>
--------------------------------------------------------------------------------
/api/api-create-page.php:
--------------------------------------------------------------------------------
1 | setOutputFormatting(false);
8 |
9 | // example template
10 | $newpage->template = 'yourTemplate';
11 |
12 | // example parent
13 | $newpage->parent = wire('pages')->get('/parent/');
14 |
15 | // example name - leave empty and let ProcessWire create a name for the page based on title
16 | $newpage->name = "foo";
17 |
18 | //example title
19 | $newpage->title = "My API-generated new PW page";
20 |
21 | // example field with example value
22 | $newpage->fieldname = "my field value";
23 |
24 | // save page
25 | $newpage->save();
--------------------------------------------------------------------------------
/api/api-create-shortlinks-for-jumplinks-module.php:
--------------------------------------------------------------------------------
1 | find('template=yourTemplate') as $yourpages) {
7 |
8 | // define a Jumplink path
9 | $from = "out/" . $yourpages->id;
10 |
11 | // define destination
12 | $to = $yourpages->www;
13 |
14 | // http://cheatsheet.processwire.com/page/built-in-methods-reference/page-setoutputformatting-true-false/
15 | $yourpages->setOutputFormatting(false);
16 |
17 | // add jumplink path to page
18 | $yourpages->shorturl = "/" . $from;
19 |
20 | // save page
21 | $yourpages->save();
22 |
23 | // create jumplink in Jumplinks module
24 | $this->modules->ProcessJumplinks->add($from, $to);
25 |
26 | };
--------------------------------------------------------------------------------
/api/api-formbuilder-entries-to-mailchimp.php:
--------------------------------------------------------------------------------
1 | get("mailchimp")->entries()->find('sort=id');
7 |
8 | foreach($entries as $entry){
9 | $mc = $modules->get("SubscribeToMailchimp");
10 |
11 | $mc_mail = $entry['e_mail'];
12 | $mc_fname = $entry['vorname'];
13 |
14 | $subscriber = [
15 | 'FNAME' => $mc_fname
16 | ];
17 |
18 | $mc->subscribe($mc_mail, $subscriber, 'SUPERSECRETMCHASH');
19 |
20 | wire('log')->save('mailchimp', $mc_mail . " - " . $mc_fname );
21 |
22 | }
--------------------------------------------------------------------------------
/api/api-get-formbuilder-entries.php:
--------------------------------------------------------------------------------
1 | get('your-form-name');
8 |
9 | // define entries you want to find (example: created 3 months ago)
10 | // Todo: more examples
11 | $entries = $form->entries()->find("created<=" . strtotime("-3 MONTH"));
12 |
--------------------------------------------------------------------------------
/api/api-limit-repeater-results.php:
--------------------------------------------------------------------------------
1 | repeater;
5 |
6 | // parts of your repeater with limited items based on your selection
7 | $myRepeaterSelection = $myRepeater->find('anotherField=value');
8 |
9 | // do whatever you want with your repeater selection
10 | echo count( $myRepeaterSelection );
11 |
12 | foreach( $myRepeaterSelection as $mrs) {
13 | // ...
14 | }
15 |
16 | // same as above but way shorter
17 | echo count( $page->repeater->find('anotherField=value') );
18 |
19 | foreach( $page->repeater->find('anotherField=value') as $item) {
20 | // ...
21 | }
22 |
23 | ?>
--------------------------------------------------------------------------------
/api/api-move-field-data-to-another-field.php:
--------------------------------------------------------------------------------
1 | find('template=yourTemplate') as $yourpages) {
7 |
8 | // define old field
9 | $old = $yourpages->oldfield;
10 |
11 | // http://cheatsheet.processwire.com/#sanitizer
12 | $oldcleaned = $sanitizer->text($old);
13 |
14 | // http://cheatsheet.processwire.com/page/built-in-methods-reference/page-setoutputformatting-true-false/
15 | $yourpages->setOutputFormatting(false);
16 |
17 | // place content in new field
18 | $yourpages->newfield = $oldcleaned;
19 |
20 | // save page
21 | $yourpages->save();
22 |
23 | };
24 |
25 |
--------------------------------------------------------------------------------
/api/api-page-subselect.php:
--------------------------------------------------------------------------------
1 | find("template=productTemplate") as $product) {
10 |
11 | // add brand from product page to brands array
12 | $brands->add($product->brandField);
13 |
14 | };
--------------------------------------------------------------------------------
/api/api-reset-password.php:
--------------------------------------------------------------------------------
1 | get('yourUsername');
7 |
8 | //http://cheatsheet.processwire.com/page/built-in-methods-reference/page-setoutputformatting-true-false/
9 | $thatGuyWhoForgotHisPassword->of(false);
10 |
11 | // set new password
12 | $thatGuyWhoForgotHisPassword->pass = 'your-new-super-secret-password-1111-elf';
13 |
14 | // save user
15 | $thatGuyWhoForgotHisPassword->save();
16 |
17 |
--------------------------------------------------------------------------------
/api/api-set-value-multilanguage.php:
--------------------------------------------------------------------------------
1 | language = $languages->get('en');
7 | $page->setAndSave('title', 'My title');
8 |
9 | $user->language = $languages->get('de');
10 | $page->setAndSave('title', 'Mein Titel');
11 |
12 | // Option 2
13 |
14 | // http://cheatsheet.processwire.com/page/built-in-methods-reference/page-setoutputformatting-true-false/
15 | $page->of(false);
16 | $page->title->setLanguageValue($languages->get('en'), 'My title');
17 | $page->title->setLanguageValue($languages->get('de'), 'Mein Titel');
18 |
19 |
20 | // save page
21 | $page->save();
22 |
23 |
--------------------------------------------------------------------------------
/api/api-update-created-date.php:
--------------------------------------------------------------------------------
1 | created = $timestamp
7 |
8 | // save page - yeah, a different way of saving a page
9 | // necessary in this case
10 | $page->save(array('quiet' => true))
--------------------------------------------------------------------------------
/backup-full-local/Modules/wbmnfktrAmazonUpdater/_amz/amz-action.php:
--------------------------------------------------------------------------------
1 | amz_asin;
7 | $request = aws_signed_request('de', array( 'Operation' => 'ItemLookup', 'ItemId' => $asin, 'ResponseGroup' => 'Images,ItemAttributes,Offers'), AWS_API_KEY, AWS_API_SECRET_KEY, AWS_ASSOCIATE_TAG);
8 | $response = @file_get_contents($request);
9 |
10 | if ($response === FALSE) {
11 |
12 | echo $asin . " - " . "Request failed.\n" . "
";
13 | // wenn keine Rückmeldung, Datensatz markieren
14 | $product = $pages->get("amz_asin=$asin");
15 | $product->of(false);
16 | $product->amz_failed = 1;
17 | $product->save();
18 |
19 | } else {
20 |
21 | // parse XML
22 | $pxml = simplexml_load_string($response);
23 | if ($pxml === FALSE) {
24 |
25 | echo "Response could not be parsed.\n";
26 |
27 | // wenn keine Rückmeldung, Datensatz markieren
28 | $product = $pages->get("amz_asin=$asin");
29 | $product->of(false);
30 | $product->amz_failed = 1;
31 | $product->save();
32 |
33 |
34 | } else {
35 |
36 | $titel = $pxml->Items->Item->ItemAttributes->Title;
37 | $brand = $pxml->Items->Item->ItemAttributes->Brand;
38 | $manufacturer = $pxml->Items->Item->ItemAttributes->Manufacturer;
39 | $preis = $pxml->Items->Item->OfferSummary->LowestNewPrice->Amount;
40 | $price = number_format($preis, 2, ',' , '.');
41 |
42 | $largeimage = $pxml->Items->Item->LargeImage->URL;
43 | $link = $pxml->Items->Item->DetailPageURL;
44 | $feature1 = $pxml->Items->Item->ItemAttributes->Feature[0];
45 | $feature2 = $pxml->Items->Item->ItemAttributes->Feature[1];
46 | $feature3 = $pxml->Items->Item->ItemAttributes->Feature[2];
47 | $feature4 = $pxml->Items->Item->ItemAttributes->Feature[3];
48 | $feature5 = $pxml->Items->Item->ItemAttributes->Feature[4];
49 | $prime = $pxml->Items->Item->Offers->Offer->OfferListing->IsEligibleForPrime;
50 | // $features = $feature1 . " " . $feature2 . " " . $feature3 . " " . $feature4 ;
51 | // $largeimage = $pxml->Items->Item->ImageSets->ImageSet->LargeImage->URL;
52 |
53 |
54 | if($product->amz_check) {
55 |
56 | $product = $pages->get("amz_asin=$asin");
57 | $product->of(false);
58 | $product->amz_prime = $prime;
59 | $product->amz_link = $link;
60 | $product->amz_manufacturer = $manufacturer;
61 | $product->amz_price = number_format(($preis / 100), 2, ',' , '.');
62 | $product->amz_failed = 0;
63 | $product->save();
64 | echo $product->amz_asin . " - " . "aktualisiert (kleine Abfrage).\n" . "
";
65 |
66 | } else {
67 |
68 | $product = $pages->get("amz_asin=$asin");
69 | $product->of(false);
70 | $product->amz_prod = $titel;
71 | $product->amz_brand = $brand;
72 | $product->brand = $brand;
73 | $product->amz_manufacturer = $manufacturer;
74 | $product->amz_f1 = $feature1;
75 | $product->amz_f2 = $feature2;
76 | $product->amz_f3 = $feature3;
77 | $product->amz_f4 = $feature4;
78 | $product->amz_f5 = $feature5;
79 | $product->amz_prime = $prime;
80 | $product->amz_link = $link;
81 | $product->amz_price = number_format(($preis / 100), 2, ',' , '.');
82 | $product->amz_imageurl = $largeimage;
83 | $product->amz_failed = 0;
84 | $product->amz_check = 1;
85 | $product->save();
86 | if(count($product->amz_image)) { $product->of(false); $product->amz_image->removeAll(); };
87 | $product->save();
88 | $product->of(false);
89 | $product->amz_image->add("$product->amz_imageurl");
90 | $product->save();
91 |
92 | echo $product->amz_asin . " - " . "aktualisiert (Initialabfrage).\n" . "
";
93 |
94 |
95 | // echo $largeimage;
96 | // echo "
";
97 | // var_dump($pxml);
98 |
99 | };
100 |
101 | }
102 | };
103 |
104 |
105 | echo "
";
106 |
107 |
108 |
109 | };
--------------------------------------------------------------------------------
/backup-full-local/Modules/wbmnfktrAmazonUpdater/_amz/amz-func.php:
--------------------------------------------------------------------------------
1 | $value)
36 | {
37 | $param = str_replace('%7E', '~', rawurlencode($param));
38 | $value = str_replace('%7E', '~', rawurlencode($value));
39 | $canonicalized_query[] = $param.'='.$value;
40 | }
41 | $canonicalized_query = implode('&', $canonicalized_query);
42 |
43 |
44 | // create the string to sign
45 | $string_to_sign = $method."\n".$host."\n".$uri."\n".$canonicalized_query;
46 |
47 |
48 | // calculate HMAC with SHA256 and base64-encoding
49 | $signature = base64_encode(hash_hmac('sha256', $string_to_sign, $private_key, TRUE));
50 |
51 |
52 | // encode the signature for the request
53 | $signature = str_replace('%7E', '~', rawurlencode($signature));
54 |
55 |
56 | // create request
57 | $request = 'http://'.$host.$uri.'?'.$canonicalized_query.'&Signature='.$signature;
58 |
59 | return $request;
60 | };
--------------------------------------------------------------------------------
/backup-full-local/Modules/wbmnfktrAmazonUpdater/_amz/amz-vars.php:
--------------------------------------------------------------------------------
1 | get("id=1289")->amz_asin;
11 |
12 | $request = aws_signed_request('de', array( 'Operation' => 'ItemLookup', 'ItemId' => $asin, 'ResponseGroup' => 'Images,ItemAttributes,Offers'), AWS_API_KEY, AWS_API_SECRET_KEY, AWS_ASSOCIATE_TAG);
13 | $response = @file_get_contents($request);
14 |
15 | if ($response === FALSE) {
16 |
17 | echo $asin . " - " . "Request failed." . "
";
18 | // wenn keine Rückmeldung, Datensatz markieren
19 | $product = wire('pages')->get("amz_asin=$asin");
20 | $product->of(false);
21 | $product->amz_failed = 1;
22 | $product->save();
23 |
24 | } else {
25 |
26 | // parse XML
27 | $pxml = simplexml_load_string($response);
28 | if ($pxml === FALSE) {
29 |
30 | echo "Response could not be parsed.\n";
31 |
32 | // wenn keine Rückmeldung, Datensatz markieren
33 | $product = wire('pages')->get("amz_asin=$asin");
34 | $product->of(false);
35 | $product->amz_failed = 1;
36 | $product->save();
37 |
38 |
39 | } else {
40 |
41 | $titel = $pxml->Items->Item->ItemAttributes->Title;
42 | $brand = $pxml->Items->Item->ItemAttributes->Brand;
43 | $manufacturer = $pxml->Items->Item->ItemAttributes->Manufacturer;
44 | $preis = $pxml->Items->Item->OfferSummary->LowestNewPrice->Amount;
45 | $price = number_format($preis, 2, ',' , '.');
46 |
47 | $largeimage = $pxml->Items->Item->LargeImage->URL;
48 | $link = $pxml->Items->Item->DetailPageURL;
49 | $feature1 = $pxml->Items->Item->ItemAttributes->Feature[0];
50 | $feature2 = $pxml->Items->Item->ItemAttributes->Feature[1];
51 | $feature3 = $pxml->Items->Item->ItemAttributes->Feature[2];
52 | $feature4 = $pxml->Items->Item->ItemAttributes->Feature[3];
53 | $feature5 = $pxml->Items->Item->ItemAttributes->Feature[4];
54 | $prime = $pxml->Items->Item->Offers->Offer->OfferListing->IsEligibleForPrime;
55 |
56 |
57 | $product = wire('pages')->get("amz_asin=$asin");
58 | $product->of(false);
59 | $product->title = $titel;
60 | $product->amz_prod = $titel;
61 | $product->amz_brand = $brand;
62 | $product->brand = $brand;
63 | $product->amz_manufacturer = $manufacturer;
64 | $product->amz_f1 = $feature1;
65 | $product->amz_f2 = $feature2;
66 | $product->amz_f3 = $feature3;
67 | $product->amz_f4 = $feature4;
68 | $product->amz_f5 = $feature5;
69 | $product->amz_prime = $prime;
70 | $product->amz_link = $link;
71 | $product->amz_price = number_format(($preis / 100), 2, ',' , '.');
72 | $product->amz_imageurl = $largeimage;
73 | $product->amz_failed = 0;
74 | $product->amz_check = 1;
75 | $product->save();
76 | if(count($product->amz_image)) { $product->of(false); $product->amz_image->removeAll(); };
77 | $product->save();
78 | $product->of(false);
79 | $product->amz_image->add("$product->amz_imageurl");
80 | $product->save();
81 |
82 | echo $product->amz_asin . " - " . "aktualisiert." . "
";
83 |
84 |
85 |
86 | }
87 | };
88 |
89 |
90 | echo "
";
91 |
92 | };
93 |
94 |
95 |
96 | ?>
--------------------------------------------------------------------------------
/backup-full-local/Modules/wbmnfktrAmazonUpdater/wbmnfktrAmazonUpdater.module:
--------------------------------------------------------------------------------
1 | "Amazon API Updater",
22 | 'version' => "0.0.1",
23 | 'summary' => "Amazon Affiliate API Abfrage auf Basis der ASIN.",
24 |
25 | 'author' => "webmanufaktur",
26 | 'href' => "https://webmanufaktur.net/",
27 |
28 | 'icon' => 'amazon',
29 |
30 | 'autoload' => true,
31 | 'singular' => true
32 |
33 |
34 | );
35 | }
36 |
37 | // static public function getDefaults() {
38 | // return array(
39 | // "key" => "value"
40 | // );
41 | // }
42 |
43 | public function __construct()
44 | {
45 | parent::__construct();
46 |
47 | $this->set('amazonkey', '');
48 | $this->set('amazonsecretkey', '');
49 | $this->set('amazontag', 'yourtag-20');
50 | $this->set('amazonasinfield', 'asin');
51 | $this->set('amazontemplate', 'amazon');
52 | }
53 |
54 | public function getModuleConfigInputfields(InputfieldWrapper $wrapper)
55 | {
56 |
57 | $amazonkey = $this->modules->InputfieldText;
58 | $amazonkey->name = 'amazonkey';
59 | $amazonkey->label = $this->_('Amazon API Key');
60 | $amazonkey->value = $this->amazonkey;
61 | $amazonkey->required = true;
62 | $wrapper->add($amazonkey);
63 |
64 | $amazonsecretkey = $this->modules->InputfieldText;
65 | $amazonsecretkey->name = 'amazonsecretkey';
66 | $amazonsecretkey->label = $this->_('Amazon Secret Key');
67 | $amazonsecretkey->value = $this->amazonsecretkey;
68 | $amazonsecretkey->required = true;
69 | $wrapper->add($amazonsecretkey);
70 |
71 | $amazontag = $this->modules->InputfieldText;
72 | $amazontag->name = 'amazontag';
73 | $amazontag->label = $this->_('Amazon Affiliate Tag');
74 | $amazontag->value = $this->amazontag;
75 | $amazontag->required = true;
76 | $wrapper->add($amazontag);
77 |
78 | $amazonasinfield = $this->modules->InputfieldText;
79 | $amazonasinfield->name = 'amazonasinfield';
80 | $amazonasinfield->label = $this->_('Amazon ASIN Feld');
81 | $amazonasinfield->value = $this->amazonasinfield;
82 | $amazonasinfield->required = true;
83 | $wrapper->add($amazonasinfield);
84 |
85 | $amazontemplate = $this->modules->InputfieldText;
86 | $amazontemplate->name = 'amazontemplate';
87 | $amazontemplate->label = $this->_('Amazon Produkt Template');
88 | $amazontemplate->value = $this->amazontemplate;
89 | $amazontemplate->required = true;
90 | $wrapper->add($amazontemplate);
91 |
92 | return $wrapper;
93 |
94 | }
95 |
96 | public function init()
97 | {
98 | $this->pages->addHookAfter('Pages::saveReady', $this, 'wbmfktrUpdateGMaps');
99 | }
100 |
101 | public function wbmfktrUpdateGMaps($event)
102 | {
103 |
104 | $page = $event->arguments[0];
105 |
106 | if($page->template == "$this->amazontemplate" && !$page->isTrash()){
107 |
108 | $this->message("Amazon ist bereit");
109 |
110 | if($page->strasse && $page->plz && $page->ort) {
111 |
112 | $location = $page->strasse . " " . $page->plz . " " . $page->ort;
113 | $page->googlemaps->address = $location;
114 | $page->trackChange('googlemaps');
115 | // $this->message("Google Maps aktualisiert");
116 |
117 | }
118 |
119 | // $this->message("You just saved page: {$page->strasse}");
120 |
121 | }
122 |
123 | }
124 |
125 | }
--------------------------------------------------------------------------------
/backup-full-local/Modules/wbmnfktrGoogleMapsUpdater/wbmnfktrGoogleMapsUpdater.module:
--------------------------------------------------------------------------------
1 | 'Google Maps Updater',
10 | 'summary' => 'Befüllt Google Maps Marker Felder auf Basis eingegebener Daten',
11 | 'version' => '101',
12 | 'author' => 'webmanufaktur',
13 | 'href' => 'https://webmanufaktur.net/',
14 | 'icon' => 'map-marker',
15 | 'requires' => 'FieldtypeMapMarker',
16 | 'singular' => true,
17 | 'autoload' => true
18 |
19 | );
20 | }
21 |
22 | public function init() {
23 | $this->pages->addHookAfter('Pages::saveReady', $this, 'wbmfktrUpdateGMaps');
24 | }
25 | public function wbmfktrUpdateGMaps($event) {
26 |
27 | $page = $event->arguments[0];
28 |
29 | if($page->template == "partner" && !$page->isTrash()){
30 |
31 | if($page->strasse && $page->plz && $page->ort) {
32 |
33 | $location = $page->strasse . " " . $page->plz . " " . $page->ort;
34 | $page->googlemaps->address = $location;
35 | $page->trackChange('googlemaps');
36 | // $this->message("Google Maps aktualisiert");
37 |
38 | }
39 |
40 | // $this->message("You just saved page: {$page->strasse}");
41 |
42 | }
43 |
44 | }
45 |
46 | };
47 |
--------------------------------------------------------------------------------
/backup-full-local/Modules/wbmnfktrInventoryChecker/wbmnfktrInventoryChecker.module:
--------------------------------------------------------------------------------
1 | 'Bestandsmelder für Mittagstischangebote',
11 | 'summary' => 'Überprüft die Bestände der Mittagstischangebote und meldet per E-Mail, wenn ein bestimmter Stand erreicht bzw. unterschritten wird.',
12 | 'version' => '001',
13 | 'author' => 'webmanufaktur',
14 | 'href' => 'https://webmanufaktur.net/',
15 | 'icon' => 'cutlery',
16 | 'singular' => true,
17 | 'autoload' => true
18 |
19 | );
20 |
21 | }
22 |
23 | public function init() {
24 |
25 | // wire('log')->save('wbmnfktr-debug', "Bestandsprüfer: " . $this->date);
26 |
27 | if(!$this->template or !$this->criticalamount or !$this->subject or !$this->receiver or !$this->sender or !$this->text or !$this->date) {
28 |
29 |
30 |
31 | } else {
32 |
33 |
34 | wire()->addHookAfter('LazyCron::everyDay', function (HookEvent $e) { //everyDay every30Seconds
35 |
36 | $pages = wire('pages');
37 | $gerichte = $pages->find("template=$this->template, $this->date>now");
38 | $kritischemenge = $this->criticalamount;
39 | $vorhandenemenge = count($gerichte);
40 |
41 | wire('log')->save('wbmnfktr-debug', "Bestandsprüfer: " . $vorhandenemenge);
42 |
43 | if($vorhandenemenge <= $kritischemenge ) {
44 |
45 | wire('log')->save('wbmnfktr-debug', "Bestandsprüfung erfolgt." . $vorhandenemenge);
46 |
47 | if( wire('config')->https ) { $host = "https://"; } else { $host = "http://"; };
48 | $to = $this->receiver;
49 | $from = $this->sender;
50 | $subject = $this->subject;
51 | $body = $this->text;
52 | $body .= "\n\nMittagstischangebote: " . $vorhandenemenge;
53 | $body .= "\n\nAdmin-Backend aufrufen: " . $host . wire('config')->httpHost . wire('config')->urls->admin;
54 |
55 | if($this->signature) {
56 | $body .= "\n\n" . $this->signature . "\n\n";
57 | };
58 |
59 | wire('mail')->send($to, $from, $subject, $body);
60 |
61 | // wire('log')->save('wbmnfktr-debug', $vorhandenemenge . " - " . $to . " " . $from . " " . $subject . " " . $body);
62 |
63 | };
64 |
65 | });
66 |
67 | };
68 |
69 | }
70 |
71 |
72 | public function getModuleConfigInputfields(InputfieldWrapper $wrapper)
73 | {
74 |
75 | // Template ====================
76 | $tpl = $this->modules->InputfieldText;
77 | $tpl->name = 'template';
78 | $tpl->label = $this->_('Template');
79 | $tpl->value = $this->template;
80 |
81 | $tpl->description = $this->_('Template der Mittagstischangeboten');
82 | $tpl->notes = $this->_('Zum Beispiel: gericht');
83 | // $tpl->placeholder = 'gericht';
84 | $tpl->required = true;
85 | $tpl->columnWidth = 33;
86 | $wrapper->add($tpl);
87 |
88 | // Datumsfeld ====================
89 | $dte = $this->modules->InputfieldText;
90 | $dte->name = 'date';
91 | $dte->label = $this->_('Datumsfeld');
92 | $dte->value = $this->date;
93 |
94 | $dte->description = $this->_('Datumsfeld');
95 | $dte->notes = $this->_('Zum Beispiel: gericht');
96 | // $dte->placeholder = 'gericht';
97 | $dte->required = true;
98 | $dte->columnWidth = 33;
99 | $wrapper->add($dte);
100 |
101 | // Kritische Menge ====================
102 | $cra = $this->modules->InputfieldInteger;
103 | $cra->name = 'criticalamount';
104 | $cra->label = $this->_('Kritische Menge');
105 | $cra->value = $this->criticalamount;
106 |
107 | $cra->description = $this->_('Kritische Menge');
108 | $cra->notes = $this->_('5 oder 15, Hauptsache eine Ganzzahl');
109 | // $cra->placeholder = '5';
110 | $cra->required = true;
111 | $cra->columnWidth = 34;
112 | $wrapper->add($cra);
113 |
114 | // Betreff ====================
115 | $sbj = $this->modules->InputfieldText;
116 | $sbj->name = 'subject';
117 | $sbj->label = $this->_('E-Mail Betreff');
118 | $sbj->value = $this->subject;
119 |
120 | $sbj->description = $this->_('Betreff der E-Mail.');
121 | $sbj->notes = $this->_('Beispiel: [Bestandswarnung] Nicht mehr viele Mittagstischangebote');
122 | $sbj->placeholder = '[Bestandswarnung] Nicht mehr viele Mittagstischangebote';
123 | $sbj->required = true;
124 | $sbj->columnWidth = 33;
125 | $wrapper->add($sbj);
126 |
127 | // Empfänger ====================
128 | $rcv = $this->modules->InputfieldText;
129 | $rcv->name = 'receiver';
130 | $rcv->label = $this->_('E-Mail Empfänger');
131 | $rcv->value = $this->receiver;
132 |
133 | $rcv->description = $this->_('E-Mail Adresse des Empfängers.');
134 | $rcv->notes = $this->_('Beispiel: to@' . wire('config')->httpHost);
135 | $rcv->placeholder = 'to@' . wire('config')->httpHost;
136 | $rcv->required = true;
137 | $rcv->columnWidth = 33;
138 | $wrapper->add($rcv);
139 |
140 | // Absender ====================
141 | $snd = $this->modules->InputfieldText;
142 | $snd->name = 'sender';
143 | $snd->label = $this->_('E-Mail Absender');
144 | $snd->value = $this->sender;
145 |
146 | $snd->description = $this->_('E-Mail Adresse des Empfängers.');
147 | $snd->notes = $this->_('Beispiel: from@' . wire('config')->httpHost);
148 | $snd->placeholder = 'from@' . wire('config')->httpHost;
149 | $snd->required = true;
150 | $snd->columnWidth = 34;
151 | $wrapper->add($snd);
152 |
153 | // Text ====================
154 | $txt = $this->modules->InputfieldTextarea;
155 | $txt->name = 'text';
156 | $txt->label = $this->_('E-Mail Text');
157 | $txt->value = $this->text;
158 |
159 | $txt->description = $this->_('E-Mail Text mit weiteren Informationen oder Anmerkungen.');
160 | $txt->notes = $this->_('Beispiel: Es sind nur noch wenige Mittagstischangebote vorhanden. Bitte überprüfen.');
161 | // $txt->placeholder = '[Bestandswarnung] Nicht mehr viele Mittagstischangebote';
162 | $txt->required = false;
163 | $txt->columnWidth = 100;
164 | $wrapper->add($txt);
165 |
166 | // Signature ====================
167 | $sig = $this->modules->InputfieldTextarea;
168 | $sig->name = 'signature';
169 | $sig->label = $this->_('E-Mail Signatur');
170 | $sig->value = $this->signature;
171 |
172 | // $sig->description = $this->_('E-Mail Text mit weiteren Informationen oder Anmerkungen.');
173 | // $sig->notes = $this->_('Beispiel: Es sind nur noch wenige Mittagstischangebote vorhanden. Bitte überprüfen.');
174 | // $sig->placeholder = '[Bestandswarnung] Nicht mehr viele Mittagstischangebote';
175 | $sig->required = false;
176 | $sig->columnWidth = 100;
177 | $wrapper->add($sig);
178 |
179 | return $wrapper;
180 |
181 | }
182 |
183 | };
184 |
--------------------------------------------------------------------------------
/backup-full-local/Snippets/_functions.php:
--------------------------------------------------------------------------------
1 | save('debug', '_functions.php');
4 |
5 | function listingKurseEnsembles($p, $o) {
6 | return join(' und ', array_filter(array_merge(array(join(', ', array_slice(wire('pages')->get("id=$p")->$o->explode('title'), 0, -1))), array_slice(wire('pages')->get("id=$p")->$o->explode('title'), -1)), 'strlen'));
7 | };
8 |
9 | function dozentin($p) {
10 | return (wire('pages')->get("id=$p")->anrede == '1') ? 'Dozentin' : 'Dozent';
11 | }
12 |
13 | function ersie($p) {
14 | return (wire('pages')->get("id=$p")->anrede == '1') ? 'Sie' : 'Er';
15 | }
16 |
17 | function generateSeoTitle($p, $t) {
18 |
19 | $pages = wire('pages');
20 | $page = $pages->get("id=$p");
21 |
22 | $ersie = ersie($p);
23 | $dozentin = dozentin($p);
24 | $kurse = listingKurseEnsembles($p, 'kurs');
25 | $ensembles = listingKurseEnsembles($p, 'ensemble');
26 |
27 | // VORNAME NACHNAME ist DOZENT/IN für INSTRUMEKURSE an der Musikschule Neumünster.
28 | // echo $page->title . " ist " . $dozentin . " für " . $kurse . ".";
29 |
30 | if($t == "dozent") {
31 | echo "{$page->title} ist {$dozentin} für {$kurse}. {$ersie}";
32 | }
33 |
34 | };
35 |
36 | //
37 | // if($page->template == "dozent") { generateSeoTitle($page->id, $page->template->name); };
38 | //
39 |
40 |
41 |
42 |
43 | // wire('log')->save('debug', '_init.php');
44 |
45 |
46 | // Globale Funktionen
47 | //include_once('./_functions.php');
48 |
49 | function generateSeoTitle($p) {
50 |
51 | $pages = wire('pages');
52 | $page = $pages->get("id=$p");
53 |
54 | // ab hier für Dozenten-Seiten
55 | if($page->template->name == 'dozent') {
56 |
57 | // sind Instrumente und Kurse hinterlegt?
58 | if(count($page->kurs) > 0) {
59 |
60 | $pt = $page->title;
61 | $ps = ($page->anrede == '1') ? 'Dozentin' : 'Dozent';
62 | $pk = $page->kurs->explode('title'); // ->implode(', ', 'title');
63 |
64 | $pk2 = join(' und ', array_filter(array_merge(array(join(', ', array_slice($pk, 0, -1))), array_slice($pk, -1)), 'strlen'));
65 | $pagetitle = "{$pt} - {$ps} für {$pk2} an der Musikschule Neumünster";
66 | $gpd = "{$ps} {$pt} unterrichtet {$pk2} an der Musikschule Neumünster.";
67 |
68 | return $pagetitle; // = $gpt;
69 | //$pagedesc = $gpd;
70 |
71 | // sind Ensembles hinterlegt?
72 | } else if(count($page->ensemble) > 0) {
73 |
74 | $pt = $page->title;
75 | $ps = ($page->anrede == '1') ? 'Ensemble-Leiterin' : 'Ensemble-Leiter';
76 | $pk = $page->ensemble->explode('title'); // ->implode(', ', 'title');
77 |
78 | $pk2 = join(' und ', array_filter(array_merge(array(join(', ', array_slice($pk, 0, -1))), array_slice($pk, -1)), 'strlen'));
79 | $gpt = "{$pt} - {$ps} des Ensembles {$pk2} an der Musikschule Neumünster";
80 | $gpd = "{$pt} - {$ps} des Ensembles {$pk2} an der Musikschule Neumünster";
81 |
82 | return $pagetitle = $gpt;
83 | $pagedesc = $gpd;
84 |
85 | // keine Instrumente, Kurse oder Ensembles?
86 | } else {
87 |
88 | return $pagetitle = $page->get('headline|title');
89 | $pagedesc = "";
90 |
91 | };
92 |
93 | // ab hier für die Dozenten-Übersicht
94 | } else if($page->template->name == 'dozenten') {
95 |
96 | $gpt = "Die {$dozentenCount} Dozentinnen und Dozenten der Musikschule Neumünster stellen sich vor";
97 | $pagetitle = $gpt;
98 | $pagedesc = "";
99 |
100 | // ab hier für Intrumenten- und Kurs-Seiten
101 | } else if($page->template->name == 'kurs') {
102 |
103 | if($page->instrumentkurs == "1") {
104 |
105 | $dc = (count($page->dozent) > 1) ? 'Dozenten' : 'Dozent';
106 | $dcc = count($page->dozent);
107 |
108 | $gpt = "Musikunterricht {$page->title}: {$page->title} lernen in Neumünster ({$dcc} {$dc})";
109 |
110 | // INSTRUMENT lernen (ANZAHL Dozenten) | Musikschule Neumünster
111 | $pagetitle = $gpt;
112 | $pagedesc = "";
113 |
114 | } else {
115 |
116 | // INSTRUMENT lernen (ANZAHL Dozenten) | Musikschule Neumünster
117 | $dc = (count($page->dozent) > 1) ? 'Dozenten' : 'Dozent';
118 | $dcc = count($page->dozent);
119 |
120 | $gpt = "Kurs für {$page->title} an der Musikschule Neumünster ({$dcc} {$dc})";
121 |
122 | // INSTRUMENT lernen (ANZAHL Dozenten) | Musikschule Neumünster
123 | $pagetitle = $gpt;
124 | $pagedesc = "";
125 |
126 | };
127 |
128 | // ab hier für die Kurs/Instrumenten-Übersicht
129 | } else if($page->template->name == 'kurse') {
130 |
131 | $gpt = "Alle {$instrumentekurseCount} Instrumente und Kurse der Musikschule Neumünster";
132 | $pagetitle = $gpt;
133 | $pagedesc = "";
134 |
135 | // ab hier für die Ensemble-Übersicht
136 | } else if($page->template->name == 'ensembles') {
137 |
138 | $gpt = "Alle {$ensemblesCount} Ensembles der Musikschule Neumünster";
139 | $pagetitle = $gpt;
140 | $pagedesc = "";
141 |
142 | // ab hier für die Ensemble-Übersicht
143 | } else if($page->template->name == 'events') {
144 |
145 | $gpt = "Termine und Veranstaltungsempfehlungen der Musikschule Neumünster ({$eventsCount} Einträge)";
146 | $pagetitle = $gpt;
147 | $pagedesc = "";
148 |
149 | // ab hier für die Startseite
150 | } else if($page->template == 'home') {
151 |
152 | $gpt = "Musikschule Neumünster – {$dozentenCount} Dozenten, {$instrumentekurseCount} Instrumente, {$ensemblesCount} Ensembles";
153 |
154 | echo $pagetitle = $gpt;
155 | $pagedesc = "";
156 |
157 | } else {
158 |
159 | $pagetitle = $page->get('headline|title');
160 | $pagedesc = "";
161 |
162 | };
163 |
164 | };
165 |
166 |
--------------------------------------------------------------------------------
/backup-full-local/Snippets/api-create-page.php:
--------------------------------------------------------------------------------
1 | setOutputFormatting(false);
7 | $newpage->template = 'your_template'; // example template
8 | $newpage->parent = wire('pages')->get('/parent/'); // example parent
9 | $newpage->name = "foo"; // example name
10 | $newpage->title = "My API-generated new PW page";
11 | $newpage->fieldname = "my field value"; // example field with example value
12 | $newpage->save();
--------------------------------------------------------------------------------
/backup-full-local/Snippets/api-create-shortlinks-for-jumplinks-module.php:
--------------------------------------------------------------------------------
1 | find('template=your_template') as $yourpages)
7 | {
8 |
9 | $from = "out/".$yourpages->id;
10 | $to = $yourpages->www;
11 |
12 | $yourpages->setOutputFormatting(false);
13 | $yourpages->shorturl = "/".$from;
14 | $yourpages->save();
15 |
16 | $this->modules->ProcessJumplinks->add($from, $to);
17 |
18 | };
--------------------------------------------------------------------------------
/backup-full-local/Snippets/api-formbuilder-entries.php:
--------------------------------------------------------------------------------
1 | get('your-form-name');
4 | $entries = $form->entries()->find("created<=" . strtotime("-3 MONTH"));
5 | // $entries now contains all your older-than-3-months entries
--------------------------------------------------------------------------------
/backup-full-local/Snippets/api-move-field-data-to-another-field.php:
--------------------------------------------------------------------------------
1 | find('template=your_template') as $yourpages)
7 | {
8 |
9 | $old = $yourpages->oldfield;
10 | $oldcleaned = $sanitizer->text($old);
11 |
12 | $yourpages->setOutputFormatting(false);
13 | $yourpages->newfield = $oldcleaned;
14 | $yourpages->save();
15 |
16 | };
17 |
18 |
--------------------------------------------------------------------------------
/backup-full-local/Snippets/api-page-subselect.php:
--------------------------------------------------------------------------------
1 | find("template=product, amz_price>0") as $watch) {
5 | $brands->add($watch->brand);
6 | };
--------------------------------------------------------------------------------
/backup-full-local/Snippets/api-reset-password.php:
--------------------------------------------------------------------------------
1 | get('admin'); // or whatever your username is
4 | $u->of(false);
5 | $u->pass = 'your-new-password';
6 | $u->save();
7 |
8 |
--------------------------------------------------------------------------------
/backup-full-local/Snippets/api-set-value-by-language.php:
--------------------------------------------------------------------------------
1 | language = $languages->get('en');
6 | $page->setAndSave('title', 'My title');
7 |
8 | $user->language = $languages->get('de');
9 | $page->setAndSave('title', 'Mein Titel');
10 |
11 | // Option 2
12 |
13 | $page->of(false);
14 | $page->title->setLanguageValue($languages->get('en'), 'My title');
15 | $page->title->setLanguageValue($languages->get('de'), 'Mein Titel');
16 | $page->save();
17 |
18 |
--------------------------------------------------------------------------------
/backup-full-local/Snippets/api-update-created-date.php:
--------------------------------------------------------------------------------
1 | created = $timestamp
6 | $page->save(array('quiet' => true))
--------------------------------------------------------------------------------
/backup-full-local/Snippets/ckeditor-text-align.txt:
--------------------------------------------------------------------------------
1 | JustifyLeft, JustifyCenter, JustifyRight, JustifyBlock
--------------------------------------------------------------------------------
/backup-full-local/Snippets/config-serial-key-procache.txt:
--------------------------------------------------------------------------------
1 | Edit your /site/templates/admin.php file and paste in the following after the opening getModuleConfigData('ProCache');
4 | $data['licenseKey'] = 'PASTE-YOUR-KEY-HERE';
5 | $modules->saveModuleConfigData('ProCache', $data);
--------------------------------------------------------------------------------
/backup-full-local/Snippets/config-session-allow.php:
--------------------------------------------------------------------------------
1 | sessionAllow = function($session) {
6 |
7 | // if there is a session cookie, chances are user is logged in
8 | if($session->hasCookie()) {
9 | return true;
10 | }
11 |
12 | // if requested URL is an admin URL, allow session
13 | if(strpos($_SERVER['REQUEST_URI'], $session->config->urls->admin) === 0) {
14 | return true;
15 | }
16 |
17 | // otherwise disallow session
18 | return false;
19 |
20 | };
--------------------------------------------------------------------------------
/backup-full-local/Snippets/delete-form-builder-entries-after-time.php:
--------------------------------------------------------------------------------
1 | addHookAfter('LazyCron::every30Seconds', function (HookEvent $e) {
4 |
5 | $age = (time() - (14 * 86400));
6 | $form = $e->forms->get("contact");
7 | $entriesOld = $form->entries()->find("created<$age");
8 |
9 | foreach($entriesOld as $entry) {
10 | $form->entries()->delete($entry[id]);
11 | $e->wire('log')->save('archiv', 'Kontaktanfrage gelöscht ' . $entry[created]);
12 | };
13 |
14 | });
--------------------------------------------------------------------------------
/backup-full-local/Snippets/form-refocus.js:
--------------------------------------------------------------------------------
1 | // scroll to form submitted message
2 | jQuery(document).ready(function($) {
3 | var f = $('#FormBuilderSubmitted');
4 | if(!f.length) return;
5 | var y = f.offset().top;
6 | $('body').animate( { scrollTop: y }, 'slow');
7 | });
--------------------------------------------------------------------------------
/backup-full-local/Snippets/google-analytics-opt-out.js:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/backup-full-local/Snippets/init.php:
--------------------------------------------------------------------------------
1 | get('/');
4 |
5 | $settings = $pages->get('template=settings');
6 |
7 | $title = $page->get('seotitle|headline|title');
8 |
9 | $headline = $page->get('headline|title');
10 |
11 | $robots = $page->get('seorobots')->value;
12 |
13 | $desc = $page->get('seodesc');
14 |
15 | // https://github.com/dragan1700/pw/blob/master/init.inc
16 |
17 | $lang = $user->language->name; // e.g. "default" or "en"
18 |
19 | if($lang == 'default') {
20 | $htmlLang = 'de';
21 | $homeURL = $config->urls->root;
22 | $addtocart = "Zur Liste hinzufügen";
23 | }
24 | if($lang == 'en') {
25 | $htmlLang = $lang;
26 | $homeURL = $config->urls->root . 'en/';
27 | $addtocart = "Add to list";
28 | }
--------------------------------------------------------------------------------
/backup-full-local/Snippets/mailer.php:
--------------------------------------------------------------------------------
1 | ";
5 | $formdata = json_decode($formdata);
6 | foreach($formdata as $field) {
7 | switch($field->name) {
8 | case 'email':
9 | case 'name':
10 | case 'tel':
11 | $html .= "" . $field->name . ": " . $sanitizer->text($field->value) . "
";
12 | if($field->name == 'email') $email = $sanitizer->email($field->value);
13 | break;
14 | case 'message':
15 | $html .= "" . $field->name . ":
---
" . nl2br($sanitizer->textarea($field->value)) . "
---
";
16 | //${$field->name} = $sanitizer->textarea($field->value);
17 | break;
18 | case 'mail':
19 | // honeypot
20 | if($field->value) $subject = 'SPAM: '.$subject;
21 | break;
22 | }
23 | }
24 | $html .= "