| | |
| | | <?php |
| | | namespace JVBase\registrar; |
| | | |
| | | use JVBase\managers\SEO\render\Thing\Organization\LocalBusiness\LocalBusiness; |
| | | use JVBase\managers\SEO\render\Thing\Thing; |
| | | use JVBase\registrar\fields\Field; |
| | | use JVBase\registrar\fields\GroupedField; |
| | | use JVBase\registrar\fields\OptionsField; |
| | |
| | | |
| | | public function modifyField(string $name, string $property, mixed $value):void |
| | | { |
| | | $property = 'set'.implode('',array_map('ucfirst',explode('_', $property))); |
| | | $field = $this->fields[$name]; |
| | | $field->$property = $value; |
| | | $field->$property($value); |
| | | } |
| | | |
| | | public function getFields():array |
| | |
| | | |
| | | public function addCommon(string $name):self |
| | | { |
| | | match ($name) { |
| | | 'wiki' => $this->addWikiField(), |
| | | 'links' => $this->addLinksField(), |
| | | 'contact' => $this->addContactField(), |
| | | 'reviews', 'review' => $this->addReviewField(), |
| | | 'alternate_name' => $this->addAlternateName(), |
| | | 'keywords' => $this->addKeywords(), |
| | | default => error_log('[Field]addCommon: No configuration found for '.$name.'.') |
| | | }; |
| | | $method = 'add'.implode('',array_map('ucfirst',explode('_', $name))).'Field'; |
| | | if (method_exists($this, $method)) { |
| | | $this->$method(); |
| | | } else { |
| | | error_log('[Field]addCommon: No configuration found for '.$name.'.'); |
| | | } |
| | | return $this; |
| | | } |
| | | |
| | | protected function addWikiField():void |
| | | protected function addWikiField(?string $label = null):void |
| | | { |
| | | $this->addField( |
| | | 'wiki', |
| | | [ |
| | | 'type' => 'url', |
| | | 'label' => 'Wikipedia Page', |
| | | 'label' => $label ?: 'Wikipedia Page', |
| | | 'description' => 'For the schema', |
| | | 'quickEdit' => true, |
| | | ] |
| | | ); |
| | | } |
| | | |
| | | protected function addLinksField():void |
| | | protected function addLinksField(?string $label = null):void |
| | | { |
| | | $this->addField( |
| | | 'links', |
| | |
| | | 'type' => 'repeater', |
| | | 'quickEdit' => true, |
| | | 'add_label' => 'title', |
| | | 'label' => 'Online Links', |
| | | 'label' => $label ?:'Online Links', |
| | | 'description' => 'These are listed publicly on the website', |
| | | 'fields' => [ |
| | | 'url' => [ |
| | |
| | | 'type' => 'text', |
| | | 'label' => 'Tracker', |
| | | 'description' => 'If you are set up to track link referrals, add what comes after the ? here.', |
| | | 'default' => 'ref=edmonton_ink' |
| | | ], |
| | | ], |
| | | 'section' => 'contact' |
| | |
| | | ); |
| | | } |
| | | |
| | | protected function addReviewField():void |
| | | protected function addReviewField(?string $label = null):void |
| | | { |
| | | $this->addField( |
| | | 'reviews', |
| | | [ |
| | | 'type' => 'repeater', |
| | | 'add_label' => 'name', |
| | | 'label' => 'Reviews', |
| | | 'fields' => [ |
| | | 'name' => [ |
| | | 'type' => 'text', |
| | | 'label' => 'Reviewer Name', |
| | | ], |
| | | 'review' => [ |
| | | 'type' => 'textarea', |
| | | 'quill' => false, |
| | | 'label' => 'Review', |
| | | ], |
| | | 'rating' => [ |
| | | 'type' => 'select', |
| | | 'label' => 'Rating', |
| | | 'options' => [ |
| | | 'none' => 'Not Given', |
| | | '0.5' => '0.5', |
| | | '1' => '1', |
| | | '1.5' => '1.5', |
| | | '2' => '2', |
| | | '2.5' => '2.5', |
| | | '3' => '3', |
| | | '3.5' => '3.5', |
| | | '4' => '4', |
| | | '4.5' => '4.5', |
| | | '5' => '5', |
| | | ], |
| | | 'default' => 'none' |
| | | ], |
| | | 'date' => [ |
| | | 'type' => 'date', |
| | | 'label' => 'Date of Review', |
| | | ], |
| | | 'url' => [ |
| | | 'type' => 'url', |
| | | 'label' => 'Link to Review (optional)', |
| | | ], |
| | | ], |
| | | 'section' => 'seo' |
| | | ] |
| | | ); |
| | | $biz = new LocalBusiness(); |
| | | $biz->setReviewField($this); |
| | | } |
| | | |
| | | protected function addAlternateName():void |
| | | protected function addAlternateNameField():void |
| | | { |
| | | $thing = new Thing(); |
| | | $thing->setAlternateNameField($this); |
| | | } |
| | | protected function addKeywordsField():void |
| | | { |
| | | $thing = new LocalBusiness(); |
| | | $thing->setKeywordsField($this); |
| | | } |
| | | |
| | | protected function addOutsidePhotoField():void |
| | | { |
| | | $business = new LocalBusiness(); |
| | | $business->setPhotoField($this); |
| | | } |
| | | |
| | | protected function addSloganField():void |
| | | { |
| | | $business = new LocalBusiness(); |
| | | $business->setSloganField($this); |
| | | } |
| | | |
| | | protected function addPaymentField():void |
| | | { |
| | | $business = new LocalBusiness(); |
| | | $business->setPaymentAcceptedField($this); |
| | | } |
| | | |
| | | protected function addAmenitiesField():void |
| | | { |
| | | $business = new LocalBusiness(); |
| | | $business->setAmenityFeatureField($this); |
| | | } |
| | | protected function addCredentialsField():void |
| | | { |
| | | $this->addField( |
| | | 'alternate_name', |
| | | 'credentials', |
| | | [ |
| | | 'type' => 'repeater', |
| | | 'label' => 'Alternate Name', |
| | | 'fields' => [ |
| | | 'name' => [ |
| | | 'type' => 'text', |
| | | 'label' => 'Name', |
| | | ] |
| | | ], |
| | | 'section' => 'seo' |
| | | 'type' => 'set', |
| | | 'label' => __('Credentials', 'jvb'), |
| | | 'options'=> [ |
| | | 'WHMIS 2015' => 'WHMIS 2015', |
| | | 'Tattoo and Piercing Safety Standards' => 'Tattoo and Piercing Safety Standards', |
| | | 'Bloodborne Pathogens and Infection Control' => 'Bloodborne Pathogens and Infection Control', |
| | | 'First Aid Training' => 'First Aid Training', |
| | | ] |
| | | ] |
| | | ); |
| | | } |
| | | protected function addKeywords():void |
| | | protected function addPermanentlyCloseField():void |
| | | { |
| | | $this->addField( |
| | | 'keywords', |
| | | [ |
| | | 'type' => 'repeater', |
| | | 'label' => 'Keywords', |
| | | 'fields' => [ |
| | | 'keyword' => [ |
| | | 'type' => 'text', |
| | | 'label' => 'Keyword', |
| | | ], |
| | | ], |
| | | 'default' => $labels ?? [ 'Edmonton tattoos', 'Edmonton tattoo artist', 'Edmonton tattooist' ], |
| | | 'section' => 'seo', |
| | | 'quickEdit' => true, |
| | | ] |
| | | ); |
| | | $business = new LocalBusiness(); |
| | | $business->setDissolutionDateField($this); |
| | | } |
| | | |
| | | protected function addHoursField():void |
| | | { |
| | | $business = new LocalBusiness(); |
| | | $business->setOpeningHoursSpecificationField($this); |
| | | } |
| | | |
| | | protected function addRateField():void |
| | | { |
| | | $this->addField('rate', |
| | | [ |
| | | 'type' => 'text', |
| | | 'subtype' => 'number', |
| | | 'label' => __('Hourly Rate', 'jvb') |
| | | ]); |
| | | } |
| | | |
| | | protected function addAwardsField():void |
| | | { |
| | | $business = new LocalBusiness(); |
| | | $business->setAwardField($this); |
| | | } |
| | | |
| | | protected function addRatingsField():void |
| | | { |
| | | $business = new LocalBusiness(); |
| | | $business->setAggregateRatingField($this); |
| | | } |
| | | |
| | | protected function addServicesField():void |
| | | { |
| | | $business = new LocalBusiness(); |
| | | $business->setHasOfferCatalogField($this); |
| | | } |
| | | } |