Example #1
0
 /**
  * Returns an array with GoogleSitemapGeneratorPage objects which is generated from POST values
  *
  * @since 4.0
  * @see GoogleSitemapGeneratorPage
  * @return array An array with GoogleSitemapGeneratorPage objects
  */
 public function HtmlApplyPages()
 {
     // Array with all page URLs
     $pages_ur = !isset($_POST["sm_pages_ur"]) || !is_array($_POST["sm_pages_ur"]) ? array() : $_POST["sm_pages_ur"];
     //Array with all priorities
     $pages_pr = !isset($_POST["sm_pages_pr"]) || !is_array($_POST["sm_pages_pr"]) ? array() : $_POST["sm_pages_pr"];
     //Array with all change frequencies
     $pages_cf = !isset($_POST["sm_pages_cf"]) || !is_array($_POST["sm_pages_cf"]) ? array() : $_POST["sm_pages_cf"];
     //Array with all lastmods
     $pages_lm = !isset($_POST["sm_pages_lm"]) || !is_array($_POST["sm_pages_lm"]) ? array() : $_POST["sm_pages_lm"];
     //Array where the new pages are stored
     $pages = array();
     //Loop through all defined pages and set their properties into an object
     if (isset($_POST["sm_pages_mark"]) && is_array($_POST["sm_pages_mark"])) {
         for ($i = 0; $i < count($_POST["sm_pages_mark"]); $i++) {
             //Create new object
             $p = new GoogleSitemapGeneratorPage();
             if (substr($pages_ur[$i], 0, 4) == "www.") {
                 $pages_ur[$i] = "http://" . $pages_ur[$i];
             }
             $p->SetUrl($pages_ur[$i]);
             $p->SetProprity($pages_pr[$i]);
             $p->SetChangeFreq($pages_cf[$i]);
             //Try to parse last modified, if -1 (note ===) automatic will be used (0)
             $lm = !empty($pages_lm[$i]) ? strtotime($pages_lm[$i], time()) : -1;
             if ($lm === -1) {
                 $p->setLastMod(0);
             } else {
                 $p->setLastMod($lm);
             }
             //Add it to the array
             array_push($pages, $p);
         }
     }
     return $pages;
 }
 /**
  * This function integrates with google sitemap generator, and adds for each viewable language, the rest of the languages url
  * Also - priority is reduced by 0.2
  * And this requires the following line at the sitemap-core.php, add-url function (line 1509 at version 3.2.4)
  * do_action('sm_addurl', $page);
  * @param GoogleSitemapGeneratorPage $sm_page Object containing the page information
  */
 function add_sm_transposh_urls($sm_page)
 {
     tp_logger("in sitemap add url: " . $sm_page->GetUrl() . " " . $sm_page->GetPriority(), 4);
     $sm_page = clone $sm_page;
     // we need the generator object (we know it must exist...)
     $generatorObject =& GoogleSitemapGenerator::GetInstance();
     // we reduce the priorty by 0.2, but not below zero
     $sm_page->SetProprity(max($sm_page->GetPriority() - 0.2, 0));
     /* <xhtml:link 
        rel="alternate"
        hreflang="de"
        href="http://www.example.com/de" /> */
     $viewable_langs = explode(',', $this->transposh->options->viewable_languages);
     $orig_url = $sm_page->GetUrl();
     foreach ($viewable_langs as $lang) {
         if (!$this->transposh->options->is_default_language($lang)) {
             $newloc = $orig_url;
             if ($this->transposh->options->enable_url_translate) {
                 $newloc = transposh_utils::translate_url($newloc, $this->transposh->home_url, $lang, array(&$this->transposh->database, 'fetch_translation'));
             }
             $newloc = transposh_utils::rewrite_url_lang_param($newloc, $this->transposh->home_url, $this->transposh->enable_permalinks_rewrite, $lang, false);
             $sm_page->SetUrl($newloc);
             $generatorObject->AddElement($sm_page);
         }
     }
 }