Exemplo n.º 1
0
 public function setProductMetaData()
 {
     $this->onExecuteBefore('setProductMetaData');
     $document = JFactory::getDocument();
     $config = KSSystem::getSeoTitlesConfig('product', 'meta');
     $metatitle = null;
     $metadescription = null;
     $metakeywords = null;
     if (empty($this->_product->metatitle)) {
         $metatitle = $this->_product->title;
     } else {
         $metatitle = $this->_product->metatitle;
     }
     if (empty($this->_product->metadescription)) {
         if ($config->description->flag == 1) {
             if ($config->description->type == 'seo-type-mini-description') {
                 $metadescription = strip_tags($this->_product->introcontent);
             } elseif ($config->description->type == 'seo-type-description') {
                 $metadescription = strip_tags($this->_product->content);
             }
             $metadescription = mb_substr($metadescription, 0, $config->description->symbols);
         }
     } else {
         $metadescription = $this->_product->metadescription;
     }
     if (empty($this->_product->metakeywords)) {
         if ($config->keywords->flag == 1) {
             if ($config->keywords->type == 'seo-type-properties-and-values') {
                 $properties = array();
                 foreach ($this->_product->properties as $property) {
                     $values = array();
                     if (!empty($property->values)) {
                         foreach ($property->values as $value) {
                             if (!empty($value->title)) {
                                 $values[] = $value->title;
                             }
                         }
                         if (!empty($value->title)) {
                             $values[] = $value->title;
                         }
                     }
                     if (count($values) > 0) {
                         $properties[] = $property->title . ' - ' . implode(',', $values);
                     }
                 }
                 if (count($properties) > 0) {
                     $metakeywords = implode(';', $properties);
                 }
             } elseif ($config->keywords->type == 'seo-type-tag') {
                 $metakeywords = strip_tags($this->_product->tag);
             }
         }
     } else {
         $metakeywords = $this->_product->metakeywords;
     }
     if (!empty($metatitle)) {
         $document->setMetaData('title', $metatitle);
     }
     if (!empty($metadescription)) {
         $document->setMetaData('description', $metadescription);
     }
     if (!empty($metakeywords)) {
         $document->setMetaData('keywords', $metakeywords);
     }
     $this->onExecuteAfter('setProductMetaData', array(&$this));
 }
Exemplo n.º 2
0
 /**
  * KsenMartModelcatalog::setCountryMetaData()
  * 
  * @return
  */
 public function setCountryMetaData()
 {
     $this->onExecuteBefore('setCountryMetaData');
     $document = JFactory::getDocument();
     $metatitle = '';
     $metadescription = '';
     $metakeywords = '';
     $country = $this->getCountry();
     $config = KSSystem::getSeoTitlesConfig('country', 'meta');
     if (empty($country->metatitle)) {
         $metatitle = $country->title;
     } else {
         $metatitle = $country->metatitle;
     }
     if (empty($country->metadescription)) {
         if ($config->description->flag == 1) {
             if ($config->description->type == 'seo-type-mini-description') {
                 $metadescription = strip_tags($country->introcontent);
             } elseif ($config->description->type == 'seo-type-description') {
                 $metadescription = strip_tags($country->content);
             }
             $metadescription = mb_substr($metadescription, 0, $config->description->symbols);
         }
     } else {
         $metadescription = $country->metadescription;
     }
     if ($country->metakeywords == '') {
         if ($config->keywords->flag == 1) {
             if ($config->keywords->type == 'seo-type-title') {
                 $metakeywords = strip_tags($country->title);
             }
         }
     } else {
         $metakeywords = $country->metakeywords;
     }
     if (!empty($metatitle)) {
         $document->setMetaData('title', $metatitle);
     }
     if (!empty($metadescription)) {
         $document->setMetaData('description', $metadescription);
     }
     if (!empty($metakeywords)) {
         $document->setMetaData('keywords', $metakeywords);
     }
     $this->onExecuteAfter('setCountryMetaData', array(&$this));
     return true;
 }