Giter Site home page Giter Site logo

apeisa / adminbar Goto Github PK

View Code? Open in Web Editor NEW
12.0 12.0 6.0 245 KB

Provides easy front-end admin bar for editing page content in ProcessWire 2.1. If you are using older 2.0 please see: https://github.com/apeisa/AdminBar/tree/AB20

Home Page: http://processwire.com/talk/index.php/topic,56.0.html

CSS 13.05% JavaScript 13.81% PHP 73.14%

adminbar's People

Contributors

apeisa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

adminbar's Issues

Class conflicts

I just had a conflict with .edit but I am sure there will be others, so it would be great to prefix all classes with "ab_" or "adminbar_", or similar.

Sitemap not working in PW2.1

I installed AdminBar in Processwire 2.1. When clicking on the Sitemap icon, it load the page again inside the lightbox instead of the sitemap.

Doesn't work without jQuery

If template which is loaded with AdminBar doesn't use jQuery, JS effects [modal, etc.] doesn't work.

Found during working on very simple project, where pages themselves have around 40kB data with all the images and styles, btu probably will be the very same when someone uses scriptaculous or mootools.

Fix needed, probably loading local jQuery if no jQuery is loaded, although I currently don't know about any 'clean' solution.

Unused file in source

Hi apeisa,

the 'icons.png' file is redundant โ€“ I accidentaly saved it and forgot to delete it :)

I have some troubles with git on my pc, so I'll actually do something on code when it will be better [tomorrow?] :)

Adam

Scrolling broken in Webkit

When in the edit mode, cannot scroll down the page to view fields below. Affects webkit browsers on OS X. (Current Safari and Chrome).

AdminBar shouldn't be loaded when in Admin

We've had issues with AdminBar loading in admin context. This is especially harmful when dealing with PageTable field, as the JavaScript redirect pretty much renders this module unusable (or PageTable unusable, depending on your point of view).

I've just changed AdminBar locally to add some of it's hooks in ready() instead of init(), since there we've got access to $page, and added a check for current page:

@@ -13,7 +13,7 @@
            'title' => 'Admin Bar',
            'summary' => 'Fast and easy in-page content editing',
            'href' => 'http://processwire.com/talk/index.php/topic,56.0.html',
-           'version' => 101,
+           'version' => 102,
            'permanent' => false,
            'autoload' => true,
            'singular' => true,
@@ -52,6 +52,12 @@
    }

    /**
+    * Permission required by our module
+    *
+    */
+   protected $ab_permission;
+
+   /**
     * Initialize the module and setup hooks
     *
     * The init method of a module is called right after ProcessWire is bootstrapped, when all
@@ -74,15 +80,28 @@

        if ($this->user->isGuest()) return false;

-       $ab_permission = $this->permissions->get('adminbar');
-       if(!$this->user->hasPermission($ab_permission)) return false;
+       $this->ab_permission = $this->permissions->get('adminbar');
+       if(!$this->user->hasPermission($this->ab_permission)) return false;

+       // hook before forms are rendered, so that we can modify the form's "action" attribute
+       $this->addHookBefore('InputfieldForm::render', $this, 'formRender');
+   }
+
+   /**
+    * Setup rest of the hooks
+    *
+    * Some hooks have to be defined here, since we need access to $page var.
+    *
+    */
+   public function ready() {
+
+       if ($this->user->isGuest() || ($this->page && $this->page->template == "admin")) return false;
+
+       if(!$this->user->hasPermission($this->ab_permission)) return false;
+
        $this->pages->addHookAfter('save', $this, 'pageSave');
        $this->addHookAfter('Page::render', $this, "pageRender");

-       // hook before forms are rendered, so that we can modify the form's "action" attribute
-       $this->addHookBefore('InputfieldForm::render', $this, 'formRender');
-
        // hook before a redirect occurs, os we can modify the redirect URL
        $this->session->addHookBefore('redirect', $this, 'sessionRedirect');
    }

What do you think, would this be valid solution, and could the module be updated to this? Any better ideas? I was going to add a check to JS first, but this seems to work much better -- unless there's some reason to load AdminBar in admin context, that is..

Module.php claims that init() is "required", but so far this seems to work perfectly without it too.. might be something that has changed since then, but to guarantee backwards compatibility, empty init() method should probably be added.. and comments should definitely be updated too :)

For the record, this seems to be the cause of ryancramerdesign/ProcessWire#775 (comment), and I've seen a few similar reports.

Note: updated the code above, InputfieldForm::render hook has to be attached in init() and is needed to support older ProcessWire versions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.