本文整理汇总了PHP中A::REGFILES方法的典型用法代码示例。如果您正苦于以下问题:PHP A::REGFILES方法的具体用法?PHP A::REGFILES怎么用?PHP A::REGFILES使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类A
的用法示例。
在下文中一共展示了A::REGFILES方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Import
function Import()
{
require_once "Structures/DataGrid.php";
require_once "Structures/DataGrid/DataSource/Excel.php";
require_once "Structures/DataGrid/DataSource/CSV.php";
require_once 'Image/Transform.php';
A::$REGFILES = getSectionByModule('pages');
mk_dir("files/" . DOMAIN . "/tmp");
clearDir("files/" . DOMAIN . "/tmp");
if (isset($_FILES['file']['tmp_name']) && file_exists($_FILES['file']['tmp_name'])) {
$path_parts = pathinfo($_FILES['file']['name']);
$ext = preg_replace("/[^a-z0-9]+/i", "", mb_strtolower($path_parts['extension']));
if ($ext == 'xls' || $ext == 'csv') {
if ($ext == 'csv') {
$sourcefile = $_FILES['file']['tmp_name'];
$content = @file_get_contents($sourcefile);
if ($content && !mb_check_encoding($content, 'UTF-8')) {
file_put_contents($sourcefile, mb_convert_encoding($content, 'UTF-8', 'Windows-1251'));
}
} else {
$sourcefile = $_FILES['file']['tmp_name'];
}
if ($ext == 'xls') {
$datasource = new Structures_DataGrid_DataSource_Excel();
$datasource->bind($sourcefile);
} elseif ($ext == 'csv') {
$datasource = new Structures_DataGrid_DataSource_CSV();
$datasource->bind($sourcefile, array('delimiter' => ';', 'enclosure' => '"'));
} else {
return false;
}
$datagrid = new Structures_DataGrid();
$datagrid->bindDataSource($datasource);
if (isset($_REQUEST['clear'])) {
A::$DB->execute("TRUNCATE " . STRUCTURE);
}
$sort = A::$DB->getOne("SELECT MAX(sort) FROM " . STRUCTURE) + 1;
$list = array();
foreach ($datagrid->recordSet as $row) {
if (empty($row)) {
continue;
}
if ($ext == 'xls') {
$trow = array();
foreach ($row as $j => $value) {
if (!empty($value)) {
$trow[$j - 1] = $value;
}
}
$row = $trow;
}
$data = array();
if (!empty($row[0])) {
$data['name_' . LANG] = trim($row[0]);
} else {
continue;
}
$j = 1;
A::$DB->query("SELECT * FROM " . DOMAIN . "_fields WHERE item='" . STRUCTURE . "' ORDER BY sort");
while ($frow = A::$DB->fetchRow()) {
switch ($frow['type']) {
default:
$data[$frow['field']] = !empty($row[$j]) ? trim($row[$j]) : "";
break;
case 'int':
$data[$frow['field']] = !empty($row[$j]) ? (int) $row[$j] : 0;
break;
case 'float':
$data[$frow['field']] = !empty($row[$j]) ? (double) $row[$j] : 0;
break;
case 'select':
if (!empty($row[$j])) {
if (!isset($list[$frow['property']])) {
$list[$frow['property']] = loadList($frow['property']);
}
$row[$j] = trim($row[$j]);
$key = array_search($row[$j], $list[$frow['property']]);
if (empty($key) && !empty($row[$j])) {
$key = addToList($frow['property'], $row[$j]);
$list[$frow['property']][$key] = $row[$j];
}
if (!empty($key)) {
$data[$frow['field']] = $key;
}
}
break;
case 'mselect':
if (!empty($row[$j])) {
if (!isset($list[$frow['property']])) {
$list[$frow['property']] = loadList($frow['property']);
}
$row[$j] = explode(',', $row[$j]);
$data[$frow['field']] = array();
foreach ($row[$j] as $value) {
$value = trim($value);
$key = array_search($value, $list[$frow['property']]);
if (empty($key) && !empty($value)) {
$key = addToList($frow['idvar'], $value);
$list[$frow['property']][$key] = $value;
}
//.........这里部分代码省略.........
示例2: fcategory_dataset_prepare
function fcategory_dataset_prepare($dataset)
{
if ($structure = getStructureByPlugin('fcategory')) {
A::$DB->query("SELECT * FROM {$structure} WHERE idsec=" . SECTION_ID . " ORDER BY sort");
while ($row = A::$DB->fetchRow()) {
switch ($row['type']) {
case "int":
$_REQUEST[$row['field']] = isset($_REQUEST[$row['field']]) ? (int) $_REQUEST[$row['field']] : 0;
$dataset->fields[] = $row['field'];
break;
case "select":
$_REQUEST[$row['field']] = isset($_REQUEST[$row['field']]) ? (int) $_REQUEST[$row['field']] : 0;
$options = loadList($row['property']);
if (!isset($options[$_REQUEST[$row['field']]]) && !empty($_REQUEST[$row['field'] . "_txt"])) {
if ($string = trim($_REQUEST[$row['field'] . "_txt"])) {
if ($plugin = getPluginByStructure($row['property'])) {
if (function_exists("{$plugin}_add")) {
$_REQUEST[$row['field']] = call_user_func("{$plugin}_add", $row['property'], $string);
}
}
}
}
$dataset->fields[] = $row['field'];
break;
case "mselect":
if (!empty($_REQUEST[$row['field']]) && is_array($_REQUEST[$row['field']])) {
$values = array();
foreach ($_REQUEST[$row['field']] as $sid) {
$values[] = sprintf("%04d", (int) $sid);
}
$_REQUEST[$row['field']] = implode(",", $values);
} else {
$_REQUEST[$row['field']] = "";
}
$dataset->fields[] = $row['field'];
break;
case "float":
$_REQUEST[$row['field']] = isset($_REQUEST[$row['field']]) ? (double) $_REQUEST[$row['field']] : 0;
$dataset->fields[] = $row['field'];
break;
case "bool":
$_REQUEST[$row['field']] = isset($_REQUEST[$row['field']]) ? "Y" : "N";
$dataset->fields[] = $row['field'];
break;
case "date":
$_REQUEST[$row['field']] = isset($_REQUEST[$row['field']]) ? (int) $_REQUEST[$row['field']] : mktime(0, 0, 0, (int) $_REQUEST[$row['field'] . 'Month'], (int) $_REQUEST[$row['field'] . 'Day'], (int) $_REQUEST[$row['field'] . 'Year']);
$dataset->fields[] = $row['field'];
break;
case "string":
case "text":
case "format":
$_REQUEST[$row['field']] = isset($_REQUEST[$row['field']]) ? trim($_REQUEST[$row['field']]) : "";
$dataset->fields[] = $row['field'];
break;
case "image":
if (empty(A::$REGFILES)) {
A::$REGFILES = getSectionByModule('pages');
}
if (empty($dataset->data) || empty($_REQUEST['parent_id'])) {
$_REQUEST[$row['field']] = UploadImage($row['field'], !empty($_REQUEST['name']) ? $_REQUEST['name'] : "");
} else {
$_REQUEST[$row['field']] = UploadImage($row['field'], !empty($_REQUEST['name']) ? $_REQUEST['name'] : "", $dataset->data[$row['field']]);
if (isset($_REQUEST[$row['field'] . '_del'])) {
DelRegImage($dataset->data[$row['field']]);
$_REQUEST[$row['field']] = 0;
}
}
$dataset->fields[] = $row['field'];
break;
case "file":
if (empty(A::$REGFILES)) {
A::$REGFILES = getSectionByModule('pages');
}
if (empty($dataset->data) || empty($_REQUEST['parent_id'])) {
$_REQUEST[$row['field']] = UploadFile($row['field'], !empty($_REQUEST['name']) ? $_REQUEST['name'] : "");
} else {
$_REQUEST[$row['field']] = UploadFile($row['field'], !empty($_REQUEST['name']) ? $_REQUEST['name'] : "", $dataset->data[$row['field']]);
if (isset($_REQUEST[$row['field'] . '_del'])) {
DelRegFile($dataset->data[$row['field']]);
$_REQUEST[$row['field']] = 0;
}
}
$dataset->fields[] = $row['field'];
break;
}
}
A::$DB->free();
}
}