Exemple #1
0
 /**
  *
  * supported options
  */
 function getOptionsSupported()
 {
     global $_zp_CMS;
     $options = array(gettext('Consumer key') => array('key' => 'tweet_news_consumer', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 2, 'desc' => gettext('This <code>tweet_news</code> app for this site needs a <em>consumer key</em>, a <em>consumer key secret</em>, an <em>access token</em>, and an <em>access token secret</em>.') . '<p class="notebox">' . gettext('Get these from <a href="http://dev.twitter.com/">Twitter developers</a>') . '</p>'), gettext('Secret') => array('key' => 'tweet_news_consumer_secret', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 3, 'desc' => gettext('The <em>secret</em> associated with your <em>consumer key</em>.')), gettext('Access token') => array('key' => 'tweet_news_oauth_token', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 4, 'desc' => gettext('The application <em>oauth_token</em> token.')), gettext('Access token secret') => array('key' => 'tweet_news_oauth_token_secret', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 5, 'desc' => gettext('The application <em>oauth_token</em> secret.')), gettext('Protected objects') => array('key' => 'tweet_news_protected', 'type' => OPTION_TYPE_CHECKBOX, 'order' => 7, 'desc' => gettext('If checked, protected items will be tweeted. <strong>Note:</strong> followers will need the password to visit the tweeted link.')));
     $list = array('<em>' . gettext('Albums') . '</em>' => 'tweet_news_albums', '<em>' . gettext('Images') . '</em>' => 'tweet_news_images');
     if (extensionEnabled('zenpage')) {
         $list['<em>' . gettext('News') . '</em>'] = 'tweet_news_news';
         $list['<em>' . gettext('Pages') . '</em>'] = 'tweet_news_pages';
     } else {
         setOption('tweet_news_news', 0);
         setOption('tweet_news_pages', 0);
     }
     $options[gettext('Tweet')] = array('key' => 'tweet_news_items', 'type' => OPTION_TYPE_CHECKBOX_ARRAY, 'order' => 6, 'checkboxes' => $list, 'desc' => gettext('If a <em>type</em> is checked, a Tweet will be made when an object of that <em>type</em> is published.'));
     if (getOption('multi_lingual')) {
         $options[gettext('Tweet Language')] = array('key' => 'tweet_language', 'type' => OPTION_TYPE_SELECTOR, 'order' => 5.5, 'selections' => generateLanguageList(), 'desc' => gettext('Select the language for the Tweet message.'));
     }
     if (getOption('tweet_news_news') && is_object($_zp_CMS)) {
         $catlist = getSerializedArray(getOption('tweet_news_categories'));
         $news_categories = $_zp_CMS->getAllCategories(false);
         $catlist = array(gettext('*not categorized*') => 'tweet_news_categories_none');
         foreach ($news_categories as $category) {
             $option = 'tweet_news_categories_' . $category['titlelink'];
             $catlist[$category['title']] = $option;
             setOptionDefault($option, NULL);
         }
         $options[gettext('News categories')] = array('key' => 'tweet_news_categories', 'type' => OPTION_TYPE_CHECKBOX_UL, 'order' => 6.5, 'checkboxes' => $catlist, 'desc' => gettext('Only those <em>news categories</em> checked will be Tweeted. <strong>Note:</strong> <em>*not categorized*</em> means those news articles which have no category assigned.'));
     }
     return $options;
 }
 static function new_image($image)
 {
     global $_zp_exifvars;
     $entry_locale = getUserLocale();
     $languages = generateLanguageList();
     $languageTags = $element = array();
     $candidates = self::getTaggingItems();
     foreach ($candidates as $key) {
         if ($meta = $image->get($key)) {
             setupCurrentLocale('en_US');
             $en_us = $element[] = exifTranslate($meta);
             foreach ($languages as $language) {
                 setupCurrentLocale($language);
                 $xlated = exifTranslate($meta);
                 if ($xlated != $en_us) {
                     // the string has a translation in this language
                     $element[] = $xlated;
                     $languageTags[$language] = $xlated;
                 }
             }
         }
     }
     setupCurrentLocale($entry_locale);
     $element = array_unique(array_merge($image->getTags(), $element));
     $image->setTags($element);
     $image->save();
     foreach ($languageTags as $language => $tag) {
         $sql = 'UPDATE ' . prefix('tags') . ' SET `language`=' . db_quote($language) . ' WHERE `name`=' . db_quote($tag) . ' AND `language`=NULL OR `language` LIKE ""';
         query($sql, false);
     }
     return $image;
 }
 function getOptionsSupported()
 {
     $host = $_SERVER['HTTP_HOST'];
     $matches = explode('.', $host);
     if (validateLocale($matches[0], 'Dynamic Locale')) {
         array_shift($matches);
         $host = implode('.', $matches);
     }
     $localdesc = '<p>' . sprintf(gettext('Select <em>Use subdomains</em> and links will be in the form <code><em>language</em>.%s</code> where <code><em>language</em></code> is the language code, e.g. <code><em>fr</em></code> for French.'), $host) . '</p>';
     $locales = generateLanguageList();
     $buttons = array(gettext('subdomain') => 2, gettext('URL') => 1, gettext('disabled') => 0);
     if (MOD_REWRITE) {
         $buttons[gettext('URL')] = 1;
         $localdesc .= '<p>' . sprintf(gettext('Select <em>URL</em> and links paths will have the language selector prepended in the form <code>%1$s/<em>language</em>/...</code>'), ltrim(WEBPATH, '/')) . '</p>';
     } else {
         unset($buttons[gettext('URL')]);
         if (getOption('dynamic_locale_subdomain') == 1) {
             setOption('dynamic_locale_subdomain', 0);
         }
     }
     $options = array(gettext('Use flags') => array('key' => 'dynamic_locale_visual', 'type' => OPTION_TYPE_CHECKBOX, 'order' => 0, 'desc' => gettext('Checked produces an array of flags. Not checked produces a selector.')), gettext('Language links') => array('key' => 'dynamic_locale_subdomain', 'type' => OPTION_TYPE_RADIO, 'order' => 1, 'buttons' => $buttons, 'desc' => $localdesc), gettext('Site language') => array('key' => 'dynamic_locale_base', 'type' => OPTION_TYPE_RADIO, 'order' => 2, 'buttons' => $locales, 'desc' => gettext('Set the primary language for your site.')));
     return $options;
 }
/**
 * returns a serialized "multilingual array" of translations
 * Used for setting default options with multi-lingual strings.
 * @param string $text to be translated
 */
function getAllTranslations($text)
{
    $entry_locale = getUserLocale();
    $result = array('en_US' => $text);
    $languages = generateLanguageList();
    $key = array_search('en_US', $languages);
    unset($languages[$key]);
    foreach ($languages as $language) {
        setupCurrentLocale($language);
        $xlated = gettext($text);
        if ($xlated != $text) {
            // the string has a translation in this language
            $result[$language] = $xlated;
        }
    }
    setupCurrentLocale($entry_locale);
    return serialize($result);
}
/**
 * Gets links to Zenpage news categories incl. pagination
 *
 * @return string
 */
function getSitemapZenpageNewsCategories()
{
    global $_zp_zenpage, $sitemap_number;
    //TODO not splitted into several sitemaps yet
    if ($sitemap_number == 1) {
        $data = '';
        $sitemap_locales = generateLanguageList();
        $changefreq = getOption('sitemap_changefreq_newscats');
        $newscats = $_zp_zenpage->getAllCategories();
        if ($newscats) {
            $data .= sitemap_echonl('<?xml version="1.0" encoding="UTF-8"?>');
            $data .= sitemap_echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
            foreach ($newscats as $newscat) {
                $catobj = new ZenpageCategory($newscat['titlelink']);
                if (!$catobj->isProtected()) {
                    switch (SITEMAP_LOCALE_TYPE) {
                        case 1:
                            foreach ($sitemap_locales as $locale) {
                                $url = seo_locale::localePath(true, $locale) . '/' . _CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/1';
                                $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            }
                            break;
                        case 2:
                            foreach ($sitemap_locales as $locale) {
                                $url = rewrite_path(_CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/1', '?p=news&amp;category=' . urlencode($catobj->getTitlelink()) . '&amp;page=1', dynamic_locale::fullHostPath($locale));
                                $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            }
                            break;
                        default:
                            $url = rewrite_path(_CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/1', '?p=news&amp;category=' . urlencode($catobj->getTitlelink()) . '&amp;page=1', FULLWEBPATH);
                            $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            break;
                    }
                    // getting pages for the categories
                    /*
                    					  if(!empty($articlesperpage)) {
                    					  $zenpage_articles_per_page = sanitize_numeric($articlesperpage);
                    					  } else {
                    					  $zenpage_articles_per_page = ZP_ARTICLES_PER_PAGE;
                    					  } */
                    $zenpage_articles_per_page = ZP_ARTICLES_PER_PAGE;
                    $articlecount = count($catobj->getArticles());
                    $catpages = ceil($articlecount / $zenpage_articles_per_page);
                    if ($catpages > 1) {
                        for ($x = 2; $x <= $catpages; $x++) {
                            switch (SITEMAP_LOCALE_TYPE) {
                                case 1:
                                    foreach ($sitemap_locales as $locale) {
                                        $url = seo_locale::localePath(true, $locale) . '/' . _CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/' . $x;
                                        $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    }
                                    break;
                                case 2:
                                    foreach ($sitemap_locales as $locale) {
                                        $url = rewrite_path(_CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/' . $x, '?p=news&amp;category=' . urlencode($catobj->getTitlelink()) . '&amp;page=' . $x, dynamic_locale::fullHostPath($locale));
                                        $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    }
                                    break;
                                default:
                                    $url = rewrite_path(_CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/' . $x, '?p=news&amp;category=' . urlencode($catobj->getTitlelink()) . '&amp;page=' . $x, FULLWEBPATH);
                                    $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    break;
                            }
                        }
                    }
                }
            }
            $data .= sitemap_echonl('</urlset>');
            // End off the <urlset> tag
        }
        return $data;
    }
}
/**
 * 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 
    }
}
/**
 * Gets links to Zenpage news categories incl. pagination
 *
 * @return string
 */
function getSitemapNewsCategories()
{
    global $_zp_CMS, $sitemap_number;
    //TODO not splitted into several sitemaps yet
    if ($sitemap_number == 1) {
        $data = '';
        $sitemap_locales = generateLanguageList();
        $changefreq = getOption('sitemap_changefreq_newscats');
        $newscats = $_zp_CMS->getAllCategories();
        if ($newscats) {
            $data .= sitemap_echonl('<?xml version="1.0" encoding="UTF-8"?>');
            $data .= sitemap_echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
            foreach ($newscats as $newscat) {
                $catobj = newCategory($newscat['titlelink']);
                if (!$catobj->isProtected()) {
                    $base = $catobj->getLink();
                    switch (SITEMAP_LOCALE_TYPE) {
                        case 1:
                            foreach ($sitemap_locales as $locale) {
                                $url = str_replace(WEBPATH, seo_locale::localePath(true, $locale), $base);
                                $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            }
                            break;
                        case 2:
                            foreach ($sitemap_locales as $locale) {
                                $url = dynamic_locale::fullHostPath($locale) . $base;
                                $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            }
                            break;
                        default:
                            $url = FULLHOSTPATH . $base;
                            $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            break;
                    }
                    // getting pages for the categories
                    $zenpage_articles_per_page = ZP_ARTICLES_PER_PAGE;
                    $articlecount = count($catobj->getArticles());
                    $catpages = ceil($articlecount / $zenpage_articles_per_page);
                    if ($catpages > 1) {
                        for ($x = 2; $x <= $catpages; $x++) {
                            $base = $catobj->getLink($x);
                            switch (SITEMAP_LOCALE_TYPE) {
                                case 1:
                                    foreach ($sitemap_locales as $locale) {
                                        $url = str_replace(WEBPATH, seo_locale::localePath(true, $locale), $base);
                                        $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    }
                                    break;
                                case 2:
                                    foreach ($sitemap_locales as $locale) {
                                        $url = dynamic_locale::fullHostPath($locale) . $base;
                                        $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    }
                                    break;
                                default:
                                    $url = FULLHOSTPATH . $base;
                                    $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    break;
                            }
                        }
                    }
                }
            }
            $data .= sitemap_echonl('</urlset>');
            // End off the <urlset> tag
        }
        return $data;
    }
}
</p>
									</td>
								</tr>
								<tr>
									<td width="175"><?php 
    echo gettext("Language:");
    ?>
</td>
									<td width="350">
										<?php 
    $currentValue = SITE_LOCALE;
    ?>
										<br />
										<ul class="languagelist">
											<?php 
    $locales = generateLanguageList('all');
    $locales[gettext("HTTP_Accept_Language")] = '';
    ksort($locales, SORT_LOCALE_STRING);
    $vers = explode('-', ZENPHOTO_VERSION);
    $vers = explode('.', $vers[0]);
    while (count($vers) < 3) {
        $vers[] = 0;
    }
    $zpversion = $vers[0] . '.' . $vers[1] . '.' . $vers[2];
    $c = 0;
    foreach ($locales as $language => $dirname) {
        $languageAlt = $language;
        $class = '';
        if (!empty($dirname) && $dirname != 'en_US') {
            $version = '';
            $po = file_get_contents(SERVERPATH . "/" . ZENFOLDER . "/locale/" . $dirname . '/LC_MESSAGES/zenphoto.po');
    echo gettext('Language:');
    ?>
</label></p>
													<input type="hidden" name="<?php 
    echo $id;
    ?>
-admin_language" id="admin_language_<?php 
    echo $id;
    ?>
" value="<?php 
    echo $currentValue;
    ?>
" />
													<ul class="flags" style="margin-left: 0px;">
														<?php 
    $_languages = generateLanguageList();
    $c = 0;
    foreach ($_languages as $text => $lang) {
        ?>
															<li id="<?php 
        echo $lang . '_' . $id;
        ?>
"<?php 
        if ($lang == $currentValue) {
            echo ' class="currentLanguage"';
        }
        ?>
>
																<a onclick="javascript:languageChange('<?php 
        echo $id;
        ?>
function setupLanguageSelector()
{
    global $xsrftoken;
    $languages = generateLanguageList();
    if (isset($_REQUEST['locale'])) {
        $locale = sanitize($_REQUEST['locale'], 0);
        if (getOption('locale') != $locale) {
            ?>
			<div class="errorbox">
				<h2>
					<?php 
            printf(gettext('<em>%s</em> is not available.'), $languages[$locale]);
            ?>
					<?php 
            printf(gettext('The locale %s is not supported on your server.'), $locale);
            ?>
					<br />
					<?php 
            echo gettext('See the <a href="http://www.zenphoto.org/news/troubleshooting-zenphoto#24">troubleshooting guide</a> on zenphoto.org for details.');
            ?>
				</h2>
			</div>
			<?php 
        }
    }
    ?>
	<ul class="sflags">
		<?php 
    $_languages = generateLanguageList();
    krsort($_languages, SORT_LOCALE_STRING);
    $currentValue = getOption('locale');
    foreach ($_languages as $text => $lang) {
        ?>
			<li<?php 
        if ($lang == $currentValue) {
            echo ' class="currentLanguage"';
        }
        ?>
>
				<?php 
        if ($lang != $currentValue) {
            ?>
					<a href="javascript:launchScript('',['locale=<?php 
            echo $lang;
            ?>
']);" >
					<?php 
        }
        if (file_exists(SERVERPATH . '/' . ZENFOLDER . '/locale/' . $lang . '/flag.png')) {
            $flag = WEBPATH . '/' . ZENFOLDER . '/locale/' . $lang . '/flag.png';
        } else {
            $flag = WEBPATH . '/' . ZENFOLDER . '/locale/missing_flag.png';
        }
        ?>
				<img src="<?php 
        echo $flag;
        ?>
" alt="<?php 
        echo $text;
        ?>
" title="<?php 
        echo $text;
        ?>
" />
				<?php 
        if ($lang != $currentValue) {
            ?>
					</a>
					<?php 
        }
        ?>
			</li>
			<?php 
    }
    ?>
	</ul>
	<?php 
}
function setupLanguageSelector()
{
    $languages = generateLanguageList();
    if (isset($_REQUEST['locale'])) {
        $locale = sanitize($_REQUEST['locale']);
        if (getOption('locale') != $locale || getOption('unsupported_' . $locale)) {
            ?>
			<div class="errorbox">
				<h2>
					<?php 
            printf(gettext('<em>%s</em> is not available.'), html_encode($languages[$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 
        }
    }
    ?>
	<ul class="sflags">
		<?php 
    $_languages = generateLanguageList();
    krsort($_languages, SORT_LOCALE_STRING);
    $currentValue = getOption('locale');
    foreach ($_languages as $text => $lang) {
        if (i18nSetLocale($lang)) {
            ?>
				<li<?php 
            if ($lang == $currentValue) {
                echo ' class="currentLanguage"';
            }
            ?>
>
					<?php 
            if ($lang != $currentValue) {
                ?>
						<a href="javascript:launchScript('',['locale=<?php 
                echo $lang;
                ?>
']);" >
							<?php 
            }
            if (file_exists(SERVERPATH . '/' . ZENFOLDER . '/locale/' . $lang . '/flag.png')) {
                $flag = WEBPATH . '/' . ZENFOLDER . '/locale/' . $lang . '/flag.png';
            } else {
                $flag = WEBPATH . '/' . ZENFOLDER . '/locale/missing_flag.png';
            }
            ?>
						<img src="<?php 
            echo $flag;
            ?>
" alt="<?php 
            echo $text;
            ?>
" title="<?php 
            echo $text;
            ?>
" />
						<?php 
            if ($lang != $currentValue) {
                ?>
						</a>
						<?php 
            }
            ?>
				</li>
				<?php 
        }
    }
    ?>
	</ul>
	<?php 
}
 /**
  *
  * Creates the news article
  * @param object $obj
  */
 protected static function publishArticle($obj, $override = NULL)
 {
     global $_zp_CMS;
     $galleryitem_text = array();
     $locale = getOption('locale');
     switch ($type = $obj->table) {
         case 'albums':
             $album = $obj->name;
             $dbstring = getOption('galleryArticles_album_text');
             $localtext = get_language_string($dbstring);
             $galleryitem_text[$locale] = sprintf($localtext, $obj->getTitle($locale));
             foreach (generateLanguageList() as $key) {
                 $languagetext = get_language_string($dbstring, $key);
                 if ($localtext != $languagetext) {
                     $galleryitem_text[$key] = sprintf($languagetext, $obj->getTitle($key));
                 }
             }
             $ref = '"' . $album . '"';
             $title = $folder = $album;
             $img = $obj->getAlbumThumbImage();
             $class = 'galleryarticles-newalbum';
             break;
         case 'images':
             $album = $obj->album->name;
             $image = $obj->filename;
             $dbstring = unserialize(getOption('galleryArticles_image_text'));
             $localtext = get_language_string($dbstring);
             $galleryitem_text[$locale] = sprintf($localtext, $obj->getTitle($locale), $obj->album->getTitle($locale));
             foreach (generateLanguageList() as $key => $val) {
                 $languagetext = get_language_string($dbstring, $key);
                 if ($localtext != $languagetext) {
                     $galleryitem_text[$key] = sprintf($localtext, $obj->getTitle($key), $obj->album->getTitle($key));
                 }
             }
             $ref = '"' . $album . '" "' . $image . '"';
             $folder = $obj->imagefolder;
             $title = $folder . '-' . $image;
             $img = $obj;
             $class = 'galleryarticles-newimage';
             break;
         default:
             //not a gallery object
             return;
     }
     $article = newArticle(seoFriendly('galleryArticles-' . $title));
     $article->setTitle(serialize($galleryitem_text));
     $imglink = $img->getCustomImage(getOption('galleryArticles_size'), NULL, NULL, NULL, NULL, NULL, NULL, -1);
     $desc = '<p><a class="' . $class . '" href="' . $obj->getLink() . '"><img src="' . $imglink . '"></a></p><p>[GALLERYARTICLEDESC ' . $ref . ']</p>';
     $article->setContent($desc);
     $date = $obj->getPublishDate();
     if (!$date) {
         $date = date('Y-m-d H:i:s');
     }
     $article->setDateTime($date);
     $article->setLastchange(date('Y-m-d H:i:s'));
     $article->setAuthor('galleryArticles');
     $article->setLastchangeauthor('galleryArticles');
     $article->setShow(true);
     $article->save();
     if ($override) {
         $cat = $override;
     } else {
         $cat = getOption('galleryArticles_category');
         if (getOption('galleryArticles_albumCategory')) {
             $catlist = $_zp_CMS->getAllCategories();
             foreach ($catlist as $category) {
                 if ($category['titlelink'] == $folder) {
                     $cat = $category['titlelink'];
                     break;
                 }
             }
         }
     }
     $article->setCategories(array($cat));
 }
/**
 * process the post of a language string form
 *
 * @param string $name the prefix for the label, id, and name tags
 * @return string
 */
function process_language_string_save($name, $sanitize_level = 3)
{
    global $_zp_active_languages;
    if (is_null($_zp_active_languages)) {
        $_zp_active_languages = generateLanguageList();
    }
    $l = strlen($name) + 1;
    $strings = array();
    foreach ($_POST as $key => $value) {
        if (!empty($value) && preg_match('/^' . $name . '_[a-z]{2}_[A-Z]{2}$/', $key)) {
            $key = substr($key, $l);
            if (in_array($key, $_zp_active_languages)) {
                $strings[$key] = sanitize($value, $sanitize_level);
            }
        }
    }
    switch (count($strings)) {
        case 0:
            if (isset($_POST[$name])) {
                return sanitize($_POST[$name], $sanitize_level);
            } else {
                return '';
            }
        case 1:
            return array_shift($strings);
        default:
            return serialize($strings);
    }
}
/**
 * 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'], 0);
        if (getOption('locale') != $locale) {
            ?>
			<div class="errorbox">
				<h2>
					<?php 
            printf(gettext('<em>%s</em> is not available.'), $languages[$locale]);
            ?>
					<?php 
            printf(gettext('The locale %s is not supported on your server.'), $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) {
        ?>
		<ul class="flags">
			<?php 
        $_languages = generateLanguageList();
        $currentValue = getOption('locale');
        foreach ($_languages as $text => $lang) {
            ?>
				<li<?php 
            if ($lang == $currentValue) {
                echo ' class="currentLanguage"';
            }
            ?>
>
					<?php 
            if ($lang != $currentValue) {
                ?>
						<a href="javascript:launchScript('',['locale=<?php 
                echo $lang;
                ?>
']);" >
						<?php 
            }
            if (file_exists(SERVERPATH . '/' . ZENFOLDER . '/locale/' . $lang . '/flag.png')) {
                $flag = WEBPATH . '/' . ZENFOLDER . '/locale/' . $lang . '/flag.png';
            } else {
                $flag = WEBPATH . '/' . ZENFOLDER . '/locale/missing_flag.png';
            }
            ?>
					<img src="<?php 
            echo $flag;
            ?>
" alt="<?php 
            echo $text;
            ?>
" title="<?php 
            echo $text;
            ?>
" />
					<?php 
            if ($lang != $currentValue) {
                ?>
						</a>
						<?php 
            }
            ?>
				</li>
				<?php 
        }
        unset($_languages);
        ?>
		</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 
        $locales = generateLanguageList();
        $currentValue = getOption('locale');
        foreach ($locales 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 
    }
}
/**
 * process the post of a language string form
 *
 * @param string $name the prefix for the label, id, and name tags
 * @param $sanitize_level the type of sanitization required
 * @return string
 */
function process_language_string_save($name, $sanitize_level = 3)
{
    $languages = generateLanguageList('all');
    $l = strlen($name) + 1;
    $strings = array();
    foreach ($_POST as $key => $value) {
        if (preg_match('/^' . $name . '_[a-z]{2}_[A-Z]{2}$/', $key)) {
            $key = substr($key, $l);
            if (in_array($key, $languages)) {
                $value = sanitize($value, $sanitize_level);
                if (!empty($value)) {
                    $strings[$key] = $value;
                }
            }
        }
    }
    switch (count($strings)) {
        case 0:
            if (isset($_POST[$name])) {
                return sanitize($_POST[$name], $sanitize_level);
            } else {
                return '';
            }
        default:
            return serialize($strings);
    }
}
Exemple #16
0
 /**
  *
  * creates an SEO language prefix list
  */
 static function LanguageSubdomains()
 {
     $domains = array();
     $langs = generateLanguageList();
     $domains = array();
     foreach ($langs as $value) {
         $domains[substr($value, 0, 2)][] = $value;
     }
     $langs = array();
     foreach ($domains as $simple => $full) {
         if (count($full) > 1) {
             foreach ($full as $loc) {
                 $langs[$loc] = $loc;
             }
         } else {
             $langs[$full[0]] = $simple;
         }
     }
     if (isset($langs[SITE_LOCALE])) {
         $langs[SITE_LOCALE] = '';
     }
     return $langs;
 }
 /**
  * Prints html meta data to be used in the <head> section of a page
  *
  */
 static function getHTMLMetaData()
 {
     global $_zp_gallery, $_zp_page, $_zp_current_album, $_zp_current_image, $_zp_current_search, $_zp_current_article, $_zp_current_page, $_zp_gallery_page, $_zp_current_category, $_zp_authority, $_zp_conf_vars, $_myFavorites;
     $host = sanitize("http://" . $_SERVER['HTTP_HOST']);
     $url = $host . getRequestURI();
     // Convert locale shorttag to allowed html meta format
     $locale_ = getUserLocale();
     $locale = zpFunctions::getLanguageText($locale_, '-');
     $canonicalurl = '';
     // generate page title, get date
     $pagetitle = "";
     // for gallery index setup below switch
     $date = strftime(DATE_FORMAT);
     // if we don't have a item date use current date
     $desc = getBareGalleryDesc();
     $thumb = '';
     if (getOption('htmlmeta_sitelogo')) {
         $thumb = getOption('htmlmeta_sitelogo');
     }
     if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
         $ogimage_width = getOption('htmlmeta_ogimage_width');
         $ogimage_height = getOption('htmlmeta_ogimage_height');
         if (empty($ogimage_width)) {
             $ogimage_width = 1280;
         }
         if (empty($ogimage_height)) {
             $ogimage_height = 900;
         }
         $twittercard_type = 'summary';
     }
     $type = 'article';
     switch ($_zp_gallery_page) {
         case 'index.php':
             $desc = getBareGalleryDesc();
             $canonicalurl = $host . $_zp_gallery->getLink($_zp_page);
             $type = 'website';
             break;
         case 'album.php':
         case 'favorites.php':
             $pagetitle = getBareAlbumTitle() . " - ";
             $date = getAlbumDate();
             $desc = getBareAlbumDesc();
             $canonicalurl = $host . $_zp_current_album->getLink($_zp_page);
             if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
                 $thumbimg = $_zp_current_album->getAlbumThumbImage();
                 getMaxSpaceContainer($ogimage_width, $ogimage_height, $thumbimg, false);
                 $thumb = $host . html_encode(pathurlencode($thumbimg->getCustomImage(NULL, $ogimage_width, $ogimage_height, NULL, NULL, NULL, NULL, false, NULL)));
                 $twittercard_type = 'summary_large_image';
             }
             break;
         case 'image.php':
             $pagetitle = getBareImageTitle() . " (" . getBareAlbumTitle() . ") - ";
             $date = getImageDate();
             $desc = getBareImageDesc();
             $canonicalurl = $host . $_zp_current_image->getLink();
             if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
                 $thumb = $host . html_encode(pathurlencode(getCustomSizedImageMaxSpace($ogimage_width, $ogimage_height)));
                 $twittercard_type = 'summary_large_image';
             }
             break;
         case 'news.php':
             if (function_exists("is_NewsArticle")) {
                 if (is_NewsArticle()) {
                     $pagetitle = getBareNewsTitle() . " - ";
                     $date = getNewsDate();
                     $desc = trim(getBare(getNewsContent()));
                     $canonicalurl = $host . $_zp_current_article->getLink();
                 } else {
                     if (is_NewsCategory()) {
                         $pagetitle = $_zp_current_category->getTitlelink() . " - ";
                         $date = strftime(DATE_FORMAT);
                         $desc = trim(getBare($_zp_current_category->getDesc()));
                         $canonicalurl = $host . $_zp_current_category->getLink($_zp_page);
                         $type = 'category';
                     } else {
                         $pagetitle = gettext('News') . " - ";
                         $desc = '';
                         $canonicalurl = $host . getNewsPathNav($_zp_page);
                         $type = 'website';
                     }
                 }
             }
             break;
         case 'pages.php':
             $pagetitle = getBarePageTitle() . " - ";
             $date = getPageDate();
             $desc = trim(getBare(getPageContent()));
             $canonicalurl = $host . $_zp_current_page->getLink();
             break;
         default:
             // for all other possible static custom pages
             $custompage = stripSuffix($_zp_gallery_page);
             $standard = array('contact' => gettext('Contact'), 'register' => gettext('Register'), 'search' => gettext('Search'), 'archive' => gettext('Archive view'), 'password' => gettext('Password required'));
             if (is_object($_myFavorites)) {
                 $standard['favorites'] = gettext('My favorites');
             }
             if (array_key_exists($custompage, $standard)) {
                 $pagetitle = $standard[$custompage] . " - ";
             } else {
                 $pagetitle = $custompage . " - ";
             }
             $desc = '';
             $canonicalurl = $host . getCustomPageURL($custompage);
             break;
     }
     // shorten desc to the allowed 200 characters if necesssary.
     $desc = html_encode(trim(substr(getBare($desc), 0, 160)));
     $pagetitle = $pagetitle . getBareGalleryTitle();
     // get master admin
     $admin = $_zp_authority->getMasterUser();
     $author = $admin->getName();
     $meta = '';
     if (getOption('htmlmeta_http-equiv-cache-control')) {
         $meta .= '<meta http-equiv="Cache-control" content="' . getOption("htmlmeta_cache_control") . '">' . "\n";
     }
     if (getOption('htmlmeta_http-equiv-pragma')) {
         $meta .= '<meta http-equiv="pragma" content="' . getOption("htmlmeta_pragma") . '">' . "\n";
     }
     if (getOption('htmlmeta_name-keywords')) {
         $meta .= '<meta name="keywords" content="' . htmlmetatags::getMetaKeywords() . '">' . "\n";
     }
     if (getOption('htmlmeta_name-description')) {
         $meta .= '<meta name="description" content="' . $desc . '">' . "\n";
     }
     if (getOption('htmlmeta_name-page-topic')) {
         $meta .= '<meta name="page-topic" content="' . $desc . '">' . "\n";
     }
     if (getOption('htmlmeta_name-robots')) {
         $meta .= '<meta name="robots" content="' . getOption("htmlmeta_robots") . '">' . "\n";
     }
     if (getOption('htmlmeta_name-publisher')) {
         $meta .= '<meta name="publisher" content="' . FULLWEBPATH . '">' . "\n";
     }
     if (getOption('htmlmeta_name-creator')) {
         $meta .= '<meta name="creator" content="' . FULLWEBPATH . '">' . "\n";
     }
     if (getOption('htmlmeta_name-author')) {
         $meta .= '<meta name="author" content="' . $author . '">' . "\n";
     }
     if (getOption('htmlmeta_name-copyright')) {
         $meta .= '<meta name="copyright" content=" (c) ' . FULLWEBPATH . ' - ' . $author . '">' . "\n";
     }
     if (getOption('htmlmeta_name-rights')) {
         $meta .= '<meta name="rights" content="' . $author . '">' . "\n";
     }
     if (getOption('htmlmeta_name-generator')) {
         $meta .= '<meta name="generator" content="ZenPhoto20 ' . ZENPHOTO_VERSION . '">' . "\n";
     }
     if (getOption('htmlmeta_name-revisit-after')) {
         $meta .= '<meta name="revisit-after" content="' . getOption("htmlmeta_revisit_after") . ' days">' . "\n";
     }
     if (getOption('htmlmeta_name-expires')) {
         $expires = getOption("htmlmeta_expires");
         if ($expires == (int) $expires) {
             $expires = preg_replace('|\\s\\-\\d+|', '', date('r', time() + $expires)) . ' GMT';
         }
         $meta .= '<meta name="expires" content="' . $expires . '">' . "\n";
     }
     // OpenGraph meta
     if (getOption('htmlmeta_opengraph')) {
         $meta .= '<meta property="og:title" content="' . $pagetitle . '">' . "\n";
         if (!empty($thumb)) {
             $meta .= '<meta property="og:image" content="' . $thumb . '">' . "\n";
         }
         $meta .= '<meta property="og:description" content="' . $desc . '">' . "\n";
         $meta .= '<meta property="og:url" content="' . html_encode($url) . '">' . "\n";
         $meta .= '<meta property="og:type" content="' . $type . '">' . "\n";
     }
     // Social network extras
     if (getOption('htmlmeta_name-pinterest')) {
         $meta .= '<meta name="pinterest" content="nopin">' . "\n";
     }
     // dissalow users to pin images on Pinterest
     // Twitter card
     $twittername = getOption('htmlmeta_twittername');
     if (getOption('htmlmeta_twittercard') || !empty($twittername)) {
         $meta .= '<meta name="twitter:creator" content="' . $twittername . '">' . "\n";
         $meta .= '<meta name="twitter:site" content="' . $twittername . '">' . "\n";
         $meta .= '<meta name="twitter:card" content="' . $twittercard_type . '">' . "\n";
         $meta .= '<meta name="twitter:title" content="' . $pagetitle . '">' . "\n";
         $meta .= '<meta name="twitter:description" content="' . $desc . '">' . "\n";
         if (!empty($thumb)) {
             $meta .= '<meta name="twitter:image" content="' . $thumb . '">' . "\n";
         }
     }
     // Canonical url
     if (getOption('htmlmeta_canonical-url')) {
         $meta .= '<link rel="canonical" href="' . $canonicalurl . '">' . "\n";
         if (METATAG_LOCALE_TYPE) {
             $langs = generateLanguageList();
             if (count($langs) != 1) {
                 if (METATAG_LOCALE_TYPE == 1) {
                     $locallink = seo_locale::localePath(false, $locale_);
                 } else {
                     $locallink = '';
                 }
                 foreach ($langs as $text => $lang) {
                     $langcheck = zpFunctions::getLanguageText($lang, '-');
                     //	for hreflang we need en-US
                     if ($langcheck != $locale) {
                         if (METATAG_LOCALE_TYPE == 1) {
                             $altlink = seo_locale::localePath(true, $lang);
                         } else {
                             $altlink = dynamic_locale::fullHostPath($lang);
                         }
                         switch ($_zp_gallery_page) {
                             case 'index.php':
                                 $altlink .= str_replace($locallink, '', $_zp_gallery->getLink($_zp_page));
                                 break;
                             case 'album.php':
                             case 'favorites.php':
                                 $altlink .= str_replace($locallink, '', $_zp_current_album->getLink($_zp_page));
                                 break;
                             case 'image.php':
                                 $altlink .= str_replace($locallink, '', $_zp_current_image->getLink());
                                 break;
                             case 'news.php':
                                 if (function_exists("is_NewsArticle")) {
                                     if (is_NewsArticle()) {
                                         $altlink .= str_replace($locallink, '', $_zp_current_article->getLink());
                                     } else {
                                         if (is_NewsCategory()) {
                                             $altlink .= str_replace($locallink, '', $_zp_current_category->getLink($_zp_page));
                                         } else {
                                             $altlink .= getNewsPathNav($_zp_page);
                                         }
                                     }
                                 }
                                 break;
                             case 'pages.php':
                                 $altlink .= str_replace($locallink, '', $_zp_current_page->getLink());
                                 break;
                             case 'archive.php':
                                 $altlink .= getCustomPageURL('archive');
                                 break;
                             case 'search.php':
                                 $searchwords = $_zp_current_search->codifySearchString();
                                 $searchdate = $_zp_current_search->getSearchDate();
                                 $searchfields = $_zp_current_search->getSearchFields(true);
                                 $searchpagepath = getSearchURL($searchwords, $searchdate, $searchfields, $_zp_page, array('albums' => $_zp_current_search->getAlbumList()));
                                 $altlink .= $searchpagepath;
                                 break;
                             case 'contact.php':
                                 $altlink .= getCustomPageURL('contact');
                                 break;
                             default:
                                 // for all other possible none standard custom pages
                                 $altlink .= getCustomPageURL($pagetitle);
                                 break;
                         }
                         // switch
                         $meta .= '<link rel="alternate" hreflang="' . $langcheck . '" href="' . html_encode($altlink) . '">' . "\n";
                     }
                     // if lang
                 }
                 // foreach
             }
             // if count
         }
         // if option
     }
     // if canonical
     echo $meta;
 }
Exemple #18
0
    /**
     * Prints html meta data to be used in the <head> section of a page
     *
     */
    static function getHTMLMetaData()
    {
        global $_zp_gallery, $_zp_galley_page, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_gallery_page, $_zp_current_category, $_zp_authority, $_zp_conf_vars, $_myFavorites, $htmlmetatags_need_cache, $_zp_page;
        zp_register_filter('image_processor_uri', 'htmlmetatags::ipURI');
        $host = sanitize("http://" . $_SERVER['HTTP_HOST']);
        $url = $host . getRequestURI();
        // Convert locale shorttag to allowed html meta format
        $locale = str_replace("_", "-", getUserLocale());
        $canonicalurl = '';
        // generate page title, get date
        $pagetitle = "";
        // for gallery index setup below switch
        $date = strftime(DATE_FORMAT);
        // if we don't have a item date use current date
        $desc = getBareGalleryDesc();
        $thumb = '';
        if (getOption('htmlmeta_sitelogo')) {
            $thumb = getOption('htmlmeta_sitelogo');
        }
        if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
            $ogimage_width = getOption('htmlmeta_ogimage_width');
            $ogimage_height = getOption('htmlmeta_ogimage_height');
            if (empty($ogimage_width)) {
                $ogimage_width = 1280;
            }
            if (empty($ogimage_height)) {
                $ogimage_height = 900;
            }
        }
        $type = 'article';
        switch ($_zp_gallery_page) {
            case 'index.php':
                $desc = getBareGalleryDesc();
                //$canonicalurl = $host . getGalleryIndexURL();
                $canonicalurl = $host . getPageNumURL($_zp_page);
                $type = 'website';
                break;
            case 'album.php':
                $pagetitle = getBareAlbumTitle() . " - ";
                $date = getAlbumDate();
                $desc = getBareAlbumDesc();
                $canonicalurl = $host . getPageNumURL($_zp_page);
                if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
                    $thumbimg = $_zp_current_album->getAlbumThumbImage();
                    getMaxSpaceContainer($ogimage_width, $ogimage_height, $thumbimg, false);
                    $thumb = $host . html_encode(pathurlencode($thumbimg->getCustomImage(NULL, $ogimage_width, $ogimage_height, NULL, NULL, NULL, NULL, false, NULL)));
                }
                break;
            case 'image.php':
                $pagetitle = getBareImageTitle() . " (" . getBareAlbumTitle() . ") - ";
                $date = getImageDate();
                $desc = getBareImageDesc();
                $canonicalurl = $host . getImageURL();
                if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
                    $thumb = $host . html_encode(pathurlencode(getCustomSizedImageMaxSpace($ogimage_width, $ogimage_height)));
                }
                break;
            case 'news.php':
                if (function_exists("is_NewsArticle")) {
                    if (is_NewsArticle()) {
                        $pagetitle = getBareNewsTitle() . " - ";
                        $date = getNewsDate();
                        $desc = trim(getBare(getNewsContent()));
                        $canonicalurl = $host . $_zp_current_zenpage_news->getLink();
                    } else {
                        if (is_NewsCategory()) {
                            $pagetitle = $_zp_current_category->getTitlelink() . " - ";
                            $date = strftime(DATE_FORMAT);
                            $desc = trim(getBare($_zp_current_category->getDesc()));
                            $canonicalurl = $host . $_zp_current_category->getLink();
                            $type = 'category';
                        } else {
                            $pagetitle = gettext('News') . " - ";
                            $desc = '';
                            $canonicalurl = $host . getNewsIndexURL();
                            $type = 'website';
                        }
                    }
                    if ($_zp_page != 1) {
                        $canonicalurl .= '/' . $_zp_page;
                    }
                }
                break;
            case 'pages.php':
                $pagetitle = getBarePageTitle() . " - ";
                $date = getPageDate();
                $desc = trim(getBare(getPageContent()));
                $canonicalurl = $host . $_zp_current_zenpage_page->getLink();
                break;
            default:
                // for all other possible static custom pages
                $custompage = stripSuffix($_zp_gallery_page);
                $standard = array('contact' => gettext('Contact'), 'register' => gettext('Register'), 'search' => gettext('Search'), 'archive' => gettext('Archive view'), 'password' => gettext('Password required'));
                if (is_object($_myFavorites)) {
                    $standard['favorites'] = gettext('My favorites');
                }
                if (array_key_exists($custompage, $standard)) {
                    $pagetitle = $standard[$custompage] . " - ";
                } else {
                    $pagetitle = $custompage . " - ";
                }
                $desc = '';
                $canonicalurl = $host . getCustomPageURL($custompage);
                if ($_zp_page != 1) {
                    $canonicalurl .= '/' . $_zp_page;
                }
                break;
        }
        // shorten desc to the allowed 200 characters if necesssary.
        $desc = html_encode(trim(substr(getBare($desc), 0, 160)));
        $pagetitle = $pagetitle . getBareGalleryTitle();
        // get master admin
        $admin = $_zp_authority->getMasterUser();
        $author = $admin->getName();
        $meta = '';
        if (getOption('htmlmeta_http-equiv-cache-control')) {
            $meta .= '<meta http-equiv="Cache-control" content="' . getOption("htmlmeta_cache_control") . '">' . "\n";
        }
        if (getOption('htmlmeta_http-equiv-pragma')) {
            $meta .= '<meta http-equiv="pragma" content="' . getOption("htmlmeta_pragma") . '">' . "\n";
        }
        if (getOption('htmlmeta_name-keywords')) {
            $meta .= '<meta name="keywords" content="' . htmlmetatags::getMetaKeywords() . '">' . "\n";
        }
        if (getOption('htmlmeta_name-description')) {
            $meta .= '<meta name="description" content="' . $desc . '">' . "\n";
        }
        if (getOption('htmlmeta_name-page-topic')) {
            $meta .= '<meta name="page-topic" content="' . $desc . '">' . "\n";
        }
        if (getOption('htmlmeta_name-robots')) {
            $meta .= '<meta name="robots" content="' . getOption("htmlmeta_robots") . '">' . "\n";
        }
        if (getOption('htmlmeta_name-publisher')) {
            $meta .= '<meta name="publisher" content="' . FULLWEBPATH . '">' . "\n";
        }
        if (getOption('htmlmeta_name-creator')) {
            $meta .= '<meta name="creator" content="' . FULLWEBPATH . '">' . "\n";
        }
        if (getOption('htmlmeta_name-author')) {
            $meta .= '<meta name="author" content="' . $author . '">' . "\n";
        }
        if (getOption('htmlmeta_name-copyright')) {
            $meta .= '<meta name="copyright" content=" (c) ' . FULLWEBPATH . ' - ' . $author . '">' . "\n";
        }
        if (getOption('htmlmeta_name-rights')) {
            $meta .= '<meta name="rights" content="' . $author . '">' . "\n";
        }
        if (getOption('htmlmeta_name-generator')) {
            $meta .= '<meta name="generator" content="Zenphoto ' . ZENPHOTO_VERSION . '">' . "\n";
        }
        if (getOption('htmlmeta_name-revisit-after')) {
            $meta .= '<meta name="revisit-after" content="' . getOption("htmlmeta_revisit_after") . '">' . "\n";
        }
        if (getOption('htmlmeta_name-expires')) {
            $expires = getOption("htmlmeta_expires");
            if ($expires == (int) $expires) {
                $expires = preg_replace('|\\s\\-\\d+|', '', date('r', time() + $expires)) . ' GMT';
            }
            $meta .= '<meta name="expires" content="' . $expires . '">' . "\n";
        }
        // OpenGraph meta
        if (getOption('htmlmeta_og-title')) {
            $meta .= '<meta property="og:title" content="' . $pagetitle . '">' . "\n";
        }
        if (getOption('htmlmeta_og-image') && !empty($thumb)) {
            $meta .= '<meta property="og:image" content="' . $thumb . '">' . "\n";
        }
        if (getOption('htmlmeta_og-description')) {
            $meta .= '<meta property="og:description" content="' . $desc . '">' . "\n";
        }
        if (getOption('htmlmeta_og-url')) {
            $meta .= '<meta property="og:url" content="' . html_encode($url) . '">' . "\n";
        }
        if (getOption('htmlmeta_og-type')) {
            $meta .= '<meta property="og:type" content="' . $type . '">' . "\n";
        }
        // Social network extras
        if (getOption('htmlmeta_name-pinterest')) {
            $meta .= '<meta name="pinterest" content="nopin">' . "\n";
        }
        // dissalow users to pin images on Pinterest
        // Twitter card
        $twittername = getOption('htmlmeta_twittername');
        if (getOption('htmlmeta_twittercard') || !empty($twittername)) {
            $meta .= '<meta property="twitter:creator" content="' . $twittername . '">' . "\n";
            $meta .= '<meta property="twitter:site" content="' . $twittername . '">' . "\n";
            $meta .= '<meta property="twitter:card" content="summary">' . "\n";
            $meta .= '<meta property="twitter:title" content="' . $pagetitle . '">' . "\n";
            $meta .= '<meta property="twitter:description" content="' . $desc . '">' . "\n";
            if (!empty($thumb)) {
                $meta .= '<meta property="twitter:image" content="' . $thumb . '">' . "\n";
            }
        }
        // Canonical url
        if (getOption('htmlmeta_canonical-url')) {
            $meta .= '<link rel="canonical" href="' . $canonicalurl . '">' . "\n";
            if (METATAG_LOCALE_TYPE) {
                $langs = generateLanguageList();
                if (count($langs) != 1) {
                    foreach ($langs as $text => $lang) {
                        $langcheck = zpFunctions::getLanguageText($lang, '-');
                        //	for hreflang we need en-US
                        if ($langcheck != $locale) {
                            switch (METATAG_LOCALE_TYPE) {
                                case 1:
                                    $altlink = seo_locale::localePath(true, $lang);
                                    break;
                                case 2:
                                    $altlink = dynamic_locale::fullHostPath($lang);
                                    break;
                            }
                            switch ($_zp_gallery_page) {
                                case 'index.php':
                                    $altlink .= '/';
                                    break;
                                case 'gallery.php':
                                    $altlink .= '/' . _PAGE_ . '/gallery';
                                    break;
                                case 'album.php':
                                    $altlink .= '/' . html_encode($_zp_current_album->name) . '/';
                                    break;
                                case 'image.php':
                                    $altlink .= '/' . html_encode($_zp_current_album->name) . '/' . html_encode($_zp_current_image->filename) . IM_SUFFIX;
                                    break;
                                case 'news.php':
                                    if (function_exists("is_NewsArticle")) {
                                        if (is_NewsArticle()) {
                                            $altlink .= '/' . _NEWS_ . '/' . html_encode($_zp_current_zenpage_news->getTitlelink());
                                        } else {
                                            if (is_NewsCategory()) {
                                                $altlink .= '/' . _NEWS_ . '/' . html_encode($_zp_current_category->getTitlelink());
                                            } else {
                                                $altlink .= '/' . _NEWS_;
                                            }
                                        }
                                    }
                                    break;
                                case 'pages.php':
                                    $altlink .= '/' . _PAGES_ . '/' . html_encode($_zp_current_zenpage_page->getTitlelink());
                                    break;
                                case 'archive.php':
                                    $altlink .= '/' . _ARCHIVE_;
                                    break;
                                case 'search.php':
                                    $altlink .= '/' . _SEARCH_ . '/';
                                    break;
                                case 'contact.php':
                                    $altlink .= '/' . _CONTACT_ . '/';
                                    break;
                                default:
                                    // for all other possible none standard custom pages
                                    $altlink .= '/' . _PAGE_ . '/' . html_encode($pagetitle);
                                    break;
                            }
                            // switch
                            //append page number if needed
                            switch ($_zp_gallery_page) {
                                case 'index.php':
                                case 'album.php':
                                    if ($_zp_page != 1) {
                                        $altlink .= _PAGE_ . '/' . $_zp_page . '/';
                                    }
                                    break;
                                case 'gallery.php':
                                case 'news.php':
                                    if ($_zp_page != 1) {
                                        $altlink .= '/' . $_zp_page;
                                    }
                                    break;
                            }
                            $meta .= '<link rel="alternate" hreflang="' . $langcheck . '" href="' . $altlink . '">' . "\n";
                        }
                        // if lang
                    }
                    // foreach
                }
                // if count
            }
            // if option
        }
        // if canonical
        if (!empty($htmlmetatags_need_cache)) {
            $meta .= '<script type="text/javascript">' . "\n";
            $meta .= 'var caches = ["' . implode('","', $htmlmetatags_need_cache) . '"];' . "\n";
            $meta .= '
					window.onload = function() {
						var index,value;
						for (index in caches) {
								value = caches[index];
								$.ajax({
									cache: false,
									type: "GET",
									url: value
								});
						}
					}
					';
            $meta .= '</script>' . "\n";
        }
        zp_remove_filter('image_processor_uri', 'htmlmetatags::ipURI');
        echo $meta;
    }
Exemple #19
0
            return $line;
        }
    }
    return NULL;
}
if (defined('OFFSET_PATH')) {
    zp_register_filter('admin_utilities_buttons', 'findQuotes_button');
} else {
    define('OFFSET_PATH', 3);
    require_once dirname(dirname($_SERVER['SCRIPT_NAME'])) . '/zp-core/functions.php';
    require_once SERVERPATH . '/' . ZENFOLDER . '/admin-globals.php';
    zp_register_filter('admin_tabs', 'findQuotes_admin_tab');
    setOptionDefault('findingQuotes_target', 'de_DE');
    printAdminHeader('overview', 'findQuotes');
    echo '</head>';
    $list = generateLanguageList('all');
    $lang = NULL;
    if (isset($_POST['language'])) {
        $selected = $lang = sanitize($_POST['language']);
        setOption('findingQuotes_target', $lang);
    } else {
        $selected = getOption('findingQuotes_target');
    }
    ?>
	<body>
		<?php 
    printLogoAndLinks();
    ?>
		<div id="main">
			<?php 
    printTabs();
setOptionDefault('search_image_sort_type', 'title');
setOptionDefault('search_album_sort_direction', '');
setOptionDefault('search_image_sort_direction', '');
purgeOption('zp_plugin_releaseUpdater');
query('UPDATE ' . prefix('administrators') . ' SET `passhash`=' . (int) getOption('strong_hash') . ' WHERE `valid`>=1 AND `passhash` IS NULL');
query('UPDATE ' . prefix('administrators') . ' SET `passupdate`=' . db_quote(date('Y-m-d H:i:s')) . ' WHERE `valid`>=1 AND `passupdate` IS NULL');
setOptionDefault('image_processor_flooding_protection', 1);
setOptionDefault('codeblock_first_tab', 1);
setOptionDefault('GD_FreeType_Path', SERVERPATH . '/' . USER_PLUGIN_FOLDER . '/gd_fonts');
$vers = explode('-', ZENPHOTO_VERSION);
$vers = explode('.', $vers[0]);
while (count($vers) < 3) {
    $vers[] = 0;
}
$zpversion = $vers[0] . '.' . $vers[1] . '.' . $vers[2];
$_languages = generateLanguageList('all');
foreach ($_languages as $language => $dirname) {
    if (!empty($dirname) && $dirname != 'en_US') {
        $version = '';
        $po = file_get_contents(SERVERPATH . "/" . ZENFOLDER . "/locale/" . $dirname . '/LC_MESSAGES/zenphoto.po');
        $i = strpos($po, 'Project-Id-Version:');
        if ($i !== false) {
            $j = strpos($po, '\\n', $i);
            if ($j !== false) {
                $pversion = strtolower(substr($po, $i + 19, $j - $i - 19));
                $vers = explode('.', trim(str_replace('zenphoto', '', $pversion)));
                while (count($vers) < 3) {
                    $vers[] = 0;
                }
                $version = (int) $vers[0] . '.' . (int) $vers[1] . '.' . (int) $vers[2];
            }
/**
 * Returns a saved (or posted) locale. Posted locales are stored as a cookie.
 *
 * Sets the 'locale' option to the result (non-persistent)
 */
function getUserLocale()
{
    if (DEBUG_LOCALE) {
        debugLogBackTrace("getUserLocale()");
    }
    $cookiepath = WEBPATH;
    if (WEBPATH == '') {
        $cookiepath = '/';
    }
    if (isset($_POST['dynamic-locale'])) {
        $locale = sanitize($_POST['dynamic-locale'], 0);
        zp_setCookie('dynamic_locale', $locale, time() + COOKIE_PESISTENCE, $cookiepath);
        if (DEBUG_LOCALE) {
            debugLog("dynamic_locale post: {$locale}");
        }
    } else {
        $localeOption = getOption('locale');
        $locale = zp_getCookie('dynamic_locale');
        if (DEBUG_LOCALE) {
            debugLog("locale from option: " . $localeOption . '; dynamic locale=' . $locale);
        }
        if (empty($localeOption) && $locale === false) {
            // if one is not set, see if there is a match from 'HTTP_ACCEPT_LANGUAGE'
            $languageSupport = generateLanguageList();
            $userLang = parseHttpAcceptLanguage();
            foreach ($userLang as $lang) {
                $l = strtoupper($lang['fullcode']);
                foreach ($languageSupport as $key => $value) {
                    if (strtoupper($value) == $l) {
                        // we got a match
                        $locale = $value;
                        if (DEBUG_LOCALE) {
                            debugLog("locale set from HTTP Accept Language: " . $locale);
                        }
                        break;
                    } else {
                        if (preg_match('/^' . $l . '/', strtoupper($value))) {
                            // we got a partial match
                            $locale = $value;
                            if (DEBUG_LOCALE) {
                                debugLog("locale set from HTTP Accept Language (partial match): " . $locale);
                            }
                            break;
                        }
                    }
                }
                if ($locale) {
                    break;
                }
            }
        }
    }
    if ($locale !== false) {
        setOption('locale', $locale, false);
    }
    if (DEBUG_LOCALE) {
        debugLog("Returning locale: " . $locale);
    }
    return $locale;
}