Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

render_new_node_record()

Description

Renders HTML for adding a new node record in the database

Parameters

ColumnTypeDefaultDescription
$form_action string Set the action path of the form
$is_tree boolean Set to TRUE if the field is category tree type
$parent integer 0 ID of the parent of this node
$node_depth_level integer 0 When rendering for trees, we need to know how many levels deep we need to render it
$parent_node_options array array Array of node options to be used as parent for new records

Return

void

Location

include/node_functions.php lines 647 to 732

Definition

 
function render_new_node_record($form_action$is_tree$parent 0$node_depth_level 0, array $parent_node_options = array())
    {
    global 
$baseurl_short$lang;
    if(!isset(
$is_tree))
        {
        
trigger_error('$is_tree param for render_new_node_record() must be set to either TRUE or FALSE!');
        }

    if (
trim($form_action)=="")
        {
        
trigger_error('$form_action param for render_new_node_record() must be set and not be an empty string!');
        }

    
// Render normal fields first then go to tree type
    
if(!$is_tree)
        {
        
?>
        <tr id="new_node_ echo $parent?>_children">
            <td>
                <input type="text" class="stdwidth" name="new_option_name" form="new_option" value="">
            </td>
            <td> </td>
            <td>
                <div class="ListTools">
                    <form id="new_option" method="post" action=" echo $form_action?>">
                         generateFormToken("new_option"); ?>
                        <button type="submit" onClick="AddNode( echo $parent?>); return false;"> echo escape($lang['add']); ?></button>
                    </form>
                </div>
            </td>
        </tr>
        

        
return;
        }

    
// Trees only
    
?>
    <table id="new_node_ echo $parent?>_children" cellspacing="0" cellpadding="5">
        <tbody>
            <tr>
            
            
// Indent node to the correct depth level
            
$i $node_depth_level;
            while(
$i)
                {
                
$i--;
                
?>
                <td class="backline" width="10">
                    <img alt="" width="11" height="11" hspace="4" src=" echo $baseurl_short?>gfx/interface/sp.gif">
                </td>
                
                
}
                
?>
                <td class="backline" width="10">
                    <img alt="" width="11" height="11" hspace="4" src=" echo $baseurl_short?>gfx/interface/sp.gif">
                </td>
                <td>
                    <input type="text" name="new_option_name" form="new_node_ echo $parent?>_option" value="">
                </td>
                <td>
                    <select class="node_parent_chosen_selector" name="new_option_parent" form="new_node_ echo $parent?>_option">
                        <option value="">Select parent</option>
                         foreach($parent_node_options as $node) {
                            
$selected '';
                            if (
trim($parent) != "" && $node['ref'] == $parent) {
                                
$selected ' selected';
                            } 
?>
                            <option value=" echo $node['ref']; ?>" echo $selected?>> echo escape($node['name']); ?></option>
                         ?>
                    </select>
                </td>
                <td>
                    <div class="ListTools">
                        <form id="new_node_ echo $parent?>_option" method="post" action=" echo $form_action?>">
                             generateFormToken("new_node_{$parent}_option"); ?>
                            <button type="submit" onClick="AddNode( echo $parent?>); return false;"> echo escape($lang['add']); ?></button>
                        </form>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>


    
}

This article was last updated 17th November 2024 15:05 Europe/London time based on the source file dated 28th October 2024 11:15 Europe/London time.