Can
Members-
Posts
350 -
Joined
-
Last visited
Everything posted by Can
-
I answered already on GitHub, don't know where you found this rule?
-
Right now I switched this particular case over to TemplateFile.. But thanks for this great insight gebeer! Didn't even know about this Can't get it working with AIOM where I need a "normal" one dimensional array $config->customJs has the array within "data" key $config->customJs->getIterator() doesnt work either and ->data is protected... By the way while investigating the source, Ryan commented the unique method and states that it's no longer necessary, add() is taking care of this already ;-) To "inject" custom vars into renderValue, should be possible anyways to "create" new wire() vars like wire('js', array()) (or wire()->set('js', array())), then it should be possible to $wire->js[] = 'foo' from the field template, and almost anywhere else..
-
Hey friends Really love the new $field->render and $field->renderValue, I'm using it more and more, the code gets shorter, more modular and therefore less duplicates. Thank you Ryan for this great addition. Checked Inputfield.php and the two blog posts about the new methods but couldn't really find what I'm looking for. Is it already possible to pass in custom variables to the field template? Like when using TemplateFile and delegate output you can simply do $templateFile->foo = $foo; Maybe something like $field->renderValue($value, '/fieldtemplate', array($foo, $bar)), or similar..think that would be amazing. Main reason for this right now is that I'm conditionally adding js and css by adding styles and scripts to $js and $css arrays, which AIOM will then combine and minify, and it would be nice when I could add those files from the field template. I read about css and js dependencies, but I don't really know how to use them and how I could add them to my $js and $css arrays..? Maybe this is already what I want? But passing custom variables to field templates could be nice anyways, what do you think?
-
Kay those 4 are now translatable (already pushed to gh) But I hav to investigate a little further why they not properly work..got another project to finish first.. But any hint is always welcome ;-) PS: Actually I planned to include a german translation file in the repo in the first place, but never made it
-
Just realized that the first post links to the old deprecated version..maybe I should delete it altogether.. Don't really know to what lines you refer? Line 54 https://github.com/CanRau/MarkupCookieConsent/blob/master/MarkupCookieConsent.module#L54 is the hook.. Normally everything should be translatable via module config, but for whatever reason I still don't get it workin..
-
I'm glad you got it working
-
There a various ways for sending additional information along with the images. And you can configure plupload to only upload on button click. using multipart_params: http://stackoverflow.com/questions/9535462/how-to-send-additional-data-using-plupload more: https://www.google.com/search?q=plupload+submit+additional+data&hl=de&gws_rd=ssl the uploader.start(); in uploader.bind('FilesAdded'.. event is starting the upload for example this is part of the events example on plupload.com document.getElementById('uploadfiles').onclick = function() { uploader.start(); return false; }; So you don't need to split the form or anything.. EDIT: By the way, pluploader isn't using your file field at all. By this it's bypassing some limitations of it. So your files are directly uploaded using XmlHttpRequest, they just name the post request like your file field for convenience ;-) And this is no matter you queue them and hit upload for all or let them upload automatically one by one.. So you could hide the file field for people with javascript enabled
-
maybe a method in WebmentionArray like public function authorMentioned($email) { $query = $this->wire('database')->prepare('SELECT * FROM webmentions WHERE email=?'); $query->execute(array($email)); return $query->columnCount(); } Don't know you db structure, but something like this should work, instead of SELECT * you should provide a single column, e.g. id And columnCount should be enough cause you just need to know if or not right?
-
Hi nalply, and welcome to Processwire and the forums (even though it's your second post ) The external db is not build on Processwire? But the url "www.example.com/external-database/item/<id>" is served by processwire, right? In your template you want to get the item from the external db which was provided in the url (<id>)? So when I get you right you could use WireDatabasePDO like so $urlSegment1 = $sanitizer->int($input->urlSegment1); $customDb = new WireDatabasePDO('mysql:host=localhost;dbname=EXTERNAL_DATABASE_NAME', 'USER', 'PASS'); $query = $customDb->prepare('SELECT column FROM table WHERE id=:id'); $query->execute(array(':id' => $urlSegment1)); $result = $query->fetchAll(PDO::FETCH_OBJ); foreach ($result as $r) { echo $r->column; } So for this template you need to enable url segments in backend to get it working and of course you need to adjust the connection and the query. But thats basically what you put in the template file, e.g. calles "external-database" Saludos Can
-
As far as I understand it you want to put the logic for this in WebmentionArray.php as you want to search the array holding your data. Maybe just checking out your WebmentionArray can help, too.. Cause it's quiet late I just throw in a link to KeyValueArray.php of FieldtypeKeyValueMultiple and hope it gives you another useful reference... Most of the stuff comes from FieldtypeEvents, but I needed to add a remove method because the one from parent didn't worked, for whatever reason.. And the get method is custom, I wanted to simplify way user can search for data.. https://github.com/CanRau/FieldtypeKeyValueMultiple/blob/master/KeyValueArray.php Saludos
-
bumped version -> 0.0.9 Changed style injection, now prepends to first <link> in head makes it easier to add custom css tweaks without the need for !important because of the cascading order Still need to get the language fields to work
-
Sorry but I still don't get you exactly? You whant to be able to enable the hint only on selected pages via module config? As far as I understand you need this information always when you use cookies for whatever reason..but maybe I'm wrong? And the module inserts this info only as long as the user didn't accept it. After accepting the message won't show up again..
-
Try to change your file field from <input class="dragDropFileUploadField" type="file" name="file[]" accept="image/jpg,image/jpeg,image/gif,image/png" multiple /> to <input class="dragDropFileUploadField" type="file" name="images[]" accept="image/jpg,image/jpeg,image/gif,image/png" multiple /> because your defined your $file_field = "images"
-
Maybe you can share your code so far? It's actually auto uploading, when you use the js as I posted. So every file will be automatically uploaded after adding.. You could look into browser delevopment tools Network tab. When you got the page with your form finished loading and then open the network tab it should be empty. Once you drag or choose a file, a new entry of type xhr should appear in network tab Is your php already doing anything with uploaded files? or at least supposed to do already, or how does your php part look right now?
-
Glad you like it Jugibur Don't really get what you mean? What website relevant data? Front or back-end?
-
Ah, what I meant by "On the serverside I had a form and the process logic already" is that I have a fully functional form like <form action="./" method="post"> <div id="dropArea"> <input class="dragDropFileUploadField" type="file" name="file[]" accept="jpg,jpeg,png,gif,mpg,mpeg,mp4,avi,wmv,mov,zip" multiple> <button type="submit" name="action" value="submit">Upload</button> </div> </form> In the JS var uploader = new plupload.Uploader({ browse_button: dropArea, // this can be an id of a DOM element or the DOM element itself drop_element: dropArea, you're defining a click and a drag&drop area in this case called "dropArea" so this element needs to be present in your form. Have you read plupload's docs? http://www.plupload.com/docs/Getting-Started EDIT: plupload is a little like Processwire as it doesn't provide the UI, instead it gives you the API and events and let's you define your upload area.
-
ah okay. Usually I do the php/html first, to ensure (somewhat) working form for js disabled users (but maybe that's not needed for you) I have everything in one template file, you could split markup and logic but in the beginning it's probably easier my form action is like action='./' so the form submits to the page it's on. and pluploads url is the same ('./') so posting to the current page I started with examples from soma https://gist.github.com/somatonic/5233338 easier because normal html form is used (at least I found it easier in the beginning) https://gist.github.com/somatonic/5236008 using PW form api & inputfields There are more examples out there, using google is more effective than forum search Ah, in my /assets/files/ folder I've got .tmp_uploads the period makes it non accessible by the web, this method is mentioned here multiple times to prevent malicious stuff $upload_path = $config->paths->assets . 'files/.tmp_uploads/'; And than you can do what ever you like with the file, create a new page for it, or add it to an existing pages file/image field or even have your own storing system.. after that you delete the file from your tmp
-
you mean in some example script of plupload? The code I posted above is all I have for plupload. On the serverside I had a form and the process logic already, so plupload is just another way of sending the files to the php. Maybe I don't really understand what you mean?
-
Forgot to mention it, was too late. I tried the option already, but I want tags to be stripped, so right now the purifier ($sanitizer->purify) seems to be the best option right now. Thanks for mentioning bbcode textformatter mr-fan, but for now I stick to plain text for mails and comments. URLs are auto linkified on output anyways.. I got the whole processwire of the project opened in sublime, so cmd+t and the desired class, module, whatever brings me straight to what I want to know, still the fastest way.
-
I think so, too. And comment system should change this as well.. Actually I figured it strips everything where a non whitespace character follows an opening bracket so your example gets stripped whereas < $20 wouldn't.. just for the record ;-) Alright.. I really need to crack the bed now^^ So love <3 to all you PW lovers
-
Wow, that's fast! Yeah read it, haven't tried htmlspecialchars, but it's not what I want.. You're right that would be way..thanks for sharing adrian, maybe I'll give it a shot Are there other things strip_tags would consider a tag and strip?
-
Buenos dias amigos, We just noticed that our contact form, and for sure comment form, too (custom build / not FieldtypeComments) occasionally strips whole paragraphs of the user content. (A girl told us that she wrote more than she saw in the replies quote) I'm cleaning input right away using $sanitizer->textarea So I tested a little and could narrow it down to strip_tags which is part of $sanitizer->text Commenting it out kept all paragraphs of my test string which were mainly lorem ipsum. With it enabled only the first line would come through. After a lot of searching and trying to PM users here in the forum in hope they would reply soon, I found the actual issue. I started the test mail with a line dedicated to my girlfriend (because she would read it) and ended it with a heart <3 strip_tags things it's the beginning of a tag and therefore strips not only the heart itself but everything after it. O.o By the way, FieldtypeComments is using strip_tags, too. And I just commented the newest Blog post about 3.0.9 and my "<3 Processwire" got stripped, too. Then I wasn't sure how to sanitize the input, didn't wanted to loose any more content, since our crowdfunding we're getting a huge load of mails every day. Thought about entities/entitiesMarkdown but when using it right on the input I needed to unentities on ouput which doesn't make sense because everything like <a onclick="alert('fooo')">click</a> would stay intact.. Many people are suggesting htmlentities for user input..when outputting though. But I don't want/need any tags except for hearts and stuff because we're hippies (quote of my girl^^) Right now I'm using $sanitizer->purify($str, array('HTML.Allowed' => '')); which works at the moment, maybe there other options? Ah, one mentioned to not sanitize input at all but store it as is in db and only escaping (e.g. htmlentities) on output.. I was quite astonished that strip_tags still considers <3 as html, even though emojis exist for decades.. What do you think, or what is your way of dealing with user input? Saludos and good night Can Ah, as far as I know it's not possible to declare <3 as valid tag to strip_tags because it's not an actual tag right? At least my testing didn't work..
-
// so we only initiate plupload if a form with id fileUploadForm is present on the page // you can change it to look for a class name if you prefer.. var filesUpload = document.getElementById("fileUploadForm"); if (typeof fileUploadForm !== 'undefined') { // this is the part of the form where people can drag and drop files into // if it should be the whole form you can strip the next line and change all dropArea vars to filesUpload var dropArea = document.getElementById("dropArea"); // the next 3 events are only to visualize drag and drop // they're basically just adding/removing the dragOver class to dropArea dropArea.addEventListener('dragover', function(e) { this.classList.add("dragOver"); e.preventDefault(); e.stopPropagation(); }, false); dropArea.addEventListener('dragleave', function(e) { this.classList.remove("dragOver"); e.preventDefault(); e.stopPropagation(); }, false); dropArea.addEventListener("drop", function(e) { this.classList.remove("dragOver"); e.preventDefault(); e.stopPropagation(); }, false); // here we actually initiate pluploader var uploader = new plupload.Uploader({ browse_button: dropArea, // this can be an id of a DOM element or the DOM element itself drop_element: dropArea, url: './', resize: {width: 3000, height: 3000}, headers: { "X-Requested-With": "XMLHttpRequest" // without this Processwire's $config->ajax won't work }, filters: { mime_types : [ { title : "Image files", extensions : "jpg,jpeg,gif,png" }, { title : "Video files", extensions : "mpg,mpeg,mp4,mov,avi,wmv" }, { title : "Zip files", extensions : "zip" } ] }, runtimes: 'html5,flash,silverlight,html4', flash_swf_url: 'plupload/Moxie.swf', required_features: true }); uploader.init(); // here you can show a preview of each file (before actual upload) uploader.bind('FilesAdded', function(up, files) { var html = ''; plupload.each(files, function(file) { /* check file.size, remove if exceeds limit */ html += '<li id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></li>'; }); document.getElementById('fileList').innerHTML += html; uploader.start(); }); // this one handles the actual progress, I'm currently just showing in percents (without progress bar) // but you can use file.percent for whatever you like (e.g. changing the width of an element with it) uploader.bind('UploadProgress', function(up, file) { if(file.percent == 100 && file.status != plupload.DONE) { file.percent = 99; } document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>"; }); // after a file is ready, my PHP script is responding with the pageimage file, so I'm swapping the preview with the response uploader.bind('FileUploaded', function(up, file, result) { // remove upload progress for this file var progressElement = document.getElementById(file.id); progressElement.parentNode.remove(progressElement); // prepend uploaded files to gallery var gallery = document.getElementById('groupGallery'); gallery.insertAdjacentHTML('afterbegin', result.response); }); // error handler.. uploader.bind('Error', function(up, err) { // document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message; console.log("Error #" + err.code + ": " + err.message); }); } So this is exactly what I use right now. Added only a few more comments. Hope it helps to get you started. You can customize plupload for your needs and as far as I remember there is somewhere documentation on how to strip unneded runtimes, like flash or silverlight. But that depends on your needs ;-)
-
I recently implemented plupload with progress bar.
-
Thank you horst! Anyway your code is awesome, so much cleaner! Even though I added a second loop to handle multiple comma (or dash) separated tag groups and added comments your version is still shorter! function processTags($tags, $tagParent = 'tags') { $vars = array('sanitizer', 'pages'); foreach ($vars as $var) ${$var} = wire("$var"); // added this loop to split CSV strings // now we can enter multiple seperate tags with children // like "Tag1,Tag2>Child Tag,Tag3" $tagsArray = $sanitizer->array($tags); $return = new PageArray(); foreach ($tagsArray as $tagGroup) { // parts now holds the hirarchical ordered parent list, without the rootParent named in $tagParent $parts = explode('>', $tagGroup); // we need to set the parent for every tag group // which can be a single comment or can have children // otherwise "Tag 3" (above example) would be a child of "Child Tag" $parent = $pages->getByPath("/$tagParent/"); foreach($parts as $part) { // try to get a childpage with name $part and parent = $parent // added second argument (2) to pageName sanitizer for translation // because the page creation uses this, so without it wouldn't find existing pages.. $p = $pages->getByPath($parent->path . $sanitizer->pageName($part, 2)); if(!$p->id) { // if it do not exist, create it now $p = new Page(); $p->parent = $parent; $p->template = 'tag'; $p->title = $part; $p->save(); } // switch parent to the next level: $parent = $p; $return->add($p); } } return $return; } Thanks a lot horst!! EDIT: I changed the $pages->get() queries to $pages->getByPath() which requires PW 3.0.6. Check out Ryans blog post with benchmarks EDIT 2: It's now returning the created (or existing) tags.