| 1 |
<?php |
<?php |
| 2 |
// $Id: import_html_ui.inc,v 1.11.4.16 2009/05/09 14:18:32 dman Exp $ |
// $Id: import_html_ui.inc,v 1.11.4.17 2009/05/17 15:12:46 dman Exp $ |
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 5 |
* Forms and UI functions for import_html. |
* Forms and UI functions for import_html. |
| 60 |
$form['#submit'][] = 'import_html_profile_settings_submit'; |
$form['#submit'][] = 'import_html_profile_settings_submit'; |
| 61 |
$form['#validate'][] = 'import_html_profile_settings_validate'; |
$form['#validate'][] = 'import_html_profile_settings_validate'; |
| 62 |
|
|
| 63 |
|
|
| 64 |
$form['import_html_proceed'] = array( |
$form['import_html_proceed'] = array( |
| 65 |
'#value' => '<h2>'. l(t("Proceed to import"), IMPORT_HTML_ADMIN_PATH .'/import_site') .'</h2><br/>', |
'#type' => 'submit', |
| 66 |
|
'#value' => t("Proceed to import"), |
| 67 |
|
'#submit' => array('import_html_goto_process'), |
| 68 |
|
'#prefix' => '<br/>', |
| 69 |
|
#'#attributes' => array('style' => 'font-size:2em;'), |
| 70 |
|
'#attributes' => array('style' => 'font-size:2em; height:2.4em; margin-top:0em'), |
| 71 |
); |
); |
| 72 |
|
|
| 73 |
// Links to other profiles |
// Links to other profiles |
| 80 |
} |
} |
| 81 |
|
|
| 82 |
/** |
/** |
| 83 |
|
* Small submit handler to redirect to the process form - just so we get a |
| 84 |
|
* button |
| 85 |
|
*/ |
| 86 |
|
function import_html_goto_process() { |
| 87 |
|
drupal_goto(IMPORT_HTML_ADMIN_PATH .'/import_site'); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
/** |
| 91 |
* This function attempts to analyse and repair your MySQL config. |
* This function attempts to analyse and repair your MySQL config. |
| 92 |
* It is highly likely the ability to do this will be restricted on shared |
* It is highly likely the ability to do this will be restricted on shared |
| 93 |
* hosts, but try anyway. |
* hosts, but try anyway. |
| 766 |
// Save only the variables I care about |
// Save only the variables I care about |
| 767 |
$keys = array_keys(import_html_profile_defaults()); |
$keys = array_keys(import_html_profile_defaults()); |
| 768 |
foreach ($keys as $key) { |
foreach ($keys as $key) { |
| 769 |
$profile[$key] = $form_state['values'][$key]; |
// It's possible that some values are not relevant if modules (path/taxonomy) are not enabled |
| 770 |
|
if ( isset($form_state['values'][$key]) ) { |
| 771 |
|
$profile[$key] = $form_state['values'][$key]; |
| 772 |
|
} |
| 773 |
} |
} |
| 774 |
|
|
| 775 |
// Save it as a blob |
// Save it as a blob |
| 814 |
} |
} |
| 815 |
else { |
else { |
| 816 |
$form['import_category'] = array( |
$form['import_category'] = array( |
| 817 |
'#value' => t("<p>There are no vocabularies available to tag the imported content with. <a href='!add_vocab'>Create one</a> if you like.</p>", array('!add_vocab' => url('admin/content/taxonomy'))), |
'#value' => t("<p><b>Taxonomy:</b> There are no vocabularies available to tag the imported content with. <a href='!add_vocab'>Create one</a> if you like.</p>", array('!add_vocab' => url('admin/content/taxonomy'))), |
| 818 |
); |
); |
| 819 |
} |
} |
| 820 |
|
|
| 954 |
|
|
| 955 |
$profile_id = isset($form_state['values']['profile_id']) ? $form_state['values']['profile_id'] : import_html_current_profile_id(); |
$profile_id = isset($form_state['values']['profile_id']) ? $form_state['values']['profile_id'] : import_html_current_profile_id(); |
| 956 |
$profile = import_html_profile($profile_id); |
$profile = import_html_profile($profile_id); |
| 957 |
|
// Display this on every page - help knowing just what's happening |
| 958 |
|
$form['profile_info'] = array( |
| 959 |
|
'#value' => '<h4>'. t("Using %profile_id profile", array('%profile_id' => $profile_id)) .'</h4>', |
| 960 |
|
); |
| 961 |
|
$form['profile_id'] = array('#type' => 'hidden', '#default_value' => $profile_id); |
| 962 |
|
|
| 963 |
|
|
| 964 |
// Note the current context and state info as the rendering functiona and submit process needs to know |
// Note the current context and state info as the rendering functiona and submit process needs to know |
| 965 |
if (isset($form_state['values'])) { |
if (isset($form_state['values'])) { |
| 966 |
$form['source_siteroot'] = array( '#type' => 'hidden', '#default_value' => $form_state['values']['source_siteroot']); |
$form['source_siteroot'] = array( '#type' => 'hidden', '#default_value' => $form_state['values']['source_siteroot']); |
| 967 |
$form['current_subsection'] = array( '#type' => 'hidden', '#default_value' => $form_state['values']['current_subsection']); |
$form['current_subsection'] = array( '#type' => 'hidden', '#default_value' => $form_state['values']['current_subsection']); |
| 968 |
} |
} |
|
$form['profile_id'] = array('#type' => 'hidden', '#default_value' => $profile_id); |
|
| 969 |
|
|
| 970 |
/* |
/* |
| 971 |
@dpm(array( |
@dpm(array( |
| 990 |
$profile['current_subsection'] = variable_get('import_html_current_subsection', ''); |
$profile['current_subsection'] = variable_get('import_html_current_subsection', ''); |
| 991 |
} |
} |
| 992 |
|
|
|
// Display this on every page - help knowing just what's happening |
|
|
$form['profile_info'] = array( |
|
|
'#value' => '<h2>'. t("Using profile %profile_id", array('%profile_id' => $profile_id)) .'</h2>', |
|
|
); |
|
|
|
|
| 993 |
switch ($form_state['storage']['step']) { |
switch ($form_state['storage']['step']) { |
| 994 |
|
|
| 995 |
case 1: |
case 1: |
| 1161 |
$form = array(); |
$form = array(); |
| 1162 |
|
|
| 1163 |
$form['help'] = array('#type' => 'markup', '#value' => t("<p> |
$form['help'] = array('#type' => 'markup', '#value' => t("<p> |
| 1164 |
For a quick intro, try <a href='!demo_link'>a quick demo</a>. |
For an intro, try <a href='!demo_link'>a quick demo</a>. |
| 1165 |
</p><p> |
</p><p> |
| 1166 |
The source website files must be directly available to this server. |
The source website files must be directly available to this server. |
| 1167 |
This process will NOT yet import the structure of a client website to a remote server, |
This process will NOT yet import the structure of a client website on a remote server, |
| 1168 |
or spider all the resources of a remote site. |
or spider all the resources of a remote site. |
| 1169 |
</p><p> |
</p><p> |
| 1170 |
<b>Note</b> Big sites <i>will</i> take a long time to process, |
<b>Note</b> Big sites <i>will</i> take a long time to process, |
| 1342 |
// @see filetype_selectors.js |
// @see filetype_selectors.js |
| 1343 |
$form['selectors'] = array( |
$form['selectors'] = array( |
| 1344 |
'#weight' => -2, |
'#weight' => -2, |
| 1345 |
'#value' => "<p id='import-html-selectors'>Select Files to import</p>", |
'#value' => "<p id='import-html-selectors'>Select files to import<br/></p>", |
| 1346 |
); |
); |
| 1347 |
|
|
| 1348 |
// Need to convert the sructured tree into a structured form |
// Need to convert the sructured tree into a structured form |
| 1538 |
// We cheat by setting the '#parents' manually before rendering, and using a counter of our own |
// We cheat by setting the '#parents' manually before rendering, and using a counter of our own |
| 1539 |
static $checkbox_count; |
static $checkbox_count; |
| 1540 |
|
|
|
// special case: if name is blank (we are at root) show the working dir |
|
|
if (! $tree['#value']) $tree['#value'] = variable_get('import_html_source_siteroot', "") ; |
|
| 1541 |
|
|
| 1542 |
$element = array(); |
$element = array(); |
| 1543 |
|
|
| 1590 |
); |
); |
| 1591 |
} |
} |
| 1592 |
$item_type = ($tree['#type'] == 'tree_branch') ? "container" : import_html_guess_file_class($tree['#filename']); |
$item_type = ($tree['#type'] == 'tree_branch') ? "container" : import_html_guess_file_class($tree['#filename']); |
| 1593 |
|
|
| 1594 |
|
// special case: if name is blank (we are at root) show the working dir |
| 1595 |
|
if (! $tree['#value']) { |
| 1596 |
|
$item_type = 'tree-root'; |
| 1597 |
|
$element['#title'] = $form_values['source_siteroot']; |
| 1598 |
|
} |
| 1599 |
|
|
| 1600 |
$element['#item-type'] = $item_type; // made-up attribute to pass to theme |
$element['#item-type'] = $item_type; // made-up attribute to pass to theme |
| 1601 |
$element['#item-path'] = $item_type; // made-up attribute to pass to theme |
$element['#item-path'] = $item_type; // made-up attribute to pass to theme |
| 1602 |
$element['#attributes']['class'] .= ' '. $item_type; |
$element['#attributes']['class'] .= ' '. $item_type; |
| 1603 |
|
|
| 1604 |
|
|
| 1605 |
// Construct the content |
// Construct the content |
| 1606 |
|
|
| 1659 |
* If you want the normal rendering back (description, value) put it in yourself. |
* If you want the normal rendering back (description, value) put it in yourself. |
| 1660 |
*/ |
*/ |
| 1661 |
function theme_tree_branch($element) { |
function theme_tree_branch($element) { |
|
|
|
| 1662 |
$toggle_button = $element['file_rel_dir']; |
$toggle_button = $element['file_rel_dir']; |
| 1663 |
$checked = $toggle_button['#value'] ? ' checked="checked" ' : ' '; |
$checked = $toggle_button['#value'] ? ' checked="checked" ' : ' '; |
| 1664 |
$atts = drupal_attributes($toggle_button['#attributes']); |
$atts = drupal_attributes($toggle_button['#attributes']); |
| 1665 |
$item_checkbox = "<input type='checkbox' name='{$toggle_button['#name']}' id='{$toggle_button['#id']}' value='{$toggle_button['#return_value']}' $checked $atts />"; |
$item_checkbox = "<input type='checkbox' name='{$toggle_button['#name']}' id='{$toggle_button['#id']}' value='{$toggle_button['#return_value']}' $checked $atts />"; |
| 1666 |
$item = "<label>$item_checkbox {$element['#title']}</label>"; |
$item = "<label>$item_checkbox {$element['#title']}</label>"; |
| 1667 |
|
|
| 1668 |
$children = empty($element['children']) ? '' : |
$children = empty($element['children']) ? '' : |
| 1669 |
'<div'. drupal_attributes($element['children']['#attributes']) .'>' |
'<div'. drupal_attributes($element['children']['#attributes']) .'>' |
| 1670 |
. drupal_render($element['children'] ) |
. drupal_render($element['children'] ) |
| 1673 |
|
|
| 1674 |
return |
return |
| 1675 |
'<fieldset'. drupal_attributes($element['#attributes']) .'>' |
'<fieldset'. drupal_attributes($element['#attributes']) .'>' |
| 1676 |
.'<legend>'. $item .'</legend>' |
."<legend class=\"{$element['#item-type']}-label\">{$item}</legend>" |
| 1677 |
. (isset($element['#description']) && $element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '') |
. (isset($element['#description']) && $element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '') |
| 1678 |
. $children |
. $children |
| 1679 |
. (isset($element['#value']) ? $element['#value'] : '') |
. (isset($element['#value']) ? $element['#value'] : '') |