adrian

Admin Actions

Recommended Posts

Hi everyone,

Here's a new module that I have been meaning to build for a long time.

http://modules.processwire.com/modules/process-admin-actions/

https://github.com/adrianbj/ProcessAdminActions

 

What does it do?

Do you have a bunch of admin snippets laying around, or do you recreate from them from scratch every time you need them, or do you try to find where you saw them in the forums, or on the ProcessWire Recipes site?

Admin Actions lets you quickly create actions in the admin that you can use over and over and even make available to your site editors (permissions for each action are assigned to roles separately so you have full control over who has access to which actions).

 

Included Actions

It comes bundled with a several actions and I will be adding more over time (and hopefully I'll get some PRs from you guys too). You can browse and sort and if you have @tpr's Admin on Steroid's datatables filter feature, you can even filter based on the content of all columns. 

Screen Shot 2016-11-29 at 11.30.44 AM.png

The headliner action included with the module is: PageTable To RepeaterMatrix which fully converts an existing (and populated) PageTable field to either a Repeater or RepeaterMatrix field. This is a huge timesaver if you have an existing site that makes heavy use of PageTable fields and you would like to give the clients the improved interface of RepeaterMatrix.

Copy Content To Other Field
This action copies the content from one field to another field on all pages that use the selected template.

Copy Field Content To Other Page
Copies the content from a field on one page to the same field on another page.

Copy Repeater Items To Other Page
Add the items from a Repeater field on one page to the same field on another page.

Copy Table Field Rows To Other Page
Add the rows from a Table field on one page to the same field on another page.

Create Users Batcher
Allows you to batch create users. This module requires the Email New User module and it should be configured to generate a password automatically.

Delete Unused Fields
Deletes fields that are not used by any templates.

Delete Unused Templates
Deletes templates that are not used by any pages.

Email Batcher
Lets you email multiple addresses at once.

Field Set Or Search And Replace
Set field values, or search and replace text in field values from a filtered selection of pages and fields.

FTP Files to Page
Add files/images from a folder to a selected page.

Page Active Languages Batcher
Lets you enable or disable active status of multiple languages on multiple pages at once.

Page Manipulator
Uses an InputfieldSelector to query pages and then allows batch actions on the matched pages.

Page Table To Repeater Matrix
Fully converts an existing (and populated) PageTable field to either a Repeater or RepeaterMatrix field.

Template Fields Batcher
Lets you add or remove multiple fields from multiple templates at once.

Template Roles Batcher
Lets you add or remove access permissions, for multiple roles and multiple templates at once.

User Roles Permissions Batcher
Lets you add or remove permissions for multiple roles, or roles for multiple users at once.

 

Creating a New Action

If you create a new action that you think others would find useful, please add it to the actions subfolder of this module and submit a PR. If you think it is only useful for you, place it in /site/templates/AdminActions/ so that it doesn't get lost on module updates.

A new action file can be as simple as this:

class UnpublishAboutPage extends ProcessAdminActions {

    protected function executeAction() {
        $p = $this->pages->get('/about/');
        $p->addStatus(Page::statusUnpublished);
        $p->save();
        return true;
    }

}

Each action:

  • class must extend "ProcessAdminActions" and the filename must match the class name and end in ".action.php" like: UnpublishAboutPage.action.php
  • the action method must be: executeAction()

As you can see there are only a few lines needed to wrap the actual API call, so it's really worth the small extra effort to make an action.

Obviously that example action is not very useful. Here is another more useful one that is included with the module. It includes $description, $notes, and $author variables which are used in the module table selector interface. It also makes use of the defineOptions() method which builds the input fields used to gather the required options before running the action.

class DeleteUnusedFields extends ProcessAdminActions {

    protected $description = 'Deletes fields that are not used by any templates.';
    protected $notes = 'Shows a list of unused fields with checkboxes to select those to delete.';
    protected $author = 'Adrian Jones';
    protected $authorLinks = array(
        'pwforum' => '985-adrian',
        'pwdirectory' => 'adrian-jones',
        'github' => 'adrianbj',
    );

    protected function defineOptions() {

        $fieldOptions = array();
        foreach($this->fields as $field) {
            if ($field->flags & Field::flagSystem || $field->flags & Field::flagPermanent) continue;
            if(count($field->getFieldgroups()) === 0) $fieldOptions[$field->id] = $field->label ? $field->label . ' (' . $field->name . ')' : $field->name;
        }

        return array(
            array(
                'name' => 'fields',
                'label' => 'Fields',
                'description' => 'Select the fields you want to delete',
                'notes' => 'Note that all fields listed are not used by any templates and should therefore be safe to delete',
                'type' => 'checkboxes',
                'options' => $fieldOptions,
                'required' => true
            )
        );

    }


    protected function executeAction($options) {

        $count = 0;
        foreach($options['fields'] as $field) {
            $f = $this->fields->get($field);
            $this->fields->delete($f);
            $count++;
        }

        $this->successMessage = $count . ' field' . _n('', 's', $count) . ' ' . _n('was', 'were', $count) . ' successfully deleted';
        return true;

    }

}

 

This defineOptions() method builds input fields that look like this:

Screen Shot 2016-11-29 at 12.32.59 PM.png

Finally we use $options array in the executeAction() method to get the values entered into those options fields to run the API script to remove the checked fields.

There is one additional method that I didn't outline called: checkRequirements() - you can see it in action in the PageTableToRepeaterMatrix action. You can use this to prevent the action from running if certain requirements are not met.

At the end of the executeAction() method you can populate $this->successMessage, or $this->failureMessage which will be returned after the action has finished.

 

Populating options via URL parameters
You can also populate the option parameters via URL parameters. You should split multiple values with a “|” character.

You can either just pre-populate options:

http://mysite.dev/processwire/setup/admin-actions/options?action=TemplateFieldsBatcher&templates=29|56&fields=219&addOrRemove=add

or you can execute immediately:

http://mysite.dev/processwire/setup/admin-actions/execute?action=TemplateFieldsBatcher&templates=29|56&fields=219&addOrRemove=add


Note the “options” vs “execute” as the last path before the parameters.

 

Automatic Backup / Restore

Before any action is executed, a full database backup is automatically made. You have a few options to run a restore if needed:

  • Follow the Restore link that is presented after an action completes
  • Use the "Restore" submenu: Setup > Admin Actions > Restore
  • Move the restoredb.php file from the /site/assets/cache/AdminActions/ folder to the root of your site and load in the browser
  • Manually restore using the AdminActionsBackup.sql file in the /site/assets/cache/AdminActions/ folder

I think all these features make it very easy to create custom admin data manipulation methods that can be shared with others and executed using a simple interface without needing to build a full Process Module custom interface from scratch. I also hope it will reduce the barriers for new ProcessWire users to create custom admin functionality.

Please let me know what you think, especially if you have ideas for improving the interface, or the way actions are defined.

 

 

  • Like 32
  • Thanks 1

Share this post


Link to post
Share on other sites

This is very cool. Both the module and the bundled actions will be super useful. Thanks! :)

  • Like 3

Share this post


Link to post
Share on other sites

Nice!

Just an idea: could the actions accept url params? Eg. prefill the template selector with "basic-page" using this url:

/admin/setup/admin-actions/options?action=TemplateFieldsBatcher&templates=basic-page

This would enable linking the action from other places of the admin (eg. add right-click menu option on pagelist, etc).

Plus another idea: actions could be put into a subdir, if users start to contribute actions their number will increase.

Btw I see you haven't overcomplicated the UI of the roles :)

  • Like 2

Share this post


Link to post
Share on other sites

Whoa, Adrian you rock as usual :) thanks so much! And the idea of contribution to the actions is the best part of all.

  • Like 3

Share this post


Link to post
Share on other sites

Awesome idea and bad ass realization @adrian! (pardon my French)

I did not install yet but will do soon and check it out. As @szabesz said collaboration is the baddest part. I can expect a load of wise stuff to learn from those actions contributed by PW gurus. It just might happen that there will be a lot of actions - maybe put them in a folder?

And one question about the backup. It seems it is custom and not integrated with db backup module. Is there a reason for that?

 

  • Like 2

Share this post


Link to post
Share on other sites
5 hours ago, tpr said:

Nice!

Just an idea: could the actions accept url params? Eg. prefill the template selector with "basic-page" using this url:


/admin/setup/admin-actions/options?action=TemplateFieldsBatcher&templates=basic-page

This would enable linking the action from other places of the admin (eg. add right-click menu option on pagelist, etc).

 

I like the idea - are you thinking that if all required options are passed it would be possible to run directly with no intermediate "Execute Action" button? Perhaps an additional url parameter: ?execute=true - without this, all options would be prefilled, but the user would still have the option to modify if needed before executing.

Any thoughts?

 

5 hours ago, tpr said:

Plus another idea: actions could be put into a subdir, if users start to contribute actions their number will increase.

Yeah, I did think about it, but I think you're right, it is probably a good idea.

 

5 hours ago, tpr said:

Btw I see you haven't overcomplicated the UI of the roles :)

I think you are being genuine and not sarcastic, but just wanted to clarify. I am actually wondering if maybe I should convert the config settings page to a DataTables layout (like how it is on the main module process page) - not sure how simple that would be to implement at this point, but might be nice if this starts to fill out with a lot of actions. Btw, in case you guys didn't realize, you can actually remove the superuser role from any actions you know you won't ever use so that you have a shorter list to choose/filter from when using the module.

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, Ivan Gretsky said:

Awesome idea and bad ass realization @adrian! (pardon my French)

Glad you like it :)

 

3 minutes ago, Ivan Gretsky said:

I did not install yet but will do soon and check it out. As @szabesz said collaboration is the baddest part. I can expect a load of wise stuff to learn from those actions contributed by PW gurus. It just might happen that there will be a lot of actions - maybe put them in a folder?

Definitely part of my goal! And yes, I agree with you and @tpr - a subfolder is the way to go.

 

3 minutes ago, Ivan Gretsky said:

And one question about the backup. It seems it is custom and not integrated with db backup module. Is there a reason for that?

Are you talking about this module: http://modules.processwire.com/modules/process-database-backups/ - what if users don't have it installed? 

At the moment it only stores the one version of the backup - it gets overwritten every time you run a new action. It would be no problem to store more backups, but I was worried that it might be tempting to restore an old backup which could take you back too far and you might lose some manually adjusted content etc. The idea of the automatic backup was to provide a quick recovery from an action that didn't do what you expected. I am definitely happy to revisit this though, so please everyone give me your ideas on this.

Share this post


Link to post
Share on other sites
10 minutes ago, adrian said:

what if users don't have it installed? 

Let's inform them ;) Jokes aside, the db backup module is supported by Ryan, so it should be safe to rely on it.

10 minutes ago, adrian said:

which could take you back too far and you might lose some manually adjusted content etc.

Sensible use cases would dictate to try things out in a development environment not on a live site, so I would not worry too much about this.

Edited by szabesz
typo
  • Like 2

Share this post


Link to post
Share on other sites

@adrian How about adding:

protected $authorForumsProfile = '985-adrian';

so that one can more easily identify the author? Should be used as trailing part of the href attribute, of course ;) 

  • Like 2

Share this post


Link to post
Share on other sites
1 hour ago, szabesz said:

Sensible use cases would dictate to try things out in a development environment not on a live site, so I would not worry too much about this.

Let me think about this a little more - even in a dev environment restoring to a really old backup could be disastrous if you're still developing the site. I guess that's the responsibility of the dev to be smart about things though.

 

29 minutes ago, szabesz said:

@adrian How about adding:


protected $authorForumsProfile = '985-adrian';

so that one can more easily identify the author? Should be used as trailing part of the href attribute, of course ;) 

I like it - I think giving authors proper credit will hopefully promote more contributions.

I have gone with PW developer directory link, PW forum profile, and also Github account, with linked icons.

Screen Shot 2016-11-30 at 7.28.31 AM.png

I could maybe provide the option for the author to fully customize their links, but don't want things getting too ugly. Any thoughts?

  • Like 2

Share this post


Link to post
Share on other sites

Ok, the optional author links are now available. These are the current options:

    protected $authorLinks = array(
        'pwforum' => '985-adrian',
        'pwdirectory' => 'adrian-jones',
        'github' => 'adrianbj',
    );

 

  • Like 3

Share this post


Link to post
Share on other sites
On 11/30/2016 at 0:09 AM, tpr said:

Just an idea: could the actions accept url params? Eg. prefill the template selector with "basic-page" using this url:


/admin/setup/admin-actions/options?action=TemplateFieldsBatcher&templates=basic-page

This would enable linking the action from other places of the admin (eg. add right-click menu option on pagelist, etc).

Ok, this functionality is ready, although please test carefully at this stage.

You can populate the option parameters via URL parameters. You should split multiple values with a "|" character.

There are two options:

1) You can either just pre-populate the options values, but still showing the options page where you can make changes via the options form GUI:

http://mysite.dev/processwire/setup/admin-actions/options?action=TemplateFieldsBatcher&templates=29|56&fields=219&addOrRemove=add

2) or you can execute immediately with the passed options values:

http://mysite.dev/processwire/setup/admin-actions/execute?action=TemplateFieldsBatcher&templates=29|56&fields=219&addOrRemove=add


Note the "options" vs "execute" as the last path segment before the parameters. 

Please try it out and let me know what you think. Do you think it might also be nice to have an option to redirect to another page after it has executed, rather than showing the results page? With your suggestion of linking from other places in the admin are you thinking about maybe an ajax call to an action, rather than loading the page? I haven't tested this yet, but it might be a nice option. I might even be able to return a JSON formatted response if called via ajax?

  • Like 3

Share this post


Link to post
Share on other sites

Thanks, it's a great step forward :) A JSON return would be great - I think a use case could be established first to see how this could work.

  • Like 1

Share this post


Link to post
Share on other sites
Just now, tpr said:

I think a use case could be established first to see how this could work.

Well you should get to work on one then :)  

Send me a PR with a new action and I can work on the ajax response to suit your needs and we'll take it from there!

  • Like 2

Share this post


Link to post
Share on other sites

I don't have any particular feature in mind now but I'm sure there will be one later :)

  • Like 1

Share this post


Link to post
Share on other sites

It's now available in the modules directory: http://modules.processwire.com/modules/process-admin-actions/ 

It also includes a few new actions. The first post and the Github ReadMe give a small description of each action.

Hope you all find something useful among them.

Again, please feel free to contribute some actions, or if you have an idea but don't know how to build, let me know and maybe I can put it together.

  • Like 4

Share this post


Link to post
Share on other sites
7 hours ago, adrian said:

or if you have an idea but don't know how to build, let me know and maybe I can put it together.

Best service ever :rolleyes:

  • Like 1

Share this post


Link to post
Share on other sites
14 hours ago, adrian said:

if you have an idea but don't know how to build, let me know and maybe I can put it together.

<attempted geek joke> If you are into the new syntax of PHP 7.1, how about something like this...

public function declareBrexitReferendumResult() : void;     /* UK version */
public function declarePresidentialElectionResult() : void; /* US version */

...take your pick. :undecided: </attempted geek joke>

  • Like 4

Share this post


Link to post
Share on other sites

For those of you who are experienced with the PW API (and those looking to learn), there is now an "Action Code" viewer that shows the executeAction() method of the action you are about to execute. It is of course collapsed by default and only available to superusers.

Anyway, hope you'll find it useful and either reassuring (if you're worried about what code it about to be executed on your site), or informative as to what can be done with the API.

Screen Shot 2016-12-04 at 12.19.22 PM.png

 

  • Like 10

Share this post


Link to post
Share on other sites

Hi everyone,

To celebrate @teppo featuring this module in PW Weekly, I have added a new action: Create Users Batcher

It lets you quickly create many users by entering: "username, email address" on separate lines in a textarea.

This action requires the EmailNewUser module and it must be configured to automatically generate a user password. The action checks for this module and that setting before it will let you proceed. I also recommend that you install the PasswordForceChange module to reduce the risks of having emailed a password to a user.

You can set multiple roles to be added to each new user. Be aware that at least one of these roles must have the "profile-edit" permission so that the user has the ability to change their password when they first login.

Screen Shot 2016-12-10 at 10.05.07 PM.png

 

Note that EmailNewUser will report each successful user creation and email sent success.

Screen Shot 2016-12-10 at 10.05.34 PM.png

 

I hope that the next time you need to create several users for a new client that you'll give this a try.

And of course, don't forget to send me your own actions for inclusion with the module :) 

  • Like 8

Share this post


Link to post
Share on other sites

Quick update to the CreateUsersBatcher action. It now allows two options:

1) Define Username and email address (requires EmailNewUser to generate password).

2) Define additional user template fields (whichever ones you want). If you use this option and include the password, then you don't need the EmailNewUser module.

You could even given all staff at a client's office the same temp password and let me know by phone (this way there is no security risk with emailing even a temporary password that will be changed) - it's your choice.

Hopefully this screenshot will help to explain it better - note that the "New Users" textarea lists the fields from the user template and the order they need to be entered. In this example I have additional "first_name" and "last_name" fields, as well as the field added by the PasswordForceChange module which you can set to 1 to enforce this if you want.

Screen Shot 2016-12-11 at 1.33.57 PM.png

  • Like 5

Share this post


Link to post
Share on other sites

New version now supports running actions via the API. 

Here's an example of copying content of a field from one page to another.

Simply load the module, and call the action class name as a method while passing the required options as an array:

$options = array(
   'field' => 99, 
   'sourcePage' => 1131, 
   'destinationPage' => 1132
);
$modules->get("ProcessAdminActions")->CopyFieldContentToOtherPage($options);

Hopefully you'll find a use for this in your hooks or template files.

  • Like 6

Share this post


Link to post
Share on other sites

I think the admin UI could be re-arranged into a table layout:

  • first column: action names
  • second column: description/notes
  • third column: applied roles + and Edit button, that opens a modal or perhaps only unhides the role asmSelector. Alternatively you can set the asmSelect to operate in "inline" mode, I've experimented with that and it worked.

I know it would take some time, but sooner or later this has to be done :)

 

  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      I've updated the module to 0.0.3. I removed the instructions from this forum, so I don't have to maintain it on multiple places. Just checkout the readme on github 🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github. 
    • By blynx
      Hej,
      A module which helps including Photoswipe and brings some modules for rendering gallery markup. Feedback highly appreciated
      (Also pull requests are appreciated 😉 - have a new Job now and don't work a lot with ProcessWire anymore, yet, feel free to contact me here or on GitHub, Im'm still "online"!)

      Modules directory: http://modules.processwire.com/modules/markup-processwire-photoswipe
      .zip download: https://github.com/blynx/MarkupProcesswirePhotoswipe/archive/master.zip
      You can add a photoswipe enabled thumbnail gallery / lightbox to your site like this. Just pass an image field to the renderGallery method:
      <?php $pwpswp = $modules->get('Pwpswp'); echo $pwpswp->renderGallery($page->nicePictures); Options are provided like so:
      <?php $galleryOptions = [ 'imageResizerOptions' => [ 'size' => '500x500' 'quality' => 70, 'upscaling' => false, 'cropping' => false ], 'loresResizerOptions' => [ 'size' => '500x500' 'quality' => 20, 'upscaling' => false, 'cropping' => false ], 'pswpOptions' => (object) [ 'shareEl' => false, 'indexIndicatorSep' => ' von ', 'closeOnScroll' => false ] ]; echo $pswp->renderGallery($page->images, $galleryOptions); More info about all that is in the readme: https://github.com/blynx/MarkupProcesswirePhotoswipe
      What do you think? Any ideas, bugs, critique, requests?
      cheers
      Steffen
    • By bernhard
      WHY?
      This module was built to fill the gap between simple $pages->find() operations and complex SQL queries.
      The problem with $pages->find() is that it loads all pages into memory and that can be a problem when querying multiple thousands of pages. Even $pages->findMany() loads all pages into memory and therefore is a lot slower than regular SQL.
      The problem with SQL on the other hand is, that the queries are quite complex to build. All fields are separate tables, some repeatable fields use multiple rows for their content that belong to only one single page, you always need to check for the page status (which is not necessary on regular find() operations and therefore nobody is used to that).
      In short: It is far too much work to efficiently and easily get an array of data based on PW pages and fields and I need that a lot for my RockGrid module to build all kinds of tabular data.

      Basic Usage

       
      Docs & Download
      https://gitlab.com/baumrock/RockFinder/tree/master
       
      Changelog
      180516 change sql query method, bump version to 1.0.0 180515 multilang bugfix 180513 beta release <180513 preview/discussion took place here: https://processwire.com/talk/topic/18983-rocksqlfinder-highly-efficient-and-flexible-sql-finder-module/
    • By flydev
      OAuth2Login for ProcessWire
      A Module which give you ability to login an existing user using your favorite thrid-party OAuth2 provider (i.e. Facebook, GitHub, Google, LinkedIn, etc.)..
      You can login from the backend to the backend directly or render a form on the frontend and redirect the user to a choosen page.
      Built on top of ThePhpLeague OAuth2-Client lib.
      Registration is not handled by this module but planned.
       
      Howto Install
      Install the module following this procedure:
       - http://modules.processwire.com/modules/oauth2-login/
       - https://github.com/flydev-fr/OAuth2Login
      Next step, in order to use a provider, you need to use Composer to install each provider
      ie: to install Google, open a terminal, go to your root directory of pw and type the following command-line: composer require league/oauth2-google
      Tested providers/packages :
          Google :  league/oauth2-google     Facebook: league/oauth2-facebook     Github: league/oauth2-github     LinkedIn: league/oauth2-linkedin
      More third-party providers are available there. You should be able to add a provider by simply adding it to the JSON config file.

      Howto Use It
      First (and for testing purpose), you should create a new user in ProcessWire that reflect your real OAuth2 account information. The important informations are, Last Name, First Name and Email. The module will compare existing users by firstname, lastname and email; If the user match the informations, then he is logged in.
      ie, if my Google fullname is John Wick, then in ProcessWire, I create a new user  Wick-John  with email  johnwick@mydomain.com
      Next step, go to your favorite provider and create an app in order to get the ClientId and ClientSecret keys. Ask on the forum if you have difficulties getting there.
      Once you got the keys for a provider, just paste it into the module settings and save it. One or more button should appear bellow the standard login form.
      The final step is to make your JSON configuration file.
      In this sample, the JSON config include all tested providers, you can of course edit it to suit your needs :
      { "providers": { "google": { "className": "Google", "packageName": "league/oauth2-google", "helpUrl": "https://console.developers.google.com/apis/credentials" }, "facebook": { "className": "Facebook", "packageName": "league/oauth2-facebook", "helpUrl": "https://developers.facebook.com/apps/", "options": { "graphApiVersion": "v2.10", "scope": "email" } }, "github": { "className": "Github", "packageName": "league/oauth2-github", "helpUrl": "https://github.com/settings/developers", "options": { "scope": "user:email" } }, "linkedin": { "className": "LinkedIn", "packageName": "league/oauth2-linkedin", "helpUrl": "https://www.linkedin.com/secure/developer" } } }  
      Backend Usage
      In ready.php, call the module :
      if($page->template == 'admin') { $oauth2mod = $modules->get('Oauth2Login'); if($oauth2mod) $oauth2mod->hookBackend(); }  
      Frontend Usage
      Small note: At this moment the render method is pretty simple. It output a InputfieldForm with InputfieldSubmit(s) into wrapped in a ul:li tag. Feedbacks and ideas welcome!
      For the following example, I created a page login and a template login which contain the following code :
      <?php namespace ProcessWire; if(!$user->isLoggedin()) { $options = array( 'buttonClass' => 'my_button_class', 'buttonValue' => 'Login with {provider}', // {{provider}} keyword 'prependMarkup' => '<div class="wrapper">', 'appendMarkup' => '</div>' ); $redirectUri = str_lreplace('//', '/', $config->urls->httpRoot . $page->url); $content = $modules->get('Oauth2Login')->config( array( 'redirect_uri' => $redirectUri, 'success_uri' => $page->url ) )->render($options); }
      The custom function lstr_replace() :
      /* * replace the last occurence of $search by $replace in $subject */ function str_lreplace($search, $replace, $subject) { return preg_replace('~(.*)' . preg_quote($search, '~') . '~', '$1' . $replace, $subject, 1); }  
      Screenshot
       



    • By gRegor
      Updated 2018-05-06:
      Version 2.0.0 released
      Updated 2017-03-27:
      Version 1.1.3 released
      Updated 2016-04-11:
      Version 1.1.2 released

      Updated 2016-02-26:
      Officially in the module directory! http://modules.processwire.com/modules/webmention/

      Updated 2016-02-25:
      Version 1.1.0 is now released. It's been submitted to the module directory so should appear there soon. In the meantime, it's available on GitHub: https://github.com/gRegorLove/ProcessWire-Webmention. Please refer to the updated README there and let me know if you have any questions!
      ------------
      Original post:
       
      This is now out of date. I recommend reading the official README.
       
      I've been working on this one for a while. It's not 100%, but it is to the point I'm using it on my own site, so it's time for me to release it in beta. Once I finish up some of the features described below, I will submit it to the modules directory as a stable plugin.
      For now, you can install from Github. It works on PW2.5. I haven't tested on PW2.6, but it should work there.
      Feedback and questions are welcome. I'm in the IRC channel #processwire as well as #indiewebcamp if you have any questions about this module, webmention, or microformats.
      Thanks to Ryan for the Comments Fieldtype which helped me a lot in the handling of webmentions in the admin area.
      ProcessWire Webmention Module
      Webmention is a simple way to automatically notify any URL when you link to it on your site. From the receiver's perspective, it is a way to request notification when other sites link to it.
      Version 1.0.0 is a stable beta that covers webmention sending, receiving, parsing, and display. An easy admin interface for received webmentions is under development, as well as support for the Webmention Vouch extension.
      Features
      * Webmention endpoint discovery
      * Automatically send webmentions asynchronously * Automatically receive webmentions * Process webmentions to extract microformats   Requirements * php-mf2 and php-mf2-cleaner libraries; bundled with this package and may optionally be updated using Composer. * This module hooks into the LazyCron module.   Installation Github: https://github.com/gRegorLove/ProcessWire-Webmention

      Installing the core module named "Webmention" will automatically install the Fieldtype and Inputfield modules included in this package.   This module will attempt to add a template and page named "Webmention Endpoint" if the template does not exist already. The default location of this endpoint is http://example.com/webmention-endpoint   After installing the module, create a new field of type "Webmentions" and add it to the template(s) you want to be able to support webmentions. Sending Webmentions
      When creating or editing a page that has the Webmentions field, a checkbox "Send Webmentions" will appear at the bottom. Check this box and any URLs linked in the page body will be queued up for sending webmentions. Note: you should only check the "Send Webmentions" box if the page status is "published."   Receiving Webmentions This module enables receiving webmentions on any pages that have have "Webmentions" field, by adding the webmention endpoint as an HTTP Link header. If you would like to specify a custom webmention endpoint URL, you can do so in the admin area, Modules > Webmention.   Processing Webmentions (beta) Currently no webmentions are automatically processed. You will need to browse to the page in the backend, click "Edit," and scroll to the Webmentions field. There is a dropdown for "Visibility" and "Action" beside each webmention. Select "Process" to parse the webmention for microformats.   A better interface for viewing/processing all received webmentions in one place is under development.   Displaying Webmentions (beta) Within your template file, you can use `$page->Webmentions->render()` [where "Webmentions" is the name you used creating the field] to display a list of approved webmentions. As with the Comments Fieldtype, you can also generate your own output.   The display functionality is also under development.   Logs This module writes two logs: webmentions-sent and webmentions-received.   Vouch The Vouch anti-spam extension is still under development.   IndieWeb The IndieWeb movement is about owning your data. It encourages you to create and publish on your own site and optionally syndicate to third-party sites. Webmention is one of the core building blocks of this movement.   Learn more and get involved by visiting http://indiewebcamp.com.   Further Reading * http://indiewebcamp.com/webmention * http://indiewebcamp.com/comments-presentation * http://indiewebcamp.com/reply