PHP Classes

File: engine/modules/core/workflow/workflow.hook.inc

Recommend this page to a friend!
  Classes of Aldo Tripiciano   Quanta CMS   engine/modules/core/workflow/workflow.hook.inc   Download  
File: engine/modules/core/workflow/workflow.hook.inc
Role: Example script
Content type: text/plain
Description: Example script
Class: Quanta CMS
Manage content that works without a database
Author: By
Last change:
Date: 6 years ago
Size: 1,327 bytes
 

Contents

Class file image Download
<?php
/**
 * Implements hook_shadow_node_form().
 *
 * @param Environment $env
 * The Environment.
 * @param array $vars
 * An array of variables.
 */
function workflow_shadow_node_form($env, $vars) {
 
$vars['shadow']->addTab('manage status', file_get_contents($env->getModulePath('workflow') . '/tpl/status_form.html'), 2);
}

/**
 * Implements hook_doctor_setup().
 *
 * Create all default statuses if they don't exist yet.
 *
 * @param Environment $env
 * The Environment.
 * @param array $vars
 * An array of variables.
 */
function workflow_doctor_setup($env, $vars) {
 
// Initialize default statuses.
 
$basic_statuses = array(
   
NODE_STATUS_DRAFT => array('title' => 'Draft'),
   
NODE_STATUS_UNPUBLISHED => array('title' => 'Unpublished'),
   
NODE_STATUS_PUBLISHED => array('title' => 'Published'),
  );

  foreach (
$basic_statuses as $status => $statusdata) {
    if (!
is_dir($env->dir['statuses'] . '/' . $status)) {
     
NodeFactory::buildNode($env, $status, '_statuses', $statusdata);
    }
  }

}

/**
 * Implements hook_node_presave().
 *
 * @param Environment $env
 * The Environment.
 * @param array $vars
 * An array of variables.
 */
function workflow_node_presave($env, $vars) {
  if (isset(
$vars['data']['edit-status'])) {
   
$vars['node']->setStatus($vars['data']['edit-status']);
  }
}