BrendonKoz

Members
  • Content Count

    59
  • Joined

  • Last visited

Community Reputation

35 Excellent

About BrendonKoz

  • Rank
    Full Member
  • Birthday 12/12/1980

Profile Information

  • Gender
    Male
  • Location
    Saratoga Springs, NY, USA

Recent Profile Visitors

2,334 profile views
  1. (Assuming the suggestion is for a normalized way of handling versioning in changelogs for all modules moving forward.) As much as I like the idea of using some dynamic method to keep a version number in check, I'm not sure that a changelog (or markdown file) is the best way to handle that - at least not by simply pulling the first line and expecting that it will contain the updated version number. There are many suggested ways of creating changelogs. (There's even a discussion about best practices mentioning some of those links.) Since there are so many ways to handle changelogs (sometimes organization-specific standards) I'm not sure this could work for everyone in practice (esp. those that are using info.json files for this module data). I definitely think it looks like a terrific idea for your own use case though, and until I thought about it further I got all excited by the prospect! I do think it's OK to have a fieldtype/inputtype combo that share the same name also share the same version number.
  2. So, food for thought in terms of REGEX vs DOMDocument: Benefits of using REGEX: Essentially faster/more efficient for processing of the data Doesn't care about valid source structure as it's parsing straight text, not XML nodes Implementation is unlikely to change Detriments of REGEX: Writing a perfect implementation of a REGEX when dealing with HTML to handle all use-cases without experiencing any edge-cases is difficult (might "greedily" match more than intended) It definitely works, but the developer argument is: is it the best (most appropriate) tool for the job? Without a good knowledge of REGEX, harder to understand the underlying code if changes/updates are required Benefits of using DOMDocument: Written specifically for the purposes of this type of task (searching/modifying the DOM) DOMDocument shouldn't ever be "greedy" over what it matches, like REGEX unintentionally tends to do Detriments of DOMDocument: May require valid HTML, but with iterations of HTML, what exactly is considered valid? Would different versions of PHP handle the DOM differently with version differences? Potential of implementation changes. loadHTML() may modify your source - what goes in might not be what comes out Character encodings may cause unforeseen issues (don't they always!) Without a good knowledge of PHP's approach to using DOMDocument, the code process can get rather difficult to understand if changes/updates are required Some further reading from someone else with more thorough testing: https://blog.futtta.be/2014/05/01/php-html-parsing-performance-shootout-regex-vs-dom/ https://blog.futtta.be/2014/04/17/some-html-dom-parsing-gotchas-in-phps-domdocument/ Realistically it's a judgment call. Speed and server efficiency versus (one would hope) better valid modifications/detections. I don't think there's really a right or wrong solution. Some shared hosting servers don't install the DOMDocument PHP extension by default though, so you'd want to check for the existence of the function during your module's install method. P.S. - Thanks for asking the question -- I knew DOMDocument was slower, but haven't compared in awhile. The articles I saw above were an interesting read.
  3. Is there any established or suggested way of how to handle providing modules that offer functionality from different providers? Example: Let's say the Google Maps and Leaflet Maps modules didn't already exist. Someone thought to create a module, but realized future clients may want one provider over another. Because they're so functionally similar, created a base module that then offers classes (GoogleMap / LeafletMap) to extend the base (Map) class - which can be chosen either in the module configuration or in the field configuration. I've seen a few different modules that offer this functionality over the years - most recently Ryan's Tfa (Two-Factor Authentication) class. Ryan's WireMail and Tfa base classes have a distinct benefit of being part of the core and therefore don't need to be installed or initialized - only the modules that extend them do, so I'm not entirely sure if custom modules requiring the installation of a base module, and then offering extension modules is the best solution. Other solutions are to add folders (or classes) containing required module extensions that will be discoverable by the main module. I think I saw one that used a JSON configuration at one point in my research too. Any thoughts from others who might've handled this for their own custom modules - or have been thinking about this recently?
  4. I appreciate the further glance - though it's most definitely in an unfinished state. When I couldn't get a database save to work I panicked a bit and rewrote some areas (not necessarily finishing them). That said, it's good to make me think about it again - I might've forgotten to go back and fix it up. I still want to provide a few data provider options (manual entry, OpenLibrary, Polaris ILS, etc) through module configuration; need to fix up the interface and figure out accessibility/internationalization concerns, then do some further testing. There's still quite a bit to do yet (I'm primarily stumped at the UI, have a few possible directions I can go), but at least now I can happily move forward! EDIT: Confused myself. Sanitization is currently being done in OpenLibraryBook::set() -- though it'll be a little different once I add various data providers for the book information. I tried checking your website for an Amazon Wishlist or Paypal link (i.e.: "Did I help you? Consider buying me a coffee."). If you want some coffee money, PM me a wishlist or Paypal email.
  5. I was honestly expecting a facepalm (missing $, semi-colon, or maybe typehint). Thank you so, so, so, so much!
  6. I began writing this module from scratch, basing it off simple examples of modules, trying to learn the necessary methods required to create a fieldtype. I was WAY off, but learned a lot. Eventually I moved towards examining the FieldtypeEvents example from Ryan and, in many areas, copy/pasting and then adjusting the code (and then trying to determine what it all was doing) method by method, file by file (from his example to my module). I've gotten to the point where I was ready to test the code - I haven't fully fleshed out my visual interface, nor integrated any of the 3rd party API tools this will (can) take advantage of. I also haven't implemented any JS or CSS for the interface. Right now I'm just trying to get it to save and then display any of the data that has been entered into the form fields of a template from the admin. When I save the page, the field is reset to defaults and no feedback message (for the field) is shown at the top of the page upon reload. When using Tracy Debugger from within the processInput method (immediately attempting to debug the $input variable), Tracy caught no data to be shown. If anyone has some time to take a quick look and see what I might've done wrong I'd be super grateful. I've had no forward progress in about 3 days (and like many others was unable to get Xdebug breakpoints working in PHPStorm). https://github.com/BrendonKoz/FieldtypeBooks
  7. Is it dynamically creating a custom template on-the-fly? Just quickly thinking how it works, though it doesn't really matter. Quite slick indeed.
  8. BrendonKoz

    The purpose of the module is to provide a way to display Leaflet Maps. Leaflet =/= OpenStreetMap. Leaflet is a map display library whereas OpenStreetMaps is the actual map layer data source. OSM can be displayed using Leaflet (popular), OpenLayers, or even Google's map library, so I don't know (for sure) if the purpose of the module was specifically to avoid using Google's technology behind the scenes (which it does anyway as is evidenced from previous discussions of the code). I prefer OpenStreetMaps' imagery and ToS, but prefer Google's geocoder. Like I said though, your fork of the code is your own -- it did not have to follow my personal ideas.
  9. BrendonKoz

    I took a look at it. This is not the same thing that I was trying to accomplish (not that it has to be). These alterations don't use the Google geocoder's returned JSON data, it uses OpenStreetMap. I don't remember how, but I do remember I was able to get the JSON results of the OpenStreetMap geocoded data without any modifications to the module. What I was unable to get was the same values (100% of the time) from Google's geocoder, which contains more information (and often, I've found, more properly formatted and correct) than the OpenStreetMaps version. Because the found addresses for PLACES don't always match ("NYS Public Library" might not list a street address on OpenStreetMap, but Google will include everything), doing a manual lookup with Google's geocoder after-the-fact won't work 100% of the time. (Those were some of my reasons anyway.) As for code: When changing a version number that has companion modules you'd probably want them all to match. Just a suggestion for any future possible patches. LeafletMapMarker.php around line 62: } else if($key == 'raw') { $value = $value; } At first I did that too in my version (I think I removed it in my repo, maybe not) but that's just unnecessary. Still looking through the rest as like I said, I don't fully grasp FieldtypeModule code.
  10. BrendonKoz

    Congratulations on your success. If you're going to make a pull request I'd make it to the original Fieldtype module as that was the only reason I had forked the original module's code to begin with - to have workable code to store the raw return data, and offer a possible pull request.
  11. BrendonKoz

    If the only JSON+LD to be displayed will be event type, I'm personally planning to just hardcode it into the template rather than run another module. I did install that module originally with that intention but it mostly just attempts to simplify the creation of the template code. My `raw` field was used so that the rest of the module's code would be untouched and would continue to run as-is. If I could get it working I'd then add a module config option to offer to always save the raw data (or leave unchecked to not save it; default behavior). That way if the module author wanted to merge changes it wouldn't have any breaking changes. The schema upgrade method would have to be updated though. I didn't notice the other variables that may have worked before -- or maybe I did; if I did, they might've been a carry-over from the fork of Ryan Cramer's GoogleMaps implementation (some code is still the same). I didn't get time to look at this today so the code is no longer fresh in my memory.
  12. BrendonKoz

    I hadn't. I had previously installed TracyDebugger and couldn't figure out how to use it -- I think my problem was as simple as having installed it in the wrong PW instance (it's working now). I'll see if I can find any additional info from that, thank you for the tip! I had not, unfortunately. I was pulled from that task to work on an Omeka (archival CMS of sorts) theme and subsequent issues, and an application form using GIS shapefiles. I hope to be finishing the Omeka thing up today. If I have time later in the day I'll take another look into this. I too don't have much experience working with PW Fieldset modules; I've been trying to figure them out here and there though.
  13. BrendonKoz

    I realize my question is now outside the scope of this module, so I apologize in advance, and also have no expectation of a response -- just hopeful! By looking through this though I think I might be picking up some things with Fieldtype development that I couldn't quite grasp beforehand, so it's still useful (to me). Thank you for the response, @gebeer that was awesome! I made those, and some additional changes, but I've still been unable to get the data to save to the database (I'm instead saving an empty string value). I believe I might need some additional code somewhere, possibly in InputfieldLeafletMapMarker.module's ___processInput method? I tried commenting out the if/else block for whether a JS geocode had been done so that it would (should?) always perform a Google geocode, but that still didn't save to the DB. Any thoughts from anyone on what I might be missing here? I manually altered the database table to include the "raw" column in my field_{$name} field values. Changes (on Github): LeafletMapMarker.php [line 38] + $this->set('raw', ''); [line 96] + $this->raw = $json['results'][0]; InputfieldLeafletMapMarker.module [line 310] - "\$page->{$this->name}->zoom" . + "\$page->{$this->name}->zoom\n" . + "\$page->{$this->name}->raw" . FieldtypeLeafletMapMarker.module [line 106] + $marker->raw = $value['raw']; [line 136] - 'zoom' => $marker->zoom/*, + 'zoom' => $marker->zoom, + 'raw' => $marker->raw/*, [line 157] + $schema['raw'] = "TEXT"; // raw google geocode data
  14. BrendonKoz

    Does this module use Google's API at some point in the geocoding process? I noticed that there are calls to: http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address= ...in LeafletMapMarker.php, and calls to... http://nominatim.openstreetmap.org ...in Control.Geocoder.js. I am using this Fieldtype on individual Events pages - it works well and made sense. I'm now trying to go back and add JSON+LD to all of those Events pages which requires a "Place" value (Example: https://developers.google.com/search/docs/data-types/events). Unfortunately the auto-corrected address field from the geocoder ($this->address in Leaflet) is not always something I can easily split into meaningful entities for the JSON+LD Event type's @Place type values. That said, the raw results originally returned from either geocoder (Google's being nicer in this regard, but OSM works too) can be used towards building this out. Based on how this module handles all of its data, is it feasible to extend it somehow to allow saving of the raw geocode data? If so, any ideas on where I might begin to look?
  15. I'd have never looked there. In fact, I know I didn't since I searched for the text string of "permi" in my *.php/*.module files. Dang. Thank you so much! Now I can fix all the other errors and continue on. Thank you!!!!