Exemple #1
0
$controller = new SimpleController();
$type = Filter::get('type');
$filter = Filter::get('filter');
$action = Filter::get('action');
$callback = Filter::get('callback', '[a-zA-Z0-9_]+', 'paste_id');
$all = Filter::getBool('all');
$subclick = Filter::get('subclick');
$choose = Filter::get('choose', '[a-zA-Z0-9_]+', '0all');
$qs = Filter::get('tags');
if ($subclick === 'all') {
    $all = true;
}
$embed = substr($choose, 0, 1) === '1';
switch ($type) {
    case 'indi':
        $controller->setPageTitle(I18N::translate('Find an individual'));
        break;
    case 'fam':
        $controller->setPageTitle(I18N::translate('Find a family'));
        break;
    case 'media':
        $controller->setPageTitle(I18N::translate('Find a media object'));
        break;
    case 'place':
        $controller->setPageTitle(I18N::translate('Find a place'));
        break;
    case 'repo':
        $controller->setPageTitle(I18N::translate('Find a repository'));
        break;
    case 'note':
        $controller->setPageTitle(I18N::translate('Find a shared note'));
    /**
     * Select a flag.
     */
    private function flags()
    {
        global $WT_TREE;
        $controller = new SimpleController();
        $controller->setPageTitle(I18N::translate('Select flag'))->pageHeader();
        $stats = new Stats($WT_TREE);
        $countries = $stats->getAllCountries();
        $action = Filter::post('action');
        $countrySelected = Filter::get('countrySelected', null, 'Countries');
        $stateSelected = Filter::get('stateSelected', null, 'States');
        $country = array();
        if (is_dir(WT_ROOT . WT_MODULES_DIR . 'googlemap/places/flags')) {
            $rep = opendir(WT_ROOT . WT_MODULES_DIR . 'googlemap/places/flags');
            while ($file = readdir($rep)) {
                if (stristr($file, '.png')) {
                    $country[] = substr($file, 0, strlen($file) - 4);
                }
            }
            closedir($rep);
            sort($country);
        }
        if ($countrySelected == 'Countries') {
            $flags = $country;
        } else {
            $flags = array();
            if (is_dir(WT_ROOT . WT_MODULES_DIR . 'googlemap/places/' . $countrySelected . '/flags')) {
                $rep = opendir(WT_ROOT . WT_MODULES_DIR . 'googlemap/places/' . $countrySelected . '/flags');
                while ($file = readdir($rep)) {
                    if (stristr($file, '.png')) {
                        $flags[] = substr($file, 0, strlen($file) - 4);
                    }
                }
                closedir($rep);
                sort($flags);
            }
        }
        $flags_s = array();
        if ($stateSelected != 'States' && is_dir(WT_ROOT . WT_MODULES_DIR . 'googlemap/places/' . $countrySelected . '/flags/' . $stateSelected)) {
            $rep = opendir(WT_ROOT . WT_MODULES_DIR . 'googlemap/places/' . $countrySelected . '/flags/' . $stateSelected);
            while ($file = readdir($rep)) {
                if (stristr($file, '.png')) {
                    $flags_s[] = substr($file, 0, strlen($file) - 4);
                }
            }
            closedir($rep);
            sort($flags_s);
        }
        if ($action == 'ChangeFlag' && isset($_POST['FLAGS'])) {
            ?>
			<script>
		<?php 
            if ($_POST['selcountry'] == 'Countries') {
                ?>
					window.opener.document.editplaces.icon.value = 'places/flags/<?php 
                echo $flags[$_POST['FLAGS']];
                ?>
.png';
					window.opener.document.getElementById('flagsDiv').innerHTML = "<img src=\"<?php 
                echo WT_STATIC_URL . WT_MODULES_DIR;
                ?>
googlemap/places/flags/<?php 
                echo $country[$_POST['FLAGS']];
                ?>
.png\">&nbsp;&nbsp;<a href=\"#\" onclick=\"change_icon();return false;\"><?php 
                echo I18N::translate('Change flag');
                ?>
</a>&nbsp;&nbsp;<a href=\"#\" onclick=\"remove_icon();return false;\"><?php 
                echo I18N::translate('Remove flag');
                ?>
</a>";
		<?php 
            } elseif ($_POST['selstate'] != "States") {
                ?>
					window.opener.document.editplaces.icon.value = 'places/<?php 
                echo $countrySelected . '/flags/' . $_POST['selstate'] . '/' . $flags_s[$_POST['FLAGS']];
                ?>
.png';
					window.opener.document.getElementById('flagsDiv').innerHTML = "<img src=\"<?php 
                echo WT_STATIC_URL . WT_MODULES_DIR;
                ?>
googlemap/places/<?php 
                echo $countrySelected . "/flags/" . $_POST['selstate'] . '/' . $flags_s[$_POST['FLAGS']];
                ?>
.png\">&nbsp;&nbsp;<a href=\"#\" onclick=\"change_icon();return false;\"><?php 
                echo I18N::translate('Change flag');
                ?>
</a>&nbsp;&nbsp;<a href=\"#\" onclick=\"remove_icon();return false;\"><?php 
                echo I18N::translate('Remove flag');
                ?>
</a>";
		<?php 
            } else {
                ?>
					window.opener.document.editplaces.icon.value = "places/<?php 
                echo $countrySelected . '/flags/' . $flags[$_POST['FLAGS']];
                ?>
.png";
					window.opener.document.getElementById('flagsDiv').innerHTML = "<img src=\"<?php 
                echo WT_STATIC_URL . WT_MODULES_DIR;
                ?>
googlemap/places/<?php 
                echo $countrySelected . '/flags/' . $flags[$_POST['FLAGS']];
                ?>
.png\">&nbsp;&nbsp;<a href=\"#\" onclick=\"change_icon();return false;\"><?php 
                echo I18N::translate('Change flag');
                ?>
</a>&nbsp;&nbsp;<a href=\"#\" onclick=\"remove_icon();return false;\"><?php 
                echo I18N::translate('Remove flag');
                ?>
</a>";
		<?php 
            }
            ?>
					window.opener.updateMap();
					window.close();
			</script>
		<?php 
            exit;
        } else {
            ?>
		<script>
			function selectCountry() {
				if (document.flags.COUNTRYSELECT.value == 'Countries') {
					window.location="module.php?mod=googlemap&mod_action=flags&countrySelected=Countries";
				} else if (document.flags.STATESELECT.value != 'States') {
					window.location="module.php?mod=googlemap&mod_action=flags&countrySelected=" + document.flags.COUNTRYSELECT.value + "&stateSelected=" + document.flags.STATESELECT.value;
				} else {
					window.location="module.php?mod=googlemap&mod_action=flags&countrySelected=" + document.flags.COUNTRYSELECT.value;
				}
			}
		</script>
		<?php 
        }
        $countryList = array();
        $placesDir = scandir(WT_MODULES_DIR . 'googlemap/places/');
        for ($i = 0; $i < count($country); $i++) {
            if (count(preg_grep('/' . $country[$i] . '/', $placesDir)) != 0) {
                $rep = opendir(WT_MODULES_DIR . 'googlemap/places/' . $country[$i] . '/');
                while ($file = readdir($rep)) {
                    if (stristr($file, 'flags')) {
                        if (isset($countries[$country[$i]])) {
                            $countryList[$country[$i]] = $countries[$country[$i]];
                        } else {
                            $countryList[$country[$i]] = $country[$i];
                        }
                    }
                }
                closedir($rep);
            }
        }
        asort($countryList);
        $stateList = array();
        if ($countrySelected != 'Countries') {
            $placesDir = scandir(WT_MODULES_DIR . 'googlemap/places/' . $countrySelected . '/flags/');
            for ($i = 0; $i < count($flags); $i++) {
                if (in_array($flags[$i], $placesDir)) {
                    $rep = opendir(WT_MODULES_DIR . 'googlemap/places/' . $countrySelected . '/flags/' . $flags[$i] . '/');
                    while ($file = readdir($rep)) {
                        $stateList[$flags[$i]] = $flags[$i];
                    }
                    closedir($rep);
                }
            }
            asort($stateList);
        }
        ?>
		<h4><?php 
        echo I18N::translate('Change flag');
        ?>
</h4>

		<p class="small text-muted">
			<?php 
        echo I18N::translate('Using the pull down menu it is possible to select a country, of which a flag can be selected.  If no flags are shown, then there are no flags defined for this country.');
        ?>
		</p>

		<form method="post" id="flags" name="flags" action="module.php?mod=googlemap&amp;mod_action=flags&amp;countrySelected=<?php 
        echo $countrySelected;
        ?>
&amp;stateSelected=<?php 
        echo $stateSelected;
        ?>
">
			<input type="hidden" name="action" value="ChangeFlag">
			<input type="hidden" name="selcountry" value="<?php 
        echo $countrySelected;
        ?>
">
			<input type="hidden" name="selstate" value="<?php 
        echo $stateSelected;
        ?>
">
			<table class="facts_table">
				<tr>
					<td class="optionbox" colspan="4">
						<select name="COUNTRYSELECT" dir="ltr" onchange="selectCountry()">
							<option value="Countries"><?php 
        echo I18N::translate('Countries');
        ?>
</option>
							<?php 
        foreach ($countryList as $country_key => $country_name) {
            echo '<option value="', $country_key, '" ';
            if ($countrySelected == $country_key) {
                echo 'selected';
            }
            echo '>', $country_name, '</option>';
        }
        ?>
						</select>
					</td>
				</tr>
				<tr>
		<?php 
        $j = 1;
        for ($i = 0; $i < count($flags); $i++) {
            if ($countrySelected == 'Countries') {
                $tempstr = '<td><input type="radio" dir="ltr" name="FLAGS" value="' . $i . '"><img src="' . WT_STATIC_URL . WT_MODULES_DIR . 'googlemap/places/flags/' . $flags[$i] . '.png" alt="' . $flags[$i] . '"  title="';
                if ($flags[$i] != 'blank') {
                    if (isset($countries[$flags[$i]])) {
                        $tempstr .= $countries[$flags[$i]];
                    } else {
                        $tempstr .= $flags[$i];
                    }
                } else {
                    $tempstr .= $countries['???'];
                }
                echo $tempstr, '">&nbsp;&nbsp;', $flags[$i], '</input></td>';
            } else {
                echo '<td><input type="radio" dir="ltr" name="FLAGS" value="', $i, '"><img src="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/places/', $countrySelected, '/flags/', $flags[$i], '.png">&nbsp;&nbsp;', $flags[$i], '</input></td>';
            }
            if ($j == 4) {
                echo '</tr><tr>';
                $j = 0;
            }
            $j++;
        }
        echo '</tr><tr';
        if ($countrySelected == 'Countries' || count($stateList) == 0) {
            echo ' style=" visibility: hidden"';
        }
        echo '>';
        ?>
					<td class="optionbox" colspan="4">
						<select name="STATESELECT" dir="ltr" onchange="selectCountry()">
							<option value="States"><?php 
        echo I18N::translate('Subdivision');
        ?>
</option>
							<?php 
        foreach ($stateList as $state_key => $state_name) {
            echo '<option value="', $state_key, '" ';
            if ($stateSelected == $state_key) {
                echo 'selected';
            }
            echo '>', $state_name, '</option>';
        }
        ?>
						</select>
					</td>
				</tr>
				<tr>
		<?php 
        $j = 1;
        for ($i = 0; $i < count($flags_s); $i++) {
            if ($stateSelected != 'States') {
                echo '<td><input type="radio" dir="ltr" name="FLAGS" value="', $i, '"><img src="', WT_STATIC_URL . WT_MODULES_DIR, 'googlemap/places/', $countrySelected, '/flags/', $stateSelected, '/', $flags_s[$i], '.png">&nbsp;&nbsp;', $flags_s[$i], '</input></td>';
            }
            if ($j == 4) {
                echo '</tr><tr>';
                $j = 0;
            }
            $j++;
        }
        ?>
				</tr>
			</table>
			<p id="save-cancel">
				<input type="submit" class="save" value="<?php 
        echo I18N::translate('save');
        ?>
">
				<input type="button" class="cancel" value="<?php 
        echo I18N::translate('close');
        ?>
" onclick="window.close();">
			</p>
		</form>
		<?php 
    }
Exemple #3
0
use Fisharebest\Webtrees\Controller\SimpleController;
use Fisharebest\Webtrees\Functions\FunctionsEdit;
use Fisharebest\Webtrees\Functions\FunctionsPrint;
use Fisharebest\Webtrees\GedcomCode\GedcomCodePedi;
define('WT_SCRIPT_NAME', 'edit_interface.php');
require './includes/session.php';
$action = Filter::post('action', null, Filter::get('action'));
$controller = new SimpleController();
$controller->restrictAccess(Auth::isEditor($WT_TREE))->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)->addInlineJavascript('autocomplete();')->addInlineJavascript('var locale_date_format="' . preg_replace('/[^DMY]/', '', str_replace(array('J', 'F'), array('D', 'M'), I18N::dateFormat())) . '";');
switch ($action) {
    ////////////////////////////////////////////////////////////////////////////////
    case 'editraw':
        $xref = Filter::get('xref', WT_REGEX_XREF);
        $record = GedcomRecord::getInstance($xref, $WT_TREE);
        check_record_access($record);
        $controller->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit raw GEDCOM'))->pageHeader()->addInlineJavascript('jQuery("#raw-gedcom-list").sortable({opacity: 0.7, cursor: "move", axis: "y"});');
        ?>
	<div id="edit_interface-page">
		<h4>
			<?php 
        echo $controller->getPageTitle();
        ?>
			<?php 
        echo FunctionsPrint::helpLink('edit_edit_raw');
        ?>
		</h4>
		<pre>     <?php 
        echo '0 @' . $record->getXref() . '@ ' . $record::RECORD_TYPE;
        ?>
</pre>
		<form method="post" action="edit_interface.php">
Exemple #4
0
}
if ($action == 'update' || $action == 'create') {
    if ($linktoid) {
        $disp = GedcomRecord::getInstance($linktoid, $WT_TREE)->canShow();
    }
}
if (!Auth::isEditor($WT_TREE) || !$disp) {
    $controller->pageHeader()->addInlineJavascript('closePopupAndReloadParent();');
    return;
}
// There is a lot of common code in the create and update cases…
// …and also in the admin_media_upload.php script
switch ($action) {
    case 'create':
        // Save the information from the “showcreateform” action
        $controller->setPageTitle(I18N::translate('Create a new media object'));
        // Validate the media folder
        $folderName = str_replace('\\', '/', $folder);
        $folderName = trim($folderName, '/');
        if ($folderName == '.') {
            $folderName = '';
        }
        if ($folderName) {
            $folderName .= '/';
            // Not allowed to use “../”
            if (strpos('/' . $folderName, '/../') !== false) {
                FlashMessages::addMessage('Folder names are not allowed to include “../”');
                break;
            }
        }
        // Make sure the media folder exists
    /**
     * Search for a media object.
     */
    private static function mediaQuery()
    {
        global $WT_TREE;
        $iid2 = Filter::get('iid', WT_REGEX_XREF);
        $controller = new SimpleController();
        $controller->setPageTitle(I18N::translate('Link to an existing media object'))->pageHeader();
        $record = GedcomRecord::getInstance($iid2, $WT_TREE);
        if ($record) {
            $headjs = '';
            if ($record instanceof Family) {
                if ($record->getHusband()) {
                    $headjs = $record->getHusband()->getXref();
                } elseif ($record->getWife()) {
                    $headjs = $record->getWife()->getXref();
                }
            }
            ?>
			<script>
				function insertId() {
					if (window.opener.document.getElementById('addlinkQueue')) {
						// alert('Please move this alert window and examine the contents of the pop-up window, then click OK')
						window.opener.insertRowToTable('<?php 
            echo $record->getXref();
            ?>
', '<?php 
            echo htmlspecialchars($record->getFullName());
            ?>
', '<?php 
            echo $headjs;
            ?>
');
						window.close();
					}
				}
			</script>
			<?php 
        } else {
            ?>
			<script>
				function insertId() {
					window.opener.alert('<?php 
            echo $iid2;
            ?>
 - <?php 
            echo I18N::translate('Not a valid individual, family, or source ID');
            ?>
');
					window.close();
				}
			</script>
			<?php 
        }
        ?>
		<script>window.onLoad = insertId();</script>
		<?php 
    }
Exemple #6
0
 /**
  * Run the report.
  */
 public function run()
 {
     $controller = new SimpleController();
     $controller->setPageTitle($this->title)->pageHeader();
     // Setting up the styles
     echo '<style type="text/css">';
     echo 'body { font: 10px sans-serif;}';
     foreach ($this->Styles as $class => $style) {
         echo '.', $class, ' { ';
         if ($style["font"] == "dejavusans") {
             $style["font"] = $this->defaultFont;
         }
         echo 'font-family: ', $style['font'], '; ';
         echo 'font-size: ', $style['size'], 'pt; ';
         // Case-insensitive
         if (stripos($style['style'], 'B') !== false) {
             echo 'font-weight: bold; ';
         }
         if (stripos($style['style'], 'I') !== false) {
             echo 'font-style: italic; ';
         }
         if (stripos($style['style'], 'U') !== false) {
             echo 'text-decoration: underline; ';
         }
         if (stripos($style['style'], 'D') !== false) {
             echo 'text-decoration: line-through; ';
         }
         echo '}', PHP_EOL;
     }
     unset($class, $style);
     //-- header divider
     echo '</style>', PHP_EOL;
     echo '<div id="headermargin" style="position: relative; top: auto; height: ', $this->headermargin, 'pt; width: ', $this->noMarginWidth, 'pt;"></div>';
     echo '<div id="headerdiv" style="position: relative; top: auto; width: ', $this->noMarginWidth, 'pt;">';
     foreach ($this->headerElements as $element) {
         if (is_object($element)) {
             $element->render($this);
         } elseif (is_string($element) && $element == "footnotetexts") {
             $this->footnotes();
         } elseif (is_string($element) && $element == "addpage") {
             $this->addPage();
         }
     }
     //-- body
     echo '</div>';
     echo '<script>document.getElementById("headerdiv").style.height="', $this->topmargin - $this->headermargin - 6, 'pt";</script>';
     echo '<div id="bodydiv" style="position: relative; top: auto; width: ', $this->noMarginWidth, 'pt; height: 100%;">';
     $this->Y = 0;
     $this->maxY = 0;
     $this->runPageHeader();
     foreach ($this->bodyElements as $element) {
         if (is_object($element)) {
             $element->render($this);
         } elseif (is_string($element) && $element == "footnotetexts") {
             $this->footnotes();
         } elseif (is_string($element) && $element == "addpage") {
             $this->addPage();
         }
     }
     //-- footer
     echo '</div>';
     echo '<script>document.getElementById("bodydiv").style.height="', $this->maxY, 'pt";</script>';
     echo '<div id="bottommargin" style="position: relative; top: auto; height: ', $this->bottommargin - $this->footermargin, 'pt;width:', $this->noMarginWidth, 'pt;"></div>';
     echo '<div id="footerdiv" style="position: relative; top: auto; width: ', $this->noMarginWidth, 'pt;height:auto;">';
     $this->Y = 0;
     $this->X = 0;
     $this->maxY = 0;
     foreach ($this->footerElements as $element) {
         if (is_object($element)) {
             $element->render($this);
         } elseif (is_string($element) && $element == "footnotetexts") {
             $this->footnotes();
         } elseif (is_string($element) && $element == "addpage") {
             $this->addPage();
         }
     }
     echo '</div>';
     echo '<script>document.getElementById("footerdiv").style.height="', $this->maxY, 'pt";</script>';
     echo '<div id="footermargin" style="position: relative; top: auto; height: ', $this->footermargin, 'pt;width:', $this->noMarginWidth, 'pt;"></div>';
 }
    /**
     * Select a flag.
     */
    private function flags()
    {
        global $WT_TREE;
        $controller = new SimpleController();
        $controller->setPageTitle(I18N::translate('Select flag'))->pageHeader();
        $stats = new Stats($WT_TREE);
        $countries = $stats->getAllCountries();
        $action = Filter::post('action');
        $countrySelected = Filter::get('countrySelected', null, 'Countries');
        $stateSelected = Filter::get('stateSelected', null, 'States');
        $country = array();
        if (is_dir(WT_ROOT . WT_MODULES_DIR . 'googlemap/places/flags')) {
            $files = glob(WT_ROOT . WT_MODULES_DIR . 'googlemap/places/flags/*.png');
            foreach ($files as $file) {
                $country[] = basename($file, '.png');
            }
        }
        if ($countrySelected == 'Countries') {
            $flags = $country;
        } else {
            $flags = array();
            if (is_dir(WT_ROOT . WT_MODULES_DIR . 'googlemap/places/' . $countrySelected . '/flags')) {
                $files = glob(WT_ROOT . WT_MODULES_DIR . 'googlemap/places/' . $countrySelected . '/flags/*.png');
                foreach ($files as $file) {
                    $flags[] = basename($file, '.png');
                }
            }
        }
        $flags_s = array();
        if ($stateSelected != 'States' && is_dir(WT_ROOT . WT_MODULES_DIR . 'googlemap/places/' . $countrySelected . '/flags/' . $stateSelected)) {
            $files = glob(WT_ROOT . WT_MODULES_DIR . 'googlemap/places/' . $countrySelected . '/flags/' . $stateSelected . '/*.png');
            foreach ($files as $file) {
                $flags_s[] = basename($file, '.png');
            }
        }
        if ($action == 'ChangeFlag' && Filter::post('FLAGS') !== null) {
            ?>
			<script>
		<?php 
            if (Filter::post('selcountry') == 'Countries') {
                ?>
					window.opener.document.editplaces.icon.value = 'places/flags/<?php 
                echo $flags[Filter::post('FLAGS')];
                ?>
.png';
					window.opener.document.getElementById('flagsDiv').innerHTML = "<img src=\"<?php 
                echo WT_STATIC_URL . WT_MODULES_DIR;
                ?>
googlemap/places/flags/<?php 
                echo $country[Filter::post('FLAGS')];
                ?>
.png\">&nbsp;&nbsp;<a href=\"#\" onclick=\"change_icon();return false;\"><?php 
                echo I18N::translate('Change flag');
                ?>
</a>&nbsp;&nbsp;<a href=\"#\" onclick=\"remove_icon();return false;\"><?php 
                echo I18N::translate('Remove flag');
                ?>
</a>";
		<?php 
            } elseif (Filter::post('selstate') != "States") {
                ?>
					window.opener.document.editplaces.icon.value = 'places/<?php 
                echo $countrySelected . '/flags/' . Filter::post('selstate') . '/' . $flags_s[Filter::post('FLAGS')];
                ?>
.png';
					window.opener.document.getElementById('flagsDiv').innerHTML = "<img src=\"<?php 
                echo WT_STATIC_URL . WT_MODULES_DIR;
                ?>
googlemap/places/<?php 
                echo $countrySelected . "/flags/" . Filter::post('selstate') . '/' . $flags_s[Filter::post('FLAGS')];
                ?>
.png\">&nbsp;&nbsp;<a href=\"#\" onclick=\"change_icon();return false;\"><?php 
                echo I18N::translate('Change flag');
                ?>
</a>&nbsp;&nbsp;<a href=\"#\" onclick=\"remove_icon();return false;\"><?php 
                echo I18N::translate('Remove flag');
                ?>
</a>";
		<?php 
            } else {
                ?>
					window.opener.document.editplaces.icon.value = "places/<?php 
                echo $countrySelected . '/flags/' . $flags[Filter::post('FLAGS')];
                ?>
.png";
					window.opener.document.getElementById('flagsDiv').innerHTML = "<img src=\"<?php 
                echo WT_STATIC_URL . WT_MODULES_DIR;
                ?>
googlemap/places/<?php 
                echo $countrySelected . '/flags/' . $flags[Filter::post('FLAGS')];
                ?>
.png\">&nbsp;&nbsp;<a href=\"#\" onclick=\"change_icon();return false;\"><?php 
                echo I18N::translate('Change flag');
                ?>
</a>&nbsp;&nbsp;<a href=\"#\" onclick=\"remove_icon();return false;\"><?php 
                echo I18N::translate('Remove flag');
                ?>
</a>";
		<?php 
            }
            ?>
					window.opener.updateMap();
					window.close();
			</script>
		<?php 
            return;
        } else {
            ?>
		<script>
			function selectCountry() {
				if (document.flags.COUNTRYSELECT.value == 'Countries') {
					window.location="module.php?mod=googlemap&mod_action=flags&countrySelected=Countries";
				} else if (document.flags.STATESELECT.value != 'States') {
					window.location="module.php?mod=googlemap&mod_action=flags&countrySelected=" + document.flags.COUNTRYSELECT.value + "&stateSelected=" + document.flags.STATESELECT.value;
				} else {
					window.location="module.php?mod=googlemap&mod_action=flags&countrySelected=" + document.flags.COUNTRYSELECT.value;
				}
			}
		</script>
		<?php 
        }
        $countryList = array();
        foreach ($country as $item) {
            if (is_dir(WT_MODULES_DIR . 'googlemap/places/' . $item . '/flags')) {
                if (isset($countries[$item])) {
                    $countryList[$item] = $countries[$item];
                } else {
                    $countryList[$item] = $item;
                }
            }
        }
        asort($countryList);
        $stateList = array();
        if ($countrySelected != 'Countries') {
            $placesDir = scandir(WT_MODULES_DIR . 'googlemap/places/' . $countrySelected . '/flags/');
            foreach ($flags as $flag) {
                if (in_array($flag, $placesDir)) {
                    $rep = opendir(WT_MODULES_DIR . 'googlemap/places/' . $countrySelected . '/flags/' . $flag . '/');
                    while ($file = readdir($rep)) {
                        $stateList[$flag] = $flag;
                    }
                    closedir($rep);
                }
            }
            asort($stateList);
        }
        ?>
		<h4><?php 
        echo I18N::translate('Change flag');
        ?>
</h4>

		<p class="small text-muted">
			<?php 
        echo I18N::translate('Using the pull down menu it is possible to select a country, of which a flag can be selected. If no flags are shown, then there are no flags defined for this country.');
        ?>
		</p>

		<form method="post" id="flags" name="flags" action="module.php?mod=googlemap&amp;mod_action=flags&amp;countrySelected=<?php 
        echo $countrySelected;
        ?>
&amp;stateSelected=<?php 
        echo $stateSelected;
        ?>
">
			<input type="hidden" name="action" value="ChangeFlag">
			<input type="hidden" name="selcountry" value="<?php 
        echo $countrySelected;
        ?>
">
			<input type="hidden" name="selstate" value="<?php 
        echo $stateSelected;
        ?>
">
			<table class="facts_table" style="margin: 0 auto 20px">
				<tr>
					<td class="optionbox" colspan="4">
						<select name="COUNTRYSELECT" dir="ltr" onchange="selectCountry()">
							<option value="Countries"><?php 
        echo I18N::translate('Countries');
        ?>
</option>
							<?php 
        foreach ($countryList as $country_key => $country_name) {
            echo '<option value="', $country_key, '" ';
            if ($countrySelected == $country_key) {
                echo 'selected';
            }
            echo '>', $country_name, '</option>';
        }
        ?>
						</select>
					</td>
				</tr>

				<?php 
        $i = 0;
        $path = WT_STATIC_URL . WT_MODULES_DIR . 'googlemap/places/';
        $path .= $countrySelected == 'Countries' ? 'flags/' : $countrySelected . '/flags/';
        foreach (array_chunk($flags, 4) as $row) {
            echo "<tr>";
            foreach ($row as $flag) {
                if ($flag != 'blank') {
                    if (isset($countries[$flag])) {
                        $title = $countries[$flag];
                    } else {
                        $title = $flag;
                    }
                } else {
                    $title = $countries['???'];
                }
                echo '<td>';
                echo '<input type="radio" dir="ltr" name="FLAGS" value="' . $i++ . '">';
                echo '<img style="width:25px; height:15px; margin-right:15px" src="' . $path . $flag . '.png" alt="' . $flag . '" title="' . $title . '">';
                echo $flag . '</td>';
            }
            echo str_repeat('<td></td>', 4 - count($row));
            echo "</tr>";
        }
        echo '<tr style="visibility:' . ($countrySelected == 'Countries' || count($stateList) == 0 ? 'hidden' : 'visible') . '">';
        ?>

				<td class="optionbox" colspan="4">
					<select name="STATESELECT" dir="ltr" onchange="selectCountry()">
						<option value="States"><?php 
        echo I18N::translate('Subdivision');
        ?>
</option>
						<?php 
        foreach ($stateList as $state_key => $state_name) {
            echo '<option value="', $state_key, '" ';
            if ($stateSelected == $state_key) {
                echo 'selected';
            }
            echo '>', $state_name, '</option>';
        }
        ?>
					</select>
				</td>
			</tr>

			<?php 
        $i = 0;
        if (!empty($flags_s)) {
            foreach (array_chunk($flags_s, 4) as $row) {
                echo "<tr>";
                foreach ($row as $flag) {
                    echo '<td><input type="radio" dir="ltr" name="FLAGS" value="', $i++, '"><img src="', WT_STATIC_URL . WT_MODULES_DIR, 'googlemap/places/', $countrySelected, '/flags/', $stateSelected, '/', $flag, '.png">&nbsp;&nbsp;', $flag, '</td>';
                }
                echo str_repeat('<td></td>', 4 - count($row));
                echo '</tr>';
            }
        }
        ?>

			</table>
			<p id="save-cancel">
				<input type="submit" class="save" value="<?php 
        echo I18N::translate('save');
        ?>
">
				<input type="button" class="cancel" value="<?php 
        echo I18N::translate('close');
        ?>
" onclick="window.close();">
			</p>
		</form>
		<?php 
    }
Exemple #8
0
 */
namespace Fisharebest\Webtrees;

use Fisharebest\Webtrees\Controller\SimpleController;
use Fisharebest\Webtrees\Module\CkeditorModule;
use PDO;
/**
 * Defined in session.php
 *
 * @global Tree $WT_TREE
 */
global $WT_TREE;
define('WT_SCRIPT_NAME', 'editnews.php');
require './includes/session.php';
$controller = new SimpleController();
$controller->setPageTitle(I18N::translate('Add/edit a journal/news entry'))->restrictAccess(Auth::isMember($WT_TREE))->pageHeader();
$action = Filter::get('action', 'compose|save', 'compose');
$news_id = Filter::getInteger('news_id');
$user_id = Filter::get('user_id', WT_REGEX_INTEGER, Filter::post('user_id', WT_REGEX_INTEGER));
$gedcom_id = Filter::get('gedcom_id', WT_REGEX_INTEGER, Filter::post('gedcom_id', WT_REGEX_INTEGER));
$date = Filter::postInteger('date', 0, PHP_INT_MAX, WT_TIMESTAMP);
$title = Filter::post('title');
$text = Filter::post('text');
switch ($action) {
    case 'compose':
        if (Module::getModuleByName('ckeditor')) {
            CkeditorModule::enableEditor($controller);
        }
        echo '<h3>' . I18N::translate('Add/edit a journal/news entry') . '</h3>';
        echo '<form style="overflow: hidden;" name="messageform" method="post" action="editnews.php?action=save&news_id=' . $news_id . '">';
        if ($news_id) {