本文整理汇总了PHP中data_entry_helper::apply_template方法的典型用法代码示例。如果您正苦于以下问题:PHP data_entry_helper::apply_template方法的具体用法?PHP data_entry_helper::apply_template怎么用?PHP data_entry_helper::apply_template使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data_entry_helper
的用法示例。
在下文中一共展示了data_entry_helper::apply_template方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: date_now
/**
* Ouputs a hidden date control set to the current date.
* The output of this control can be configured using the following templates:
* <ul>
* <li><b>hidden_text</b></br>
* Template used for the for hidden inputs.
* </ul>
*
*
* @param array $options Options array with the following possibilities:<ul>
* <li><b>fieldname</b><br/>
* Required. The name of the database field this control is bound to.
* Default 'sample:date'.</li>
* <li><b>id</b><br/>
* Optional. The id to assign to the HTML control. If not assigned the
* fieldname is used.</li>
* <li><b>default</b><br/>
* Optional. The default value to assign to the control. This is overridden
* when reloading a record with existing data for this control.</li>
* </ul>
*
* @return string HTML to insert into the page for the date picker control.
*/
public static function date_now($options, $hidden = NULL)
{
$r = "";
$options = self::check_options($options);
$options = array_merge(array('fieldname' => 'sample:date', 'default' => '0'), $options);
$id = isset($options['id']) ? $options['id'] : $options['fieldname'];
$options['id'] = $id;
$id = self::jq_esc($id);
// JavaScript to obtain the date value;
self::$javascript .= "\n (function (\$) {\n // Calculate date string\n var d = new Date();\n var day = d.getDate();\n day = ((day < 10) ? '0' : '') + day\n var month = d.getMonth() + 1;\n month = ((month < 10) ? '0' : '') + month\n var year = d.getFullYear()\n var date = year + '-' + month + '-' + day;\n \n \$('#{$id}').attr('value', date);\n }) (jqm);\n ";
// HTML which will accept the date value
if (is_null($hidden) || $hidden) {
$r .= self::hidden_text($options);
} else {
$r .= data_entry_helper::apply_template('jqmDate', $options);
}
return $r;
}
示例2: iform_mnhnl_lux5kgridControl
//.........这里部分代码省略.........
if ($args['includeLocTools'] && function_exists('iform_loctools_listlocations')) {
$locations = iform_loctools_listlocations($node);
} else {
$locations = 'all';
}
if ($args['locationMode'] == 'parent' || $args['locationMode'] == 'multi') {
if (!isset($args['loctoolsLocTypeID'])) {
return "locationMode == parent, loctoolsLocTypeID not set.";
}
iform_mnhnl_set_editable($auth, $args, $node, array(), $args['locationMode'] == 'parent' ? "conditional" : $options['AdminMode'], $loctypeParam);
$locOptions = array('validation' => array('required'), 'label' => $options['ChooseParentLabel'], 'id' => $options['ChooseParentFieldID'], 'table' => 'location', 'fieldname' => $options['ChooseParentFieldName'], 'valueField' => 'id', 'captionField' => 'name', 'template' => 'select', 'itemTemplate' => 'select_item', 'columns' => 'id,name', 'extraParams' => array_merge($auth['read'], array('parent_id' => 'NULL', 'view' => 'detail', 'orderby' => 'name', 'location_type_id' => $args['loctoolsLocTypeID'], 'deleted' => 'f')));
$locResponse = data_entry_helper::get_population_data($locOptions);
if (isset($locResponse['error'])) {
return "PARENT LOOKUP ERROR: " . $locResponse['error'];
}
$opts = "";
if (!isset(data_entry_helper::$entity_to_load[$options['ParentFieldName']])) {
$opts = str_replace(array('{value}', '{caption}', '{selected}'), array('', htmlentities(lang::get('LANG_CommonParentBlank')), ''), $indicia_templates[$locOptions['itemTemplate']]);
}
foreach ($locResponse as $record) {
$include = false;
if ($locations == 'all') {
$include = true;
} else {
if (in_array($record["id"], $locations)) {
$include = true;
}
}
if ($include == true) {
$opts .= str_replace(array('{value}', '{caption}', '{selected}'), array($record[$locOptions['valueField']], htmlentities($record[$locOptions['captionField']]), isset(data_entry_helper::$entity_to_load[$options['ParentFieldName']]) ? data_entry_helper::$entity_to_load[$options['ParentFieldName']] == $record[$locOptions['valueField']] ? 'selected=selected' : '' : ''), $indicia_templates[$locOptions['itemTemplate']]);
}
}
$locOptions['items'] = $opts;
$retVal .= '<p>' . $options['Instructions1'] . '</p>' . data_entry_helper::apply_template($locOptions['template'], $locOptions) . ($args['includeNumSites'] ? '<label for="dummy-num-sites" class="auto-width">' . lang::get('LANG_NumSites') . ':</label> <input id="dummy-num-sites" name="dummy:num-sites" class="checkNumSites narrow" readonly="readonly"><br />
' : '') . '<p>' . $options['Instructions2'] . '</p>' . ($options['AdminMode'] && (!isset($args['adminsCanCreate']) || !$args['adminsCanCreate']) ? '<p>' . lang::get('LANG_LocModTool_CantCreate') . '</p>' : '');
}
if ($args['locationMode'] == 'parent') {
$retVal .= "<input type='hidden' id=\"sample-location-id\" name=\"sample:location_id\" value='" . data_entry_helper::$entity_to_load['sample:location_id'] . "' />";
data_entry_helper::$javascript .= "\njQuery(\"#" . $options['ChooseParentFieldID'] . "\").change(function(){\n jQuery(\"#imp-geom,#imp-boundary-geom,#imp-sref,#imp-srefX,#imp-srefY,#" . $options['MainFieldID'] . ",#" . $options['ParentFieldID'] . ",#sample-location-id,#location-name,#sample-location-name\").val('');\n jQuery(\"#location_location_type_id\").val('{$primary}');\n loadFeatures(this.value, '', {initial: false}, true, true, true, true, true);\n if(typeof hook_mnhnl_parent_changed != 'undefined')\n hook_mnhnl_parent_changed();\n});\njQuery(\"#" . $options['ParentFieldID'] . "\").change(function(){\n if(jQuery(this).val() != '') {\n // we have a new parent location, so draw boundary\n jQuery.getJSON(\"" . data_entry_helper::$base_url . "/index.php/services/data/location/\"+jQuery(this).val()+\"?mode=json&view=detail&auth_token=" . $auth['read']['auth_token'] . "&nonce=" . $auth['read']["nonce"] . "&callback=?\",\n function(data) {\n if (data.length>0) {\n var parser = new OpenLayers.Format.WKT();\n if(data[0].boundary_geom){ // only one location if any\n var feature = parser.read(data[0].boundary_geom)\n feature=convertFeature(feature, \$('#map')[0].map.projection);\n ParentLocationLayer.destroyFeatures();\n ParentLocationLayer.addFeatures([feature]);\n zoomToLayerExtent(ParentLocationLayer);\n }\n }});\n" . ($options['AdminMode'] ? " // in admin mode we have to reset the location name drop downs.\n jQuery('#location-name').find('option').removeAttr('disabled');\n" . (isset($args['duplicateNameCheck']) && ($args['duplicateNameCheck'] == true || $args['duplicateNameCheck'] == 'check' || $args['duplicateNameCheck'] == 'enforce') ? " jQuery.getJSON(\"" . data_entry_helper::$base_url . "/index.php/services/data/location?parent_id=\"+jQuery(this).val()+\"&location_type_id" . $primary . "&mode=json&view=detail&auth_token=" . $auth['read']['auth_token'] . "&nonce=" . $auth['read']["nonce"] . "&callback=?\",\n function(data) {\n if (data.length>0) {\n var currentName = jQuery('#location-name').val();\n var currentID = jQuery('#" . $options['MainFieldID'] . "').val();\n // first check if there is a clash and give a warning\n for(var di=0; di<data.length; di++){\n if(currentName == data[di].name && currentID != data[di].id && currentID != ''){\n alert(\"" . lang::get('This site name is already in use in the new square. Please choose another.') . "\");\n break; // only display one message\n }\n }\n" . ($args['duplicateNameCheck'] == 'enforce' ? " // if enforce, disable all options for existing and reset the name value if needed.\n for(var di=0; di<data.length; di++){\n if(data[di].name == parseInt(data[di].name) && currentID != data[di].id)\n // only disable fields for existing locations for numeric names and which are not me. \n jQuery('#location-name').find('option').filter('[value='+data[di].name+']').attr('disabled','disabled');\n }\n // finally if enforce and there is a clash, reset the value. This will then automatically take first available.\n for(var di=0; di<data.length; di++){\n if(currentName == data[di].name && currentID != data[di].id)\n jQuery('#location-name').val('');\n }\n" : "") . "\n }});\n" : "") : "") . " } else\n ParentLocationLayer.destroyFeatures();\n});\n";
// choose a single site from a parent, so built site selector drop down.
// parent uses ID locModTool
$opts = "";
$locOptions = array('label' => $options['MainFieldLabel'], 'id' => $options['MainFieldID'], 'table' => 'location', 'fieldname' => $options['MainFieldName'], 'valueField' => 'id', 'captionField' => 'name', 'template' => 'select', 'itemTemplate' => 'select_item', 'nocache' => true, 'extraParams' => array_merge($auth['read'], array('parent_id' => data_entry_helper::$entity_to_load["location:parent_id"], 'view' => 'detail', 'orderby' => 'name', 'location_type_id' => $loctypeParam, 'deleted' => 'f')));
if (isset(data_entry_helper::$entity_to_load["sample:id"])) {
// if preloaded, then drop down is dependant on value in parent field: if not then get user to enter parent first
$response = data_entry_helper::get_population_data($locOptions);
// OK as parent_id filled in: not likely to be large number.
if (isset($response['error'])) {
return "CHILD LOOKUP ERROR: " . $response['error'];
}
$opts .= str_replace(array('{value}', '{caption}', '{selected}'), array('', htmlentities(lang::get('LANG_CommonEmptyLocationID')), ''), $indicia_templates[$locOptions['itemTemplate']]);
foreach ($response as $record) {
$caption = htmlspecialchars($record[$locOptions['captionField']]);
// it will be extended using a attribute template by JS
$opts .= str_replace(array('{value}', '{caption}', '{selected}'), array($record[$locOptions['valueField']], htmlentities($caption), isset(data_entry_helper::$entity_to_load['location:id']) ? data_entry_helper::$entity_to_load['sample:location_id'] == $record[$locOptions['valueField']] ? 'selected=selected' : '' : ''), $indicia_templates[$locOptions['itemTemplate']]);
}
} else {
$opts = "<option >" . lang::get("LANG_CommonChooseParentFirst") . "</option>";
}
$locOptions['items'] = $opts;
// single site requires all location data in main form. Mult site must have array: depends on implementation so left to actual form.
$retVal .= data_entry_helper::apply_template($locOptions['template'], $locOptions) . "<br />";
if ($options['AdminMode']) {
$locOptions = array('validation' => array('required'), 'label' => $options['ParentLabel'], 'id' => $options['ParentFieldID'], 'fieldname' => $options['ParentFieldName'], 'valueField' => 'id', 'captionField' => 'name', 'template' => 'select', 'itemTemplate' => 'select_item');
$opts = str_replace(array('{value}', '{caption}', '{selected}'), array('', '', ''), $indicia_templates[$locOptions['itemTemplate']]);
foreach ($locResponse as $record) {
示例3: array
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/gpl.html.
*
* @package Survey cleanup
* @subpackage Views
* @author Indicia Team
* @license http://www.gnu.org/licenses/gpl.html GPL
* @link http://code.google.com/p/indicia/
*/
require_once DOCROOT . 'client_helpers/data_entry_helper.php';
if (!($this->auth->logged_in('CoreAdmin') || $this->auth->has_website_access('admin', $survey->website_id))) {
echo '<p class="page-notice ui-state-highlight ui-corner-all">You must be an admin of the website that this survey belongs to in order to use the Survey Cleanup tool</p>';
} else {
echo data_entry_helper::radio_group(array('label' => 'Type of data to cleanup', 'fieldname' => 'mode', 'id' => 'mode', 'lookupValues' => array('deleted' => 'Mark deleted records', 'test' => 'Test records', 'all' => 'All records'), 'sep' => '<br/>', 'default' => 'deleted'));
echo data_entry_helper::hidden_text(array('fieldname' => 'survey_id', 'default' => $survey->id));
echo data_entry_helper::apply_template('submitButton', array('id' => 'cleanup-button', 'class' => 'indicia-button', 'caption' => 'Cleanup Records'));
data_entry_helper::link_default_stylesheet();
data_entry_helper::$dumped_resources[] = 'jquery';
data_entry_helper::$dumped_resources[] = 'jquery_ui';
data_entry_helper::$dumped_resources[] = 'fancybox';
data_entry_helper::$javascript .= "\$('#cleanup-button').click(function() {\n if (!confirm('Are you certain you want to cleanup these records?')) {\n return false;\n } else {\n \$.post(\"" . url::site('survey_cleanup/cleanup') . "\", \n { mode: \$('input:radio[name=mode]:checked').val(), survey_id: \$('#survey_id').val() }, \n function(data, textStatus) {\n alert(data);\n }\n );\n }\n });\n";
echo data_entry_helper::dump_javascript();
}