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


PHP WT_DB::getInstance方法代码示例

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


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

示例1: edit

 private function edit()
 {
     require_once WT_ROOT . 'includes/functions/functions_edit.php';
     if (WT_Filter::postBool('save') && WT_Filter::checkCsrf()) {
         $block_id = WT_Filter::postInteger('block_id');
         if ($block_id) {
             WT_DB::prepare("UPDATE `##block` SET gedcom_id=NULLIF(?, '0'), block_order=? WHERE block_id=?")->execute(array(WT_Filter::postInteger('gedcom_id'), WT_Filter::postInteger('block_order'), $block_id));
         } else {
             WT_DB::prepare("INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(?, '0'), ?, ?)")->execute(array(WT_Filter::postInteger('gedcom_id'), $this->getName(), WT_Filter::postInteger('block_order')));
             $block_id = WT_DB::getInstance()->lastInsertId();
         }
         set_block_setting($block_id, 'header', WT_Filter::post('header'));
         set_block_setting($block_id, 'faqbody', WT_Filter::post('faqbody'));
         $languages = array();
         foreach (WT_I18N::installed_languages() as $code => $name) {
             if (WT_Filter::postBool('lang_' . $code)) {
                 $languages[] = $code;
             }
         }
         set_block_setting($block_id, 'languages', implode(',', $languages));
         $this->config();
     } else {
         $block_id = WT_Filter::getInteger('block_id');
         $controller = new WT_Controller_Page();
         if ($block_id) {
             $controller->setPageTitle(WT_I18N::translate('Edit FAQ item'));
             $header = get_block_setting($block_id, 'header');
             $faqbody = get_block_setting($block_id, 'faqbody');
             $block_order = WT_DB::prepare("SELECT block_order FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne();
             $gedcom_id = WT_DB::prepare("SELECT gedcom_id FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne();
         } else {
             $controller->setPageTitle(WT_I18N::translate('Add an FAQ item'));
             $header = '';
             $faqbody = '';
             $block_order = WT_DB::prepare("SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name=?")->execute(array($this->getName()))->fetchOne();
             $gedcom_id = WT_GED_ID;
         }
         $controller->pageHeader();
         if (array_key_exists('ckeditor', WT_Module::getActiveModules())) {
             ckeditor_WT_Module::enableEditor($controller);
         }
         // "Help for this page" link
         echo '<div id="page_help">', help_link('add_faq_item', $this->getName()), '</div>';
         echo '<form name="faq" method="post" action="module.php?mod=', $this->getName(), '&amp;mod_action=admin_edit">';
         echo WT_Filter::getCsrf();
         echo '<input type="hidden" name="save" value="1">';
         echo '<input type="hidden" name="block_id" value="', $block_id, '">';
         echo '<table id="faq_module">';
         echo '<tr><th>';
         echo WT_I18N::translate('Question');
         echo '</th></tr><tr><td><input type="text" name="header" size="90" tabindex="1" value="' . WT_Filter::escapeHtml($header) . '"></td></tr>';
         echo '<tr><th>';
         echo WT_I18N::translate('Answer');
         echo '</th></tr><tr><td>';
         echo '<textarea name="faqbody" class="html-edit" rows="10" cols="90" tabindex="2">', WT_Filter::escapeHtml($faqbody), '</textarea>';
         echo '</td></tr>';
         echo '</table><table id="faq_module2">';
         echo '<tr>';
         echo '<th>', WT_I18N::translate('Show this block for which languages?'), '</th>';
         echo '<th>', WT_I18N::translate('FAQ position'), help_link('add_faq_order', $this->getName()), '</th>';
         echo '<th>', WT_I18N::translate('FAQ visibility'), help_link('add_faq_visibility', $this->getName()), '</th>';
         echo '</tr><tr>';
         echo '<td>';
         $languages = get_block_setting($block_id, 'languages');
         echo edit_language_checkboxes('lang_', $languages);
         echo '</td><td>';
         echo '<input type="text" name="block_order" size="3" tabindex="3" value="', $block_order, '"></td>';
         echo '</td><td>';
         echo select_edit_control('gedcom_id', WT_Tree::getIdList(), WT_I18N::translate('All'), $gedcom_id, 'tabindex="4"');
         echo '</td></tr>';
         echo '</table>';
         echo '<p><input type="submit" value="', WT_I18N::translate('save'), '" tabindex="5">';
         echo '</form>';
         exit;
     }
 }
开发者ID:jacoline,项目名称:webtrees,代码行数:76,代码来源:module.php

示例2: edit

 private function edit()
 {
     require_once WT_ROOT . 'includes/functions/functions_edit.php';
     if (WT_USER_CAN_EDIT) {
         if (WT_Filter::postBool('save') && WT_Filter::checkCsrf()) {
             $block_id = WT_Filter::postInteger('block_id');
             if ($block_id) {
                 WT_DB::prepare("UPDATE `##block` SET gedcom_id=?, xref=? WHERE block_id=?")->execute(array(WT_Filter::postInteger('gedcom_id'), WT_Filter::post('xref', WT_REGEX_XREF), $block_id));
             } else {
                 WT_DB::prepare("INSERT INTO `##block` (gedcom_id, xref, module_name, block_order) VALUES (?, ?, ?, ?)")->execute(array(WT_Filter::postInteger('gedcom_id'), WT_Filter::post('xref', WT_REGEX_XREF), $this->getName(), 0));
                 $block_id = WT_DB::getInstance()->lastInsertId();
             }
             set_block_setting($block_id, 'title', WT_Filter::post('title'));
             set_block_setting($block_id, 'story_body', WT_Filter::post('story_body'));
             $languages = array();
             foreach (WT_I18N::installed_languages() as $code => $name) {
                 if (WT_Filter::postBool('lang_' . $code)) {
                     $languages[] = $code;
                 }
             }
             set_block_setting($block_id, 'languages', implode(',', $languages));
             $this->config();
         } else {
             $block_id = WT_Filter::getInteger('block_id');
             $controller = new WT_Controller_Page();
             if ($block_id) {
                 $controller->setPageTitle(WT_I18N::translate('Edit story'));
                 $title = get_block_setting($block_id, 'title');
                 $story_body = get_block_setting($block_id, 'story_body');
                 $gedcom_id = WT_DB::prepare("SELECT gedcom_id FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne();
                 $xref = WT_DB::prepare("SELECT xref FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne();
             } else {
                 $controller->setPageTitle(WT_I18N::translate('Add a story'));
                 $title = '';
                 $story_body = '';
                 $gedcom_id = WT_GED_ID;
                 $xref = WT_Filter::get('xref', WT_REGEX_XREF);
             }
             $controller->pageHeader()->addExternalJavascript(WT_STATIC_URL . 'js/autocomplete.js')->addInlineJavascript('autocomplete();');
             if (array_key_exists('ckeditor', WT_Module::getActiveModules())) {
                 ckeditor_WT_Module::enableEditor($controller);
             }
             echo '<form name="story" method="post" action="module.php?mod=', $this->getName(), '&amp;mod_action=admin_edit">';
             echo WT_Filter::getCsrf();
             echo '<input type="hidden" name="save" value="1">';
             echo '<input type="hidden" name="block_id" value="', $block_id, '">';
             echo '<input type="hidden" name="gedcom_id" value="', WT_GED_ID, '">';
             echo '<table id="story_module">';
             echo '<tr><th>';
             echo WT_I18N::translate('Story title');
             echo '</th></tr><tr><td><textarea name="title" rows="1" cols="90" tabindex="2">', WT_Filter::escapeHtml($title), '</textarea></td></tr>';
             echo '<tr><th>';
             echo WT_I18N::translate('Story');
             echo '</th></tr><tr><td>';
             echo '<textarea name="story_body" class="html-edit" rows="10" cols="90" tabindex="2">', WT_Filter::escapeHtml($story_body), '</textarea>';
             echo '</td></tr>';
             echo '</table><table id="story_module2">';
             echo '<tr>';
             echo '<th>', WT_I18N::translate('Individual'), '</th>';
             echo '<th>', WT_I18N::translate('Show this block for which languages?'), '</th>';
             echo '</tr>';
             echo '<tr>';
             echo '<td class="optionbox">';
             echo '<input data-autocomplete-type="INDI" type="text" name="xref" id="pid" size="4" value="' . $xref . '">';
             echo print_findindi_link('pid');
             if ($xref) {
                 $person = WT_Individual::getInstance($xref);
                 if ($person) {
                     echo ' ', $person->format_list('span');
                 }
             }
             echo '</td>';
             $languages = get_block_setting($block_id, 'languages');
             echo '<td class="optionbox">';
             echo edit_language_checkboxes('lang_', $languages);
             echo '</td></tr></table>';
             echo '<p><input type="submit" value="', WT_I18N::translate('save'), '" tabindex="5">';
             echo '</p>';
             echo '</form>';
             exit;
         }
     } else {
         header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH);
         exit;
     }
 }
开发者ID:brambravo,项目名称:webtrees,代码行数:86,代码来源:module.php

示例3: update_places

/**
 * extract all places from the given record and insert them into the places table
 *
 * @param        $gid
 * @param        $ged_id
 * @param string $gedrec
 */
function update_places($gid, $ged_id, $gedrec)
{
    global $placecache;
    static $sql_insert_placelinks = null;
    static $sql_insert_places = null;
    static $sql_select_places = null;
    if (!$sql_insert_placelinks) {
        // Use INSERT IGNORE as a (temporary) fix for https://bugs.launchpad.net/webtrees/+bug/582226
        // It ignores places that utf8_unicode_ci consider to be the same (i.e. accents).
        // For example Québec and Quebec
        // We need a better solution that attaches multiple names to single places
        $sql_insert_placelinks = WT_DB::prepare("INSERT IGNORE INTO `##placelinks` (pl_p_id, pl_gid, pl_file) VALUES (?,?,?)");
        $sql_insert_places = WT_DB::prepare("INSERT INTO `##places` (p_place, p_parent_id, p_file, p_std_soundex, p_dm_soundex) VALUES (?,?,?,?,?)");
        $sql_select_places = WT_DB::prepare("SELECT p_id FROM `##places` WHERE p_file=? AND p_parent_id=? AND p_place=?");
    }
    if (!isset($placecache)) {
        $placecache = array();
    }
    $personplace = array();
    // import all place locations, but not control info such as
    // 0 HEAD/1 PLAC or 0 _EVDEF/1 PLAC
    $pt = preg_match_all("/^[2-9] PLAC (.+)/m", $gedrec, $match, PREG_SET_ORDER);
    for ($i = 0; $i < $pt; $i++) {
        $place = trim($match[$i][1]);
        $lowplace = WT_I18N::strtolower($place);
        //-- if we have already visited this place for this person then we don't need to again
        if (isset($personplace[$lowplace])) {
            continue;
        }
        $personplace[$lowplace] = 1;
        $places = explode(',', $place);
        //-- reverse the array to start at the highest level
        $secalp = array_reverse($places);
        $parent_id = 0;
        $search = true;
        foreach ($secalp as $place) {
            $place = trim($place);
            $key = strtolower($place . "_" . $parent_id);
            //-- if this place has already been added then we don't need to add it again
            if (isset($placecache[$key])) {
                $parent_id = $placecache[$key];
                if (!isset($personplace[$key])) {
                    $personplace[$key] = 1;
                    $sql_insert_placelinks->execute(array($parent_id, $gid, $ged_id));
                }
                continue;
            }
            //-- only search the database while we are finding places in it
            if ($search) {
                //-- check if this place and level has already been added
                $tmp = $sql_select_places->execute(array($ged_id, $parent_id, $place))->fetchOne();
                if ($tmp) {
                    $p_id = $tmp;
                } else {
                    $search = false;
                }
            }
            //-- if we are not searching then we have to insert the place into the db
            if (!$search) {
                $std_soundex = WT_Soundex::soundex_std($place);
                $dm_soundex = WT_Soundex::soundex_dm($place);
                $sql_insert_places->execute(array($place, $parent_id, $ged_id, $std_soundex, $dm_soundex));
                $p_id = WT_DB::getInstance()->lastInsertId();
            }
            $sql_insert_placelinks->execute(array($p_id, $gid, $ged_id));
            //-- increment the level and assign the parent id for the next place level
            $parent_id = $p_id;
            $placecache[$key] = $p_id;
            $personplace[$key] = 1;
        }
    }
}
开发者ID:brambravo,项目名称:webtrees,代码行数:79,代码来源:functions_import.php


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