Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Can I add workflow step to language section of properties tab View modes: 
User avatar
Member
Member
brien-anca - 7/15/2011 12:47:53 AM
   
Can I add workflow step to language section of properties tab
It would be very helpful if I could display the workflow step of each language version of a document in the language section of the properties tab. Is this possible?

Eg: instead of
Doc 1 English Translated
Doc 1 German Translated
Doc 1 Spanish Outdated
Doc 1 Italian Translated

I would prefer
Doc 1 English Published
Doc 1 German Translation
Doc 1 Spanish Translation Review
Doc 1 Italian Ready to Publish

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 7/16/2011 7:12:30 AM
   
RE:Can I add workflow step to language section of properties tab
Hello,

As it turns out you will have to make some customizations. The name of the workflow step can be taken from the table CMS_WorkflowStep.
Here is a sample query (this is just an example):

select StepName from CMS_WorkflowStep where StepID in (select DocumentWorkflowStepID from CMS_Document where DocumentID='990')

The value 990 in this case is the DocumentID.

The file which displays the given content is in this case the ~CMSModules\Content\CMSDesk\Properties\General.aspx ASPX file and it's code behind. You will have to modify those files to take the workflow step name from the database and display it according to your needs.

FYI:

If you want to edit the CMS Desk/CMS Site manager, you can find out what files are displaying the given content with the Firefox browser. "Right click on the given frame -> This Frame -> View frame info" - there is the path of the file, which contains the displayed page.


Best regards,
Boris Pocatko

User avatar
Member
Member
brien-anca - 7/27/2011 9:12:57 PM
   
RE:Can I add workflow step to language section of properties tab
Thanks,

FYI, I added another column in Languages.xml and modified ~CMSModules\Content\CMSDesk\Properties\Languages.aspx ReloadData() method as follows (Build Workflow Step comment):

    protected void ReloadData()
{
if (nodeId != 0)
{
if (!dataReloaded)
{
dataReloaded = true;
// Get node
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
TreeNode node = tree.SelectSingleNode(nodeId);
// Check if node is not null
if (node != null)
{
// Get documents
int topN = gridLanguages.GridView.PageSize * (gridLanguages.GridView.PageIndex + 1 + gridLanguages.GridView.PagerSettings.PageButtonCount);
DataSet documentsDS = DocumentHelper.GetDocuments(CMSContext.CurrentSiteName, node.NodeAliasPath, TreeProvider.ALL_CULTURES, false, null, null, null, -1, false, topN, TreeProvider.SELECTNODES_REQUIRED_COLUMNS + ", DocumentModifiedWhen, DocumentLastPublished, DocumentName, VersionNumber, Published", tree);
DataTable documents = documentsDS.Tables[0];

if (!DataHelper.DataSourceIsEmpty(documents))
{
// Get site cultures
DataSet allSiteCultures = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName).Copy();

// Rename culture column to enable row transfer
allSiteCultures.Tables[0].Columns[2].ColumnName = "DocumentCulture";
// Create where condition for row transfer
string where = "DocumentCulture NOT IN (";
foreach (DataRow row in documents.Rows)
{
where += "'" + row["DocumentCulture"] + "',";
}
where = where.TrimEnd(',') + ")";

// Transfer missing cultures, keep original list of site cultures
DataHelper.TransferTableRows(documents, allSiteCultures.Copy().Tables[0], where, null);
DataHelper.EnsureColumn(documents, "DocumentCultureDisplayName", typeof(string));

// Ensure culture names
foreach (DataRow cultDR in documents.Rows)
{
string cultureCode = cultDR["DocumentCulture"].ToString();
DataRow[] cultureRow = allSiteCultures.Tables[0].Select("DocumentCulture='" + cultureCode + "'");
if (cultureRow.Length > 0)
{
cultDR["DocumentCultureDisplayName"] = cultureRow[0]["CultureName"].ToString();
}
}

// Initialize unigrid
gridLanguages.OnExternalDataBound += gridLanguages_OnExternalDataBound;

// Ensure default culture to be first
DataRow defaultCultureRow = documents.Select("DocumentCulture='" + DefaultSiteCulture + "'")[0];

DataRow dr = documents.NewRow();
dr.ItemArray = defaultCultureRow.ItemArray;
documents.Rows.InsertAt(dr, 0);
documents.Rows.Remove(defaultCultureRow);

// Get last modification date of default culture
defaultCultureRow = documents.Select("DocumentCulture='" + DefaultSiteCulture + "'")[0];
defaultLastModification = ValidationHelper.GetDateTime(defaultCultureRow["DocumentModifiedWhen"], DateTimeHelper.ZERO_TIME);
defaultLastPublished = ValidationHelper.GetDateTime(defaultCultureRow["DocumentLastPublished"], DateTimeHelper.ZERO_TIME);
// Add column containing translation status
documents.Columns.Add("TranslationStatus", typeof(TranslationStatusEnum));

// Add a column conataining workflow step
documents.Columns.Add("WorkflowStep");

// Get proper translation status and store it to datatable
foreach (DataRow document in documents.Rows)
{
TranslationStatusEnum status = TranslationStatusEnum.NotAvailable;
string workflowStep = "";
int documentId = ValidationHelper.GetInteger(document["DocumentID"], 0);
if (documentId == 0)
{
status = TranslationStatusEnum.NotAvailable;
}
else
{
// Build the document status

string versionNumber = ValidationHelper.GetString(DataHelper.GetDataRowValue(document, "VersionNumber"), null);
DateTime lastModification = DateTimeHelper.ZERO_TIME;

// Check if document is outdated
if (versionNumber != null)
{
lastModification = ValidationHelper.GetDateTime(document["DocumentLastPublished"], DateTimeHelper.ZERO_TIME);
status = (lastModification < defaultLastPublished) ? TranslationStatusEnum.Outdated : TranslationStatusEnum.Translated;
}
else
{
lastModification = ValidationHelper.GetDateTime(document["DocumentModifiedWhen"], DateTimeHelper.ZERO_TIME);
status = (lastModification < defaultLastModification) ? TranslationStatusEnum.Outdated : TranslationStatusEnum.Translated;
}

// BUild the workflow step

TreeNode nodeThisLang = tree.SelectSingleDocument(documentId);
if (nodeThisLang != null)
{
WorkflowManager wm = new WorkflowManager((TreeProvider)tree);
WorkflowInfo wi = wm.GetNodeWorkflow(nodeThisLang);

if (wi != null)
{
// Document is using workflow
WorkflowStepInfo step = wm.GetStepInfo(nodeThisLang);
workflowStep = step.StepDisplayName;
}
}

}
document["TranslationStatus"] = status;
document["WorkflowStep"] = workflowStep;
}

// Bind datasource
DataSet filteredDocuments = documentsDS.Clone();
DataRow[] filteredDocs = documents.Select(gridLanguages.GetDataTableFilter());
foreach (DataRow row in filteredDocs)
{
filteredDocuments.Tables[0].ImportRow(row);
}

gridLanguages.DataSource = filteredDocuments;
gridLanguages.ReloadData();
}
}
}
}

Not culture specific column contents but suits my purposes