예제 #1
0
 /**
  * Assign module's template vars
  *
  * @param array $row Database row of module
  * @param mixed $template_module Template data as returned by module
  *
  * @return null
  */
 public function assign_module_vars($row, $template_module)
 {
     if (is_array($template_module)) {
         $this->template->assign_block_vars('modules_' . $this->portal_columns->number_to_string($row['module_column']), array('TEMPLATE_FILE' => $this->parse_template_file($template_module['template']), 'IMAGE_SRC' => $this->path_helper->get_web_root_path() . ltrim($this->root_path . 'styles/all/theme/images/portal/' . $template_module['image_src'], './'), 'TITLE' => $template_module['title'], 'CODE' => $template_module['code'], 'MODULE_ID' => $row['module_id'], 'IMAGE_WIDTH' => $row['module_image_width'], 'IMAGE_HEIGHT' => $row['module_image_height']));
     } else {
         $this->template->assign_block_vars('modules_' . $this->portal_columns->number_to_string($row['module_column']), array('TEMPLATE_FILE' => $this->parse_template_file($template_module), 'IMAGE_SRC' => $this->path_helper->get_web_root_path() . ltrim($this->root_path . 'styles/all/theme/images/portal/' . $row['module_image_src'], './'), 'IMAGE_WIDTH' => $row['module_image_width'], 'IMAGE_HEIGHT' => $row['module_image_height'], 'MODULE_ID' => $row['module_id'], 'TITLE' => isset($this->user->lang[$row['module_name']]) ? $this->user->lang[$row['module_name']] : utf8_normalize_nfc($row['module_name'])));
     }
 }
예제 #2
0
 /**
  * Set allowed columns based on supplied columns array
  *
  * @param array $columns Allowed columns
  */
 protected function set_allowed_columns($columns)
 {
     if (!empty($columns)) {
         foreach ($columns as $column => $show) {
             $this->allowed_columns |= $show ? $this->portal_columns->string_to_constant($column) : 0;
         }
     } else {
         $this->allowed_columns = 0;
     }
 }
예제 #3
0
 /**
  * Get the horizontal move action (columns to move)
  *
  * @param array $module_data Array containing the module data
  * @param int $direction Direction to move; 1 for right, -1 for left
  *
  * @return int|null Move action if module can be moved, calls
  *		handle_after_move() if it can't be moved
  */
 public function get_horizontal_move_action($module_data, $direction)
 {
     if ($this->constraints_handler->can_move_horizontally($module_data, $direction)) {
         if ($this->module->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($module_data['module_column'] + $direction))) {
             return $direction;
             // we move 1 column
         } else {
             if ($this->module->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($module_data['module_column'] + $direction * 2)) && $module_data['module_column'] != $this->portal_columns->string_to_number('center')) {
                 return 2 * $direction;
                 // we move 2 columns
             }
         }
     }
     $this->handle_after_move(false);
 }
 /**
  * Check if module can be moved to desired column
  *
  * @param \board3\portal\modules\module_interface $module
  * @param string $column Column string
  *
  * @return bool True if module can be moved, false if not
  */
 public function can_add_module($module, $column)
 {
     return (bool) ($module->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($column)));
 }