コード例 #1
0
 function loadConfigInSite(Config $config, Site $site)
 {
     $file = $site->getDir() . DIRECTORY_SEPARATOR . "config.ini";
     $data = parse_ini_file($file);
     if (isset($data['theme']) && $data['theme']) {
         $config->theme = $data['theme'];
         // TODO check valid
     }
     if (isset($data['title']) && $data['title']) {
         $config->title = $data['title'];
     }
     if (isset($data['default_country']) && $data['default_country']) {
         $config->defaultCountry = $data['default_country'];
         // TODO check valid
     }
     if (isset($data['default_timezone']) && $data['default_timezone']) {
         $config->defaultTimeZone = $data['default_timezone'];
         // TODO check valid
     }
     if (isset($data['base_url']) && $data['base_url']) {
         $config->baseURL = $data['base_url'];
     }
     if (isset($data['internal_link_to_dir_append_directory_index'])) {
         $config->internalLinkToDirAppendDirectoryIndex = (bool) $data['internal_link_to_dir_append_directory_index'];
     }
     if (isset($data['robots_index'])) {
         $config->robotsIndex = (bool) $data['robots_index'];
     }
     if (isset($data['robots_follow'])) {
         $config->robotsFollow = (bool) $data['robots_follow'];
     }
 }
コード例 #2
0
 function __construct(Site $site)
 {
     $this->cacheDir = new TemporaryFolder();
     $templates = array(APP_ROOT_DIR . DIRECTORY_SEPARATOR . 'theme' . DIRECTORY_SEPARATOR . $site->getConfig()->theme . DIRECTORY_SEPARATOR . 'templates');
     $siteTemplates = $site->getDir() . DIRECTORY_SEPARATOR . 'theme' . DIRECTORY_SEPARATOR . 'templates';
     if (file_exists($siteTemplates) && is_dir($siteTemplates)) {
         array_unshift($templates, $siteTemplates);
     }
     $loader = new Twig_Loader_Filesystem($templates);
     $this->twig = new Twig_Environment($loader, array('cache' => $this->cacheDir->get()));
     $this->twig->addExtension(new InternalLinkHelper($site->getConfig()));
     $this->twig->addExtension(new \JMBTechnologyLimited\Twig\Extensions\LinkifyExtension());
     $this->twig->addExtension(new \JMBTechnologyLimited\Twig\Extensions\SameDayExtension());
     $this->twig->addExtension(new \JMBTechnologyLimited\Twig\Extensions\TimeZoneExtension());
     $this->twig->addExtension(new \JMBTechnologyLimited\Twig\Extensions\LinkInfoExtension());
     $this->twig->addExtension(new TruncateExtension());
 }