本文整理汇总了PHP中Fields::Get方法的典型用法代码示例。如果您正苦于以下问题:PHP Fields::Get方法的具体用法?PHP Fields::Get怎么用?PHP Fields::Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fields
的用法示例。
在下文中一共展示了Fields::Get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CreateFile
public function CreateFile($data)
{
$format = $data["format"] == "excel" || $data["format"] == "csv" ? $data["format"] : "csv";
$PHPExcel = "PHPExcel";
if (!class_exists($PHPExcel)) {
include_once plugin_dir_path(__FILE__) . 'extlibs/PHPExcel/PHPExcel.php';
}
include_once plugin_dir_path(__FILE__) . 'extlibs/PHPExcel/PHPExcel/Writer/Excel2007.php';
$fields = Fields::Get($data["swichdatatype"]);
$obj = new \PHPExcel();
$objProperties = $obj->getProperties();
$objActiveSheet = $obj->getActiveSheet();
$objProperties->setCreator("MakeRise");
$objProperties->setTitle("Data Exported List");
$products_with_variations = isset($data["products_with_variations"]) ? $data["products_with_variations"] : 'Off';
$orders_with_fancy = isset($data["orders_with_fancy"]) ? $data["orders_with_fancy"] : 'Off';
$filter = array("recordsstatus" => $data["recordsstatus"], "recordsauthor" => $data["recordsauthor"], "date-from" => $data["date-from"], "date-to" => $data["date-to"], "datatype" => $data["swichdatatype"], "products_with_variations" => $products_with_variations, "orders_with_fancy" => $orders_with_fancy, "order" => "ID" . " ASC");
if (isset($data["prod-cats"])) {
$filter["prod-cats"] = $data["prod-cats"];
}
$wpdatas = $this->GetData($filter);
$obj->setActiveSheetIndex(0);
$i = 0;
if ($data["cols"]) {
foreach ($data["cols"] as $value) {
if (!in_array($value, $data["fields"])) {
continue;
}
$a = Fields::GetAlphas($i);
$f = strip_tags($fields[$value][0]);
$f = str_replace("Variations: ", "", $f);
$objActiveSheet->SetCellValue($a . "1", $f);
$ColumnDimension = $objActiveSheet->getColumnDimension($a);
$ColumnDimension->setAutoSize(true);
$Style = $objActiveSheet->getStyle($a . "1");
$StyleFont = $Style->getFont();
$StyleFont->setBold(true);
$r = 2;
foreach ($wpdatas as $wpdata) {
if (isset($wpdata[$value])) {
$objActiveSheet->SetCellValue($a . $r, $wpdata[$value]);
}
$r++;
}
$i++;
}
}
$objActiveSheet->setTitle('List');
$filetype = $format == "csv" ? ".csv" : ".xls";
$dt = new \DateTime("now");
$fname = "Data_" . $dt->format("Y-m-d_h-i-s") . "__" . uniqid() . $filetype;
if ($format == "csv") {
$objw = new \PHPExcel_Writer_CSV($obj);
$objw->setDelimiter(';');
$objw->setEnclosure('"');
} else {
$objw = new \PHPExcel_Writer_Excel2007($obj);
}
$files = glob(plugin_dir_path(__FILE__) . "tmp/*");
foreach ($files as $file) {
$dt = new \DateTime(date("F d Y H:i:s.", filemtime($file)));
$dt->modify("+1 day");
$dt_now = new \DateTime("now");
if ($dt_now > $dt && is_file($file)) {
unlink($file);
}
}
$objw->save(plugin_dir_path(__FILE__) . "tmp/" . $fname);
return array("fileurl" => plugin_dir_url(__FILE__) . "tmp/" . $fname, "filename" => $fname);
}
示例2: Preview
private function Preview()
{
$products_with_variations = isset($this->data["products_with_variations"]) ? $this->data["products_with_variations"] : 'Off';
$orders_with_fancy = isset($this->data["orders_with_fancy"]) ? $this->data["orders_with_fancy"] : 'Off';
$filter = array("recordsstatus" => $this->data["recordsstatus"], "recordsauthor" => $this->data["recordsauthor"], "date-from" => $this->data["date-from"], "date-to" => $this->data["date-to"], "datatype" => $this->data["datatype"], "products_with_variations" => $products_with_variations, "orders_with_fancy" => $orders_with_fancy, "order" => "ID" . " ASC", "limit" => 500);
if (isset($this->data["prod-cats"])) {
$filter["prod-cats"] = $this->data["prod-cats"];
}
$view = new View("views/datatable");
$view->setArray(array("fields" => Fields::Get($this->data["datatype"]), "data" => $this->core->GetData($filter), "totalfound" => $this->core->totalfound, "datatype" => $this->data["datatype"]));
echo json_encode(array("success" => true, "datatable" => $view->render(false)));
}