Author: sshyrkov
Date: Mon Dec  3 19:39:48 2007
New Revision: 19332

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19332&repname=
=3Djahia
Log:
JAHIA-2156: Sp3 Topbar Redesign: New "Quick Validate" button
http://www.jahia.net/jira/browse/JAHIA-2156
Resolution: "Quick validate" icon added to perform most "permissive" workfl=
ow action

Added:
    trunk/core/src/java/org/jahia/ajax/actionmenus/QuickValidationAction.ja=
va
    trunk/core/src/java/org/jahia/services/workflow/QuickActivationJob.java
    trunk/core/src/webapp/jsp/jahia/engines/images/gear_ok.png   (with prop=
s)
Modified:
    trunk/core/src/conf/java/jahiatemplates/common.properties
    trunk/core/src/conf/java/jahiatemplates/common_en.properties
    trunk/core/src/webapp/WEB-INF/etc/struts/struts-config.xml
    trunk/core/src/webapp/jsp/jahia/topbar/topmenu.inc

Modified: trunk/core/src/conf/java/jahiatemplates/common.properties
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/conf/j=
ava/jahiatemplates/common.properties&rev=3D19332&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/core/src/conf/java/jahiatemplates/common.properties (original)
+++ trunk/core/src/conf/java/jahiatemplates/common.properties Mon Dec  3 19=
:39:48 2007
@@ -14,6 +14,8 @@
 siteSettings                             =3D Site settings
 esiInvalidatePage                        =3D Regenerate the current page i=
n the ESI Cache Server
 filemanager.name                         =3D File manager
+quickValidate                            =3D Quick validation =

+quickValidate.prompt                     =3D This will perform a workflow =
validation operation. You can enter your comment here. Would you like to co=
ntinue?
 =

 ContentPageOperations                    =3D Page operations
 ContentContainerListOperations           =3D List operations

Modified: trunk/core/src/conf/java/jahiatemplates/common_en.properties
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/conf/j=
ava/jahiatemplates/common_en.properties&rev=3D19332&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/core/src/conf/java/jahiatemplates/common_en.properties (original)
+++ trunk/core/src/conf/java/jahiatemplates/common_en.properties Mon Dec  3=
 19:39:48 2007
@@ -14,6 +14,8 @@
 siteSettings                             =3D Site settings
 esiInvalidatePage                        =3D Regenerate the current page i=
n the ESI Cache Server
 filemanager.name                         =3D File manager
+quickValidate                            =3D Quick validation =

+quickValidate.prompt                     =3D This will perform a workflow =
validation operation. You can enter your comment here. Would you like to co=
ntinue?
 =

 ContentPageOperations                    =3D Page operations
 ContentContainerListOperations           =3D List operations

Added: trunk/core/src/java/org/jahia/ajax/actionmenus/QuickValidationAction=
.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/core/src=
/java/org/jahia/ajax/actionmenus/QuickValidationAction.java&rev=3D19332&rep=
name=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/core/src/java/org/jahia/ajax/actionmenus/QuickValidationAction.ja=
va (added)
+++ trunk/core/src/java/org/jahia/ajax/actionmenus/QuickValidationAction.ja=
va Mon Dec  3 19:39:48 2007
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2002-2007 Jahia Ltd
+ *
+ * Licensed under the JAHIA COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (J=
CDDL), =

+ * Version 1.0 (the "License"), or (at your option) any later version; you=
 may =

+ * not use this file except in compliance with the License. You should hav=
e =

+ * received a copy of the License along with this program; if not, you may=
 obtain =

+ * a copy of the License at =

+ *
+ *  http://www.jahia.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software =

+ * distributed under the License is distributed on an "AS IS" BASIS, =

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied=
. =

+ * See the License for the specific language governing permissions and =

+ * limitations under the License.
+ */
+package org.jahia.ajax.actionmenus;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.jahia.ajax.AjaxAction;
+import org.jahia.exceptions.JahiaException;
+import org.jahia.hibernate.manager.SpringContextSingleton;
+import org.jahia.params.ProcessingContext;
+import org.jahia.params.ProcessingContextFactory;
+import org.jahia.registries.ServicesRegistry;
+import org.jahia.services.scheduler.BackgroundJob;
+import org.jahia.services.workflow.ActivationJob;
+import org.jahia.services.workflow.QuickActivationJob;
+import org.quartz.JobDataMap;
+import org.quartz.JobDetail;
+
+/**
+ * Ajax-based action handler for retrieving the workflow state of the cont=
ent
+ * object.
+ * =

+ * @author Sergiy Shyrkov
+ */
+public class QuickValidationAction extends AjaxAction {
+
+    private static final Logger logger =3D Logger
+            .getLogger(QuickValidationAction.class);
+
+    private static ProcessingContextFactory processingContextFactory =3D (=
ProcessingContextFactory) SpringContextSingleton
+            .getInstance().getContext().getBean(
+                    ProcessingContextFactory.class.getName());
+
+    public ActionForward execute(ActionMapping mapping, ActionForm form,
+            HttpServletRequest request, HttpServletResponse response)
+            throws IOException, ServletException {
+
+        long startTime =3D System.currentTimeMillis();
+
+        response.setHeader("Cache-Control",
+                "no-cache, no-store, must-revalidate");
+        response.setHeader("Pragma", "no-cache");
+        response.setDateHeader("Expires", System.currentTimeMillis() - 19 =
* 24
+                * 60 * 60 * 1000L);
+
+        try {
+            String pid =3D request.getParameter("pid");
+            if (StringUtils.isEmpty(pid)) {
+                throw new IllegalArgumentException(
+                        "Required parameter 'pid' is missing.");
+            }
+            String key =3D request.getParameter("key");
+            if (StringUtils.isEmpty(key)) {
+                throw new IllegalArgumentException(
+                        "Required parameter 'key' is missing.");
+            }
+            ProcessingContext ctx =3D processingContextFactory.getContext(
+                    request, response, super.getServlet().getServletContex=
t(),
+                    "/op/edit/pid/" + pid);
+
+            scheduleJob(ctx, key);
+
+            response.setStatus(HttpServletResponse.SC_OK);
+
+        } catch (IllegalArgumentException iae) {
+            response.sendError(HttpServletResponse.SC_BAD_REQUEST, iae
+                    .getMessage());
+        } catch (Exception e) {
+            logger.error("Unable to process the request !", e);
+            if (!response.isCommitted()) {
+                response.sendError(
+                        HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+                        "Unable to get workflow state. Cause: "
+                                + e.getMessage());
+            }
+        }
+        if (logger.isDebugEnabled()) {
+            logger.debug("GetExtendedWorkflowStateAction.perform took: "
+                    + (System.currentTimeMillis() - startTime));
+        }
+        return null;
+    }
+
+    private void scheduleJob(ProcessingContext ctx, String objectKey)
+            throws JahiaException {
+        final JobDetail jobDetail =3D BackgroundJob.createJahiaJob(
+                "QuickValidation", QuickActivationJob.class, ctx);
+        JobDataMap jobDataMap =3D jobDetail.getJobDataMap();
+        jobDataMap.put(BackgroundJob.JOB_DESTINATION_SITE, ctx.getSite()
+                .getSiteKey());
+        jobDataMap.put(BackgroundJob.JOB_TYPE, ActivationJob.WORKFLOW_TYPE=
);
+
+        jobDataMap.put(QuickActivationJob.CONTENT_OBJECT_KEY, objectKey);
+        jobDataMap.put(ActivationJob.COMMENTS_INPUT, ctx
+                .getParameter(ActivationJob.COMMENTS_INPUT));
+
+        ServicesRegistry.getInstance().getSchedulerService()
+                .scheduleJobNow(jobDetail);
+    }
+
+}

Added: trunk/core/src/java/org/jahia/services/workflow/QuickActivationJob.j=
ava
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/core/src=
/java/org/jahia/services/workflow/QuickActivationJob.java&rev=3D19332&repna=
me=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/core/src/java/org/jahia/services/workflow/QuickActivationJob.java=
 (added)
+++ trunk/core/src/java/org/jahia/services/workflow/QuickActivationJob.java=
 Mon Dec  3 19:39:48 2007
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2002-2007 Jahia Ltd
+ *
+ * Licensed under the JAHIA COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (J=
CDDL), =

+ * Version 1.0 (the "License"), or (at your option) any later version; you=
 may =

+ * not use this file except in compliance with the License. You should hav=
e =

+ * received a copy of the License along with this program; if not, you may=
 obtain =

+ * a copy of the License at =

+ *
+ *  http://www.jahia.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software =

+ * distributed under the License is distributed on an "AS IS" BASIS, =

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied=
. =

+ * See the License for the specific language governing permissions and =

+ * limitations under the License.
+ */
+package org.jahia.services.workflow;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.jahia.content.ContentObject;
+import org.jahia.content.NodeOperationResult;
+import org.jahia.content.ObjectKey;
+import org.jahia.engines.workflow.ActionEntry;
+import org.jahia.engines.workflow.AdvancedWorkflowEngine;
+import org.jahia.engines.workflow.WorkflowHelper;
+import org.jahia.engines.workflow.WorkflowHelperEntry;
+import org.jahia.engines.workflow.WorkflowHelperLanguageEntry;
+import org.jahia.params.ProcessingContext;
+import org.jahia.registries.ServicesRegistry;
+import org.jahia.services.lock.LockKey;
+import org.jahia.services.lock.LockService;
+import org.jahia.services.version.ActivationTestResults;
+import org.jahia.services.version.JahiaSaveVersion;
+import org.jahia.services.version.StateModificationContext;
+import org.quartz.JobDataMap;
+import org.quartz.JobExecutionContext;
+
+/**
+ * Backgrouind job used to perform most "permissive" activation action for=
 the
+ * current user and teh secified content object.
+ * =

+ * @author Sergiy Shyrkov
+ */
+public class QuickActivationJob extends ActivationJob {
+
+    public static final String CONTENT_OBJECT_KEY =3D "contentObjectKey";
+
+    private static final Logger logger =3D Logger
+            .getLogger(QuickActivationJob.class);
+
+    private boolean checkLockAcquired(ContentObject contentObject,
+            ProcessingContext ctx) {
+        boolean success =3D true;
+        // locks activated?
+        if (ctx.settings().areLocksActivated()) {
+            LockService lockRegistry =3D ServicesRegistry.getInstance()
+                    .getLockService();
+            final LockKey lockKey =3D LockKey.composeLockKey(contentObject
+                    .getObjectKey(), LockKey.WORKFLOW_ACTION);
+
+            // do we already have a lock on it? If not --> acquire it
+            if (lockRegistry.isAlreadyAcquiredInContext(lockKey, ctx.getUs=
er(),
+                    ctx.getUser().getUserKey())
+                    || lockRegistry.acquire(lockKey, ctx.getUser(), ctx
+                            .getUser().getUserKey(), ctx.getSessionState()
+                            .getMaxInactiveInterval(), false)) {
+                // great, we have it!
+            } else {
+                // failure
+                success =3D false;
+            }
+        }
+        return success;
+    }
+
+    public void executeJahiaJob(JobExecutionContext jobExecutionContext,
+            ProcessingContext ctx) throws Exception {
+
+        JobDataMap jobData =3D jobExecutionContext.getJobDetail().getJobDa=
taMap();
+        ActivationTestResults activationTestResults =3D new ActivationTest=
Results(
+                ActivationTestResults.FAILED_OPERATION_STATUS);
+
+        try {
+            ContentObject contentObject =3D retrieveObject(jobData, ctx);
+
+            WorkflowHelper workflowHelper =3D AdvancedWorkflowEngine
+                    .getWorkflowHelper(ctx, contentObject);
+            JahiaSaveVersion saveVersion =3D ServicesRegistry.getInstance()
+                    .getJahiaVersionService().getSiteSaveVersion(
+                            ctx.getSiteID());
+            WorkflowHelperEntry wfEntry =3D workflowHelper.getEntry(conten=
tObject
+                    .getObjectKey());
+
+            Iterator langEntries =3D wfEntry.getLanguageEntries();
+            WorkflowHelperLanguageEntry langEntry =3D langEntries.hasNext(=
) ? (WorkflowHelperLanguageEntry) langEntries
+                    .next()
+                    : null;
+
+            if (langEntry !=3D null && langEntry.getAvailableOptions().siz=
e() > 0) {
+                ActionEntry action =3D (ActionEntry) langEntry
+                        .getAvailableOptions().get(0);
+
+                // can we get a lock on this object?
+                if (!checkLockAcquired(contentObject, ctx)) {
+                    throw new IllegalStateException(
+                            "Unable to acquire a lock on the object '"
+                                    + contentObject.getObjectKey()
+                                    + "' for workflow operation");
+                }
+
+                String comment =3D StringUtils.isNotEmpty(jobData
+                        .getString(ActivationJob.COMMENTS_INPUT)) ? jobData
+                        .getString(ActivationJob.COMMENTS_INPUT) : null;
+                Map userNotifData =3D new HashMap();
+                Map externalWorkflows =3D new HashMap();
+                Set languageCodes =3D new HashSet();
+                for (Iterator iterator =3D wfEntry.getLanguages(); iterator
+                        .hasNext();) {
+                    languageCodes.add((String) iterator.next());
+                }
+
+                activationTestResults =3D new ActivationTestResults(
+                        ActivationTestResults.COMPLETED_OPERATION_STATUS);
+
+                ExternalWorkflow externalWorkflow =3D processWorkflow(ctx,
+                        workflowHelper, contentObject.getObjectKey(), acti=
on
+                                .getAdditionalKey(), action.getKey(),
+                        languageCodes, saveVersion, userNotifData, comment,
+                        activationTestResults, new StateModificationContex=
t(
+                                contentObject.getObjectKey(), languageCode=
s));
+                =

+                releaseLock(contentObject, ctx);
+                =

+                if (externalWorkflow !=3D null) {
+                    externalWorkflows.put(externalWorkflow, externalWorkfl=
ow);
+                }
+                if (externalWorkflows.size() > 0) {
+                    Iterator it =3D externalWorkflows.keySet().iterator();
+                    while (it.hasNext()) {
+                        ((ExternalWorkflow) it.next()).sendResults(ctx,
+                                activationTestResults, userNotifData);
+                    }
+                } else {
+                    sendMail(ctx, comment, userNotifData);
+                }
+
+            } else {
+                logger.info("No workflow action is available for user '"
+                        + ctx.getUser().getUsername() + "' for object '"
+                        + contentObject.getObjectKey() + "'");
+                activationTestResults
+                        .setStatus(ActivationTestResults.COMPLETED_OPERATI=
ON_STATUS);
+            }
+        } catch (IllegalArgumentException e) {
+            logger.error(e);
+            activationTestResults.appendError(new NodeOperationResult(null,
+                    null, e.getMessage()));
+        } catch (IllegalStateException e) {
+            logger.error(e);
+            activationTestResults.appendError(new NodeOperationResult(null,
+                    null, e.getMessage()));
+        } finally {
+            jobData.put(RESULT, activationTestResults);
+        }
+    }
+
+    private void releaseLock(ContentObject contentObject, ProcessingContex=
t ctx) {
+        // locks activated?
+        if (ctx.settings().areLocksActivated()) {
+            LockService lockRegistry =3D ServicesRegistry.getInstance()
+                    .getLockService();
+            final LockKey lockKey =3D LockKey.composeLockKey(contentObject
+                    .getObjectKey(), LockKey.WORKFLOW_ACTION);
+
+            // release lock
+            lockRegistry.release(lockKey, ctx.getUser(), ctx.getUser()
+                    .getUserKey());
+        }
+    }
+
+    private ContentObject retrieveObject(JobDataMap jobData,
+            ProcessingContext ctx) throws ClassNotFoundException {
+        // get our object
+        String keyValue =3D jobData.getString(CONTENT_OBJECT_KEY);
+
+        // key value is not empty?
+        if (StringUtils.isEmpty(keyValue)) {
+            throw new IllegalArgumentException(
+                    "The object key is either null or empty");
+        }
+
+        ObjectKey key =3D ObjectKey.getInstance(keyValue);
+
+        // correct key?
+        if (key =3D=3D null) {
+            throw new IllegalArgumentException(
+                    "Unable to find a content object for a key: " + key);
+        }
+
+        ContentObject contentObject =3D ContentObject
+                .getContentObjectInstance(key);
+
+        // content object found for this key?
+        if (contentObject =3D=3D null) {
+            throw new IllegalArgumentException(
+                    "Unable to find a content object for a key: " + key);
+        }
+
+        return contentObject;
+    }
+
+}

Modified: trunk/core/src/webapp/WEB-INF/etc/struts/struts-config.xml
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/webapp=
/WEB-INF/etc/struts/struts-config.xml&rev=3D19332&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/core/src/webapp/WEB-INF/etc/struts/struts-config.xml (original)
+++ trunk/core/src/webapp/WEB-INF/etc/struts/struts-config.xml Mon Dec  3 1=
9:39:48 2007
@@ -395,6 +395,11 @@
                 validate=3D"false">
         </action>
 =

+        <action path=3D"/QuickValidate"
+            type=3D"org.jahia.ajax.actionmenus.QuickValidationAction"
+                validate=3D"false">
+        </action>
+        =

         <!--=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D-->
         <!-- ADMININSTRATION SECTION                                           
                                           -->
         <!--=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D-->

Added: trunk/core/src/webapp/jsp/jahia/engines/images/gear_ok.png
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/core/src=
/webapp/jsp/jahia/engines/images/gear_ok.png&rev=3D19332&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
Binary file - no diff available.

Modified: trunk/core/src/webapp/jsp/jahia/topbar/topmenu.inc
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/webapp=
/jsp/jahia/topbar/topmenu.inc&rev=3D19332&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/core/src/webapp/jsp/jahia/topbar/topmenu.inc (original)
+++ trunk/core/src/webapp/jsp/jahia/topbar/topmenu.inc Mon Dec  3 19:39:48 =
2007
@@ -96,7 +96,22 @@
     function reportError(request) {
         var thekey =3D request.responseText;
         alert(thekey);
-    }
+    }
+
+function doPublishPage() {
+    var comment =3D prompt("<content:resourceBundle resourceBundle=3D'jahi=
atemplates.common' resourceName=3D'quickValidate.prompt' defaultValue=3D'!!=
!This will perform a workflow validation operation. You can enter your comm=
ent here. Would you like to continue?'/>", "");
+    if (comment !=3D null) {
+        new Ajax.Request(jahia.config.contextPath + '/ajaxaction/QuickVali=
date', {
+            method: 'post',
+            parameters: 'pid=3D' + jahia.config.pageId + '&key=3DContentPa=
ge_' + jahia.config.pageId + '&commentsInput=3D' + encodeURIComponent(comme=
nt),
+            onFailure: function(transport) {
+                alert('Error ' + transport.status + ' - ' + transport.stat=
usText);
+            }
+        });
+    }
+
+    return false;
+}    =

 </script>
 <%
     }
@@ -157,7 +172,8 @@
                            request.setAttribute("languagesStates", 
pageOnlyLanguagesStates=
);
                        }
                        =

-                Enumeration languageEnum =3D languageSettings.elements();
+                Enumeration languageEnum =3D languageSettings.elements();
+                boolean hasSomethingToPublish =3D false;
 =

                 while (siteLangSettingsEnum.hasMoreElements()) {
                     SiteLanguageSettings curSetting =3D (SiteLanguageSetti=
ngs)siteLangSettingsEnum.nextElement();
@@ -188,11 +204,15 @@
                            %><div class=3D"workflowState"><jahia:displayLa=
nguageFlag code=3D"<%=3DlanguageCode%>"
                                 href=3D'<%=3DcurrentLanguageCode.equals(la=
nguageCode) ? "" : jData.gui().drawPageLanguageSwitch(languageCode)%>'
                                 alt=3D"<%=3DlanguageName%>"/><%
-                                if (languageState !=3D null /*&& wf_visu.t=
rim().equalsIgnoreCase("true")*/) {
+                                if (languageState !=3D null /*&& wf_visu.t=
rim().equalsIgnoreCase("true")*/) {
+                                    hasSomethingToPublish =3D hasSomething=
ToPublish || languageState.intValue() > 1; =

                                     %><jahia:displayIcon src=3D"<%=3Dlangu=
ageState.toString()%>" lang=3D"<%=3DlanguageCode%>"/><%
                                 } %></div><%
                     }
-                }//end while
+                }//end while
+                if (hasSomethingToPublish) {
+                %><span>|</span><span><a href=3D"#publish" onclick=3D"retu=
rn doPublishPage();" title=3D"<content:resourceBundle resourceBundle=3D'jah=
iatemplates.common' resourceName=3D'quickValidate' defaultValue=3D'Quick va=
lidation'/>" style=3D"margin-top: 0; padding-top: 0;"><img style=3D"margin-=
top: 0" src=3D"<content:serverHttpPath />/jsp/jahia/engines/images/gear_ok.=
png" width=3D"16" height=3D"16" alt=3D"<content:resourceBundle resourceBund=
le=3D'jahiatemplates.common' resourceName=3D'quickValidate' defaultValue=3D=
'Quick validation'/>" title=3D"<content:resourceBundle resourceBundle=3D'ja=
hiatemplates.common' resourceName=3D'quickValidate' defaultValue=3D'Quick v=
alidation'/>" border=3D"0" /></a></span><%
+                }
             }
     }
 }

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to