diff options
| author | fisharebest <fisharebest@gmail.com> | 2010-05-24 16:12:01 +0000 |
|---|---|---|
| committer | fisharebest <fisharebest@gmail.com> | 2010-05-24 16:12:01 +0000 |
| commit | 65072e6af27a6e8c802073fc560a79392118ed3a (patch) | |
| tree | 19f8e578e5b3d25c0c72cf4da81e253f235e3391 /includes/functions | |
| parent | 2bf6a6072a5a4eb89143ffcdb4871d5a8396809b (diff) | |
| download | webtrees-65072e6af27a6e8c802073fc560a79392118ed3a.tar.gz webtrees-65072e6af27a6e8c802073fc560a79392118ed3a.tar.bz2 webtrees-65072e6af27a6e8c802073fc560a79392118ed3a.zip | |
Tables and blocks. Add wt_module_settings, move wt_nextid to wt_next_id, remove html block - just have adv-html block.
Diffstat (limited to 'includes/functions')
| -rw-r--r-- | includes/functions/functions.php | 26 | ||||
| -rw-r--r-- | includes/functions/functions_db.php | 28 | ||||
| -rw-r--r-- | includes/functions/functions_import.php | 6 | ||||
| -rw-r--r-- | includes/functions/functions_print_facts.php | 2 |
4 files changed, 44 insertions, 18 deletions
diff --git a/includes/functions/functions.php b/includes/functions/functions.php index d51db78928..1e9d066b2b 100644 --- a/includes/functions/functions.php +++ b/includes/functions/functions.php @@ -2888,7 +2888,7 @@ function get_new_xref($type='INDI', $ged_id=WT_GED_ID, $use_cache=false) { } $num= - WT_DB::prepare("SELECT ni_id FROM {$TBLPREFIX}nextid WHERE ni_type=? AND ni_gedfile=?") + WT_DB::prepare("SELECT next_id FROM {$TBLPREFIX}next_id WHERE record_type=? AND gedcom_id=?") ->execute(array($type, $ged_id)) ->fetchOne(); @@ -2898,8 +2898,8 @@ function get_new_xref($type='INDI', $ged_id=WT_GED_ID, $use_cache=false) { if (is_null($num)) { $num = 1; - WT_DB::prepare("INSERT INTO {$TBLPREFIX}nextid VALUES(?, ?, ?)") - ->execute(array($num+1, $type, $ged_id)); + WT_DB::prepare("INSERT INTO {$TBLPREFIX}next_id (gedcom_id, record_type, next_id) VALUES(?, ?, 1)") + ->execute(array($ged_id, $type)); } //-- make sure this number has not already been used @@ -2917,7 +2917,7 @@ function get_new_xref($type='INDI', $ged_id=WT_GED_ID, $use_cache=false) { $key = $prefix.$num; //-- update the next id number in the DB table - WT_DB::prepare("UPDATE {$TBLPREFIX}nextid SET ni_id=? WHERE ni_type=? AND ni_gedfile=?") + WT_DB::prepare("UPDATE {$TBLPREFIX}next_id SET next_id=? WHERE record_type=? AND gedcom_id=?") ->execute(array($num+1, $type, $ged_id)); return $key; } @@ -3009,7 +3009,7 @@ function mediaFileInfo($fileName, $thumbName, $mid, $name='', $notes='', $obeyVi // -- Classify the incoming media file if (preg_match('~^https?://~i', $fileName)) $type = 'url_'; else $type = 'local_'; - if ((preg_match('/\.flv$/i', $fileName) || preg_match('~^https?://.*\.youtube\..*/watch\?~i', $fileName)) && is_dir(WT_ROOT.'modules/JWplayer')) { + if ((preg_match('/\.flv$/i', $fileName) || preg_match('~^https?://.*\.youtube\..*/watch\?~i', $fileName)) && is_dir(WT_ROOT.'modules/jw_player')) { $type .= 'flv'; } else if (preg_match('~^https?://picasaweb*\.google\..*/.*/~i', $fileName)) { $type .= 'picasa'; @@ -3032,17 +3032,17 @@ function mediaFileInfo($fileName, $thumbName, $mid, $name='', $notes='', $obeyVi require_once WT_ROOT.'modules/lightbox/lb_defaultconfig.php'; switch ($type) { case 'url_flv': - $url = encode_url('module.php?mod=JWplayer&mod_action=flvVideo&flvVideo='.encrypt($fileName)) . "\" rel='clearbox(500, 392, click)' rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8'); + $url = encode_url('module.php?mod=jw_player&mod_action=flvVideo&flvVideo='.encrypt($fileName)) . "\" rel='clearbox(500, 392, click)' rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8'); break 2; case 'local_flv': - $url = encode_url('module.php?mod=JWplayer&mod_action=flvVideo&flvVideo='.encrypt($SERVER_URL.$fileName)) . "\" rel='clearbox(500, 392, click)' rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8'); + $url = encode_url('module.php?mod=jw_player&mod_action=flvVideo&flvVideo='.encrypt($SERVER_URL.$fileName)) . "\" rel='clearbox(500, 392, click)' rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8'); break 2; case 'url_wmv': - $url = encode_url('module.php?mod=JWplayer&mod_action=wmvVideo&wmvVideo='.encrypt($fileName)) . "\" rel='clearbox(500, 392, click)' rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8'); + $url = encode_url('module.php?mod=jw_player&mod_action=wmvVideo&wmvVideo='.encrypt($fileName)) . "\" rel='clearbox(500, 392, click)' rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8'); break 2; case 'local_audio': case 'local_wmv': - $url = encode_url('module.php?mod=JWplayer&mod_action=wmvVideo&wmvVideo='.encrypt($SERVER_URL.$fileName)) . "\" rel='clearbox(500, 392, click)' rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8'); + $url = encode_url('module.php?mod=jw_player&mod_action=wmvVideo&wmvVideo='.encrypt($SERVER_URL.$fileName)) . "\" rel='clearbox(500, 392, click)' rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8'); break 2; case 'url_image': case 'local_image': @@ -3061,17 +3061,17 @@ function mediaFileInfo($fileName, $thumbName, $mid, $name='', $notes='', $obeyVi // Lightbox is not installed or Lightbox is not appropriate for this media type switch ($type) { case 'url_flv': - $url = "javascript:;\" onclick=\" var winflv = window.open('".encode_url('module.php?mod=JWplayer&mod_action=flvVideo&flvVideo='.encrypt($fileName)) . "', 'winflv', 'width=500, height=392, left=600, top=200'); if (window.focus) {winflv.focus();}"; + $url = "javascript:;\" onclick=\" var winflv = window.open('".encode_url('module.php?mod=jw_player&mod_action=flvVideo&flvVideo='.encrypt($fileName)) . "', 'winflv', 'width=500, height=392, left=600, top=200'); if (window.focus) {winflv.focus();}"; break 2; case 'local_flv': - $url = "javascript:;\" onclick=\" var winflv = window.open('".encode_url('module.php?mod=JWplayer&mod_action=flvVideo&flvVideo='.encrypt($SERVER_URL.$fileName)) . "', 'winflv', 'width=500, height=392, left=600, top=200'); if (window.focus) {winflv.focus();}"; + $url = "javascript:;\" onclick=\" var winflv = window.open('".encode_url('module.php?mod=jw_player&mod_action=flvVideo&flvVideo='.encrypt($SERVER_URL.$fileName)) . "', 'winflv', 'width=500, height=392, left=600, top=200'); if (window.focus) {winflv.focus();}"; break 2; case 'url_wmv': - $url = "javascript:;\" onclick=\" var winwmv = window.open('".encode_url('module.php?mod=JWplayer&mod_action=wmvVideo&wmvVideo='.encrypt($fileName)) . "', 'winwmv', 'width=500, height=392, left=600, top=200'); if (window.focus) {winwmv.focus();}"; + $url = "javascript:;\" onclick=\" var winwmv = window.open('".encode_url('module.php?mod=jw_player&mod_action=wmvVideo&wmvVideo='.encrypt($fileName)) . "', 'winwmv', 'width=500, height=392, left=600, top=200'); if (window.focus) {winwmv.focus();}"; break 2; case 'local_wmv': case 'local_audio': - $url = "javascript:;\" onclick=\" var winwmv = window.open('".encode_url('module.php?mod=JWplayer&mod_action=wmvVideo&wmvVideo='.encrypt($SERVER_URL.$fileName)) . "', 'winwmv', 'width=500, height=392, left=600, top=200'); if (window.focus) {winwmv.focus();}"; + $url = "javascript:;\" onclick=\" var winwmv = window.open('".encode_url('module.php?mod=jw_player&mod_action=wmvVideo&wmvVideo='.encrypt($SERVER_URL.$fileName)) . "', 'winwmv', 'width=500, height=392, left=600, top=200'); if (window.focus) {winwmv.focus();}"; break 2; case 'url_image': $imgsize = findImageSize($fileName); diff --git a/includes/functions/functions_db.php b/includes/functions/functions_db.php index 7f779a1fdd..de09e3a039 100644 --- a/includes/functions/functions_db.php +++ b/includes/functions/functions_db.php @@ -1764,7 +1764,7 @@ function delete_gedcom($ged_id) { WT_DB::prepare("DELETE FROM {$TBLPREFIX}media_mapping WHERE mm_gedfile=?")->execute(array($ged_id)); WT_DB::prepare("DELETE FROM {$TBLPREFIX}module_privacy WHERE gedcom_id =?")->execute(array($ged_id)); WT_DB::prepare("DELETE FROM {$TBLPREFIX}name WHERE n_file =?")->execute(array($ged_id)); - WT_DB::prepare("DELETE FROM {$TBLPREFIX}nextid WHERE ni_gedfile=?")->execute(array($ged_id)); + WT_DB::prepare("DELETE FROM {$TBLPREFIX}next_id WHERE gedcom_id =?")->execute(array($ged_id)); WT_DB::prepare("DELETE FROM {$TBLPREFIX}other WHERE o_file =?")->execute(array($ged_id)); WT_DB::prepare("DELETE FROM {$TBLPREFIX}placelinks WHERE pl_file =?")->execute(array($ged_id)); WT_DB::prepare("DELETE FROM {$TBLPREFIX}places WHERE p_file =?")->execute(array($ged_id)); @@ -2663,6 +2663,32 @@ function set_block_setting($block_id, $setting_name, $setting_value) { } } +function get_module_setting($module_name, $setting_name, $default_value=null) { + global $TBLPREFIX; + + $value= + WT_DB::prepare("SELECT setting_value FROM {$TBLPREFIX}module_setting WHERE module_name=? AND setting_name=?") + ->execute(array($module_name, $setting_name)) + ->fetchOne(); + + if (is_null($value)) { + return $default_value; + } else { + return $value; + } +} + +function set_module_setting($module_name, $setting_name, $setting_value) { + global $TBLPREFIX; + + if (is_null($setting_value)) { + WT_DB::prepare("DELETE FROM {$TBLPREFIX}module_setting WHERE module_name=? AND setting_name=?") + ->execute(array($module_name, $setting_name)); + } else { + WT_DB::prepare("REPLACE INTO {$TBLPREFIX}module_setting (module_name, setting_name, setting_value) VALUES (?, ?, ?)") + ->execute(array($module_name, $setting_name, $setting_value)); + } +} /** * update favorites regarding a merge of records diff --git a/includes/functions/functions_import.php b/includes/functions/functions_import.php index 33194aaf53..bd99fcbf51 100644 --- a/includes/functions/functions_import.php +++ b/includes/functions/functions_import.php @@ -1178,11 +1178,11 @@ function empty_database($ged_id, $keepmedia) { WT_DB::prepare("DELETE FROM {$TBLPREFIX}change WHERE gedcom_id=?")->execute(array($ged_id)); if ($keepmedia) { - WT_DB::prepare("DELETE FROM {$TBLPREFIX}link WHERE l_file =? AND l_type<> 'OBJE'")->execute(array($ged_id)); - WT_DB::prepare("DELETE FROM {$TBLPREFIX}nextid WHERE ni_gedfile=? AND ni_type<>'OBJE'")->execute(array($ged_id)); + WT_DB::prepare("DELETE FROM {$TBLPREFIX}link WHERE l_file =? AND l_type <>'OBJE'")->execute(array($ged_id)); + WT_DB::prepare("DELETE FROM {$TBLPREFIX}next_id WHERE gedcom_id=? AND record_type<>'OBJE'")->execute(array($ged_id)); } else { WT_DB::prepare("DELETE FROM {$TBLPREFIX}link WHERE l_file =?")->execute(array($ged_id)); - WT_DB::prepare("DELETE FROM {$TBLPREFIX}nextid WHERE ni_gedfile=?")->execute(array($ged_id)); + WT_DB::prepare("DELETE FROM {$TBLPREFIX}next_id WHERE gedcom_id =?")->execute(array($ged_id)); WT_DB::prepare("DELETE FROM {$TBLPREFIX}media WHERE m_gedfile =?")->execute(array($ged_id)); WT_DB::prepare("DELETE FROM {$TBLPREFIX}media_mapping WHERE mm_gedfile=?")->execute(array($ged_id)); } diff --git a/includes/functions/functions_print_facts.php b/includes/functions/functions_print_facts.php index db591dc410..abcf75e238 100644 --- a/includes/functions/functions_print_facts.php +++ b/includes/functions/functions_print_facts.php @@ -1481,7 +1481,7 @@ function print_main_media_row($rtype, $rowm, $pid) { } else { $file_type = 'local_'; } - if (preg_match("/\.flv$/i", $rowm['m_file']) && file_exists(WT_ROOT.'modules/JWplayer/flvVideo.php')) { + if (preg_match("/\.flv$/i", $rowm['m_file']) && file_exists(WT_ROOT.'modules/jw_player/flvVideo.php')) { $file_type .= 'flv'; } elseif (preg_match("/\.(jpg|jpeg|gif|png)$/i", $rowm['m_file'])) { $file_type .= 'image'; |
