コード例 #1
0
/**
 * Attempts to match the name of a file to the "clean name" within the name map file.
 * If no mapping is found, it will clean it to the best of its ability and return
 * that "cleaner" version of the page name.
 *
 * @param   string  $page   Name of the page, potentially with category path.
 * @param   string  $lang   Language to use.
 *
 * @return  string  Final formatted name.
 */
function findName($page, $lang = '')
{
    global $nameMap;
    if (empty($lang)) {
        $lang = \App\getLanguage();
    }
    $useMap = $nameMap[$lang];
    if (array_key_exists($page, $useMap)) {
        return $useMap[$page];
    }
    $exp = explode('/', $page);
    $last = array_pop($exp);
    return str_replace('_', ' ', str_replace('.md', '', $last));
}
コード例 #2
0
ファイル: View.php プロジェクト: jbelelieu/banana-dance-lite
 /**
  * @param   array   $changes
  *
  * @return  bool
  */
 private function appendFixedVariables(array $changes)
 {
     $lang = \App\getLanguage();
     $fixed = (include dirname(dirname(__FILE__)) . '/wiki/config/custom_variables.php');
     if (empty($fixed[$lang])) {
         return $changes;
     }
     $useFixed = $fixed[$lang];
     // If the user requested a language other than english but there
     // are no entries for that language, try to default to english.
     if (empty($useFixed) && $lang != BD_DEFAULT_LANGUAGE) {
         if (empty($fixed[BD_DEFAULT_LANGUAGE])) {
             return false;
         }
         $useFixed = $fixed[BD_DEFAULT_LANGUAGE];
     }
     if (!empty($useFixed)) {
         return array_merge($changes, $useFixed);
     } else {
         return $changes;
     }
 }
コード例 #3
0
 /**
  * Custom replacements available on all pages. Establish standard
  * replacements within the "config/custom_replacements.php" file.
  *
  * @return  bool
  */
 private function standardReplacements()
 {
     $replacements = (include dirname(dirname(__FILE__)) . '/wiki/config/custom_replacements.php');
     $lang = \App\getLanguage();
     $useArray = $replacements[$lang];
     // If the user requested a language other than english but there
     // are no entries for that language, try to default to english.
     if (empty($useArray) && $lang != BD_DEFAULT_LANGUAGE) {
         if (empty($replacements[BD_DEFAULT_LANGUAGE])) {
             return false;
         }
         $useArray = $replacements[BD_DEFAULT_LANGUAGE];
     }
     $keys = array_keys($useArray);
     $values = array_values($useArray);
     $this->content = str_replace($keys, $values, $this->content);
     return true;
 }
コード例 #4
0
 /**
  * Changes that apply to all possible templates.
  */
 private function getDefaultChanges()
 {
     $base = \App\getBaseUrl();
     return array('assets' => $base . '/app/views/' . BD_THEME . '/assets', 'wiki_name' => BD_NAME, 'wiki_theme' => BD_THEME, 'wiki_base_url' => $base, 'branding_color' => BD_BRANDING_COLOR, 'page' => $this->page, 'category' => $this->category, 'currentLanguage' => \App\getLanguage(), 'languages' => $this->buildLanguages(), 'query' => '', 'navigation' => $this->structure->getHtml());
 }
コード例 #5
0
 /**
  * Builds an array of items that make up the category and page.
  *
  * @param   string   $category
  *
  * @return  array
  */
 private function buildLinkComponents($category)
 {
     $build = array();
     $dirs = array_reverse(explode('/', $category));
     $lang = \App\getLanguage();
     foreach ($dirs as $item) {
         // We don't care about anything before the language folder.
         if ($item == $lang) {
             break;
         }
         $build[] = $item;
     }
     array_shift($build);
     return array_reverse($build);
 }