Beispiel #1
0
/**
 * Получение ссылки для изображения
 * @param $param
 */
function smarty_function_getImageLink($param)
{
    $image = getParam($param, 'image', '');
    $size = getParam($param, 'size', '');
    $form = getParam($param, 'form', '');
    $name = getParam($param, 'name', '');
    if ($size == '') {
        echo '/userfiles/original/' . $image;
    } else {
        Files::setImageSize($size);
        echo Files::getImageLink($image, $name);
    }
}
Beispiel #2
0
 /**
  * Получение информации о записи для редактирования
  * @param string $table
  * @param int $id
  * @param int $parent
  * @param array $exc
  * @return array
  */
 public function getAdminEditedRow($table, $id = 0, $parent = 0, $exc = array())
 {
     // Поля разрешенные для редактирования
     $allowed_fields = array();
     // Получение информации о полях таблицы
     $fields = $this->getTableFields($table, $exc);
     // Проверяем существование настроек для таблицы
     $options = $this->getRowsClear('options_tables', 'table_name', PREF . $table, 'position', 'ASC', 1, 200, 2);
     if (is_array($options) && !empty($options)) {
         foreach ($options as $key => $option_value) {
             if ($option_value['edit_list'] == 1) {
                 $allowed_fields[] = $option_value['table_cell'];
             }
         }
     } else {
         foreach ($fields as $key => $field_item) {
             $allowed_fields[] = $field_item['Field'];
         }
     }
     $data = array();
     if ($id > 0) {
         $result = $this->getRowById($table, $id);
         if (is_array($result) && !empty($result)) {
             foreach ($result as $key => $value) {
                 for ($i = 0; $i < count($fields); $i++) {
                     if (in_array($fields[$i]['Field'], $allowed_fields)) {
                         if ($key == $fields[$i]['Field']) {
                             $path = '';
                             if ($fields[$i]['Field'] == 'image' || $fields[$i]['Field'] == 'icon') {
                                 $path = Files::getImageLink($value);
                             }
                             $data[$key] = array('value' => $value, 'path' => $path, 'type' => $fields[$i]['Type'], 'values' => $fields[$i]['values'], 'relation' => $fields[$i]['relation']);
                         }
                     }
                 }
             }
         }
     } else {
         for ($i = 0; $i < count($fields); $i++) {
             if (in_array($fields[$i]['Field'], $allowed_fields)) {
                 if ($fields[$i]['Field'] == 'position') {
                     $fields[$i]['Default'] = $this->getMaxPosition($table, $parent);
                 }
                 $data[$fields[$i]['Field']] = array('value' => $fields[$i]['Default'], 'type' => $fields[$i]['Type'], 'values' => $fields[$i]['values'], 'relation' => $fields[$i]['relation']);
             }
         }
     }
     // Подставляем данные из пост
     if (isset($_POST)) {
         foreach ($data as $key => $value) {
             foreach ($_POST as $post_key => $post_value) {
                 if ($key == $post_key && $key != 'pass') {
                     $data[$key]['value'] = Text::get_post($post_key);
                 }
             }
         }
     }
     return $data;
 }
Beispiel #3
0
<?php

/**
 * Created by PhpStorm.
 * User: klim
 * Date: 06.10.14
 * Time: 21:52
 */
$item_id = (int) Text::get_get('item_id');
$table = Text::get_get('table');
$size = Text::get_get('size');
Files::setImageSize($size);
$file = Files::loadFiles();
if ($file['Filedata']['error'] == 0) {
    // Получение объекта кооректного класса для текущейт таблицы
    $base = checkTableType($table);
    $file_insert = new SimpleModule($base, $__lang);
    $file_insert->setUid($_SESSION['user']['id']);
    $data = array('item_id' => $item_id, 'name' => $file['Filedata']['orig_name'], 'image' => $file['Filedata']['name'], 'position' => 0, 'active' => '1');
    $result = $file_insert->setRow($table, $data);
    $smarty->assign('__lang', $__lang);
    $smarty->assign('image', Files::getImageLink($file['Filedata']['name']));
    $smarty->assign('image_id', $result);
    $smarty->assign('position', 1);
    $smarty->assign('active', '1');
    echo $smarty->fetch(DOC . 'templates/.admin/matches/admin_catalog_image_block.tpl');
} else {
    echo 'Error - ' . $file['Filedata']['error'];
}
exit;
Beispiel #4
0
 /**
  * Получение связей
  * @param string $table
  * @param string $relation_table
  * @param string $col1
  * @param string $col2
  * @param int $value
  * @return array
  */
 public function getRelationList($table, $relation_table, $col1, $col2, $value)
 {
     $data = parent::getRelationList($table, $relation_table, $col1, $col2, $value);
     // Получение изображений для позиций
     Files::setImageSize('100x100');
     for ($i = 0; $i < count($data); $i++) {
         $tmp = $this->__getImages($data[$i]['id'], 1);
         $data[$i]['image_link'] = Files::getImageLink($tmp['image']);
         $group = $this->getRow('catalog_groups', $data[$i]['group_id']);
         $data[$i]['link'] = $group['link'] . $data[$i]['alias'] . ".html";
     }
     return $data;
 }