Jump to content

flydev

Members
  • Posts

    1,355
  • Joined

  • Last visited

  • Days Won

    48

Everything posted by flydev

  1. Hi, The used settings (port) look not secure. try theses settings :
  2. @Steve_Stifler Just before going to tutorials, have a look at those discussions, for sure it will interest you / make you enthousiast / make you ?
  3. Hi @Zahari M. also you could read those threads to see a usecase :
  4. Hi @gottberg There is a bit of work to get images, as the way you are doing return Images Objects and not array. You can have a look at this file to see the "complexity" to retrieve those objects : https://github.com/microcipcip/processvue/blob/master/site-processvue/templates/inc/pagefields.php#L236 Or you can build your own images array before assigning it to the API answer : See updated ImageHelper.php file at the bottom of this post. /* route : 'page' => [ ['GET', '{id:\d+}', Example::class, 'getPage', ["auth" => false]] ] */ // get page route answer function public static function getPage($data) { $data = RestApiHelper::checkAndSanitizeRequiredParameters($data, ['id|int']); $response = new \StdClass(); $p = wire('pages')->get($data->id); if(!$p ->id) throw new \Exception('Page not found'); $response->id = $p->id; $response->name = $p->name; $response->title = $p->title; $response->body = $p->body; $response->sidebar = $p->sidebar; $response->summary = $p->summary; // our own images array $images = array(); foreach ($p->images as $image) { array_push($images, array( $image->name => array( 'url' => $image->url, 'filename' => $image->filename, 'width' => $image->width, 'height' => $image->height // ... ) ) ); } $response->images = $images; return $response; } Result : --- Edit : The image class helper : <?php namespace ProcessWire; /** * InputfieldImage Helper * Use for single image * * Usage : * $image is your ProcessWire PageImage * return ImageHelper::get($image, [400, 800, 1200, 2000, 2500]); */ class ImageHelper { public static function get ($image, $widths = [400, 800, 1200]) { $response = new \StdClass(); $response->focus = ["x" => $image->focus['left'], "y" => $image->focus['top']]; $response->urls = []; $response->description = $image->description; $response->name = $image->basename; $response->width = $image->width; $response->height = $image->height; foreach ($widths as $width) { $croppedImage = $image->width($width); $url = new \StdClass(); $url->url = $croppedImage->httpUrl; $url->width = $croppedImage->width; $url->height = $croppedImage->height; $url->ratio = $croppedImage->height / $croppedImage->width; array_push($response->urls, $url); } return $response; } } /** * InputfieldImage Helper * Use for multiple images * * Usage : * $images is your ProcessWire PageImages * return ImagesHelper::get($images, [400, 800, 1200, 2000, 2500]); */ class ImagesHelper { public static function get($images, $widths = [400, 800, 1200]) { $response = new \StdClass(); $response->images = []; $img = new \StdClass(); // our own images array $imagesArr = array(); foreach ($images as $image) { $img->focus = ["x" => $image->focus['left'], "y" => $image->focus['top']]; $img->urls = []; $img->description = $image->description; $img->name = $image->basename; $img->width = $image->width; $img->height = $image->height; foreach ($widths as $width) { $croppedImage = $image->width($width); $url = new \StdClass(); $url->url = $croppedImage->httpUrl; $url->width = $croppedImage->width; $url->height = $croppedImage->height; $url->ratio = $croppedImage->height / $croppedImage->width; array_push($img->urls, $url); } array_push($response->images, $img); } return $response; } }
  5. Hi Rudy, Storing a JSON array in a TextArea should works as expected without doing anything than saving the field in a standard fashion. protected static function getDefaultData() { return array( 'json_config' => '' ); } public static function getModuleConfigInputfields(array $data) { $data = array_merge(self::getDefaultData(), $data); $modules = wire('modules'); $fields = new InputfieldWrapper(); $field = $modules->get("InputfieldTextarea"); $field->label = __('JSON Config'); $field->attr('name+id', 'json_config'); $field->attr('value', $data['json_config']); $fields->append($field); return $fields; }
  6. Hey @horst It is solved ? If not, you might could try what is suggested in this answer on StackExchange : https://webmasters.stackexchange.com/questions/116301/how-to-force-ssl-and-www-for-a-subdomain-as-an-independent-domain Edit: ok, didn't read the post's update.
  7. @Pete I can build Windows desktop app only or multi-device application if needed, but I cannot start coding something before three weeks. Language used will be C++ or Pascal, so if it is not to far, let's discuss this in PM ?
  8. Okay I get your point. I made a 30 lines CSS Only switcher that should work with other theme than UiKit : https://codepen.io/flydev/pen/QYYZVL
  9. Hi Peter, It's hard to find something without the logs and the phpinfo() result, we can only make assumptions. What say the logs ? Could be something related to the PHP Garbage Collection mystery.. Hard to tell at this point and even worse with shared host. Also, it's possible that Plesk have a script run by a CRON job which delete sessions EACH HOUR, that could be the issue too! ask your host about that or look into your panel. A suggestion before starting scratching your head by modifying some values in the php.ini file would be to test the same form submission but with a different session handler configured, eg, SessionHandlerDB and SessionHandlerRedis. Setting up the last one for testing is quite simple, configure the Redis server on your computer to listen all interface (::1), open the right port (6379 by default) in your firewall/box and set the connection information in the config.php of your website, done, test it now. And as always, if you want me to have a ninja session on your server settings, ping by PM ?
  10. With this lib for example: https://github.com/zhiyul/Switch (there are multi choice on Github), load it on your module ___init() (add it to your scripts queue) and then in your module js file, call var el = document.querySelector('.checkbox-switch'); var mySwitch = new Switch(el, options); then do send your ajax request in the onChange event. Hope you get it. If you need a real example, just ask.
  11. If you are on a unix based system then you should give a try to Tasker/DataSet as @dragan said or look at the pcntl extension used in conjunction with the lib PHP League CSV. On windows (because the pcntl extension is not supported) I am used to write a custom import script with the same lib (PHP League) and calling `set_time_limit()` in the loop after importing X records. I import and create something like ~15k pages each night, it work pretty good.
  12. Very nice idea, thanks for sharing it with us ? Do not hesitate do register your modules in the modules directory.
  13. Hello guys, Which version are you using ? I just tested it with Duplicator 1.2.9 and everything works fine on my side a part an issue already reported in dev thread which is related to the "restore" procedure. Is there anything in the Duplicator logs ? Or maybe something in the ProcessWire logs (errors or exceptions) and at least in the PHP error log file ? Please, feel free to post/report things there :
  14. Hi @MarcoPLY Not really helping here, but the update about WireHttp and cURL came in ProcessWire 3.0.124 and it say : https://github.com/processwire/processwire/blob/dev/wire/core/WireHttp.php#L670 I am curious to see from where its happening. What is your registration code ? It is the LoginRegister module which is triggering this exception ? (sorry, I have trouble expressing myself, I'm sick ? )
  15. @mtcode https://processwire.com/docs/start/structure/templates/#scalability-and-customizability
  16. Hello @Demo Feel free to contact me or @Jguiselin via PM ?
  17. Just in case, I use those alias to install or upgrade my installs : # ProcessWire Wireshell bash alias # grab and install the latest ProcessWire development version from the latest commit alias pwnew='wireshell new --sha=`git ls-remote https://github.com/processwire/processwire refs/heads/dev | cut -f1`' # upgrade to the latest ProcessWire development version from the latest commit alias pwup='wireshell upgrade --sha=`git ls-remote https://github.com/processwire/processwire refs/heads/dev | cut -f1`' https://gist.github.com/flydev-fr/addcf54fa8348de20115d3c1314ddb3d
  18. Hi and welcome ! Great first contribution ? FYI there is one similar field (I think) based on Chosen there : @Sergio https://github.com/sebi2020/InputfieldTagify https://yaireo.github.io/tagify/
  19. You could follow or show to us the full stack trace to see which Textformatter is being called. Are they all set in the field option / details tab ? if yes, you might from there compare which one is missing ?
  20. I you like white themes, there is one cool theme : Github Plus + Material Icons
  21. Backup all your work on an external hard drive, sync your data in iCloud, do a Time Machine Backup, then restore your macbook. Once restored, change the default DNS settings to the Cloudfare/APNIC own (1.1.1.1 and 1.0.0.1), try your wifi adapter by downloading a large file (like an OS Linux ISO file), or even torrent files. If everything work fine, its time/the occasion to prepare your macbook with all the dev env, apps and copy/organize back your works files. Once finished, do a Time Machine Backup before doing everything with your mac. If it didn't work, I would follow @pwired advice to buy a new wifi adapter. ConEmu, even on Windows Server.
  22. I am going to ask on StackExchange but I got another (magic) find, which give incredible performance on InnoDB schema. Adjusting `innodb_buffer_pool_size` (it need to be calculated) give better result than those in the above screenshots... The query to calculate the size to set based on the current data set : SELECT CONCAT(ROUND(KBS/POWER(1024, IF(PowerOf1024<0,0,IF(PowerOf1024>3,0,PowerOf1024)))+0.49999), SUBSTR(' KMG',IF(PowerOf1024<0,0, IF(PowerOf1024>3,0,PowerOf1024))+1,1)) recommended_innodb_buffer_pool_size FROM (SELECT SUM(data_length+index_length) KBS FROM information_schema.tables WHERE engine='InnoDB') A, (SELECT 2 PowerOf1024) B; So for my DB I needed to set the var to 2GB (still not 100% sure) but the result are there - lower than in my previous screenshot : From 18s to 4s : From 96ms to ˜6ms : ? ?
  23. @gregory @Jonathan Lahijani I tested it (but not with all the Custom Embed option), it works with the Custom Embed options C and D. Use the following hook : <?php namespace ProcessWire; // the captcha module $captcha = $this->modules->get("MarkupGoogleRecaptcha"); // hook FormBuilder $forms->addHookBefore('FormBuilderProcessor::renderReady', function ($e) use ($captcha) { $form = $e->arguments(0); // do some custom check here ... if ($captcha->data_recaptcha_type === 'invisible') { // invisible captcha $captcha->render($form); $f = $this->modules->get("InputfieldHidden"); $f->attr('id+name', 'login_submit'); $f->value = 'login_submit'; $form->append($f); } else { // recaptcha v2 $f = $this->modules->get("InputfieldMarkup"); $f->value = $captcha->render(); foreach ($form->children as $field) { if ($field instanceof InputfieldSubmit) { // find the submit button $form->insertBefore($f, $field); // insert reCAPTCHA before the submit button } } } }); I will test later to see if it's possible to embed the captcha into an IFrame.
  24. Thanks for the update - Would you have an idea why my queries are running so much faster on mysql5.7 than mysql5.6 ? What is your version on your dev platform ? Did you tested the two server version on your side ? Check. I switched my MySQL server version on MAMP from 5.6 to 5.7 and when I clicked a button which execute quite big query, it was, oh wow, instant. Switched back to 5.6, the query took like 8 to 12 52 seconds ? Still, I didn't investigated what's going on, but result... and the same happened on a Windows Server with MySQL 5.6/5.7 upgrade. Edit: Another one looking through millions of pages...
×
×
  • Create New...