コード例 #1
0
ファイル: main.php プロジェクト: CeosSoftworks/BlogHenkel
function mainPage()
{
    $langs = \CEOS\WPi10n\Language::all();
    ?>

<div class="ceos-wp-i10n">
	<?php 
    include 'header.php';
    ?>
	
	<section id="main-page" class="page-content">
		<div id="main-left">
			<h3 class="title"><?php 
    echo __('Languages', $domain);
    ?>
</h3>
			<p class="desc"><?php 
    echo __('Select one of the languages below to edit its entries. You can start supporting a new language by clicking the "Add new language" button.', $domain);
    ?>
</p>
			
			<ul id="langs-list">
			<?php 
    if (is_array($langs) && sizeof($langs) > 0) {
        ?>
				<?php 
        foreach ($langs as $lang) {
            ?>
					<li class="lang">
						<a href="" class="lang-link">
							<span class="lang-title"><?php 
            echo __($lang->englishName, $domain);
            ?>
</span>
							<span class="lang-code">(<?php 
            echo $lang->code;
            ?>
)</span>
							<span class="lang-status"><?php 
            echo __($lang->status, $domain);
            ?>
</span>
						</a>
					</li>
				<?php 
        }
        ?>
			<?php 
    } else {
        ?>
				<li class="empty">
					<div class="inner"><?php 
        echo __('No languages available.<br /><small>Click the button below to add a new language.</small>', $domain);
        ?>
</div>
				</li>
			<?php 
    }
    ?>
			</ul>

			<a id="add-lang-link" class="button button-primary"><?php 
    echo __('Add new language', $domain);
    ?>
</a>
		</div>

		<form id="main-right" action="" method="GET">
			<h3 class="title"><?php 
    echo __('Settings', $domain);
    ?>
</h3>

			<div class="content table" id="settings">
				<div class="row">
					<div class="cell desc">
						<label for="def-lang"><?php 
    echo __('Default website language', $domain);
    ?>
</label>
					</div>
					<div class="cell setting">
						<select class="ceos-select" id="def-lang" name="def-lang">
							<?php 
    if (is_array($langs) && sizeof($langs) > 0) {
        ?>
								<?php 
        foreach ($langs as $lang) {
            ?>
									<option value="<?php 
            echo $lang->code;
            ?>
"><?php 
            echo __($lang->englishName, $domain);
            ?>
</option>
								<?php 
        }
        ?>
							<?php 
    }
    ?>
						</select>
					</div>
				</div>
			</div>
			
			<input type="submit" class="save-link button button-primary" value="<?php 
    echo __('Save settings', $domain);
    ?>
">
		</form>
	</section>
	
	<?php 
    include 'footer.php';
    ?>
</div>

<?php 
}
コード例 #2
0
<?php

require 'service-header.php';
require_once PLUGIN_PATH . '/classes/lang.php';
$requiredFields = array('englishName', 'localName', 'code');
verifyRequiredFields($requiredFields, $_POST);
$lang = new \CEOS\WPi10n\Language();
$lang->englishName = $_POST['englishName'];
$lang->localName = $_POST['localName'];
$lang->code = $_POST['code'];
if (!\CEOS\WPi10n\Language::exists($lang->code, $lang->englishName, $lang->localName)) {
    if (!$lang->push()) {
        header('HTTP/1.1 430 Failure');
        $headers['service-status'] = 'error';
        $headers['service-details'] = 'Error pushing language to the database';
    }
} else {
    header('HTTP/1.1 430 Failure');
    $headers['service-status'] = 'error';
    $headers['service-details'] = 'Language already registered';
}
require 'service-footer.php';