本文整理汇总了PHP中data_entry_helper::javascript方法的典型用法代码示例。如果您正苦于以下问题:PHP data_entry_helper::javascript方法的具体用法?PHP data_entry_helper::javascript怎么用?PHP data_entry_helper::javascript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data_entry_helper
的用法示例。
在下文中一共展示了data_entry_helper::javascript方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_form
/**
* Return the generated form output.
* @return Form HTML.
*/
public static function get_form($args, $node)
{
data_entry_helper::$website_id = $args['website_id'];
if (!empty($args['high_volume']) && $args['high_volume']) {
// node level caching for most page hits
$cached = data_entry_helper::cache_get(array('node' => $node->nid), HIGH_VOLUME_CACHE_TIMEOUT);
if ($cached !== false) {
$cached = explode('|!|', $cached);
data_entry_helper::$javascript = $cached[1];
data_entry_helper::$late_javascript = $cached[2];
data_entry_helper::$onload_javascript = $cached[3];
data_entry_helper::$required_resources = json_decode($cached[4], true);
return $cached[0];
}
}
self::$node = $node;
self::$called_class = 'iform_' . $node->iform;
// Convert parameter, defaults, into structured array
self::parse_defaults($args);
// Supply parameters that may be missing after form upgrade
if (method_exists(self::$called_class, 'getArgDefaults')) {
$args = call_user_func(array(self::$called_class, 'getArgDefaults'), $args);
}
// Get authorisation tokens to update and read from the Warehouse. We allow child classes to generate this first if subclassed.
if (self::$auth) {
$auth = self::$auth;
} else {
$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
self::$auth = $auth;
}
// Determine how the form was requested and therefore what to output
$mode = method_exists(self::$called_class, 'getMode') ? call_user_func(array(self::$called_class, 'getMode'), $args, $node) : '';
self::$mode = $mode;
if ($mode === self::MODE_GRID) {
// Output a grid of existing records
$r = call_user_func(array(self::$called_class, 'getGrid'), $args, $node, $auth);
} else {
if (($mode === self::MODE_EXISTING || $mode === self::MODE_EXISTING_RO || $mode === self::MODE_CLONE) && is_null(data_entry_helper::$entity_to_load)) {
// only load if not in error situation.
call_user_func_array(array(self::$called_class, 'getEntity'), array(&$args, $auth));
}
// attributes must be fetched after the entity to load is filled in - this is because the id gets filled in then!
$attributes = method_exists(self::$called_class, 'getAttributes') ? call_user_func(array(self::$called_class, 'getAttributes'), $args, $auth) : array();
$r = call_user_func(array(self::$called_class, 'get_form_html'), $args, $auth, $attributes);
}
if (!empty($args['high_volume']) && $args['high_volume']) {
$c = $r . '|!|' . data_entry_helper::$javascript . '|!|' . data_entry_helper::$late_javascript . '|!|' . data_entry_helper::$onload_javascript . '|!|' . json_encode(data_entry_helper::$required_resources);
data_entry_helper::cache_set(array('node' => $node->nid), $c, HIGH_VOLUME_CACHE_TIMEOUT);
}
return $r;
}
示例2: mapping_for_volunteers_guests
public static function mapping_for_volunteers_guests($auth, $args, $tabalias, $options, $path)
{
iform_load_helpers(array('data_entry_helper'));
data_entry_helper::$javascript = "\n if (\$('#dynamic-my_own_locality').is(':checked')) {\n \$('#tab-records').show();\n } else {\n \$('#tab-records').hide();\n }\n ";
}
示例3: get_control_speciesidentifier
private static function get_control_speciesidentifier($auth, $args, $tabalias, $options)
{
static $taxIdx = 0;
// we need to control which items are lockable if locking requested
if (!empty($options['lockable']) && $options['lockable'] == true) {
$options['identifiers_lockable'] = $options['lockable'];
} else {
$options['identifiers_lockable'] = '';
}
unset($options['lockable']);
// get the identifier type data
$filter = array('termlist_external_key' => 'indicia:assoc:identifier_type');
$dataOpts = array('table' => 'termlists_term', 'extraParams' => $auth['read'] + $filter);
$options['identifierTypes'] = data_entry_helper::get_population_data($dataOpts);
// get the identifier attribute type data
$dataOpts = array('table' => 'identifier_attribute', 'extraParams' => $auth['read']);
$options['idnAttributeTypes'] = data_entry_helper::get_population_data($dataOpts);
// set up the known system types for identifier attributes
$options['baseColourId'] = -1;
$options['textColourId'] = -1;
$options['sequenceId'] = -1;
$options['positionId'] = -1;
foreach ($options['idnAttributeTypes'] as $idnAttributeType) {
if (!empty($idnAttributeType['system_function'])) {
switch ($idnAttributeType['system_function']) {
case 'base_colour':
$options['baseColourId'] = $idnAttributeType['id'];
break;
case 'text_colour':
$options['textColourId'] = $idnAttributeType['id'];
break;
case 'sequence':
$options['sequenceId'] = $idnAttributeType['id'];
break;
case 'position':
$options['positionId'] = $idnAttributeType['id'];
break;
}
}
}
// get the subject observation attribute type data
$dataOpts = array('table' => 'subject_observation_attribute', 'extraParams' => $auth['read']);
$options['sjoAttributeTypes'] = data_entry_helper::get_population_data($dataOpts);
// set up the known system types for subject_observation attributes
$options['attachmentId'] = -1;
$options['genderId'] = -1;
$options['stageId'] = -1;
$options['lifeStatusId'] = -1;
foreach ($options['sjoAttributeTypes'] as $sjoAttributeType) {
if (!empty($sjoAttributeType['system_function'])) {
switch ($sjoAttributeType['system_function']) {
case 'attachment':
$options['attachmentId'] = $sjoAttributeType['id'];
break;
case 'gender':
$options['genderId'] = $sjoAttributeType['id'];
break;
case 'stage':
$options['stageId'] = $sjoAttributeType['id'];
break;
case 'life_status':
$options['lifeStatusId'] = $sjoAttributeType['id'];
break;
}
}
}
// get the identifiers subject observation attribute type data
$dataOpts = array('table' => 'identifiers_subject_observation_attribute', 'extraParams' => $auth['read']);
$options['isoAttributeTypes'] = data_entry_helper::get_population_data($dataOpts);
// set up the known system types for subject_observation attributes
$options['conditionsId'] = -1;
foreach ($options['isoAttributeTypes'] as $isoAttributeType) {
if (!empty($isoAttributeType['system_function'])) {
switch ($isoAttributeType['system_function']) {
case 'identifier_condition':
$options['conditionsId'] = $isoAttributeType['id'];
break;
}
}
}
// 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">';
//.........这里部分代码省略.........
示例4: file_box
//.........这里部分代码省略.........
*
* @todo select file button pointer overriden by the flash shim
* @todo if using a normal file input, after validation, the input needs to show that the file upload has worked.
* @todo Cleanup uploaded files that never got submitted because of validation failure elsewhere.
*/
public static function file_box($options)
{
global $indicia_templates;
// Upload directory defaults to client_helpers/upload, but can be overriden.
$interim_image_folder = isset(parent::$interim_image_folder) ? parent::$interim_image_folder : 'upload/';
$relpath = self::getRootFolder() . self::client_helper_path();
//If a subType option is supplied, it means we only want to load a particular media type, not just any old media associated with the sample
if (!empty($options['subType'])) {
self::$upload_file_types[$options['subType']] = self::$upload_file_types['image'];
}
// Allow options to be defaulted and overridden
$defaults = array('id' => 'default', 'upload' => true, 'maxFileCount' => 4, 'autoupload' => false, 'msgUploadError' => lang::get('upload error'), 'msgFileTooBig' => lang::get('file too big for warehouse'), 'runtimes' => array('html5', 'flash', 'silverlight', 'html4'), 'autoupload' => true, 'imageWidth' => 200, 'uploadScript' => $relpath . 'upload.php', 'destinationFolder' => $relpath . $interim_image_folder, 'finalImageFolder' => self::get_uploaded_image_folder(), 'jsPath' => self::$js_path, 'buttonTemplate' => $indicia_templates['button'], 'table' => 'occurrence_medium', 'maxUploadSize' => self::convert_to_bytes(isset(parent::$maxUploadSize) ? parent::$maxUploadSize : '4M'), 'codeGenerated' => 'all', 'mediaTypes' => !empty($options['subType']) ? array($options['subType']) : array('Image:Local'), 'fileTypes' => (object) self::$upload_file_types, 'imgPath' => empty(self::$images_path) ? self::relative_client_helper_path() . "../media/images/" : self::$images_path, 'addBtnCaption' => lang::get('Add {1}'), 'msgPhoto' => lang::get('photo'), 'msgFile' => lang::get('file'), 'msgLink' => lang::get('link'), 'msgNewImage' => lang::get('New {1}'), 'msgDelete' => lang::get('Delete this item'), 'msgUseAddFileBtn' => lang::get('Use the Add file button to select a file from your local disk. Files of type {1} are allowed.'), 'msgUseAddLinkBtn' => lang::get('Use the Add link button to add a link to information stored elsewhere on the internet. You can enter links from {1}.'));
$defaults['caption'] = !isset($options['mediaTypes']) || $options['mediaTypes'] === array('Image:Local') ? lang::get('Photos') : lang::get('Media files');
if (isset(self::$final_image_folder_thumbs)) {
$defaults['finalImageFolderThumbs'] = $relpath . self::$final_image_folder_thumbs;
}
$browser = self::get_browser_info();
// Flash doesn't seem to work on IE6.
if ($browser['name'] == 'msie' && $browser['version'] < 7) {
$defaults['runtimes'] = array_diff($defaults['runtimes'], array('flash'));
}
if ($indicia_templates['file_box'] != '') {
$defaults['file_boxTemplate'] = $indicia_templates['file_box'];
}
if ($indicia_templates['file_box_initial_file_info'] != '') {
$defaults['file_box_initial_file_infoTemplate'] = $indicia_templates['file_box_initial_file_info'];
}
if ($indicia_templates['file_box_uploaded_image'] != '') {
$defaults['file_box_uploaded_imageTemplate'] = $indicia_templates['file_box_uploaded_image'];
}
$options = array_merge($defaults, $options);
$options['id'] = $options['table'] . '-' . $options['id'];
$containerId = 'container-' . $options['id'];
if ($options['codeGenerated'] != 'php') {
// build the JavaScript including the required file links
self::add_resource('plupload');
foreach ($options['runtimes'] as $runtime) {
self::add_resource("plupload_{$runtime}");
}
// convert runtimes list to plupload format
$options['runtimes'] = implode(',', $options['runtimes']);
$javascript = "\n\$('#" . str_replace(':', '\\\\:', $containerId) . "').uploader({";
// Just pass the options array through
$idx = 0;
foreach ($options as $option => $value) {
if (is_array($value) || is_object($value)) {
$value = json_encode($value);
} else {
// not an array, so wrap as string
$value = "'{$value}'";
}
$javascript .= "\n {$option} : {$value}";
// comma separated, except last entry
if ($idx < count($options) - 1) {
$javascript .= ',';
}
$idx++;
}
//If the subType is specified, then this option is supplied as text by the user. So go and look up the ID to use in code.
if (!empty($options['subType'])) {
$typeTermData = self::get_population_data(array('table' => 'termlists_term', 'extraParams' => $options['readAuth'] + array('term' => $options['subType'], 'columns' => 'id')));
$mediaTypeIdLimiter = $typeTermData[0]['id'];
}
// add in any reloaded items, when editing or after validation failure
if (self::$entity_to_load) {
//If we only want to display media of a particular type, then supply this as a parameter when extracting the media.
if (!empty($mediaTypeIdLimiter)) {
$images = self::extract_media_data(self::$entity_to_load, isset($options['loadExistingRecordKey']) ? $options['loadExistingRecordKey'] : $options['table'], false, false, $mediaTypeIdLimiter);
} else {
$images = self::extract_media_data(self::$entity_to_load, isset($options['loadExistingRecordKey']) ? $options['loadExistingRecordKey'] : $options['table']);
}
$javascript .= ",\n existingFiles : " . json_encode($images);
}
$javascript .= "\n});\n";
}
if ($options['codeGenerated'] == 'js') {
// we only want to return the JavaScript, so go no further.
return $javascript;
} elseif ($options['codeGenerated'] == 'all') {
if (isset($options['tabDiv'])) {
// The file box is displayed on a tab, so we must only generate it when the tab is displayed.
$javascript = "var uploaderTabHandler = function(event, ui) { \n" . " panel = typeof ui.newPanel==='undefined' ? ui.panel : ui.newPanel[0];\n" . " if (\$(panel).attr('id')==='" . $options['tabDiv'] . "') {\n " . $javascript . " indiciaFns.unbindTabsActivate(\$(\$('#" . $options['tabDiv'] . "').parent()), uploaderTabHandler);\n" . " }\n};\n" . "indiciaFns.bindTabsActivate(\$(\$('#" . $options['tabDiv'] . "').parent()), uploaderTabHandler);\n";
// Insert this script at the beginning, because it must be done before the tabs are initialised or the
// first tab cannot fire the event
self::$javascript = $javascript . self::$javascript;
} else {
self::$onload_javascript .= $javascript;
}
}
// Output a placeholder div for the jQuery plugin. Also output a normal file input for the noscripts
// version.
$r = '<div class="file-box" id="' . $containerId . '"></div><noscript>' . self::image_upload(array('label' => $options['caption'], 'id' => $options['id'], 'fieldname' => str_replace('_', ':', $options['table']))) . '</noscript>';
$r .= self::add_link_popup($options);
return $r;
}
示例5: dump_javascript
/**
* Helper function to collect javascript code in a single location. Should be called at the end of each HTML
* page which uses the data entry helper so output all JavaScript required by previous calls.
*
* @return string JavaScript to insert into the page for all the controls added to the page so far.
*
* @link http://code.google.com/p/indicia/wiki/TutorialBuildingBasicPage#Build_a_data_entry_page
*/
public static function dump_javascript()
{
// Add the default stylesheet to the end of the list, so it has highest CSS priority
if (self::$default_styles) {
self::add_resource('defaultStylesheet');
}
self::setup_jquery_validation_js();
$dump = self::internal_dump_javascript(self::$javascript, self::$late_javascript, self::$onload_javascript, self::$required_resources);
// ensure scripted JS does not output again if recalled.
self::$javascript = "";
self::$late_javascript = "";
self::$onload_javascript = "";
return $dump;
}
示例6: dump_javascript
/**
* Helper function to collect javascript code in a single location. Should be called at the end of each HTML
* page which uses the data entry helper so output all JavaScript required by previous calls.
*
* @return string JavaScript to insert into the page for all the controls added to the page so far.
*
* @link http://code.google.com/p/indicia/wiki/TutorialBuildingBasicPage#Build_a_data_entry_page
*/
public static function dump_javascript()
{
global $indicia_resources, $indicia_templates;
// Add the default stylesheet to the end of the list, so it has highest CSS priority
if (self::$default_styles) {
self::add_resource('defaultStylesheet');
}
// If required, setup jQuery validation. We can't prep this JavaScript earlier since we would
// not know all the control messages.
// In the following block, we set the validation plugin's error class to our template.
// We also define the error label to be wrapped in a <p> if it is on a newline.
if (self::$validated_form_id) {
self::$javascript .= "\$('#" . self::$validated_form_id . "').validate({\n errorClass: \"" . $indicia_templates['error_class'] . "\",\n " . (in_array('inline', self::$validation_mode) ? "\n " : "errorElement: 'p',\n ") . "highlight: function(element, errorClass) {\n // Don't highlight the actual control, as it could be hidden anyway\n },\n messages: " . json_encode(self::$validation_messages) . "\n });\n";
}
$dump = self::internal_dump_javascript(self::$javascript, self::$late_javascript, self::$onload_javascript, $indicia_resources);
// ensure scripted JS does not output again if recalled.
self::$javascript = "";
self::$late_javascript = "";
self::$onload_javascript = "";
return $dump;
}
示例7: file_box
//.........这里部分代码省略.........
* </li>
* <li><b>file_box_initial_file_info</b></br>
* HTML which provides the outer container for each displayed image, including the header and
* remove file button. Has an element with class set to media-wrapper into which images
* themselves will be inserted.
* </li>
* <li><b>file_box_uploaded_image</b></br>
* Template for the HTML for each uploaded image, including the image, caption input
* and hidden inputs to define the link to the database. Will be inserted into the
* file_box_initial_file_info template's media-wrapper element.
* </li>
* <li><b>button</b></br>
* Template for the buttons used.
* </li>
* </ul>
*
* @todo select file button pointer overriden by the flash shim
* @todo if using a normal file input, after validation, the input needs to show that the file upload has worked.
* @todo Cleanup uploaded files that never got submitted because of validation failure elsewhere.
*/
public static function file_box($options)
{
global $indicia_templates;
// Upload directory defaults to client_helpers/upload, but can be overriden.
$interim_image_folder = isset(parent::$interim_image_folder) ? parent::$interim_image_folder : 'upload/';
$relpath = self::getRootFolder() . self::client_helper_path();
// Allow options to be defaulted and overridden
$defaults = array('caption' => lang::get('Files'), 'id' => 'default', 'upload' => true, 'maxFileCount' => 4, 'autoupload' => false, 'msgUploadError' => lang::get('upload error'), 'msgFileTooBig' => lang::get('file too big for warehouse'), 'runtimes' => array('html5', 'flash', 'silverlight', 'html4'), 'autoupload' => true, 'imageWidth' => 200, 'uploadScript' => $relpath . 'upload.php', 'destinationFolder' => $relpath . $interim_image_folder, 'finalImageFolder' => self::get_uploaded_image_folder(), 'jsPath' => self::$js_path, 'buttonTemplate' => $indicia_templates['button'], 'table' => 'occurrence_medium', 'maxUploadSize' => self::convert_to_bytes(isset(parent::$maxUploadSize) ? parent::$maxUploadSize : '4M'), 'codeGenerated' => 'all', 'mediaTypes' => array('Image:Local'), 'imgPath' => empty(self::$images_path) ? self::relative_client_helper_path() . "../media/images/" : self::$images_path);
if (isset(self::$final_image_folder_thumbs)) {
$defaults['finalImageFolderThumbs'] = $relpath . self::$final_image_folder_thumbs;
}
$browser = self::get_browser_info();
// Flash doesn't seem to work on IE6.
if ($browser['name'] == 'msie' && $browser['version'] < 7) {
$defaults['runtimes'] = array_diff($defaults['runtimes'], array('flash'));
}
if ($indicia_templates['file_box'] != '') {
$defaults['file_boxTemplate'] = $indicia_templates['file_box'];
}
if ($indicia_templates['file_box_initial_file_info'] != '') {
$defaults['file_box_initial_file_infoTemplate'] = $indicia_templates['file_box_initial_file_info'];
}
if ($indicia_templates['file_box_uploaded_image'] != '') {
$defaults['file_box_uploaded_imageTemplate'] = $indicia_templates['file_box_uploaded_image'];
}
$options = array_merge($defaults, $options);
$options['id'] = $options['table'] . '-' . $options['id'];
$containerId = 'container-' . $options['id'];
if ($options['codeGenerated'] != 'php') {
// build the JavaScript including the required file links
self::add_resource('plupload');
foreach ($options['runtimes'] as $runtime) {
self::add_resource("plupload_{$runtime}");
}
// convert runtimes list to plupload format
$options['runtimes'] = implode(',', $options['runtimes']);
$javascript = "\n\$('#" . str_replace(':', '\\\\:', $containerId) . "').uploader({";
// Just pass the options array through
$idx = 0;
foreach ($options as $option => $value) {
if (is_array($value)) {
$value = json_encode($value);
} else {
// not an array, so wrap as string
$value = "'{$value}'";
}
$javascript .= "\n {$option} : {$value}";
// comma separated, except last entry
if ($idx < count($options) - 1) {
$javascript .= ',';
}
$idx++;
}
// add in any reloaded items, when editing or after validation failure
if (self::$entity_to_load) {
$images = self::extract_media_data(self::$entity_to_load, isset($options['loadExistingRecordKey']) ? $options['loadExistingRecordKey'] : $options['table']);
$javascript .= ",\n existingFiles : " . json_encode($images);
}
$javascript .= "\n});\n";
}
if ($options['codeGenerated'] == 'js') {
// we only want to return the JavaScript, so go no further.
return $javascript;
} elseif ($options['codeGenerated'] == 'all') {
if (isset($options['tabDiv'])) {
// The file box is displayed on a tab, so we must only generate it when the tab is displayed.
$javascript = "var uploaderTabHandler = function(event, ui) { \n" . " if (ui.panel.id=='" . $options['tabDiv'] . "') {\n " . $javascript . " jQuery(jQuery('#" . $options['tabDiv'] . "').parent()).unbind('tabsshow', uploaderTabHandler);\n" . " }\n};\n" . "jQuery(jQuery('#" . $options['tabDiv'] . "').parent()).bind('tabsshow', uploaderTabHandler);\n";
// Insert this script at the beginning, because it must be done before the tabs are initialised or the
// first tab cannot fire the event
self::$javascript = $javascript . self::$javascript;
} else {
self::$onload_javascript .= $javascript;
}
}
// Output a placeholder div for the jQuery plugin. Also output a normal file input for the noscripts
// version.
$r = '<div class="file-box" id="' . $containerId . '"></div><noscript>' . self::image_upload(array('label' => $options['caption'], 'id' => $options['id'], 'fieldname' => str_replace('_', ':', $options['table']))) . '</noscript>';
$r .= self::add_link_popup($options);
return $r;
}
示例8: get_site_tab
private static function get_site_tab($auth, $args, $settings)
{
$r = '<div id="site-details" class="ui-helper-clearfix">';
$r .= '<form method="post" id="input-form">';
$r .= $auth['write'];
$r .= '<fieldset><legend>' . lang::get('Site Details') . '</legend>';
$r .= "<input type=\"hidden\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />\n";
$r .= "<input type=\"hidden\" name=\"survey_id\" value=\"" . $args['survey_id'] . "\" />\n";
$r .= "<input type=\"hidden\" name=\"location:location_type_id\" value=\"" . $settings['SiteLocationType'][0]['id'] . "\" />\n";
if ($settings['locationId']) {
$r .= '<input type="hidden" name="location:id" id="location:id" value="' . $settings['locationId'] . "\" />\n";
}
$r .= data_entry_helper::text_input(array('fieldname' => 'location:name', 'label' => lang::get('Site Name'), 'class' => 'control-width-4 required'));
$r .= data_entry_helper::sref_and_system(array('fieldname' => 'location:centroid_sref', 'geomFieldname' => 'location:centroid_geom', 'label' => 'Site Central Grid Ref', 'systems' => array('4326' => '4326'), 'class' => 'required', 'disabled' => ' readonly="readonly" ', 'helpText' => lang::get('The following field is filled in automatically when the site is drawn on the map.')));
$r .= '<input type="hidden" name="location:boundary_geom" id="imp-boundary-geom" value="' . data_entry_helper::$entity_to_load['location:boundary_geom'] . '"/>';
// setup the map options
$options = iform_map_get_map_options($args, $auth['read']);
$r .= get_attribute_html($settings['attributes'], $args, array('extraParams' => $auth['read']));
$r .= '</fieldset>';
if (!$settings['locationId']) {
$help = lang::get('Use the search box to find a nearby town or village, then drag the map to pan and zoom in or out to find your site.');
$r .= '<p class="ui-state-highlight page-notice ui-corner-all">' . $help . '</p>';
$r .= data_entry_helper::georeference_lookup(array('label' => lang::get('Search for place'), 'driver' => $args['georefDriver'], 'georefPreferredArea' => $args['georefPreferredArea'], 'georefCountry' => $args['georefCountry'], 'georefLang' => $args['language'], 'readAuth' => $auth['read']));
}
$help = '<p>' . lang::get('Draw your site by selecting the appropriate tool in the top right of the map') . ':</p>' . '<ol><li>' . lang::get('Navigation Tool. This allows you to navigate around the map by dragging.') . '</li>' . '<li>' . lang::get('Draw Site Tool. This tool allows you to draw your site on the map. Click on the map to start drawing, and click each time you wish to fix a point on the outline of your site. <b>Double click the last fixed point to finish drawing</b>. Double clicking will replace any previously drawn site outline.') . '</li>' . '<li>' . lang::get('Modify Site Tool. This tool allows you to change the shape of a previously drawn site. Click on the existing site outline to add grab points (circles) along it. You can then click and drag these points to change the shape of the site. To remove a fixed point, hover your mouse over the point and press the "Delete" button on your keyboard.') . '</li></ol>';
if ($args['allow_user_assignment']) {
if ($settings['canAllocUser']) {
$help .= '<p>' . lang::get('You, as a scheme administrator, have the option of changing who the site is assigned to, using control under the map. If you so wish, the site may be assigned to more than one person at a time.') . '</p>';
}
}
$r .= '<div class="page-notice ui-state-highlight ui-corner-all">' . $help . '</div>';
if (isset($args['maxPrecision']) && $args['maxPrecision'] != '') {
$options['clickedSrefPrecisionMax'] = $args['maxPrecision'];
}
if (isset($args['minPrecision']) && $args['minPrecision'] != '') {
$options['clickedSrefPrecisionMin'] = $args['minPrecision'];
}
$olOptions = iform_map_get_ol_options($args);
$options['clickForSpatialRef'] = false;
$options['allowPolygonRecording'] = true;
$options['latLongFormat'] = 'DMS';
$options['autoFillInCentroid'] = true;
$options['initialFeatureWkt'] = false;
$options['initialBoundaryWkt'] = data_entry_helper::$entity_to_load['location:boundary_geom'];
$options['hintModifyFeature'] = lang::get('Modify Site Tool.');
$options['hintDrawPolygonHint'] = lang::get('Draw Site Tool.');
$options['hintNavigation'] = lang::get('Navigation Tool.');
$options['searchDisplaysPoint'] = false;
// with multiple maps can't use built in method on tabshow, so do here...
$divId = preg_replace('/[^a-zA-Z0-9]/', '', 'site-details');
$javascript = "var mapTabHandler = function(event, ui) { \n";
$javascript .= " panel = typeof ui.newPanel==='undefined' ? ui.panel : ui.newPanel[0];\n if (panel.id=='site-details' && typeof indiciaData.mapdiv !== 'undefined') {\n var map = jQuery('#map')[0].map;\n map.updateSize();\n var layerBounds = map.editLayer.getDataExtent().clone(); // use a clone\n map.zoomToExtent(layerBounds);\n }\n};\nindiciaFns.bindTabsActivate(jQuery(jQuery('#site-details').parent()), mapTabHandler);\n";
// Insert this script at the beginning, because it must be done before the tabs are initialised or the
// first tab cannot fire the event
data_entry_helper::$javascript = $javascript . data_entry_helper::$javascript;
$r .= map_helper::map_panel($options, $olOptions);
if ($args['allow_user_assignment']) {
if ($settings['canAllocUser']) {
$r .= self::get_user_assignment_control($auth['read'], $settings['cmsUserAttr'], $args);
} else {
if (!$settings['locationId']) {
// for a new record, we need to link the current user to the location if they are not admin.
global $user;
self::get_user_assignment_control($auth['read'], $settings['cmsUserAttr'], $args);
// this will populate the recorder list.
$r .= '<input type="hidden" name="locAttr:' . self::$cmsUserAttrId . '" value="' . $user->uid . '">';
}
}
}
$r .= '<button type="submit" class="indicia-button right">' . lang::get('Save') . '</button>';
if ($settings['locationId']) {
$r .= '<button type="button" class="indicia-button right" id="delete-site">' . lang::get('Delete') . '</button>';
}
$r .= '</form>';
$r .= '</div>';
// site-details
if ($settings['locationId']) {
$treeIDs = array();
foreach ($settings['trees'] as $id => $tree) {
$treeIDs[] = $tree['id'];
}
data_entry_helper::$javascript .= "\ndeleteSite = function(){\n if(confirm(\"" . lang::get('Are you sure you wish to delete this location?') . "\")){\n deleteTrees([" . implode(',', $treeIDs) . "]);\n \$('#delete-site').html('Deleting Site');\n deleteLocation(" . $settings['locationId'] . ");\n \$('#delete-site').html('Done');\n window.location='" . url($args['sites_list_path']) . "';\n };\n};\n\$('#delete-site').click(deleteSite);\n";
}
return $r;
}