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);
 }
 function testRenderAsEdit_references()
 {
     $mdts = Metadata_Term_Set::getOneFromDb(['metadata_term_set_id' => 6101], $this->DB);
     $mdts->loadReferences();
     $canonical = Metadata_Reference::renderReferencesArrayAsListsEdit($mdts->references);
     //            $canonical = '';
     //
     //            $list_items_image = '';
     //            $list_items_link = '';
     //            $list_items_text = '';
     //            foreach ($mdts->references as $r) {
     //                if ($r->type == 'image') {
     //                    $list_items_image .= '<li>'.$r->renderAsEditEmbed().'</li>'."\n";
     //                } elseif ($r->type == 'link') {
     //                    $list_items_link .= '<li>'.$r->renderAsEditEmbed().'</li>'."\n";
     //                } elseif ($r->type == 'text') {
     //                    $list_items_text .= '<li>'.$r->renderAsEditEmbed().'</li>'."\n";
     //                }
     //            }
     //
     //            $canonical .= '<ul class="metadata-references edit-metadata-references metadata-references-images">."\n"';
     //            $canonical .= $list_items_image;
     //            $canonical .= '</ul>'."\n";
     //            $canonical .= '<ul class="metadata-references edit-metadata-references metadata-references-links">'."\n";
     //            $canonical .= $list_items_link;
     //            $canonical .= '</ul>'."\n";
     //            $canonical .= '<ul class="metadata-references edit-metadata-references metadata-references-texts">'."\n";
     //            $canonical .= $list_items_text;
     //            $canonical .= '</ul>'."\n";
     $rendered = $mdts->renderAsEdit_references();
     //            echo "<pre>\n".htmlentities($canonical)."\n--------------\n".htmlentities($rendered)."\n</pre>";
     $this->assertEqual($canonical, $rendered);
     $this->assertNoPattern('/IMPLEMENTED/', $rendered);
 }
 function testRenderReferencesArrayAsListsEdit()
 {
     $ref_list = [Metadata_Reference::getOneFromDb(['metadata_reference_id' => 6302], $this->DB), Metadata_Reference::getOneFromDb(['metadata_reference_id' => 6305], $this->DB), Metadata_Reference::getOneFromDb(['metadata_reference_id' => 6304], $this->DB), Metadata_Reference::getOneFromDb(['metadata_reference_id' => 6303], $this->DB), Metadata_Reference::getOneFromDb(['metadata_reference_id' => 6306], $this->DB)];
     $canonical = '';
     $canonical .= '<div class="metadata-references edit-metadata-references">' . "\n";
     $canonical .= '  <ul class="metadata-references metadata-references-images edit-metadata-references-images">' . "\n";
     $canonical .= '    <li>' . $ref_list[1]->renderAsEditEmbed() . '</li>' . "\n";
     $canonical .= '    <li>' . $ref_list[3]->renderAsEditEmbed() . '</li>' . "\n";
     $canonical .= '  </ul>' . "\n";
     $canonical .= '  <ul class="metadata-references metadata-references-links edit-metadata-references-links">' . "\n";
     $canonical .= '    <li>' . $ref_list[2]->renderAsEditEmbed() . '</li>' . "\n";
     $canonical .= '    <li>' . $ref_list[4]->renderAsEditEmbed() . '</li>' . "\n";
     $canonical .= '  </ul>' . "\n";
     $canonical .= '  <ul class="metadata-references metadata-references-texts edit-metadata-references-texts">' . "\n";
     $canonical .= '    <li>' . $ref_list[0]->renderAsEditEmbed() . '</li>' . "\n";
     $canonical .= '  </ul>' . "\n";
     $canonical .= '</div>' . "\n";
     $rendered = Metadata_Reference::renderReferencesArrayAsListsEdit($ref_list);
     //            echo "<pre>\n".htmlentities($canonical)."\n-----\n".htmlentities($rendered)."\n</pre>";
     $this->assertEqual($canonical, $rendered);
     $this->assertNoPattern('/IMPLEMENTED/', $rendered);
 }
 public function renderAsReferencesListEdit()
 {
     $rendered = '';
     $this->cacheReferences();
     $rendered .= '<div class="metadata-references">';
     $rendered .= Metadata_Reference::renderReferencesArrayAsListsEdit($this->references);
     //            if (count($this->references) > 0) {
     //                $rendered .= '<ul class="metadata-references">'."\n";
     //                $rendered .= '<li><a href="#" id="add_new_metadata_reference_button-for_metadata_term_value_'.$this->metadata_term_value_id.'" class="btn" data-for_metadata_term_value="'.$this->metadata_term_value_id.'">'.util_lang('add_metadata_reference').'</a></li>'."\n";
     //                foreach ($this->references as $r) {
     //                    $rendered .= '<li>'.$r->renderAsEditEmbed().'</li>'."\n";
     //                }
     //                $rendered .= '</ul>'."\n";
     //            }
     $rendered .= '</div>';
     return $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;
   }
 public function renderAsEdit_references()
 {
     $this->cacheTermValues();
     $rendered = Metadata_Reference::renderReferencesArrayAsListsEdit($this->references);
     return $rendered;
 }