/**
  * @return string
  */
 public function generate()
 {
     // Backend
     if (TL_MODE == 'BE') {
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['member_rating'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     // Set the item from the auto_item parameter
     if ($GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) {
         \Input::setGet('member', \Input::get('auto_item'));
     }
     // activate comment by token via url
     if (strlen(\Input::get('activation_token'))) {
         $this->activateOrDelete();
         exit;
     }
     // set the ratedUser var
     $this->ratedUser = \MemberModel::findByPk(\Input::get('member'));
     if ($this->ratedUser === null) {
         return '';
     }
     // overwrite default template
     if ($this->memberRatingDetailTemplate != '') {
         $this->strTemplate = $this->memberRatingDetailTemplate;
     }
     return parent::generate();
 }
Ejemplo n.º 2
0
 /**
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['member_rating'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     // overwrite default template
     if ($this->memberRatingListTemplate != '') {
         $this->strTemplate = $this->memberRatingListTemplate;
     }
     return parent::generate();
 }
 /**
  * add member to a certain group that is assigned to a certain score
  */
 public function addGroupMembership()
 {
     $arrayGrades = MemberRating::getGradeLabelingArray();
     if (!count($arrayGrades) > 0) {
         return;
     }
     krsort($arrayGrades);
     $objMember = \MemberModel::findAll();
     while ($objMember->next()) {
         foreach ($arrayGrades as $grade) {
             $score = MemberRating::getScore($objMember->id);
             if ($score >= $grade['score']) {
                 if (count($grade['groups']) > 0) {
                     MemberRating::addToGroup($objMember->id, $grade['groups']);
                 }
                 break;
             }
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @param $score
  * @return array
  */
 public static function getGrade($id, $key = 'label')
 {
     $score = self::getScore($id);
     if ($score == '0') {
         $score = 0;
     }
     $arrReturn = array();
     $arrayGrades = MemberRating::getGradeLabelingArray();
     krsort($arrayGrades);
     $arrayGrades = count($arrayGrades) ? $arrayGrades : false;
     if ($arrayGrades) {
         foreach ($arrayGrades as $arrGrade) {
             if ($score >= $arrGrade['score']) {
                 $arrReturn['label'] = $arrGrade['label'];
                 $src = self::getImageDir() . '/levelicons/' . $arrGrade['icon'];
                 if (is_file(TL_ROOT . '/' . $src)) {
                     $objFile = new \File($src, true);
                     if ($objFile !== NULL) {
                         if ($objFile->isGdImage) {
                             $size = sprintf('width="%s" height="%s"', $objFile->width, $objFile->height);
                             $arrReturn['icon'] = sprintf('<img src="%s" %s alt="%s" title="%s" class="%s">', TL_FILES_URL . $src, $size, 'grade icon', specialchars($arrGrade['label']), 'gradeIcon');
                         }
                     }
                 }
                 break;
             }
         }
     }
     return $arrReturn[$key] ? $arrReturn[$key] : NULL;
 }