- Главная
- Форумы
- Техподдержка Drupal
- Решение проблем
Главные вкладки
- Просмотр(активная вкладка)
- Реакции
12 января 2014 в 4:09
Всем привет. Помогите с решением. Перенес сайт на хостинг и возникла проблема при настройке отображения полей. Поле отображения картинки, к примеру, слева есть кнопка по нажатию на которую показывается меню настройки отображения картинки, ее размеры и на что она ссылается при клике. Так вот при нажатии на эту кнопку вылетает всплывающее окно следующего содержания:
Возникла AJAX HTTP ошибка.
Полученный код HTTP: 200
Следует отладочная информация.
Путь: /system/ajax
Текст Состояния: OK
Текст Ответа: [{«command»:«settings»,«settings»:{«basePath»:«/«,«pathPrefix»:«»,«ajaxPageState»:
{«theme»:«seven»,«theme_token»:«2J3KowjLFRBatAqM6DA5Gftwh4MXFLJszqC2MgEY5Zk»},«quote_nest»:«2»,«ajax»:{«edit-fields-field-img-
settings-edit-form-actions-save-settings»:{«callback»:«field_ui_display_overview_multistep_js»,«wrapper»:«field-display-overview-
wrapper»,«effect»:«fade»,«event»:«mousedown»,«keypress»:true,«prevent»:«click»,«url»:«/system/ajax»,«submit»:
{«_triggering_element_name»:«field_img_formatter_settings_update»,«_triggering_element_value»:«u041eu0431u043du043eu0432u0438
u0442u044c»}},«edit-fields-field-img-settings-edit-form-actions-cancel-settings»:
{«callback»:«field_ui_display_overview_multistep_js»,«wrapper»:«field-display-overview-
wrapper»,«effect»:«fade»,«event»:«mousedown»,«keypress»:true,«prevent»:«click»,«url»:«/system/ajax»,«submit»:
{«_triggering_element_name»:«field_img_formatter_settings_cancel»,«_triggering_element_value»:«u041eu0442u043cu0435u043du0438
u0442u044c»}}},«fieldUIRowsData»:{«body»:
{«rowHandler»:«field»,«defaultFormatter»:«text_default»,«name»:«body»,«region»:«visible»},«field-img»:
{«rowHandler»:«field»,«defaultFormatter»:«image»,«name»:«field_img»,«region»:«visible»},«subscriptions-ui»:
{«rowHandler»:«field»,«name»:«subscriptions_ui»,«region»:«visible»},«-add-new-group»:
{«rowHandler»:«group»,«name»:«_add_new_group»,«region»:«add_new»}}},«merge»:true},
{«command»:«insert»,«method»:null,«selector»:null,«data»:«u003Cdiv id=u0022field-display-overview-wrapperu0022u003Eu003Ctable
class=u0022field-ui-overview sticky-enabledu0022 id=u0022field-display-overviewu0022u003En
u003Ctheadu003Eu003Ctru003Eu003Cthu003Eu041fu043eu043bu0435u003C/thu003Eu003Cthu003Eu0412u0435u0441u003C/thu00
3Eu003Cthu003Eu0420u043eu0434u0438u0442u0435u043bu044cu003C/thu003Eu003Cthu003Eu041cu0435u0442u043au0430u003C
/thu003Eu003Cth colspan=u00223u0022u003Eu0424u043eu0440u043cu0430u0442u003C/thu003E
u003C/tru003Eu003C/theadu003Enu003Ctbodyu003En u003Ctr class=u0022region-message region-visible-message region-
populatedu0022u003Eu003Ctd colspan=u00227u0022u003Eu041fu043eu043bu0435u0439 u043du0435u0442.u003C/tdu003E
u003C/tru003En u003Ctr class=u0022draggable tabledrag-leaf field-formatter-settings-editing oddu0022 id=u0022field-
imgu0022u003Eu003Ctdu003Eu041au0430u0440u0442u0438u043du043au0430u003C/tdu003Eu003Ctdu003Eu003Cdiv
class=u0022form-item form-type-textfield form-item-fields-field-img-weightu0022u003En u003Clabel class=u0022element-
invisibleu0022 for=u0022edit-fields-field-img-weight—2u0022u003Eu0412u0435u0441
u041au0430u0440u0442u0438u043du043au0430 u003C/labelu003En u003Cinput class=u0022field-weight form-textu0022
type=u0022textu0022 id=u0022edit-fields-field-img-weight—2u0022 name=u0022fields[field_img][weight]u0022 value=u00220u0022
size=u00223u0022 maxlength=u0022128u0022 /u003Enu003C/divu003Enu003C/tdu003Eu003Ctdu003Eu003Cdiv class=u0022form-
item form-type-select form-item-fields-field-img-parentu0022u003En u003Clabel class=u0022element-invisibleu0022
for=u0022edit-fields-field-img-parent—2u0022u003Eu041eu0442u043eu0431u0440u0430u0436u0430u0435u043cu0430u044f
u043cu0435u0442u043au0430 u0434u043bu044f u041au0430u0440u0442u0438u043du043au0430 u003C/labelu003En
u003Cselect class=u0022field-parent form-selectu0022 id=u0022edit-fields-field-img-parent—2u0022 name=u0022fields[field_img]
[parent]u0022u003Eu003Coption value=u0022u0022 selected=u0022selectedu0022u003E- u041du0435
u0443u043au0430u0437u0430u043du043e —u003C/optionu003Eu003Coption
value=u0022_add_new_groupu0022u003Eu0414u043eu0431u0430u0432u0438u0442u044c u043du043eu0432u0443u044e
u0433u0440u0443u043fu043fu0443u003C/optionu003Eu003C/selectu003Enu003C/divu003Enu003Cinput class=u0022field-
nameu0022 type=u0022hiddenu0022 name=u0022fields[field_img][parent_wrapper][hidden_name]u0022 value=u0022field_imgu0022
/u003Enu003C/tdu003Eu003Ctdu003Eu003Cdiv class=u0022form-item form-type-select form-item-fields-field-img-
labelu0022u003En u003Clabel class=u0022element-invisibleu0022 for=u0022edit-fields-field-img-label-
-2u0022u003Eu041eu0442u043eu0431u0440u0430u0436u0430u0435u043cu0430u044f u043cu0435u0442u043au0430
u0434u043bu044f u041au0430u0440u0442u0438u043du043au0430 u003C/labelu003En u003Cselect id=u0022edit-fields-field-
img-label—2u0022 name=u0022fields[field_img][label]u0022 class=u0022form-selectu0022u003Eu003Coption
value=u0022aboveu0022u003Eu0421u0432u0435u0440u0445u0443u003C/optionu003Eu003Coption
value=u0022inlineu0022u003Eu0412 u043bu0438u043du0438u044eu003C/optionu003Eu003Coption value=u0022hiddenu0022
selected=u0022selectedu0022u003Eu0026lt;u0421u043au0440u044bu0442u043eu0026gt;u003C/optionu003Eu003C/selectu003En
u003C/divu003Enu003C/tdu003Eu003Ctd colspan=u00223u0022u003Eu003Cdiv class=u0022ajax-new-contentu0022u003Eu003Cdiv
class=u0022form-item form-type-select form-item-fields-field-img-typeu0022u003En u003Clabel class=u0022element-
invisibleu0022 for=u0022edit-fields-field-img-type—2u0022u003Eu0417u0430u0434u0430u043du0438u0435
u0444u043eu0440u043cu0430u0442u0430 u0434u043bu044f u041au0430u0440u0442u0438u043du043au0430
u003C/labelu003En u003Cselect class=u0022field-formatter-type form-selectu0022 id=u0022edit-fields-field-img-type—2u0022
name=u0022fields[field_img][type]u0022u003Eu003Coption value=u0022imageu0022
selected=u0022selectedu0022u003Eu0418u0437u043eu0431u0440u0430u0436u0435u043du0438u0435u003C/optionu003Eu003Copti
on
value=u0022hiddenu0022u003Eu0026lt;u0421u043au0440u044bu0442u043eu0026gt;u003C/optionu003Eu003C/selectu003Enu003
C/divu003Enu003Cdiv class=u0022field-formatter-settings-edit-form form-wrapperu0022 id=u0022edit-fields-field-img-settings-
edit-formu0022u003Eu041du0430u0441u0442u0440u043eu0439u043au0438 u0444u043eu0440u043cu0430u0442u0430: u003Cspan
class=u0022formatter-nameu0022u003Eu0418u0437u043eu0431u0440u0430u0436u0435u043du0438u0435u003C/spanu003Eu003Cdiv
class=u0022form-item form-type-select form-item-fields-field-img-settings-edit-form-settings-image-styleu0022u003En
u003Clabel for=u0022edit-fields-field-img-settings-edit-form-settings-image-styleu0022u003Eu0421u0442u0438u043bu044c
u0438u0437u043eu0431u0440u0430u0436u0435u043du0438u044f u003C/labelu003En u003Cselect id=u0022edit-fields-field-
img-settings-edit-form-settings-image-styleu0022 name=u0022fields[field_img][settings_edit_form][settings][image_style]u0022
class=u0022form-selectu0022u003Eu003Coption value=u0022u0022 selected=u0022selectedu0022u003Eu041du0435u0442
(u043eu0440u0438u0433u0438u043du0430u043bu044cu043du043eu0435
u0438u0437u043eu0431u0440u0430u0436u0435u043du0438u0435)u003C/optionu003Eu003Coption
value=u0022avataru0022u003Eavataru003C/optionu003Eu003Coption value=u0022thumbnailu0022u003EThumbnail
(100×100)u003C/optionu003Eu003Coption value=u0022mediumu0022u003EMedium (220×220)u003C/optionu003Eu003Coption
value=u0022largeu0022u003ELarge (480×480)u003C/optionu003Eu003C/selectu003Enu003C/divu003Enu003Cdiv
class=u0022form-item form-type-select form-item-fields-field-img-settings-edit-form-settings-image-linku0022u003En u003Clabel
for=u0022edit-fields-field-img-settings-edit-form-settings-image-
linku0022u003Eu0418u0437u043eu0431u0440u0430u0436u0435u043du0438u0435 u043au0430u043a
u0441u0441u044bu043bu043au0430 u043du0430 u003C/labelu003En u003Cselect id=u0022edit-fields-field-img-settings-edit-
form-settings-image-linku0022 name=u0022fields[field_img][settings_edit_form][settings][image_link]u0022 class=u0022form-
selectu0022u003Eu003Coption value=u0022u0022
selected=u0022selectedu0022u003Eu041du0438u0447u0435u0433u043eu003C/optionu003Eu003Coption
value=u0022contentu0022u003Eu0421u043eu0434u0435u0440u0436u0438u043cu043eu0435u003C/optionu003Eu003Coption
value=u0022fileu0022u003Eu0424u0430u0439u043bu003C/optionu003Eu003C/selectu003Enu003C/divu003Enu003Cdiv
class=u0022form-actions form-wrapperu0022 id=u0022edit-fields-field-img-settings-edit-form-actionsu0022u003Eu003Cinput
type=u0022submitu0022 id=u0022edit-fields-field-img-settings-edit-form-actions-save-settingsu0022
name=u0022field_img_formatter_settings_updateu0022 value=u0022u041eu0431u043du043eu0432u0438u0442u044cu0022
class=u0022form-submitu0022 /u003Eu003Cinput type=u0022submitu0022 id=u0022edit-fields-field-img-settings-edit-form-
actions-cancel-settingsu0022 name=u0022field_img_formatter_settings_cancelu0022
value=u0022u041eu0442u043cu0435u043du0438u0442u044cu0022 class=u0022form-submitu0022
/u003Eu003C/divu003Eu003C/divu003Eu003C/divu003Eu003C/tdu003E u003C/tru003En u003Ctr class=u0022draggable
tabledrag-leaf evenu0022
id=u0022bodyu0022u003Eu003Ctdu003Eu0422u0435u043au0441u0442u003C/tdu003Eu003Ctdu003Eu003Cdiv class=u0022form-item
form-type-textfield form-item-fields-body-weightu0022u003En u003Clabel class=u0022element-invisibleu0022 for=u0022edit-
fields-body-weight—2u0022u003Eu0412u0435u0441 u0422u0435u043au0441u0442 u003C/labelu003En u003Cinput
class=u0022field-weight form-textu0022 type=u0022textu0022 id=u0022edit-fields-body-weight—2u0022 name=u0022fields[body]
[weight]u0022 value=u00221u0022 size=u0022
Не могу понять в чем дело, в гугле искал решение, много что нашел, и что F5 нужно просто нажать, увеличить memory, которая у меня и так 128MB от хостера, и что в файле local.inc нужно увеличить время ответа скриптов, но ничего не помогло. Подскажите что нибудь, пожалуйста.
- Drupal7
- Есть вопрос
- Решение проблем
I’m new to Drupal, and I’m working with a Drupal site that someone else wrote. From the admin menu, when I go to Structure -> Pages -> Edit Content -> Gear Menu -> Edit (or Settings), Drupal throws up this error:
«An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging
information follows. Path:
/panels/ajax/editor/edit-pane/panel_context%3Apage-join_step_two%3Apage_join_step_two_panel_context/4
[…] RESPONSE = nullnullnullnullnullnullnullnullfalseCancelled: Error
bad character content for element
‘data_key’________nullnullnullfalsenullnull»
The code is also inserting the line
«RESPONSE = nullnullnullnullnullnullnullnullfalseCancelled: Error bad
character content for element ‘data_key’ ________
nullnullnullfalsenullnull»
at the bottom of every page.
I know that Firebug can cause the Ajax HTTP 200 error, but I don’t have it installed. I’ve spent hours looking through help pages for this error, and nothing has worked. Can you help? Thanks!
Chapabu
13.8k2 gold badges38 silver badges58 bronze badges
asked Aug 13, 2012 at 1:16
we need to uncomment .htaccess file in php_value auto_append_file none may be it work.
in ajax return value must be defined.if not exist show this kind of error.clear cache.
one other solution if you working on the local you need to disable newest module than check it[first you need to take DB backup].
answered Aug 13, 2012 at 7:01
1
-
Just disable recently enabled module. or
-
May be this error comes to the jQuery module 1.8, not come in 1.7 so check it updated or not.
-
Every module start with
<?php. just check this line.
This seems to have occurred because of a Javascript conflict with some other module or theme.
Many users solved the issue by doing the following;
-
Removing the Drupal for Firebug addon (This did the trick for a majority of the users who reported the issue).
-
Disabling Firebug.
-
Flushing the theme’s cache.
-
Uninstalling Jquery UI and Jquery Update modules.
-
Removing the Twitter Profile module solved the issue for a small number of users.
-
Disabling the Theme Developer module solved the issues for a user.
WaQaR Ali
1,68812 silver badges23 bronze badges
answered Sep 10, 2014 at 13:04
2
Ajax HTTP 200 error is generic error and there is not enough info to properly solve it.
You’ll need to:
grep -r "find in files" .
in the code base the string data_key (or whatever is printed) and can then debug from there.
kenorb
13.8k10 gold badges93 silver badges159 bronze badges
answered May 30, 2013 at 7:47
David ThomasDavid Thomas
21.8k2 gold badges29 silver badges68 bronze badges
2
Error bad character content for element
means there is a validation error in your XML while parsing the file or response.
This could be related to some external service or custom module breaking Drupal instance.
The problem can be tracked by looking for some specifics in the database, e.g.:
drush sql-dump --ordered-dump | grep data_key
answered Nov 23, 2015 at 11:17
kenorbkenorb
13.8k10 gold badges93 silver badges159 bronze badges
I’m new to Drupal, and I’m working with a Drupal site that someone else wrote. From the admin menu, when I go to Structure -> Pages -> Edit Content -> Gear Menu -> Edit (or Settings), Drupal throws up this error:
«An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging
information follows. Path:
/panels/ajax/editor/edit-pane/panel_context%3Apage-join_step_two%3Apage_join_step_two_panel_context/4
[…] RESPONSE = nullnullnullnullnullnullnullnullfalseCancelled: Error
bad character content for element
‘data_key’________nullnullnullfalsenullnull»
The code is also inserting the line
«RESPONSE = nullnullnullnullnullnullnullnullfalseCancelled: Error bad
character content for element ‘data_key’ ________
nullnullnullfalsenullnull»
at the bottom of every page.
I know that Firebug can cause the Ajax HTTP 200 error, but I don’t have it installed. I’ve spent hours looking through help pages for this error, and nothing has worked. Can you help? Thanks!
Chapabu
13.8k2 gold badges38 silver badges58 bronze badges
asked Aug 13, 2012 at 1:16
we need to uncomment .htaccess file in php_value auto_append_file none may be it work.
in ajax return value must be defined.if not exist show this kind of error.clear cache.
one other solution if you working on the local you need to disable newest module than check it[first you need to take DB backup].
answered Aug 13, 2012 at 7:01
1
-
Just disable recently enabled module. or
-
May be this error comes to the jQuery module 1.8, not come in 1.7 so check it updated or not.
-
Every module start with
<?php. just check this line.
This seems to have occurred because of a Javascript conflict with some other module or theme.
Many users solved the issue by doing the following;
-
Removing the Drupal for Firebug addon (This did the trick for a majority of the users who reported the issue).
-
Disabling Firebug.
-
Flushing the theme’s cache.
-
Uninstalling Jquery UI and Jquery Update modules.
-
Removing the Twitter Profile module solved the issue for a small number of users.
-
Disabling the Theme Developer module solved the issues for a user.
WaQaR Ali
1,68812 silver badges23 bronze badges
answered Sep 10, 2014 at 13:04
2
Ajax HTTP 200 error is generic error and there is not enough info to properly solve it.
You’ll need to:
grep -r "find in files" .
in the code base the string data_key (or whatever is printed) and can then debug from there.
kenorb
13.8k10 gold badges93 silver badges159 bronze badges
answered May 30, 2013 at 7:47
David ThomasDavid Thomas
21.8k2 gold badges29 silver badges68 bronze badges
2
Error bad character content for element
means there is a validation error in your XML while parsing the file or response.
This could be related to some external service or custom module breaking Drupal instance.
The problem can be tracked by looking for some specifics in the database, e.g.:
drush sql-dump --ordered-dump | grep data_key
answered Nov 23, 2015 at 11:17
kenorbkenorb
13.8k10 gold badges93 silver badges159 bronze badges
<?php/**
* Set up batch for first and last name loading.
*
* This is where Drupal's Batch API comes into play.
* It's as simple as defining $batch, and then calling batch_set($batch)
*/
function kladr_create() {// Update the user profiles to add values to newly added profile fields
$batch = array(
'title' => t('Creating kladr vocabulary'), // Title to display while running.
'operations' => array(), // Operations to complete, in order. Defined below.
'finished' => '_kladr_vocabulary_finished', // Last function to call.
'init_message' => t('Initializing...'),
'progress_message' => t('Fixed @current out of @total.'),
'error_message' => t('Creating encountered an error.'),
);// Add as many operations as you need. They'll run in the order specified.
// Parameters can be defined in the (currently) empty arrays and will need
// to also be added following the $context parameters for the operation
// functions below.
$batch['operations'][] = array('_kladr_vocabulary_select', array());
$batch['operations'][] = array('_kladr_vocabulary_create_structure', array());
$batch['operations'][] = array('_kladr_vocabulary_insert_data', array());// Tip the first domino.
batch_set($batch);
}/**
*
*/
function _kladr_vocabulary_select(&$context) {$vid = variable_get('kladr_taxonomy', FALSE);
if($vid) {
$vocabulary = taxonomy_vocabulary_load($vid);if ($vocabulary->name) {
$context['message'] = 'Selected taxonomy vocabulary '. $vocabulary->name;
$context['finished'] = 1;
return;
}
}
$context['finished'] = 0;
}/**
* Create a taxonomy term and return the tid.
*/
function custom_create_taxonomy_term($name, $vid, $parent_id = 0) {
$term = new stdClass();
$term->name = $name;
$term->vid = $vid;
$term->parent = array($parent_id);
taxonomy_term_save($term);
return $term->tid;
}function get_taxonomy_tid($name, $vid, $parent_tid = 0) {
$query = db_select('taxonomy_term_data', 't');
$query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
$query->addField('t', 'tid');
$query->condition('h.parent', $parent_tid);
$query->condition('t.name', trim($name));
$query->condition('t.vid', $vid);
$tids = $query->execute()->fetchCol();return isset($tids) && is_array($tids) && count($tids) > 0 ? $tids[0] : NULL;
}function getParentTaxonomyId($cc, $rrr) {
$sql = "SELECT tid FROM {kladr_taxonomy} WHERE cc = :cc and rrr = :rrr";
$params = array(':cc' => $cc, ':rrr' => $rrr);
return db_query($sql, $params)->fetchField();
}/**
*
*/function _kladr_vocabulary_create_structure(&$context) {
$vid = variable_get('kladr_taxonomy', FALSE);
$start_from_row = variable_get('kladr_taxonomy_last', 1);if(!$vid OR $start_from_row > 1) {
$context['finished'] = 1;
return;
}// open in read-only mode
$db = dbase_open(drupal_get_path('module', 'kladr') .'/BASE/KLADR.DBF', 0);
if ($db) {
$record_numbers = dbase_numrecords($db);
for ($i = 1; $i <= $record_numbers; $i++) {
$row= dbase_get_record($db, $i);$name=trim(mb_convert_encoding($row[0], "UTF-8", "cp866")); // Наименование
$socr=trim(mb_convert_encoding($row[1], "UTF-8", "cp866")); // Сокращенное наименование типа объекта
$code=$row[2]; // Код
$index=$row[3]; // Почтовый индекс
$gninmb=$row[4]; // Код ИФНС
$uno=$row[5]; // Код территориального участка ИФНС
$ocatd=$row[6]; // Код ОКАТО
$status=$row[7]; // Статус объекта$CC = (int)substr($code, 0, 2);
$RRR = (int)substr($code, 2, 3);
$GGG = (int)substr($code, 5, 3);
$PPP = (int)substr($code, 8, 3);
$AA = (int)substr($code, 11, 2);if ($RRR==0 AND $GGG==0 AND $PPP==0 AND $AA==0){ // region
$name = $name . ' ' . $socr;
$tid = get_taxonomy_tid($name, $vid, 0);
if ($tid) {
drupal_set_message('* region ' . $name . ' already exists (tid: ' . $tid . ')');
} else {
$tid = custom_create_taxonomy_term($name, $vid, 0);
drupal_set_message('+ added region: ' . $name);
}if (!getParentTaxonomyId($CC, 0))
db_query('INSERT INTO {kladr_taxonomy} (cc, rrr, tid, name) VALUES(:cc, 0, :tid, :name)', array(':cc' => $CC, ':tid' => $tid, ':name' => $name));} else if ($GGG==0 AND $PPP==0 AND $AA==0) { // subregion
$name = $name . ' ' . $socr;
$parent_tid = getParentTaxonomyId($CC, 0);
if ($parent_tid) {
$tid = get_taxonomy_tid($name, $vid, $parent_tid);
// drupal_set_message($name . ' -> parent tid: ' . $parent_tid . ', tid: ' . $tid);
if ($tid) {
drupal_set_message(' * subregion: ' . $name . ' already exists in taxonomy (tid: ' . $tid . ')');
} else {
$tid = custom_create_taxonomy_term($name, $vid, $parent_tid);
drupal_set_message(' + added subregion: ' . $name . ', tid: ' . $tid);
}if (!getParentTaxonomyId($CC, $RRR))
db_query('INSERT INTO {kladr_taxonomy} (cc, rrr, tid, name) VALUES(:cc, :rrr, :tid, :name)', array(':cc' => $CC, ':rrr' => $RRR, ':tid' => $tid, ':name' => $name));
} else {
drupal_set_message(' - parent not found for subregion: ' . $name . ", id: " . $CC . ", sub_id: " . $RRR . ', parent_tid: ' . $parent_tid, 'warning');
}
}
}
}
dbase_close($db);$context['finished'] = 1;
}function startsWith($haystack, $needle)
{
return !strncmp($haystack, $needle, strlen($needle));
}/**
*
*/
function _kladr_vocabulary_insert_data(&$context) {$vid = variable_get('kladr_taxonomy', FALSE);
if(!$vid) {
$context['finished'] = 1;
return;
}// open in read-only mode
$db = dbase_open(drupal_get_path('module', 'kladr') .'/BASE/KLADR.DBF', 0);if ($db) {
$insert_rows_for_one_time = 50000;
$start_from_row = variable_get('kladr_taxonomy_last', 1);$record_numbers = dbase_numrecords($db);
drupal_set_message('DB opened, ' . $record_numbers . ' records');
for ($i = $start_from_row;
$i <= $record_numbers AND $i <= ($start_from_row + $insert_rows_for_one_time);
$i++) {
variable_set('kladr_taxonomy_last', $i);$row= dbase_get_record($db, $i);
$name=trim(mb_convert_encoding($row[0], "UTF-8", "cp866")); // Наименование
$socr=trim(mb_convert_encoding($row[1], "UTF-8", "cp866")); // Сокращенное наименование типа объекта
$code=$row[2]; // Код
$index=$row[3]; // Почтовый индекс
$gninmb=$row[4]; // Код ИФНС
$uno=$row[5]; // Код территориального участка ИФНС
$ocatd=$row[6]; // Код ОКАТО
$status=$row[7]; // Статус объекта$CC = (int)substr($code, 0, 2);
$RRR = (int)substr($code, 2, 3);
$GGG = (int)substr($code, 5, 3);
$PPP = (int)substr($code, 8, 3);
$AA = (int)substr($code, 11, 2);// drupal_set_message("::1 - term: name=$name, $code=$CC|$RRR");
if ($RRR==0 AND $GGG==0 AND $PPP==0 AND $AA==0){
// debug stub
// we process this case in _kladr_vocabulary_create_structure
} else if ($GGG==0 AND $PPP==0 AND $AA==0){
// debug stub
// we process this case in _kladr_vocabulary_create_structure
} else if (($status>0 OR $socr='г') AND $AA==0 AND !startsWith($name, 'сдт')){
$parent_tid = getParentTaxonomyId($CC, $RRR);
if ($parent_tid) {
$tid = get_taxonomy_tid($name, $vid, $parent_tid);
if (!$tid)
$tid = custom_create_taxonomy_term($name, $vid, $parent_tid);
// drupal_set_message(' + added settlement: ' . $name);
} else {
drupal_set_message(' - parent not fount for settlement: ' . $name . ", cc: " . $CC . ", rrr: " . $RRR);
}
}}
drupal_set_message('DB last inserted record '. $i);dbase_close($db);
}
$context['finished'] = 1;
}/**
*
*/
function _kladr_vocabulary_finished($success, $results, $operations) {if ($success) {
$message = t('KLADR taxonomy vocabulary updated.');
}
else {
$message = t('Finished with error.');
}
drupal_set_message($message);
}/**
* Save recursive array of terms for a vocabulary.
*
* Example:
* <code><?php
* $terms = array(
* 'Species' => array(
* 'Dog',
* 'Cat',
* 'Bird' ),
* 'Sex' => array(
* 'Male',
* 'Female' ) )
* _save_terms_recursive( $vid, $terms );
* </code>
*
* @param int $vid Vocabulary id
* @param array $terms Recursive array of terms
* @param int $ptid Parent term id (generated by taxonomy_save_term)
*/
function _save_terms_recursive( $vid, &$terms, $ptid=0 ) {
foreach ( $terms as $k => $v ) {
// simple check for numeric indices (term array without children)
$name = is_string( $k ) ? $k : $v;
$term = array( 'vid' => $vid, 'name' => $name, 'parent' => $ptid );
drupal_set_message("_save_terms_recursive - term: " . print_r($term, true));
// taxonomy_save_term( $term );
if ( is_array( $v ) && count( $v ) )
_save_terms_recursive( $vid, $terms[ $k ], $term[ 'tid' ] );
}
}
