예제 #1
0
    /**
     * @param ChannelBlock $block
     * @return mixed
     */
    private function getLimit(ChannelBlock $block)
    {
        if(contextTool::instance()->isMobile())
        {
            if($block->attribute("mobile_limit"))
            {
                return $block->attribute("mobile_limit");
            }
        }
        else
        {
            if($block->attribute("desktop_limit"))
            {
                return $block->attribute("desktop_limit");
            }
        }

        return 100;
    }
    /**
     * @return ChannelBlock[]
     */
    public function getChannelBlocks()
    {
        $blocks = array();
        $channelHasBlocks = ChannelHasBlock::fetchBlocksByApplicationLocalized($this->attribute("id"));

        /** @var ChannelBlock $hasBlock */
        foreach($channelHasBlocks as $hasBlock)
        {
            if($hasBlock)
            {
                $blocks[] = ChannelBlock::fetchById( $hasBlock->attribute("block_id") );
            }
        }

        return $blocks;
    }
 /**
  * @return ChannelBlock
  */
 public function getChannelBlock()
 {
     return self::fetchObject(ChannelBlock::definition(), null, array("id" => $this->attribute("block_id")));
 }
 /**
  * Allow to set channel and channelBlockId from view parameters in url : (channel)/131
  */
 protected function initChannelInformations()
 {
     $parameters = $this->_params['UserParameters'];
     if($parameters && $parameters["channel"])
     {
         $block = ChannelBlock::fetchById($parameters["channel"]);
         if($block instanceof ChannelBlock)
         {
             $this->channel = $block->getChannelApplicationLocalized();
             $this->channelBlockId = $parameters["channel"];
         }
     }
     else if ($this->getCustomParameter('ParentChannel') !== false)
     {
         $channelIdentifier = $this->getCustomParameter('ParentChannel');
         $channel = ApplicationLocalized::getLocalizedApplicationByIdentifier($channelIdentifier);
         if ($channel != null && $channel instanceof ApplicationLocalized)
         {
             $this->channel = $channel;
         }
     }
 }