コード例 #1
0
ファイル: RenderManager.php プロジェクト: arpad9/bygmarket
 /**
  * Loads location data, containers, grids and blocks
  *
  * @param string $dispatch       URL dispatch (controller.mode.action)
  * @param string $area           Area ('A' for admin or 'C' for custom
  * @param array  $dynamic_object
  * @param int    $location_id
  * @param string $lang_code      2 letters language code
  */
 public function __construct($dispatch, $area, $dynamic_object = array(), $location_id = 0, $lang_code = DESCR_SL)
 {
     Debugger::checkpoint('Start render location');
     // Try to get location for this dispatch
     if ($location_id > 0) {
         $this->_location = Location::instance()->getById($location_id, $lang_code);
     } else {
         $this->_location = Location::instance()->get($dispatch, $dynamic_object, $lang_code);
     }
     $this->_area = $area;
     if (!empty($this->_location)) {
         if (isset($dynamic_object['object_id']) && $dynamic_object['object_id'] > 0) {
             $this->_containers = Container::getListByArea($this->_location['location_id'], 'C');
         } else {
             $this->_containers = Container::getListByArea($this->_location['location_id'], $this->_area);
         }
         $this->_grids = Grid::getList(array('container_ids' => Container::getIds($this->_containers)));
         $blocks = Block::instance()->getList(array('?:bm_snapping.*', '?:bm_blocks.*', '?:bm_blocks_descriptions.*'), Grid::getIds($this->_grids), $dynamic_object, null, null, $lang_code);
         $this->_blocks = $blocks;
         $this->_view = \Tygh::$app['view'];
         $this->_theme = self::_getThemePath($this->_area);
         $this->_dynamic_object_scheme = SchemesManager::getDynamicObject($this->_location['dispatch'], 'C');
     }
 }
コード例 #2
0
ファイル: Block.php プロジェクト: arpad9/bygmarket
 /**
  * Get blocks by type from given location_id, returns snapping_id and block status
  *
  * @param  string     $block_type  Type of block
  * @param  int        $location_id Location Id
  * @return array|bool Array with snapping_id => block_status
  */
 public function getBlocksByTypeForLocation($block_type, $location_id)
 {
     $blocks = false;
     if (!empty($location_id)) {
         $containers = Container::getListByArea($location_id, 'C');
         $grids = Grid::getList(array('container_ids' => Container::getIds($containers), 'simple' => true));
         $condition = db_quote(' AND ?:bm_blocks.type = ?s', $block_type);
         $condition .= $this->getCompanyCondition('?:bm_blocks.company_id');
         $blocks = db_get_hash_single_array("SELECT ?:bm_snapping.snapping_id, ?:bm_snapping.status " . "FROM ?:bm_snapping " . "LEFT JOIN ?:bm_blocks " . "ON ?:bm_blocks.block_id = ?:bm_snapping.block_id " . "WHERE ?:bm_snapping.grid_id IN (?n) ?p", array('snapping_id', 'status'), Grid::getIds($grids), $condition);
     }
     return $blocks;
 }