public static function renderFormInteriorForNewNotebookPageField($unique_string)
 {
     $rendered = '';
     $rendered .= '<div class="notebook_page_field-label_metadata new-notebook-field-data">';
     $rendered .= '<div class="form-field-label">' . util_lang('metadata', 'properize') . '</div>';
     $rendered .= Metadata_Structure::renderControlSelectAllMetadataStructures('notebook_page_field-label_metadata_structure_id_' . $unique_string) . "\n";
     $rendered .= '</div>';
     $rendered .= '<div class="notebook_page_field-value_specific_metadata new-notebook-field-data">';
     $rendered .= '<div class="form-field-label">' . util_lang('metadata_specific_value', 'properize') . '</div>';
     $rendered .= '<select name="notebook_page_field-value_metadata_term_value_id_' . $unique_string . '" id="notebook_page_field-value_metadata_term_value_id_' . $unique_string . '" class="metadata_term_value_select_control">' . "\n";
     $rendered .= '  <option value="-1">-- ' . util_lang('nothing_from_the_list') . ' --</option>' . "\n";
     $rendered .= '</select>' . "\n";
     $rendered .= '</div>';
     $rendered .= '<div class="notebook_page_field-value_open_metadata new-notebook-field-data">';
     $rendered .= '<div class="form-field-label">' . util_lang('metadata_open_value', 'properize') . '</div>';
     $rendered .= '<input type="text" name="notebook_page_field-value_open_' . $unique_string . '" id="notebook_page_field-value_open_' . $unique_string . '" class="page_field_open_value" value=""/>' . "\n";
     $rendered .= '</div>';
     return $rendered;
 }
 function testRenderFormInteriorForNewNotebookPageField()
 {
     global $DB;
     $DB = $this->DB;
     $canonical = '';
     $canonical .= '<div class="notebook_page_field-label_metadata new-notebook-field-data">';
     $canonical .= '<div class="form-field-label">' . util_lang('metadata', 'properize') . '</div>';
     $canonical .= Metadata_Structure::renderControlSelectAllMetadataStructures('notebook_page_field-label_metadata_structure_id_ABC') . "\n";
     $canonical .= '</div>';
     $canonical .= '<div class="notebook_page_field-value_specific_metadata new-notebook-field-data">';
     $canonical .= '<div class="form-field-label">' . util_lang('metadata_specific_value', 'properize') . '</div>';
     $canonical .= '<select name="notebook_page_field-value_metadata_term_value_id_ABC" id="notebook_page_field-value_metadata_term_value_id_ABC" class="metadata_term_value_select_control">' . "\n";
     $canonical .= '  <option value="-1">-- ' . util_lang('nothing_from_the_list') . ' --</option>' . "\n";
     $canonical .= '</select>' . "\n";
     $canonical .= '</div>';
     $canonical .= '<div class="notebook_page_field-value_open_metadata new-notebook-field-data">';
     $canonical .= '<div class="form-field-label">' . util_lang('metadata_open_value', 'properize') . '</div>';
     $canonical .= '<input type="text" name="notebook_page_field-value_open_ABC" id="notebook_page_field-value_open_ABC" class="page_field_open_value" value=""/>' . "\n";
     $canonical .= '</div>';
     $rendered = Notebook_Page_Field::renderFormInteriorForNewNotebookPageField('ABC');
     //            echo "<pre>\n".htmlentities($canonical)."\n------------------\n".htmlentities($rendered)."\n</pre>";
     $this->assertEqual($canonical, $rendered);
     $this->assertNoPattern('/IMPLEMENTED/', $rendered);
 }
 function testRenderAsEdit()
 {
     $mds = Metadata_Structure::getOneFromDb(['metadata_structure_id' => 6001], $this->DB);
     $mds->loadTermSetAndValues();
     $mds->loadReferences();
     // name, description, details, term set ('none' is OK) - fields present
     // add/remove child structures - add button present, remove buttons present
     // re-order child structures - ordering handles and data fields present
     // ??? references ?
     $canonical = '';
     $canonical .= '<form id="form-edit-metadata-structure-base-data" action="/digitalfieldnotebooks/app_code/metadata_structure.php">' . "\n";
     $canonical .= '  <input type="hidden" name="action" value="update"/>' . "\n";
     $canonical .= '  <input type="hidden" id="metadata_structure_id" name="metadata_structure_id" value="' . $mds->metadata_structure_id . '"/>' . "\n";
     $canonical .= '  <div id="actions"><button id="edit-submit-control" class="btn btn-success" type="submit" name="edit-submit-control" value="update"><i class="icon-ok-sign icon-white"></i> Update</button>' . "\n";
     $canonical .= '  <a id="edit-cancel-control" class="btn" href="/digitalfieldnotebooks/app_code/metadata_structure.php?action=view&metadata_structure_id=6001"><i class="icon-remove"></i> Cancel</a>  <a id="edit-delete-metadata-structure-control" class="btn btn-danger" href="/digitalfieldnotebooks/app_code/metadata_structure.php?action=delete&metadata_structure_id=6001"><i class="icon-trash icon-white"></i> Delete</a>  </div>' . "\n";
     $canonical .= '<div id="edit-rendered_metadata_structure_6001" class="edit-rendered_metadata_structure" ' . $mds->fieldsAsDataAttribs() . '>' . "\n";
     $canonical .= '  <div class="metadata_lineage"><a href="' . APP_ROOT_PATH . '/app_code/metadata_structure.php?action=list">metadata</a> &gt;</div>' . "\n";
     $canonical .= '  <div class="metadata-parent-controls">' . util_lang('label_metadata_structure_change_parent') . ': ' . Metadata_Structure::renderControlSelectAllMetadataStructures('parent_metadata_structure_id', $mds->parent_metadata_structure_id, util_lang('metadata_root_level')) . '</div>' . "\n";
     $canonical .= '  <div class="metadata-structure-header">' . "\n";
     $canonical .= '    <h3><input id="" class="object-name-control" type="text" name="name" value="flower"/></h3>' . "\n";
     $canonical .= '    <div class="active-state-controls"><input type="checkbox" name="flag_active" value="1" checked="checked"/> ' . util_lang('active') . '</div>' . "\n";
     $canonical .= '    <div class="description-controls"><input title="brief description/summary" class="description-control" type="text" name="description" value="info about the flower"/></div>' . "\n";
     $canonical .= '    <div class="details-controls"><textarea title="additional information/details - no size limit" class="details-control" name="details"></textarea></div>' . "\n";
     $canonical .= '    <h4>references</h4>' . "\n";
     $canonical .= Metadata_Reference::renderReferencesArrayAsListsEdit($mds->references);
     $canonical .= '  </div>' . "\n";
     $canonical .= '  <div class="metadata-term-set-controls"><h4>' . util_lang('metadata_term_set') . "</h4>\n" . Metadata_Term_Set::renderAllAsSelectControl('', $mds->term_set ? $mds->term_set->metadata_term_set_id : 0) . "</div>\n";
     $canonical .= '  <h4>further breakdown:</h4>' . "\n";
     $canonical .= '  <ul class="metadata-structure-tree">' . "\n";
     $canonical .= '    <li><a href="' . APP_ROOT_PATH . '/app_code/metadata_structure.php?action=create&parent_metadata_structure_id=' . $mds->metadata_structure_id . '" id="btn-add-metadata-structure" title="' . htmlentities(util_lang('add_metadata_structure')) . '" class="creation_link btn">' . htmlentities(util_lang('add_metadata_structure')) . '</a></li>' . "\n";
     $children = $mds->getChildren();
     foreach ($children as $mds_child) {
         $canonical .= '    ' . $mds_child->renderAsListTreeEditable();
     }
     $canonical .= '  </ul>';
     $canonical .= '</div>';
     $rendered = $mds->renderAsEdit();
     //            echo "<pre>\n".htmlentities($canonical)."\n---------------\n".htmlentities($rendered)."\n</pre>";
     $this->assertNoPattern('/IMPLEMENTED/', $rendered);
     $this->assertEqual($canonical, $rendered);
 }
   public function renderAsEdit()
   {
       if ($this->metadata_structure_id != 'NEW') {
           $this->loadTermSetAndValues();
           $this->loadReferences();
       }
       //  '.$mds_parent->renderAsLink().' &gt;
       $rendered = '';
       $rendered .= '<form id="form-edit-metadata-structure-base-data" action="' . APP_ROOT_PATH . '/app_code/metadata_structure.php">' . "\n";
       $rendered .= '  <input type="hidden" name="action" value="update"/>' . "\n";
       $rendered .= '  <input type="hidden" id="metadata_structure_id" name="metadata_structure_id" value="' . $this->metadata_structure_id . '"/>' . "\n";
       $rendered .= '  <div id="actions">';
       $rendered .= '<button id="edit-submit-control" class="btn btn-success" type="submit" name="edit-submit-control" value="update"><i class="icon-ok-sign icon-white"></i> ' . util_lang($this->metadata_structure_id != 'NEW' ? 'update' : 'save', 'properize') . '</button>' . "\n";
       if ($this->metadata_structure_id != 'NEW') {
           $rendered .= '  <a id="edit-cancel-control" class="btn" href="' . APP_ROOT_PATH . '/app_code/metadata_structure.php?action=view&metadata_structure_id=' . $this->metadata_structure_id . '"><i class="icon-remove"></i> ' . util_lang('cancel', 'properize') . '</a>';
           $rendered .= '  <a id="edit-delete-metadata-structure-control" class="btn btn-danger" href="' . APP_ROOT_PATH . '/app_code/metadata_structure.php?action=delete&metadata_structure_id=' . $this->metadata_structure_id . '"><i class="icon-trash icon-white"></i> ' . util_lang('delete', 'properize') . '</a>';
       } else {
           $rendered .= '  <a id="edit-cancel-control" class="btn" href="' . APP_ROOT_PATH . '/app_code/metadata_structure.php?action=edit&metadata_structure_id=' . $this->metadata_structure_id . '"><i class="icon-remove"></i> ' . util_lang('cancel', 'properize') . '</a>';
       }
       $rendered .= '  </div>' . "\n";
       $rendered .= '<div id="edit-rendered_metadata_structure_' . $this->metadata_structure_id . '" class="edit-rendered_metadata_structure" ' . $this->fieldsAsDataAttribs() . '>
 <div class="metadata_lineage"><a href="' . APP_ROOT_PATH . '/app_code/metadata_structure.php?action=list">' . util_lang('metadata') . '</a> &gt;';
       $lineage = $this->getLineage();
       foreach ($lineage as $mds_ancestor) {
           if ($mds_ancestor->metadata_structure_id != $this->metadata_structure_id) {
               $rendered .= ' ' . $mds_ancestor->renderAsLink() . ' &gt;';
           }
       }
       $rendered .= '</div>' . "\n";
       $rendered .= '  <div class="metadata-parent-controls">' . util_lang('label_metadata_structure_change_parent') . ': ' . Metadata_Structure::renderControlSelectAllMetadataStructures('parent_metadata_structure_id', $this->parent_metadata_structure_id, util_lang('metadata_root_level')) . '</div>' . "\n";
       $rendered .= '  <div class="metadata-structure-header">' . "\n";
       $rendered .= '    <h3><input id="" class="object-name-control" type="text" name="name" value="' . htmlentities($this->name) . '"/></h3>' . "\n";
       $rendered .= '    <div class="active-state-controls"><input type="checkbox" name="flag_active" value="1"' . ($this->flag_active ? ' checked="checked"' : '') . '/> ' . util_lang('active') . '</div>' . "\n";
       $rendered .= '    <div class="description-controls"><input title="' . util_lang('title_description') . '" class="description-control" type="text" name="description" value="' . htmlentities($this->description) . '"/></div>' . "\n";
       $rendered .= '    <div class="details-controls"><textarea title="' . util_lang('title_details') . '" class="details-control" name="details">' . htmlentities($this->details) . '</textarea></div>' . "\n";
       if ($this->metadata_structure_id != 'NEW') {
           $rendered .= '    <h4>' . util_lang('metadata_references') . '</h4>' . "\n";
           $rendered .= Metadata_Reference::renderReferencesArrayAsListsEdit($this->references);
           $rendered .= '  </div>' . "\n";
       }
       $rendered .= '  <div class="metadata-term-set-controls"><h4>' . util_lang('metadata_term_set') . "</h4>\n" . Metadata_Term_Set::renderAllAsSelectControl('', $this->term_set ? $this->term_set->metadata_term_set_id : 0) . "</div>\n";
       if ($this->metadata_structure_id != 'NEW') {
           $rendered .= '  <h4>' . util_lang('metadata_children') . ':</h4>' . "\n";
           $rendered .= '  <ul class="metadata-structure-tree">' . "\n";
           $rendered .= '    <li><a href="' . APP_ROOT_PATH . '/app_code/metadata_structure.php?action=create&parent_metadata_structure_id=' . $this->metadata_structure_id . '" id="btn-add-metadata-structure" title="' . htmlentities(util_lang('add_metadata_structure')) . '" class="creation_link btn">' . htmlentities(util_lang('add_metadata_structure')) . '</a></li>' . "\n";
           $children = $this->getChildren();
           if ($children) {
               foreach ($children as $child) {
                   $rendered .= '    ' . $child->renderAsListTreeEditable();
               }
           }
           $rendered .= '  </ul>';
           if (!$this->term_set && !$children) {
               $rendered .= '<span class="empty-metadata-msg info">' . util_lang('metadata_no_children_no_values') . '</span>';
           }
       }
       $rendered .= '</div>';
       return $rendered;
   }