本文整理汇总了PHP中FabrikWorker::log方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikWorker::log方法的具体用法?PHP FabrikWorker::log怎么用?PHP FabrikWorker::log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FabrikWorker
的用法示例。
在下文中一共展示了FabrikWorker::log方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* do the plugin action
*
* @return number of records updated
*/
function process(&$data, &$listModel)
{
$app = JFactory::getApplication();
$params = $this->getParams();
//Get plugin settings and save state of request array vars we might change
$maxFiles = (int) $params->get('cron_importcsv_maxfiles', 1);
$deleteFile = $params->get('cron_importcsv_deletefile', true);
$cronDir = $params->get('cron_importcsv_directory');
$useTableName = (int) $params->get('cron_importcsv_usetablename', false);
$dropdata = $params->get('cron_importcsv_dropdata', '0');
$orig_dropdata = JRequest::getVar('dropdata', -1);
$overwrite = $params->get('cron_importcsv_overwrite', '0');
$orig_overwrite = JRequest::getVar('overwrite', -1);
$jform = array();
$jform['drop_data'] = $dropdata;
$jform['overwrite'] = $overwrite;
JRequest::setVar('jform', $jform);
$orig_listid = JRequest::getInt('listid', -1);
//Fabrik use this as the base directory, so we need a new directory under 'media'
define("FABRIK_CSV_IMPORT_ROOT", JPATH_ROOT . DS . 'media');
$d = FABRIK_CSV_IMPORT_ROOT . DS . $cronDir;
//TODO: Need to also have a FILTER for CSV files ONLY.
$filter = "\\.CSV\$|\\.csv\$";
$exclude = array('done', '.svn', 'CVS');
$arrfiles = JFolder::files($d, $filter, true, true, $exclude);
// the csv import class needs to know we are doing a cron import
JRequest::setVar('cron_csvimport', true);
$xfiles = 0;
foreach ($arrfiles as $full_csvfile) {
if (++$xfiles > $maxFiles) {
break;
}
FabrikWorker::log('plg.cron.cronimportcsv.information', "Starting import: {$full_csvfile}: ");
$clsImportCSV = JModel::getInstance('Importcsv', 'FabrikFEModel');
if ($useTableName) {
$listid = $this->getListIdFromFileName(basename($full_csvfile));
} else {
$table =& $listModel->getTable();
$listid = $table->id;
}
if (empty($listid)) {
FabrikWorker::log('plg.cron.cronimportcsv.warning', "List with name {$filename} does not exist");
continue;
}
JRequest::setVar('listid', $listid);
// grab the CSV file, need to strip import root off path first
$csvfile = str_replace(FABRIK_CSV_IMPORT_ROOT, '', $full_csvfile);
$clsImportCSV->setBaseDir(FABRIK_CSV_IMPORT_ROOT);
$clsImportCSV->readCSV($csvfile);
//get this->matchedHeading
$clsImportCSV->findExistingElements();
$msg = $clsImportCSV->makeTableFromCSV();
if ($app->isAdmin()) {
$app->enqueueMessage($msg);
}
if ($deleteFile == '1') {
JFile::delete($full_csvfile);
} else {
if ($deleteFile == '2') {
$new_csvfile = $full_csvfile . '.' . time();
JFile::move($full_csvfile, $new_csvfile);
} else {
if ($deleteFile == '3') {
$done_folder = dirname($full_csvfile) . DS . 'done';
if (JFolder::exists($done_folder)) {
$new_csvfile = $done_folder . DS . basename($full_csvfile);
JFile::move($full_csvfile, $new_csvfile);
} else {
if ($app->isAdmin()) {
$app->enqueueMessage("Move file requested, but can't find 'done' folder: {$done_folder}");
}
}
}
}
}
FabrikWorker::log('plg.cron.cronimportcsv.information', $msg);
}
// Leave the request array how we found it
if (!empty($orig_listid)) {
JRequest::setvar('listid', $orig_listid);
}
if ($orig_dropdata != -1) {
JRequest::setVar('drop_data', $orig_dropdata);
}
if ($orig_overwrite != -1) {
JRequest::setVar('overwite', $orig_overwrite);
}
if ($xfiles > 0) {
$updates = $clsImportCSV->addedCount + $clsImportCSV->updatedCount;
} else {
$updates = 0;
}
return $updates;
}
示例2: process
/**
* do the plugin action
*
*/
function process(&$data, &$listModel)
{
$params = $this->getParams();
// grab the table model and find table name and PK
$table = $listModel->getTable();
$table_name = $table->db_table_name;
$primary_key = $table->db_primary_key;
$primary_key_element = FabrikString::shortColName($table->db_primary_key);
// for now, we have to read the table ourselves. We can't rely on the $data passed to us
// because it can be arbitrarily filtered according to who happened to hit the page when cron
// needed to run.
$mydata = array();
$db = FabrikWorker::getDbo();
$db->setQuery("SELECT * FROM {$table_name}");
$mydata[0] = $db->loadObjectList();
// grab all the params, like GMaps key, field names to use, etc
// $geocode_gmap_key = $params->get('geocode_gmap_key');
$geocode_batch_limit = (int) $params->get('geocode_batch_limit', '0');
$geocode_delay = (int) $params->get('geocode_delay', '0');
$geocode_is_empty = $params->get('geocode_is_empty');
$geocode_zoom_level = $params->get('geocode_zoom_level', '4');
$geocode_map_element_long = $params->get('geocode_map_element');
$geocode_map_element = FabrikString::shortColName($geocode_map_element_long);
$geocode_addr1_element_long = $params->get('geocode_addr1_element');
$geocode_addr1_element = $geocode_addr1_element_long ? FabrikString::shortColName($geocode_addr1_element_long) : '';
$geocode_addr2_element_long = $params->get('geocode_addr2_element');
$geocode_addr2_element = $geocode_addr2_element_long ? FabrikString::shortColName($geocode_addr2_element_long) : '';
$geocode_city_element_long = $params->get('geocode_city_element');
$geocode_city_element = $geocode_city_element_long ? FabrikString::shortColName($geocode_city_element_long) : '';
$geocode_state_element_long = $params->get('geocode_state_element');
$geocode_state_element = $geocode_state_element_long ? FabrikString::shortColName($geocode_state_element_long) : '';
$geocode_zip_element_long = $params->get('geocode_zip_element');
$geocode_zip_element = $geocode_zip_element_long ? FabrikString::shortColName($geocode_zip_element_long) : '';
$geocode_country_element_long = $params->get('geocode_country_userid_element');
$geocode_country_element = $geocode_country_element_long ? FabrikString::shortColName($geocode_country_element_long) : '';
$geocode_when = $params->get('geocode_zip_element', '1');
// sanity check, make sure required elements have been specified
/*
if (empty($geocode_gmap_key)) {
JError::raiseNotice(500, 'No google maps key specified');
return;
}
$gmap = new GMaps($geocode_gmap_key);
*/
$gmap = new GeoCode();
// run through our table data
$total_encoded = 0;
$total_attempts = 0;
foreach ($mydata as $gkey => $group) {
if (is_array($group)) {
foreach ($group as $rkey => $row) {
if ($geocode_batch_limit > 0 && $total_attempts >= $geocode_batch_limit) {
FabrikWorker::log('plg.cron.geocode.information', 'reached batch limit');
break 2;
}
// See if the map element is considered empty
// Values of $geocode_when are:
// 1: default or empty
// 2: empty
// 3: always
$do_geocode = true;
if ($geocode_when == '1') {
$do_geocode = empty($row->{$geocode_map_element}) || $row->{$geocode_map_element} == $geocode_is_empty;
} else {
if ($geocode_when == '2') {
$geocode = empty($row->{$geocode_map_element});
}
}
if ($do_geocode) {
// it's empty, so lets try and geocode.
// first, construct the address
// we'll build an array of address components, which we'll explode into a string later
$a_full_addr = array();
// for each address component element, see if one is specific in the params,
// if so, see if it has a value in this row
// if so, add it to the address array.
if ($geocode_addr1_element) {
if ($row->{$geocode_addr1_element}) {
$a_full_addr[] = $row->{$geocode_addr1_element};
}
}
if ($geocode_addr2_element) {
if ($row->{$geocode_addr2_element}) {
$a_full_addr[] = $row->{$geocode_addr2_element};
}
}
if ($geocode_city_element) {
if ($row->{$geocode_city_element}) {
$a_full_addr[] = $row->{$geocode_city_element};
}
}
if ($geocode_state_element) {
if ($row->{$geocode_state_element}) {
$a_full_addr[] = $row->{$geocode_state_element};
}
}
//.........这里部分代码省略.........
示例3: cropForLarger
/**
* Enter description here ...
* @param unknown_type $oImage
* @param unknown_type $filepath
* @param unknown_type $destCropFile
* @param unknown_type $coords
*/
private function cropForLarger($oImage, $filepath, $destCropFile, $coords)
{
$params =& $this->getParams();
$bg = $params->get('fileupload_crop_bg', '#FFFFFF');
$log = array();
$log['coords'] = $coords;
$imagedim = $coords->imagedim;
$srcX = $coords->cropdim->x;
$srcY = $coords->cropdim->y;
$cropWidth = $coords->cropdim->w;
$cropHeight = $coords->cropdim->h;
$scale = (int) $coords->scale;
//deprecaited (again lol)
//from here replaces commented code below
list($width, $height) = getimagesize($filepath);
$log['rotate'] = array('path' => $filepath, 'dest' => $destCropFile, 'rotation' => $coords->rotation * -1);
list($rotatedImgObject, $rotateWidth, $rotateHeight) = $oImage->rotate($filepath, $destCropFile, $coords->rotation * -1);
$xx = $rotateWidth / 2 - $width / 2;
$yy = $rotateHeight / 2 - $height / 2;
//need to crop image down to initial crop interface dimensions as rotate changes image dimensions
//$oImage->crop($destCropFile, $destCropFile, $xx , $yy , 400, 400);
//check if image size is smaller than canvas size first
$destW = $imagedim->w < 400 ? $imagedim->w : 400;
$destH = $imagedim->h < 400 ? $imagedim->h : 400;
//@todo test for smaller image - set offset so that they dont appear at top
$log['crop1'] = array($destCropFile, $destCropFile, $xx, $yy, $destW, $destH, 0, 0, $bg);
$oImage->crop($destCropFile, $destCropFile, $xx, $yy, $destW, $destH, 0, 0, $bg);
$destX = $imagedim->x - $imagedim->w / 2;
$destY = $imagedim->y - $imagedim->h / 2;
//make an image the size of the crop interface
$image_p = imagecreatetruecolor($destW, $destH);
list($image, $header) = $oImage->imageFromFile($destCropFile);
//figure out what the destination w/h should be (scaling the image based on the submitted scale value)
$destwidth = $width * ((double) $scale / 100);
$destheight = $height * ((double) $scale / 100);
//create a file which resembles the crop interfaces image
$log['scale'] = array('dest' => $destCropFile, 'destX' => $destX, 'destY' => $destY, 'destWidth' => $destwidth, 'destHeight' => $destheight, 'sourceWidth' => $width, 'sourceHeight' => $height);
imagecopyresampled($image_p, $image, $destX, $destY, 0, 0, $destwidth, $destheight, $width, $height);
$oImage->imageToFile($destCropFile, $image_p);
//finally take the cropper coordinates and crop the image
$offsetX = $imagedim->w < 400 ? (400 - $imagedim->w) / 2 : 0;
$offsetY = $imagedim->h < 400 ? (400 - $imagedim->h) / 2 : 0;
$srcX = $coords->cropdim->x - $coords->cropdim->w / 2 - $offsetX;
$srcY = $coords->cropdim->y - $coords->cropdim->h / 2 - $offsetY;
$log['crop2'] = array('dest' => $destCropFile, 'startx' => $srcX, 'starty' => $srcY, 'crop width' => $cropWidth, 'cropHeight' => $cropHeight, 'cropx' => 0, 'cropy' => 0, 'bg' => $bg);
$oImage->crop($destCropFile, $destCropFile, $srcX, $srcY, $cropWidth, $cropHeight, 0, 0, $bg);
FabrikWorker::log('fabrik.fileupload.crop', $log);
}
示例4: process
/**
* Do the plugin action
*
* @param array &$data array data to process
* @param object &$listModel plugin's list model
*
* @return int number of records run
*/
public function process(&$data, &$listModel)
{
$params = $this->getParams();
$db = $listModel->getDb();
$query = $db->getQuery(true);
// Grab the table model and find table name and PK
$table = $listModel->getTable();
$table_name = $table->db_table_name;
$primary_key = $table->db_primary_key;
$primary_key_element = FabrikString::shortColName($table->db_primary_key);
$primary_key_element_long = $table_name . '___' . $primary_key_element . '_raw';
$connection = (int) $params->get('connection');
/*
* For now, we have to read the table ourselves. We can't rely on the $data passed to us
* because it can be arbitrarily filtered according to who happened to hit the page when cron
* needed to run.
*/
/*
$mydata = array();
$db = FabrikWorker::getDbo(false, $connection);
$query = $db->getQuery(true);
$query->select('*')->from($table_name);
$db->setQuery($query);
$mydata[0] = $db->loadObjectList();
*/
// Grab all the params, like GMaps key, field names to use, etc.
$geocode_batch_limit = (int) $params->get('geocode_batch_limit', '0');
$geocode_delay = (int) $params->get('geocode_delay', '0');
$geocode_is_empty = $params->get('geocode_is_empty');
$geocode_zoom_level = $params->get('geocode_zoom_level', '4');
$geocode_map_element_long = $params->get('geocode_map_element');
$geocode_map_element = FabrikString::shortColName($geocode_map_element_long);
$geocode_addr1_element_long = $params->get('geocode_addr1_element');
$geocode_addr1_element = $geocode_addr1_element_long ? FabrikString::shortColName($geocode_addr1_element_long) : '';
$geocode_addr2_element_long = $params->get('geocode_addr2_element');
$geocode_addr2_element = $geocode_addr2_element_long ? FabrikString::shortColName($geocode_addr2_element_long) : '';
$geocode_city_element_long = $params->get('geocode_city_element');
$geocode_city_element = $geocode_city_element_long ? FabrikString::shortColName($geocode_city_element_long) : '';
$geocode_state_element_long = $params->get('geocode_state_element');
$geocode_state_element = $geocode_state_element_long ? FabrikString::shortColName($geocode_state_element_long) : '';
$geocode_zip_element_long = $params->get('geocode_zip_element');
$geocode_zip_element = $geocode_zip_element_long ? FabrikString::shortColName($geocode_zip_element_long) : '';
$geocode_country_element_long = $params->get('geocode_country_element');
$geocode_country_element = $geocode_country_element_long ? FabrikString::shortColName($geocode_country_element_long) : '';
$geocode_when = $params->get('geocode_when', '1');
$gmap = new GeoCode();
// Run through our table data
$total_encoded = 0;
$total_attempts = 0;
foreach ($data as $gkey => $group) {
if (is_array($group)) {
foreach ($group as $rkey => $row) {
if ($geocode_batch_limit > 0 && $total_attempts >= $geocode_batch_limit) {
FabrikWorker::log('plg.cron.geocode.information', 'reached batch limit');
break 2;
}
/*
* See if the map element is considered empty
* Values of $geocode_when are:
* 1: default or empty
* 2: empty
* 3: always
*/
$do_geocode = true;
if ($geocode_when == '1') {
$do_geocode = empty($row->{$geocode_map_element_long}) || $row->{$geocode_map_element_long} == $geocode_is_empty;
} elseif ($geocode_when == '2') {
$do_geocode = empty($row->{$geocode_map_element_long});
}
if ($do_geocode) {
/*
* It's empty, so lets try and geocode.
* first, construct the address
* we'll build an array of address components, which we'll explode into a string later
*/
$a_full_addr = array();
/*
* For each address component element, see if one is specific in the params,
* if so, see if it has a value in this row
* if so, add it to the address array.
*/
if ($geocode_addr1_element_long) {
if ($row->{$geocode_addr1_element_long}) {
$a_full_addr[] = $row->{$geocode_addr1_element_long};
}
}
if ($geocode_addr2_element_long) {
if ($row->{$geocode_addr2_element_long}) {
$a_full_addr[] = $row->{$geocode_addr2_element_long};
}
}
if ($geocode_city_element_long) {
//.........这里部分代码省略.........