当前位置: 首页>>代码示例>>PHP>>正文


PHP Database::prepare方法代码示例

本文整理汇总了PHP中Fisharebest\Webtrees\Database::prepare方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::prepare方法的具体用法?PHP Database::prepare怎么用?PHP Database::prepare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fisharebest\Webtrees\Database的用法示例。


在下文中一共展示了Database::prepare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upgrade

 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     $index_dir = Site::getPreference('INDEX_DIRECTORY');
     // Due to the language code changes in 1.7.0, we need to update some other settings
     foreach ($this->languages as $old => $new) {
         try {
             Database::prepare("UPDATE `##site_setting` SET setting_name = REPLACE(setting_name, :old, :new) " . "WHERE setting_name LIKE 'WELCOME_TEXT_AUTH_MODE_%'")->execute(array('old' => $old, 'new' => $new));
         } catch (PDOException $ex) {
             // Duplicate key? Already done?
         }
         Database::prepare("UPDATE `##block_setting` SET setting_value = REPLACE(setting_value, :old, :new) " . "WHERE setting_name = 'languages'")->execute(array('old' => $old, 'new' => $new));
         // Historical fact files
         if (file_exists($index_dir . 'histo.' . $old . '.php') && !file_exists($index_dir . 'histo.' . $new . '.php')) {
             rename($index_dir . 'histo.' . $old . '.php', $index_dir . 'histo.' . $new . '.php');
         }
         // Language files
         if (file_exists($index_dir . 'language/' . $old . '.php') && !file_exists($index_dir . 'language/' . $new . '.php')) {
             rename($index_dir . 'language/' . $old . '.php', $index_dir . 'language/' . $new . '.php');
         }
         if (file_exists($index_dir . 'language/' . $old . '.csv') && !file_exists($index_dir . 'language/' . $new . '.csv')) {
             rename($index_dir . 'language/' . $old . '.csv', $index_dir . 'language/' . $new . '.csv');
         }
         if (file_exists($index_dir . 'language/' . $old . '.mo') && !file_exists($index_dir . 'language/' . $new . '.mo')) {
             rename($index_dir . 'language/' . $old . '.mo', $index_dir . 'language/' . $new . '.mo');
         }
     }
 }
开发者ID:tronsmit,项目名称:webtrees,代码行数:30,代码来源:Migration31.php

示例2: upgrade

 /** {@inheritDoc} */
 public function upgrade()
 {
     $module_options = 'FTV_OPTIONS';
     $ftv_options = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_options))->fetchOne();
     $options = unserialize($ftv_options);
     if (!empty($options)) {
         foreach ($options as $option) {
             foreach ($option as $key => $value) {
                 if ($key == 'USE_FTV_THUMBS') {
                     $option['RESIZE_THUMBS'] = $value;
                     unset($option[$key]);
                 }
                 if ($key == 'COUNTRY') {
                     unset($option[$key]);
                 }
             }
             $option['USE_GEDCOM_PLACES'] = '1';
             $option['THUMB_RESIZE_FORMAT'] = '2';
             $new_options[] = $option;
         }
         if (isset($new_options)) {
             Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_options), $module_options));
         }
         unset($new_options);
     }
 }
开发者ID:bxbroze,项目名称:webtrees,代码行数:27,代码来源:Migration7.php

示例3: upgrade

 /** {@inheritDoc} */
 public function upgrade()
 {
     // add key 'LINK' to FTV_SETTINGS
     // change options to multidimensional array with array key = tree id.
     $module_settings = 'FTV_SETTINGS';
     $ftv_settings = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_settings))->fetchOne();
     $settings = unserialize($ftv_settings);
     if (!empty($settings)) {
         foreach ($settings as $setting) {
             if (!array_key_exists('LINK', $setting)) {
                 $setting['LINK'] = I18N::translate('Descendants of the %s family', $setting['SURNAME']);
                 $new_settings[] = $setting;
             }
         }
         if (isset($new_settings)) {
             Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_settings), $module_settings));
         }
         unset($new_settings);
     }
     $module_options = 'FTV_OPTIONS';
     $ftv_options = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_options))->fetchOne();
     $options = unserialize($ftv_options);
     if (!empty($options)) {
         $show_places = array_key_exists('SHOW_PLACES', $options) ? $options['SHOW_PLACES'] : '1';
         $country = array_key_exists('COUNTRY', $options) ? $options['COUNTRY'] : '';
         $show_occu = array_key_exists('SHOW_OCCU', $options) ? $options['SHOW_OCCU'] : '1';
         foreach (Tree::getAll() as $tree) {
             $new_options[$tree->getTreeId()] = array('SHOW_PLACES' => $show_places, 'COUNTRY' => $country, 'SHOW_OCCU' => $show_occu);
         }
         if (isset($new_options)) {
             Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_options), $module_options));
         }
         unset($new_options);
     }
 }
开发者ID:bxbroze,项目名称:webtrees,代码行数:36,代码来源:Migration0.php

示例4: upgrade

 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     try {
         Database::prepare("ALTER TABLE `##site_setting` CHANGE setting_value setting_value VARCHAR(2000) NOT NULL")->execute();
     } catch (PDOException $ex) {
         // Already done?
     }
 }
开发者ID:tunandras,项目名称:webtrees,代码行数:11,代码来源:Migration32.php

示例5: upgrade

 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     try {
         Database::prepare("ALTER TABLE `##site_setting` CHANGE setting_value setting_value VARCHAR(2000) NOT NULL")->execute();
     } catch (PDOException $ex) {
         // Already done?
     }
     Database::prepare("DELETE FROM `##change` WHERE old_gedcom = '' AND new_gedcom = ''")->execute();
 }
开发者ID:tronsmit,项目名称:webtrees,代码行数:12,代码来源:Migration32.php

示例6: getPlaceIcon

 /**
  * {@inheritDoc}
  * @see \MyArtJaub\Webtrees\Map\MapProviderInterface::getPlaceIcon()
  */
 public function getPlaceIcon(\Fisharebest\Webtrees\Place $place)
 {
     if (!$place->isEmpty()) {
         $place_details = Database::prepare('SELECT SQL_CACHE pl_icon FROM `##placelocation` WHERE pl_id=? ORDER BY pl_place')->execute(array($this->getProviderPlaceId($place)))->fetchOneRow();
         if ($place_details) {
             return WT_MODULES_DIR . 'googlemap/' . $place_details->pl_icon;
         }
     }
     return null;
 }
开发者ID:jon48,项目名称:webtrees-lib,代码行数:14,代码来源:GoogleMapsProvider.php

示例7: getBlock

 /**
  * Generate the HTML content of this block.
  *
  * @param int      $block_id
  * @param bool     $template
  * @param string[] $cfg
  *
  * @return string
  */
 public function getBlock($block_id, $template = true, $cfg = array())
 {
     global $ctype, $WT_TREE;
     $num = $this->getBlockSetting($block_id, 'num', '10');
     $count_placement = $this->getBlockSetting($block_id, 'count_placement', 'before');
     $block = $this->getBlockSetting($block_id, 'block', '0');
     foreach (array('count_placement', 'num', 'block') as $name) {
         if (array_key_exists($name, $cfg)) {
             ${$name} = $cfg[$name];
         }
     }
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
         $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
     } else {
         $title = '';
     }
     $title .= $this->getTitle();
     $content = '';
     // load the lines from the file
     $top10 = Database::prepare("SELECT page_parameter, page_count" . " FROM `##hit_counter`" . " WHERE gedcom_id = :tree_id AND page_name IN ('individual.php','family.php','source.php','repo.php','note.php','mediaviewer.php')" . " ORDER BY page_count DESC LIMIT :limit")->execute(array('tree_id' => $WT_TREE->getTreeId(), 'limit' => (int) $num))->fetchAssoc();
     if ($block) {
         $content .= '<table width="90%">';
     } else {
         $content .= '<table>';
     }
     foreach ($top10 as $id => $count) {
         $record = GedcomRecord::getInstance($id, $WT_TREE);
         if ($record && $record->canShow()) {
             $content .= '<tr>';
             if ($count_placement == 'before') {
                 $content .= '<td dir="ltr" style="text-align:right">[' . $count . ']</td>';
             }
             $content .= '<td class="name2" ><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></td>';
             if ($count_placement == 'after') {
                 $content .= '<td dir="ltr" style="text-align:right">[' . $count . ']</td>';
             }
             $content .= '</tr>';
         }
     }
     $content .= "</table>";
     if ($template) {
         if ($block) {
             $class .= ' small_inner_block';
         }
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
开发者ID:josefpavlik,项目名称:webtrees,代码行数:60,代码来源:TopPageViewsModule.php

示例8: upgrade

 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // - data update for 1.4.0 media changes
     $_cfgs = Database::prepare("SELECT gs1.gedcom_id AS gedcom_id, gs1.setting_value AS media_directory, gs2.setting_value AS use_media_firewall, gs3.setting_value AS media_firewall_thumbs, gs4.setting_value AS media_firewall_rootdir" . " FROM `##gedcom_setting` gs1" . " LEFT JOIN `##gedcom_setting` gs2 ON (gs1.gedcom_id = gs2.gedcom_id AND gs2.setting_name='USE_MEDIA_FIREWALL')" . " LEFT JOIN `##gedcom_setting` gs3 ON (gs1.gedcom_id = gs3.gedcom_id AND gs3.setting_name='MEDIA_FIREWALL_THUMBS')" . " LEFT JOIN `##gedcom_setting` gs4 ON (gs1.gedcom_id = gs4.gedcom_id AND gs4.setting_name='MEDIA_FIREWALL_ROOTDIR')" . " WHERE gs1.setting_name = 'MEDIA_DIRECTORY'")->fetchAll();
     // The constant WT_DATA_DIR is not defined yet (although it was when this script was originally written).
     $WT_DATA_DIR = realpath('data');
     // Check the config for each tree
     foreach ($_cfgs as $_cfg) {
         if ($_cfg->use_media_firewall) {
             // We’re using the media firewall.
             $_mf_dir = realpath($_cfg->media_firewall_rootdir) . DIRECTORY_SEPARATOR;
             if ($_mf_dir == $WT_DATA_DIR) {
                 // We’re already storing our media in the data folder - nothing to do.
             } else {
                 // We’ve chosen a custom location for our media folder - need to update our media-folder to point to it.
                 // We have, for example,
                 // $_mf_dir = /home/fisharebest/my_pictures/
                 // $WT_DATA_DIR = /home/fisharebest/public_html/webtrees/data/
                 // Therefore we need to calculate ../../../my_pictures/
                 $_media_dir = '';
                 $_tmp_dir = $WT_DATA_DIR;
                 while (strpos($_mf_dir, $_tmp_dir) !== 0) {
                     $_media_dir .= '../';
                     $_tmp_dir = preg_replace('~[^/\\\\]+[/\\\\]$~', '', $_tmp_dir);
                     if ($_tmp_dir == '') {
                         // Shouldn't get here - but this script is not allowed to fail...
                         continue 2;
                     }
                 }
                 $_media_dir .= $_cfg->media_directory;
                 Database::prepare("UPDATE `##gedcom_setting`" . " SET setting_value=?" . " WHERE gedcom_id=? AND setting_name='MEDIA_DIRECTORY'")->execute(array($_media_dir, $_cfg->gedcom_id));
             }
         } else {
             // Not using the media firewall - just move the public folder to the new location (if we can).
             if (file_exists(WT_ROOT . $_cfg->media_directory) && is_dir(WT_ROOT . $_cfg->media_directory) && !file_exists($WT_DATA_DIR . $_cfg->media_directory)) {
                 try {
                     rename(WT_ROOT . $_cfg->media_directory, $WT_DATA_DIR . $_cfg->media_directory);
                 } catch (\ErrorException $ex) {
                     // Cannot move the folder?
                 }
                 File::delete($WT_DATA_DIR . $_cfg->media_directory . '.htaccess');
                 File::delete($WT_DATA_DIR . $_cfg->media_directory . 'index.php');
                 File::delete($WT_DATA_DIR . $_cfg->media_directory . 'Mediainfo.txt');
                 File::delete($WT_DATA_DIR . $_cfg->media_directory . 'thumbs/Thumbsinfo.txt');
             }
         }
     }
     // Delete old settings
     Database::exec("DELETE FROM `##gedcom_setting` WHERE setting_name IN ('USE_MEDIA_FIREWALL', 'MEDIA_FIREWALL_THUMBS', 'MEDIA_FIREWALL_ROOTDIR')");
 }
开发者ID:tunandras,项目名称:webtrees,代码行数:53,代码来源:Migration22.php

示例9: upgrade

 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     $WEBTREES_EMAIL = 'webtrees-noreply@' . preg_replace('/^www\\./i', '', Filter::server('SERVER_NAME'));
     // Default settings for new trees.  No defaults for:
     // imported, title, CONTACT_USER_ID, WEBMASTER_USER_ID
     // The following settings have defaults, but may need overwriting:
     // LANGUAGE, SURNAME_TRADITION
     Database::prepare("INSERT IGNORE INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value) VALUES" . "(-1, 'ADVANCED_NAME_FACTS', 'NICK,_AKA')," . "(-1, 'ADVANCED_PLAC_FACTS', '')," . "(-1, 'ALLOW_THEME_DROPDOWN', '1')," . "(-1, 'CALENDAR_FORMAT', 'gregorian')," . "(-1, 'CHART_BOX_TAGS', '')," . "(-1, 'COMMON_NAMES_ADD', '')," . "(-1, 'COMMON_NAMES_REMOVE', '')," . "(-1, 'COMMON_NAMES_THRESHOLD', '40')," . "(-1, 'DEFAULT_PEDIGREE_GENERATIONS', '4')," . "(-1, 'EXPAND_RELATIVES_EVENTS', '0')," . "(-1, 'EXPAND_SOURCES', '0')," . "(-1, 'FAM_FACTS_ADD', 'CENS,MARR,RESI,SLGS,MARR_CIVIL,MARR_RELIGIOUS,MARR_PARTNERS,RESN')," . "(-1, 'FAM_FACTS_QUICK', 'MARR,DIV,_NMR')," . "(-1, 'FAM_FACTS_UNIQUE', 'NCHI,MARL,DIV,ANUL,DIVF,ENGA,MARB,MARC,MARS')," . "(-1, 'FAM_ID_PREFIX', 'F')," . "(-1, 'FORMAT_TEXT', 'markdown')," . "(-1, 'FULL_SOURCES', '0')," . "(-1, 'GEDCOM_ID_PREFIX', 'I')," . "(-1, 'GEDCOM_MEDIA_PATH', '')," . "(-1, 'GENERATE_UIDS', '0')," . "(-1, 'HIDE_GEDCOM_ERRORS', '1')," . "(-1, 'HIDE_LIVE_PEOPLE', '1')," . "(-1, 'INDI_FACTS_ADD', 'AFN,BIRT,DEAT,BURI,CREM,ADOP,BAPM,BARM,BASM,BLES,CHRA,CONF,FCOM,ORDN,NATU,EMIG,IMMI,CENS,PROB,WILL,GRAD,RETI,DSCR,EDUC,IDNO,NATI,NCHI,NMR,OCCU,PROP,RELI,RESI,SSN,TITL,BAPL,CONL,ENDL,SLGC,_MILI,ASSO,RESN')," . "(-1, 'INDI_FACTS_QUICK', 'BIRT,BURI,BAPM,CENS,DEAT,OCCU,RESI')," . "(-1, 'INDI_FACTS_UNIQUE', '')," . "(-1, 'KEEP_ALIVE_YEARS_BIRTH', '')," . "(-1, 'KEEP_ALIVE_YEARS_DEATH', '')," . "(-1, 'LANGUAGE', 'en-US')," . "(-1, 'MAX_ALIVE_AGE', '120')," . "(-1, 'MAX_DESCENDANCY_GENERATIONS', '15')," . "(-1, 'MAX_PEDIGREE_GENERATIONS', '10')," . "(-1, 'MEDIA_DIRECTORY', 'media/')," . "(-1, 'MEDIA_ID_PREFIX', 'M')," . "(-1, 'MEDIA_UPLOAD', :MEDIA_UPLOAD)," . "(-1, 'META_DESCRIPTION', '')," . "(-1, 'META_TITLE', :META_TITLE)," . "(-1, 'NOTE_FACTS_ADD', 'SOUR,RESN')," . "(-1, 'NOTE_FACTS_QUICK', '')," . "(-1, 'NOTE_FACTS_UNIQUE', '')," . "(-1, 'NOTE_ID_PREFIX', 'N')," . "(-1, 'NO_UPDATE_CHAN', '0')," . "(-1, 'PEDIGREE_FULL_DETAILS', '1')," . "(-1, 'PEDIGREE_LAYOUT', '1')," . "(-1, 'PEDIGREE_ROOT_ID', '')," . "(-1, 'PEDIGREE_SHOW_GENDER', '0')," . "(-1, 'PREFER_LEVEL2_SOURCES', '1')," . "(-1, 'QUICK_REQUIRED_FACTS', 'BIRT,DEAT')," . "(-1, 'QUICK_REQUIRED_FAMFACTS', 'MARR')," . "(-1, 'REPO_FACTS_ADD', 'PHON,EMAIL,FAX,WWW,RESN')," . "(-1, 'REPO_FACTS_QUICK', '')," . "(-1, 'REPO_FACTS_UNIQUE', 'NAME,ADDR')," . "(-1, 'REPO_ID_PREFIX', 'R')," . "(-1, 'REQUIRE_AUTHENTICATION', '0')," . "(-1, 'SAVE_WATERMARK_IMAGE', '0')," . "(-1, 'SAVE_WATERMARK_THUMB', '0')," . "(-1, 'SHOW_AGE_DIFF', '0')," . "(-1, 'SHOW_COUNTER', '1')," . "(-1, 'SHOW_DEAD_PEOPLE', :SHOW_DEAD_PEOPLE)," . "(-1, 'SHOW_EST_LIST_DATES', '0')," . "(-1, 'SHOW_FACT_ICONS', '1')," . "(-1, 'SHOW_GEDCOM_RECORD', '0')," . "(-1, 'SHOW_HIGHLIGHT_IMAGES', '1')," . "(-1, 'SHOW_LDS_AT_GLANCE', '0')," . "(-1, 'SHOW_LEVEL2_NOTES', '1')," . "(-1, 'SHOW_LIVING_NAMES', :SHOW_LIVING_NAMES)," . "(-1, 'SHOW_MEDIA_DOWNLOAD', '0')," . "(-1, 'SHOW_NO_WATERMARK', :SHOW_NO_WATERMARK)," . "(-1, 'SHOW_PARENTS_AGE', '1')," . "(-1, 'SHOW_PEDIGREE_PLACES', '9')," . "(-1, 'SHOW_PEDIGREE_PLACES_SUFFIX', '0')," . "(-1, 'SHOW_PRIVATE_RELATIONSHIPS', '1')," . "(-1, 'SHOW_RELATIVES_EVENTS', '_BIRT_CHIL,_BIRT_SIBL,_MARR_CHIL,_MARR_PARE,_DEAT_CHIL,_DEAT_PARE,_DEAT_GPAR,_DEAT_SIBL,_DEAT_SPOU')," . "(-1, 'SOURCE_ID_PREFIX', 'S')," . "(-1, 'SOUR_FACTS_ADD', 'NOTE,REPO,SHARED_NOTE,RESN')," . "(-1, 'SOUR_FACTS_QUICK', 'TEXT,NOTE,REPO')," . "(-1, 'SOUR_FACTS_UNIQUE', 'AUTH,ABBR,TITL,PUBL,TEXT')," . "(-1, 'SUBLIST_TRIGGER_I', '200')," . "(-1, 'SURNAME_LIST_STYLE', 'style2')," . "(-1, 'SURNAME_TRADITION', 'paternal')," . "(-1, 'THUMBNAIL_WIDTH', '100')," . "(-1, 'USE_RIN', '0')," . "(-1, 'USE_SILHOUETTE', '1')," . "(-1, 'WATERMARK_THUMB', '0')," . "(-1, 'WEBTREES_EMAIL', :WEBTREES_EMAIL)," . "(-1, 'WORD_WRAPPED_NOTES', '0')")->execute(array('MEDIA_UPLOAD' => Auth::PRIV_USER, 'META_TITLE' => WT_WEBTREES, 'SHOW_DEAD_PEOPLE' => Auth::PRIV_PRIVATE, 'SHOW_LIVING_NAMES' => Auth::PRIV_USER, 'SHOW_NO_WATERMARK' => Auth::PRIV_USER, 'WEBTREES_EMAIL' => $WEBTREES_EMAIL));
     // Previous versions of webtrees allowed this setting to be empty.
     Database::prepare("DELETE FROM `##gedcom_setting` WHERE setting_name  ='WEBTREES_EMAIL' AND setting_value = ''")->execute();
     Database::prepare("INSERT IGNORE INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value)" . " SELECT gedcom_id, 'WEBTREES_EMAIL', :WEBTREES_EMAIL" . " FROM `##gedcom` WHERE gedcom_id > 0")->execute(array('WEBTREES_EMAIL' => $WEBTREES_EMAIL));
     // Default restrictions
     Database::prepare("INSERT IGNORE INTO `##default_resn` (gedcom_id, tag_type, resn) VALUES " . "(-1, 'SSN', 'confidential')," . "(-1, 'SOUR', 'privacy')," . "(-1, 'REPO', 'privacy')," . "(-1, 'SUBM', 'confidential')," . "(-1, 'SUBN', 'confidential')")->execute();
 }
开发者ID:tunandras,项目名称:webtrees,代码行数:17,代码来源:Migration30.php

示例10: getBlock

 /**
  * Generate the HTML content of this block.
  *
  * @param int      $block_id
  * @param bool     $template
  * @param string[] $cfg
  *
  * @return string
  */
 public function getBlock($block_id, $template = true, $cfg = array())
 {
     global $ctype, $WT_TREE;
     switch (Filter::get('action')) {
         case 'deletenews':
             $news_id = Filter::getInteger('news_id');
             if ($news_id) {
                 Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id));
             }
             break;
     }
     $block = $this->getBlockSetting($block_id, 'block', '1');
     foreach (array('block') as $name) {
         if (array_key_exists($name, $cfg)) {
             ${$name} = $cfg[$name];
         }
     }
     $usernews = Database::prepare("SELECT SQL_CACHE news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS updated, subject, body FROM `##news` WHERE user_id = ? ORDER BY updated DESC")->execute(array(Auth::id()))->fetchAll();
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     $title = '';
     $title .= $this->getTitle();
     $content = '';
     if (!$usernews) {
         $content .= I18N::translate('You have not created any journal items.');
     }
     foreach ($usernews as $news) {
         $content .= '<div class="journal_box">';
         $content .= '<div class="news_title">' . $news->subject . '</div>';
         $content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($news->updated) . '</div>';
         if ($news->body == strip_tags($news->body)) {
             // No HTML?
             $news->body = nl2br($news->body, false);
         }
         $content .= $news->body . '<br><br>';
         $content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $news->news_id . ', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Edit') . '</a> | ';
         $content .= '<a href="index.php?action=deletenews&amp;news_id=' . $news->news_id . '&amp;ctype=' . $ctype . '&amp;ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($news->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>';
         $content .= "</div><br>";
     }
     $content .= '<br><a href="#" onclick="window.open(\'editnews.php?user_id=' . Auth::id() . '\', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Add a new journal entry') . '</a>';
     if ($template) {
         if ($block) {
             $class .= ' small_inner_block';
         }
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
开发者ID:pal-saugstad,项目名称:webtrees,代码行数:58,代码来源:UserJournalModule.php

示例11: upgrade

 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // Move repositories to their own table
     Database::exec("CREATE TABLE IF NOT EXISTS `##repository` (" . " repository_id INTEGER AUTO_INCREMENT                      NOT NULL," . " gedcom_id     INTEGER                                     NOT NULL," . " xref          VARCHAR(20)                                 NOT NULL," . " gedcom        LONGTEXT                                    NOT NULL," . " name          VARCHAR(90)                                 NOT NULL," . " address       VARCHAR(255)                                NOT NULL," . " restriction   ENUM('', 'confidential', 'privacy', 'none') NOT NULL," . " uid           VARCHAR(34)                                 NOT NULL," . " changed_at    DATETIME                                    NOT NULL," . " PRIMARY KEY (repository_id)," . " UNIQUE  KEY `##repository_ix1` (gedcom_id, xref)," . " UNIQUE  KEY `##repository_ix2` (xref, gedcom_id)," . "         KEY `##repository_ix3` (name)," . "         KEY `##repository_ix4` (address)," . "         KEY `##repository_ix5` (restriction)," . "         KEY `##repository_ix6` (uid)," . "         KEY `##repository_ix7` (changed_at)," . " CONSTRAINT `##repository_fk1` FOREIGN KEY (gedcom_id) REFERENCES `##gedcom` (gedcom_id)" . ") COLLATE utf8_unicode_ci ENGINE=InnoDB");
     Database::exec("START TRANSACTION");
     $repositories = Database::prepare("SELECT * FROM `##other` WHERE o_type = 'REPO'")->fetchAll();
     foreach ($repositories as $n => $repository) {
         Database::prepare("INSERT INTO `##repository` (" . " gedcom_id, xref, gedcom, name, address, restriction, uid, changed_at" . ") VALUES (" . " :gedcom_id, :xref, :gedcom, :name, :address, :restriction, :uid, :changed_at" . ")")->execute(array('gedcom_id' => $repository->o_file, 'xref' => $repository->o_id, 'gedcom' => $repository->o_gedcom, 'name' => '', 'address' => '', 'restriction' => '', 'uid' => '', 'changed_at' => ''));
         Database::prepare("DELETE FROM `##other` WHERE o_file = :gedcom_id AND o_id = :xref")->execute(array('gedcom_id' => $repository->o_file, 'xref' => $repository->o_id));
         if ($n % 500 === 499) {
             Database::exec("COMMIT");
             Database::exec("START TRANSACTION");
         }
     }
     Database::exec("COMMIT");
 }
开发者ID:tronsmit,项目名称:webtrees,代码行数:19,代码来源:Migration37.php

示例12: upgrade

 /** {@inheritDoc} */
 public function upgrade()
 {
     $module_options = 'FTV_OPTIONS';
     $ftv_options = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_options))->fetchOne();
     $options = unserialize($ftv_options);
     if (!empty($options)) {
         foreach ($options as $option) {
             $option['SHOW_PDF_ICON'] = '2';
             $new_options[] = $option;
         }
         if (isset($new_options)) {
             Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_options), $module_options));
         }
         unset($new_options);
     }
 }
开发者ID:bxbroze,项目名称:webtrees,代码行数:17,代码来源:Migration5.php

示例13: upgrade

 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // - changes to the values for the gedcom setting SHOW_RELATIVES_EVENTS
     $settings = Database::prepare("SELECT gedcom_id, setting_value FROM `##gedcom_setting` WHERE setting_name='SHOW_RELATIVES_EVENTS'")->fetchAssoc();
     foreach ($settings as $gedcom_id => $setting) {
         // Delete old settings
         $setting = preg_replace('/_(BIRT|MARR|DEAT)_(COUS|MSIB|FSIB|GGCH|NEPH|GGPA)/', '', $setting);
         $setting = preg_replace('/_FAMC_(RESI_EMIG)/', '', $setting);
         // Rename settings
         $setting = preg_replace('/_MARR_(MOTH|FATH|FAMC)/', '_MARR_PARE', $setting);
         $setting = preg_replace('/_DEAT_(MOTH|FATH)/', '_DEAT_PARE', $setting);
         // Remove duplicates
         preg_match_all('/[_A-Z]+/', $setting, $match);
         // And save
         Tree::findById($gedcom_id)->setPreference('SHOW_RELATIVES_EVENTS', implode(',', array_unique($match[0])));
     }
 }
开发者ID:tronsmit,项目名称:webtrees,代码行数:20,代码来源:Migration5.php

示例14: calculateRelationships

 /**
  * Calculate the shortest paths - or all paths - between two individuals.
  *
  * @param Individual $individual1
  * @param Individual $individual2
  * @param bool       $all
  *
  * @return string[][]
  */
 public function calculateRelationships(Individual $individual1, Individual $individual2, $all)
 {
     $rows = Database::prepare("SELECT l_from, l_to FROM `##link` WHERE l_file = :tree_id AND l_type IN ('FAMS', 'FAMC', 'CHIL', 'HUSB', 'WIFE')")->execute(array('tree_id' => $individual1->getTree()->getTreeId()))->fetchAll();
     $graph = array();
     foreach ($rows as $row) {
         $graph[$row->l_from][$row->l_to] = 1;
     }
     $xref1 = $individual1->getXref();
     $xref2 = $individual2->getXref();
     $dijkstra = new Dijkstra($graph);
     $paths = $dijkstra->shortestPaths($xref1, $xref2);
     if ($all) {
         // Only process each exclusion list once;
         $excluded = array();
         $queue = array();
         foreach ($paths as $path) {
             // Insert the paths into the queue, with an exclusion list.
             $queue[] = array('path' => $path, 'exclude' => array());
             // While there are un-extended paths
             while (list(, $next) = each($queue)) {
                 // For each family on the path
                 for ($n = count($next['path']) - 2; $n >= 1; $n -= 2) {
                     $exclude = $next['exclude'];
                     $exclude[] = $next['path'][$n];
                     sort($exclude);
                     $tmp = implode('-', $exclude);
                     if (in_array($tmp, $excluded)) {
                         continue;
                     } else {
                         $excluded[] = $tmp;
                     }
                     // Add any new path to the queue
                     foreach ($dijkstra->shortestPaths($xref1, $xref2, $exclude) as $new_path) {
                         $queue[] = array('path' => $new_path, 'exclude' => $exclude);
                     }
                 }
             }
         }
         // Extract the paths from the queue, removing duplicates.
         $paths = array();
         foreach ($queue as $next) {
             $paths[implode('-', $next['path'])] = $next['path'];
         }
     }
     return $paths;
 }
开发者ID:tunandras,项目名称:webtrees,代码行数:55,代码来源:RelationshipController.php

示例15: upgrade

 /** {@inheritDoc} */
 public function upgrade()
 {
     // remove key 'LINK' from FTV_SETTINGS
     $module_settings = 'FTV_SETTINGS';
     $ftv_asettings = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_settings))->fetchOne();
     $asettings = unserialize($ftv_asettings);
     if (!empty($asettings)) {
         foreach ($asettings as $asetting) {
             if (array_key_exists('LINK', $asetting)) {
                 unset($asetting['LINK']);
                 $new_asettings[] = $asetting;
             }
         }
         if (isset($new_asettings)) {
             Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_asettings), $module_settings));
         }
         unset($new_asettings);
     }
     $ftv_bsettings = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_settings))->fetchOne();
     $bsettings = unserialize($ftv_bsettings);
     if (!empty($bsettings)) {
         foreach ($bsettings as $bsetting) {
             if (!array_key_exists('DISPLAY_NAME', $bsetting)) {
                 $bsetting['DISPLAY_NAME'] = $bsetting['SURNAME'];
                 $new_bsettings[] = $bsetting;
             }
         }
         if (isset($new_bsettings)) {
             Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_bsettings), $module_settings));
         }
         unset($new_bsettings);
     }
     $module_options = 'FTV_OPTIONS';
     $ftv_options = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_options))->fetchOne();
     $options = unserialize($ftv_options);
     if (!empty($options)) {
         foreach ($options as $option) {
             $option['USE_FULLNAME'] = '0';
             $new_options[] = $option;
         }
         if (isset($new_options)) {
             Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_options), $module_options));
         }
         unset($new_options);
     }
 }
开发者ID:bxbroze,项目名称:webtrees,代码行数:47,代码来源:Migration1.php


注:本文中的Fisharebest\Webtrees\Database::prepare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。