load() protected method

protected load ( $filename )
Esempio n. 1
0
File: i18n.php Progetto: ukd1/kohana
 /**
  * Returns translation of a string. If no translation exists, the original
  * string will be returned.
  *
  * @param   string   text to translate
  * @return  string
  */
 public static function get($string)
 {
     // Load the translation table
     $table = i18n::load(i18n::$lang);
     // Return the translated string if it exists
     return isset($table[$string]) ? $table[$string] : $string;
 }
Esempio n. 2
0
 /**
  * Parses the $_FILES superglobal for uploaded files. An event is triggered for each file. Handlers
  * can then decide whether to keep the uploaded file. The action result is filled with the properties
  * of the $_FILES superglobal storing the corresponding result - whether the respective file was
  * removed or has been accepted.
  */
 protected function action_main($skipPermsCheck = false)
 {
     if (!$skipPermsCheck and !Permissions::has('sys_upload')) {
         return $this->redirectForbidden();
     }
     $lang = i18n::load('diamondmvc');
     $result = array();
     $success = true;
     if (!empty($_FILES)) {
         foreach ($_FILES as $prop => $file) {
             // Skip this file if not desired.
             if (!empty($this->filters) and !in_array($prop, $this->filters)) {
                 continue;
             }
             // Attempt to save the file.
             if (!$this->handleUpload($prop, $file)) {
                 $this->addMessage(str_replace('%name%', $file['name'], $lang->get('ERROR_TITLE', 'ControllerUpload')), $lang->get('ERROR_MESSAGE', 'ControllerUpload'), 'error');
                 $result[$prop] = false;
                 $success = false;
             } else {
                 $result[$prop] = true;
             }
         }
     }
     $this->result = array('success' => $success, 'details' => $result);
 }
Esempio n. 3
0
 protected function generateDocsMenu($ctrl)
 {
     $lang = i18n::load('diamondmvc');
     $result = new ModuleNavbar($ctrl);
     $result->addLinkLeft($lang->get('HOME'), DIAMONDMVC_URL . '/docs')->addMenuLeft($lang->get('GUIDES'))->addLink($lang->get('GETTING_STARTED'), DIAMONDMVC_URL . '/docs/getting-started')->addLink($lang->get('CONTROLLERS'), DIAMONDMVC_URL . '/docs/controllers')->addLink($lang->get('VIEWS'), DIAMONDMVC_URL . '/docs/views')->addLink($lang->get('MODELS'), DIAMONDMVC_URL . '/docs/models')->addLink($lang->get('INTERNATIONALIZATION'), DIAMONDMVC_URL . '/docs/i18n')->addLink($lang->get('PERMISSIONS'), DIAMONDMVC_URL . '/docs/permissions')->addLink($lang->get('EXTENSIONS'), DIAMONDMVC_URL . '/docs/extensions')->back();
     return $result;
 }
Esempio n. 4
0
 protected function action_main()
 {
     $this->title = 'Error!';
     $lang = i18n::load('diamondmvc');
     $errors = array();
     if (isset($_SESSION['errors'])) {
         $errors = $_SESSION['errors'];
         unset($_SESSION['errors']);
     } else {
         if (isset($_SESSION['error'])) {
             $errors[] = $_SESSION['error'];
             unset($_SESSION['error']);
         } else {
             if (isset($_REQUEST['msg'])) {
                 $error = array();
                 $error['title'] = isset($_REQUEST['title']) ? htmlspecialchars(urldecode($_REQUEST['title'])) : $lang->get('GENERIC_ERROR');
                 $error['msg'] = htmlspecialchars(urldecode($_REQUEST['msg']));
                 // Prevent XSS attacks on our beloved clients
                 $error['level'] = isset($_REQUEST['level']) ? $_REQUEST['level'] : 'warn';
                 // The addMessage method automatically sanitizes this
                 $errors[] = $error;
             }
         }
     }
     foreach ($errors as $error) {
         $this->addMessage($error['title'], $error['msg'], $error['level']);
     }
 }
Esempio n. 5
0
 *  - files:       List of files to be shown in the filebrowser.
 * 
 * Each item in the files array ought to provide the following data:
 *  - is_dir: Whether the item represents a directory or a regular file
 *  - name:   Name of the item
 *  - id:     Unique ID. This is passed to the AJAX callback upon clicking the item.
 *  - size:   Size in bytes
 *  - perms:  File permissions
 */
defined('DIAMONDMVC') or die;
if (isset($this->controller)) {
    $data = $this->controller->getResult();
} else {
    $data = $this->getData();
}
$lang = i18n::load('diamondmvc');
$this->addStylesheet('filebrowser.css');
$this->addStylesheet('/assets/dropzone/dropzone.min.css');
$this->addScript('./filebrowser');
$this->addScript('dropzone');
?>
<div class="view view-filebrowser">
	<?php 
if (isset($data['controls']) and !empty($data['controls'])) {
    ?>
		<div class="filebrowser-controls pull-right">
			<?php 
    if (isset($data['controls']['custom']) and !empty($data['controls']['custom'])) {
        ?>
				<?php 
        echo $data['controls']['custom'];
Esempio n. 6
0
<?php

/**
 * @package  DiamondMVC
 * @author   Zyr <*****@*****.**>
 * @version  1.0
 * @license  CC-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
 * 
 * Extension installation mask. Provides a modal to choose an extension ZIP archive for upload.
 */
$lang = i18n::load('diamondmvc-backend');
// $this->addStylesheet('install.css');
$this->addScript('dropzone');
$this->addScript('./install');
$data = $this->controller->getResult();
$snippet = $data['filebrowser'];
foreach ($snippet->getStylesheets() as $sheet) {
    $this->addStylesheet($sheet);
}
foreach ($snippet->getScripts() as $script) {
    $this->addScript($script);
}
?>
<div class="view view-install" id="view-system">
	<a href="<?php 
echo DIAMONDMVC_URL;
?>
/system/installations" class="btn btn-primary pull-right"><?php 
echo $lang->get('RETURN_TO_OVERVIEW', 'ControllerSystem.Install');
?>
</a>
Esempio n. 7
0
 /**
  * Reads the HTML template of this view into memory. The template is searched
  * based on the view's name.
  * Template parameters ought to be set prior to the invokation of this method.
  * @return View             Diese Instanz zur Methodenverkettung.
  */
 public function read()
 {
     ob_start();
     $path = $this->getPath();
     if (!empty($path)) {
         include $path;
     } else {
         $lang = i18n::load('diamondmvc');
         echo $lang->get('VIEW_NOT_FOUND');
     }
     $this->buffer = ob_get_contents();
     ob_end_clean();
     return $this;
 }
Esempio n. 8
0
 protected function redirectForbidden()
 {
     $lang = i18n::load('diamondmvc-backend');
     $_SESSION['error'] = array('title' => $lang->get('ERROR_RESTRICTED_ACCESS'), 'msg' => $lang->get('ERROR_INSUFFICIENT_PERMISSIONS'), 'level' => 'error');
     redirect(DIAMONDMVC_URL . '/error');
 }
Esempio n. 9
0
File: i18n.php Progetto: rair/yacs
 /**
  * load localized strings for one module
  *
  * @param string module name
  */
 public static function bind($module)
 {
     global $context;
     // sanity check
     if (!isset($context['language'])) {
         return;
     }
     // initialization
     if (!isset($context['l10n_modules'])) {
         $context['l10n_modules'] = array();
     }
     // ensure all cached modules are accurate on development machine
     if ($context['with_debug'] == 'Y') {
         i18n::load('en', $module);
         i18n::load('fr', $module);
     }
     // this module has already been loaded
     if (isset($context['l10n_modules'][$module])) {
         return;
     }
     // avoid further loading
     $context['l10n_modules'][$module] = TRUE;
     // load strings according to surfer localization
     i18n::load($context['language'], $module);
     // load strings according to community localization
     if ($context['preferred_language'] != $context['language']) {
         i18n::load($context['preferred_language'], $module);
     }
 }