Beispiel #1
0
 public static function generateSitemapWithoutPing()
 {
     global $SITEURL;
     $filenames = getFiles(GSDATAPAGESPATH);
     if (count($filenames)) {
         foreach ($filenames as $file) {
             if (isFile($file, GSDATAPAGESPATH, 'xml')) {
                 $data = getXML(GSDATAPAGESPATH . $file);
                 if ($data->url != '404' && $data->private != 'Y') {
                     $pagesArray[] = array('url' => (string) $data->url, 'parent' => (string) $data->parent, 'date' => (string) $data->pubDate, 'menuStatus' => (string) $data->menuStatus);
                 }
             }
         }
     }
     $pagesSorted = subval_sort($pagesArray, 'menuStatus');
     $languages = return_i18n_available_languages();
     $deflang = return_i18n_default_language();
     $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
     $xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance');
     $xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     if (count($pagesSorted)) {
         foreach ($pagesSorted as $page) {
             // set <loc>
             if (count($languages) > 1) {
                 $pos = strrpos($page['url'], '_');
                 if ($pos !== false) {
                     $pageLoc = find_i18n_url(substr($page['url'], 0, $pos), $page['parent'], substr($page['url'], $pos + 1));
                 } else {
                     $pageLoc = find_i18n_url($page['url'], $page['parent'], $deflang);
                 }
             } else {
                 $pageLoc = find_i18n_url($page['url'], $page['parent']);
             }
             // set <lastmod>
             $pageLastMod = makeIso8601TimeStamp(date("Y-m-d H:i:s", strtotime($page['date'])));
             // set <changefreq>
             $pageChangeFreq = 'weekly';
             // set <priority>
             $pagePriority = $page['menuStatus'] == 'Y' ? '1.0' : '0.5';
             //add to sitemap
             $url_item = $xml->addChild('url');
             $url_item->addChild('loc', htmlspecialchars($pageLoc));
             $url_item->addChild('lastmod', $pageLastMod);
             $url_item->addChild('changefreq', $pageChangeFreq);
             $url_item->addChild('priority', $pagePriority);
         }
     }
     //create xml file
     $file = GSROOTPATH . 'sitemap.xml';
     XMLsave($xml, $file);
 }
Beispiel #2
0
 public function __construct($data, $key, $id, $transkey = array(), $language, $creDate, $pubDate, $score)
 {
     if (self::$defaultLanguage === null) {
         self::$defaultLanguage = function_exists('return_i18n_default_language') ? return_i18n_default_language() : '';
     }
     $this->id = $id;
     $this->language = $language;
     $this->creDate = $creDate;
     $this->pubDate = $pubDate;
     $this->score = $score;
     $this->data = $data;
     $this->key = $key;
     $this->transkey = $transkey;
 }
Beispiel #3
0
 public static function outputLink($gallery)
 {
     include_once GSPLUGINPATH . 'i18n_gallery/helper.php';
     $url = @$gallery['url'] ? $gallery['url'] : 'index';
     $parent = @$gallery['parent'] ? $gallery['parent'] : null;
     $tags = @$gallery['tags'] ? $gallery['tags'] : null;
     $thumb = i18n_gallery_thumb($gallery);
     $title = $gallery['title'];
     if (function_exists('return_i18n_languages')) {
         $languages = return_i18n_languages();
         $deflang = return_i18n_default_language();
         foreach ($languages as $language) {
             $fullkey = 'title' . ($language == $deflang ? '' : '_' . $language);
             if (isset($gallery[$fullkey])) {
                 $title = $gallery[$fullkey];
                 break;
             }
         }
     }
     $link = function_exists('find_i18n_url') ? find_i18n_url($url, $parent) : find_url($url, $parent);
     if ($tags) {
         $link .= (strpos($link, '?') !== false ? '&' : '?') . 'imagetags=' . urlencode($tags);
     }
     if (isset($thumb)) {
         $item = @$gallery['items'][$thumb];
         if (!$item) {
             $item = $gallery['items'][0];
         }
         echo '<div class="gallery-link">';
         echo '<a href="' . htmlspecialchars($link) . '" class="gallery-thumb-link">';
         echo '<img src="';
         i18n_gallery_thumb_link($gallery, $item);
         echo '" alt="' . htmlspecialchars($title) . '" title="' . htmlspecialchars($title) . '"/>';
         echo '</a>';
         echo '<span class="gallery-title">' . htmlspecialchars($title) . '</span>';
         echo '</div>';
     } else {
         echo '<a href="' . htmlspecialchars($link) . '" class="gallery-title-link">';
         echo htmlspecialchars($title);
         echo '</a>';
     }
 }
Beispiel #4
0
function i18n_customfields_list_pages_json()
{
    if (function_exists('find_i18n_url') && class_exists('I18nNavigationFrontend')) {
        $slug = isset($_GET['id']) ? $_GET['id'] : (isset($_GET['newid']) ? $_GET['newid'] : '');
        $pos = strpos($slug, '_');
        $lang = $pos !== false ? substr($slug, $pos + 1) : null;
        $structure = I18nNavigationFrontend::getPageStructure(null, false, null, $lang);
        $pages = array();
        $nbsp = html_entity_decode('&nbsp;', ENT_QUOTES, 'UTF-8');
        $lfloor = html_entity_decode('&lfloor;', ENT_QUOTES, 'UTF-8');
        foreach ($structure as $page) {
            $text = ($page['level'] > 0 ? str_repeat($nbsp, 5 * $page['level'] - 2) . $lfloor . $nbsp : '') . cl($page['title']);
            $link = find_i18n_url($page['url'], $page['parent'], $lang ? $lang : return_i18n_default_language());
            $pages[] = array($text, $link);
        }
        return json_encode($pages);
    } else {
        return list_pages_json();
    }
}
Beispiel #5
0
    }
    while ($filename = readdir($dir_handle)) {
        if (!is_dir($dir . $filename)) {
            if (!copy($dir . $filename, GSDATAPAGESPATH . $filename)) {
                closedir($dir_handle);
                return false;
            }
        }
    }
    closedir($dir_handle);
    exec_action('menu-aftersave');
    return true;
}
global $LANG;
$i18n_url = function_exists('find_i18n_url');
$def_language = function_exists('return_i18n_default_language') ? return_i18n_default_language() : $LANG;
if (!isset($_POST['save']) && isset($_GET['undo'])) {
    if (i18n_navigation_structure_undo()) {
        $msg = i18n_r('i18n_navigation/UNDO_SUCCESS');
        $success = true;
    } else {
        $msg = i18n_r('i18n_navigation/UNDO_FAILURE');
    }
}
i18n_navigation_structure_load($pages, $languages);
if (isset($_POST['save'])) {
    $dir = GSBACKUPSPATH . 'i18n_navigation/';
    // create directory if necessary
    if (!file_exists($dir)) {
        @mkdir(substr($dir, 0, strlen($dir) - 1), 0777);
        $fp = @fopen($dir . '.htaccess', 'w');
Beispiel #6
0
 public static function getGalleryFromParams($params, $ignoreQuery = false, $ignoreSettings = false, $lang = null)
 {
     if (!$ignoreQuery) {
         if (!@$params['name'] && @$_GET['name']) {
             $params['name'] = $_GET['name'];
         }
         if (!@$params['type'] && @$_GET['type']) {
             $params['type'] = $_GET['type'];
         }
         if (!@$params['tags'] && @$_GET['imagetags']) {
             $params['tags'] = $_GET['imagetags'];
         }
     }
     if (!@$params['name']) {
         return null;
     }
     $gallery = self::getGallery($params['name']);
     if (!$gallery || !@$gallery['type']) {
         return null;
     }
     foreach ($params as $key => $value) {
         $gallery[$key] = $value;
     }
     if (@$params['tags']) {
         // filter images
         $tags = preg_split('/\\s*,\\s*/', trim($params['tags']));
         $newitems = array();
         foreach ($gallery['items'] as $item) {
             if (!@$item['tags']) {
                 continue;
             }
             $itemtags = preg_split('/\\s*,\\s*/', trim($item['tags']));
             if (count(array_intersect($tags, $itemtags)) == count($tags)) {
                 $newitems[] = $item;
             }
         }
         $gallery['items'] = $newitems;
     }
     if (!$ignoreSettings) {
         // add settings
         $settings = self::getSettings();
         if (!@$gallery['thumbwidth'] && !@$gallery['thumbheight']) {
             if (intval(@$settings['thumbwidth']) > 0 || intval(@$settings['thumbheight']) > 0) {
                 $gallery['thumbwidth'] = intval(@$settings['thumbwidth']) > 0 ? intval($settings['thumbwidth']) : null;
                 $gallery['thumbheight'] = intval(@$settings['thumbheight']) > 0 ? intval($settings['thumbheight']) : null;
                 $gallery['thumbcrop'] = @$settings['thumbcrop'];
             } else {
                 $gallery['thumbwidth'] = I18N_GALLERY_DEFAULT_THUMB_WIDTH;
                 $gallery['thumbheight'] = I18N_GALLERY_DEFAULT_THUMB_HEIGHT;
                 $gallery['thumbcrop'] = 0;
             }
         }
         if (count($settings) > 0) {
             if (!isset($gallery['jquery']) && isset($settings['jquery'])) {
                 $gallery['jquery'] = $settings['jquery'];
             }
             if (!isset($gallery['css']) && isset($settings['css'])) {
                 $gallery['css'] = $settings['css'];
             }
             if (!isset($gallery['js']) && isset($settings['js'])) {
                 $gallery['js'] = $settings['js'];
             }
             if (!@$gallery['width'] && !@$gallery['height']) {
                 if (intval(@$settings['width']) > 0) {
                     $gallery['width'] = intval($settings['width']);
                 }
                 if (intval(@$settings['height']) > 0) {
                     $gallery['height'] = intval($settings['height']);
                 }
             }
         }
     }
     // get best language texts
     if (function_exists('return_i18n_languages')) {
         global $language;
         //$languages = return_i18n_languages();
         if (!$lang) {
             $lang = $language;
         }
         $deflang = return_i18n_default_language();
         $languages = @$lang && $lang != $deflang ? array($lang, $deflang) : array($deflang);
         foreach ($languages as $lang) {
             $fullkey = 'title' . ($lang == $deflang ? '' : '_' . $lang);
             if (isset($gallery[$fullkey])) {
                 $gallery['_title'] = $gallery[$fullkey];
                 break;
             }
         }
         foreach ($gallery['items'] as &$item) {
             foreach ($languages as $lang) {
                 $fullkey = 'title' . ($lang == $deflang ? '' : '_' . $lang);
                 if (isset($item[$fullkey])) {
                     $item['_title'] = $item[$fullkey];
                     break;
                 }
             }
             foreach ($languages as $lang) {
                 $fullkey = 'description' . ($lang == $deflang ? '' : '_' . $lang);
                 if (isset($item[$fullkey])) {
                     $item['_description'] = $item[$fullkey];
                     break;
                 }
             }
         }
     } else {
         $gallery['_title'] = $gallery['title'];
         foreach ($gallery['items'] as &$item) {
             $item['_title'] = $item['title'];
             $item['_description'] = $item['description'];
         }
     }
     return $gallery;
 }
Beispiel #7
0
 public function I18nNavigationItem($item, $classes, $text, $title, $showTitles, $component)
 {
     $this->item = $item;
     $this->classes = $classes;
     $this->text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
     $this->title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
     $this->showTitles = $showTitles;
     $this->component = $component;
     $this->deflang = function_exists('return_i18n_default_language') ? return_i18n_default_language() : null;
 }
Beispiel #8
0
 private function &execute()
 {
     $results = array();
     if (count($this->tags) <= 0 && count($this->words) <= 0) {
         return $results;
     }
     if (!file_exists(GSDATAOTHERPATH . I18N_WORD_INDEX)) {
         create_i18n_search_index();
     }
     $isi18n = function_exists('i18n_init');
     // use multibyte string functions?
     $ismb = function_exists('mb_ereg_replace');
     if ($ismb) {
         mb_regex_encoding('UTF-8');
     }
     // language?
     $defaultLanguage = function_exists('return_i18n_default_language') ? return_i18n_default_language() : '';
     $languages = function_exists('return_i18n_languages') ? $this->language ? array($this->language) : return_i18n_languages() : array($defaultLanguage);
     // scores per id
     $idScores = null;
     $tagIds = array();
     if ($this->tags && count($this->tags) > 0) {
         for ($i = 0; $i < count($this->tags); $i++) {
             if ($ismb) {
                 $this->tags[$i] = mb_ereg_replace("[^\\w]", "_", mb_strtolower(trim($this->tags[$i]), 'UTF-8'));
             } else {
                 $this->tags[$i] = preg_replace("/[^\\w]/", "_", strtolower(trim($this->tags[$i])));
             }
             $tagIds[$this->tags[$i]] = array();
         }
         $f = fopen(GSDATAOTHERPATH . I18N_TAG_INDEX, "r");
         while (($line = fgets($f)) !== false) {
             foreach ($this->tags as $tag) {
                 if (strncmp($line, $tag . ' ', strlen($tag) + 1) == 0) {
                     $fullids = preg_split("/\\s+/", trim($line));
                     unset($fullids[0]);
                     foreach ($fullids as $fullid) {
                         $tagIds[$tag][$fullid] = 1;
                     }
                 }
             }
         }
         fclose($f);
         foreach ($this->tags as $tag) {
             if ($idScores === null) {
                 $idScores = $tagIds[$tag];
             } else {
                 $idScores = array_intersect_key($idScores, $tagIds[$tag]);
             }
         }
     }
     if ($this->words && count($this->words) > 0) {
         $wordIds = array();
         for ($i = 0; $i < count($this->words); $i++) {
             if ($ismb) {
                 $this->words[$i] = mb_strtolower(trim($this->words[$i]), 'UTF-8');
             } else {
                 $this->words[$i] = strtolower(trim($this->words[$i]));
             }
             $wordIds[$this->words[$i]] = array();
         }
         $f = fopen(GSDATAOTHERPATH . I18N_WORD_INDEX, "r");
         while (($line = fgets($f)) !== false) {
             foreach ($this->words as $word) {
                 if ($this->is_word($line, $word, $ismb)) {
                     $fullidAndScores = preg_split("/\\s+/", trim($line));
                     unset($fullidAndScores[0]);
                     foreach ($fullidAndScores as $fullidAndScore) {
                         $pos = strrpos($fullidAndScore, ":");
                         $score = (int) substr($fullidAndScore, $pos + 1);
                         $fullid = substr($fullidAndScore, 0, $pos);
                         if (isset($wordIds[$word][$fullid])) {
                             $wordIds[$word][$fullid] += $score;
                         } else {
                             if ($idScores == null || isset($idScores[$fullid])) {
                                 $wordIds[$word][$fullid] = $score;
                             }
                         }
                     }
                 }
             }
         }
         fclose($f);
         foreach ($this->words as $word) {
             if ($idScores === null) {
                 $idScores = $wordIds[$word];
             } else {
                 $idScores = array_intersect_key($idScores, $wordIds[$word]);
                 foreach ($idScores as $fullid => $score) {
                     $idScores[$fullid] = $score * $wordIds[$word][$fullid];
                 }
             }
         }
     }
     $filteredresults = array();
     if ($idScores && count($idScores) > 0) {
         $idPubDates = array();
         $idCreDates = array();
         $f = fopen(GSDATAOTHERPATH . I18N_DATE_INDEX, "r");
         while (($line = fgets($f)) !== false) {
             $items = preg_split("/\\s+/", trim($line));
             $fullid = $items[0];
             if (count($items) >= 2 && isset($idScores[$fullid])) {
                 $idPubDates[$fullid] = (int) $items[1];
                 $idCreDates[$fullid] = count($items) >= 3 ? (int) $items[2] : (int) $items[1];
             }
         }
         fclose($f);
         foreach ($idScores as $fullid => $score) {
             if ($isi18n) {
                 $pos = strrpos($fullid, "_");
                 $language = $pos !== false ? substr($fullid, $pos + 1) : $defaultLanguage;
                 $id = $pos !== false ? substr($fullid, 0, $pos) : $fullid;
             } else {
                 $language = '';
                 $id = $fullid;
             }
             if (in_array($language, $languages)) {
                 // ignore language, if not default and not requested by user
                 if (substr($id, 0, 1) == '#') {
                     $ispage = false;
                     $id = substr($id, 1);
                 } else {
                     $ispage = true;
                 }
                 if ($ispage) {
                     $results[] = new I18nSearchResultPage($id, $language, $idCreDates[$fullid], $idPubDates[$fullid], $idScores[$fullid]);
                 } else {
                     global $filters;
                     $item = null;
                     foreach ($filters as $filter) {
                         if ($filter['filter'] == I18N_FILTER_SEARCH_ITEM) {
                             $item = call_user_func_array($filter['function'], array($id, $language, $idCreDates[$fullid], $idPubDates[$fullid], $idScores[$fullid]));
                             if ($item) {
                                 break;
                             }
                         }
                     }
                     $results[] = $item ? $item : new I18nSearchResultItem($id, $language, $idCreDates[$fullid], $idPubDates[$fullid], $idScores[$fullid]);
                 }
             }
         }
         foreach ($results as $item) {
             global $filters;
             $vetoed = false;
             foreach ($filters as $filter) {
                 if ($filter['filter'] == I18N_FILTER_VETO_SEARCH_ITEM) {
                     if (call_user_func_array($filter['function'], array($item))) {
                         $vetoed = true;
                         break;
                     }
                 }
             }
             if (!$vetoed) {
                 $filteredresults[] = $item;
             }
         }
         switch ($this->sort_field) {
             case 'url':
                 usort($filteredresults, array($this, 'compare_url'));
                 break;
             case 'date':
                 usort($filteredresults, array($this, 'compare_date'));
                 break;
             case 'created':
                 usort($filteredresults, array($this, 'compare_created'));
                 break;
             case 'score':
                 usort($filteredresults, array($this, 'compare_score'));
                 break;
             default:
                 usort($filteredresults, array($this, 'compare_field'));
         }
         if ($this->sort_order == '-') {
             $filteredresults = array_reverse($filteredresults);
         }
     }
     return $filteredresults;
 }
Beispiel #9
0
function i18n_load_texts($plugin)
{
    global $LANG, $language;
    if (basename($_SERVER['PHP_SELF']) == 'index.php') {
        // frontend language with I18N plugin is always two characters long
        i18n_merge($plugin, $language) || i18n_merge($plugin, return_i18n_default_language()) || i18n_merge($plugin, 'en');
    } else {
        i18n_merge($plugin, $LANG) || strlen($LANG) > 2 && i18n_merge($plugin, substr($LANG, 0, 2)) || i18n_merge($plugin, 'en_US') || i18n_merge($plugin, 'en');
    }
}
Beispiel #10
0
 public static function index()
 {
     if (!self::$instance) {
         self::$instance = new I18nSearchIndexer();
         self::$ismb = function_exists('mb_ereg_search');
         if (self::$ismb) {
             mb_regex_encoding('UTF-8');
         }
         self::$isi18n = function_exists('i18n_init');
         self::$defaultLanguage = function_exists('return_i18n_default_language') ? return_i18n_default_language() : '';
     }
     self::$instance->indexPages();
     exec_action(I18N_ACTION_INDEX);
     self::$instance->processTags();
     self::$instance->save();
 }
Beispiel #11
0
$name ? i18n('i18n_gallery/EDIT_HEADER') : i18n('i18n_gallery/CREATE_HEADER');
?>
</h3>

		<div class="edit-nav" >
      <p>
<?php 
if (count($languages) > 0) {
    ?>
        <?php 
    i18n('i18n_gallery/LANGUAGE');
    ?>
 &nbsp;
        <select name="gallerylang" class="text" id="gallerylang" style="width:auto;float:none;">
          <?php 
    echo '<option value="" selected="selected">' . return_i18n_default_language() . '</option>';
    ?>
          <?php 
    foreach ($languages as $language) {
        echo '<option>' . $language . '</option>';
    }
    ?>
        </select>
<?php 
}
if (@$name) {
    ?>
  		  <a href="<?php 
    echo $viewlink;
    ?>
" target="_blank"><?php 
Beispiel #12
0
$showTags = array_key_exists('showTags', $params) ? $params['showTags'] : true;
$minTagSizePercent = array_key_exists('minTagSize', $params) ? (int) $params['minTagSize'] : 100;
$maxTagSizePercent = array_key_exists('maxTagSize', $params) ? (int) $params['maxTagSize'] : 250;
$addTags = array_key_exists('addTags', $params) ? $params['addTags'] : '';
$goText = @$i18n['GO'];
$is_ajax = !isset($params['ajax']) || $params['ajax'];
$live = $is_ajax && isset($params['live']) && $params['live'];
$url = function_exists('find_i18n_url') ? find_i18n_url($slug, null) : find_url($slug, null);
$method = strpos($url, '?') !== false ? 'POST' : 'GET';
// with GET the parameters are not submitted!
$language = isset($params['lang']) ? $params['lang'] : null;
$placeholderText = @$params['PLACEHOLDER'];
// languages
$reqlangs = null;
if (function_exists('return_i18n_languages')) {
    $deflang = return_i18n_default_language();
    $languages = $language ? array($language) : return_i18n_languages();
    foreach ($languages as $lang) {
        if ($lang == $deflang) {
            $lang = '';
        }
        $reqlangs = $reqlangs === null ? $lang : $reqlangs . ',' . $lang;
    }
}
// mark
$mark = false;
if (file_exists(GSDATAOTHERPATH . I18N_SEARCH_SETTINGS_FILE)) {
    $data = getXML(GSDATAOTHERPATH . I18N_SEARCH_SETTINGS_FILE);
    $mark = true && $data->mark;
}
?>
Beispiel #13
0
<?php

global $id, $parent;
if (isset($_GET['id'])) {
    if (($pos = strrpos($id, '_')) !== false) {
        $viewlink = find_i18n_url(substr($id, 0, $pos), (string) $parent, substr($id, $pos + 1));
    } else {
        $viewlink = find_i18n_url($id, (string) $parent, return_i18n_default_language());
    }
}
?>
<script type="text/javascript">
  // <![CDATA[
  $(function() {
<?php 
if (isset($_GET['id'])) {
    ?>
    $('.edit-nav a[target=_blank]').attr('href', <?php 
    echo json_encode($viewlink);
    ?>
);
<?php 
}
if (!$id && isset($_GET['newid'])) {
    ?>
    $('#post-id').val(<?php 
    echo json_encode($_GET['newid']);
    ?>
);
<?php 
}
Beispiel #14
0
<?php

if (function_exists('find_i18n_url')) {
    $slug = isset($_GET['id']) ? $_GET['id'] : (isset($_GET['newid']) ? $_GET['newid'] : '');
    $pos = strpos($slug, '_');
    $lang = $pos !== false ? substr($slug, $pos + 1) : null;
    $structure = I18nNavigationFrontend::getPageStructure(null, false, null, $lang);
    $pages = array();
    $nbsp = html_entity_decode('&nbsp;', ENT_QUOTES, 'UTF-8');
    $lfloor = html_entity_decode('&lfloor;', ENT_QUOTES, 'UTF-8');
    foreach ($structure as $page) {
        $text = ($page['level'] > 0 ? str_repeat($nbsp, 5 * $page['level'] - 2) . $lfloor . $nbsp : '') . cl($page['title']);
        $link = find_i18n_url($page['url'], $page['parent'], '(' . ($lang ? $lang : return_i18n_default_language()) . ')');
        $pages[] = array($text, $link);
    }
    ?>
<script type="text/javascript">
  //<![CDATA[
  // modify existing Link dialog
  CKEDITOR.on( 'dialogDefinition', function( ev ) {
    if ((ev.editor != editor) || (ev.data.name != 'link')) return;

    var definition = ev.data.definition;
    var infoTab = definition.getContents('info');
    
    for (var i=0; i<infoTab.elements.length; i++) {
      var element = infoTab.elements[i];
      if ('id' in element && element.id == 'localPageOptions') {
        element.children[0].items = <?php 
    echo json_encode($pages);
    ?>
Beispiel #15
0
 public function saveRates()
 {
     $data = new \SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><rates></rates>');
     $ncat = isset($_POST['ncat']) ? $_POST['ncat'] : 0;
     for ($catId = 0; $catId < $ncat; $catId++) {
         $catname = self::CATEGORY_NAME . $catId;
         if (!isset($_POST[$catname]) || empty($_POST[$catname])) {
             continue;
         }
         $category = $data->addChild("category");
         // Add category name
         $category->addChild("name", $_POST[$catname]);
         // Iterate on category prices
         for ($pos = 0; isset($_POST[self::CATEGORY_PRICE . $catId . "_" . $pos]); $pos++) {
             $category->addChild("price", $_POST[self::CATEGORY_PRICE . $catId . "_" . $pos]);
         }
         // Iterate on rates
         $nrate = isset($_POST['nrate_' . $catId]) ? $_POST['nrate_' . $catId] : 0;
         for ($rateId = 0; $rateId < $nrate; $rateId++) {
             $ratename = self::RATE_NAME . $catId . "_" . $rateId;
             if (!isset($_POST[$ratename]) || empty($_POST[$ratename])) {
                 continue;
             }
             $rate = $category->addChild("rate");
             $rate->addChild("name", $_POST[$ratename]);
             // Iterate on category prices
             for ($pos = 0; isset($_POST[self::RATE_PRICE . $catId . '_' . $rateId . '_' . $pos]); $pos++) {
                 $rate->addChild("price", $_POST[self::RATE_PRICE . $catId . '_' . $rateId . '_' . $pos]);
             }
         }
     }
     $lang = isset($_POST['lang']) ? $_POST['lang'] : return_i18n_default_language();
     if (!XMLsave($data, GSDATAPATH . RATES_DIR . RATES_FILENAME . '_' . $lang . '.xml')) {
         return false;
     }
     if ($lang != $this->cur_lang) {
         $this->cur_lang = $lang;
     }
     return true;
 }
Beispiel #16
0
<?php

$slug = @$params['slug'];
$is_ajax = !isset($params['ajax']) || $params['ajax'];
$addtags = isset($params['addTags']) ? preg_split('/\\s+/', trim($params['addTags'])) : null;
$reqtags = trim(@$_REQUEST['tags']) ? preg_split('/\\s+/', trim($_REQUEST['tags'])) : null;
$language = isset($params['lang']) ? $params['lang'] : null;
// languages
$isi18n = function_exists('return_i18n_languages');
$defaultLanguage = $isi18n ? return_i18n_default_language() : '';
$languages = $isi18n ? $language ? array($language) : return_i18n_languages() : null;
// read tag file
if (!file_exists(GSDATAOTHERPATH . I18N_WORD_INDEX)) {
    create_i18n_search_index();
}
$alltags = array();
$f = fopen(GSDATAOTHERPATH . I18N_TAG_INDEX, "r");
while (($line = fgets($f)) !== false) {
    $items = preg_split("/\\s+/", trim($line));
    $tag = array_shift($items);
    if ($languages) {
        // filter items
        $filteredItems = array();
        foreach ($items as $item) {
            $pos = strrpos($item, '_');
            $lang = $pos !== false ? substr($item, $pos + 1) : $defaultLanguage;
            if (in_array($lang, $languages)) {
                $filteredItems[] = $item;
            }
        }
        if (count($filteredItems) > 0) {