public static function renderFormInteriorForNewMetadataTermValue($unique_str) { $rendered = ''; $rendered .= '<div class="new-metadata-term-value edit-metadata-term-value">'; $rendered .= ' <div class="edit-metadata-term-value-name">'; $rendered .= '<input type="text" name="metadata-term-value-name-' . $unique_str . '" value="' . htmlentities(util_lang('new_metadata_term_value_name')) . '"/>'; $rendered .= '</div>' . "\n"; $rendered .= ' <div class="edit-metadata-term-value-description">'; $rendered .= '<input type="text" name="metadata-term-value-description-' . $unique_str . '" value="' . htmlentities(util_lang('new_metadata_term_value_description')) . '"/>'; $rendered .= '</div>' . "\n"; $rendered .= '</div>'; return $rendered; }
function testGetValuesAsOptions() { $this->doLoginBasic(); global $DB; $DB = $this->DB; $this->get('http://localhost/digitalfieldnotebooks/ajax_actions/metadata_structure.php?action=value_options&metadata_structure_id=6002'); $this->checkBasicAsserts(); $mdts = Metadata_Term_Set::getOneFromDb(['metadata_term_set_id' => 6101], $DB); $expected = ' <option value="-1">' . util_lang('prompt_select') . '</option>' . "\n" . $mdts->renderValuesAsOptions(); $this->assertNoPattern('/error/i'); $results = json_decode($this->getBrowser()->getContent()); $this->assertEqual('success', $results->status); $this->assertEqual($expected, $results->html_output); }
function testIndexPageLoadsCorrectText() { $this->get('http://localhost/digitalfieldnotebooks/'); $this->assertTitle(new PatternExpectation('/' . LANG_APP_NAME . ': /')); $this->assertNoPattern('/' . util_lang('app_signed_in_status') . ': \\<a[^\\>]*\\>' . TESTINGUSER . '\\<\\/a\\>/'); $this->assertPattern('/' . util_lang('app_sign_in_action') . '/'); $this->assertPattern('/' . util_lang('app_short_description') . '/'); $this->assertPattern('/' . util_lang('app_sign_in_msg') . '/'); // check for published, verfied notebooks that are publically viewable // $this->assertText(ucfirst(util_lang('public')).' '.ucfirst(util_lang('notebooks'))); // $this->assertEltByIdHasAttrOfValue('list-of-user-notebooks','data-notebook-count','1'); // $this->assertEltByIdHasAttrOfValue('notebook-item-1','data-notebook_id','1004'); // $this->assertLink('testnotebook4'); }
public function renderAsListItemEdit($idstr = '', $classes_array = [], $other_attribs_hash = []) { // return 'TO BE IMPLEMENTED'; // global $USER; if (!$idstr) { $idstr = 'specimen-image-' . $this->specimen_image_id; } array_unshift($classes_array, 'specimen-image'); $li_elt = substr(util_listItemTag($idstr, $classes_array, $other_attribs_hash), 0, -1); $li_elt .= ' ' . $this->fieldsAsDataAttribs() . '>'; $li_elt .= '<button type="button" class="btn btn-danger button-delete-specimen-image" title="' . util_lang('prompt_confirm_delete', 'ucfirst') . '" data-specimen_image_id="' . $this->specimen_image_id . '" data-dom_id="' . $idstr . '"><i class="icon-remove icon-white"></i></button><br/>'; $li_elt .= $this->renderAsHtml(); $li_elt .= '<div class="controls">'; // publish, verify, reordering handle $li_elt .= util_orderingLeftRightControls($idstr); $li_elt .= '<input type="hidden" name="new_ordering-' . $idstr . '" id="new_ordering-' . $idstr . '" value="' . $this->ordering . '"/>'; if ($this->specimen_image_id != 'NEW') { $li_elt .= '<div class="control-workflows">'; if ($USER->canActOnTarget('publish', $this)) { $li_elt .= '<span class="control-publish"><input id="flag_workflow_published_' . $this->specimen_image_id . '-control" type="checkbox" name="flag_workflow_published" value="1"' . ($this->flag_workflow_published ? ' checked="checked"' : '') . ' /> ' . util_lang('publish') . '</span>, '; } else { $li_elt .= '<span class="control-publish">' . ($this->flag_workflow_published ? util_lang('published_true') : util_lang('published_false')) . '</span>, '; } if ($USER->canActOnTarget('verify', $this)) { $li_elt .= '<span class="control-verify"><input id="flag_workflow_validated_' . $this->specimen_image_id . '-control" type="checkbox" name="flag_workflow_validated" value="1"' . ($this->flag_workflow_validated ? ' checked="checked"' : '') . ' /> ' . util_lang('verify') . '</span>'; } else { $li_elt .= '<span class="control-verify">' . ($this->flag_workflow_validated ? util_lang('verified_true') : util_lang('verified_false')) . '</span>'; } $li_elt .= '</div>'; } // $li_elt .= '<span class="ordering-handle">< ></span>'; $li_elt .= '</div>'; $li_elt .= '</li>'; return $li_elt; }
function testBaseDataUpdate_NEW() { $this->doLoginAdmin(); $this->get('http://localhost/digitalfieldnotebooks/app_code/metadata_structure.php?action=create&parent_metadata_structure_id=6001'); $this->checkBasicAsserts(); $this->setField('name', 'brand new metadata structure'); $this->click('<i class="icon-ok-sign icon-white"></i> ' . util_lang('save', 'properize')); $this->checkBasicAsserts(); $this->assertText('brand new metadata structure'); $mds = Metadata_Structure::getOneFromDb(['name' => 'brand new metadata structure'], $this->DB); $this->assertTrue($mds->matchesDb); }
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> ></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 renderAsEditEmbed() { $this->cacheImages(); global $USER; $rendered = '<div class="specimen embedded">' . "\n" . '<button class="btn btn-danger button-mark-specimen-for-delete" title="' . util_lang('mark_for_delete', 'ucfirst') . '" data-do-mark-title="' . util_lang('mark_for_delete', 'ucfirst') . '" data-remove-mark-title="' . util_lang('unmark_for_delete', 'ucfirst') . '" data-for_dom_id="list_item-specimen_' . $this->specimen_id . '" data-specimen_id="' . $this->specimen_id . '"><i class="icon-remove-sign icon-white"></i></button>' . "\n" . '<div id="form-edit-specimen-' . $this->specimen_id . '" class="form-edit-specimen" data-specimen_id="' . $this->specimen_id . '">' . "\n" . ' <h3><input type="text" name="specimen-name_' . $this->specimen_id . '" id="specimen-name_' . $this->specimen_id . '" value="' . htmlentities($this->name) . '"/>' . "</h3>\n"; $rendered .= ' <div class="control-workflows">'; if ($this->specimen_id != 'NEW') { if ($USER->canActOnTarget('publish', $this)) { $rendered .= ' <span class="published_state workflow-control"><input id="specimen-workflow-publish-control_' . $this->specimen_id . '" type="checkbox" name="specimen-flag_workflow_published_' . $this->specimen_id . '" value="1"' . ($this->flag_workflow_published ? ' checked="checked"' : '') . ' /> ' . util_lang('publish') . '</span>,'; } else { $rendered .= ' <span class="published_state workflow-info">' . ($this->flag_workflow_published ? util_lang('published_true') : util_lang('published_false')) . '</span>,'; } if ($USER->canActOnTarget('verify', $this)) { $rendered .= ' <span class="verified_state verified_state_' . ($this->flag_workflow_validated ? 'true' : 'false') . ' workflow-control"><input id="specimen-workflow-validate-control_' . $this->specimen_id . '" type="checkbox" name="specimen-flag_workflow_validated_' . $this->specimen_id . '" value="1"' . ($this->flag_workflow_validated ? ' checked="checked"' : '') . ' /> ' . util_lang('verify') . '</span>'; } else { $rendered .= ' <span class="verified_state verified_state_' . ($this->flag_workflow_validated ? 'true' : 'false') . ' workflow-info">' . ($this->flag_workflow_validated ? util_lang('verified_true') : util_lang('verified_false')) . '</span>'; } } $rendered .= "</div>\n"; $rendered .= ' <ul class="base-info">' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('coordinates') . '</div> : <div class="field-value"><input type="text" name="specimen-gps_longitude_' . $this->specimen_id . '" id="specimen-gps_longitude_' . $this->specimen_id . '" value="' . $this->gps_longitude . '"/>, <input type="text" name="specimen-gps_latitude_' . $this->specimen_id . '" id="specimen-gps_latitude_' . $this->specimen_id . '" value="' . $this->gps_latitude . '"/></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('notes') . '</div> : <div class="field-value"><textarea name="specimen-notes_' . $this->specimen_id . '" id="specimen-notes_' . $this->specimen_id . '" class="specimen-notes" row="4" cols="120">' . htmlentities($this->notes) . '</textarea></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('catalog_identifier') . '</div> : <div class="field-value"><input type="text" name="specimen-catalog_identifier_' . $this->specimen_id . '" id="specimen-catalog_identifier_' . $this->specimen_id . '" value="' . htmlentities($this->catalog_identifier) . '"/></div></li>' . "\n"; $rendered .= ' </ul>' . "\n"; $rendered .= ' <button type="button" class="specimen-save-image-ordering-button btn-success" id="save-specimen-image-ordering-for-' . $this->specimen_id . '" data-for-specimen-id="' . $this->specimen_id . '">' . util_lang('save_ordering', 'ucfirst') . '</button>' . "\n"; $rendered .= ' <ul class="specimen-images inline">' . "\n"; $rendered .= ' <li class="specimen-image-upload-section"><a href="#" id="specimen-control-add-image-for-' . $this->specimen_id . '" class="btn add-specimen-image-button" data-for-specimen="' . $this->specimen_id . '">' . util_lang('add_specimen_image') . '</a>' . "\n"; $rendered .= '<div id="specimen-image-upload-form-for-' . $this->specimen_id . '" class="specimen-image-upload-form">' . "\n"; $rendered .= '<input name="image_file" id="specimen-image-file-for-' . $this->specimen_id . '" class="specimen-image-file-picker" type="file" />' . "\n"; $rendered .= '<label class="specimen-image-file-input-label" id="specimen-image-file-for-' . $this->specimen_id . '-label" for="specimen-image-file-for-' . $this->specimen_id . '">' . util_lang('prompt_choose_file', 'properize') . '</label>' . "\n"; $rendered .= '<input type="button" class="specimen-image-upload-do-it-button" id="specimen-image-upload-submit-for-' . $this->specimen_id . '" value="' . util_lang('upload', 'properize') . '" data-for-specimen="' . $this->specimen_id . '"/>' . "\n"; $rendered .= '<input type="button" class="specimen-image-upload-cancel-button" value="' . util_lang('cancel', 'properize') . '" data-for-specimen="' . $this->specimen_id . '"/>' . "\n"; $rendered .= '<img src="' . APP_ROOT_PATH . '/img/ajax-loader.gif" id="loading-img" style="display:none;" alt="Please Wait"/>' . "\n"; $rendered .= '</div>' . "\n"; $rendered .= '</li>' . "\n"; if (count($this->images) > 0) { foreach ($this->images as $image) { $rendered .= ' ' . $image->renderAsListItemEdit() . "\n"; } } $rendered .= ' </ul>' . "\n"; $rendered .= "</div>\n</div>"; return $rendered; }
function renderAsEdit() { $this->cacheExtras(); $this->cacheNotebookPages(); $this->cacheSpecimens(); $rendered = '<div id="rendered_authoritative_plant_' . $this->authoritative_plant_id . '" class="authoritative-plant edit-authoritative-plant" ' . $this->fieldsAsDataAttribs() . ' data-can-edit="1">' . "\n"; $rendered .= ' <form id="form-edit-authoritative-plant" action="' . APP_ROOT_PATH . '/app_code/authoritative_plant.php">' . "\n"; $rendered .= ' <input type="hidden" name="action" value="update"/>' . "\n"; $rendered .= ' <input type="hidden" id="authoritative_plant_id" name="authoritative_plant_id" value="' . $this->authoritative_plant_id . '"/>' . "\n"; $rendered .= ' <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> ' . util_lang('update', 'properize') . '</button>' . "\n"; $rendered .= ' <a id="edit-cancel-control" class="btn" href="/digitalfieldnotebooks/app_code/authoritative_plant.php?action=view&authoritative_plant_id=' . $this->authoritative_plant_id . '"><i class="icon-remove"></i> ' . util_lang('cancel', 'properize') . '</a> '; if ($this->authoritative_plant_id != 'NEW') { $rendered .= '<a id="edit-delete-authoritative-plant-control" class="btn btn-danger" href="/digitalfieldnotebooks/app_code/authoritative_plant.php?action=delete&authoritative_plant_id=' . $this->authoritative_plant_id . '"><i class="icon-trash icon-white"></i> ' . util_lang('delete', 'properize') . '</a>'; } $rendered .= '</div>' . "\n"; // basic data fields $rendered .= ' <ul class="base-info">' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('class') . '</div> : <div class="field-value taxonomy taxonomy-class"><input type="text" name="authoritative_plant-class_' . $this->authoritative_plant_id . '" id="authoritative_plant-class_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->class) . '"/></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('order') . '</div> : <div class="field-value taxonomy taxonomy-order"><input type="text" name="authoritative_plant-order_' . $this->authoritative_plant_id . '" id="authoritative_plant-order_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->order) . '"/></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('family') . '</div> : <div class="field-value taxonomy taxonomy-family"><input type="text" name="authoritative_plant-family_' . $this->authoritative_plant_id . '" id="authoritative_plant-family_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->family) . '"/></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('genus') . '</div> : <div class="field-value taxonomy taxonomy-genus"><input type="text" name="authoritative_plant-genus_' . $this->authoritative_plant_id . '" id="authoritative_plant-genus_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->genus) . '"/></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('species') . '</div> : <div class="field-value taxonomy taxonomy-species"><input type="text" name="authoritative_plant-species_' . $this->authoritative_plant_id . '" id="authoritative_plant-species_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->species) . '"/></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('variety') . '</div> : <div class="field-value taxonomy taxonomy-variety"><input type="text" name="authoritative_plant-variety_' . $this->authoritative_plant_id . '" id="authoritative_plant-variety_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->variety) . '"/></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('catalog_identifier') . '</div> : <div class="field-value" taxonomy taxonomy-catalog_identifier><input type="text" name="authoritative_plant-catalog_identifier_' . $this->authoritative_plant_id . '" id="authoritative_plant-catalog_identifier_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->catalog_identifier) . '"/></div></li>' . "\n"; $rendered .= ' </ul>' . "\n"; // flag active control $rendered .= ' <div class="active-state-controls"><input type="checkbox" name="flag_active" value="1"' . ($this->flag_active ? ' checked="checked"' : '') . '/> ' . util_lang('active') . '</div>' . "\n"; // extra info : common names (w/ reordering controls) if ($this->authoritative_plant_id != 'NEW') { $rendered .= ' <h5>' . util_lang('common_names', 'properize') . '</h5>' . "\n"; $rendered .= ' <ul class="authoritative-plant-extras authoritative-plant-extra-common_name">' . "\n"; $rendered .= ' <li><a href="#" id="add_new_authoritative_plant_common_name_button" class="btn">' . util_lang('add_common_name') . '</a></li>' . "\n"; foreach ($this->extras as $ae) { if ($ae->type == 'common name') { $rendered .= ' ' . $ae->renderAsListItemEdit() . "\n"; } } $rendered .= ' </ul>' . "\n"; // extra info : images (w/ reordering controls) $rendered .= ' <h5>' . util_lang('images', 'properize') . '</h5>' . "\n"; $rendered .= ' <ul class="authoritative-plant-extras authoritative-plant-extra-image">' . "\n"; $rendered .= ' <li><a href="#" id="add_new_authoritative_plant_image_button" class="btn">' . util_lang('add_image') . '</a></li>' . "\n"; foreach ($this->extras as $ae) { if ($ae->type == 'image') { $rendered .= ' ' . $ae->renderAsListItemEdit() . "\n"; } } $rendered .= ' </ul>' . "\n"; // extra info : text (w/ reordering controls) $rendered .= ' <h5>' . util_lang('descriptions', 'properize') . '</h5>' . "\n"; $rendered .= ' <ul class="authoritative-plant-extras authoritative-plant-extra-description">' . "\n"; $rendered .= ' <li><a href="#" id="add_new_authoritative_plant_description_button" class="btn">' . util_lang('add_description') . '</a></li>' . "\n"; foreach ($this->extras as $ae) { if ($ae->type == 'description') { $rendered .= ' ' . $ae->renderAsListItemEdit() . "\n"; } } $rendered .= ' </ul>' . "\n"; $rendered .= ' <input type="hidden" id="created_authoritative_plant_extra_ids" name="created_authoritative_plant_extra_ids" value=""/>' . "\n"; $rendered .= ' <input type="hidden" id="deleted_authoritative_plant_extra_ids" name="deleted_authoritative_plant_extra_ids" value=""/>' . "\n"; $rendered .= ' <input type="hidden" id="deleted_specimen_ids" name="deleted_specimen_ids" value=""/>' . "\n"; $rendered .= ' <input type="hidden" id="created_specimen_ids" name="created_specimen_ids" value=""/>' . "\n"; $rendered .= Specimen::renderSpecimenListBlock($this->specimens); } $rendered .= ' </form>' . "\n"; $rendered .= '</div>' . "\n"; return $rendered; }
public function renderAsListItemEdit($idstr = '', $classes_array = [], $other_attribs_hash = []) { if (!$idstr) { $idstr = 'list_item-notebook_page_field_' . $this->notebook_page_field_id; } $li_elt = substr(util_listItemTag($idstr, $classes_array, $other_attribs_hash), 0, -1); $li_elt .= ' ' . $this->fieldsAsDataAttribs() . '>'; $mds = $this->getMetadataStructure(); $mds->loadTermSetAndValues(); // util_prePrintR($mds); // $li_elt .= '<div class="notebook-page-field-label field-label" title="'.htmlentities($mds->description).'">'.htmlentities($mds->name).'</div> : <div class="notebook-page-field-value field-value">'; $li_elt .= '<div class="notebook-page-field-label field-label" title="' . htmlentities($mds->description) . '">' . $mds->renderAsFullName() . '</div> : <div class="notebook-page-field-value field-value">'; if ($mds->term_set) { $li_elt .= $mds->term_set->renderAsSelectControl('page_field_select_' . $this->notebook_page_field_id, $this->value_metadata_term_value_id); } else { $li_elt .= util_lang('metadata_structure_has_no_term_set'); } $li_elt .= '; <input type="text" name="page_field_open_value_' . $this->notebook_page_field_id . '" id="page_field_open_value_' . $this->notebook_page_field_id . '" class="page_field_open_value" value="' . htmlentities($this->value_open) . '"/>'; $li_elt .= '</div> <button class="btn btn-danger button-mark-pagefield-for-delete" title="' . util_lang('mark_for_delete', 'ucfirst') . '" data-do-mark-title="' . util_lang('mark_for_delete', 'ucfirst') . '" data-remove-mark-title="' . util_lang('unmark_for_delete', 'ucfirst') . '" data-for_dom_id="' . $idstr . '" data-notebook_page_field_id="' . $this->notebook_page_field_id . '"><i class="icon-remove-sign icon-white"></i></button></li>'; return $li_elt; }
function testNewNotebookPage() { $n = Notebook::getOneFromDb(['notebook_id' => 1001], $this->DB); $this->doLoginBasic(); $this->get('http://localhost/digitalfieldnotebooks/app_code/notebook.php?action=edit¬ebook_id=1001'); $this->checkBasicAsserts(); $this->click(util_lang('add_notebook_page')); $this->checkBasicAsserts(); $this->assertEltByIdHasAttrOfValue('form-edit-notebook-page-base-data', 'action', APP_ROOT_PATH . '/app_code/notebook_page.php'); // $this->showContent(); }
function testRenderAsEdit() { $ap = Authoritative_Plant::getOneFromDb(['authoritative_plant_id' => 5001], $this->DB); $ap->cacheExtras(); $ap->cacheNotebookPages(); $ap->cacheSpecimens(); global $USER; $USER = User::getOneFromDb(['username' => TESTINGUSER], $this->DB); $canonical = '<div id="rendered_authoritative_plant_5001" class="authoritative-plant edit-authoritative-plant" ' . $ap->fieldsAsDataAttribs() . ' data-can-edit="1">' . "\n"; $canonical .= ' <form id="form-edit-authoritative-plant" action="' . APP_ROOT_PATH . '/app_code/authoritative_plant.php">' . "\n"; $canonical .= ' <input type="hidden" name="action" value="update"/>' . "\n"; $canonical .= ' <input type="hidden" id="authoritative_plant_id" name="authoritative_plant_id" value="' . $ap->authoritative_plant_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/authoritative_plant.php?action=view&authoritative_plant_id=5001"><i class="icon-remove"></i> Cancel</a> <a id="edit-delete-authoritative-plant-control" class="btn btn-danger" href="/digitalfieldnotebooks/app_code/authoritative_plant.php?action=delete&authoritative_plant_id=5001"><i class="icon-trash icon-white"></i> Delete</a></div>' . "\n"; // basic data fields $canonical .= ' <ul class="base-info">' . "\n"; $canonical .= ' <li><div class="field-label">' . util_lang('class') . '</div> : <div class="field-value taxonomy taxonomy-class"><input type="text" name="authoritative_plant-class_' . $ap->authoritative_plant_id . '" id="authoritative_plant-class_' . $ap->authoritative_plant_id . '" value="' . htmlentities($ap->class) . '"/></div></li>' . "\n"; $canonical .= ' <li><div class="field-label">' . util_lang('order') . '</div> : <div class="field-value taxonomy taxonomy-order"><input type="text" name="authoritative_plant-order_' . $ap->authoritative_plant_id . '" id="authoritative_plant-order_' . $ap->authoritative_plant_id . '" value="' . htmlentities($ap->order) . '"/></div></li>' . "\n"; $canonical .= ' <li><div class="field-label">' . util_lang('family') . '</div> : <div class="field-value taxonomy taxonomy-family"><input type="text" name="authoritative_plant-family_' . $ap->authoritative_plant_id . '" id="authoritative_plant-family_' . $ap->authoritative_plant_id . '" value="' . htmlentities($ap->family) . '"/></div></li>' . "\n"; $canonical .= ' <li><div class="field-label">' . util_lang('genus') . '</div> : <div class="field-value taxonomy taxonomy-genus"><input type="text" name="authoritative_plant-genus_' . $ap->authoritative_plant_id . '" id="authoritative_plant-genus_' . $ap->authoritative_plant_id . '" value="' . htmlentities($ap->genus) . '"/></div></li>' . "\n"; $canonical .= ' <li><div class="field-label">' . util_lang('species') . '</div> : <div class="field-value taxonomy taxonomy-species"><input type="text" name="authoritative_plant-species_' . $ap->authoritative_plant_id . '" id="authoritative_plant-species_' . $ap->authoritative_plant_id . '" value="' . htmlentities($ap->species) . '"/></div></li>' . "\n"; $canonical .= ' <li><div class="field-label">' . util_lang('variety') . '</div> : <div class="field-value taxonomy taxonomy-variety"><input type="text" name="authoritative_plant-variety_' . $ap->authoritative_plant_id . '" id="authoritative_plant-variety_' . $ap->authoritative_plant_id . '" value="' . htmlentities($ap->variety) . '"/></div></li>' . "\n"; $canonical .= ' <li><div class="field-label">' . util_lang('catalog_identifier') . '</div> : <div class="field-value" taxonomy taxonomy-catalog_identifier><input type="text" name="authoritative_plant-catalog_identifier_' . $ap->authoritative_plant_id . '" id="authoritative_plant-catalog_identifier_' . $ap->authoritative_plant_id . '" value="' . htmlentities($ap->catalog_identifier) . '"/></div></li>' . "\n"; $canonical .= ' </ul>' . "\n"; // flag active control $canonical .= ' <div class="active-state-controls"><input type="checkbox" name="flag_active" value="1"' . ($ap->flag_active ? ' checked="checked"' : '') . '/> ' . util_lang('active') . '</div>' . "\n"; // extra info : common names (w/ reordering controls) $canonical .= ' <h5>' . util_lang('common_names', 'properize') . '</h5>' . "\n"; $canonical .= ' <ul class="authoritative-plant-extras authoritative-plant-extra-common_name">' . "\n"; $canonical .= ' <li><a href="#" id="add_new_authoritative_plant_common_name_button" class="btn">' . util_lang('add_common_name') . '</a></li>' . "\n"; foreach ($ap->extras as $ae) { if ($ae->type == 'common name') { $canonical .= ' ' . $ae->renderAsListItemEdit() . "\n"; } } $canonical .= ' </ul>' . "\n"; // extra info : images (w/ reordering controls) $canonical .= ' <h5>' . util_lang('images', 'properize') . '</h5>' . "\n"; $canonical .= ' <ul class="authoritative-plant-extras authoritative-plant-extra-image">' . "\n"; $canonical .= ' <li><a href="#" id="add_new_authoritative_plant_image_button" class="btn">' . util_lang('add_image') . '</a></li>' . "\n"; foreach ($ap->extras as $ae) { if ($ae->type == 'image') { $canonical .= ' ' . $ae->renderAsListItemEdit() . "\n"; } } $canonical .= ' </ul>' . "\n"; // extra info : text (w/ reordering controls) $canonical .= ' <h5>' . util_lang('descriptions', 'properize') . '</h5>' . "\n"; $canonical .= ' <ul class="authoritative-plant-extras authoritative-plant-extra-description">' . "\n"; $canonical .= ' <li><a href="#" id="add_new_authoritative_plant_description_button" class="btn">' . util_lang('add_description') . '</a></li>' . "\n"; foreach ($ap->extras as $ae) { if ($ae->type == 'description') { $canonical .= ' ' . $ae->renderAsListItemEdit() . "\n"; } } $canonical .= ' </ul>' . "\n"; // specimens, as per notebook page rendering $canonical .= ' <input type="hidden" id="created_authoritative_plant_extra_ids" name="created_authoritative_plant_extra_ids" value=""/>' . "\n"; $canonical .= ' <input type="hidden" id="deleted_authoritative_plant_extra_ids" name="deleted_authoritative_plant_extra_ids" value=""/>' . "\n"; $canonical .= ' <input type="hidden" id="deleted_specimen_ids" name="deleted_specimen_ids" value=""/>' . "\n"; $canonical .= ' <input type="hidden" id="created_specimen_ids" name="created_specimen_ids" value=""/>' . "\n"; $canonical .= Specimen::renderSpecimenListBlock($ap->specimens); // // ' <h4>'.ucfirst(util_lang('specimens'))."</h4>\n". // ' <ul class="specimens">'."\n"; // $canonical .= ' <li><a href="#" id="add_new_specimen_button" class="btn">'.util_lang('add_specimen').'</a></li>'."\n"; // if ($ap->specimens) { // foreach ($ap->specimens as $specimen) { // $canonical .= ' <li id="list_item-specimen_'.$specimen->specimen_id.'">'.$specimen->renderAsEditEmbed()."</li>\n"; // } // } else { // $canonical .= '<li>'.util_lang('no_metadata','ucfirst').'</li>'."\n"; // } // $canonical .= " </ul>\n"; // close form and div $canonical .= ' </form>' . "\n"; $canonical .= '</div>' . "\n"; $rendered = $ap->renderAsEdit(); // echo "<pre>\n".htmlentities($canonical)."\n------------------\n".htmlentities($rendered)."\n</pre>"; $this->assertEqual($canonical, $rendered); }
public function renderAsEdit() { $this->loadPageFields(); $this->loadSpecimens(); $n = $this->getNotebook(); $ap = ''; if ($this->notebook_page_id != 'NEW') { $ap = $this->getAuthoritativePlant(); } // util_prePrintR('TO BE IMPLEMENTED: handle auth plant for new pages (i.e. where auth plant id == 0)'); // util_prePrintR($this); global $USER, $ACTIONS; $actions_attribs = ''; // $add_field_button_li = ''; if ($USER->canActOnTarget($ACTIONS['edit'], $this)) { $actions_attribs .= ' data-can-edit="1"'; // $add_field_button_li = ' <li><a href="" id="btn-add-notebook-page-field" class="creation_link btn">'.util_lang('add_notebook_page_field').'</a></li>'."\n"; } $owner = $USER; if ($n->user_id != $USER->user_id) { $owner = $n->getUser(); } $rendered = '<div id="rendered_notebook_page_' . $this->notebook_page_id . '" class="rendered_notebook_page edit_rendered_notebook_page" ' . $this->fieldsAsDataAttribs() . $actions_attribs . ">\n" . '<form id="form-edit-notebook-page-base-data" action="' . APP_ROOT_PATH . '/app_code/notebook_page.php">' . "\n" . ' <input type="hidden" name="action" value="update"/>' . "\n" . ' <input type="hidden" id="notebook_page_id" name="notebook_page_id" value="' . $this->notebook_page_id . '"/>' . "\n" . ' <input type="hidden" id="notebook_id" name="notebook_id" value="' . $this->notebook_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->notebook_page_id != 'NEW' ? 'update' : 'save', 'properize') . '</button>' . "\n"; if ($this->notebook_page_id != 'NEW') { $rendered .= ' <a id="edit-cancel-control" class="btn" href="' . APP_ROOT_PATH . '/app_code/notebook_page.php?action=view¬ebook_page_id=' . $this->notebook_page_id . '"><i class="icon-remove"></i> ' . util_lang('cancel', 'properize') . '</a>'; $rendered .= ' <a id="edit-delete-notebook-page-control" class="btn btn-danger" href="' . APP_ROOT_PATH . '/app_code/notebook_page.php?action=delete¬ebook_page_id=' . $this->notebook_page_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/notebook.php?action=edit¬ebook_id=' . $this->notebook_id . '"><i class="icon-remove"></i> ' . util_lang('cancel', 'properize') . '</a>'; } $rendered .= '</div>' . "\n"; $rendered .= '<h4>' . util_lang('page_in_notebook', 'ucfirst') . ' <a href="' . APP_ROOT_PATH . '/app_code/notebook.php?action=view¬ebook_id=' . $n->notebook_id . '" id="parent-notebook-link">' . htmlentities($n->name) . '</a></h4>' . "\n"; if ($this->notebook_page_id != 'NEW') { $rendered .= '<a class="show-hide-control" href="#" data-for_elt_id="select_new_authoritative_plant_' . $this->notebook_page_id . '">' . util_lang('change_authoritative_plant') . '</a>'; $rendered .= ' <div id="select_new_authoritative_plant_' . $this->notebook_page_id . '" class="select_new_authoritative_plant">' . Authoritative_Plant::renderControlSelectAllAuthoritativePlants($this->notebook_page_id != 'NEW' ? $ap->authoritative_plant_id : 0) . '</div>' . "\n"; $rendered .= ' ' . $ap->renderAsViewEmbed() . "\n"; } else { $rendered .= ' <div id="select_new_authoritative_plant_' . $this->notebook_page_id . '" class="NEW_select_new_authoritative_plant">' . Authoritative_Plant::renderControlSelectAllAuthoritativePlants(0) . '</div>' . "\n"; } $rendered .= ' <div class="info-timestamps"><span class="created_at">' . util_lang('created_at') . ' ' . util_datetimeFormatted($this->created_at) . '</span>, <span class="updated_at">' . util_lang('updated_at') . ' ' . util_datetimeFormatted($this->updated_at) . "</span></div>\n" . ' <div class="info-owner">' . util_lang('owned_by') . ' <a href="' . APP_ROOT_PATH . '/app_code/user.php?action=view&user_id=' . $owner->user_id . '">' . htmlentities($owner->screen_name) . '</a></div>' . "\n"; $rendered .= '<div class="control-workflows">'; if ($this->notebook_page_id != 'NEW') { if ($USER->canActOnTarget('publish', $this)) { $rendered .= ' <span class="published_state workflow-control"><input id="notebook-page-workflow-publish-control" type="checkbox" name="flag_workflow_published" value="1"' . ($this->flag_workflow_published ? ' checked="checked"' : '') . ' /> ' . util_lang('publish') . '</span>,'; } else { $rendered .= ' <span class="published_state workflow-info">' . ($this->flag_workflow_published ? util_lang('published_true') : util_lang('published_false')) . '</span>,'; } if ($USER->canActOnTarget('verify', $this)) { $rendered .= ' <span class="verified_state verified_state_' . ($this->flag_workflow_validated ? 'true' : 'false') . ' workflow-control"><input id="notebook-page-workflow-validate-control" type="checkbox" name="flag_workflow_validated" value="1"' . ($this->flag_workflow_validated ? ' checked="checked"' : '') . ' /> ' . util_lang('verify') . '</span>'; } else { $rendered .= ' <span class="verified_state verified_state_' . ($this->flag_workflow_validated ? 'true' : 'false') . ' workflow-info">' . ($this->flag_workflow_validated ? util_lang('verified_true') : util_lang('verified_false')) . '</span>'; } $rendered .= '<br/>' . "\n"; } else { $rendered .= ' <span class="published_state workflow-info">' . ($this->flag_workflow_published ? util_lang('published_true') : util_lang('published_false')) . '</span>,'; $rendered .= ' <span class="verified_state verified_state_' . ($this->flag_workflow_validated ? 'true' : 'false') . ' workflow-info">' . ($this->flag_workflow_validated ? util_lang('verified_true') : util_lang('verified_false')) . '</span>'; } $rendered .= "</div>\n"; $rendered .= ' <div class="notebook_page_notes"><textarea id="notebook-page-notes" name="notes" rows="4" cols="120">' . htmlentities($this->notes) . '</textarea></div>' . "\n"; if ($this->notebook_page_id != 'NEW') { $rendered .= ' <h4>' . ucfirst(util_lang('metadata')) . "</h4>\n"; $rendered .= ' <ul class="notebook-page-fields">' . "\n"; $rendered .= ' <li><a href="#" id="add_new_notebook_page_field_button" class="btn">' . util_lang('add_notebook_page_field') . '</a></li>' . "\n"; if ($this->page_fields) { $prev_pf_structure_id = $this->page_fields[0]->label_metadata_structure_id; foreach ($this->page_fields as $pf) { $spacer_class = ''; if ($pf->label_metadata_structure_id != $prev_pf_structure_id) { $spacer_class = 'spacing-list-item'; } $rendered .= ' ' . $pf->renderAsListItemEdit('list_item-notebook_page_field_' . $pf->notebook_page_field_id, [$spacer_class]) . "\n"; $prev_pf_structure_id = $pf->label_metadata_structure_id; } } else { $rendered .= '<li>' . util_lang('no_metadata', 'ucfirst') . '</li>' . "\n"; } $rendered .= ' </ul>' . "\n"; $rendered .= Specimen::renderSpecimenListBlock($this->specimens); // $rendered .= ' <h4>'.ucfirst(util_lang('specimens'))."</h4>\n". // ' <ul class="specimens">'."\n"; // $rendered .= ' <li><a href="#" id="add_new_specimen_button" class="btn">'.util_lang('add_specimen').'</a></li>'."\n"; // if ($this->specimens) { // foreach ($this->specimens as $specimen) { // $rendered .= ' <li id="list_item-specimen_'.$specimen->specimen_id.'">'.$specimen->renderAsEditEmbed()."</li>\n"; // } // } else { // $rendered .= '<li>'.util_lang('no_metadata','ucfirst').'</li>'."\n"; // } // $rendered .= " </ul>\n"; $rendered .= '<input type="hidden" id="initial_page_field_ids" name="initial_page_field_ids" value="' . implode(',', Db_Linked::arrayOfAttrValues($this->page_fields, 'notebook_page_field_id')) . '"/>' . "\n"; $rendered .= '<input type="hidden" id="created_page_field_ids" name="created_page_field_ids" value=""/>' . "\n"; $rendered .= '<input type="hidden" id="deleted_page_field_ids" name="deleted_page_field_ids" value=""/>' . "\n"; $rendered .= '<input type="hidden" id="initial_specimen_ids" name="initial_specimen_ids" value="' . implode(',', Db_Linked::arrayOfAttrValues($this->specimens, 'specimen_id')) . '"/>' . "\n"; $rendered .= '<input type="hidden" id="created_specimen_ids" name="created_specimen_ids" value=""/>' . "\n"; $rendered .= '<input type="hidden" id="deleted_specimen_ids" name="deleted_specimen_ids" value=""/>' . "\n"; } $rendered .= '</form>' . "\n"; $rendered .= "</div>"; return $rendered; }
function testRenderAsListItemEdit_noTermSet() { $npf = Notebook_Page_Field::getOneFromDb(['notebook_page_field_id' => 1204], $this->DB); $mds = Metadata_Structure::getOneFromDb(['metadata_structure_id' => 6004], $this->DB); global $USER; $USER = User::getOneFromDb(['username' => TESTINGUSER], $this->DB); $canonical = '<li id="list_item-notebook_page_field_1204" data-notebook_page_field_id="1204" data-created_at="' . $npf->created_at . '" data-updated_at="' . $npf->updated_at . '" data-notebook_page_id="1101" data-label_metadata_structure_id="6004" data-value_metadata_term_value_id="0" data-value_open="wavy-ish" data-flag_delete="0">' . '<div class="notebook-page-field-label field-label" title="' . htmlentities($mds->description) . '">' . $mds->renderAsFullName() . '</div> : <div class="notebook-page-field-value field-value">' . util_lang('metadata_structure_has_no_term_set') . '; <input type="text" name="page_field_open_value_1204" id="page_field_open_value_1204" class="page_field_open_value" value="wavy-ish"/>' . '</div> <button class="btn btn-danger button-mark-pagefield-for-delete" title="' . util_lang('mark_for_delete', 'ucfirst') . '" data-do-mark-title="' . util_lang('mark_for_delete', 'ucfirst') . '" data-remove-mark-title="' . util_lang('unmark_for_delete', 'ucfirst') . '" data-for_dom_id="list_item-notebook_page_field_1204" data-notebook_page_field_id="1204"><i class="icon-remove-sign icon-white"></i></button></li>'; $rendered = $npf->renderAsListItemEdit(); // echo "<pre>\n".htmlentities($canonical)."\n--------\n".htmlentities($rendered)."\n</pre>"; $this->assertEqual($canonical, $rendered); $this->assertNoPattern('/IMPLEMENTED/', $rendered); }
function testRenderAsListItemEdit() { $si = Specimen_Image::getOneFromDb(['specimen_image_id' => 8103], $this->DB); global $USER; $USER = User::getOneFromDb(['username' => TESTINGUSER], $this->DB); $canonical = '<li id="specimen-image-8103" class="specimen-image" data-specimen_image_id="8103" data-created_at="' . $si->created_at . '" data-updated_at="' . $si->updated_at . '" data-specimen_id="8002" data-user_id="101" data-image_reference="testing/USER101_8103_cnh_castanea_dentata.jpg" data-ordering="0.75000" data-flag_workflow_published="0" data-flag_workflow_validated="1" data-flag_delete="0">'; $canonical .= '<button type="button" class="btn btn-danger button-delete-specimen-image" title="' . util_lang('prompt_confirm_delete', 'ucfirst') . '" data-specimen_image_id="' . $si->specimen_image_id . '" data-dom_id="specimen-image-8103"><i class="icon-remove icon-white"></i></button><br/>'; $canonical .= $si->renderAsHtml(); $canonical .= '<div class="controls">'; $canonical .= util_orderingLeftRightControls('specimen-image-8103'); $canonical .= '<input type="hidden" name="new_ordering-specimen-image-8103" id="new_ordering-specimen-image-8103" value="' . $si->ordering . '"/>'; // publish, verify, reordering handle $canonical .= '<div class="control-workflows"><span class="control-publish"><input id="flag_workflow_published_8103-control" type="checkbox" name="flag_workflow_published" value="1" /> publish</span>, <span class="control-verify">verified</span></div>'; $canonical .= '</div>'; $canonical .= '</li>'; $rendered = $si->renderAsListItemEdit(); // echo "<pre>\n".htmlentities($canonical)."\n------------------\n".htmlentities($rendered)."\n</pre>"; $this->assertEqual($canonical, $rendered); $this->assertNoPattern('/IMPLEMENTED/', $rendered); }
exit; } # 2. confirm that the user is allowed to take that action // global specimen create // additional permission checks are handled at the save point for notebook pages and authoritative plants respectively $has_permission = $USER->flag_is_system_admin; if (!$has_permission) { $USER->cacheRoleActionTargets(); // check global specimen perms (indiv specimen perms are only for editing, not creating, as indiv perms require a specific object ID as a target for the permission) if (in_array('global_specimen', array_keys($USER->cached_role_action_targets_hash_by_target_type_by_id))) { foreach ($USER->cached_role_action_targets_hash_by_target_type_by_id['global_specimen'] as $glob_rat) { if ($glob_rat->action_id == $ACTIONS['create']->action_id) { $has_permission = true; break; } } } } if (!$has_permission) { $results['note'] = util_lang('no_permission'); echo json_encode($results); exit; } # 3. branch behavior based on the action # create - return an appropriate form field set if ($has_permission && $action == 'create') { $results['html_output'] = '<div class="specimen embedded">' . "\n" . Specimen::renderFormInteriorForNewSpecimen($unique_str, $DB) . "\n</div>"; $results['status'] = 'success'; } echo json_encode($results); exit;
function testCreateButton() { $this->doLoginBasic(); $this->get('http://localhost/digitalfieldnotebooks/app_code/notebook.php?action=list'); $this->checkBasicAsserts(); $this->click(util_lang('add_notebook')); $this->checkBasicAsserts(); $this->assertPattern('/' . util_lang('new_notebook_title') . '/'); // $this->showContent(); }
$new_s->updateDb(); } } } } $action = 'view'; } if ($action == 'list') { echo '<h2>' . ucfirst(util_lang('authoritative_plants')) . '</h2>' . "\n"; if ($USER->canActOnTarget($ACTIONS['edit'], $ap)) { ?> <a href="<?php echo APP_ROOT_PATH . '/app_code/authoritative_plant.php?action=create&user_id=' . $USER->user_id; ?> " class="btn" id="btn-add-authoritative_plant"><?php echo util_lang('add_authoritative_plant'); ?> </a><?php } $all_ap = Authoritative_Plant::getAllFromDb(['flag_delete' => false], $DB); echo '<ul id="list-of-authoritative-plants" class="all-authoritative-plants">' . "\n"; foreach ($all_ap as $ap) { if ($USER->canActOnTarget($ACTIONS['view'], $ap)) { echo $ap->renderAsListItem(); } } echo '</ul>' . "\n"; // echo 'TODO: implement list action'; } if ($action == 'view') { if ($USER->canActOnTarget($ACTIONS['edit'], $ap)) {
function util_coordsMapLink($longitude, $latitude, $zoom = 19) { if (!is_numeric($longitude)) { return util_lang('longitude') . ' ' . util_lang('invalid_value'); } if (!is_numeric($latitude)) { return util_lang('latitude') . ' ' . util_lang('invalid_value'); } if (!is_numeric($zoom)) { return util_lang('zoom_level') . ' ' . util_lang('invalid_value'); } return "http://maps.google.com/maps?q={$latitude},{$longitude}+(point)&z={$zoom}&ll={$latitude},{$longitude}"; }
<?php require_once '../app_setup.php'; $pageTitle = ucfirst(util_lang('search')); require_once '../app_head.php'; # 1. determine whether displaying the form or else doing a search # 2. if displaying the form build it from the metadata # 3. if doing a search # determine the type # fetch the results # build the results display # build the filter/refinement data # build the filter/refinement display echo "TODO: implement search"; require_once '../foot.php';
function testViewNotEditable() { $this->doLoginBasic(); $this->goToNotebookPageView(1104); $this->checkBasicAsserts(); // NOTE: most of the messy details of this are checked in the notebook_page object tests of renderAsView - see app_infrastructure_tests/TestOfNotebookPage.class.php // this just makes sure that the plant lable is actually showing up and that the appropriate edit buttons are there $ap1 = Authoritative_Plant::getOneFromDb(['authoritative_plant_id' => 5001], $this->DB); // page heading text $this->assertText($ap1->renderAsShortText()); // NO 'edit' control $this->assertNoLink(util_lang('edit')); // NO 'add field' control $this->assertNoLink(util_lang('add_notebook_page_field')); // no 'add specimen' control $this->assertNoLink(util_lang('add_specimen')); $this->assertNoText('IMPLEMENTED'); }
$specimenImageDel = Specimen_Image::getOneFromDb(['specimen_image_id' => $specimenImageId], $DB); if (!$specimenImageDel->matchesDb) { $results['status'] = 'success'; } else { $results['note'] = util_lang('msg_delete_failed'); echo json_encode($results); exit; } } elseif ($has_permission && $action == 'reorder') { // get the specimen if (!$specimen) { $specimen = Specimen::getOneFromDb(['specimen_id' => $specimenId], $DB); } // get the image for it $specimen->loadImages(); foreach ($specimen->images as $si) { $req_key = 'ordering_' . $si->specimen_image_id; if (array_key_exists($req_key, $_REQUEST) && is_numeric($_REQUEST[$req_key])) { $si->ordering = $_REQUEST[$req_key]; $si->updateDb(); if (!$si->matchesDb) { $results['note'] = util_lang('msg_database_update_failed'); echo json_encode($results); exit; } } } $results['status'] = 'success'; } echo json_encode($results); exit;
function testRenderAsEdit() { $mdts = Metadata_Term_Set::getOneFromDb(['metadata_term_set_id' => 6101], $this->DB); $canonical = ''; $canonical .= '<form id="form-edit-metadata-term-set-base-data" action="' . APP_ROOT_PATH . '/app_code/metadata_term_set.php">' . "\n"; $canonical .= ' <input type="hidden" name="action" value="update"/>' . "\n"; $canonical .= ' <input type="hidden" id="metadata_term_set_id" name="metadata_term_set_id" value="' . $mdts->metadata_term_set_id . '"/>' . "\n"; $canonical .= ' <div id="actions">' . "\n"; $canonical .= ' <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('update', 'properize') . '</button>' . "\n"; $canonical .= ' <a id="edit-cancel-control" class="btn" href="' . APP_ROOT_PATH . '/app_code/metadata_term_set.php?action=view&metadata_term_set_id=' . $mdts->metadata_term_set_id . '"><i class="icon-remove"></i> ' . util_lang('cancel', 'properize') . '</a>' . "\n"; $canonical .= ' <a id="edit-delete-metadata-term-set-control" class="btn btn-danger" href="' . APP_ROOT_PATH . '/app_code/metadata_term_set.php?action=delete&metadata_term_set_id=' . $mdts->metadata_term_set_id . '"><i class="icon-trash icon-white"></i> ' . util_lang('delete', 'properize') . '</a>' . "\n"; $canonical .= ' </div>' . "\n"; $canonical .= ' <div class="edit-metadata-term-set" ' . $mdts->fieldsAsDataAttribs() . '>' . "\n"; $canonical .= ' <div class="edit-metadata-term-set-header">'; $canonical .= '<a href="' . APP_ROOT_PATH . '/app_code/metadata_term_set.php?action=list">' . util_lang('all_metadata_term_sets') . '</a> >'; $canonical .= '<h3><input class="object-name-control" id="mdts-name" name="name" type="text" value="' . htmlentities($mdts->name) . '"/></h3>'; $canonical .= '</div>'; $canonical .= ' <div class="description-controls"><input title="' . util_lang('title_description') . '" class="description-control" type="text" name="description" value="' . htmlentities($mdts->description) . '"/></div>' . "\n"; $canonical .= $mdts->renderAsEdit_references(); $canonical .= $mdts->renderAsEdit_term_values(); $canonical .= $mdts->renderAsHtml_structures(); $canonical .= ' </div>' . "\n"; $canonical .= '</form>' . "\n"; $rendered = $mdts->renderAsEdit(); // echo "<pre>\n".htmlentities($canonical)."\n-------\n".htmlentities($rendered)."\n</pre>"; $this->assertNoPattern('/IMPLEMENTED/', $rendered); $this->assertEqual($canonical, $rendered); }
} echo $notebook->renderAsView(); } elseif ($action == 'edit' || $action == 'create') { //echo 'TO BE IMPLEMENTED:: implement edit and create actions'; echo $notebook->renderAsEdit(); } elseif ($action == 'delete') { echo 'TO BE IMPLEMENTED:: implement delete action'; } elseif ($action == 'list') { $counter = 0; $num_notebooks = count($all_accessible_notebooks); echo '<h2>' . ucfirst(util_lang('notebooks')) . '</h2>'; echo "<ul id=\"list-of-user-notebooks\" data-notebook-count=\"{$num_notebooks}\">\n"; foreach ($all_accessible_notebooks as $notebook) { if ($notebook) { $counter++; echo $notebook->renderAsListItem('notebook-item-' . $counter) . "\n"; } } echo "</ul>\n"; if ($USER->canActOnTarget($ACTIONS['create'], new Notebook(['DB' => $DB]))) { ?> <a href="<?php echo APP_ROOT_PATH . '/app_code/notebook.php?action=create&user_id=' . $USER->user_id; ?> " class="btn" id="btn-add-notebook"><?php echo util_lang('add_notebook'); ?> </a><?php } } require_once '../foot.php';
function renderAsEdit() { global $USER, $ACTIONS; $actions_attribs = ''; if ($USER->user_id == $this->user_id) { $actions_attribs .= ' data-can-edit="1"'; } elseif ($USER->canActOnTarget($ACTIONS['edit'], $this)) { $actions_attribs .= ' data-can-edit="1"'; } $notebook_owner = $USER; if ($this->user_id != $USER->user_id) { $notebook_owner = $this->getUser(); } if ($this->notebook_id) { $this->cachePages(); } else { $this->notebook_id = 'NEW'; } $rendered = '<div id="edit_rendered_notebook_' . $this->notebook_id . '" class="edit_rendered_notebook" ' . $this->fieldsAsDataAttribs() . $actions_attribs . '>' . "\n" . '<form action="' . APP_ROOT_PATH . '/app_code/notebook.php">' . "\n"; $rendered .= '<div id="actions">' . "\n"; if ($this->notebook_id == 'NEW') { // $rendered .= ' <input id="edit-submit-control" class="btn" type="submit" name="edit-submit-control" value="'.util_lang('save','properize').'"/>'."\n"; $rendered .= ' <button id="edit-submit-control" class="btn btn-success" type="submit" name="edit-submit-control"><i class="icon-ok-sign icon-white"></i> ' . util_lang('save', 'properize') . '</button>' . "\n"; $rendered .= ' <a id="edit-cancel-control" class="btn" href="' . APP_ROOT_PATH . '/app_code/notebook.php?action=list"><i class="icon-remove"></i> ' . util_lang('cancel', 'properize') . '</a>' . "\n"; } else { // $rendered .= ' <input id="edit-submit-control" class="btn" type="submit" name="edit-submit-control" value="'.util_lang('update','properize').'"/>'."\n"; $rendered .= ' <button id="edit-submit-control" class="btn btn-success" type="submit" name="edit-submit-control"><i class="icon-ok-sign icon-white"></i> ' . util_lang('update', 'properize') . '</button>' . "\n"; $rendered .= ' <a id="edit-cancel-control" class="btn" href="' . APP_ROOT_PATH . '/app_code/notebook.php?action=view¬ebook_id=' . $this->notebook_id . '"><i class="icon-remove"></i> ' . util_lang('cancel', 'properize') . '</a>' . "\n"; } $rendered .= "</div>\n"; $rendered .= ' <input type="hidden" name="action" value="update"/>' . "\n" . ' <input type="hidden" name="notebook_id" value="' . $this->notebook_id . '"/>' . "\n" . ' <h3 class="notebook_title">' . ucfirst(util_lang('notebook')) . ': <input id="notebook-name" type="text" name="name" value="' . $this->name . '"/></h3>' . "\n" . ' <div class="info-timestamps"><span class="created_at">' . util_lang('created_at') . ' ' . util_datetimeFormatted($this->created_at) . '</span>, <span class="updated_at">' . util_lang('updated_at') . ' ' . util_datetimeFormatted($this->updated_at) . '</span></div>' . "\n" . ' <div class="info-owner">' . util_lang('owned_by') . ' <a href="' . APP_ROOT_PATH . '/app_code/user.php?action=view&user_id=' . $notebook_owner->user_id . '">' . htmlentities($notebook_owner->screen_name) . '</a></div>' . "\n"; $rendered .= '<div class="control-workflows">'; if ($this->notebook_id != 'NEW') { if ($USER->canActOnTarget('publish', $this)) { $rendered .= ' <span class="published_state workflow-control"><input id="notebook-workflow-publish-control" type="checkbox" name="flag_workflow_published" value="1"' . ($this->flag_workflow_published ? ' checked="checked"' : '') . ' /> ' . util_lang('publish') . '</span>,'; } else { $rendered .= ' <span class="published_state workflow-info">' . ($this->flag_workflow_published ? util_lang('published_true') : util_lang('published_false')) . '</span>,'; } if ($USER->canActOnTarget('verify', $this)) { $rendered .= ' <span class="verified_state verified_state_' . ($this->flag_workflow_validated ? 'true' : 'false') . ' workflow-control"><input id="notebook-workflow-validate-control" type="checkbox" name="flag_workflow_validated" value="1"' . ($this->flag_workflow_validated ? ' checked="checked"' : '') . ' /> ' . util_lang('verify') . '</span>'; } else { $rendered .= ' <span class="verified_state verified_state_' . ($this->flag_workflow_validated ? 'true' : 'false') . ' workflow-info">' . ($this->flag_workflow_validated ? util_lang('verified_true') : util_lang('verified_false')) . '</span>'; } } $rendered .= "</div>\n"; $rendered .= ' <div class="notebook_notes"><textarea id="notebook-notes" name="notes" rows="4" cols="120">' . htmlentities($this->notes) . '</textarea></div>' . "\n"; $rendered .= '</form>' . "\n"; if ($this->notebook_id == 'NEW') { $rendered .= ' <h4>' . ucfirst(util_lang('pages')) . '</h4>' . "\n" . ' ' . util_lang('new_notebook_must_be_saved') . "\n"; } else { $rendered .= ' <h4>' . ucfirst(util_lang('pages')) . '</h4>' . "\n" . ' <ul id="list-of-notebook-pages" data-notebook-page-count="' . count($this->pages) . '">' . "\n"; // NOTE: add page control only in edit mode, not view mode! if ($USER->canActOnTarget($ACTIONS['edit'], $this)) { $rendered .= ' <li><a href="' . APP_ROOT_PATH . '/app_code/notebook_page.php?action=create¬ebook_id=' . $this->notebook_id . '" id="btn-add-notebook-page" class="creation_link btn">' . htmlentities(util_lang('add_notebook_page')) . '</a></li>' . "\n"; } if (count($this->pages) > 0) { $page_counter = 0; foreach ($this->pages as $p) { $page_counter++; $rendered .= ' ' . $p->renderAsListItem('notebook-page-item-' . $page_counter) . "\n"; } } else { $rendered .= ' <li>' . util_lang('zero_pages') . '</li>' . "\n"; } $rendered .= ' </ul>' . "\n"; } $rendered .= '</div>'; return $rendered; }
} } } } $action = 'view'; } echo '<script src="' . APP_ROOT_PATH . '/js/notebook_page_general.js"></script>' . "\n"; if ($action == 'view') { if ($USER->canActOnTarget($ACTIONS['edit'], $notebook_page)) { echo '<div id="actions">' . $notebook_page->renderAsButtonEdit() . '</div>' . "\n"; } echo $notebook_page->renderAsView(); echo '<script src="' . APP_ROOT_PATH . '/js/plant_image_viewer.js"></script>' . "\n"; } else { if ($action == 'edit' || $action == 'create') { if ($USER->canActOnTarget($ACTIONS['edit'], $notebook_page)) { echo $notebook_page->renderAsEdit(); } echo '<script src="' . APP_ROOT_PATH . '/js/plant_image_viewer.js"></script>' . "\n"; echo '<script src="' . APP_ROOT_PATH . '/js/ordering_controls.js"></script>' . "\n"; echo '<script src="' . APP_ROOT_PATH . '/js/notebook_page_edit.js"></script>' . "\n"; //echo 'TODO: implement edit and create actions'; } else { if ($action == 'delete') { $notebook = $notebook_page->getNotebook(); $notebook_page->doDelete(); util_redirectToAppPage('app_code/notebook.php?action=view¬ebook_id=' . $notebook->notebook_id, 'info', util_lang('msg_notebook_page_deleted')); } } } require_once '../foot.php';
if ($action != 'delete') { require_once '../app_head.php'; } # 4. branch behavior based on the action # update - update the object with the data coming in, then show the object (w/ 'saved' message) # verify/publish - set the appropriate flag (true or false, depending on data coming in), then show the object (w/ 'saved' message) # *list* - not a standard action; show a list (tree) of all metadata to which the user has view access # view - show the object # create/edit - show a form with the object's current values ($action is 'update' on form submit) # delete - delete the metadata_structure, then go to list w/ 'deleted' message if ($action == 'update' || $action == 'verify' || $action == 'publish') { echo 'TODO: implement update, verify, and publish actions'; $action = 'view'; } if ($action == 'list') { echo '<h2>' . util_lang('all_metadata_term_sets', 'properize') . '</h2>' . "\n"; $all_metadata_term_sets = Metadata_Term_Set::getAllFromDb([], $DB); echo '<ul class="all-metadata-term-sets">' . "\n"; foreach ($all_metadata_term_sets as $a_mdts) { if ($USER->canActOnTarget($ACTIONS['view'], $a_mdts)) { echo $a_mdts->renderAsListItem(); } } echo '</ul>' . "\n"; } if ($action == 'view') { if ($USER->canActOnTarget($ACTIONS['edit'], $mdts)) { echo '<div id="actions">' . $mdts->renderAsButtonEdit() . '</div>' . "\n"; } echo $mdts->renderAsView(); } else {
function testRenderAsEdit_newNotebook() { global $USER; $USER = User::getOneFromDb(['username' => TESTINGUSER], $this->DB); $n = Notebook::createNewNotebookForUser($USER->user_id, $this->DB); // $this->fail(); // $canonical = '<div id="edit_rendered_notebook_NEW" class="edit_rendered_notebook" data-notebook_id="NEW" data-created_at="'.$n->created_at.'" data-updated_at="'.$n->updated_at.'" data-user_id="101" data-name="'.htmlentities($n->name).'" data-notes="'.htmlentities(util_lang('new_notebook_notes')).'" data-flag_workflow_published="0" data-flag_workflow_validated="0" data-flag_delete="0" data-can-edit="1"> //<form action="'.APP_ROOT_PATH.'/app_code/notebook.php"> // <input type="hidden" name="action" value="update"/> // <input type="hidden" name="notebook_id" value="NEW"/> // <h3 class="notebook_title">'.ucfirst(util_lang('notebook')).': <input id="notebook-name" type="text" name="name" value="'.htmlentities($n->name).'"/></h3> // <span class="created_at">'.util_lang('created_at').' '.util_datetimeFormatted($n->created_at).'</span>, <span class="updated_at">'.util_lang('updated_at').' '.util_datetimeFormatted($n->updated_at).'</span><br/> // <span class="owner">'.util_lang('owned_by').' <a href="'.APP_ROOT_PATH.'/app_code/user.php?action=view&user_id=101">'.$USER->screen_name.'</a></span><br/> // <div class="notebook-notes"><textarea id="notebook-notes" name="notes" rows="4" cols="120">'.htmlentities(util_lang('new_notebook_notes')).'</textarea></div> // <input id="edit-submit-control" class="btn" type="submit" name="edit-submit-control" value="'.util_lang('save','properize').'"/> // <a id="edit-cancel-control" class="btn" href="/digitalfieldnotebooks/app_code/notebook.php?action=list">'.util_lang('cancel','properize').'</a> //</form> // <h4>'.ucfirst(util_lang('pages')).'</h4> // '.util_lang('new_notebook_must_be_saved').' //</div>'; $canonical = '<div id="edit_rendered_notebook_NEW" class="edit_rendered_notebook" data-notebook_id="NEW" data-created_at="' . $n->created_at . '" data-updated_at="' . $n->updated_at . '" data-user_id="101" data-name="' . htmlentities($n->name) . '" data-notes="' . htmlentities(util_lang('new_notebook_notes')) . '" data-flag_workflow_published="0" data-flag_workflow_validated="0" data-flag_delete="0" data-can-edit="1"> <form action="' . APP_ROOT_PATH . '/app_code/notebook.php"> <div id="actions"> <button id="edit-submit-control" class="btn btn-success" type="submit" name="edit-submit-control"><i class="icon-ok-sign icon-white"></i> ' . util_lang('save', 'properize') . '</button> <a id="edit-cancel-control" class="btn" href="' . APP_ROOT_PATH . '/app_code/notebook.php?action=list"><i class="icon-remove"></i> ' . util_lang('cancel', 'properize') . '</a> </div> <input type="hidden" name="action" value="update"/> <input type="hidden" name="notebook_id" value="NEW"/> <h3 class="notebook_title">' . ucfirst(util_lang('notebook')) . ': <input id="notebook-name" type="text" name="name" value="' . htmlentities($n->name) . '"/></h3> <div class="info-timestamps"><span class="created_at">' . util_lang('created_at') . ' ' . util_datetimeFormatted($n->created_at) . '</span>, <span class="updated_at">' . util_lang('updated_at') . ' ' . util_datetimeFormatted($n->updated_at) . '</span></div> <div class="info-owner">' . util_lang('owned_by') . ' <a href="' . APP_ROOT_PATH . '/app_code/user.php?action=view&user_id=101">' . $USER->screen_name . '</a></div> <div class="control-workflows"></div> <div class="notebook_notes"><textarea id="notebook-notes" name="notes" rows="4" cols="120">' . htmlentities(util_lang('new_notebook_notes')) . '</textarea></div> </form> <h4>' . ucfirst(util_lang('pages')) . '</h4> ' . util_lang('new_notebook_must_be_saved') . ' </div>'; $rendered = $n->renderAsEdit(); // echo "<pre>\n".htmlentities($canonical)."\n-----------------\n".htmlentities($rendered)."\n</pre>"; $this->assertEqual($canonical, $rendered); $this->assertNoPattern('/IMPLEMENTED/', $rendered); }
function testLang() { // 1. set up LANGUAGE and CURRENT_LANGUAGE_SET // 2. run the assert global $LANGUAGE, $CUR_LANG_SET; $CUR_LANG_SET = 'test'; $LANGUAGE[$CUR_LANG_SET]['foo'] = 'bar'; $LANGUAGE[$CUR_LANG_SET]['baz_maz'] = 'baz maz'; $this->assertEqual(util_lang('foo'), 'bar'); $this->assertEqual(util_lang('baz_maz'), 'baz maz'); $this->assertEqual(util_lang('baz_maz', 'ucfirst'), 'Baz maz'); $this->assertEqual(util_lang('baz_maz', 'properize'), 'Baz Maz'); }
function testViewNotEditable() { $this->doLoginBasic(); $this->goToNotebookView(1004); $this->checkBasicAsserts(); $n = Notebook::getOneFromDb(['notebook_id' => 1004], $this->DB); // util_prePrintR($n); $ap1 = Authoritative_Plant::getOneFromDb(['authoritative_plant_id' => 5001], $this->DB); // page heading text $this->assertText(ucfirst(util_lang('notebook'))); $this->assertText($n->name); $this->assertText($n->notes); // NO 'edit' control $this->assertNoLink(util_lang('edit')); // number of notebook pages $this->assertEltByIdHasAttrOfValue('list-of-notebook-pages', 'data-notebook-page-count', '1'); $this->assertEltByIdHasAttrOfValue('notebook-page-item-1', 'data-notebook_page_id', '1104'); $this->assertLink($ap1->renderAsShortText()); // NO 'add page' control $this->assertNoLink(util_lang('add_notebook_page')); }
</form> <?php } else { //util_prePrintR($LANGUAGE); ?> <form id="frmSignin" class="navbar-form pull-right" method="post" action=""> <input type="text" id="username" class="span2" name="username" placeholder="<?php echo util_lang('username'); ?> " value="" /> <input type="password" id="password_login" class="span2" name="password" placeholder="<?php echo util_lang('password'); ?> " value="" /> <input type="submit" id="submit_signin" class="btn" name="submit_signin" value="<?php echo util_lang('app_sign_in_action'); ?> " /> </form> <?php } ?> </div> </div> </div> </div> <div class="container"> <!--div closed in the footer--> <?php // display screen message? if (isset($_REQUEST["success"])) {