当前位置: 首页>>代码示例>>PHP>>正文


PHP data_entry_helper::entity_to_load方法代码示例

本文整理汇总了PHP中data_entry_helper::entity_to_load方法的典型用法代码示例。如果您正苦于以下问题:PHP data_entry_helper::entity_to_load方法的具体用法?PHP data_entry_helper::entity_to_load怎么用?PHP data_entry_helper::entity_to_load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在data_entry_helper的用法示例。


在下文中一共展示了data_entry_helper::entity_to_load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_form

 /**
  * Return the generated form output.
  * @param array $args List of parameter values passed through to the form depending on how the form has been configured.
  * This array always contains a value for language.
  * @param object $node The Drupal node object.
  * @param array $response When this form is reloading after saving a submission, contains the response from the service call.
  * Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data).
  * @return Form HTML.
  */
 public static function get_form($args, $node, $response = null)
 {
     $reloadPath = self::get_reload_path();
     $auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
     $r = "<form method=\"post\" id=\"entry_form\" action=\"{$reloadPath}\">\n";
     $r .= $auth['write'];
     data_entry_helper::$entity_to_load = array();
     if (!empty($_GET['termlists_term_id'])) {
         data_entry_helper::load_existing_record($auth['read'], 'termlists_term', $_GET['termlists_term_id']);
         // map fields to their appropriate supermodels
         data_entry_helper::$entity_to_load['term:term'] = data_entry_helper::$entity_to_load['termlists_term:term'];
         data_entry_helper::$entity_to_load['term:id'] = data_entry_helper::$entity_to_load['termlists_term:term_id'];
         data_entry_helper::$entity_to_load['meaning:id'] = data_entry_helper::$entity_to_load['termlists_term:meaning_id'];
         if (function_exists('hostsite_set_page_title')) {
             hostsite_set_page_title(lang::get('Edit {1}', data_entry_helper::$entity_to_load['term:term']));
         }
     }
     $r .= data_entry_helper::hidden_text(array('fieldname' => 'website_id', 'default' => $args['website_id']));
     $r .= data_entry_helper::hidden_text(array('fieldname' => 'termlists_term:id'));
     $r .= data_entry_helper::hidden_text(array('fieldname' => 'termlists_term:termlist_id', 'default' => $args['termlist_id']));
     $r .= data_entry_helper::hidden_text(array('fieldname' => 'termlists_term:preferred', 'default' => 't'));
     $r .= data_entry_helper::hidden_text(array('fieldname' => 'term:id'));
     $r .= data_entry_helper::hidden_text(array('fieldname' => 'term:language_id', 'default' => $args['language_id']));
     $r .= data_entry_helper::hidden_text(array('fieldname' => 'meaning:id'));
     // request automatic JS validation
     data_entry_helper::enable_validation('entry_form');
     $r .= data_entry_helper::text_input(array('label' => lang::get('Term'), 'fieldname' => 'term:term', 'helpText' => lang::get('Please provide the term'), 'validation' => array('required'), 'class' => 'control-width-5'));
     $r .= "<input type=\"submit\" name=\"form-submit\" id=\"delete\" value=\"Delete\" />\n";
     $r .= "<input type=\"submit\" name=\"form-submit\" value=\"Save\" />\n";
     $r .= '<form>';
     self::set_breadcrumb($args);
     return $r;
 }
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:42,代码来源:term.php

示例2: getEntity

 /**
  * Preparing to display an existing sample with occurrences.
  * When displaying a grid of occurrences, just load the sample and data_entry_helper::species_checklist
  * will load the occurrences.
  * When displaying just one occurrence we must load the sample and the occurrence
  */
 protected static function getEntity($args, $auth)
 {
     data_entry_helper::$entity_to_load = array();
     // If we know the occurrence ID but not the sample, we must look it up
     if (self::$loadedOccurrenceId && !self::$loadedSampleId) {
         $response = data_entry_helper::get_population_data(array('table' => 'occurrence', 'extraParams' => $auth['read'] + array('id' => self::$loadedOccurrenceId, 'view' => 'detail')));
         if (count($response) != 0) {
             //we found an occurrence
             self::$loadedSampleId = $response[0]['sample_id'];
         }
     }
     // Load the sample record
     if (self::$loadedSampleId) {
         data_entry_helper::load_existing_record($auth['read'], 'sample', self::$loadedSampleId, 'detail', false, true);
     }
     // Ensure that if we are used to load a different survey's data, then we get the correct survey attributes. We can change args
     // because the caller passes by reference.
     if ($args['survey_id'] != data_entry_helper::$entity_to_load['sample:survey_id']) {
         throw new exception(lang::get('Attempt to access a record on a different survey.'));
     }
     if ($args['sample_method_id'] != data_entry_helper::$entity_to_load['sample:sample_method_id']) {
         throw new exception(lang::get('Attempt to access a record with the wrong sample_method_id.'));
     }
     // enforce that people only access their own data, unless explicitly have permissions
     $editor = !empty($args['edit_permission']) && function_exists('user_access') && user_access($args['edit_permission']);
     if (!$editor && function_exists('hostsite_get_user_field') && data_entry_helper::$entity_to_load['sample:created_by_id'] != 1 && data_entry_helper::$entity_to_load['sample:created_by_id'] !== hostsite_get_user_field('indicia_user_id')) {
         throw new exception(lang::get('Attempt to access a record you did not create.'));
     }
 }
开发者ID:joewoodhouse,项目名称:client_helpers,代码行数:35,代码来源:tree_sample_occurrence.php

示例3: loadExistingUserTrust

 /**
  * Fetch an existing user trust's information from the database when editing.
  * @param integer $id User trust ID
  * @param array $auth Authorisation tokens
  */
 private static function loadExistingUserTrust($id, $auth)
 {
     $trust = data_entry_helper::get_population_data(array('table' => 'user_trust', 'extraParams' => $auth['read'] + array('view' => 'detail', 'id' => $_GET['user_trust_id']), 'nocache' => true));
     data_entry_helper::$entity_to_load = array('user_trust:id' => $trust[0]['id'], 'user_trust:user_id' => $trust[0]['user_id'], 'user_trust:user_id:person_name' => $trust[0]['person'], 'user_trust:survey_id' => $trust[0]['survey_id'], 'user_trust:survey_id:title' => $trust[0]['survey'], 'user_trust:taxon_group_id' => $trust[0]['taxon_group_id'], 'user_trust:taxon_group_id:title' => $trust[0]['taxon_group'], 'user_trust:location_id' => $trust[0]['location_id'], 'user_trust:location_id:name' => $trust[0]['location']);
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:10,代码来源:user_trust_edit.php

示例4: dump_errors

 /**
  * Takes a response from a call to forward_post_to() and outputs any errors from it onto the screen.
  *
  * @param string $response Return value from a call to forward_post_to().
  * @param boolean $inline Set to true if the errors are to be placed alongside the controls rather than at the top of the page.
  * Default is true.
  * @see forward_post_to()
  * @link http://code.google.com/p/indicia/wiki/TutorialBuildingBasicPage#Build_a_data_entry_page
  */
 public static function dump_errors($response, $inline = true)
 {
     $r = "";
     if (is_array($response)) {
         // set form mode
         self::$form_mode = 'ERRORS';
         if (array_key_exists('error', $response) || array_key_exists('errors', $response)) {
             if ($inline && array_key_exists('errors', $response)) {
                 // Setup an errors array that the data_entry_helper can output alongside the controls
                 self::$validation_errors = $response['errors'];
                 // And tell the helper to reload the existing data.
                 self::$entity_to_load = $_POST;
                 if (isset($response['code'])) {
                     switch ($response['code']) {
                         case 2003:
                             if (function_exists('hostsite_show_message')) {
                                 hostsite_show_message(lang::get('The data could not be saved.'), 'error');
                             } else {
                                 $r .= "<div class=\"ui-widget ui-corner-all ui-state-highlight page-notice\">" . lang::get('The data could not be saved.') . "</div>\n";
                             }
                     }
                 }
             } else {
                 $r .= "<div class=\"ui-state-error ui-corner-all\">\n";
                 $r .= "<p>An error occurred when the data was submitted.</p>\n";
                 if (is_array($response['error'])) {
                     $r .= "<ul>\n";
                     foreach ($response['error'] as $field => $message) {
                         $r .= "<li>{$field}: {$message}</li>\n";
                     }
                     $r .= "</ul>\n";
                 } else {
                     $r .= "<p class=\"error_message\">" . $response['error'] . "</p>\n";
                 }
                 if (array_key_exists('file', $response) && array_key_exists('line', $response)) {
                     $r .= "<p>Error occurred in " . $response['file'] . " at line " . $response['line'] . "</p>\n";
                 }
                 if (array_key_exists('errors', $response)) {
                     $r .= "<pre>" . print_r($response['errors'], true) . "</pre>\n";
                 }
                 if (array_key_exists('trace', $response)) {
                     $r .= "<pre>" . print_r($response['trace'], true) . "</pre>\n";
                 }
                 $r .= "</div>\n";
             }
         } elseif (array_key_exists('warning', $response)) {
             if (function_exists('hostsite_show_message')) {
                 hostsite_show_message(lang::get('A warning occurred when the data was submitted.') . ' ' . $response['error'], 'error');
             } else {
                 $r .= 'A warning occurred when the data was submitted.';
                 $r .= '<p class="error">' . $response['error'] . "</p>\n";
             }
         } elseif (array_key_exists('success', $response)) {
             $successMessage = lang::get('Thank you for submitting your data.');
             if (function_exists('hostsite_show_message')) {
                 hostsite_show_message($successMessage);
             } else {
                 $r .= "<div class=\"ui-widget ui-corner-all ui-state-highlight page-notice\">" . $successMessage . "</div>\n";
             }
         }
     } else {
         $r .= "<div class=\"ui-state-error ui-corner-all\">{$response}</div>\n";
     }
     return $r;
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:74,代码来源:data_entry_helper.php

示例5: iform_mnhnl_locModTool

function iform_mnhnl_locModTool($auth, $args, $node)
{
    global $indicia_templates;
    if (!isset($args['clientSideValidation']) || $args['clientSideValidation']) {
        data_entry_helper::enable_validation('entry_form');
    }
    if ($args['locationMode'] == 'multi') {
        $args['locationMode'] = 'parent';
    }
    data_entry_helper::$entity_to_load = array();
    $retVal = "<div id=\"locations\">";
    if ($args['shpFileDownloadURL'] != "") {
        $request = $args['shpFileDownloadURL'] . "/geoserver/wfs?request=GetFeature&service=wfs&version=1.0.0&outputformat=SHAPE-ZIP&srsName=EPSG:2169";
        if ($args['LocationTypeTerm'] == '' && isset($args['loctoolsLocTypeID'])) {
            $args['LocationTypeTerm'] = $args['loctoolsLocTypeID'];
        }
        $primary = iform_mnhnl_getTermID($auth, 'indicia:location_types', $args['LocationTypeTerm']);
        $request .= "&cql_filter=website_id=" . $args['website_id'] . " AND ";
        if ($args['SecondaryLocationTypeTerm'] != '') {
            $secondary = iform_mnhnl_getTermID($auth, 'indicia:location_types', $args['SecondaryLocationTypeTerm']);
            $request .= "(type_id=" . $primary . "OR type_id=" . $secondary . ")";
        } else {
            $request .= "type_id=" . $primary;
        }
        $request .= "&typename=" . $args['shpFileFeaturePrefix'] . ':';
        $filedetails = "&format_options=filename:" . $args['reportFilenamePrefix'];
        $retValList = "";
        if ($args['usePoints'] != 'none' || isset($args['shpDownloadPoints']) && $args['shpDownloadPoints']) {
            $retValList .= "<a href=\"" . $request . "point_locations" . $filedetails . "_Points.zip\">" . lang::get('Points') . "</a>";
        }
        if ($args['useLines'] != 'none' || isset($args['shpDownloadLines']) && $args['shpDownloadLines']) {
            $retValList .= ($retValList == "" ? "" : " : ") . "<a href=\"" . $request . "line_locations" . $filedetails . "_Lines.zip\">" . lang::get('Lines') . "</a>";
        }
        if ($args['usePolygons'] != 'none' || isset($args['shpDownloadPolygons']) && $args['shpDownloadPolygons']) {
            $retValList .= ($retValList == "" ? "" : " : ") . "<a href=\"" . $request . "polygon_locations" . $filedetails . "_Polygons.zip\">" . lang::get('Polygons') . "</a>";
        }
        $retVal .= "<fieldset><legend>" . lang::get('LANG_SHP_Download_Legend') . "</legend>\n      <p>" . lang::get('LANG_Shapefile_Download') . " " . $retValList . "</p></fieldset>";
    }
    $includeOutsideSquare = $args['locationMode'] == 'parent';
    // includes multi - see above
    // filtered
    if ($args['locationMode'] == 'filtered') {
        $filterAttrs = explode(',', $args['filterAttrs']);
        foreach ($filterAttrs as $idx => $filterAttr) {
            $filterAttr = explode(':', $filterAttr);
            if ($filterAttr[0] == 'Parent' && $filterAttr[1] == "true") {
                $includeOutsideSquare = true;
            }
        }
    }
    if ($includeOutsideSquare) {
        $confirmedLocationTypeID = iform_mnhnl_getTermID($auth, 'indicia:location_types', $args['SecondaryLocationTypeTerm']);
        if (is_null($confirmedLocationTypeID)) {
            $confirmedLocationTypeID = "0";
        }
        $submittedLocationTypeID = iform_mnhnl_getTermID($auth, 'indicia:location_types', $args['LocationTypeTerm']);
        $retVal .= "<fieldset><legend>" . lang::get('LANG_Outside_Square_Reports') . "</legend>\n  \t<form method='post' action='" . data_entry_helper::$base_url . '/index.php/services/report/requestReport?report=reports_for_prebuilt_forms/MNHNL/luxbio_outside_squares_1.xml&reportSource=local&auth_token=' . $auth['read']['auth_token'] . '&nonce=' . $auth['read']['nonce'] . '&mode=csv&filename=' . $args['reportFilenamePrefix'] . "CentreOutsideSquaresReport'>\n      <label style='width:auto;'>" . lang::get('LANG_Outside_Square_Download_1') . ":</label>\n      <input type='hidden' name='params' value='{\"website_id\":" . $args['website_id'] . ", \"survey_id\":" . $args['survey_id'] . ", \"primary_loc_type_id\":" . $submittedLocationTypeID . ", \"secondary_loc_type_id\":" . $confirmedLocationTypeID . "}' />\n      <input type='submit' class='ui-state-default ui-corner-all' value='" . lang::get('Download') . "'>\n    </form>\n  \t<form method='post' action='" . data_entry_helper::$base_url . '/index.php/services/report/requestReport?report=reports_for_prebuilt_forms/MNHNL/luxbio_outside_squares_2.xml&reportSource=local&auth_token=' . $auth['read']['auth_token'] . '&nonce=' . $auth['read']['nonce'] . '&mode=csv&filename=' . $args['reportFilenamePrefix'] . "BoundaryCutsSquaresReport'>\n      <label style='width:auto;'>" . lang::get('LANG_Outside_Square_Download_2') . ":</label>\n      <input type='hidden' name='params' value='{\"website_id\":" . $args['website_id'] . ", \"survey_id\":" . $args['survey_id'] . ", \"primary_loc_type_id\":" . $submittedLocationTypeID . ", \"secondary_loc_type_id\":" . $confirmedLocationTypeID . "}' />\n      <input type='submit' class='ui-state-default ui-corner-all' value='" . lang::get('Download') . "'>\n    </form>\n    </fieldset>";
    }
    $retVal .= "<form method=\"post\" id=\"entry_form\">" . $auth['write'] . "<input type=\"hidden\" id=\"source\" name=\"source\" value=\"iform_mnhnl_locModTool\" />" . "<input type=\"hidden\" id=\"website_id\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />" . "<input type=\"hidden\" id=\"survey_id\" name=\"survey_id\" value=\"" . $args['survey_id'] . "\" />";
    $retVal .= iform_mnhnl_lux5kgridControl($auth, $args, $node, array('Instructions2' => lang::get('LANG_LocModTool_Instructions2'), 'MainFieldLabel' => lang::get('LANG_LocModTool_IDLabel'), 'NameLabel' => lang::get('LANG_LocModTool_NameLabel'), 'ParentLabel' => lang::get('LANG_LocModTool_ParentLabel'), 'AdminMode' => true));
    $retVal .= "<label for=\"location-delete\">" . lang::get("LANG_LocModTool_DeleteLabel") . ":</label> <input type=checkbox id=\"location-delete\" name=\"location:deleted\" value='t'><br />\n  <p>" . lang::get("LANG_LocModTool_DeleteInstructions") . "</p>";
    // location comments are included as a separate control on the main form.
    if (isset($args['includeLocationComment']) && $args['includeLocationComment']) {
        $retVal .= data_entry_helper::textarea(array('id' => 'location-comment', 'fieldname' => 'location:comment', 'label' => lang::get("LANG_LocationModTool_CommentLabel"))) . "<br />";
    }
    $laArgs = array("lookUpKey" => "meaning_id", "sep" => " ", "class" => "wide", "tabNameFilter" => "", "numValues" => 10000);
    $defs = array();
    if (isset($args['siteTabSplitAttrs']) && $args['siteTabSplitAttrs'] != "") {
        $defs = explode(':', $args['siteTabSplitAttrs']);
        $defs1 = explode(',', $defs[0]);
        $laArgs["tabNameFilter"] = $defs1[0];
        $laArgs["class"] = $defs1[1];
    }
    $retVal .= iform_mnhnl_locationattributes($auth, $args, '', $laArgs);
    $retVal .= iform_mnhnl_SrefFields($auth, $args, true);
    if (count($defs) > 1) {
        $defs1 = explode(',', $defs[1]);
        $laArgs["tabNameFilter"] = $defs1[0];
        $laArgs["class"] = $defs1[1];
        $retVal .= iform_mnhnl_locationattributes($auth, $args, '', $laArgs);
    }
    $args['interface'] = 'Tabs';
    $mapOptions = iform_map_get_map_options($args, $auth['read']);
    $olOptions = iform_map_get_ol_options($args);
    if ($args['locationMode'] != 'parent') {
        // this includes multi as well (see above)
        // can't call the protested control function
        $georefOpts = iform_map_get_georef_options($args, $auth['read']);
        // can't use place search without the driver API key
        if ($georefOpts['driver'] == 'geoplanet' && empty(helper_config::$geoplanet_api_key)) {
            $retVal .= '<p>The form structure includes a [place search] control but needs a geoplanet api key.</p>';
        } else {
            $retVal .= data_entry_helper::georeference_lookup($georefOpts);
        }
        $mapOptions['searchLayer'] = true;
        $mapOptions['searchUpdatesSref'] = false;
        $mapOptions['searchDisplaysPoint'] = false;
    }
    // For main page we force to Tabs to ensure map drawn correctly
    $mapOptions['tabDiv'] = 'locations';
//.........这里部分代码省略.........
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:101,代码来源:mnhnl_common.php

示例6: get_form

 /**
  * Return the generated form output.
  * @return Form HTML.
  */
 public static function get_form($args, $node)
 {
     global $user;
     $logged_in = $user->uid > 0;
     $r = '';
     // Get authorisation tokens to update and read from the Warehouse.
     $writeAuth = data_entry_helper::get_auth($args['website_id'], $args['password']);
     $readAuth = data_entry_helper::get_read_auth($args['website_id'], $args['password']);
     $svcUrl = data_entry_helper::$base_url . '/index.php/services';
     $mode = 0;
     // default mode : display survey selector
     // mode 1: display new sample
     // mode 2: display existing sample
     $loadID = null;
     $displayThisOcc = true;
     // when populating from the DB rather than POST we have to be
     // careful with selection object, as geom in wrong format.
     if ($_POST) {
         if (!is_null(data_entry_helper::$entity_to_load)) {
             $mode = 2;
             // errors with new sample, entity poulated with post, so display this data.
         }
         // else valid save, so go back to gridview: default mode 0
     } else {
         if (array_key_exists('sample_id', $_GET)) {
             $mode = 2;
             $loadID = $_GET['sample_id'];
         } else {
             if (array_key_exists('newSample', $_GET)) {
                 $mode = 1;
                 data_entry_helper::$entity_to_load = array();
             }
         }
         // else default to mode 0
     }
     ///////////////////////////////////////////////////////////////////
     // default mode 0 : display survey selector
     ///////////////////////////////////////////////////////////////////
     if ($mode == 0) {
         // Create the Sample list datagrid for this user.
         drupal_add_js(drupal_get_path('module', 'iform') . '/media/js/hasharray.js', 'module');
         drupal_add_js(drupal_get_path('module', 'iform') . '/media/js/jquery.datagrid.js', 'module');
         drupal_add_js("jQuery(document).ready(function(){\n  \$('div#smp_grid').indiciaDataGrid('rpt:mnhnl_collab_list_samples', {\n    indiciaSvc: '" . $svcUrl . "',\n    dataColumns: ['location_name', 'entered_sref', 'date', 'num_occurrences', 'completed'],\n    reportColumnTitles: {location_name : '" . lang::get('LANG_Location') . "', entered_sref : '" . lang::get('LANG_Spatial_ref') . "', date : '" . lang::get('LANG_Date') . "', num_occurrences : '" . lang::get('LANG_Num_Occurrences') . "', completed : '" . lang::get('LANG_Completed') . "'},\n    actionColumns: {" . lang::get('LANG_Edit') . " : \"" . url('node/' . $node->nid, array('query' => 'sample_id=�id�')) . "\"},\n    auth : { nonce : '" . $readAuth['nonce'] . "', auth_token : '" . $readAuth['auth_token'] . "'},\n    parameters : {\n    \t\t\tsurvey_id : '" . $args['survey_id'] . "',\n    \t\t\tuserID_attr_id : '" . $args['uid_attr_id'] . "',\n    \t\t\tuserID : '" . $user->uid . "'\n    \t\t\t\t},\n    itemsPerPage : 12 \n  });\n});\n\n", 'inline');
         $r .= '<div id="sampleList" class="mnhnl-btw-datapanel"><div id="smp_grid"></div>';
         $r .= '<form><input type="button" value="' . lang::get('LANG_Add_Sample') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => 'newSample')) . '\'"></form></div>';
         $r .= "</div>\n";
         return $r;
     }
     ///////////////////////////////////////////////////////////////////
     data_entry_helper::$javascript .= "\n// Create vector layers: one to display the location onto, and another for the occurrence list\n// the default edit layer is used for the occurrences themselves\nlocStyleMap = new OpenLayers.StyleMap({\n                \"default\": new OpenLayers.Style({\n                    fillColor: \"Green\",\n                    strokeColor: \"Black\",\n                    fillOpacity: 0.3,\n                    strokeWidth: 1\n                  })\n  });\nlocationLayer = new OpenLayers.Layer.Vector(\"" . lang::get("LANG_Location_Layer") . "\",\n                                    {styleMap: locStyleMap});\n";
     if ($loadID) {
         // Can't cache these as data may have just changed
         data_entry_helper::$entity_to_load['occurrence:record_status'] = 'I';
         $url = $svcUrl . '/data/sample/' . $loadID;
         $url .= "?mode=json&view=detail&auth_token=" . $readAuth['auth_token'] . "&nonce=" . $readAuth["nonce"];
         $session = curl_init($url);
         curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
         $entity = json_decode(curl_exec($session), true);
         // Attributes should be loaded by get_attributes.
         data_entry_helper::$entity_to_load = array();
         foreach ($entity[0] as $key => $value) {
             data_entry_helper::$entity_to_load['sample:' . $key] = $value;
         }
         $url = $svcUrl . '/data/occurrence';
         $url .= "?mode=json&view=detail&auth_token=" . $readAuth['auth_token'] . "&nonce=" . $readAuth["nonce"] . "&sample_id=" . $loadID . "&deleted=FALSE";
         $session = curl_init($url);
         curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
         $entities = json_decode(curl_exec($session), true);
         foreach ($entities as $entity) {
             data_entry_helper::$entity_to_load['occurrence:record_status'] = $entity['record_status'];
             data_entry_helper::$entity_to_load['sc:' . $entity['taxa_taxon_list_id'] . ':' . $entity['id'] . ':present'] = true;
         }
         data_entry_helper::$entity_to_load['sample:geom'] = '';
         // value received from db is not WKT, which is assumed by all the code.
         data_entry_helper::$entity_to_load['sample:date'] = data_entry_helper::$entity_to_load['sample:date_start'];
         // bit of a bodge to get around vague dates.
     }
     $defAttrOptions = array('extraParams' => $readAuth);
     //    $r .= "<h1>MODE = ".$mode."</h1>";
     //    $r .= "<h2>readOnly = ".$readOnly."</h2>";
     $r = "<form method=\"post\" id=\"entry_form\">\n";
     // Get authorisation tokens to update and read from the Warehouse.
     $r .= $writeAuth;
     $r .= "<input type=\"hidden\" id=\"website_id\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />\n";
     $r .= "<input type=\"hidden\" id=\"sample:survey_id\" name=\"sample:survey_id\" value=\"" . $args['survey_id'] . "\" />\n";
     if (array_key_exists('sample:id', data_entry_helper::$entity_to_load)) {
         $r .= "<input type=\"hidden\" id=\"sample:id\" name=\"sample:id\" value=\"" . data_entry_helper::$entity_to_load['sample:id'] . "\" />\n";
     }
     // request automatic JS validation
     data_entry_helper::enable_validation('entry_form');
     $attributes = data_entry_helper::getAttributes(array('id' => data_entry_helper::$entity_to_load['sample:id'], 'valuetable' => 'sample_attribute_value', 'attrtable' => 'sample_attribute', 'key' => 'sample_id', 'fieldprefix' => 'smpAttr', 'extraParams' => $readAuth, 'survey_id' => $args['survey_id']));
     if ($logged_in) {
         // If logged in, output some hidden data about the user
         $uid = $user->uid;
         $email = $user->mail;
         $username = $user->name;
//.........这里部分代码省略.........
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:101,代码来源:mnhnl_collaborators_1.php

示例7: loadExistingGroup

 /**
  * Fetch an existing group's information from the database when editing.
  * @param integer $id Group ID
  * @param array $auth Authorisation tokens
  */
 private static function loadExistingGroup($id, $auth, $args)
 {
     $group = data_entry_helper::get_population_data(array('table' => 'group', 'extraParams' => $auth['read'] + array('view' => 'detail', 'id' => $_GET['group_id']), 'nocache' => true));
     $group = $group[0];
     if ($group['created_by_id'] !== hostsite_get_user_field('indicia_user_id')) {
         if (!function_exists('user_access') || !user_access('Iform groups admin')) {
             // user did not create group. So, check they are an admin
             $admins = data_entry_helper::get_population_data(array('table' => 'groups_user', 'extraParams' => $auth['read'] + array('group_id' => $_GET['group_id'], 'administrator' => 't'), 'nocache' => true));
             $found = false;
             foreach ($admins as $admin) {
                 if ($admin['user_id'] === hostsite_get_user_field('indicia_user_id')) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 throw new exception(lang::get('You are trying to edit a group you don\'t have admin rights to.'));
             }
         }
     }
     data_entry_helper::$entity_to_load = array('group:id' => $group['id'], 'group:title' => $group['title'], 'group:code' => $group['code'], 'group:group_type_id' => $group['group_type_id'], 'group:joining_method' => $group['joining_method'], 'group:description' => $group['description'], 'group:from_date' => $group['from_date'], 'group:to_date' => $group['to_date'], 'group:private_records' => $group['private_records'], 'group:filter_id' => $group['filter_id'], 'group:logo_path' => $group['logo_path'], 'filter:id' => $group['filter_id']);
     if ($args['include_report_filter']) {
         $def = $group['filter_definition'] ? $group['filter_definition'] : '{}';
         data_entry_helper::$javascript .= "indiciaData.filter.def={$def};\n";
     }
     if ($args['include_administrators'] || $args['include_members']) {
         $members = data_entry_helper::get_population_data(array('table' => 'groups_user', 'extraParams' => $auth['read'] + array('view' => 'detail', 'group_id' => $_GET['group_id']), 'nocache' => true));
         $admins = array();
         $others = array();
         foreach ($members as $member) {
             if ($member['administrator'] === 't') {
                 $admins[] = array('fieldname' => 'groups_user:user_id:' . $member['id'], 'caption' => $member['person_name'], 'default' => $member['user_id']);
             } else {
                 $others[] = array('fieldname' => 'groups_user:user_id:' . $member['id'], 'caption' => $member['person_name'], 'default' => $member['user_id']);
             }
         }
         data_entry_helper::$entity_to_load['groups_user:admin_user_id'] = $admins;
         data_entry_helper::$entity_to_load['groups_user:user_id'] = $others;
     }
 }
开发者ID:joewoodhouse,项目名称:client_helpers,代码行数:45,代码来源:group_edit.php

示例8: get_form_sampleoccurrence

 protected static function get_form_sampleoccurrence($args, $node)
 {
     // attributes must be fetched after the entity to load is filled in - this is because the id gets filled in then!
     $cancelUrl = self::$currentUrl;
     $cancelUrl .= strpos($cancelUrl, '?') === false ? '?' : '&';
     $cancelUrl .= "supersample_id=" . data_entry_helper::$entity_to_load['sample:parent_id'];
     $attributes = data_entry_helper::getAttributes(array('id' => data_entry_helper::$entity_to_load['sample:id'], 'valuetable' => 'sample_attribute_value', 'attrtable' => 'sample_attribute', 'key' => 'sample_id', 'fieldprefix' => 'smpAttr', 'extraParams' => self::$auth['read'], 'survey_id' => $args['survey_id']));
     if (self::$mode == MODE_EXISTING_OCCURRENCE && self::$gridmode == false && isset(data_entry_helper::$entity_to_load['sample:id'])) {
         $cloneEntity = data_entry_helper::$entity_to_load;
         $occList = data_entry_helper::preload_species_checklist_occurrences(data_entry_helper::$entity_to_load['sample:id'], self::$auth['read'], $args['occurrence_images']);
         foreach ($occList as $id => $taxon) {
             self::$occurrenceIds[] = $id;
         }
         if (count(self::$occurrenceIds) > 1) {
             self::$gridmode = true;
             data_entry_helper::$entity_to_load = $cloneEntity;
         }
     }
     // Make sure the form action points back to this page
     $r = "<form method=\"post\" id=\"entry_form\" action=\"" . self::$currentUrl . "\">\n";
     // Get authorisation tokens to update the Warehouse, plus any other hidden data.
     $hiddens = self::$auth['write'] . "<input type=\"hidden\" id=\"website_id\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />\n" . "<input type=\"hidden\" id=\"survey_id\" name=\"survey_id\" value=\"" . $args['survey_id'] . "\" />\n" . "<input type=\"hidden\" id=\"parent_id\" name=\"sample:parent_id\" value=\"" . data_entry_helper::$entity_to_load['sample:parent_id'] . "\" />\n" . "<input type=\"hidden\" id=\"date\" name=\"sample:date\" value=\"" . data_entry_helper::$entity_to_load['sample:date'] . "\" />\n";
     if (isset(data_entry_helper::$entity_to_load['sample:id'])) {
         $hiddens .= "<input type=\"hidden\" id=\"sample:id\" name=\"sample:id\" value=\"" . data_entry_helper::$entity_to_load['sample:id'] . "\" />\n";
     }
     // Check if Record Status is included as a control. If not, then add it as a hidden.
     $arr = explode("\r\n", $args['structure']);
     if (!in_array('[record status]', $arr)) {
         $value = isset($args['defaults']['occurrence:record_status']) ? $args['defaults']['occurrence:record_status'] : 'C';
         $hiddens .= "<input type=\"hidden\" id=\"occurrence:record_status\" name=\"occurrence:record_status\" value=\"{$value}\" />\n";
     }
     // request automatic JS validation
     if (!isset($args['clientSideValidation']) || $args['clientSideValidation']) {
         data_entry_helper::enable_validation('entry_form');
     }
     self::set_attribute_default_block($attributes);
     $tabs = self::get_all_tabs($args['occurrence_structure'], array());
     $r .= "<div id=\"controls\">\n";
     // Build a list of the tabs that actually have content
     $tabHtml = self::get_tab_html($tabs, self::$auth, $args, $attributes, $hiddens);
     // Output the dynamic tab headers
     $headerOptions = array('tabs' => array());
     foreach ($tabHtml as $tab => $tabContent) {
         $alias = preg_replace('/[^a-zA-Z0-9]/', '', strtolower($tab));
         $tabtitle = lang::get("LANG_Tab_{$alias}");
         if ($tabtitle == "LANG_Tab_{$alias}") {
             // if no translation provided, we'll just use the standard heading
             $tabtitle = $tab;
         }
         $headerOptions['tabs']['#' . $alias] = $tabtitle;
     }
     if ($args['interface'] != 'one_page') {
         $r .= data_entry_helper::tab_header($headerOptions);
         data_entry_helper::enable_tabs(array('divId' => 'controls', 'style' => $args['interface'], 'progressBar' => isset($args['tabProgress']) && $args['tabProgress'] == true));
     }
     // Output the dynamic tab content
     $pageIdx = 0;
     foreach ($tabHtml as $tab => $tabContent) {
         // get a machine readable alias for the heading
         $tabalias = preg_replace('/[^a-zA-Z0-9]/', '', strtolower($tab));
         $r .= '<div id="' . $tabalias . '">' . "\n";
         // For wizard include the tab title as a header.
         if ($args['interface'] != 'tabs') {
             $r .= '<h1>' . $headerOptions['tabs']['#' . $tabalias] . '</h1>';
         }
         $r .= $tabContent;
         // Add any buttons required at the bottom of the tab
         if ($args['interface'] == 'wizard') {
             $r .= data_entry_helper::wizard_buttons(array('classRedisplay' => 'ui-widget-content ui-state-default ui-corner-all indicia-button tab-submit-redisplay', 'captionSaveRedisplay' => 'save and redisplay', 'divId' => 'controls', 'page' => $pageIdx === 0 ? 'first' : ($pageIdx == count($tabs) - 1 ? 'last' : 'middle')));
         } elseif ($pageIdx == count($tabs) - 1 && !($args['interface'] == 'tabs' && $args['save_button_below_all_pages'])) {
             // last part of a non wizard interface must insert a save button, unless it is tabbed interface with save button beneath all pages
             $r .= "<input type=\"submit\" class=\"ui-state-default ui-corner-all\" value=\"" . lang::get('LANG_Save') . "\" />\n";
             $r .= "<input type=\"submit\" name=\"navigate:newoccurrence\" class=\"ui-state-default ui-corner-all\" value=\"" . lang::get('LANG_Save_and_New') . "\" />\n";
             $r .= "<input type=\"button\" class=\"ui-state-default ui-corner-all\"value=\"" . lang::get('LANG_Cancel') . "\" onclick=\"window.location.href='" . $cancelUrl . "'\" >\n";
         }
         $pageIdx++;
         $r .= "</div>\n";
     }
     $r .= "</div>\n";
     if ($args['interface'] == 'tabs' && $args['save_button_below_all_pages']) {
         $r .= "<input type=\"submit\" class=\"ui-state-default ui-corner-all\" value=\"" . lang::get('LANG_Save') . "\" />\n";
         $r .= "<input type=\"submit\" name=\"navigate:newoccurrence\" class=\"ui-state-default ui-corner-all\" value=\"" . lang::get('LANG_Save_and_New') . "\" />\n";
         $r .= "<input type=\"button\" class=\"ui-state-default ui-corner-all\" value=\"" . lang::get('LANG_Cancel') . "\" onclick=\"window.location.href='" . $cancelUrl . "'\" >\n";
     }
     if (!empty(data_entry_helper::$validation_errors)) {
         $r .= data_entry_helper::dump_remaining_errors();
     }
     $r .= "</form>";
     $url = self::$svcUrl . "/data/sample/" . data_entry_helper::$entity_to_load['sample:parent_id'];
     $url .= "?mode=json&view=detail&auth_token=" . self::$auth['read']['auth_token'] . "&nonce=" . self::$auth['read']['nonce'];
     $session = curl_init($url);
     curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
     $entity = json_decode(curl_exec($session), true);
     if (isset($entity['error'])) {
         throw new Exception($entity['error']);
     }
     data_entry_helper::$javascript .= "\n// Create a vector layer to display the supersample location\n// the default edit layer is used for the subsamples\nSSStyleMap = new OpenLayers.StyleMap({\n                \"default\": new OpenLayers.Style({\n                    fillColor: \"Green\",\n                    strokeColor: \"Black\",\n                    fillOpacity: 0.2,\n                    strokeWidth: 1\n                  })\n  });\nSSLayer = new OpenLayers.Layer.Vector(\"" . lang::get("LANG_Supersample_Layer") . "\",\n                                    {styleMap: SSStyleMap});\nSSparser = new OpenLayers.Format.WKT();\nSSfeature = SSparser.read('" . $entity[0]['wkt'] . "');\nSSLayer.addFeatures([SSfeature]);\n";
     // The map can get initialised an awful lot later (eg when the tab it is on is displayed).
     // It is therefore virtually impossible to zoom to this supersample in as the code is not templated
     return $r;
//.........这里部分代码省略.........
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:101,代码来源:mnhnl_dynamic_2.php

示例9: get_control_speciesidentifier


//.........这里部分代码省略.........
         }
     }
     // throw an exception if any of the required custom attributes is missing
     $errorMessages = array();
     foreach (array('baseColourId', 'textColourId', 'sequenceId', 'positionId', 'attachmentId', 'genderId', 'stageId', 'lifeStatusId', 'conditionsId') as $attrId) {
         if ($options[$attrId] === -1) {
             $errorMessages[] = lang::get('Required custom attribute for ' . $attrId . ' has not been found. ' . 'Please check this has been created on the warehouse and is associated with the correct system function.');
         }
     }
     if (count($errorMessages) > 0) {
         $errorMessage = implode('<br />', $errorMessages);
         throw new exception($errorMessage);
     }
     // configure the identifiers javascript
     // write it late so it happens after any locked values are applied
     if (!$options['inNewIndividual']) {
         data_entry_helper::$late_javascript .= "indicia.wwt.initForm (\n        '" . $options['baseColourId'] . "',\n        '" . $options['textColourId'] . "',\n        '" . $options['sequenceId'] . "',\n        '" . $options['positionId'] . "',\n        '" . $args['default_leg_vertical'] . "',\n        '" . (!empty($args['neck_collar_regex']) ? $args['neck_collar_regex'] : '') . "',\n        '" . (!empty($args['enscribed_colour_ring_regex']) ? $args['enscribed_colour_ring_regex'] : '') . "',\n        '" . (!empty($args['metal_ring_regex']) ? $args['metal_ring_regex'] : '') . "',\n        '" . ($args['clientSideValidation'] ? 'true' : 'false') . "',\n        '" . ($args['subjectAccordion'] ? 'true' : 'false') . "'\n" . ");\n";
     }
     $r = '';
     $options['fieldprefix'] = 'idn:' . $taxIdx . ':';
     if (!$options['inNewIndividual']) {
         $r .= '<div id="idn:subject:accordion" class="idn-subject-accordion">';
     }
     if ($args['subjectAccordion']) {
         $r .= '<h3 id="' . $options['fieldprefix'] . 'individual:header" class="individual_header"><a href="" data-heading="' . lang::get('Colour-marked Individual') . ' ' . ($taxIdx + 1) . '">' . lang::get('Colour-marked Individual') . ' ' . ($taxIdx + 1) . '</a></h3>';
     } else {
         $r .= '<h3 id="' . $options['fieldprefix'] . 'individual:header" class="individual_header" data-heading="' . lang::get('Colour-marked Individual') . ' ' . ($taxIdx + 1) . '">' . lang::get('Colour-marked Individual') . ' ' . ($taxIdx + 1) . '</h3>';
     }
     $r .= '<div id="' . $options['fieldprefix'] . 'individual:panel" class="individual_panel ui-corner-all">';
     $r .= '<div class="ui-helper-clearfix">';
     $r .= '<fieldset id="' . $options['fieldprefix'] . 'individual:fieldset" class="taxon_individual ui-corner-all">';
     $r .= '<legend id="' . $options['fieldprefix'] . 'individual:legend">Individual details</legend>';
     // output the hiddens
     if (isset(data_entry_helper::$entity_to_load[$options['fieldprefix'] . 'subject_observation:id'])) {
         $r .= '<input type="hidden" id="' . $options['fieldprefix'] . 'subject_observation:id" name="' . $options['fieldprefix'] . 'subject_observation:id" ' . 'value="' . data_entry_helper::$entity_to_load[$options['fieldprefix'] . 'subject_observation:id'] . '" />' . "\n";
     }
     if (isset(data_entry_helper::$entity_to_load[$options['fieldprefix'] . 'occurrences_subject_observation:id'])) {
         $r .= '<input type="hidden" id="' . $options['fieldprefix'] . 'occurrences_subject_observation:id" name="' . $options['fieldprefix'] . 'occurrences_subject_observation:id" ' . 'value="' . data_entry_helper::$entity_to_load[$options['fieldprefix'] . 'occurrences_subject_observation:id'] . '" />' . "\n";
     }
     if (isset(data_entry_helper::$entity_to_load[$options['fieldprefix'] . 'occurrence:id'])) {
         $r .= '<input type="hidden" id="' . $options['fieldprefix'] . 'occurrence:id" name="' . $options['fieldprefix'] . 'occurrence:id" ' . 'value="' . data_entry_helper::$entity_to_load[$options['fieldprefix'] . 'occurrence:id'] . '" />' . "\n";
     }
     // Check if Record Status is included as a control. If not, then add it as a hidden.
     $arr = helper_base::explode_lines($args['structure']);
     if (!in_array('[record status]', $arr)) {
         if (isset(data_entry_helper::$entity_to_load[$options['fieldprefix'] . 'occurrence:record_status'])) {
             $value = data_entry_helper::$entity_to_load[$options['fieldprefix'] . 'occurrence:record_status'];
         } else {
             $value = isset($args['defaults']['occurrence:record_status']) ? $args['defaults']['occurrence:record_status'] : 'C';
         }
         $r .= '<input type="hidden" id="' . $options['fieldprefix'] . 'occurrence:record_status" ' . 'name="' . $options['fieldprefix'] . 'occurrence:record_status" value="' . $value . '" />' . "\n";
     }
     // add subject type and count as a hidden
     $value = '';
     if (isset(data_entry_helper::$entity_to_load[$options['fieldprefix'] . 'subject_observation:subject_type_id'])) {
         $value = data_entry_helper::$entity_to_load[$options['fieldprefix'] . 'subject_observation:subject_type_id'];
     } else {
         if (isset($args['subject_type_id'])) {
             $value = $args['subject_type_id'];
         }
     }
     if ($value !== '') {
         $r .= '<input type="hidden" id="' . $options['fieldprefix'] . 'subject_observation:subject_type_id" ' . 'name="' . $options['fieldprefix'] . 'subject_observation:subject_type_id" value="' . $value . '" />' . "\n";
     }
     if (isset(data_entry_helper::$entity_to_load[$options['fieldprefix'] . 'subject_observation:count'])) {
         $value = data_entry_helper::$entity_to_load[$options['fieldprefix'] . 'subject_observation:count'];
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:67,代码来源:wwt_colour_marked_report.php

示例10: get_form

   /**
    * Return the generated form output.
    * @return Form HTML.
    */
   public static function get_form($args, $node)
   {
       define("MODE_GRID", 0);
       define("MODE_NEW_SAMPLE", 1);
       define("MODE_EXISTING", 2);
       self::parse_defaults($args);
       self::getArgDefaults($args);
       global $user;
       $logged_in = $user->uid > 0;
       self::$node = $node;
       // Get authorisation tokens to update and read from the Warehouse.
       $auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
       $svcUrl = data_entry_helper::$base_url . '/index.php/services';
       self::$auth = $auth;
       $mode = isset($args['no_grid']) && $args['no_grid'] ? MODE_NEW_SAMPLE : MODE_GRID;
       // default mode when no grid set to false - display grid of existing data
       // mode MODE_EXISTING: display existing sample
       $loadedSampleId = null;
       $loadedOccurrenceId = null;
       if ($_POST) {
           if (!array_key_exists('website_id', $_POST)) {
               // non Indicia POST, in this case must be the location allocations. add check to ensure we don't corrept the data by accident
               if (function_exists('iform_loctools_checkaccess') && iform_loctools_checkaccess($node, 'admin') && array_key_exists('mnhnld1', $_POST)) {
                   iform_loctools_deletelocations($node);
                   foreach ($_POST as $key => $value) {
                       $parts = explode(':', $key);
                       iform_loctools_insertlocation($node, $parts[2], $parts[1]);
                   }
               }
           } else {
               if (!is_null(data_entry_helper::$entity_to_load)) {
                   $mode = MODE_EXISTING;
                   // errors with new sample, entity populated with post, so display this data.
               }
           }
           // else valid save, so go back to gridview: default mode 0
       }
       if (array_key_exists('sample_id', $_GET) && $_GET['sample_id'] != '{sample_id}') {
           $mode = MODE_EXISTING;
           $loadedSampleId = $_GET['sample_id'];
       }
       if (array_key_exists('occurrence_id', $_GET) && $_GET['occurrence_id'] != '{occurrence_id}') {
           $mode = MODE_EXISTING;
           $loadedOccurrenceId = $_GET['occurrence_id'];
           self::$occurrenceIds = array($loadedOccurrenceId);
       }
       if ($mode != MODE_EXISTING && array_key_exists('newSample', $_GET)) {
           $mode = MODE_NEW_SAMPLE;
           data_entry_helper::$entity_to_load = array();
       }
       // else default to mode MODE_GRID or MODE_NEW_SAMPLE depending on no_grid parameter
       self::$mode = $mode;
       // default mode  MODE_GRID : display grid of the samples to add a new one
       // or edit an existing one.
       if ($mode == MODE_GRID) {
           $r = '';
           $attributes = data_entry_helper::getAttributes(array('valuetable' => 'sample_attribute_value', 'attrtable' => 'sample_attribute', 'key' => 'sample_id', 'fieldprefix' => 'smpAttr', 'extraParams' => $auth['read'], 'survey_id' => $args['survey_id']), false);
           $tabs = array('#sampleList' => lang::get('LANG_Main_Samples_Tab'));
           if ($args['includeLocTools'] && function_exists('iform_loctools_checkaccess') && iform_loctools_checkaccess($node, 'admin')) {
               $tabs['#setLocations'] = lang::get('LANG_Allocate_Locations');
           }
           if (method_exists(get_called_class(), 'getExtraGridModeTabs')) {
               $extraTabs = call_user_func(array(get_called_class(), 'getExtraGridModeTabs'), false, $auth['read'], $args, $attributes);
               if (is_array($extraTabs)) {
                   $tabs = $tabs + $extraTabs;
               }
           }
           if (count($tabs) > 1) {
               $r .= "<div id=\"controls\">" . data_entry_helper::enable_tabs(array('divId' => 'controls', 'active' => '#sampleList')) . "<div id=\"temp\"></div>";
               $r .= data_entry_helper::tab_header(array('tabs' => $tabs));
           }
           $r .= "<div id=\"sampleList\">" . call_user_func(array(get_called_class(), 'getSampleListGrid'), $args, $node, $auth, $attributes) . "</div>";
           if ($args['includeLocTools'] && function_exists('iform_loctools_checkaccess') && iform_loctools_checkaccess($node, 'admin')) {
               $r .= '
 <div id="setLocations">
   <form method="post">
     <input type="hidden" id="mnhnld1" name="mnhnld1" value="mnhnld1" /><table border="1"><tr><td></td>';
               $url = $svcUrl . '/data/location?mode=json&view=detail&auth_token=' . $auth['read']['auth_token'] . "&nonce=" . $auth['read']["nonce"] . "&parent_id=NULL&orderby=name";
               $session = curl_init($url);
               curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
               $entities = json_decode(curl_exec($session), true);
               $userlist = iform_loctools_listusers($node);
               foreach ($userlist as $uid => $a_user) {
                   $r .= '<td>' . $a_user->name . '</td>';
               }
               $r .= "</tr>";
               if (!empty($entities)) {
                   foreach ($entities as $entity) {
                       if (!$entity["parent_id"]) {
                           // only assign parent locations.
                           $r .= "<tr><td>" . $entity["name"] . "</td>";
                           $defaultuserids = iform_loctools_getusers($node, $entity["id"]);
                           foreach ($userlist as $uid => $a_user) {
                               $r .= '<td><input type="checkbox" name="location:' . $entity["id"] . ':' . $uid . (in_array($uid, $defaultuserids) ? '" checked="checked"' : '"') . '></td>';
                           }
                           $r .= "</tr>";
//.........这里部分代码省略.........
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:101,代码来源:mnhnl_dynamic_1.php

示例11: cloneEntity

 protected static function cloneEntity($args, $auth, &$attributes)
 {
     // First modify the sample attribute information in the $attributes array.
     // Set the sample attribute fieldnames as for a new record
     foreach ($attributes as $attributeKey => $attributeValue) {
         if ($attributeValue['multi_value'] == 't') {
             // Set the attribute fieldname to the attribute id plus brackets for multi-value attributes
             $attributes[$attributeKey]['fieldname'] = $attributeValue['id'] . '[]';
             foreach ($attributeValue['default'] as $defaultKey => $defaultValue) {
                 //Fixed a problem with a checkbox_group that the client reported as not saving after cloning. The problem is the value field was also including the fieldname which was
                 //preventing save, so I have removed the fieldname from the defaults list here. I don't have time to test all the scenarios for this, so to be safe I have just made it
                 //so the fix is only applied to the checkbox_group, if we find there are problems with other types of multi-value control then this check can be removed, but as we only
                 //have one reported issue and I can't test all the scenarios I have left in this checkbox_group check to avoid breaking existing code that I can't test.
                 if (isset($attributeValue['control_type']) && $attributeValue['control_type'] === 'checkbox_group') {
                     unset($attributes[$attributeKey]['default'][$defaultKey]['fieldname']);
                 } else {
                     $attributes[$attributeKey]['default'][$defaultKey]['fieldname'] = $attributeValue['id'] . '[]';
                 }
             }
         } else {
             // Set the attribute fieldname to the attribute id for single values
             $attributes[$attributeKey]['fieldname'] = $attributeValue['id'];
         }
     }
     // Now load the occurrences and their attributes.
     // @todo: Convert to occurrences media capabilities.
     $loadImages = $args['occurrence_images'];
     $subSamples = array();
     data_entry_helper::preload_species_checklist_occurrences(data_entry_helper::$entity_to_load['sample:id'], $auth['read'], $loadImages, array(), $subSamples, false);
     // If using a species grid $entity_to_load will now contain elements in the form
     //  sc:row_num:occ_id:occurrence:field_name
     //  sc:row_num:occ_id:present
     //  sc:row_num:occ_id:occAttr:occAttr_id:attrValue_id
     // We are going to strip out the occ_id and the attrValue_id
     $keysToDelete = array();
     $elementsToAdd = array();
     foreach (data_entry_helper::$entity_to_load as $key => $value) {
         $parts = explode(':', $key);
         // Is this an occurrence?
         if ($parts[0] === 'sc') {
             // We'll be deleting this
             $keysToDelete[] = $key;
             // And replacing it
             $parts[2] = '';
             if (count($parts) == 6) {
                 unset($parts[5]);
             }
             $keyToCreate = implode(':', $parts);
             $elementsToAdd[$keyToCreate] = $value;
         }
     }
     foreach ($keysToDelete as $key) {
         unset(data_entry_helper::$entity_to_load[$key]);
     }
     data_entry_helper::$entity_to_load = array_merge(data_entry_helper::$entity_to_load, $elementsToAdd);
     // Unset the sample and occurrence id from entitiy_to_load as for a new record.
     unset(data_entry_helper::$entity_to_load['sample:id']);
     unset(data_entry_helper::$entity_to_load['occurrence:id']);
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:59,代码来源:dynamic_sample_occurrence.php

示例12: getEntity

 protected static function getEntity($args, $auth)
 {
     data_entry_helper::$entity_to_load = array();
     //If a zoom_id is supplied, it means we are moving into add mode but for a specific region
     //So we want an empty page but the map should be zoomed in to the location boundary.
     //This boundary acts as a ghost, so it isn't actually submitted, it is purely visual.
     if (!empty($_GET['zoom_id'])) {
         self::zoom_map($auth, $_GET['zoom_id'], $args);
     } else {
         //Note:
         //When the user selects a boundary, the page is reloaded with an additional parent_id parameter in the url.
         //In this case, we use the parent_id as the main record id, the system then uses the location_id to load boundary information
         //for the main record.
         if (!empty($_GET['parent_id'])) {
             $recordId = $_GET['parent_id'];
         } elseif (!empty($_GET['location_id'])) {
             $recordId = $_GET['location_id'];
         }
         if (!empty($recordId)) {
             self::load_existing_record($args, $auth, 'location', $recordId);
         }
     }
 }
开发者ID:joewoodhouse,项目名称:client_helpers,代码行数:23,代码来源:cudi_form.php

示例13: getEntity

 protected static function getEntity($args, $auth)
 {
     data_entry_helper::$entity_to_load = array();
     data_entry_helper::load_existing_record($auth['read'], 'person', $_GET['person_id'], 'detail', false, false);
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:5,代码来源:dynamic_person.php

示例14: get_form

 /**
  * Return the generated form output.
  * @return Form HTML.
  */
 public static function get_form($args, $node, $response = null)
 {
     global $user;
     $logged_in = $user->uid > 0;
     $r = '';
     // Get authorisation tokens to update and read from the Warehouse.
     $writeAuth = data_entry_helper::get_auth($args['website_id'], $args['password']);
     $readAuth = data_entry_helper::get_read_auth($args['website_id'], $args['password']);
     $svcUrl = data_entry_helper::$base_url . '/index.php/services';
     $presetLayers = array();
     // read out the activated preset layers
     if (isset($args['preset_layers'])) {
         foreach ($args['preset_layers'] as $layer => $active) {
             if ($active !== 0) {
                 $presetLayers[] = $layer;
             }
         }
     }
     // When invoked by GET there are the following modes:
     // Not logged in: Display an information message.
     // No additional arguments: display the survey selector.
     // Additional argument - newSample: display the main page, no occurrence or occurrence list tabs. Survey tab active.
     // Additional argument - sample_id=<id>: display the main page, fill in the main sample details, "Add Occurrence" tab present, survey tab active.
     // Additional argument - occurrence_id=<id>: display the main page, fill in the main sample details, "Add Occurrence" tab active.
     $mode = 0;
     // default mode : display survey selector
     // mode 1: display new sample: no occurrence list or add occurrence tabs. Survey tab active
     // mode 2: display existing sample. Survey tab active. No occurence details filled in.
     // mode 3: display existing occurrence. Add Occurrence tab active. Occurence details filled in.
     // mode 4: NO LONGER USED. display Occurrence List. Occurrence List tab active. No occurence details filled in.
     $readOnly = false;
     // On top of this, things can be flagged as readonly. RO mode 2+4 means no Add Occurrence tab.
     if (!$logged_in) {
         return lang::get('LANG_not_logged_in');
     }
     $parentSample = array();
     $parentErrors = null;
     $parentLoadID = null;
     $childSample = array();
     $childErrors = null;
     $childLoadID = null;
     $saveErrors = data_entry_helper::$validation_errors;
     $thisOccID = -1;
     // IDs have to be >0, so this is outside the valid range
     $displayThisOcc = true;
     // when populating from the DB rather than POST we have to be
     // careful with selection object, as geom in wrong format.
     if ($_POST) {
         if (array_key_exists('website_id', $_POST)) {
             // Indicia POST, already handled.
             if (array_key_exists('newSample', $_GET)) {
                 if (!is_null(data_entry_helper::$entity_to_load)) {
                     $mode = 1;
                     // errors with new sample, entity populated with post, so display this data.
                     $parentSample = data_entry_helper::$entity_to_load;
                     $parentErrors = $saveErrors;
                 } else {
                     // else new sample just saved, so reload it ready to add occurrences
                     // OR, child sample/occurrence saved against new parent sample, in which case parent sample is in the post.
                     $mode = 2;
                     $parentLoadID = array_key_exists('sample:parent_id', $_POST) ? $_POST['sample:parent_id'] : $response['outer_id'];
                 }
             } else {
                 // could have saved parent sample or child sample/occurrence pair.
                 if (array_key_exists('sample:parent_id', $_POST)) {
                     // have saved child sample/occurrence pair
                     $parentLoadID = $_POST['sample:parent_id'];
                     // load the parent sample.
                     $mode = 3;
                     if (isset(data_entry_helper::$entity_to_load)) {
                         // errors so display Edit Occurrence page.
                         $childSample = data_entry_helper::$entity_to_load;
                         $childErrors = $saveErrors;
                         $displayThisOcc = false;
                         if ($childSample['occurrence:id']) {
                             $thisOccID = $childSample['occurrence:id'];
                         }
                     }
                 } else {
                     // saved parent record. display updated parent, no child.
                     $mode = 2;
                     // display parent sample details, whether errors or not.
                     if (isset(data_entry_helper::$entity_to_load)) {
                         // errors so use posted data.
                         $parentSample = data_entry_helper::$entity_to_load;
                         $parentErrors = $saveErrors;
                     } else {
                         $parentLoadID = $_POST['sample:id'];
                         // load the parent sample.
                     }
                 }
             }
         } else {
             // non Indicia POST, in this case must be the location allocations. add check to ensure we don't corrept the data by accident
             if (iform_loctools_checkaccess($node, 'admin') && array_key_exists('mnhnlbtw', $_POST)) {
                 iform_loctools_deletelocations($node);
//.........这里部分代码省略.........
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:101,代码来源:mnhnl_bird_transect_walks.php

示例15: get_form


//.........这里部分代码省略.........
           foreach ($entity[0] as $key => $value) {
               $childSample['sample:' . $key] = $value;
           }
           $childSample['sample:geom'] = '';
           // value received from db is not WKT, which is assumed by all the code.
           $thisOccID = $childLoadID;
           // this will be used to load the occurrence into the editlayer.
           $childSample['taxon'] = $childSample['occurrence:taxon'];
           $parentLoadID = $childSample['sample:parent_id'];
       }
       if ($parentLoadID) {
           // load the container master sample
           $url = $svcUrl . '/data/sample/' . $parentLoadID;
           $url .= "?mode=json&view=detail&auth_token=" . $readAuth['auth_token'] . "&nonce=" . $readAuth["nonce"];
           $session = curl_init($url);
           curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
           $entity = json_decode(curl_exec($session), true);
           $parentSample = array();
           foreach ($entity[0] as $key => $value) {
               $parentSample['sample:' . $key] = $value;
           }
           if (is_array($locations) && !in_array($entity[0]["location_id"], $locations)) {
               return '<p>' . lang::get('LANG_No_Access_To_Location') . '</p>';
           }
           if ($entity[0]["parent_id"]) {
               return '<p>' . lang::get('LANG_No_Access_To_Sample') . '</p>';
           }
           $parentSample['sample:date'] = $parentSample['sample:date_start'];
           // bit of a bodge
           // default values for attributes from DB are picked up automatically.
       }
       $childSample['sample:date'] = $parentSample['sample:date'];
       // enforce a match between child and parent sample dates
       data_entry_helper::$entity_to_load = $parentSample;
       $attributes = data_entry_helper::getAttributes(array('id' => data_entry_helper::$entity_to_load['sample:id'], 'valuetable' => 'sample_attribute_value', 'attrtable' => 'sample_attribute', 'key' => 'sample_id', 'fieldprefix' => 'smpAttr', 'extraParams' => $readAuth));
       $closedFieldName = $attributes[$args['sample_closure_id']]['fieldname'];
       $closedFieldValue = data_entry_helper::check_default_value($closedFieldName, array_key_exists('default', $attributes[$args['sample_closure_id']]) ? $attributes[$args['sample_closure_id']]['default'] : '0');
       // default is not closed
       $adminPerm = 'IForm node ' . $node->nid . ' admin';
       if ($closedFieldValue == '1' && !user_access($adminPerm)) {
           // sample has been closed, no admin perms. Everything now set to read only.
           $surveyReadOnly = true;
           $disabledText = "disabled=\"disabled\"";
           $defAttrOptions = array('extraParams' => $readAuth, 'disabled' => $disabledText);
       } else {
           // sample open.
           $disabledText = "";
           $defAttrOptions = array('extraParams' => $readAuth);
       }
       // with the AJAX code, we deal with the validation semi manually: Form name is meant be invalid as we only want code included.
       data_entry_helper::enable_validation('DummyForm');
       $r .= "<div id=\"controls\">\n";
       $activeTab = 'survey';
       // mode 1 = new Sample, display sample.
       if ($mode == 2) {
           // have specified a sample ID
           if ($args["on_edit_survey_nav"] == "survey") {
               $activeTab = 'survey';
           } else {
               if ($surveyReadOnly || $args["on_edit_survey_nav"] == "list") {
                   $activeTab = 'occurrenceList';
               } else {
                   $activeTab = 'occurrence';
               }
           }
           if ($surveyReadOnly) {
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:67,代码来源:mnhnl_bird_transect_walks.php


注:本文中的data_entry_helper::entity_to_load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。