Concrete5 isEditMode()-like handler to get Information about active editing or publishing - content-management-system

So my question is if there is a Concrete 5 handler/listener instead of
isEditMode()
that tells if the user is in active Editing mode or if he just has published his Edit?
Something like
isPublished() or isEditModeActive()
Thx yall
thanks for your interest!
So i tried the Eventhandler in the way it is decumented in the second example:
1. i created site_events.php in the /config
2. i added
<?PHP Events::extendPageType('inhalt', 'on_page_version_approve');?>
i added to the site.php
define('ENABLE_APPLICATION_EVENTS', true);
on the reffered inhalt.php pagetype i added
function on_page_version_approve() {
echo "page published";
}
... nothing happens.
In the description it is written, that the refferring inhalt.php has to exist in /controllers. However, this is not the case. I actually dont quite understand the structure of the Eventhandling. It would be great if you could help me out there...
Thanks in advance anyways :)

It sounds like you want what concrete5 calls Events (http://www.concrete5.org/documentation/developers/system/events/).
As per the docs, you'll get the Page as arguments to the functions you register.
There is nothing quite as specific as what you're looking for, but:
For published, use on_page_version_approve.
For editing, try on_before_render. It's a bit generic (ie, it'll be getting called far more than you're interested), but you can do something like if ($page->getCollectionCheckedOutUserID()). You should experiment a bit with this, though. For example, if you check out the home page for editing, and then someone else loads the live version, the event will probably get called again, and the Page will probably show "checked out". But maybe you can check ->isEditMode(), which should check it against the logged in user...

Related

appAPI.notifier.show sometimes not work

i have a problem with Crossrider code.
I want to display notifier with this code:
appAPI.notifier.show({
'name':'my-notification-name',
'title':'Title',
'body':body_popUp,
'theme':'facebook',
'position':'bottom-left',
'close':false,
'sticky':true,
'fadeAfter':1,
'width':'700px',
'closeWhenClicked':false
});
but sometimes work, sometimes not work.
Do you have an idea? I have to write any instructions before call .show()?
Thanks in advance, Mattia
You don't show what body_popUp is set to but, assuming it's valid HTML and it's placed in the extension,js file, the code look fine.
In general, note that the notification is smart and only appears when it detects user movement in the browser. This algorithm is used as a way to ensure that the notification is seen, as it assumes the user is looking when activity is detected.
[Disclosure: I am a Crossrider employee]

MagnificPopup won´t work with Typo3

I would like to use magnific popup for a site which is still in development, but unfortunately nothing happens after the installation and adding the static content in my template.
No matter what i try no popup comes up.
If someone would like to help me i will provide access to the site.
Thanks a lot!
First thing to do:
look at your source code: does the 'link' show any sign of 'magnific popup' code?
Added classes? id?
Second: do you see any extra javascript and/or stylesheet that is added by the extension?
If you answer negative to 1 of these, the extension does not output anything. Sounds logic, but it is the first step. Is it a solution? Nope, it means your live just got a bit more worse, but hang in there !
If it does show any code from the ext: look at your console, are there any js errors occurred ? (if you don't know what console is, or (even worse) you work with IE) please read about chrome console of at least install Firefox with firebug.
My best beth would be a JS error...
Can it be possible that the ext itself does not work?
Does your php error logs tell you that the extension is behaving badly?
Do you see errors in the typoscript analyser (or whatever it's called to analyse the css_styled_content and other TS spaghetti )
If not, then no, it is not the ext.
Again, i'm betting my wive, three horses and a barrel of beer on JS erros.
Good luck mate !
ps: IF i'm wrong, i'm not sending you my wife by postal service. Loads of trouble last time. Nor the horses, same shizzle ..

How to find out if Unity plugin hangs (from unityscript)

Unity player on my page hangs sometimes. Is it possible to detect it from unityscript (polling method is acceptable) and react to that- for example reload page?
a colleague ran into this issue, I believe that after an extend research with no good results he came up with this solution:
In the web page declare a global variable stillAlive for example.
Use setInterval to check for that variable every n second, something like this:
if (stillAlive){
stillAlive = false;
}else{
//do things
}
Make an Application.ExternalEval call in your application every n/2 seconds, something like this
Application.ExternalEval ("stillAlive=true;");
I don't know the exact details, but he did something to sync those. I'm sure you can figure something out along this idea.
Note: For some reason I couldn't format the code in this answer, so if someone can fix it, please do.
Update: I've just asked him, he said he "synced" them by initiating the setInterval() with Application.ExternalEval().

User Authorization in KohanaPHP App vs Endless Loop

Wondering how to name this question. Think this is the best situation possible.
Situation:
I got small app written in KohanaPHP framework. However there's one small bug that makes my crazy.
I got my own Core_Controller that is extended by every controller in this app. In constructor of this controller, I'm checking user profile status. So far so good. Although I'm facing a logical issue. It's called endless redirect loop. If I try to redirect (in Core_Controller constructor) user to Member_Controller it cannot be workig due to endless lopp. I understand why it happen.
Solution:
I'm looking for a solution how to make it flexible. I tried to move this verification to a helper and call it in Core_Controller constructor. However, it can be working correctly.
Question:
Do I have to put verification in constructor of every single controller? IS there any universal method to do it?
Waiting for your thoughts.
M.A.
Just check if user is verified and the current request's action isn't something like member/verification, do the redirect.
And parent::__construct(); will call the parent constructor, so I don't see the problem in that either..
You need a condition where it doesn't redirect (on the page you have redirected to). You'll want some code similar to this.
if not member_controller then
redirect to member_controller
else
do nothing
endif
The else isn't needed, but just added so it's more clear to you.

How to show previous url after user has canceled dialog with message from Activity#mayStop()?

In our app we need to check if the data is saved when we are in a particular place before navigating away from it. So the user should be able to negate a browser back button request. But by the time that the history value change event is received the url has already been changed. The History class doesn't seem to have a way to restore the url back. Anybody have any ideas?
In GWT 2.1 you get Activities and Places. And activity has a maystop method, which is exactly what you want, if I understand you correctly.
Use a window.onunload or window.onbeforeunload javascript callback to confrim/save state.
onbeforeunload example
I haven't actually implemented this behavior yet, but here is my plan and maybe it will work for you.
1) Each time you receive an onHistoryChanged event and decide to allow it, save the current historyToken in an instance variable somewhere.
2) Keep track of activity on the page that should block navigation. Use a data structure that can keep track of multiple activities, like multiple file uploads, multiple edits, etc.
3) When you receive a new onHistoryChanged event, if your data structure from #2 indicates that it's not safe to navigate, avoid changing the page and restore the historyToken that you saved in #1. I'm assuming that you can do this either by:
a) Calling History.newItem(oldHistoryToken, false) or
b) Calling History.newItem(oldHistoryToken, true) and keeping a flag to force the next onHistoryChanged to be ignored.
Again, I haven't actually implemented this so let me know how it works out.
If you have links that allow the user to leave the app and you want to prevent that as well, you'll need to also add an onbeforeunload.
Have a look at the PlaceManagerImpl class from the gwt-platform framework. Especially the onValueChange() method and the methods dealing with the onLeaveQuestion field.
Hope that helps.
In this issue report, t.broyer explains in his comment that such behavior was planned during design of Places framework. The most important part is:
mayStop was a mistake, or it should have only been called when unloading the app, not for internal navigation within the app.
So probably it's better to not use it at all...