}
     if (version_compare($version, $zpversion) < 0) {
         if (empty($version)) {
             $version = '0.0.0';
         }
         $language .= ' <small>{v' . $version . '}</small>';
         $languageAlt .= ' {v' . $version . '}';
         $class = ' style="background-color:#FFEFB7;"';
     }
 } else {
     $version = $zpversion;
 }
 if (empty($dirname)) {
     $flag = WEBPATH . '/' . ZENFOLDER . '/locale/auto.png';
 } else {
     $flag = getLanguageFlag($dirname);
 }
 if (getOption('unsupported_' . $dirname)) {
     $c_attrs = $r_attrs = ' disabled="disabled"';
 } else {
     if (getOption('disallow_' . $dirname)) {
         $c_attrs = '';
         $r_attrs = ' disabled="disabled"';
     } else {
         $c_attrs = ' checked="checked"';
         $r_attrs = '';
     }
 }
 if ($dirname == $currentValue) {
     $r_attrs = ' checked="checked"';
     $c_attrs = ' checked="checked" disabled="disabled"';
Beispiel #2
0
        ?>
"<?php 
        if ($lang == $currentValue) {
            echo ' class="currentLanguage"';
        }
        ?>
>
																<a onclick="javascript:languageChange('<?php 
        echo $id;
        ?>
', '<?php 
        echo $lang;
        ?>
');" >
																	<img src="<?php 
        echo getLanguageFlag($lang);
        ?>
" alt="<?php 
        echo $text;
        ?>
" title="<?php 
        echo $text;
        ?>
" />
																</a>
															</li>
															<?php 
        $c++;
        if ($c % 7 == 0) {
            echo '<br class="clearall" />';
        }
/**
 * prints a form for selecting a locale
 * The POST handling is by getUserLocale() called in functions.php
 *
 */
function printLanguageSelector($flags = NULL)
{
    $localeOption = getOption('locale');
    $languages = generateLanguageList();
    if (isset($_REQUEST['locale'])) {
        $locale = sanitize($_REQUEST['locale']);
        if ($localeOption != $locale) {
            ?>
			<div class="errorbox">
				<h2>
					<?php 
            printf(gettext('<em>%s</em> is not available.'), html_encode($locale));
            ?>
					<?php 
            printf(gettext('The locale %s is not supported on your server.'), html_encode($locale));
            ?>
					<br />
					<?php 
            echo gettext('You can use the <em>debug</em> plugin to see which locales your server supports.');
            ?>
				</h2>
			</div>
			<?php 
        }
    }
    if (is_null($flags)) {
        $flags = getOption('dynamic_locale_visual');
    }
    if ($flags) {
        asort($languages);
        ?>
		<ul class="flags">
			<?php 
        $request = parse_url(getRequestURI());
        $separator = '?';
        if (isset($request['query'])) {
            $query = explode('&', $request['query']);
            $uri['query'] = '';
            foreach ($query as $key => $str) {
                if (preg_match('/^locale\\s*=/', $str)) {
                    unset($query[$key]);
                }
            }
            if (empty($query)) {
                unset($request['query']);
            } else {
                $request['query'] = implode('&', $query);
                $separator = '&';
            }
        }
        $uri = $request['path'];
        if (isset($request['query'])) {
            $uri .= '?' . $request['query'];
        }
        foreach ($languages as $text => $lang) {
            ?>
				<li<?php 
            if ($lang == $localeOption) {
                echo ' class="currentLanguage"';
            }
            ?>
>
					<?php 
            switch (LOCALE_TYPE) {
                case 2:
                    $path = dynamic_locale::fullHostPath($lang) . html_encode($uri);
                    break;
                case 1:
                    $path = seo_locale::localePath(false, $lang) . str_replace(WEBPATH, '', html_encode($uri));
                    break;
                default:
                    $path = $uri . $separator . 'locale=' . $lang;
                    break;
            }
            $flag = getLanguageFlag($lang);
            if ($lang != $localeOption) {
                ?>
						<a onclick="launchScript('<?php 
                echo $path;
                ?>
', []);" >
							<?php 
            }
            ?>
						<img src="<?php 
            echo $flag;
            ?>
" alt="<?php 
            echo $text;
            ?>
" title="<?php 
            echo $text;
            ?>
" />
						<?php 
            if ($lang != $localeOption) {
                ?>
						</a>
						<?php 
            }
            ?>
				</li>
				<?php 
        }
        ?>
		</ul>
		<?php 
    } else {
        ?>
		<form action="#" method="post">
			<input type="hidden" name="oldlocale" value="<?php 
        echo getOption('locale');
        ?>
" />
			<select id="dynamic-locale" class="languageselect" name="locale" onchange="this.form.submit()">
				<?php 
        foreach ($languages as $text => $lang) {
            echo '<option class="languageoption" value="' . html_encode($lang) . '"';
            if ($lang == $localeOption) {
                echo ' selected="selected"';
            }
            echo '>';
            echo html_encode($text) . "</option>\n";
        }
        ?>
			</select>
		</form>
		<?php 
    }
}
/**
 * Creates an unordered checklist of the tags
 *
 * @param object $that Object for which to get the tags
 * @param string $postit prefix to prepend for posting
 * @param bool $showCounts set to true to get tag count displayed
 * @param string $tagsort set true to sort alphabetically
 * @param bool $addnew true enables adding tags, ==2 for "additive" tags
 * @param bool $resizeable set true to allow the box to be resized
 * @param string $class class of the selections
 */
function tagSelector($that, $postit, $showCounts = false, $tagsort = 'alpha', $addnew = true, $resizeable = false, $class = 'checkTagsAuto')
{
    global $_zp_admin_ordered_taglist, $_zp_admin_LC_taglist;
    if ((int) $addnew <= 1 && is_null($_zp_admin_ordered_taglist)) {
        switch ($tagsort) {
            case 'language':
                $order = '`language` DESC,`name`';
                break;
            case 'recent':
                $order = '`id` DESC';
                break;
            default:
                $order = '`name`';
                break;
        }
        $languages = $counts = array();
        $sql = "SELECT DISTINCT tags.name, tags.language, tags.id, (SELECT COUNT(*) FROM " . prefix('obj_to_tag') . " as object WHERE object.tagid = tags.id) AS count FROM " . prefix('tags') . " as tags ORDER BY {$order}";
        $tagresult = query($sql);
        if ($tagresult) {
            while ($tag = db_fetch_assoc($tagresult)) {
                $counts[$tag['name']] = $tag['count'];
                $languages[$tag['name']] = $tag['language'];
            }
            db_free_result($tagresult);
        }
        if ($tagsort == 'mostused') {
            arsort($counts, SORT_NUMERIC);
        }
        $_zp_admin_LC_taglist = $them = array();
        foreach ($counts as $tag => $count) {
            $them[mb_strtolower($tag)] = $tag;
            $_zp_admin_LC_taglist[$tag] = $tag;
        }
        $flags = array('' => WEBPATH . '/' . ZENFOLDER . '/images/placeholder.png');
        foreach (generateLanguageList('all') as $dirname) {
            $flags[$dirname] = getLanguageFlag($dirname);
        }
        $_zp_admin_ordered_taglist = array($them, $counts, $languages, $flags);
    } else {
        list($them, $counts, $languages, $flags) = $_zp_admin_ordered_taglist;
        if ((int) $addnew == 2) {
            $them = $counts = array();
        }
    }
    if (is_null($that)) {
        $tags = array();
    } else {
        $tags = $that->getTags(false);
    }
    if (count($tags) > 0) {
        $them = array_diff_key($them, $tags);
    }
    $total = count($tags) + count($them);
    if ($resizeable) {
        if ($total > 0) {
            $tagclass = 'resizeable_tagchecklist';
        } else {
            $tagclass = 'resizeable_empty_tagchecklist';
        }
        if (is_bool($resizeable)) {
            $tagclass .= ' resizeable_tagchecklist_fixed_width';
        }
        ?>
			<script>
				$(function () {
					$("#resizable_<?php 
        echo $postit;
        ?>
").resizable({
						minHeight: 120,
						resize: function (event, ui) {
							$(this).css("width", '');
							$('#list_<?php 
        echo $postit;
        ?>
').height($('#resizable_<?php 
        echo $postit;
        ?>
').height());
						}
					})
				});</script>
			<?php 
    } else {
        $tagclass = 'tagchecklist';
    }
    if ($addnew) {
        ?>
			<span class="new_tag displayinline" >
				<a onclick="addNewTag('<?php 
        echo $postit;
        ?>
');" title="<?php 
        echo gettext('add tag');
        ?>
">
					<img src="<?php 
        echo WEBPATH . '/' . ZENFOLDER;
        ?>
/images/add.png" title="<?php 
        echo gettext('add tag');
        ?>
"/>
				</a>
				<span class="tagSuggestContainer">
					<input class="tagsuggest <?php 
        echo $class;
        ?>
 " type="text" value="" name="newtag_<?php 
        echo $postit;
        ?>
" id="newtag_<?php 
        echo $postit;
        ?>
" />
				</span>
			</span>
			<?php 
        if ((int) $addnew == 2) {
            ?>
				<input type="hidden" value="1" name="additive_<?php 
            echo $postit;
            ?>
" id="additive_<?php 
            echo $postit;
            ?>
" />
				<?php 
        }
    }
    ?>
		<div id="resizable_<?php 
    echo $postit;
    ?>
" class="tag_div">
			<ul id="list_<?php 
    echo $postit;
    ?>
" class="<?php 
    echo $tagclass;
    ?>
">
				<?php 
    if (count($tags) > 0) {
        foreach ($tags as $tag => $item) {
            $listitem = $postit . postIndexEncode($item);
            ?>
						<li id="<?php 
            echo $tag;
            ?>
_element">
							<label class="displayinline">
								<input id="<?php 
            echo $listitem;
            ?>
" class="<?php 
            echo $class;
            ?>
" name="<?php 
            echo 'tag_list_' . $postit . '[]';
            ?>
" type="checkbox" checked="checked" value="<?php 
            echo html_encode($item);
            ?>
" />
								<img src="<?php 
            echo $flags[$languages[$item]];
            ?>
" height="10" width="16" />
								<?php 
            if ($showCounts) {
                echo html_encode($item) . ' [' . $counts[$item] . ']';
            } else {
                echo html_encode($item);
            }
            ?>
							</label>
						</li>
						<?php 
        }
        ?>
					<li><hr /></li>
					<?php 
    }
    foreach ($them as $tagLC => $item) {
        $listitem = $postit . postIndexEncode($item);
        ?>
					<li id="<?php 
        echo $listitem;
        ?>
_element">
						<label class="displayinline">
							<input id="<?php 
        echo $listitem;
        ?>
" class="<?php 
        echo $class;
        ?>
" name="<?php 
        echo 'tag_list_' . $postit . '[]';
        ?>
" type="checkbox" value="<?php 
        echo html_encode($item);
        ?>
" />
							<img src="<?php 
        echo $flags[$languages[$item]];
        ?>
" height="10" width="16" />
							<?php 
        if ($showCounts) {
            echo html_encode($item) . ' [' . $counts[$item] . ']';
        } else {
            echo html_encode($item);
        }
        ?>
						</label>
					</li>
					<?php 
    }
    ?>
			</ul>
		</div>
		<?php 
}
/**
 * prints a form for selecting a locale
 * The POST handling is by getUserLocale() called in functions.php
 *
 */
function printLanguageSelector($flags = NULL)
{
    $languages = generateLanguageList();
    if (isset($_REQUEST['locale'])) {
        $locale = sanitize($_REQUEST['locale']);
        if (getOption('locale') != $locale) {
            ?>
			<div class="errorbox">
				<h2>
					<?php 
            printf(gettext('<em>%s</em> is not available.'), html_encode($locale));
            ?>
					<?php 
            printf(gettext('The locale %s is not supported on your server.'), html_encode($locale));
            ?>
					<br />
					<?php 
            echo gettext('See the troubleshooting guide on zenphoto.org for details.');
            ?>
				</h2>
			</div>
			<?php 
        }
    }
    if (is_null($flags)) {
        $flags = getOption('dynamic_locale_visual');
    }
    if ($flags) {
        asort($languages);
        ?>
		<ul class="flags">
			<?php 
        $currentValue = getOption('locale');
        $request = parse_url(getRequestURI());
        $separator = '?';
        if (isset($request['query'])) {
            $query = explode('&', $request['query']);
            $uri['query'] = '';
            foreach ($query as $key => $str) {
                if (preg_match('/^locale\\s*=/', $str)) {
                    unset($query[$key]);
                }
            }
            if (empty($query)) {
                unset($request['query']);
            } else {
                $request['query'] = implode('&', $query);
                $separator = '&';
            }
        }
        $uri = $request['path'];
        if (isset($request['query'])) {
            $uri .= '?' . $request['query'];
        }
        foreach ($languages as $text => $lang) {
            ?>
				<li<?php 
            if ($lang == $currentValue) {
                echo ' class="currentLanguage"';
            }
            ?>
>
					<?php 
            if ($lang != $currentValue) {
                switch (LOCALE_TYPE) {
                    case 2:
                        ?>
								<a href="<?php 
                        echo dynamic_locale::fullHostPath($lang) . html_encode($uri);
                        ?>
" >
									<?php 
                        break;
                    case 1:
                        ?>
									<a href="<?php 
                        echo str_replace(WEBPATH, seo_locale::localePath(false, $lang), html_encode($uri));
                        ?>
" >
										<?php 
                        break;
                    default:
                        ?>
										<a href="<?php 
                        echo $uri . $separator;
                        ?>
locale=<?php 
                        echo $lang;
                        ?>
" >
											<?php 
                        break;
                }
            }
            $flag = getLanguageFlag($lang);
            ?>
								<img src="<?php 
            echo $flag;
            ?>
" alt="<?php 
            echo $text;
            ?>
" title="<?php 
            echo $text;
            ?>
" />
								<?php 
            if ($lang != $currentValue) {
                ?>
								</a>
								<?php 
            }
            ?>
							</li>
							<?php 
        }
        ?>
						</ul>
						<?php 
    } else {
        ?>
						<form action="#" method="post">
							<input type="hidden" name="oldlocale" value="<?php 
        echo getOption('locale');
        ?>
" />
							<select id="dynamic-locale" class="languageselect" name="locale" onchange="this.form.submit()">
								<?php 
        $currentValue = getOption('locale');
        foreach ($languages as $key => $item) {
            echo '<option class="languageoption" value="' . html_encode($item) . '"';
            if ($item == $currentValue) {
                echo ' selected="selected"';
            }
            echo ' >';
            echo html_encode($key) . "</option>\n";
        }
        ?>
							</select>
						</form>
						<?php 
    }
}