Example #1
0
 /**
  * Add new sitemap item to $items array
  *
  * @param string $loc
  * @param string $lastmod
  * @param string $priority
  * @param string $freq
  * @param array  $images
  * @param string $title
  * @param array $translations
  * @param array $videos
  *
  * @return void
  */
 public function add($loc, $lastmod = null, $priority = null, $freq = null, $images = [], $title = null, $translations = [], $videos = [])
 {
     if ($this->model->getEscaping()) {
         $loc = htmlentities($loc, ENT_XML1);
         if ($title != null) {
             htmlentities($title, ENT_XML1);
         }
         if ($images) {
             foreach ($images as $k => $image) {
                 foreach ($image as $key => $value) {
                     $images[$k][$key] = htmlentities($value, ENT_XML1);
                 }
             }
         }
         if ($translations) {
             foreach ($translations as $k => $translation) {
                 foreach ($translation as $key => $value) {
                     $translations[$k][$key] = htmlentities($value, ENT_XML1);
                 }
             }
         }
         if ($videos) {
             foreach ($videos as $k => $video) {
                 if ($video['title']) {
                     $videos[$k]['title'] = htmlentities($video['title'], ENT_XML1);
                 }
                 if ($video['description']) {
                     $videos[$k]['description'] = htmlentities($video['description'], ENT_XML1);
                 }
             }
         }
     }
     $this->model->setItems(['loc' => $loc, 'lastmod' => $lastmod, 'priority' => $priority, 'freq' => $freq, 'images' => $images, 'title' => $title, 'translations' => $translations, 'videos' => $videos]);
 }
Example #2
0
 /**
  * Add new sitemap item to $items array
  *
  * @param string $loc
  * @param string $lastmod
  * @param string $priority
  * @param string $freq
  * @param array  $images
  * @param string $title
  * @param array $translations
  * @param array $videos
  * @param array $googlenews
  *
  * @return void
  */
 public function add($loc, $lastmod = null, $priority = null, $freq = null, $images = [], $title = null, $translations = [], $videos = [], $googlenews = [])
 {
     if ($this->model->getEscaping()) {
         $loc = htmlentities($loc, ENT_XML1);
         if ($title != null) {
             htmlentities($title, ENT_XML1);
         }
         if ($images) {
             foreach ($images as $k => $image) {
                 foreach ($image as $key => $value) {
                     $images[$k][$key] = htmlentities($value, ENT_XML1);
                 }
             }
         }
         if ($translations) {
             foreach ($translations as $k => $translation) {
                 foreach ($translation as $key => $value) {
                     $translations[$k][$key] = htmlentities($value, ENT_XML1);
                 }
             }
         }
         if ($videos) {
             foreach ($videos as $k => $video) {
                 if ($video['title']) {
                     $videos[$k]['title'] = htmlentities($video['title'], ENT_XML1);
                 }
                 if ($video['description']) {
                     $videos[$k]['description'] = htmlentities($video['description'], ENT_XML1);
                 }
             }
         }
         if ($googlenews) {
             if (isset($googlenews['sitename'])) {
                 $googlenews['sitename'] = htmlentities($googlenews['sitename'], ENT_XML1);
             }
         }
     }
     $googlenews['sitename'] = isset($googlenews['sitename']) ? $googlenews['sitename'] : '';
     $googlenews['language'] = isset($googlenews['language']) ? $googlenews['language'] : 'en';
     $googlenews['publication_date'] = isset($googlenews['publication_date']) ? $googlenews['publication_date'] : date('Y-m-d H:i:s');
     $this->model->setItems(['loc' => $loc, 'lastmod' => $lastmod, 'priority' => $priority, 'freq' => $freq, 'images' => $images, 'title' => $title, 'translations' => $translations, 'videos' => $videos, 'googlenews' => $googlenews]);
 }
Example #3
0
 /**
  * Add new sitemap item to $items array
  *
  * @param string $loc
  * @param string $lastmod
  * @param string $priority
  * @param string $freq
  * @param array  $images
  * @param string $title
  * @param string $translation
  *
  * @return void
  */
 public function add($loc, $lastmod = null, $priority = null, $freq = null, $images = array(), $title = null, $translation = array())
 {
     if ($this->model->getEscaping()) {
         $loc = htmlentities($loc, ENT_XML1);
         if ($title != null) {
             htmlentities($title, ENT_XML1);
         }
         if ($images) {
             foreach ($images as $k => $image) {
                 foreach ($image as $key => $value) {
                     $images[$k][$key] = htmlentities($value, ENT_XML1);
                 }
             }
         }
         if ($translation) {
             foreach ($translation as $key => $value) {
                 $translation[$key] = htmlentities($value, ENT_XML1);
             }
         }
     }
     $this->model->setItems(array('loc' => $loc, 'lastmod' => $lastmod, 'priority' => $priority, 'freq' => $freq, 'images' => $images, 'title' => $title, 'translation' => $translation));
 }
Example #4
0
 /**
  * Add new sitemap one or multiple items to $items array
  *
  * @param array $params
  *
  * @return void
  */
 public function addItem($params = [])
 {
     // if is multidimensional
     if (array_key_exists(1, $params)) {
         foreach ($params as $a) {
             $this->addItem($a);
         }
         return;
     }
     // get params
     foreach ($params as $key => $value) {
         ${$key} = $value;
     }
     // set default values
     if (!isset($loc)) {
         $loc = '/';
     }
     if (!isset($lastmod)) {
         $lastmod = null;
     }
     if (!isset($priority)) {
         $priority = null;
     }
     if (!isset($freq)) {
         $freq = null;
     }
     if (!isset($title)) {
         $title = null;
     }
     if (!isset($images)) {
         $images = [];
     }
     if (!isset($translations)) {
         $translations = [];
     }
     if (!isset($alternates)) {
         $alternates = [];
     }
     if (!isset($videos)) {
         $videos = [];
     }
     if (!isset($googlenews)) {
         $googlenews = [];
     }
     // escaping
     if ($this->model->getEscaping()) {
         $loc = htmlentities($loc, ENT_XML1);
         if ($title != null) {
             htmlentities($title, ENT_XML1);
         }
         if ($images) {
             foreach ($images as $k => $image) {
                 foreach ($image as $key => $value) {
                     $images[$k][$key] = htmlentities($value, ENT_XML1);
                 }
             }
         }
         if ($translations) {
             foreach ($translations as $k => $translation) {
                 foreach ($translation as $key => $value) {
                     $translations[$k][$key] = htmlentities($value, ENT_XML1);
                 }
             }
         }
         if ($alternates) {
             foreach ($alternates as $k => $alternate) {
                 foreach ($alternate as $key => $value) {
                     $alternates[$k][$key] = htmlentities($value, ENT_XML1);
                 }
             }
         }
         if ($videos) {
             foreach ($videos as $k => $video) {
                 if ($video['title']) {
                     $videos[$k]['title'] = htmlentities($video['title'], ENT_XML1);
                 }
                 if ($video['description']) {
                     $videos[$k]['description'] = htmlentities($video['description'], ENT_XML1);
                 }
             }
         }
         if ($googlenews) {
             if (isset($googlenews['sitename'])) {
                 $googlenews['sitename'] = htmlentities($googlenews['sitename'], ENT_XML1);
             }
         }
     }
     $googlenews['sitename'] = isset($googlenews['sitename']) ? $googlenews['sitename'] : '';
     $googlenews['language'] = isset($googlenews['language']) ? $googlenews['language'] : 'en';
     $googlenews['publication_date'] = isset($googlenews['publication_date']) ? $googlenews['publication_date'] : date('Y-m-d H:i:s');
     $this->model->setItems(['loc' => $loc, 'lastmod' => $lastmod, 'priority' => $priority, 'freq' => $freq, 'images' => $images, 'title' => $title, 'translations' => $translations, 'videos' => $videos, 'googlenews' => $googlenews, 'alternates' => $alternates]);
 }