Admin event hook when flex object is saved - grav

In Grav admin, there is an event hook called onAdminSave, which is triggered when you save a page. Is there a similar hook for flex objects, that allows manipulation of flex objects before they are written to the filesystem?

If you run grep -roHE --include=*.php "fireEvent\('[^']+'" inside folder /user/plugins/flex-objects you will get the following named events:
classes/FlexFormFactory.php: fireEvent('onBeforeFlexFormInitialize'
classes/Table/DataTable.php: fireEvent('onTwigSiteVariables'
classes/Admin/AdminController.php: fireEvent('onFlexTask'
classes/Admin/AdminController.php: fireEvent('onFlexAction'
classes/Admin/AdminController.php: fireEvent('onFlexAfterDelete'
classes/Admin/AdminController.php: fireEvent('onAdminAfterSaveAs'
classes/Admin/AdminController.php: fireEvent('onAdminCreatePageFrontmatter'
classes/Admin/AdminController.php: fireEvent('onFlexAfterSave'
classes/Controllers/ObjectController.php: fireEvent('gitsync'
classes/Controllers/MediaController.php: fireEvent('onAdminAfterAddMedia'
classes/Controllers/MediaController.php: fireEvent('onAdminAfterDelMedia'
flex-objects.php: fireEvent('onFlexInit'
flex-objects.php: fireEvent('onBeforeFlexFormInitialize'
You also might want to take a look at this similar question on Grav's own forum: Admin Event Hook for Flex Object

Related

How to format Alfresco'API parameter activityFilter in servce user activities feed ?

I need to use that api : http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Freferences%2FRESTful-FeedUserfeedGet.html
What I don't know is how to format activityFilter parameter ? What kind of things can I filter ? I'd like to set a max number of results, is it possible ?
I don't know where to find the documentation.
Thank you.
Mathieu.
I don't know where/if the list is documented, but it isn't hard to find out the values you are looking for...
The first place to go is the Web Script Index, which is:
http://localhost:8080/alfresco/service/index
From there you can find that web script, click on its ID, and see its declaration, any accompanying documentation, and, often, the code of the web script controller.
In this case, the controller is Java-based, so you can get its class and go look at that in the source.
Often, that's not convenient. So the next thing to do is to realize that Alfresco Share makes use of the same web script. If you turn on Firebug and go to the Alfresco Share Global Dashboard you can see the activity feed dashlet. As you change the second dropdown (the one that defaults to "all items") you will see your browser doing GETs against that web script. By choosing the various choices available in the dashlet, you'll see that the values it uses to filter activities are:
org.alfresco.comments.comment-created
org.alfresco.comments.comment-updated
org.alfresco.documentlibrary.file-added
org.alfresco.documentlibrary.file-deleted
org.alfresco.documentlibrary.file-updated
org.alfresco.documentlibrary.files-added
org.alfresco.documentlibrary.files-deleted
org.alfresco.documentlibrary.files-updated
org.alfresco.profile.status-changed
org.alfresco.site.user-joined
org.alfresco.site.user-left
org.alfresco.site.user-role-changed
You can pass more than one of these at-a-time to the web script by separating each with an escaped comma (%2C).
There may be more filters available, but those are the ones used by the activity feed dashlet on the global dashboard.

How can you extend the default behavior of Tridion.Cme.Commands.Open.prototype._execute()?

I have written a GUI extension which adds an additional tab to many of the Item views in the SDL Tridion CME (e.g. Component, Page and Schema etc.). I have also written some JavaScript which loads that tab directly if when the view is loaded with a tab name is specified in the URL.
The result is that if a page is loaded with the tab name added as follows:
http://localhost/WebUI/item.aspx?tcm=64#id=tcm:1-48-64&tab=InfoTab
Rather than the default of
http://localhost/WebUI/item.aspx?tcm=64#id=tcm:1-48-64
The Info Tab will be loaded on top, instead of the General Tab. This is performed with the following code snippet and works very well:
$evt.addEventHandler($display, "start", onDisplayStarted);
// This callback is called when any view has finished loading
function onDisplayStarted() {
$evt.removeEventHandler($display, "start", onDisplayStarted);
var tabname = $url.getHashParam("tab");
if (tabname != '') {
var tabControl = $controls.getControl($("#MasterTabControl"), "Tridion.Controls.TabControl");
tabControl.selectItem(tabname);
}
}
Now I would like to make a context menu item to open items and link to the tabs using my new functionality. My first thought was to construct the Item URL myself and simply open a new window in my execute method. So I looked at the default functionality in the standard Open.prototype_execute() functionality of the GUI. This is stored in the navigation.js file of the CME, and is performed by the Tridion.Cme.Commands.Open.prototype._execute method. The code is a lot more complicated than I had anticipated as it deals with shared items, and permissions etc.
Rather than just copying all of this code to my own function, I was wondering if there is a way to elegantly extend the existing Open.prototype_execute() function and append my “&tab=MyTab” to the $cme.Popups.OPEN_ITEM_OPTIONS.URL constant for my own functions.
Any advice would be greatly appreciated.
At the end the Open command uses $config.getEditorUrl(item_type) to get the url for the item view (item_type - $const.ItemType.COMPONENT, etc). There are no extension points for this part of the functionality, but you could always try to overwrite it on your own risk.

Ploneinfo (as in phpinfo)

What is the most sraightforward (but not very hackish - unPlonish) way to create a "page" in Plone (v 4.x), which would show some Plone internals info? I'd like to generate a page document, which would paste dir() (or whatever my own function) result to <pre/> or something like that. Straightforward.. i mean, without having to create a Plone product or having to modify server files directly - just using ZMI..
You want to install plone.app.debugtoolbar
http://pypi.python.org/pypi/plone.app.debugtoolbar/
which gives you access to the most imporant informations about the current context object, request data etc.
Products.DocFinderTab adds a "Doc" tab in the ZMI that allows you to explore the current object and its methods. If you installed with the Unified Installer and use the "develop" configuration, it's already loaded.
Products.Clouseau may still work with recent Plone's, though it's aging. It gives you an AJAX interface to explore the context from within Plone.
Finally, to explore the request object, you may just add:
<div tal:replace="structure request" />
to a template. That will allow you to check all the HTTP and form variables as well as what's stored in the request.
Go to the ZMI, add a "Script (Python)", and define your function dir() and print the result like this :
print dir()
return printed

CurrentWorkItem.ID is correct or not in workflow script editor?

I am using Tridion 2011 SP1, And I am creating workflow like start-->create-->Review-->publish--Stop.
I created and registered the class library, and invoke the C# method using VBscript (Script Editor of WF Tab) as given below.
Option Explicit
Dim workflowHandler
Set workflowHandler= CreateObject("CoreComponentWorkflow.WorkflowHandler")
If Not workflowHandler Is Nothing Then
Call workflowHandler.PublishComponent(Cstr(CurrentWorkItem.ID))
FinishActivity "Published to WIP"
End If
Set workflowHandler= Nothing
Is the above code is correct? I am sure I am able to create object using the below line.
Set workflowHandler= CreateObject("CoreComponentWorkflow.WorkflowHandler")
And currently I am publishing the current item only using the C# code, am calling the C# function as below.
Call workflowHandler.PublishComponent(Cstr(CurrentWorkItem.ID))
After publishing the item, I am finishing the activity using below.
FinishActivity "Published to WIP"
I have checked the above code directly in the server by hard coding the currentworkitem, it was working fine. But when I put the same code in vbscript editor, the item is not published.
Can any one suggest on this?
When you hardcode you might be adding the TCM ID directly so it is working properly, which means that CurrentWorkItem.ID is not the correct API call to get the Component ID. See Igor comment below to get the tcm id.

Tridion 2009 - Publish another Component from a Component Template

First, the overall description:
There are two Component Templates, NewsArticle and NewsList. NewsArticle is a Dreamweaver Template, and is used to display the content of a news article. NewsList is an xml file that contains aggregated information about all of the news articles.
Currently, a content author must publish the news article, and then re-publish the newslist to regenerate the xml.
Problem:
I have been tasked with having the publish of a news article also regenerate and publish the newslist. Through C#, I am able to retrieve the content of the newslist component, generate the updated xml from the news article, and merge it into the xml from the newslist. I am running into trouble getting the newslist to publish.
I have limited access to documentation, but from what I do have, I believe using the static PublishEngine.Publish method will allow me to do what I need. I believe the first parameter (items) is just a list that contains my updated newslist, and the second parameter is a new PublishInstruction with the RenderInstruction.RenderMode set to Publish. I am a little lost on what the publicationTargets should be.
Am I on the right track? If so, any help with the Publish method call is appreciated, and if not, any suggestions?
Like Quirijn suggested, a broker query is the cleanest approach.
In a situation if a broker isn't available (i.e. static publishing model only) I usually generate the newslist XML from a TBB that adds the XML as a binary, rather than kicking off publishing of another component or page. You can do this by calling this method in your C# TBB:
engine.PublishingContext.RenderedItem.AddBinary(
Stream yourXmlContentConvertedToMemoryStream,
string filename,
StructureGroup location,
string variantId,
string mimeType)
Make the variantId unique per the newslist XML file that you create, so that different components can overwrite/update the same file.
Better yet, do this in a Page Template rather than Component Template so that the news list is generated once per page, rather than per component (if you have multiple articles per page).
You are on the right tracks here with the engine.Publish() method:
PublishEngine.Publish(
new IdentifiableObject[] { linkedComponent },
engine.PublishingContext.PublishInstruction,
new List() { engine.PublishingContext.PublicationTarget });
You can just reuse the PublishInstruction and Target from the current context of your template. This sample shows a Component, but it should work in a page too.
One thing to keep in mind is that this is not possible in SDL Tridion 2011 SP1, as the publish action is not allowed out of the box due to security restrictions. I have an article about this here http://www.tridiondeveloper.com/the-story-of-sdl-tridion-2011-custom-resolver-and-the-allowwriteoperationsintemplates-attribute

Resources