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


PHP data_entry_helper::species_checklist_prepare_attributes方法代码示例

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


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

示例1: mnhnl_reptiles_species_checklist

 public static function mnhnl_reptiles_species_checklist()
 {
     global $indicia_templates;
     $options = data_entry_helper::check_arguments(func_get_args(), array('listId', 'occAttrs', 'readAuth', 'extraParams', 'lookupListId'));
     $options = data_entry_helper::get_species_checklist_options($options);
     data_entry_helper::add_resource('json');
     data_entry_helper::add_resource('autocomplete');
     $occAttrControls = array();
     $occAttrs = array();
     // Load any existing sample's occurrence data into $entity_to_load
     $subSamples = array();
     if (isset(data_entry_helper::$entity_to_load['sample:id'])) {
         data_entry_helper::preload_species_checklist_occurrences(data_entry_helper::$entity_to_load['sample:id'], $options['readAuth'], false, array(), $subSamples, false);
     }
     // load the full list of species for the grid, including the main checklist plus any additional species in the reloaded occurrences.
     $options['extraParams']['view'] = 'detail';
     $occList = self::get_species_checklist_occ_list($options);
     // If we managed to read the species list data we can proceed
     if (!array_key_exists('error', $occList)) {
         $attributes = data_entry_helper::getAttributes(array('id' => null, 'valuetable' => 'occurrence_attribute_value', 'attrtable' => 'occurrence_attribute', 'key' => 'occurrence_id', 'fieldprefix' => "{fieldname}", 'extraParams' => $options['readAuth'], 'survey_id' => array_key_exists('survey_id', $options) ? $options['survey_id'] : null));
         // Get the attribute and control information required to build the custom occurrence attribute columns
         data_entry_helper::species_checklist_prepare_attributes($options, $attributes, $occAttrControls, $occAttrs);
         $grid = "<p>" . lang::get('LANG_SpeciesInstructions') . "</p>\n";
         if (isset($options['lookupListId'])) {
             $grid .= self::get_species_checklist_clonable_row($options, $occAttrControls, $attributes);
         }
         $grid .= '<table class="ui-widget ui-widget-content mnhnl-species-grid ' . $options['class'] . '" id="' . $options['id'] . '">';
         $grid .= self::get_species_checklist_header($options, $occAttrs);
         $rows = array();
         $rowIdx = 0;
         foreach ($occList as $occ) {
             $ttlid = $occ['taxon']['id'];
             $firstCell = data_entry_helper::mergeParamsIntoTemplate($occ['taxon'], 'taxon_label', false, true);
             if ($options['PHPtaxonLabel']) {
                 $firstCell = eval($firstCell);
             }
             $colspan = ' colspan="' . count($attributes) . '"';
             // assume always removeable and presence is hidden.
             $firstrow = '<td class="ui-state-default remove-row" style="width: 1%" rowspan="' . ($options['occurrenceComment'] ? "3" : "2") . '" >X</td>';
             $firstrow .= str_replace('{content}', $firstCell, str_replace('{colspan}', $colspan, $indicia_templates['taxon_label_cell']));
             $existing_record_id = $occ['id'];
             $hidden = $options['rowInclusionCheck'] == 'checkbox' ? '' : ' style="display:none"';
             if ($options['rowInclusionCheck'] == 'alwaysFixed' || $options['rowInclusionCheck'] == 'alwaysRemovable' || data_entry_helper::$entity_to_load != null && array_key_exists("sc:{$ttlid}:{$existing_record_id}:present", data_entry_helper::$entity_to_load)) {
                 $checked = ' checked="checked"';
             } else {
                 $checked = '';
             }
             $secondrow = "<td class=\"scPresenceCell\"{$hidden}>" . ($options['rowInclusionCheck'] != 'hasData' ? "<input type=\"hidden\" class=\"scPresence\" name=\"sc:{$ttlid}:{$existing_record_id}:present\" value=\"0\"/><input type=\"checkbox\" class=\"scPresence\" name=\"sc:{$ttlid}:{$existing_record_id}:present\" {$checked} />" : '') . "</td>";
             foreach ($occAttrControls as $attrId => $control) {
                 if ($existing_record_id) {
                     $search = preg_grep("/^sc:" . $ttlid . "[_[0-9]*]?:{$existing_record_id}:occAttr:{$attrId}" . '[:[0-9]*]?$/', array_keys(data_entry_helper::$entity_to_load));
                     $ctrlId = count($search) === 1 ? implode('', $search) : "sc:{$ttlid}:{$existing_record_id}:occAttr:{$attrId}";
                 } else {
                     $ctrlId = "sc:{$ttlid}:x{$rowIdx}:occAttr:{$attrId}";
                 }
                 if (isset(data_entry_helper::$entity_to_load[$ctrlId])) {
                     $existing_value = data_entry_helper::$entity_to_load[$ctrlId];
                 } elseif (array_key_exists('default', $attributes[$attrId])) {
                     $existing_value = $attributes[$attrId]['default'];
                 } else {
                     $existing_value = '';
                 }
                 $oc = str_replace('{fieldname}', $ctrlId, $control);
                 if (!empty($existing_value)) {
                     // For select controls, specify which option is selected from the existing value
                     if (substr($oc, 0, 7) == '<select') {
                         $oc = str_replace('value="' . $existing_value . '"', 'value="' . $existing_value . '" selected="selected"', $oc);
                     } else {
                         if (strpos($oc, 'checkbox') !== false) {
                             if ($existing_value == "1") {
                                 $oc = str_replace('type="checkbox"', 'type="checkbox" checked="checked"', $oc);
                             }
                         } else {
                             $oc = str_replace('value=""', 'value="' . $existing_value . '"', $oc);
                         }
                     }
                     // assume all error handling/validation done client side
                 }
                 $secondrow .= str_replace(array('{label}', '{content}'), array(lang::get($attributes[$attrId]['caption']), $oc), $indicia_templates[$options['attrCellTemplate']]);
             }
             $thirdrow = "";
             if ($options['occurrenceComment']) {
                 $thirdrow .= "\n<td class=\"ui-widget-content scCommentCell\" {$colspan}><label for=\"sc:{$ttlid}:{$existing_record_id}:occurrence:comment\" class=\"auto-width\" >" . lang::get("Comment") . " : </label><input class=\"scComment\" type=\"text\" name=\"sc:{$ttlid}:{$existing_record_id}:occurrence:comment\" " . "id=\"sc:{$ttlid}:{$existing_record_id}:occurrence:comment\" value=\"" . htmlspecialchars(data_entry_helper::$entity_to_load["sc:{$ttlid}:{$existing_record_id}:occurrence:comment"]) . "\" /></td>";
             }
             $rows[] = '<tr>' . $firstrow . '</tr>';
             $rows[] = '<tr class="scMeaning-' . $occ['taxon']['taxon_meaning_id'] . ' scDataRow">' . $secondrow . '</tr>';
             // no images.
             if ($thirdrow != "") {
                 $rows[] = '<tr class="scMeaning-' . $occ['taxon']['taxon_meaning_id'] . ' scDataRow">' . $thirdrow . '</tr>';
             }
             // no images.
             $rowIdx++;
         }
         $grid .= "\n<tbody>\n";
         if (count($rows) > 0) {
             $grid .= implode("\n", $rows) . "\n";
         } else {
             $grid .= "<tr style=\"display: none\"><td></td></tr>\n";
         }
         $grid .= "</tbody>\n</table>\n";
//.........这里部分代码省略.........
开发者ID:joewoodhouse,项目名称:client_helpers,代码行数:101,代码来源:mnhnl_reptiles.php

示例2: my_species_checklist

 public static function my_species_checklist($options)
 {
     global $indicia_templates;
     $base = base_path();
     if (substr($base, -1) != '/') {
         $base .= '/';
     }
     $indicia_templates['taxon_label'] = '{taxon}<br/><img src="' . $base . drupal_get_path('module', 'iform') . '/client_helpers/prebuilt_forms/images/ofs_pollinator/{taxonComp}.png" alt="[{taxon} Image]">';
     // load taxon list
     // load attributes.
     $options = data_entry_helper::get_species_checklist_options($options);
     //make a copy of the options so that we can maipulate it
     $overrideOptions = $options;
     $occAttrControls = array();
     $occAttrs = array();
     $taxonRows = array();
     // at this stage no preloading: no editing of existing data.
     // load the full list of species for the grid, including the main checklist plus any additional species in the reloaded occurrences.
     $taxalist = self::get_species_checklist_taxa_list($options, $taxonRows);
     // If we managed to read the species list data we can proceed
     if (!array_key_exists('error', $taxalist)) {
         $attrOptions = array('id' => null, 'valuetable' => 'occurrence_attribute_value', 'attrtable' => 'occurrence_attribute', 'key' => 'occurrence_id', 'fieldprefix' => "sc:-idx-::occAttr", 'extraParams' => $options['readAuth'], 'survey_id' => array_key_exists('survey_id', $options) ? $options['survey_id'] : null);
         $attributes = data_entry_helper::getAttributes($attrOptions);
         // Get the attribute and control information required to build the custom occurrence attribute columns
         data_entry_helper::species_checklist_prepare_attributes($options, $attributes, $occAttrControls, $occAttrs);
         $grid = "\n";
         // No look up list -> no cloneable row
         $grid .= '<table class="ui-widget ui-widget-content species-grid ' . $options['class'] . '" id="' . $options['id'] . '">';
         $visibleColIdx = 0;
         $grid .= "<thead class=\"ui-widget-header\"><tr><th>Wings</th><th>Other Features</th>";
         for ($i = 0; $i < $options['columns']; $i++) {
             $grid .= self::get_species_checklist_col_header($options['id'] . "-species-{$i}", lang::get('species_checklist.species'), $visibleColIdx, $options['colWidths'], '', '');
             $grid .= self::get_species_checklist_col_header($options['id'] . "-present-{$i}", lang::get('species_checklist.present'), $visibleColIdx, $options['colWidths'], 'display:none', '');
             foreach ($occAttrs as $idx => $a) {
                 $filename = preg_replace('/\\s+/', '-', strtolower($a));
                 $grid .= self::get_species_checklist_col_header($options['id'] . "-attr{$idx}-{$i}", lang::get($a), $visibleColIdx, $options['colWidths'], '', $base . drupal_get_path('module', 'iform') . '/client_helpers/prebuilt_forms/images/ofs_pollinator/' . $filename . '.png');
             }
         }
         $grid .= '</tr></thead>';
         $rows = array();
         $taxonCounter = array();
         $rowIdx = 0;
         $grid .= "\n<tbody>\n";
         if (count($taxonRows)) {
             $grid .= '<tr class="top"><td rowspan="2" class="dot-right"><b>No obvious wings</b></td><td>Antennae short</td>' . self::dump_one_row(0, $taxonRows[0], $taxalist, $taxonRows, $occAttrControls, $attributes, $options) . '</tr>';
         }
         if (count($taxonRows) > 1) {
             $grid .= '<tr class="dot-top"><td>Antennae varying lengths</td>' . self::dump_one_row(1, $taxonRows[1], $taxalist, $taxonRows, $occAttrControls, $attributes, $options) . '</tr>';
         }
         if (count($taxonRows) > 2) {
             $grid .= '<tr class="top"><td rowspan="2" class="dot-right"><b>One pair of wings</b><br/>One pair of wings, usually clear<br />Wings, held out from or held along the body</td><td rowspan="2" class="scOtherFeaturesCell" >Antennae usually short<br/><img src="' . $base . drupal_get_path('module', 'iform') . '/client_helpers/prebuilt_forms/images/ofs_pollinator/short-antennae.png" alt=""></td>' . self::dump_one_row(2, $taxonRows[2], $taxalist, $taxonRows, $occAttrControls, $attributes, $options) . '</tr>';
         }
         if (count($taxonRows) > 3) {
             $grid .= '<tr class="dot-top">' . self::dump_one_row(3, $taxonRows[3], $taxalist, $taxonRows, $occAttrControls, $attributes, $options) . '</tr>';
         }
         if (count($taxonRows) > 4) {
             $grid .= '<tr class="top"><td class="dot-right"><b>Two pairs of wings</b><br/>Two pairs of wings, coloured</td><td>Antennae usually long</td>' . self::dump_one_row(4, $taxonRows[4], $taxalist, $taxonRows, $occAttrControls, $attributes, $options) . '</tr>';
         }
         if (count($taxonRows) > 5) {
             $grid .= '<tr class="dot-top"><td rowspan="2" class="dot-right">Two pairs of wings, usually clear<br/>Wings held out from or held along body</td><td rowspan="2" class="scOtherFeaturesCell" >Antennae usually long<br/><img src="' . $base . drupal_get_path('module', 'iform') . '/client_helpers/prebuilt_forms/images/ofs_pollinator/long-antennae.png" alt=""></td>' . self::dump_one_row(5, $taxonRows[5], $taxalist, $taxonRows, $occAttrControls, $attributes, $options) . '</tr>';
         }
         if (count($taxonRows) > 6) {
             $grid .= '<tr class="dot-top">' . self::dump_one_row(6, $taxonRows[6], $taxalist, $taxonRows, $occAttrControls, $attributes, $options) . '</tr>';
         }
         $txnID = 7;
         if (count($taxonRows) > $txnID) {
             $grid .= '<tr class="top"><td class="dot-right"><b>?</b></td><td></td>' . '<td class="scTaxonCell">Unknown Other?</td>' . '<td style="display:none" class="scPresenceCell"><input type="hidden" value="' . $taxonRows[$txnID]["ttlId"] . '" id="sc:' . $options['id'] . '-' . $txnID . '::present" name="sc:' . $options['id'] . '-' . $txnID . '::present"></td>' . '<td class="scOccAttrCell ui-widget-content scComment" colspan="' . count($attributes) . '"><input type="text" value="" name="sc:' . $options['id'] . '-' . $txnID . '::comment" id="sc:' . $options['id'] . '-' . $txnID . '::comment"></td></tr>';
         }
         $grid .= "</tbody>\n</table>\n";
         $grid .= '<input name="rowInclusionCheck" value="hasData" type="hidden" />';
         $r .= $grid;
         return $r;
     } else {
         return $taxalist['error'];
     }
 }
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:76,代码来源:ofs_pollinator_2013.php

示例3: species_checklist


//.........这里部分代码省略.........
     $taxonRows = array();
     $subSampleRows = array();
     if (!empty($options['useThirdLevelSamples']) && $options['useThirdLevelSamples'] == true) {
         $useThirdLevelSamples = true;
     } else {
         $useThirdLevelSamples = false;
     }
     // Load any existing sample's occurrence data into $entity_to_load
     if (isset(data_entry_helper::$entity_to_load['sample:id']) && $options['useLoadedExistingRecords'] === false) {
         self::preload_species_checklist_occurrences(data_entry_helper::$entity_to_load['sample:id'], $options['readAuth'], $options['mediaTypes'], $options['reloadExtraParams'], $subSampleRows, $options['speciesControlToUseSubSamples'], isset($options['subSampleSampleMethodID']) ? $options['subSampleSampleMethodID'] : '', $options['id'], $useThirdLevelSamples);
     }
     // load the full list of species for the grid, including the main checklist plus any additional species in the reloaded occurrences.
     $taxalist = data_entry_helper::get_species_checklist_taxa_list($options, $taxonRows);
     // If we managed to read the species list data we can proceed
     if (!array_key_exists('error', $taxalist)) {
         $attrOptions = array('id' => null, 'valuetable' => 'occurrence_attribute_value', 'attrtable' => 'occurrence_attribute', 'key' => 'occurrence_id', 'fieldprefix' => "sc:-idx-::occAttr", 'extraParams' => $options['readAuth'], 'survey_id' => array_key_exists('survey_id', $options) ? $options['survey_id'] : null);
         if (isset($options['attributeIds'])) {
             // make sure we load the grid ID attribute
             if (!empty($options['gridIdAttributeId']) && !in_array($options['gridIdAttributeId'], $options['attributeIds'])) {
                 $options['attributeIds'][] = $options['gridIdAttributeId'];
             }
             $attrOptions['extraParams'] += array('query' => json_encode(array('in' => array('id' => $options['attributeIds']))));
         }
         $attributes = data_entry_helper::getAttributes($attrOptions);
         // Merge in the attribute options passed into the control which can override the warehouse config
         if (isset($options['occAttrOptions'])) {
             foreach ($options['occAttrOptions'] as $attrId => $attr) {
                 if (isset($attributes[$attrId])) {
                     $attributes[$attrId] = array_merge($attributes[$attrId], $attr);
                 }
             }
         }
         // Get the attribute and control information required to build the custom occurrence attribute columns
         data_entry_helper::species_checklist_prepare_attributes($options, $attributes, $occAttrControls, $occAttrControlsExisting, $occAttrs);
         $beforegrid = '<span style="display: none;">Step 1</span>' . "\n";
         if (isset($options['lookupListId'])) {
             $subSampleImagesToLoad = array();
             //Cycle through sub-samples of the main parent sample
             foreach ($subSampleRows as $subSampleIdx => $subSampleRow) {
                 foreach (data_entry_helper::$entity_to_load as $key => $value) {
                     $keyParts = explode(':', $key);
                     //Get an array of sample media to load onto the grid
                     if (strpos($key, 'third-level-smp-occ-grid') !== false && strpos($key, ':sample_medium:id') !== false) {
                         if (!in_array($keyParts[3], $subSampleImagesToLoad)) {
                             $subSampleImagesToLoad[] = $keyParts[3];
                         }
                     }
                 }
             }
             //For each sub-sample, add a row to the occurrences grid with the image loaded, this is then ready for the user.
             //To create occurrences with
             if (isset($subSampleImagesToLoad)) {
                 $mediaIdArray = array();
                 foreach ($subSampleImagesToLoad as $subSampleImageIdx => $subSampleImageToLoad) {
                     $mediaIdArray[] = $subSampleImageToLoad;
                     $beforegrid .= self::get_species_checklist_empty_row_with_image($options, $occAttrControls, $attributes, $subSampleImageIdx, $subSampleImageToLoad);
                 }
                 $encodedMediaArray = json_encode($mediaIdArray);
                 data_entry_helper::$javascript .= "indiciaData.encodedMediaArray=" . json_encode($encodedMediaArray) . ";\n";
             }
             $beforegrid .= self::get_species_checklist_clonable_row($options, $occAttrControls, $attributes);
         }
         $onlyImages = true;
         if ($options['mediaTypes']) {
             foreach ($options['mediaTypes'] as $mediaType) {
                 if (substr($mediaType, 0, 6) !== 'Image:') {
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:67,代码来源:dynamic_progressive_seasearch_survey.php

示例4: sampleAttrRows

 private static function sampleAttrRows($args, $auth)
 {
     $sampleAttrs = self::getAttributes($args, $auth);
     $controls = array();
     $controlsExisting = array();
     $captions = array();
     data_entry_helper::species_checklist_prepare_attributes($args, $sampleAttrs, $controls, $controlsExisting, $captions);
     if (!empty($_GET['sample_id'])) {
         // loading existing, so let's retrieve all the subsample data
         $ids = array();
         foreach (self::$existingSamples as $sample) {
             $ids[] = $sample['id'];
         }
         $sampleData = data_entry_helper::get_population_data(array('table' => 'sample_attribute_value', 'extraParams' => $auth['read'] + array('sample_id' => $ids, 'view' => 'list'), 'nocache' => true));
     }
     $r = '';
     foreach ($controls as $idx => $control) {
         $r .= "<tr><td><strong>{$captions[$idx]}</strong></td>";
         $weekstart = self::getStartDate($args);
         for ($i = 0; $i < $args['weeks']; $i++) {
             if ($weekstart > time()) {
                 $r .= "<td class=\"col-{$i}\"><span class=\"disabled\"></span></td>";
             } else {
                 $valId = '';
                 $val = null;
                 if (!empty(self::$sampleIdsByDate[$weekstart])) {
                     $sampleId = self::$sampleIdsByDate[$weekstart];
                     foreach ($sampleData as $value) {
                         if ($value['sample_id'] === $sampleId && $value['sample_attribute_id'] === $sampleAttrs[$idx]['attributeId']) {
                             $valId = ":{$value['id']}";
                             $val = $value['raw_value'];
                         }
                     }
                 }
                 $fieldname = str_replace('smpAttr', "smpAttr{$i}", $sampleAttrs[$idx]['fieldname']) . $valId;
                 $thisCtrl = str_replace('{fieldname}', $fieldname, $control);
                 if ($val !== null) {
                     // Inject value into existing attribute control.  Approach taken depends on the data type
                     if ($sampleAttrs[$idx]['data_type'] === 'B' && $val === '1') {
                         // Currently only supporting checkboxes here
                         $thisCtrl = str_replace('type="checkbox"', 'type="checkbox" checked="checked"', $thisCtrl);
                     }
                 }
                 $r .= "<td class=\"col-{$i}\">{$thisCtrl}</td>";
             }
             $weekstart = strtotime('+7 days', $weekstart);
         }
         $r .= "</tr>\n";
     }
     return $r;
 }
开发者ID:joewoodhouse,项目名称:client_helpers,代码行数:51,代码来源:dynamic_weekly_counts.php


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