/**
  * Resolves value for related attribute
  * @param string $attribute
  * @param string $relatedAttribute
  * @return string
  */
 protected function resolveDisplayedValueForRelatedAttribute($attribute, $relatedAttribute)
 {
     if ($this->element instanceof LeadStateDropDownElement) {
         $label = ContactsUtil::resolveStateLabelByLanguage($this->model->{$attribute}, Yii::app()->language);
         return Yii::app()->format->text($label);
     }
     return $this->model->{$attribute}->{$relatedAttribute};
 }
 /**
  * @depends testGetContactStateLabelsKeyedByLanguageAndOrder
  */
 public function testResolveStateLabelByLanguage()
 {
     $states = ContactState::getByName('Qualified');
     $this->assertEquals('Qualified', ContactsUtil::resolveStateLabelByLanguage($states[0], 'en'));
     $this->assertEquals('QualifiedFr', ContactsUtil::resolveStateLabelByLanguage($states[0], 'fr'));
     $this->assertEquals('QualifiedDe', ContactsUtil::resolveStateLabelByLanguage($states[0], 'de'));
 }
 /**
  * Get an array of states from the starting state onwards, id/translated label pairings of the
  * existing contact states ordered by order.
  * @param string $language
  * @return array
  */
 public static function getLeadStateDataFromStartingStateLabelByLanguage($language)
 {
     assert('is_string($language)');
     $leadStatesData = array();
     $states = ContactState::getAll('order');
     $startingState = ContactsUtil::getStartingStateId();
     foreach ($states as $state) {
         if ($startingState == $state->id) {
             break;
         }
         $state->name = ContactsUtil::resolveStateLabelByLanguage($state, $language);
         $leadStatesData[] = $state;
     }
     return $leadStatesData;
 }
 /**
  * Renders the noneditable dropdown content.
  * Takes the model attribute value and converts it into the proper display value
  * based on the corresponding dropdown display label.
  * @return A string containing the element's content.
  */
 protected function renderControlNonEditable()
 {
     $label = ContactsUtil::resolveStateLabelByLanguage($this->model->{$this->attribute}, Yii::app()->language);
     return Yii::app()->format->text($label);
 }