Ejemplo n.º 1
0
 /**
  * @param PosterInterface $parent
  * @param PosterInterface $poster
  * @param                 $forAction
  * @param int             $relationType
  * @param int             $relationId
  *
  * @return string
  */
 public function getRelationOptionForSelect(PosterInterface $parent = null, PosterInterface $poster = null, $forAction, $relationType = null, $relationId = null)
 {
     if (empty($parent) or empty($poster)) {
         return false;
     }
     if ($poster->getUserId() != $parent->getUserId()) {
         return false;
     }
     if (null === $relationId || null === $relationType) {
         list($relationType, $relationId) = $parent->getPrivacy($forAction);
     }
     if (null == $relationId) {
         $relationType = RELATION_TYPE_ANYONE;
         $relationId = RELATION_TYPE_ANYONE;
     }
     $parentType = $parent->getType();
     $msgId = null;
     if ($relationType < RELATION_TYPE_CUSTOM) {
         return ['type' => $relationType, 'value' => $relationId, 'label' => app()->text('relation.relation_type_' . $parentType . '_' . $relationType)];
     }
     $item = app()->relation()->findById($relationId);
     if (!$item instanceof Relation) {
         return ['type' => RELATION_TYPE_ANYONE, 'value' => RELATION_TYPE_ANYONE, 'label' => 'relation.relation_type_public'];
     }
     return ['type' => $item->getRelationType(), 'value' => $item->getRelationId(), 'label' => strtr($item->getRelationName(), ['$parent' => $parent->getTitle()])];
 }
Ejemplo n.º 2
0
 /**
  * @param \Kendo\Content\PosterInterface|\Kendo\Content\ContentInterface $item
  *
  * @return string
  */
 public function toLink($item)
 {
     if (!$item) {
         return '';
     }
     return '<a href="' . $item->toHref() . '">' . $item->getTitle() . '</a>';
 }