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


PHP data_entry_helper::wrap_with_attrs方法代码示例

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


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

示例1: get_submission

 /**
  * Handles the construction of a submission array from a set of form values.
  * @param array $values Associative array of form data values. 
  * @param array $args iform parameters. 
  * @return array Submission structure.
  */
 public static function get_submission($values, $args)
 {
     $sampleMod = data_entry_helper::wrap_with_attrs($values, 'sample');
     if (isset($values['sample:deleted'])) {
         return $sampleMod;
     }
     $subsamples = array();
     // first do transect grid
     for ($i = 0; $i < 5; $i++) {
         // Fieldname is TG:speciesID:gridX:gridY:GridsampleID:OccID:AttrID
         for ($j = 0; $j < 5; $j++) {
             $sa = array('fkId' => 'parent_id', 'model' => array('id' => 'sample', 'fields' => array()));
             if (isset($values['TGS:' . $j * 2 . ':' . $i * 2])) {
                 $sa['model']['fields']['id'] = array('value' => $values['TGS:' . $j * 2 . ':' . $i * 2]);
             }
             $sa['model']['fields']['date'] = array('value' => $values['sample:date']);
             $sa['model']['fields']['location_id'] = array('value' => $values['sample:location_id']);
             $sa['model']['fields']['location_name'] = array('value' => 'GR ' . $values['sample:location_name'] . ' ' . $j * 2 . $i * 2);
             $sa['model']['fields']['website_id'] = array('value' => $values['website_id']);
             $sa['model']['fields']['survey_id'] = array('value' => $values['survey_id']);
             $suboccs = array();
             foreach ($values as $key => $value) {
                 $parts = explode(':', $key);
                 if ($parts[0] == 'TG' && $parts[2] == (string) ($j * 2) && $parts[3] == (string) ($i * 2)) {
                     $occ = array('fkId' => 'sample_id', 'model' => array('id' => 'occurrence', 'fields' => array()));
                     $occ['model']['fields']['taxa_taxon_list_id'] = array('value' => $parts[1]);
                     $occ['model']['fields']['website_id'] = array('value' => $values['website_id']);
                     if ($parts[5] != '-') {
                         $occ['model']['fields']['id'] = array('value' => $parts[5]);
                     }
                     $attrFields = array('occurrence_attribute_id' => $args['qual_dist_attr_id'], 'value' => $value);
                     if ($parts[6] != '-') {
                         $attrFields['id'] = $parts[6];
                     }
                     $occ['model']['metaFields'] = array('occAttributes' => array('value' => array(array('id' => 'occurrence', 'fields' => $attrFields))));
                     if ($parts[5] != '-' || $value != $args['ignore_qual_dist_id']) {
                         $suboccs[] = $occ;
                     }
                 }
             }
             $sa['model']['subModels'] = $suboccs;
             if (isset($sa['model']['fields']['id']) || count($suboccs) > 0) {
                 $subsamples[] = $sa;
             }
         }
     }
     // next do section list
     for ($i = 1; $i <= $args['max_number_sections']; $i++) {
         // Fieldname is SL:speciesID:section:SectionsampleID:OccID:AttrID
         $sa = array('fkId' => 'parent_id', 'model' => array('id' => 'sample', 'fields' => array()));
         if (isset($values['SLS:' . $i])) {
             $sa['model']['fields']['id'] = array('value' => $values['SLS:' . $i]);
         }
         $sa['model']['fields']['date'] = array('value' => $values['sample:date']);
         $sa['model']['fields']['location_id'] = array('value' => $values['sample:location_id']);
         $sa['model']['fields']['location_name'] = array('value' => 'SL ' . $values['sample:location_name'] . ' ' . $i);
         $sa['model']['fields']['website_id'] = array('value' => $values['website_id']);
         $sa['model']['fields']['survey_id'] = array('value' => $values['survey_id']);
         $saattrs = array();
         foreach ($values as $key => $value) {
             $parts = explode(':', $key);
             if ($parts[0] == 'SLA' && $parts[1] == (string) $i) {
                 // Fieldname is SLA:section:SectionsampleID:AttrValID:AttrID
                 $attr = array("id" => "sample", "fields" => array());
                 $attr['fields']['sample_attribute_id'] = $parts[4];
                 if ($parts[3] != '-') {
                     $attr['fields']['id'] = $parts[3];
                 }
                 $attr['fields']['value'] = $value;
                 if ($parts[3] != '-' || $value != '') {
                     $saattrs[] = $attr;
                 }
             }
         }
         if (count($saattrs) > 0) {
             $sa['model']['metaFields'] = array('smpAttributes' => array('value' => $saattrs));
         }
         $suboccs = array();
         foreach ($values as $key => $value) {
             $parts = explode(':', $key);
             if ($parts[0] == 'SL' && $parts[2] == (string) $i) {
                 // Fieldname is SL:speciesID:section:SectionsampleID:OccID:AttrValID
                 $occ = array('fkId' => 'sample_id', 'model' => array('id' => 'occurrence', 'fields' => array('taxa_taxon_list_id' => array('value' => $parts[1]), 'website_id' => array('value' => $values['website_id']))));
                 if ($parts[4] != '-') {
                     $occ['model']['fields']['id'] = array('value' => $parts[4]);
                 }
                 if ($parts[5] != '-' || $value != '') {
                     $occ['model']['fields']['occAttr:' . $args['quant_dist_attr_id'] . ($parts[5] != '-' ? ':' . $parts[5] : '')] = array('value' => $value);
                     $suboccs[] = $occ;
                 }
             }
         }
         $sa['model']['subModels'] = $suboccs;
         if (isset($sa['model']['fields']['id']) || count($suboccs) > 0 || count($saattrs) > 0) {
//.........这里部分代码省略.........
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:101,代码来源:mnhnl_butterflies.php

示例2: get_submission

 /**
  * Handles the construction of a submission array from a set of form values.
  * @param array $values Associative array of form data values. 
  * @param array $args iform parameters. 
  * @return array Submission structure.
  */
 public static function get_submission($values, $args)
 {
     if (isset($values['source'])) {
         // comes from main Sites tab, Admins may create so need to check for locations_website entry
         $locModel = submission_builder::wrap_with_images($values, 'location');
         if (isset($values['locations_website:website_id'])) {
             // assume no other submodels
             $locModel['subModels'] = array(array('fkId' => 'location_id', 'model' => array('id' => 'locations_website', 'fields' => array('website_id' => array('value' => $values['locations_website:website_id'])))));
         }
         return $locModel;
     }
     if (isset($values['sample:recorder_names'])) {
         if (is_array($values['sample:recorder_names'])) {
             $values['sample:recorder_names'] = implode("\r\n", $values['sample:recorder_names']);
         }
     }
     // else just load the string
     $sampleMod = data_entry_helper::wrap_with_attrs($values, 'sample');
     if (isset($values['sample:deleted'])) {
         return $sampleMod;
     }
     $subsamples = array();
     $locations = array();
     foreach ($values as $key => $value) {
         $parts = explode(':', $key, 4);
         //     $cloneprefix='CG:--rownum--:--sampleid--:smpAttr:--attr_id--[:--attr_value_id--]
         //     $cloneprefix='CG:--rownum--:--sampleid--:smpAttr:--attr_id--\[\] for a multivalue checkbox group, with an array value
         if ($parts[0] == 'CG' && count($parts) > 1 && $parts[1] != '--rownum--' && $parts[1] != '') {
             $field = explode(':', $parts[3]);
             if ($field[0] == 'location') {
                 $locations[$parts[1]][$field[1]] = array('value' => $value);
                 $locations[$parts[1]]['website_id'] = array('value' => $values['website_id']);
                 $locations[$parts[1]]['survey_id'] = array('value' => $values['survey_id']);
             } else {
                 if ($parts[2] != "--sampleid--" && $parts[2] != "") {
                     $subsamples[$parts[1]]['id'] = array('value' => $parts[2]);
                 }
                 if (is_array($value)) {
                     for ($i = count($value) - 1; $i >= 0; $i--) {
                         // reverse order so we can unset array members.
                         $tokens = explode(':', $value[$i], 5);
                         // need to discard the CG prefix
                         if (count($tokens) > 1) {
                             unset($value[$i]);
                             $subsamples[$parts[1]][$tokens[4]] = array('value' => $tokens[0]);
                         }
                     }
                     if (count($value) > 0) {
                         // sweep up any new ones.
                         $subsamples[$parts[1]][$parts[3]] = array('value' => $value);
                     }
                 } else {
                     $subsamples[$parts[1]][$parts[3]] = array('value' => $value);
                 }
                 $subsamples[$parts[1]]['website_id'] = array('value' => $values['website_id']);
                 $subsamples[$parts[1]]['survey_id'] = array('value' => $values['survey_id']);
             }
         }
     }
     // locations and subsamples arrays are indexed by cgrownum.
     // next create an array of subsample models with their occurrences attached.
     $subsamples2 = array();
     $newsgrowContents = array();
     // array indexed on sgrownum of subarrays of samples which have new occurrences
     ksort($subsamples);
     // by cgrownum
     foreach ($subsamples as $sampleIndex => $subsampleFields) {
         if (isset($subsampleFields['date']) && $subsampleFields['date']['value'] != "") {
             $subsampleFields['location_name'] = $subsampleFields['name'];
             $subsample = array('fkId' => 'parent_id', 'model' => array('id' => 'sample', 'fields' => $subsampleFields));
             if (isset($locations[$sampleIndex])) {
                 $locweb = array('fkId' => 'location_id', 'model' => array('id' => 'locations_website', 'fields' => array('website_id' => array('value' => $values['website_id']))));
                 $locations[$sampleIndex]['name'] = $subsampleFields['name'];
                 $locations[$sampleIndex]['parent_id'] = array('value' => $values['sample:location_id']);
                 $locations[$sampleIndex]['centroid_sref_system'] = array('value' => $values['location:centroid_sref_system']);
                 $subsample['model']['superModels'] = array(array('fkId' => 'location_id', 'model' => array('id' => 'location', 'fields' => $locations[$sampleIndex], 'subModels' => array($locweb))));
             }
             $occs = array();
             foreach ($values as $key => $value) {
                 $parts = explode(':', $key, 7);
                 // SG:--sgrownum--:--cgrownum--:--sampleid--:--ttlid--:--occid--:occAttr:--attr_id--[:--attr_value_id--]
                 if ($parts[0] == 'SG' && count($parts) > 1 && $parts[4] != '--ttlid--' && $parts[4] != '' && $parts[2] == $sampleIndex && ($parts[5] != "--occid--" && $parts[5] != "" || $value != "")) {
                     $occ = array('fkId' => 'sample_id', 'model' => array('id' => 'occurrence', 'fields' => array('taxa_taxon_list_id' => array('value' => $parts[4]), 'website_id' => array('value' => $values['website_id']), 'survey_id' => array('value' => $values['survey_id']), $parts[6] => array('value' => $value))));
                     if ($value == "") {
                         $occ['model']['fields']['deleted'] = array('value' => 't');
                         unset($occ['model']['fields'][$parts[6]]);
                     }
                     if ($parts[5] != "--occid--" && $parts[5] != "") {
                         $occ['model']['fields']['id'] = array('value' => $parts[5]);
                     } else {
                         if (!isset($newsgrowContents[intval($parts[1])])) {
                             $newsgrowContents[intval($parts[1])] = array();
                         }
                         $newsgrowContents[intval($parts[1])][] = $sampleIndex;
//.........这里部分代码省略.........
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:101,代码来源:mnhnl_butterflies2.php

示例3: build_sample_occurrences_list_submission

 /**
  * Helper function to simplify building of a submission that contains a single sample
  * and multiple occurrences records generated by a species_checklist control.
  *
  * @param array $values List of the posted values to create the submission from.
  * @param boolean $include_if_any_data If true, then any list entry which has any data
  * set will be included in the submission. Set this to true when hiding the select checkbox
  * in the grid.
  * @return array Sample submission array
  */
 public static function build_sample_occurrences_list_submission($values, $include_if_any_data = false)
 {
     // We're mainly submitting to the sample model
     $sampleMod = data_entry_helper::wrap_with_attrs($values, 'sample');
     $occurrences = data_entry_helper::wrap_species_checklist($values, $include_if_any_data);
     // Add the occurrences in as subModels
     $sampleMod['subModels'] = $occurrences;
     return $sampleMod;
 }
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:19,代码来源:data_entry_helper.php

示例4: get_submission

 /**
  * Handles the construction of a submission array from a set of form values.
  * @param array $values Associative array of form data values.
  * @param array $args iform parameters.
  * @return array Submission structure.
  */
 public static function get_submission($values, $args)
 {
     if (isset($values['sample:parent_id'])) {
         $sampleMod = data_entry_helper::build_sample_occurrence_submission($values);
     } else {
         $sampleMod = data_entry_helper::wrap_with_attrs($values, 'sample');
     }
     return $sampleMod;
 }
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:15,代码来源:mnhnl_bird_transect_walks.php


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