Exemplo n.º 1
0
 /**
  * Generates a link to the view of the object.
  *
  * @return string a link to the model
  */
 public function getUrlLink($htmlOptions = array())
 {
     $name = $this->owner->hasAttribute('name') || $this->owner->canGetProperty('name') || property_exists($this->owner, 'name') ? $this->owner->name : '';
     if (trim($name) == '') {
         if ($this->owner->hasAttribute('fileName')) {
             // for media models
             $name = $this->owner->fileName;
         }
         if (trim($name) == '') {
             $name = $this->owner->hasAttribute('id') ? '#' . $this->owner->id : '';
         }
     }
     $url = $this->url;
     if ($this->owner instanceof Contacts) {
         return CHtml::link('<span>' . X2Html::encode($name) . '</span>', $url, array_merge(array('class' => 'contact-name'), $htmlOptions));
     } else {
         return CHtml::link('<span>' . X2Html::encode($name) . '</span>', $url, $htmlOptions);
     }
 }
Exemplo n.º 2
0
 /**
  * Generates a link to the view of the object.
  *
  * @return string a link to the model
  */
 public function getUrlLink($htmlOptions = array())
 {
     if (Yii::app()->params->isMobileApp && !self::isMobileLinkableRecordType(get_class($this->owner))) {
         return $this->owner->renderAttribute('name');
     }
     $name = $this->owner->hasAttribute('name') || $this->owner->canGetProperty('name') || property_exists($this->owner, 'name') ? $this->owner->name : '';
     if (trim($name) == '') {
         if ($this->owner->hasAttribute('fileName')) {
             // for media models
             $name = $this->owner->fileName;
         }
         if (trim($name) == '') {
             $name = $this->owner->hasAttribute('id') ? '#' . $this->owner->id : '';
         }
     }
     $url = $this->url;
     if ($this->owner instanceof Contacts) {
         return CHtml::link('<span>' . X2Html::encode($name) . '</span>', $url, array_merge(array('class' => 'contact-name'), $htmlOptions));
     } else {
         return CHtml::link('<span>' . X2Html::encode($name) . '</span>', $url, $htmlOptions);
     }
 }