Jump to content

Juergen

Members
  • Posts

    1,411
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Juergen

  1. Hello LostKobrakai and netcarver, your code works in regex tester but on the page I got the same result as in my regex. It seems that in a textformatter module the regex doesnt work as expected. Images without figure tag will not be rendered correctly. You can try it by adding this textformatter module to the body field of your installation. Add 2 images via the editor to the body field. One without caption (so no figure tag will be added by the editor) and on with caption. After you check the source code of the output you will see that the manipulation of the first image fails. Best regards
  2. Good Job! I like the design.
  3. Thanks for your response LostKobrakai, I will try this and write a Feedback after that. Best regards
  4. Hello, I made a copy of the Textformatter Autoschema module to add additional Markups. I have included a additional regex to fetch all images which are inside a link. They should be modified with a little bit of additional markup to make CSS3 effects possible. Here is the copy of the module code with the changes. <?php /** * @author FlipZoom Media Inc. - David Karich * @contact David Karich <david.karich@flipzoom.de> * @website www.flipzoom.de * @create 201401-10 * @style Tab size: 4 / Soft tabs: YES * ---------------------------------------------------------------------------------- * @licence * Copyright (c) 2013 FlipZoom Media Inc. - David Karich * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is furnished * to do so, subject to the following conditions: The above copyright notice and * this permission notice shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ---------------------------------------------------------------------------------- */ class TextformatterBootstrapMarkups extends Textformatter { /** * ------------------------------------------------------------------------ * getModuleInfo is a module required by all modules to tell * ProcessWire about them * ------------------------------------------------------------------------ * @return array */ public static function getModuleInfo() { return array( // ------------------------------------------------------------------------ // The module'ss title, typically a little more descriptive than the // class name // ------------------------------------------------------------------------ 'title' => 'Bootstrap Markup changer with Schema.org', // ------------------------------------------------------------------------ // Version: major, minor, revision, i.e. 100 = 1.1.0 // ------------------------------------------------------------------------ 'version' => 100, // ------------------------------------------------------------------------ // Summary is brief description of what this module is // ------------------------------------------------------------------------ 'summary' => 'Converts standard tags into Bootstrap markup classes enriched with schema.org data.', // ------------------------------------------------------------------------ // singular=true: indicates that only one instance of the module is allowed. // This is usually what you want for modules that attach hooks. // ------------------------------------------------------------------------ 'singular' => true, // ------------------------------------------------------------------------ // autoload=true: indicates the module should be started with ProcessWire. // This is necessary for any modules that attach runtime hooks, otherwise those // hooks won't get attached unless some other code calls the module on it's own. // Note that autoload modules are almost always also 'singular' (seen above). // ------------------------------------------------------------------------ 'autoload' => false, ); } /** * ------------------------------------------------------------------------ * Searches for tags and adds the right attribute. * ------------------------------------------------------------------------ * @param string $string * @return string $string */ public function format(&$string) { // ------------------------------------------------------------------------ // H1 headlines // ------------------------------------------------------------------------ $string = preg_replace('/<h1(.*)>/Uis', '<h1$1 itemprop="headline">', $string); // ------------------------------------------------------------------------ // H2, H3, H4, H5, H6 headlines // ------------------------------------------------------------------------ $string = preg_replace('/<h([2|3|4|5|6]{1})(.*)>/Uis', '<h$1$2 itemprop="alternativeHeadline">', $string); // ------------------------------------------------------------------------ // Tables // ------------------------------------------------------------------------ //$string = preg_replace('/<table(.*)>/Uis', '<table class="table" $1 itemscope itemtype="http://schema.org/Table">', $string); $string = str_replace('<table', '<div class="table-responsive"><table itemscope itemtype="http://schema.org/Table"', $string); $string = str_replace('</table>', '</table></div>', $string); // ------------------------------------------------------------------------ // Unordered lists // ------------------------------------------------------------------------ //$string = preg_replace('/<ul(.*)>/Uis', '<ul itemscope itemtype="http://schema.org/ItemList">', $string); // ------------------------------------------------------------------------ // Ordered lists // ------------------------------------------------------------------------ //$string = preg_replace('/<ol(.*)>/Uis', '<ol class="itemscope itemtype="http://schema.org/ItemList">', $string); // ------------------------------------------------------------------------ // Paragraphs // ------------------------------------------------------------------------ $string = preg_replace('/<p(.*)>/Uis', '<p$1 itemprop="text">', $string); // ------------------------------------------------------------------------ // Links // ------------------------------------------------------------------------ //$string = preg_replace('/<a(.*)>/Uis', '<a$1 itemprop="url">', $string); // ------------------------------------------------------------------------ // Address // ------------------------------------------------------------------------ //$string = preg_replace('/<address(.*)>/Uis', '<address itemscope itemtype="http://schema.org/PostalAddress">', $string); // ------------------------------------------------------------------------ // Images // ------------------------------------------------------------------------ // THIS IS WHERE THE PROBLEM IS LOCATED //add additional markup to linked images $regeximg = '/<a(.*?)><img(.*?)(\/)?><\/a>/Ui';//grab all images inside links $imgsubstitute = '<a$1 itemprop="image" data-lightbox="gallery" class="img-responsive thumbnail"><div class="scalecontainer"><span class="roll"></span><img$2/></div></a>'; $string = preg_replace($regeximg, $imgsubstitute, $string); } } ?> Take a look at the code for images near the bottom. This is what I have added. Unfortunately this only works if the images are in a figure tag like this: <figure class="align_left"><a title="" data-original-title="" href="/site/assets/files/1807/bora_bora_3.jpg"><img alt="Rochen" src="/site/assets/files/1807/bora_bora_3.132x0-is.jpg" width="132"></a> <figcaption>Rochen</figcaption></figure> But it doesnt work if the figure tag is not there like: <a title="" data-original-title="" href="/site/assets/files/1807/bora_bora_3.jpg"><img alt="Rochen" class="align_left" src="/site/assets/files/1807/bora_bora_3.150x0-is.jpg" width="150"></a> I have tested the regex with a Regex-Tester and it works. Take a look here. But this is the result on my webpage: As you can see the first image has errors in the markup - this is the image which is not in a figure tag. The markup of the first image after the manipulation looks like this: <p> <a title="" data-original-title="" href="/site/assets/files/1807/bora_bora_3.jpg" itemprop="image" data-lightbox="gallery" class="img-responsive thumbnail"></a> </p> <div class="scalecontainer"> <a title="" data-original-title="" href="/site/assets/files/1807/bora_bora_3.jpg" itemprop="image" data-lightbox="gallery" class="img-responsive thumbnail"> <span class="roll"></span> <img alt="Rochen" class="align_left" src="/site/assets/files/1807/bora_bora_3.150x0-is.jpg" width="150"> </a> </div> instead of this <a title="" data-original-title="" href="/site/assets/files/1807/bora_bora_3.jpg" class="thumbnail"><div class="scalecontainer"><span class="roll"></span><img title="" data-original-title="" href="/site/assets/files/1807/bora_bora_3.jpg"></div></a> So it makes always a strange markup and I dont know why because everthing seems ok to me. Maybe someone has an idea
  5. Thanks !!! Point 5 seems very interesting to me. Another possibility would be to copy the pwimage plugin, rename it, adapt the markup and use this instead of the original image plugin. In this case the markup will be stored in the database exactly the way that it is visible in the editor - no textformatter or jQuery manipulation necessary. Mhh, I am struggle within. I will think over.
  6. Hello @ all, I want to manipulate the markup of images added via the editor. In this case I have 2 possibilities: 1) To create a textformatter module or 2) to manipulate the output via jQuery General question: Will be the markup from a textformatter module cached or will it be created on runtime like jQuery? I prefer cacheable content so if it will be cachable I would tend to create a module instead of jQuery manipulation. Thanks in advance for your help.
  7. My goal was not to copy only one field. The body field was only an example. It would be great to copy all multilingual fields in the template with only one click. Imagine you have more textareas or editor fields in a template. One click and you have copied all your fields at once.
  8. Copying the source code is necessary at the moment. Anyway. It could be a useful feature to copy content via clicking a button and maybe it could be integrated easily without a lot of effort. But this is not a real important feature. It was only a thought of mine to improve the workflow. Best regards
  9. It would be great to add a copy button for content fields on multilingual site. F.e.: You have written a complex text with images, tables and so on in your body field in your default language (fe English). After that you want to translate the content to other languages (German, French). Therefore you have copy all the content. If there will be a copy button to copy the whole content of the default language body field to all the other language body fields with only one click. You will only have to translate the content. There will be no need to insert all the elements once more by copy and paste. This would be a great addition to make working with multilingual sites much more comfortable. Best regards
  10. I would suggest to include a delete button for images in the modal window of the editor. Today it is possible to upload images directly with the editor, but it is not possible to remove them in the modal window. So a delete button next to the upload button would be a great addition. At the moment it is only possible to delete an image at the image field. Best regards
      • 1
      • Like
  11. This is the solution to remove unwanted table attributes from CKEditor. Go to /wire/modules/Inputfield/InputfieldCKEditor/ckeditor-4.4.6/config.js and insert this piece of code into the config.js: CKEDITOR.on( 'dialogDefinition', function( ev ) { var dialogName = ev.data.name; var dialogDefinition = ev.data.definition; if (dialogName == 'table') { // Get the advanced tab reference var infoTab2 = dialogDefinition.getContents('advanced'); //Set the default // Remove the 'Advanced' tab completely dialogDefinition.removeContents('advanced'); // Get the properties tab reference var infoTab = dialogDefinition.getContents('info'); // Remove unnecessary bits from this tab infoTab.remove('txtBorder'); infoTab.remove('cmbAlign'); infoTab.remove('txtWidth'); infoTab.remove('txtHeight'); infoTab.remove('txtCellSpace'); infoTab.remove('txtCellPad'); infoTab.remove('txtCaption'); infoTab.remove('txtSummary'); } }); After that you have only a few attributes left. This is the best way to prevent customers from filling out useless table attributes. This works for other plugins (images, links and so on) too. A big thanks to Lostkobrakai for pointing me into the right direction.
  12. Sounds interesting, I will check this tomorrow. Thanks
  13. Hello @ all, I want to disable some of the obsolent and unnecessary attributes ot tables that CKEditor offers, because they are not HTML5 compliant or not necessary. I am talking about the summary, the border and the other attributes that CKEditor offers. I want to disable them so that customers cannot be able to use them. I am not talking about to clean up the html Markup - I can get rid of unwanted markup via a textformatter module, thats not the problem. I am talking about the table plugin button in the editor itself. If you click on that button you will be able to add borders, width, class, id and so on. I want to disable some of them, but I dont know if this is possible or not. Maybe someone can gave me a hint. Best regards Jürgen
  14. Works perfect!!!!!! This is exactly the way that I want. Thanx. PDO is new to me - I have to take a look.
  15. Thanks Adrian, I included the code and it works. Yes you are right, this is not the "last visit", it is the current visit. Unfortunately the query doesnt output all logins of the user which are stored in the column "login_timestamp". So it is not possible to grab the second position "last visit".
  16. For everyone who also wants to use the Login history module from Teppo (http://modules.processwire.com/modules/process-login-history/), here is my attempt to make a sql query to output the date and time of the last visit on a frontend template. $query = $db->query("SELECT login_timestamp FROM process_login_history WHERE username='{$user->name}' AND login_was_successful=1 ORDER BY login_timestamp DESC"); $lastvisit = $query->fetch_row(); echo $lastvisit[0]; This will give you an output for the last successful login like this: 2015-05-08 16:40:59 It calls the table "process_login_history" from the module. The dates of the logins are stored in the column "login_timestamp". If the login was successful or not is stored in the column "login_was_successful" and has the value "1" for a successful login. The username is stored in the column "username". I dont know if the code is the best but it works. If someone has an improvement, please post it here. Best regards
  17. Adrian, thank you so much for your efforts. I havent seen that there is also a module available. This seems the best approach to me because it stores both (frontend and backend) logins. The other possibilities only show frontend logins. Thanks!!!!!
  18. I have tried the code above, but it always stores the date and time of the present login (the current date and time) and do not shows the last login date and time. The code is inside the user frontend profile template. $username = $user->name; wire()->addHookAfter("Session::login", function(HookEvent $event) { $person->of(false); $name = $event->arguments('$username'); $name = $this->wire('sanitizer')->username($username); $person = wire('users')->get($username); $last = $person->last_page_load; $person->last_page_load = date('Y-m-d H:i:s'); $person->save(); }); I have never worked with hooks and therefore its quite difficult to me to figure out. What I want to achieve: If a user logs out (or maybe logs in) then the date and time of the logout (or login) will be stored in a userfield called "last_page_load". If the user logs in the next time, the date and time of the last visit will be displayed in his user profile on the frontend.
  19. Sorry, I dont need to save the checkbox status after redirect, because the redirect only take place if the form has no errors. So all correct data will be submitted via the form and will be stored in the database before the redirect starts. No need to keep the checkbox state alive. [CLOSED]
  20. hello @ all, today I am struggeling with the following problem: I have a checkbox field in a frontend user profile form. <input name="delete" type="checkbox"> Delete profile image If the user clicks the checkbox the profile image will be deleted after submission. In the same form there is also a select drop down field for the language where the user can change his prefered language (German or English). After saving the user will be redirected to the english page with these lines of code. if ($newuserlanguage) {//if language has changed $languageurl = $page->localUrl($newuserlanguage); //get url for the new language $session->redirect($languageurl); //redirect to the new page } This piece of code will be executed POST after submitting the form and works as expected. The user will be redirected to the new page after submit. PROBLEM: The redirect leads to that the checkbox value is always empty - in other words the checkbox status (checked or unchecked) will not be stored if a redirect is present. If I remove the redirect code it will work as expected. I am not a PHP-Pro so I have no idea how I can fix this problem. Has anyone an idea how to handle checkboxes and redirects. I dont want to store values in a cookie if there could be another way. I have tried it to store it in a session but I cannot get it to work. Best regards Jürgen
  21. I found the solution: you have to include $user->userimage->removeAll(); // wirearray before this line of code $user->userimage = $upload_path . $files[0]; This removes the image array in a first step and then loads the new image in the database.
  22. But for what is the API call "setOverwrite(true)" ? It must be possible to overwrite the existing image by uploading a new image without deleting the old manually. In backend it works perfectly. Only one image is allowed: setMaxFiles(1) If I upload a new one then delete (overwrite) the old on and store the new: setOverwrite(true) This seems logical to me
  23. Oh thats new to me - Thanx for the hint
  24. hello @ all, I have tried to use a code that i found in the forum to make a single image upload on the frontend. The problem is that it stores multiple images instead of deleting the old and storing the new. My aim is to offer subscribers to add/change their profile image in the frontend. Here is the code that I use from the post that I have found: <?php $upload_path = $config->paths->assets . "files/avatar_uploads/"; $f = new WireUpload('userimage'); $f->setMaxFiles(1); $f->setMaxFileSize(1*1024*1024); $f->setOverwrite(true); $f->setDestinationPath($upload_path); $f->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); if($input->post->form_submit) { if(!is_dir($upload_path)) { if(!wireMkdir($upload_path)) throw new WireException("No upload path!"); } $files = $f->execute(); if ($f->getErrors()) { foreach($files as $filename) @unlink($upload_path . $filename); foreach($f->getErrors() as $e) echo $e; } else { //$u = $users->get($user); //$u = $user->name; //Save the photo to the avatar field $user->of(false); $user->userimage->removeAll(); // wirearray (line added by @horst: explanation is three posts beneath) $user->userimage = $upload_path . $files[0]; $user->save(); $user->of(true); @unlink($upload_path . $files[0]); } } ?> <form class="forum-form" accept-charset="utf-8" action="./" method="post" enctype="multipart/form-data" > <input type="file" id="attach" name="userimage" accept="image/jpg,image/jpeg,image/gif,image/png" /> <input type="submit" name="form_submit" value="Submit"/> </form> $f->setMaxFiles(1); so it is set to 1 file $f->setOverwrite(true); so it should overwrite the existing image Every time I upload a new image it will be added instead of deleting the old. So I have more than one image displayed in the backend area. If I upload the image in the backend it works as expected. I use the latest dev version of PW. Has anyone an idea why MaxFiles and setOverwrite will be ignored? This ist the array output if I use var_dump: object(Pageimages)#729 (2) { ["count"]=> int(2) ["items"]=> array(2) { ["chrysanthemum.jpg"]=> string(17) "chrysanthemum.jpg" ["desert.jpg"]=> string(10) "desert.jpg" } } Best regards Jürgen
  25. Thanks Lostkobrakai this was a mistake, I am switching between Joomla and Processwire and therefore I wrote TinyMCE. I will check out the link you provided. Thanx
×
×
  • Create New...