Exemplo n.º 1
0
 /**
  * parseTemplate hook for articles and events
  *
  * @param \Template $objTempalte
  */
 public function parseTemplate(\Template $objTemplate)
 {
     // check for mod_article template
     if (stripos($objTemplate->getName(), 'mod_article') !== false) {
         // prepare sharebuttons string
         $strSharebuttons = '';
         // get the networks
         $arrNetworks = deserialize($objTemplate->sharebuttons_networks);
         // check if there are any networks
         if ($arrNetworks) {
             // set data
             $networks = $arrNetworks;
             $theme = $objTemplate->sharebuttons_theme;
             $template = $objTemplate->sharebuttons_template;
             $url = $objTemplate->href;
             $title = $objTemplate->title;
             $description = $objTemplate->teaser;
             // create the share buttons
             $strSharebuttons = self::createShareButtons($networks, $theme, $template, $url, $title, $description);
         }
         // set sharebuttons variable
         $objTemplate->sharebuttons = $strSharebuttons;
     } elseif (stripos($objTemplate->getName(), 'event_') === 0) {
         // prepare sharebuttons string
         $strSharebuttons = '';
         // get the calendar
         if (($objCalendar = \CalendarModel::findById($objTemplate->pid)) !== null) {
             // get the networks
             $arrNetworks = deserialize($objCalendar->sharebuttons_networks);
             // check if there are any networks
             if ($arrNetworks) {
                 // set data
                 $networks = $arrNetworks;
                 $theme = $objCalendar->sharebuttons_theme;
                 $template = $objCalendar->sharebuttons_template;
                 $url = $objTemplate->href;
                 $title = $objTemplate->title;
                 $description = $objTemplate->teaser;
                 $image = $objTemplate->singleSRC;
                 // create the share buttons
                 $strSharebuttons = self::createShareButtons($networks, $theme, $template, $url, $title, $description, $image);
             }
         }
         // set sharebuttons variable
         $objTemplate->sharebuttons = $strSharebuttons;
     }
 }