コード例 #1
0
 /**
  * Language constructor.
  * @param string $domain
  * @param string $code
  */
 public function __construct(Manager $manager, $domain, $code)
 {
     $this->manager = $manager;
     //
     $languages = $manager->getLanguages();
     if (isset($languages[$code]) && !empty($languages[$code])) {
         $info = $languages[$code];
         $this->code = $code;
         //
         $this->info = $info['info'];
         $this->name = $info['name'];
         $this->locale = $info['locale'];
         $this->direction = $info['dir'];
     } else {
         $code = 'en';
     }
     $this->domain = $domain;
     //
     $pathName = Inflector::classify($domain);
     if ($pathName == 'Nova') {
         $basePath = SYSTEMDIR;
     } else {
         if ($pathName == 'Shared') {
             $basePath = ROOTDIR . 'shared' . DS;
         } else {
             if (is_dir(APPDIR . 'Modules' . DS . $pathName)) {
                 $basePath = APPDIR . 'Modules/' . $pathName . DS;
             } else {
                 if (is_dir(APPDIR . 'Templates' . DS . $pathName)) {
                     $basePath = APPDIR . 'Templates/' . $pathName . DS;
                 } else {
                     $basePath = APPDIR;
                 }
             }
         }
     }
     $filePath = $basePath . 'Language' . DS . ucfirst($code) . DS . 'messages.php';
     // Check if the language file is readable.
     if (!is_readable($filePath)) {
         return;
     }
     // Get the Domain's messages from the Language file.
     $messages = (include $filePath);
     // A final consistency check.
     if (is_array($messages) && !empty($messages)) {
         $this->messages = $messages;
     }
 }
コード例 #2
0
 /**
  * Get the singular form of an English word.
  *
  * @param  string  $value
  * @return string
  */
 public static function singular($value)
 {
     return Inflector::singularize($value);
 }
コード例 #3
0
 /**
  * Create the absolute address to the template folder.
  *
  * @param  boolean $custom
  * @return string url to template folder
  */
 public static function templatePath($custom = TEMPLATE, $folder = '/assets/')
 {
     $template = Inflector::tableize($custom);
     return Config::get('app.url') . 'templates/' . $template . $folder;
 }
コード例 #4
0
 /**
  * Register a custom implicit Validator extension.
  *
  * @param  string   $rule
  * @param  \Closure|string  $extension
  * @param  string  $message
  * @return void
  */
 public function extendImplicit($rule, $extension, $message = null)
 {
     $this->implicitExtensions[$rule] = $extension;
     if ($message !== null) {
         $rule = Inflector::tableize($rule);
         $this->fallbackMessages[$rule] = $message;
     }
 }
コード例 #5
0
ファイル: Assets.php プロジェクト: sisnox/framework
 /**
  * load css scripts
  * @param  String|Array  $files      paths to file/s
  * @param  boolean       $cache      if set to true a cache will be created and serverd
  * @param  boolean       $refresh    if true the cache will be updated
  * @param  string        $cachedMins minutes to hold the cache
  */
 public static function css($files, $cache = false, $refresh = false, $cachedMins = '1440')
 {
     $path = APPDIR . Url::relativeTemplatePath() . 'css/compressed.min.css';
     $type = 'css';
     if ($cache == false) {
         static::resource($files, $type);
     } else {
         if ($refresh == false && file_exists($path) && filemtime($path) > time() - 60 * $cachedMins) {
             $path = str_replace(APPDIR, null, $path);
             $path = Inflector::tableize($path);
             static::resource(DIR . $path, $type);
         } else {
             $source = static::collect($files, $type);
             $source = static::compress($source);
             file_put_contents($path, $source);
             $path = str_replace(APPDIR, null, $path);
             $path = Inflector::tableize($path);
             static::resource(DIR . $path, $type);
         }
     }
 }
コード例 #6
0
ファイル: Url.php プロジェクト: sisnox/framework
 /**
  * Created the absolute address to the template folder.
  *
  * @param  boolean $custom
  * @return string url to template folder
  */
 public static function templatePath($custom = TEMPLATE, $folder = '/assets/')
 {
     $template = Inflector::tableize($custom);
     return SITEURL . 'templates/' . $template . $folder;
 }
コード例 #7
0
 /**
  * Get the Table for the Model.
  *
  * @return string
  */
 public function getTable()
 {
     if (isset($this->table)) {
         return $this->table;
     }
     $baseName = class_basename($this);
     return str_replace('\\', '', Inflector::tableize($baseName));
 }
コード例 #8
0
ファイル: Router.php プロジェクト: sisnox/framework
 protected function dispatchFile($uri)
 {
     // For properly Assets serving, the file URI should be as following:
     //
     // /templates/default/assets/css/style.css
     // /modules/blog/assets/css/style.css
     // /assets/css/style.css
     $filePath = '';
     if (preg_match('#^assets/(.*)$#i', $uri, $matches)) {
         $filePath = ROOTDIR . 'assets' . DS . $matches[1];
     } else {
         if (preg_match('#^(templates|modules)/(.+)/assets/(.*)$#i', $uri, $matches)) {
             // We need to classify the path name (the Module/Template path).
             $basePath = ucfirst($matches[1]) . DS . Inflector::classify($matches[2]);
             $filePath = APPDIR . $basePath . DS . 'Assets' . DS . $matches[3];
         }
     }
     if (!empty($filePath)) {
         // Serve the specified Asset File.
         Response::serveFile($filePath);
         return true;
     }
     return false;
 }
コード例 #9
0
ファイル: ClassicRouter.php プロジェクト: sisnox/framework
 /**
  * Ability to call controllers in their module/directory/controller/method/param way.
  *
  * NOTE: This Auto-Dispatch routing use the styles:
  *      <DIR><directory><controller><method><params>
  *      <DIR><module><directory><controller><method><params>
  *
  * @param $uri
  * @return bool
  */
 public function autoDispatch($uri)
 {
     // Explode the URI in its parts.
     $parts = explode('/', trim($uri, '/'));
     // Loop through URI parts, checking for the Controller file including its path.
     $controller = '';
     if (!empty($parts)) {
         // Classify, to permit: '<DIR>/file_manager/admin/' -> '<APPDIR>/Modules/FileManager/Admin/
         $controller = Inflector::classify(array_shift($parts));
     }
     // Verify if the first URI part match a Module.
     $testPath = APPDIR . 'Modules' . DS . $controller;
     if (!empty($controller) && is_dir($testPath)) {
         // Walking in a Module path.
         $moduleName = $controller;
         $basePath = 'Modules/' . $controller . '/Controllers/';
         // Go further only if have other URI Parts, to permit URL mappings like:
         // '<DIR>/clients' -> '<APPDIR>/app/Modules/Clients/Controllers/Clients.php'
         if (!empty($parts)) {
             $controller = Inflector::classify(array_shift($parts));
         }
     } else {
         $moduleName = '';
         $basePath = 'Controllers/';
     }
     // Check for the Controller, even in sub-directories.
     $directory = '';
     while (!empty($parts)) {
         $testPath = APPDIR . str_replace('/', DS, $basePath . $directory . $controller);
         if (!is_readable($testPath . '.php') && is_dir($testPath)) {
             $directory .= $controller . DS;
             $controller = Inflector::classify(array_shift($parts));
             continue;
         }
         break;
     }
     // Get the normalized Controller
     $defaultOne = !empty($moduleName) ? $moduleName : DEFAULT_CONTROLLER;
     $controller = !empty($controller) ? $controller : $defaultOne;
     // Get the normalized Method
     $method = !empty($parts) ? array_shift($parts) : DEFAULT_METHOD;
     // Prepare the Controller's class name.
     $controller = str_replace(array('//', '/'), '\\', 'App/' . $basePath . $directory . $controller);
     // The Method shouldn't start with '_'; also check if the Controller's class exists.
     if ($method[0] !== '_' && class_exists($controller)) {
         // Get the parameters, if any.
         $params = !empty($parts) ? $parts : array();
         // Invoke the Controller's Method with the given arguments.
         return $this->invokeController($controller, $method, $params);
     }
     return false;
 }
コード例 #10
0
 /**
  * Determine the URI from the given method name.
  *
  * @param  string  $name
  * @param  string  $prefix
  * @return string
  */
 public function getPlainUri($name, $prefix)
 {
     return $prefix . '/' . implode('-', array_slice(explode('_', Inflector::tableize($name)), 1));
 }