Jump to content

adrian

PW-Moderators
  • Posts

    10,778
  • Joined

  • Last visited

  • Days Won

    346

Posts posted by adrian

  1. Ok, I have just added support for images that are embedded into the text within an email. These images are now added to the page's images field and then embedded into the body RTE field, just as they appeared in the email.

    Minimal testing so far, but seems to work great even with multiple images. Would appreciate some testing of the attached version before I submit to Pete.

    My forked version

    ProcessEmailToPage.zip

    • Like 4
  2. joe_ma,

    I think the cleanest option would be to limit posts by date in your initial selector. That saves the resources of getting all the posts and foreach'ing through all of them.

    Something like this should work for you.

    $newsposts = wire("pages")->find("parent=/news-articles/, $category, template=TUT_news, Datum>time(), limit=10");
        
    foreach($newsposts as $newspost){
        $out .="<hr><div class='clearfix'>";
        if($newspost->Artikelbild){
            $out .="<a href='{$newspost->Artikelbild->url}' class=''>";
            $out .="<img class='align_left' src='{$newspost->Artikelbild->url}'>";
            $out .="</a>";
        }
        $out .="<p>{$newspost->Datum}</p>";
        $out .="<a href='{$newspost->url}'><h3>{$newspost->title}</h3></a>";
        $out .= $newspost->body;
        $out .="</div>";
    }
     

    I am not sure if that selector is exactly what you need - I grabbed most of it from the tutorial, just adding in the date check. Also, it will depend on how the date is stored. You might need to change time() to something like date("Y-m-d").

    Let us know how you go.

  3. I am curious as to the name of your images field. That error you are getting makes me think you don't have a field called "images". The module currently has the field hardcoded as "images" so clearly that needs to be made flexible so that other fields can be used. Not sure the best approach for this though. If there is only one image field in the selected template, it's easy, but if there is more than one we'd have to either just choose the first, or ask what field to use in the config settings, which might be best. Also, if there is more than one image attached, and the chosen field is set to only store one image, then there is also an issue. Also I see that there isn't anything to determine if the attachment is in fact an image which is something that should also be checked, and if it's not should the file be added to a files field on the page?

    Anyway, please check that your images field is in fact named "images" and see if that helps. I am curious about nothing showing up in the body of your page though. Do you have a "body" field in the selected template? Sorry, I see that you didn't enter any text in the body of the email, so this is expected. Regardless, I think this is something else that needs to be made configurable - at the moment the body field must be named "body" as this is the hardcoded name.

    EDIT: I haven't narrowed down why yet, but if I send the email from Mac Mail, no attachments get converted to images, but if I send them from gmail from within the web interface, everything works perfectly - maybe there is some limitation with flourish and its ability to detect attachments in some case, or maybe it is the crazy way Macs attach files :)

    ANOTHER UPDATE: I just sent an email with an attached image from MS Outlook and it also works perfectly, so I am beginning to think there really is something amiss with attachments and the Flourish/Mac Mail combination. Can anyone else confirm this with the version of the module attached to my previous message?

    AND ANOTHER: I have added support for inline attachments and this seems to be helping with Mac Mail. I had also been using this setting:

    defaults write com.apple.mail DisableInlineAttachmentViewing -bool yes
    

    on my Mac, but reversing that (change yes to false), along with the new inline support and images are now being added. The one outstanding problem I can see at the moment is that if a Mac Mail message also has text in it, the image won't work, so test without anything but the image for now if you are using Mac Mail.  Turns out this needed "related", not "inline". I have added support for this in the new version attached this morning.

    One other thing I think might be a nice addition to this module is support for embedding images into the body field if they were embedded inline in the email. I need sleep now, but might look into this tomorrow!

    My forked version

    • Like 3
  4. Just added a new forceSecure option to the config. Also made sure that if port is left blank, that it sends NULL, rather than blank which seems to be a requirement.

    Also added a fix for the HTML vs text email issue reported by @martind

    All these will go to another PR for Pete in a few minutes.

    Please let me know if the attached version works for you now.

    My forked version

    • Like 3
  5. Ok, I decided to do some testing at my end on the connection issue. I was trying with a gmail account using imap and found I needed to force a secure connection:

    http://flourishlib.com/docs/fMailbox

    It seems to me like this module should have an config option to define this true/false, but for the moment I just changed this line in the .module file from:

    $mailbox = new fMailbox($this->emailType, $this->emailHost, $category->emailAddress, $this->emailPassword, $this->emailPort);
    

    to:

    $mailbox = new fMailbox($this->emailType, $this->emailHost, $category->emailAddress, $this->emailPassword, NULL, TRUE);
    

    I was having connection or username/password issues until I made this change, but now it works perfectly and pages are created as expected.

    Can you let me know if that works for you and if it does I'll add a config setting for it and add that to the pull request to Pete.

  6. Glad that sorted out the category adding issue. I'll submit that pull request to Pete.

    As for the server connection issue - I am really not sure, but I don't think it is related to this module. Perhaps there are some issues with the Flourish library (included in this module) and your pop/imap server, or a firewall issue.

    Maybe someone who has been using the module more might have a better idea.

  7. I have attached a revised version of the module. I know Pete is pretty busy with other things at the moment, so I thought I'd try to help out.

    I haven't tested this thoroughly, but I think it should take care of things. It also includes a few other fixes, like adding delete buttons for each category and also fixing a bunch of PHP warnings.

    If you could test and let me know if everything is working fine and then I'll submit a pull request for Pete.

    My forked version

    • Like 2
  8. Nice catch horst :)

    Can I go one simpler:

    $pids = array(1010, 1011, 1022);
    if(in_array($page->id, $pids)) {
        echo $pages->get("1114")->body";
    }
    

    or even just:

    if(in_array($page->id, array(1010, 1011, 1022))) echo $pages->get("1114")->body";
    • Like 4
  9. Hey kongondo - no worries. Maybe it will be ready for the modules directory sometime soon. I just need to find the time to get back to it - maybe this post will get me motivated to find the time - I do think it has lots of potential and most of the hard work is already done :)

    • Like 1
  10. Check out this module:

    http://processwire.com/talk/topic/4420-page-list-migrator/

    It is still in development, but it allows you to export a hierarchy of pages, templates and fields from one PW installation to another and import them into another PW installation. It currently doesn't copy the actually template.php files, but that is the easy part really :)

    A blog setup is definitely one of the uses I am thinking of for this module, but at the moment you will find on the import page of the module the ability to import/create the pages/templates/fields for lists of countries and a few state lists.

    I really do want to get back to finalizing this module, but it is in a usable state already although I would definitely recommend running it on a test installation of PW and not one with data that you care about first. If it works for your needs then use it wherever.

    • Like 2
  11. No problem, another alternative would be:

    $pids = array(1010, 1011, 1022);
    $downloads = $pages->get("1114");   
    if (in_array($page->id, $pids)){
        echo "$downloads->body";
    } 
    

    This would be cleaner if your list of pages started getting longer.

    • Like 4
  12. The key is find vs get:

    $downloads = $pages->find("id=1|1114|1452");
    
    foreach($download as $p){
        echo $p->body;
    }
    

    EDIT: Actually I am not quite sure what you are trying to achieve. I left out the check for whether the current page is id=1011, but you can easily add that back into my code.

    Am I on the right track with grabbing the content of pages using multiple IDs in the find, or am I off track completely with what you want?

    • Like 1
  13. Wow, speedy service! It shouldn't be that complicated to get imagemagick compiled with rsvg. I have certainly had my issues with dependency conflicts over the years, but two weeks is a lot of debugging time :)

    Anyway, great to hear you have it working now and the conversion results are good. I am really excited to have someone else using this. I wish there was an easier way to make these conversions, but unfortunately there is nothing simple. There are options that use batik (needs java) and some php classes that make use of running inkscape via the command line (relies on exec which is often disabled), so the imagemiagick / rsvg combo seems to be the best option and gives great results.

    That latest version should have fixed a few dimension calculation issues from the previous version, but please let me know if you come across any issues or have any ideas for improved functionality.

  14. Yes, I am using the Zurb Foundation 5 profile which has 1.10.x version of jQuery. Maybe the module could be fixed to use .on?

    It isn't always as simple, but in the case of this module with the way that statement is structured, you can simply replace "live" with "on". 

    If you want you can file an issue over at: https://github.com/NicoKnoll/ProcessPageDelete/issues/new and ask Nico to make the change. I don't think there is any need to worry about detecting the availability of "on" anymore with a "live" fallback, because PW is using jQuery 1.8 which supports "on".

    • Like 1
×
×
  • Create New...