PHP Classes

File: engine/modules/contrib/tpledit/tpledit.hook.inc

Recommend this page to a friend!
  Classes of Aldo Tripiciano   Quanta CMS   engine/modules/contrib/tpledit/tpledit.hook.inc   Download  
File: engine/modules/contrib/tpledit/tpledit.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: 907 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 tpledit_shadow_node_form($env, $vars) {
 
/** @var Shadow $shadow */
 
$shadow = $vars['shadow'];
 
// Edit the current template of the node.
  // For now, we will only allow editing existing tpl.html files, NOT creating new ones.
 
$node = $shadow->getNode();
 
$node->buildTemplate();
  if (
is_file($node->getData('tpl_file'))) {
   
$shadow->addTab('manage templates', file_get_contents('core/node/tpl/tpl_edit.inc'), 2);
  }
}

/**
 * Implements hook_action_node_edit().
 * @param $env
 * @param $vars
 */
function tpledit_action_node_edit($env, $vars) {
 
// TODO: move elsewhere maybe?
 
if (isset($vars['data']['edit-tpl-file'])) {
   
NodeFactory::updateTemplate($env, $vars['data']['edit-tpl-file'], $vars['data']['edit-tpl']);
  }
}