get() статический публичный Метод

Gets a language value by key
static public get ( mixed $key = null, mixed $default = null ) : mixed
$key mixed The key to look for. Pass false or null to return the entire language array.
$default mixed Optional default value, which should be returned if no element has been found
Результат mixed
Пример #1
0
 public function __construct()
 {
     $this->type = 'text';
     $this->icon = 'user';
     $this->label = l::get('fields.user.label', 'User');
     $this->placeholder = l::get('fields.user.placeholder', 'Username…');
 }
Пример #2
0
 /**
  * @param array $event The fields of this event including the 'private'
  * fields which start with a <code>_</code> (e.g. <code>_begin_date</code>).
  */
 function __construct($event)
 {
     self::validate($event);
     $this->hasEnd = true;
     $this->hasBeginTime = (bool) a::get($event, self::beginTimeKey);
     $this->hasEndTime = (bool) a::get($event, self::endTimeKey);
     $this->beginTimestamp = self::getTimestamp(a::get($event, self::beginDateKey), a::get($event, self::beginTimeKey));
     $this->endTimestamp = self::getTimestamp(a::get($event, self::endDateKey), a::get($event, self::endTimeKey));
     // if there is no end date given, use the same as the beginning date
     if (!$this->endTimestamp) {
         $this->endTimestamp = self::getTimestamp(a::get($event, self::beginDateKey), a::get($event, self::endTimeKey));
         // if there also is no end time given, there is no end at all
         if (!$this->hasEndTime) {
             $this->hasEnd = false;
         }
     }
     // if there is no end time given, the event lasts until end of the day
     if (!$this->hasEndTime) {
         $this->endTimestamp = strtotime('tomorrow', $this->endTimestamp);
     }
     // only use the full format, if there were times given for this event
     $this->timeFormat = $this->hasBeginTime || $this->hasEndTime ? l::get('calendar-full-time-format') : l::get('calendar-time-format');
     // remove the 'private' fields
     $this->fields = self::filterFields($event);
 }
Пример #3
0
 public function __construct()
 {
     $this->type = 'text';
     $this->icon = 'chain';
     $this->label = l::get('fields.page.label', 'Page');
     $this->placeholder = l::get('fields.page.placeholder', 'path/to/page');
 }
Пример #4
0
 public function index()
 {
     if (app::$site->users()->count() > 0) {
         go('panel/login');
     }
     if ($problems = installation::check()) {
         $content = view('installation/check', array('problems' => $problems));
     } else {
         $form = app::form('installation', array('language' => c::get('panel.language', 'en')));
         $form->cancel = false;
         $form->save = l::get('installation.signup.button');
         $form->centered = true;
         foreach (app::languages() as $lang) {
             $form->fields()->get('language')->options[$lang->code()] = $lang->title();
         }
         $form->on('submit', function ($form) {
             try {
                 app::$site->users()->create($form->serialize());
                 go('panel/login/welcome');
             } catch (Exception $e) {
                 $form->alert($e->getMessage());
             }
         });
         $content = view('installation/signup', array('form' => $form));
     }
     return layout('installation', array('meta' => new Snippet('meta'), 'content' => $content));
 }
Пример #5
0
 public static function login($redirect = '/')
 {
     if (self::user()) {
         go(url($redirect));
     }
     self::kill();
     $password = get('password');
     $username = get('username');
     if (empty($username) || empty($password)) {
         return false;
     }
     // try to find the user
     $account = self::load($username);
     if (!$account) {
         return array('status' => 'error', 'msg' => l::get('auth.error', 'Invalid username or password'));
     }
     // check for matching usernames
     if (str::lower($account->username()) != str::lower($username)) {
         return array('status' => 'error', 'msg' => l::get('auth.error', 'Invalid username or password'));
     }
     // check for a matching password
     if (!self::checkPassword($account, $password)) {
         return array('status' => 'error', 'msg' => l::get('auth.error', 'Invalid username or password'));
     }
     // generate a random token
     $token = str::random();
     // add the username.
     $account->token = $token;
     // store the token in the cookie
     // and the user data in the session
     cookie::set('authFrontend', $token, 60 * 60 * 24);
     s::set('authFrontend.' . $token, $account->username());
     go(url($redirect));
 }
Пример #6
0
 public function __construct()
 {
     $this->type = 'url';
     $this->icon = 'chain';
     $this->label = l::get('fields.url.label', 'URL');
     $this->placeholder = 'http://';
 }
Пример #7
0
 function login()
 {
     s::restart();
     $password = get('password');
     $username = get('username');
     if (empty($username) || empty($password)) {
         return array('status' => 'error', 'msg' => l::get('login.error'));
     }
     $account = self::load($username);
     if (!$account) {
         return array('status' => 'error', 'msg' => l::get('login.error'));
     }
     // check for matching usernames
     if (str::lower($account['username']) != str::lower($username)) {
         return array('status' => 'error', 'msg' => l::get('login.error'));
     }
     // check for a matching password
     if (!self::checkPassword($account, $password)) {
         return array('status' => 'error', 'msg' => l::get('login.error'));
     }
     // generate a random token
     $token = str::random();
     // add the username.
     // It's only the key of the array so far.
     $account['token'] = $token;
     // store the token in the cookie
     // and the user data in the session
     cookie::set('auth', $token, 60 * 60 * 24);
     s::set($token, $account);
     // assign the user data to this obj
     $this->_ = $account;
     return array('status' => 'success', 'msg' => l::get('login.success'));
 }
Пример #8
0
 public function __construct()
 {
     $this->type = 'text';
     $this->label = l::get('fields.title.label', 'Title');
     $this->icon = 'font';
     $this->required = true;
 }
Пример #9
0
 public function __construct()
 {
     $this->label = l::get('fields.textarea.label', 'Text');
     $this->buttons = true;
     $this->min = 0;
     $this->max = false;
 }
Пример #10
0
 public function __construct()
 {
     $this->type = 'text';
     $this->icon = 'map-marker';
     $this->label = l::get('fields.location.label', 'Location');
     $this->placeholder = l::get('fields.location.placeholder', 'Coordinates');
     $this->readonly = true;
 }
Пример #11
0
 public function __construct()
 {
     $this->icon = 'tag';
     $this->label = l::get('fields.tags.label', 'Tags');
     $this->index = 'siblings';
     $this->separator = ',';
     $this->lower = false;
 }
Пример #12
0
 public function __construct()
 {
     $this->type = 'email';
     $this->icon = 'envelope';
     $this->label = l::get('fields.email.label', 'Email');
     $this->placeholder = l::get('fields.email.placeholder', '*****@*****.**');
     $this->autocomplete = true;
 }
Пример #13
0
 public function __construct()
 {
     $this->type = 'number';
     $this->label = l::get('fields.number.label', 'Number');
     $this->placeholder = l::get('fields.number.placeholder', '#');
     $this->step = 1;
     $this->min = 0;
     $this->max = false;
 }
Пример #14
0
 public function testSet()
 {
     l::set('anothervar', 'anothervalue');
     l::set('testvar', 'overwrittenvalue');
     $this->assertEquals('anothervalue', l::get('anothervar'));
     $this->assertEquals('overwrittenvalue', l::get('testvar'));
     l::set(array('var1' => 'value1', 'var2' => 'value2'));
     $this->assertEquals('value1', l::get('var1'));
     $this->assertEquals('value2', l::get('var2'));
 }
Пример #15
0
 public function __construct()
 {
     $this->type = 'text';
     $this->icon = 'user';
     $this->label = l::get('fields.user.label', 'User');
     $this->options = array();
     foreach (kirby()->site()->users() as $user) {
         $this->options[$user->username()] = $user->username();
     }
 }
Пример #16
0
 public function input()
 {
     $input = parent::input();
     $input->removeAttr('name');
     $input->data(array('field' => 'date', 'format' => $this->format(), 'i18n' => html(json_encode(array('previousMonth' => '&lsaquo;', 'nextMonth' => '&rsaquo;', 'months' => l::get('fields.date.months'), 'weekdays' => l::get('fields.date.weekdays'), 'weekdaysShort' => l::get('fields.date.weekdays.short'))), false)));
     $hidden = new Brick('input', null);
     $hidden->type = 'hidden';
     $hidden->name = $this->name();
     $hidden->value = $this->value();
     return $input . $hidden;
 }
Пример #17
0
 public function label()
 {
     if (!$this->label) {
         return null;
     }
     $label = new Brick('label', $this->i18n($this->label));
     $label->addClass('label');
     $label->attr('for', $this->id());
     if ($this->required()) {
         $label->append(new Brick('abbr', '*', array('title' => l::get('required', 'Required'))));
     }
     return $label;
 }
Пример #18
0
 public function options()
 {
     switch (strtolower($this->text())) {
         case 'yes/no':
             $true = l::get('fields.toggle.yes');
             $false = l::get('fields.toggle.no');
             break;
         case 'on/off':
             $true = l::get('fields.toggle.on');
             $false = l::get('fields.toggle.off');
             break;
     }
     return array('true' => $true, 'false' => $false);
 }
Пример #19
0
 function file($field, $destination, $params = array())
 {
     $allowed = a::get($params, 'allowed', c::get('upload.allowed', array('image/jpeg', 'image/png', 'image/gif')));
     $maxsize = a::get($params, 'maxsize', c::get('upload.maxsize', self::max_size()));
     $overwrite = a::get($params, 'overwrite', c::get('upload.overwrite', true));
     $sanitize = a::get($params, 'sanitize', true);
     $file = a::get($_FILES, $field);
     if (empty($file)) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.missing-file', 'The file has not been found'));
     }
     $name = a::get($file, 'name');
     $type = a::get($file, 'type');
     $tmp_name = a::get($file, 'tmp_name');
     $error = a::get($file, 'error');
     $size = a::get($file, 'size');
     $msg = false;
     $extension = self::mime_to_extension($type, 'jpg');
     // convert the filename to a save name
     $fname = $sanitize ? f::safe_name(f::name($name)) : f::name($name);
     // setup the destination
     $destination = str_replace('{name}', $fname, $destination);
     $destination = str_replace('{extension}', $extension, $destination);
     if (file_exists($destination) && $overwrite == false) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.file-exists', 'The file exists and cannot be overwritten'));
     }
     if (empty($tmp_name)) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.missing-file', 'The file has not been found'));
     }
     if ($error != 0) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.invalid-upload', 'The upload failed'));
     }
     if ($size > $maxsize) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.too-big', 'The file is too big'));
     }
     if (!in_array($type, $allowed)) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.invalid-file', 'The file type is not allowed') . ': ' . $type);
     }
     // try to change the permissions for the destination
     @chmod(dirname($destination), 0777);
     if (!@copy($tmp_name, $destination)) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.move-error', 'The file could not be moved to the server'));
     }
     // try to change the permissions for the final file
     @chmod($destination, 0777);
     return array('status' => 'success', 'msg' => l::get('upload.success', 'The file has been uploaded'), 'type' => $type, 'extension' => $extension, 'file' => $destination, 'size' => $size, 'name' => f::filename($destination));
 }
Пример #20
0
function i18n($value)
{
    if (empty($value)) {
        return null;
    } else {
        if (is_array($value)) {
            $translation = a::get($value, panel()->translation()->code());
            if (empty($translation)) {
                // try to fallback to the default language at least
                $translation = a::get($value, kirby()->option('panel.language'));
            }
            return $translation;
        } else {
            if (is_string($value) and $translation = l::get($value)) {
                return $translation;
            } else {
                return $value;
            }
        }
    }
}
Пример #21
0
<?php

// detect handler from 1) query parameter ("?handler="), or fallback to 2) http referer
$handler_name = get('handler') ?: a::last(array_filter(explode('/', server::get('http_referer'))));
$handler_path = c::get('root.content') . '/smart-submit/' . $handler_name . '.php';
// check honeypot
if (get('smart-submit-honeypot') && intval(get('smart-submit-honeypot')) < 2) {
    die('{"error":"' . (l::get('smart-submit-alarm') ?: 'Anti-spam alarm. Please try again.') . '"}');
}
if (file_exists($handler_path)) {
    require $handler_path;
} else {
    die('{"error":"' . (l::get('smart-submit-missing-handler') ?: 'Error - handler not found. Please contact web site administrator for details.') . '"}');
}
Пример #22
0
    if (page('shop')->paypal_action() != 'live') {
        ?>
                        <div class="message  message--warning">
                            <?php 
        echo l::get('sandbox-message');
        ?>
                        </div>
                    <?php 
    }
    ?>

                    <input type="hidden" name="gateway" value="paypal">

                    <div class="forRobots hide">
                      <label for="subject"><?php 
    echo l::get('honeypot-label');
    ?>
</label>
                      <input type="text" name="subject">
                    </div>

                    <button class="btn  btn--accent" type="submit">Pay with PayPal</button>
                </form>

            </div><!-- /. cart summary -->
        <?php 
}
?>

        <script type="text/javascript">
            // Remove setCountry and setShipping submit buttons
Пример #23
0
 /**
  * Bundles the form data to an e-mail body and sends it.
  */
 private function sendForm()
 {
     $mailBody = "";
     $snippet = $this->options['snippet'];
     if (empty($snippet)) {
         foreach ($this->data as $key => $value) {
             if (str::startsWith($key, '_')) {
                 continue;
             }
             $mailBody .= ucfirst($key) . ': ' . $value . "\n\n";
         }
     } else {
         $mailBody = snippet($snippet, array('data' => $this->data), true);
         if ($mailBody === false) {
             throw new Exception("The email snippet '" . $snippet . "' does not exist!");
         }
     }
     $params = array('service' => $this->options['service'], 'options' => $this->options['service-options'], 'to' => $this->options['to'], 'from' => a::get($this->data, 'name', '') . ' <' . a::get($this->data, '_from') . '>', 'subject' => $this->options['subject'], 'body' => $mailBody);
     $email = email($params);
     if ($email->send()) {
         $params['subject'] = l::get('sendform-email-copy') . ' ' . $params['subject'];
         // if everything was ok, send the copies
         foreach ($this->options['copy'] as $address) {
             $params['to'] = $address;
             email($params)->send();
         }
         $this->message = l::get('sendform-send-success');
         $this->sentSuccessful = true;
         // now this form send session is over, so destroy the token
         $this->destroyToken();
     } else {
         $this->message = l::get('sendform-send-error') . " " . $email->error();
     }
 }
Пример #24
0
		<!-- Shipping -->
		<input type="hidden" name="shipping_1" value="<?php 
echo $txn->shipping();
?>
">
	
		<!-- Tax -->
		<input type="hidden" name="tax_cart" value="<?php 
echo $txn->tax();
?>
">

		<!-- Transaction ID (Callback for the success page to grab the right transaction page) -->
		<input type="hidden" name="custom" value="<?php 
echo $txn->slug();
?>
">

		<button type="submit"><?php 
echo l::get('continue-to-paypal');
?>
</button>
	</form>

	<script>
		// Automatically submit the form
		document.paypalexpress.submit();
	</script>
</body>
</html>
Пример #25
0
        }
        ?>
                        </small>
                    </div>
                </div>
                <nav class="item-options">
                    <ul class="nav nav-bar">
                        <li>
                            <a class="btn btn-with-icon [ selector-checkbox js-selector-checkbox ]" href="">
                                <i class="icon icon-left fa fa-circle-o"></i>
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
        <?php 
    }
    ?>
    <?php 
} else {
    ?>
        <div class="item selector-item-empty">
            <?php 
    echo l::get('selector.empty');
    ?>
        </div>
    <?php 
}
?>
</div>
Пример #26
0
" />
      </div>
    </fieldset>
  </form>
      
</div>

<?php 
    echo $panel->form->overlays();
    echo $panel->form->js();
    ?>

<?php 
} else {
    ?>
<div class="form">
  <h3><?php 
    echo l::get('nocontent.title');
    ?>
</h3>
  <em class="empty"><?php 
    echo l::get('nocontent.text');
    ?>
</em>
</div>
<?php 
}
?>

<?php 
snippet('footer');
Пример #27
0
} else {
    ?>
<div class="options form">
  <h3><?php 
    echo l::get('options.home.url');
    ?>
</h3>
  <?php 
    if ($page->isHomePage()) {
        ?>
  <em class="empty"><?php 
        echo l::get('options.home.text');
        ?>
</em>
  <?php 
    } else {
        ?>
  <em class="empty"><?php 
        echo l::get('options.error.text');
        ?>
</em>  
  <?php 
    }
    ?>
</div>
<?php 
}
?>

<?php 
snippet('footer');
Пример #28
0
<?php

// Set detected language
site()->visit('shop', (string) site()->detectedLanguage());
site()->kirby->localize();
// Build body text
$body = l::get('transaction-id') . ' ' . $txn->txn_id() . "\n\n";
$body .= 'status :' . $payment_status . "\n";
$body .= 'payer-name : ' . $payer_name . "\n";
$body .= 'payer-email : ' . $payer_email . "\n";
$body .= 'payer-address : ' . $payer_address . "\n\n";
$body .= l::get('order-error-message-update') . ' ';
$body .= page('shop/orders')->url() . '?txn_id=' . $txn->txn_id();
// Build email
$email = new Email(array('to' => page('shop')->error_email()->value, 'from' => 'noreply@' . server::get('server_name'), 'subject' => l::get('order-error-subject'), 'body' => $body));
// Send it
$email->send();
Пример #29
0
        <p class="uk-form-help-block uk-text-muted uk-margin-remove" id="countryHelp"><?php 
echo l::get('country-help');
?>
</p>
      </div>
      <div class="uk-form-row">
        <button class="uk-button uk-button-primary uk-button-large uk-form-width-medium" type="submit" name="update">
          <?php 
echo l::get('update');
?>
        </button>
      </div>
    </form>

    <h3><?php 
echo l::get('delete-account');
?>
</h3>
    <p><?php 
echo l::get('delete-account-text');
?>
</p>
    <form class="uk-form" method="post">
        <button class="uk-button" type="submit" name="delete"><?php 
echo l::get('delete-account-verify');
?>
</button>
    </form>

<?php 
snippet('footer');
Пример #30
0
 public function buttons()
 {
     $fieldset = new Brick('fieldset');
     $fieldset->addClass('fieldset buttons cf');
     if ($this->centered) {
         $fieldset->addClass('buttons-centered');
     }
     $button = new Brick('input', null);
     $button->addClass('btn btn-rounded');
     if ($this->cancel) {
         $cancel = clone $button;
         $cancel->tag('a');
         $cancel->addClass('btn-cancel');
         $cancel->attr('href', $this->back);
         $cancel->text($this->cancel === true ? l::get('cancel') : $this->cancel);
         $fieldset->append($cancel);
     }
     if ($this->save) {
         $submit = clone $button;
         $submit->attr('type', 'submit');
         $submit->addClass('btn-submit');
         $submit->data('saved', l::get('saved'));
         $submit->val($this->save === true ? l::get('save') : $this->save);
         $fieldset->append($submit);
     }
     return ($this->save or $this->cancel) ? $fieldset : null;
 }