Skip to content

Commit

Permalink
Fixed new lines for phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mussulis committed Aug 30, 2023
1 parent e4d42d2 commit 827d2c8
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 13 deletions.
2 changes: 2 additions & 0 deletions magmi/inc/fshelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ public function unlink($path)
*/
public function copyFromRemote($remoteurl, $destpath)
{
error_log("copyFromRemote()" . __LINE__);
$rfg = RemoteFileGetterFactory::getFGInstance($this->_rfgid);
$mp = str_replace("//", "/", $this->_magdir . "/" . str_replace($this->_magdir, '', $destpath));
$ok = $rfg->copyRemoteFile($remoteurl, $mp);
Expand All @@ -387,6 +388,7 @@ public function copyFromRemote($remoteurl, $destpath)
*/
public function copy($srcpath, $destpath)
{
error_log("copy() " . __LINE__);
$result = false;
$destpath = str_replace("//", "/", $this->_magdir . "/" . str_replace($this->_magdir, '', $destpath));
if (preg_match('|^.*?://.*$|', $srcpath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
?>
<span> No csv files found in <?php echo $self->getScanDir(false)?></span>
<?php
}?>
}?>
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@
$('<?php echo $prefix ?>:update_cb').observe('click',showHideAttributeGroups);
<?php
} ?>
</script>
</script>
2 changes: 1 addition & 1 deletion magmi/plugins/base/datasources/csv/csvds_filelist.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
?>
<span> No csv files found in <?php echo $this->getScanDir(false)?></span>
<?php
}?>
}?>
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
checked="checked" <?php
}?>>Delete children products</li>

</ul>
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function initialize($params)
$this->magdir = Magmi_Config::getInstance()->getMagentoDir();
$this->_mdh = MagentoDirHandlerFactory::getInstance()->getHandler($this->magdir);
$this->_mdh->setRemoteGetterId("image");
error_log("mdh: " . get_class($this->_mdh));

// remote root
if ($this->getParam("IMG:remoteroot", "")) {
Expand Down Expand Up @@ -439,12 +440,15 @@ public function saveImage($imgfile, $target)
*/
public function copyImageFile($imgfile, &$item, $extra)
{
error_log("in copyImageFile");
if ($imgfile == "__NULL__" || $imgfile == null) {
error_log("$imgfile is null");
return false;
}

// check for source image in error
if ($this->isErrorImage($imgfile)) {
error_log("Error $imgfile");
if ($this->_newitem) {
$this->fillErrorAttributes($item);
};
Expand All @@ -453,12 +457,14 @@ public function copyImageFile($imgfile, &$item, $extra)

//handle remote root per image
if (!is_remote_path($imgfile)) {
error_log("! is_remote_path $imgfile");
if ($this->_remoteroot != "") {
$imgfile = $this->_remoteroot . str_replace("//", "/", "/$imgfile");
}
}
//handle amazon specific
if (is_remote_path($imgfile)) {
error_log("is_remote_path $imgfile");
// Amazon images patch , remove SLXXXX part
if (preg_match('|amazon\..*?/images/I|', $imgfile)) {
$pattern = '/\bSL[0-9]+\./i';
Expand All @@ -468,6 +474,7 @@ public function copyImageFile($imgfile, &$item, $extra)

$source = $this->findImageFile($imgfile);
if ($source == false) {
error_log("$imgfile not found");
$this->log("$imgfile cannot be found in images path", "warning");
// last image in error,add it to error cache
$this->setErrorImg($imgfile);
Expand All @@ -484,30 +491,36 @@ public function copyImageFile($imgfile, &$item, $extra)
$impath = "/$i1/$i2/$bimgfile";
// target directory;

if(!strstr(getcwd(), "pub")) {
error_log("current cwd: " . getcwd());
if(!strstr(getcwd(), "pub"))
$l2d = "pub/media/catalog/product/$i1/$i2";
}
else {
else
$l2d = "media/catalog/product/$i1/$i2";
}

// test for existence
$targetpath = "$l2d/$bimgfile";
error_log("l2d " . $l2d);
error_log("targetpath " . $targetpath);

/* test for same image (without problem) */
if ($impath == $this->_lastimage) {
return $impath;
}

error_log("mdh->file_exists() " . $this->_mdh->file_exists($targetpath));
error_log("writemode " . $this->getParam("IMG:writemode"));

/* test if imagefile comes from export */
if (!$this->_mdh->file_exists($targetpath) || $this->getParam("IMG:writemode") == "override") {
error_log("file not exists || writemode is override");
// if we already had problems with this target,assume we'll get others.
if ($this->isErrorImage($impath)) {
error_log("isError");
return false;
}

/* try to recursively create target dir */
if (!$this->_mdh->file_exists($l2d)) {
error_log("creating target dir");
$tst = $this->_mdh->mkdir($l2d, Magmi_Config::getInstance()->getDirMask(), true);
if (!$tst) {
// if we had problem creating target directory,add target to error cache
Expand All @@ -520,16 +533,19 @@ public function copyImageFile($imgfile, &$item, $extra)
}

if (!$this->saveImage($imgfile, $targetpath)) {
error_log("saving image");
$errors = $this->_mdh->getLastError();
$this->fillErrorAttributes($item);
$this->log("error copying $l2d/$bimgfile : {$errors["type"]},{$errors["message"]}", "warning");
unset($errors);
$this->setErrorImg($impath);
return false;
} else {
error_log("save image failed");
@$this->_mdh->chmod("$l2d/$bimgfile", Magmi_Config::getInstance()->getFileMask());

if ($this->getParam("IMG:storeindb", "no") == "yes") {
error_log("store in DB");
/* create target dirs if they don't exist */
$dir_table = $this->tablename('core_directory_storage');
// get "catalog/product" path ID
Expand Down Expand Up @@ -575,6 +591,7 @@ public function copyImageFile($imgfile, &$item, $extra)
}
$this->_lastimage = $impath;
/* return image file name relative to media dir (with leading / ) */
error_log("returning " . $impath);
return $impath;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
</li>
</ul>

</div>
</div>
1 change: 1 addition & 0 deletions magmi/plugins/utilities/clearproducts/clearproduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function runUtility()
}

//clean url rewrites for products
//$sql = "DELETE FROM ".$this->tablename("core_url_rewrite")." WHERE product_id IS NOT NULL AND is_system=1";
$sql = "DELETE FROM ".$this->tablename("url_rewrite")." WHERE entity_id IS NOT NULL AND is_autogenerated=1";
$this->delete($sql);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
?>
<span> No csv files found in <?php echo $this->getScanDir(false)?></span>
<?php
}?>
}?>
2 changes: 1 addition & 1 deletion magmi/web/magmi_progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,4 @@ class='log_end <?php if (count($parser->getData("error")) > 0) {
</div>
<script type="text/javascript">endImport();</script>
<?php endif?>
<?php endif?>
<?php endif?>
2 changes: 1 addition & 1 deletion magmi/web/progress_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
}
}
?>
</ul>
</ul>

0 comments on commit 827d2c8

Please sign in to comment.