Jump to content

SteveB

Members
  • Posts

    214
  • Joined

  • Last visited

Recent Profile Visitors

7,228 profile views

SteveB's Achievements

Sr. Member

Sr. Member (5/6)

195

Reputation

2

Community Answers

  1. I love this module and it's perfect for generating reports and things for users. What I'd like to know is how I can get my pages2pdf template to also save a pdf file on the server, as well as sending it as a download to the user. Certain of these pdfs are of general interest and I'd like to keep a current copy sitting in a directory. Thanks.
  2. Teppo, The undefined indexes thing was only a Notice (harmless) and only when I have debug true in my PW config file. Re. the filters, the filters form in /setup/changelog has a select returning numeric values. The first thing I did was to put this line in right after where you define $query in buildQuery. wire('log')->save('messages', 'changelog @' . __LINE__ . ' ' . $query); Here's results I got (line number will not be same as yours): No filters: changelog @518 SELECT process_changelog.* FROM process_changelog WHERE operation IN('added','moved','edited','trashed','renamed','deleted','restored','published','unpublished') ORDER BY timestamp DESC, id DESC LIMIT 0, 25 'Edited' filter: changelog @518 SELECT process_changelog.* FROM process_changelog WHERE operation = '3' ORDER BY timestamp DESC, id DESC LIMIT 0, 25 So I just used the $this->operations array to look up the string from the number the form supplied.
  3. Downloaded this yesterday for a test drive (V 1.2.15). Like it very much. Reporting back with observations and mods. Disclaimer - I did make another change particular to my needs but I'm pretty certain it doesn't impact anything else. If the page had a RuntimeMarkup field (kind of a pseudo-field) it was always detected as changed. See ProcessChangelogHooks. foreach ($page->template->fields as $field) { //if ($page->isChanged($field->name)) { if (empty($field->runtimeFields) && $page->isChanged($field->name)) { //SB added condition - ignore RuntimeMarkup field $fields_edited[] = $field->name; } } Also undefined index notices as Adrian mentioned. See ProcessChangelog. switch ($operation) { case 'renamed': if(!empty($details["Previous $key"])) { //SB added if $target .= $details["Previous $key"] . " <strong>" . __("as") . "</strong> " // as // In context of a rename operation ("renamed old-page-name as new-page-name") . $details[ucfirst($key)]; break; } case 'trashed': if(! empty($details["Previous $key"])) { //SB added if $target .= $details["Previous $key"] . " <em>(" . $details[ucfirst($key)] . ")</em>"; break; } default: $target .= $details[ucfirst($key)]; } The ProcessChangelog buildQuery method was doing things like WHERE operation = '3' instead of using the name of the operation. That made the filter not work. case "operation": if (!in_array($value, array_flip($this->operations))) { unset($this->input->get->$key); break; } if($value) $value = $this->operations[$value - 1]; //SB fix - want word not number else break; //SB fix default: $where[] = "$key $operator '$value'"; } Thanks!
  4. Okay, using flock now. I ended up making a class to manage locks on PW pages. The lock file goes in with the page's other file assets. Automatic unlock on destruct. Logging if you want it. That got me thinking about adding this support for locking to the Page class as described here but it's not really necessary.
  5. Whoops. Reminds me why I used use mysql update for this kind of thing. Was trying to stick with pages etc. Will rethink. Thanks!
  6. Sorry Horst, it's just 3 functions to make working with the page status attribute more convenient. I'd say these are work in progress but here's what they look like now. Edit: Skip ahead... These fns were the wrong approach. //with default args will wait up to 4s for locked page to unlock. Returns false or the page. function claimPage($page, $tries=5, $ms=100){ if($page->hasStatus(Page::statusLocked)) $page = waitForPage($page, $tries, $ms); if(! $page) return false; $page->addStatus(Page::statusLocked); $page->save(); return $page; } //if page is locked, wait and recheck. Returns false or the page. function waitForPage($page, $tries=5, $ms=100){ $t = 500; while($page->hasStatus(Page::statusLocked) && $tries--){ $t += $ms; usleep($ms); $this->pages->uncache($page); //so we get current status } if (! $tries && $page->hasStatus(Page::statusLocked)){ $this->releasePage($page); //we're expiring the lock afer a decent wait... return false; //but honoring the lock } return $page; } //unlock and save function releasePage($page){ $page->removeStatus(Page::statusLocked); $page->save(); return $page; }
  7. Based on this maybe try... $page->template->cache_time = 0; // disable the cache
  8. Mostly about managing a queue and locking data while it's being updated. I'm wondering if anyone has a different idea about this or feels uncomfortable about employing Page, Template, etc. instead of a module. I like it this way because it's so adaptable but maybe someone has a more appealing way. Scenario: The site uses lots of page fields and most of its pages are indexed by ElasticSearch. When a page is indexed, page fields are (usually) represented in the index by the title field of the referenced page. ElasticSearch automatically re-indexes a page whenever it is saved. That's great but if A points to B and we save B after renaming it, B is re-indexed but A still has the old title in its search index. Solution: To handle that I have code hooked after Pages::saveReady make a PageArray of pages we'd like to re-index. Usually just a few but in rare instances a few thousand. Some care is taken with the querying in case we have a lot. To queue that work I'm using a page with a page field to represent the queue. You use a urlSegment to pass it a command (similar to a process page). Setting aside some details about access, the hooked code adds pages to the page array. Cron calls the queue page periodically, code in the template file does the first N pages, removes them from the page field and updates the page. So far so good and it has worked very nicely but two things are asynchronously fetching and updating that page field without any locking. They're quick but if we're not lucky updates will be missed or repeated. So I wrote some little functions to add, remove and test Page::statusLocked on the queue page. Docs say it's not enforced by the core (but is checked by Process modules). Both the hooked code and the queue code will respect the lock, wait and retry for a few seconds. After updating the page they release the lock. To avoid problems with stuck locks, the function that waits and retries will only wait so long before unlocking the page. It waits longer than we'd ever need to keep something locked in normal operation. Thanks. Details on request, trying not to bury the main points.
  9. Yes, that did it. The Spex layout is working, all the JS & CSS loads, etc. Must have been good coffee. I ended up adding a line to set a variable so I can know in a template file that a preview is being rendered. $this->addHookBefore('ProcessVersionControl::executePreview', function(HookEvent $event) { wire('modules')->get('Spex')->setActivePage(null); wire('modules')->get('Spex')->addTemplateVar('vcpvw', 1); }); For this particular project where many of the pages being edited have lots of fields (24), I'm not entirely sure a visual preview is best but I've only just gotten it working so too soon to say. This next observation may or may not have to do with the fact that I have not turned on Version Control for any of the image fields (I have a different kind of image archive for that) and I'm using PageImageAssistant (a.k.a. Pia). I noticed that in the template where I'd normally show a thumbnail from a page chosen in a page field, The value for $page->myField->image in the preview is not the full data. Kind of makes sense, this is for a page that is not currently selected but was selected at the time the preview is representing. I get the image basename and I can work with that. As I'm testing now I had a weird thing happen where I changed a page field (multiple values, checkboxes) and the change showed up in previews for earlier revisions. In fairness, this is a test page in my local dev server. I'll make some brand new content and try again. (a misunderstanding) I made a minor change (@619) so that in the editor clock icon only shows up on fields with more than one version. Otherwise, there's nothing to look at. protected function renderHTML(array $data) { $markup = ""; foreach ($data as $field => $field_data) { $diff = " diff"; if ($this->diff_disabled) $diff = ""; if ($diff && wire('fields')->get($field)->type instanceof FieldtypeFile) $diff = ""; $revision = count($field_data) ? " data-revision='{$field_data[0]['revision']}'" : ""; $markup .= "<div class='field-revisions$diff' data-field='$field'$revision>"; //if (count($field_data)) { if (count($field_data) > 1) { $markup .= "<ul class='ui-widget-content'>"; Thanks for taking an interest and solving my Spex problem.
  10. I agree it's not a VersionControl problem exactly but I'd like to find a way to use both of these useful modules. Putting that code in Iinit.php made no difference. Putting it in the template file seemed a step in the right direction but then I found that apparently _init.php wasn't loaded at all. At least, calls to functions in a file I include from there failed (does not exist). Including _init.php from the template file gets us a bit closer but Spex does not appear to be fully working in this mashup and the layout is very incomplete. The field based way of looking at changes (clock icon) is not working well with PageListSelectMultiple and I use a lot of those. Thinking about a plan B. Thanks
  11. Anybody using this with Spex in their templates? When I click to preview revision in the history tab listings it accesses a url like... /processwire/setup/version-control/preview/?pages_id=38172&revision=333 That causes... Fatal error: Call to a member function setLayout() on null in... Just asking in case it's come up before. Thanks.
  12. My main issue with any of the themes is usually colors. I'm using classic now and do some inspecting and CSS search and replace if it changes. Used Reno for a while but classic is always in sync with the latest features. If it was just for me I'd tone down the shocking pink and use a more natural green but currently I'm only making the selected tab's edges 10% darker and field separation lines 3% darker. With the default colors one client, new to Processwire, did not perceive the page editor tabs (content, children...) as tabs.
  13. Is there a trick to making it crawl when PW is installed in a subdirectory?
  14. Bumping this old thread to shine some light on an obscure fact about that whitelist for domain names. Here's my story: Moved site from development server to real server. Some users (not all) reported View links sending them to the development server. Never happened to other users. Clearing browser cache did not help. Dumping DB and searching text for the development server domain name did not turn up anything. The only place I could find the development server domain name was in the config file in the array defining $config->httpHosts. Documentation calls $config->httpHosts a whitelist so I assumed I could put both the dev and real domain names in the list and maintain a single config file to use in both places. It's not just a whitelist!! The source code of ProcessWire.php explains that If you have not explicitly set $config->httpHost (note: no "s" on end) and the PHP vars for $_SERVER['SERVER_NAME'] and $_SERVER['HTTP_HOST'] don't match anything in $config->httpHosts (with "s") the getHttpHost function defaults to... "no valid host found, default to first in whitelist" The server's environment variables had the domain with www on it but the server accepts URLs with or without the www and people use either one. My dev site was the first one in the list.
  15. I've just tried this out using 3.0.20 and have some observations. In the setup I selected one template and several fields but left defaults for everything else. I did not select any image or file fields. It created tables, including one in which I found information about images. In the edit page for the template I enabled in setup just about every field has little clock icon on it, many of them no selected in setup. edit: Many of these don't have any changes yet but still show an icon (distracting for users) The fields I did select seem to work as intended and the others do not record changes, they just have the icons. Any ideas about how to record changes made to a PageTableExtended field (pages saved as children, different template)? Another question, when it installed and populated tables I wondered if that process is timeout proof (batching of some kind to handle thousands of pages). Thanks.
×
×
  • Create New...