*/
public $memberProcessCountPerRound = 20;
+ /**
+ * fileProcessCountPerRound
+ *
+ * @var float
+ * @access public
+ */
+ public $fileProcessCountPerRound = 10;
+ /**
+ * photoProcessCountPerRound
+ *
+ * @var float
+ * @access public
+ */
+ public $photoProcessCountPerRound = 10;
+
/**
* numberProcessed
*
*/
public $photosProcessed = 0;
+ /**
+ * filesProcessed
+ *
+ * @var float
+ * @access public
+ */
+ public $filesProcessed = 0;
+
/**
* processingComplete
*
if ( isset( $_REQUEST['numberProcessed'] ) ) {
$this->numberProcessed = filter_var( $_REQUEST['numberProcessed'], FILTER_VALIDATE_INT );
}
+ if ( isset( $_REQUEST['photosProcessed'] ) ) {
+ $this->photosProcessed = filter_var( $_REQUEST['photosProcessed'], FILTER_VALIDATE_INT );
+ }
+ if ( isset( $_REQUEST['filesProcessed'] ) ) {
+ $this->filesProcessed = filter_var( $_REQUEST['filesProcessed'], FILTER_VALIDATE_INT );
+ }
// $fileData - The main files needed for the member import
// - field: input field name
// - name: file name
$success = $this->processFile( $uploadPath . '/' . $file['name'], $file['type'] );
if ( $success ) {
$fileData[$fileHeader]['results'] = "<p>$fileHeader file processed successfully.</p>";
+ } else {
+ $fileData[$fileHeader]['results'] = "<p>$fileHeader failed.</p>";
}
// Store the first files into wp options
// If the file validates then we're ready to process
$readyToProcess = $isValid;
// Set the view file
- $view= 'photosValidate.html';
+ $view = 'photosValidate.html';
$fileData = '<pre>$_FILES: ' . print_r( $_FILES, true ) . '</pre>';
break;
// If the file validates then we're ready to process
$readyToProcess = $isValid;
// Set the view file
- $view= 'filesValidate.html';
+ $view = 'filesValidate.html';
$fileData = '<pre>$_FILES: ' . print_r( $_FILES, true ) . '</pre>';
break;
require_once GLM_MEMBERS_PLUGIN_PATH . '/classes/data/dataMemberInfo.php';
$memberInfoObj = new GlmDataMemberInfo( $this->wpdb, $this->config );
+ $start = 1;
+ if ( isset( $_REQUEST['start'] ) ) {
+ $start = filter_var( $_REQUEST['start'], FILTER_VALIDATE_INT );
+ }
+
if ( is_file( $uploadPath . '/photoData.csv' ) ) {
// Get the entire photo file data
- $photoData = $this->readCSVFile( $uploadPath . '/photoData.csv' );
- //echo '<pre>$photoData: ' . print_r( $photoData, true ) . '</pre>';
+ $photoData = $this->readCSVFile( $uploadPath . '/photoData.csv' );
$this->totalPhotos = count( $photoData );
- $this->photosProcessed = count( $photoData );
- $refType = $this->config['ref_type_numb']['MemberInfo'];
+ $refType = $this->config['ref_type_numb']['MemberInfo'];
$refTable = $this->config['ref_type_table'][$refType];
// Loop through the photoData array
- foreach ( $photoData as $photo ) {
- echo '<pre>$photo: ' . print_r( $photo, true ) . '</pre>';
+ // Find out how many are left to process.
+ $testEnd = $start + $this->photoProcessCountPerRound;
+ $ending = ( $testEnd <= $this->totalPhotos ) ? $testEnd : $this->totalPhotos;
+
+ // We have to add one to $ending (array starts at 1 not 0).
+ $ending++;
+ for ( $index = $start; $index < $ending; $index++ ) {
+ //foreach ( $photoData as $photo ) {
+ $photo = $photoData[$index];
// If there's no url or the url is not valid then skip it.
if ( $photoUrl = filter_var( $photo['image'], FILTER_VALIDATE_URL ) ) {
- echo '<pre>$photoUrl: ' . print_r( $photoUrl, true ) . '</pre>';
// Need to first get the member id from the database
// It will match from the old_member_id field
$memberId = $this->wpdb->get_var(
if ( !$memberId ) {
continue;
}
- echo '<pre>$memberId: ' . print_r( $memberId, true ) . '</pre>';
// Now that we have the member id we need to get the
// id for the active member info record
$memberInfoId = $memberInfoObj->getActiveInfoIdForMember( $memberId );
if ( !$memberInfoId ) {
continue;
}
- echo '<pre>$memberInfoId: ' . print_r( $memberInfoId, true ) . '</pre>';
$res = $ImageUpload->storeImage(
$photoUrl,
$refType,
$photo['caption']
);
}
+ $this->photosProcessed++;
}
// Set the view file
- $view= 'photosProcess.html';
+ $view = 'photosProcess.html';
} else {
// Set the view file
- $view= 'photosValidate.html';
+ $view = 'photosValidate.html';
+ }
+ // Here we need to check to see if we processed all members.
+ // Also the counter has to increment the total processed so far.
+ if ( $this->photosProcessed == $this->totalPhotos ) {
+ $this->processingComplete = true;
}
break;
case 'filesProcess':
// Setup the file processing
require_once GLM_MEMBERS_PLUGIN_PATH . '/models/admin/ajax/fileUpload.php';
- $FileUpload = new GlmMembersAdmin_ajax_imageUpload($this->wpdb, $this->config);
+ $FileUpload = new GlmMembersAdmin_ajax_fileUpload($this->wpdb, $this->config);
// Setup the member_info class
require_once GLM_MEMBERS_PLUGIN_PATH . '/classes/data/dataMemberInfo.php';
$memberInfoObj = new GlmDataMemberInfo( $this->wpdb, $this->config );
+ $start = 1;
+ if ( isset( $_REQUEST['start'] ) ) {
+ $start = filter_var( $_REQUEST['start'], FILTER_VALIDATE_INT );
+ }
+
if ( is_file( $uploadPath . '/filesData.csv' ) ) {
// Get the entire files file data
- $filesData = $this->readCSVFile( $uploadPath . '/filesData.csv' );
- //echo '<pre>$filesData: ' . print_r( $filesData, true ) . '</pre>';
- $this->totalFiles = count( $filesData );
- $this->filesProcessed = count( $filesData );
+ $filesData = $this->readCSVFile( $uploadPath . '/filesData.csv' );
+ $this->totalFiles = count( $filesData );
- $refType = $this->config['ref_type_numb']['MemberInfo'];
+ $refType = $this->config['ref_type_numb']['MemberInfo'];
$refTable = $this->config['ref_type_table'][$refType];
// Loop through the filesData array
- foreach ( $filesData as $file ) {
- echo '<pre>$file: ' . print_r( $file, true ) . '</pre>';
+ // Find out how many are left to process.
+ $testEnd = $start + $this->fileProcessCountPerRound;
+ $ending = ( $testEnd <= $this->totalFiles ) ? $testEnd : $this->totalFiles;
+
+ // We have to add one to $ending (array starts at 1 not 0).
+ $ending++;
+ for ( $index = $start; $index < $ending; $index++ ) {
+ $file = $filesData[$index];
// If there's no url or the url is not valid then skip it.
- if ( $fileUrl = filter_var( $file['image'], FILTER_VALIDATE_URL ) ) {
- echo '<pre>$fileUrl: ' . print_r( $fileUrl, true ) . '</pre>';
+ if ( $fileUrl = filter_var( $file['file_url'], FILTER_VALIDATE_URL ) ) {
// Need to first get the member id from the database
// It will match from the old_member_id field
$memberId = $this->wpdb->get_var(
if ( !$memberId ) {
continue;
}
- echo '<pre>$memberId: ' . print_r( $memberId, true ) . '</pre>';
// Now that we have the member id we need to get the
// id for the active member info record
$memberInfoId = $memberInfoObj->getActiveInfoIdForMember( $memberId );
if ( !$memberInfoId ) {
continue;
}
- echo '<pre>$memberInfoId: ' . print_r( $memberInfoId, true ) . '</pre>';
$res = $FileUpload->storeFile(
$fileUrl,
$refType,
$refTable,
$memberInfoId,
- $file['caption']
+ $file['file_name']
);
}
+ $this->filesProcessed++;
}
// Set the view file
- $view= 'filesProcess.html';
+ $view = 'filesProcess.html';
} else {
// Set the view file
- $view= 'filesValidate.html';
+ $view = 'filesValidate.html';
+ }
+ // Here we need to check to see if we processed all members.
+ // Also the counter has to increment the total processed so far.
+ if ( $this->filesProcessed == $this->totalFiles ) {
+ $this->processingComplete = true;
}
- $view= 'filesValidate.html';
break;
case 'photos':
// Set the view file
- $view= 'photos.html';
+ $view = 'photos.html';
unset( $fileData );
if ( is_file( $uploadPath . '/photoData.csv' ) ) {
$fileExists = true;
'totalPhotos' => $this->totalPhotos,
'totalFiles' => $this->totalFiles,
'photosProcessed' => $this->photosProcessed,
+ 'filesProcessed' => $this->filesProcessed,
'completed' => $this->processingComplete,
'data' => false,
'fileData' => $fileData,
// create truncated short_descr from descriptions - less tags, html encoded characters, newlines, tabs, etc.
$stripped = str_replace(
- php_eol,
+ PHP_EOL,
'',
preg_replace( '/\t+/', '', preg_replace( "/&#?[a-z0-9]{2,8};/i", "", strip_tags( $data['descr'] ) ) )
);