<?php

/**
 * [BEGIN_COT_EXT]
 * Hooks=market.jscfg
 * [END_COT_EXT]
 */

defined('COT_CODE') or die('Wrong URL');

require_once cot_incfile('mavatars', 'plug');
global $db, $db_x, $db_mavatars;

$mavatar_description = new mavatar('market', 'description', ($item['item_id'] > 0 ? $item['item_id'] : ''), ($item['item_id'] > 0 ? '' : 'edit'));
$mavatar_instruction = new mavatar('market', 'instruction', ($item['item_id'] > 0 ? $item['item_id'] : ''), ($item['item_id'] > 0 ? '' : 'edit'));

$return['files'] = array(
  'description' => array(),
  'instruction' => array()
);

foreach($mavatar_description->tags() as $mav) {
  $return['files']['description'][] = array(
    'id' => $mav['ID'],
    'name' => $mav['FILEORIGNAME'] . '.' . $mav['FILEEXT'],
    'path' => $mav['FILEPATH']
  );
}

foreach($mavatar_instruction->tags() as $mav) {
  $return['files']['instruction'][] = array(
    'id' => $mav['ID'],
    'name' => $mav['FILEORIGNAME'] . '.' . $mav['FILEEXT'],
    'path' => $mav['FILEPATH']
  );
}
