• 16-01-2019, 12:23:19
    #1
    Merhaba arkadaşlar sitenin çeşitli yerlerine kodu eklemeyi denesemde ne yazık ki görmedi.. En son bulduğum şu dosyada olacağını tahmin ediyorum fakat kodu nereye ekleyeceğimi nasıl bir fonksiyon açacağımı bilemiyorum.

    Yardımlarınız için şimdiden teşekkür ederim.

    <?php
    
    /*
     * This file is part of Flarum.
     *
     * (c) Toby Zerner <toby.zerner@gmail.com>
     *
     * For the full copyright and license information, please view the LICENSE
     * file that was distributed with this source code.
     */
    
    namespace Flarum\Api\Serializer;
    
    use Flarum\Post\CommentPost;
    use Flarum\User\Gate;
    
    class PostSerializer extends BasicPostSerializer
    {
        /**
         * @var \Flarum\User\Gate
         */
        protected $gate;
    
        /**
         * @param \Flarum\User\Gate $gate
         */
        public function __construct(Gate $gate)
        {
            $this->gate = $gate;
        }
    
        /**
         * {@inheritdoc}
         */
        protected function getDefaultAttributes($post)
        {
            $attributes = parent::getDefaultAttributes($post);
    
            unset($attributes['content']);
    
            $gate = $this->gate->forUser($this->actor);
    
            $canEdit = $gate->allows('edit', $post);
    
            if ($post instanceof CommentPost) {
                $attributes['contentHtml'] = $post->content_html;
    
                if ($canEdit) {
                    $attributes['content'] = $post->content;
                }
                if ($gate->allows('viewIps', $post)) {
                    $attributes['ipAddress'] = $post->ip_address;
                }
            } else {
                $attributes['content'] = $post->content;
            }
    
            if ($post->edited_at) {
                $attributes['editedAt'] = $this->formatDate($post->edited_at);
            }
    
            if ($post->hidden_at) {
                $attributes['isHidden'] = true;
                $attributes['hiddenAt'] = $this->formatDate($post->hidden_at);
            }
    
            $attributes += [
                'canEdit'   => $canEdit,
                'canDelete' => $gate->allows('delete', $post),
                'canHide'   => $gate->allows('hide', $post)
            ];
    
            return $attributes;
        }
    
        /**
         * @return \Tobscure\JsonApi\Relationship
         */
        protected function user($post)
        {
            return $this->hasOne($post, UserSerializer::class);
        }
    
        /**
         * @return \Tobscure\JsonApi\Relationship
         */
        protected function discussion($post)
        {
            return $this->hasOne($post, BasicDiscussionSerializer::class);
        }
    
        /**
         * @return \Tobscure\JsonApi\Relationship
         */
        protected function editedUser($post)
        {
            return $this->hasOne($post, BasicUserSerializer::class);
        }
    
        /**
         * @return \Tobscure\JsonApi\Relationship
         */
        protected function hiddenUser($post)
        {
            return $this->hasOne($post, BasicUserSerializer::class);
        }
    }
  • 16-01-2019, 12:25:43
    #2
    dudbox adlı üyeden alıntı: mesajı görüntüle
    Merhaba arkadaşlar sitenin çeşitli yerlerine kodu eklemeyi denesemde ne yazık ki görmedi.. En son bulduğum şu dosyada olacağını tahmin ediyorum fakat kodu nereye ekleyeceğimi nasıl bir fonksiyon açacağımı bilemiyorum.

    Yardımlarınız için şimdiden teşekkür ederim.

    <?php
    
    /*
     * This file is part of Flarum.
     *
     * (c) Toby Zerner <toby.zerner@gmail.com>
     *
     * For the full copyright and license information, please view the LICENSE
     * file that was distributed with this source code.
     */
    
    namespace Flarum\Api\Serializer;
    
    use Flarum\Post\CommentPost;
    use Flarum\User\Gate;
    
    class PostSerializer extends BasicPostSerializer
    {
        /**
         * @var \Flarum\User\Gate
         */
        protected $gate;
    
        /**
         * @param \Flarum\User\Gate $gate
         */
        public function __construct(Gate $gate)
        {
            $this->gate = $gate;
        }
    
        /**
         * {@inheritdoc}
         */
        protected function getDefaultAttributes($post)
        {
            $attributes = parent::getDefaultAttributes($post);
    
            unset($attributes['content']);
    
            $gate = $this->gate->forUser($this->actor);
    
            $canEdit = $gate->allows('edit', $post);
    
            if ($post instanceof CommentPost) {
                $attributes['contentHtml'] = $post->content_html;
    
                if ($canEdit) {
                    $attributes['content'] = $post->content;
                }
                if ($gate->allows('viewIps', $post)) {
                    $attributes['ipAddress'] = $post->ip_address;
                }
            } else {
                $attributes['content'] = $post->content;
            }
    
            if ($post->edited_at) {
                $attributes['editedAt'] = $this->formatDate($post->edited_at);
            }
    
            if ($post->hidden_at) {
                $attributes['isHidden'] = true;
                $attributes['hiddenAt'] = $this->formatDate($post->hidden_at);
            }
    
            $attributes += [
                'canEdit'   => $canEdit,
                'canDelete' => $gate->allows('delete', $post),
                'canHide'   => $gate->allows('hide', $post)
            ];
    
            return $attributes;
        }
    
        /**
         * @return \Tobscure\JsonApi\Relationship
         */
        protected function user($post)
        {
            return $this->hasOne($post, UserSerializer::class);
        }
    
        /**
         * @return \Tobscure\JsonApi\Relationship
         */
        protected function discussion($post)
        {
            return $this->hasOne($post, BasicDiscussionSerializer::class);
        }
    
        /**
         * @return \Tobscure\JsonApi\Relationship
         */
        protected function editedUser($post)
        {
            return $this->hasOne($post, BasicUserSerializer::class);
        }
    
        /**
         * @return \Tobscure\JsonApi\Relationship
         */
        protected function hiddenUser($post)
        {
            return $this->hasOne($post, BasicUserSerializer::class);
        }
    }
    adsense kodları genellikle <head> ....
    </head> arasına ekleniyor.
  • 16-01-2019, 12:30:47
    #3
    hocam bu ne bişi anlamadık.
  • 16-01-2019, 19:00:24
    #4
    Hocam yazının içine adsense eklemek istiyorum fakat tüm dosyalarda içerik {!! content !!} diye çekilmiş ve content.php diye bir sayfa yok. Burası "content" in tanımlama bölümü buraya adsenseyi ekleyebilirsek "content" çekildiğinde adsenseyide çekmiş olacak.. Ücret Önerebilirim yapacak olan arkadaşlar için.