コード例 #1
0
ファイル: rebuildRouter.php プロジェクト: ninodafonte/SIFO
 public function build()
 {
     header('Content-Type: text/plain');
     $this->setLayout('manager/findi18n.tpl');
     try {
         $master_routes = \Sifo\Config::getInstance($this->instance)->getConfig('lang/router_' . self::MASTER_LANGUAGE);
     } catch (Exception_Configuration $e) {
         die('The master file does not exist. ' . $e->getMessage());
     }
     $findI18N = new ManagerFindi18nController();
     $files_available = $findI18N->getFilesystemFiles("instances/{$this->instance}/config/lang");
     foreach ($files_available as $key => $filename) {
         // Is a 'router' config file (but not master)
         if (strpos($filename, 'router_') !== false) {
             $translated_routes = $this->getTranslatedRoutes($filename);
             // Remove keys not present in master:
             foreach ($translated_routes as $route => $route_translated) {
                 if (!isset($master_routes[$route])) {
                     unset($translated_routes[$route]);
                     echo "Deleted route {$route} in {$filename}\n";
                 }
             }
             // Add keys not present in master
             foreach ($master_routes as $route => $route_translated) {
                 if (!isset($translated_routes[$route])) {
                     $translated_routes[$route] = $route_translated;
                 }
             }
             ksort($translated_routes);
             $this->saveConfig($filename, $translated_routes);
         }
     }
     echo "\n\nRoutes rebuild!";
     die;
 }
コード例 #2
0
ファイル: findi18n.ctrl.php プロジェクト: ninodafonte/SIFO
 public function getLiterals($instance)
 {
     $path = \Sifo\Bootstrap::$application . "/{$instance}";
     // Parse all templates
     $literals_groups['tpl'] = $this->extractStringsForTranslation("{$path}/templates", $instance, true);
     // Parse all models:
     $literals_groups['models'] = $this->extractStringsForTranslation("{$path}/models", $instance, false);
     // Parse all controllers:
     $literals_groups['controllers'] = $this->extractStringsForTranslation("{$path}/controllers", $instance, false);
     // Parse all form configs:
     $literals_groups['forms'] = $this->extractStringsForTranslation("{$path}/config", $instance, false);
     // Smarty plugins:
     $libs_path = ROOT_PATH . \Sifo\Config::getInstance()->getLibrary('smarty') . '/plugins';
     $literals_groups['smarty'] = $this->extractStringsForTranslation($libs_path, 'libs', false);
     // Your instance plugins:
     $instance_plugins = $path . '/templates/_smarty/plugins';
     if (is_dir($instance_plugins)) {
         $literals_groups['smarty'] = array_merge($literals_groups['smarty'], $this->extractStringsForTranslation($instance_plugins, $instance, false));
     }
     $final_literals = array();
     foreach ($literals_groups as $group) {
         foreach ($group as $literal => $relative_path) {
             if (array_key_exists($literal, $final_literals)) {
                 $final_literals[$literal] = $final_literals[$literal] . ", " . $relative_path;
             } else {
                 $final_literals[$literal] = $relative_path;
             }
         }
     }
     return $final_literals;
 }
コード例 #3
0
ファイル: openinviter.php プロジェクト: ninodafonte/SIFO
 public function __construct()
 {
     $this->basePath = dirname(__FILE__);
     $openinviter_settings = \Sifo\Config::getInstance()->getConfig('openinviter');
     require_once $this->basePath . "/plugins/_base.php";
     $this->settings = $openinviter_settings;
     $this->configOK = $this->checkConfig();
 }
コード例 #4
0
 protected function finalRender($debug)
 {
     $view = new \Sifo\View();
     $view->assign('debug_modules', $this->debug_modules);
     $view->assign('debug', $debug);
     $view->assign('command_line_mode', true);
     $content = $view->fetch(ROOT_PATH . '/' . \Sifo\Config::getInstance()->getConfig('templates', 'debug/debug.tpl'));
     file_put_contents(ROOT_PATH . '/logs/cli_debug.html', $content);
 }
コード例 #5
0
ファイル: common.ctrl.php プロジェクト: ninodafonte/SIFO
 /**
  * Assign selected error code metadata to page to allow error translations.
  *
  * @return array
  */
 public function getErrorMetadata()
 {
     try {
         $metadata = \Sifo\Config::getInstance()->getConfig('lang/metadata_' . $this->getParam('lang'));
     } catch (Exception_Configuration $e) {
         $metadata = \Sifo\Config::getInstance()->getConfig('lang/metadata_en_US');
     }
     $error_code = $this->getParam('code');
     return isset($metadata[$error_code]) ? $metadata[$error_code] : false;
 }
コード例 #6
0
ファイル: Krumo.php プロジェクト: ninodafonte/SIFO
/**
 * Alias of krumo::dump(). Formatted data dump. No output in production.
 * You need to download Krumo into "libs" first and declare it in "libraries.config.php"
 *
 * @param mixed $data,...
 */
function d($var)
{
    // Enable Krumo only when debug is present.
    if (\Sifo\Domains::getInstance()->getDebugMode()) {
        require_once ROOT_PATH . '/libs/' . \Sifo\Config::getInstance()->getLibrary('krumo') . '/class.krumo.php';
        krumo($var);
    } else {
        return false;
    }
}
コード例 #7
0
ファイル: twitter.model.php プロジェクト: ninodafonte/SIFO
 public function __construct()
 {
     try {
         $this->credentials = \Sifo\Config::getInstance()->getConfig('twitter_oauth', \Sifo\Domains::getInstance()->getDomain());
         parent::__construct($this->credentials['consumer_key'], $this->credentials['consumer_secret']);
         $this->useAsynchronous(true);
         $this->setTimeout($this->credentials['request_timeout'], $this->credentials['connection_timeout']);
     } catch (\Exception $e) {
         throw new \Sifo\Exception_500($e->getMessage());
     }
 }
コード例 #8
0
ファイル: advertising.ctrl.php プロジェクト: ninodafonte/SIFO
 public function build()
 {
     $module = $this->getParam('module_name');
     try {
         $ads_config = \Sifo\Config::getInstance()->getConfig('ads', $module);
         $this->setLayout($ads_config['layout']);
         $this->assign('ad', $ads_config);
     } catch (\Sifo\Exception_Configuration $e) {
         // The programmer is an asshole, but page should load anyway:
         trigger_error("Failed to load banners for module '{$module}', not present in ads.config.php");
         $this->setLayout('empty.tpl');
     }
 }
コード例 #9
0
/**
 * Allow using {extends} and {include} Smarty functions taking into account the instance
 * inheritance. Given template will be translated to full path tempalte file for
 * active instance.
 *
 * @param $template
 * @return string
 */
function smarty_modifier_custom_tpl($template)
{
    if (!isset($template)) {
        trigger_error("custom_tpl: The attribute 'template' are not set", E_USER_NOTICE);
    }
    $instance_templates = \Sifo\Config::getInstance()->getConfig('templates');
    if (isset($instance_templates[$template])) {
        $selected_template = $instance_templates[$template];
    } else {
        trigger_error("The template '{$template}' has not been found in the templates folder.", E_USER_ERROR);
        return false;
    }
    return ROOT_PATH . "/{$selected_template}";
}
コード例 #10
0
ファイル: Memcache.php プロジェクト: ninodafonte/SIFO
 /**
  * Returns an instance of the Memcache object with the configured servers.
  *
  * @return Memcache
  */
 public function __construct()
 {
     try {
         $servers = \Sifo\Config::getInstance()->getConfig('cache', 'servers');
     } catch (\Sifo\Exception_Configuration $e) {
         // Default memcached address and listening port.
         $servers = array(array('127.0.0.1' => 11211));
     }
     $this->cache_object = new Memcache();
     foreach ($servers[0] as $server => $port) {
         $this->cache_object->addServer($server, $port);
     }
     return $this->cache_object;
 }
コード例 #11
0
ファイル: head.ctrl.php プロジェクト: ninodafonte/SIFO
 /**
  * Assign a variable to the tpl with the HTML code to load the JS and CSS files.
  */
 protected function assignMedia()
 {
     // On development create all the packed files on the fly:
     if (\Sifo\Domains::getInstance()->getDevMode()) {
         $packer = new \Sifo\JsPacker();
         $packer->packMedia();
         $packer = new \Sifo\CssPacker();
         $packer->packMedia();
     }
     $this->assign('media', \Sifo\Config::getInstance()->getConfig('css'));
     $this->assign('css_groups', $this->css_groups);
     $this->assign('js_groups', $this->js_groups);
     $this->assign('static_rev', $this->getStaticRevision());
     $this->assign('media_module', $this->fetch('shared/media_packer.tpl'));
 }
コード例 #12
0
ファイル: Keyspace.php プロジェクト: ninodafonte/SIFO
 /**
  * Returns the final Key name for the given parameters.
  *
  * @param string $key_name
  * @param array $parameters
  * @throws KeySpace_Exception
  */
 public static function get($key_name, $parameters = null)
 {
     if (!isset(self::$keyspace)) {
         self::$keyspace = \Sifo\Config::getInstance()->getConfig('keyspace');
     }
     if (!isset(self::$keyspace[$key_name])) {
         throw new KeySpace_Exception("Key named '{$key_name}' is not available in the key space.");
     }
     $key = self::$keyspace[$key_name];
     if (is_array($parameters)) {
         foreach ($parameters as $tag => $value) {
             $tag = preg_quote($tag, '/');
             $key = preg_replace("/<({$tag})>/", $value, $key);
         }
     }
     // Remove any missing parameters:
     if (false !== strpos($key, '<')) {
         throw new KeySpace_Exception("The key contains undeclared parameters for replacement");
     }
     return $key;
 }
コード例 #13
0
ファイル: Pagination.php プロジェクト: ninodafonte/SIFO
 /**
  * Set the pagination template.
  *
  * @param string $layout_template Name pagination template (this is the .tpl file).
  * @return boolean
  */
 public function setTemplate($layout_template)
 {
     $tpl_config = $this->config->getConfig('templates');
     if (!isset($tpl_config[$layout_template])) {
         trigger_error("Template file '{$layout_template}' not found.");
         return false;
     }
     $this->layout_template = ROOT_PATH . '/' . $tpl_config[$layout_template];
 }
コード例 #14
0
ファイル: ConfigTest.php プロジェクト: ninodafonte/SIFO
 public function __construct($instance_name)
 {
     return parent::__construct($instance_name);
 }