示例#1
0
 public function report()
 {
     $errors = count($this->errors['sku']) + count($this->errors['name']);
     $success = count($this->products) - $errors;
     $tab = new Tabs();
     $report = new Report();
     $tab->start();
     $tab->start("buttons");
     $tab->button("info", false, true);
     $success > 0 ? $tab->button("success", $success) : $tab->button("success");
     $errors > 0 ? $tab->button("errors", $errors) : $tab->button("errors");
     $tab->end("buttons");
     $tab->start("entries");
     $tab->entry("info", true);
     $report->start("import data");
     $report->entry("info", "info", "Products to be added: " . count($this->products));
     $report->entry($errors > 0 ? "warning" : "success", $errors > 0 ? "warning" : "success", "Products added: {$success}");
     $report->entry($errors > 0 ? "warning" : "info", $errors > 0 ? "warning" : "info", "Errors: {$errors}");
     $report->entry("info", "info", "Clearing parsed data and import file");
     if (unlink($_SESSION['upload_file'])) {
         unset($_SESSION['upload_file']);
         unset($_SESSION['products']);
         $report->entry("success", "success", "Cleared parsed data");
     }
     if ($errors == 0) {
         $report->entry("success", "success", "Import completed without errors");
     } else {
         $report->entry("warning", "warning", "Import completed with errors please review");
     }
     $report->end();
     $tab->entry("end");
     $tab->entry("success");
     $report->start("Successful product creation");
     foreach ($this->products as $key => $product) {
         if (!in_array($product['sku'], $this->errors['sku']) && !in_array($product['name'], $this->errors['name'])) {
             $report->entry("success", "product: {$key}", "Added: " . $product['name']);
         }
     }
     if ($success == 0) {
         $report->entry("info", "info", "No products we're added");
     }
     $report->end();
     $tab->entry("end");
     $tab->entry("errors");
     if (count($this->errors['sku']) > 0) {
         $report->start("Sku duplicates");
         foreach ($this->products as $key => $product) {
             if (in_array($product['sku'], $this->errors['sku'])) {
                 $report->entry("warning", "product: {$key}", "Failed to add product: " . $product['name'] . "<br />Due to duplicated sku: " . $product['sku'] . "<br/>Existing product: " . $this->duplicates[$product['sku']]);
             }
         }
         $report->end();
     }
     if (count($this->errors['name']) > 0) {
         $report->start("Name duplicates");
         foreach ($this->products as $key => $product) {
             if (in_array($product['name'], $this->errors['name'])) {
                 $report->entry("warning", "product: {$key}", "Failed to add product: " . $product['name'] . "<br />Due to not having a valid sku and provided name already exists<br/>Existing product: " . $product['sku']);
             }
         }
         $report->end();
     }
     if ($errors == 0) {
         $report->start("Import errors");
         $report->entry("info", "info", "No products have errors");
         $report->end();
     }
     $tab->entry("end");
     $tab->end("entries");
     $tab->end();
 }
示例#2
0
 /**
  * Tests that the timer method returns the expected result.
  *
  * @return void
  */
 public function testReportTimerReturnsMilliSeconds()
 {
     $start = microtime(true);
     $report = new Report();
     $report->start();
     usleep(50000);
     // 50 Milli Seconds
     $report->end();
     $time = ceil((microtime(true) - $start) * 1000.0);
     $this->assertGreaterThanOrEqual(50.0, $report->getElapsedTimeInMillis());
     $this->assertLessThanOrEqual($time, $report->getElapsedTimeInMillis());
 }
示例#3
0
文件: PHPMD.php 项目: flavius/phpmd
 /**
  * This method will process all files that can be found in the given input
  * path. It will apply rules defined in the comma-separated <b>$ruleSets</b>
  * argument. The result will be passed to all given renderer instances.
  *
  * @param string $inputPath
  * @param string $ruleSets
  * @param \PHPMD\AbstractRenderer[] $renderers
  * @param \PHPMD\RuleSetFactory $ruleSetFactory
  * @return void
  */
 public function processFiles($inputPath, $ruleSets, array $renderers, RuleSetFactory $ruleSetFactory)
 {
     // Merge parsed excludes
     $this->ignorePatterns = array_merge($this->ignorePatterns, $ruleSetFactory->getIgnorePattern($ruleSets));
     $this->input = $inputPath;
     $report = new Report();
     $factory = new ParserFactory();
     $parser = $factory->create($this);
     foreach ($ruleSetFactory->createRuleSets($ruleSets) as $ruleSet) {
         $parser->addRuleSet($ruleSet);
     }
     $report->start();
     $parser->parse($report);
     $report->end();
     foreach ($renderers as $renderer) {
         $renderer->start();
     }
     foreach ($renderers as $renderer) {
         $renderer->renderReport($report);
     }
     foreach ($renderers as $renderer) {
         $renderer->end();
     }
     $this->violations = !$report->isEmpty();
 }
示例#4
0
 public function check_flux()
 {
     $report = new Report();
     $report->start("flux files");
     $report->entry("info", "Flux Settings", "Off");
     $report->entry("info", "Flux Settings", "Checking for existing files");
     $files['Up'] = "../var/magmi-import/flux-up/Flux - {$this->collection_name}.csv";
     $files['Down'] = "../var/magmi-import/flux-down/Flux - {$this->collection_name}.csv";
     foreach ($files as $key => $file) {
         if (is_file($file)) {
             $report->entry("success", "{$key} File", "File exists, deleting file");
             unlink($file);
         } else {
             $report->entry("default", "{$key} File", "File does not exist, doing nothing");
         }
     }
     $report->end();
 }
示例#5
0
 public function manage()
 {
     global $db;
     $blacklist = $db->select("blacklist");
     $report = new Report();
     $report->start("words & phrases", 3);
     if ($blacklist) {
         foreach ($blacklist as $phrase) {
             if (strpos($phrase['word'], " ") !== false) {
                 $format = "phrase";
             } else {
                 $format = "word";
             }
             $report->entry("default", $format, $phrase['word'] . "||<a class='btn btn-xs btn-danger' href='blacklist.php?d=" . $phrase['id'] . "' role='button'>delete</a>");
         }
     } else {
         $report->entry("danger", "error", "You seriously need to sit down and think about your life.");
     }
     $report->end();
 }
示例#6
0
文件: m2e.php 项目: HQPDevCrew/BPU
///////////////////
// Start Script	 //
///////////////////
$mage_db = new MageDB();
$results = $mage_db->select("catalog_product_entity", null, "entity_id,sku");
if ($results) {
    foreach ($results as $result) {
        $mp[$result['entity_id']] = $result['sku'];
    }
} else {
    $mp = $results;
}
$ai = $mage_db->select("m2epro_amazon_listing_product", null, "listing_product_id,sku");
if ($mp and $ai) {
    if ($_SESSION['display']) {
        $report->start("Comparing Amazon Item Sku's to Products", 3);
    }
    foreach ($ai as $si) {
        $result = $mage_db->select("m2epro_listing_product", $si['listing_product_id'], "product_id", 1);
        $si['product_id'] = $result['product_id'];
        if ($mp[$si['product_id']] !== $si['sku']) {
            if ($_SESSION['display']) {
                $entry = $mp[$si['product_id']] . "||" . $si['sku'];
                $report->entry("warning", $si['product_id'], $entry);
            } else {
                $mage_db->delete("m2epro_amazon_listing_product", "`listing_product_id` = " . $si['listing_product_id']);
                $mage_db->delete("m2epro_listing_product", $si['listing_product_id']);
                $html->redirection("../scripts.php");
            }
        }
        // else if($_SESSION['display']) {
示例#7
0
    }
}
$_SESSION['display'] = isset($display) ? $display : true;
if ($_SESSION['display']) {
    echo '<div class="container-fluid"><div class="row"><div class="col-xs-12 text-center"><h3>Running Redundant Category Cleanse</h3></div></div><hr /><div class="row"><div class="col-xs-6 col-xs-offset-3">';
}
///////////////////
// Start Script	 //
///////////////////
require "../../app/Mage.php";
Mage::register('isSecureArea', true);
umask(0);
Mage::app();
$categoryCollection = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addFieldToFilter('level', array('gteq' => 2));
//greater than root category id
$report->start("Deleting Empty Categories");
$deleted = 0;
foreach ($categoryCollection as $category) {
    $cname = strtolower($category->getName());
    if ($cname !== "ebay listings" and $cname !== "amazon listings") {
        if ($category->getProductCount() === 0) {
            $deleted++;
            if (!$disable) {
                $report->entry("success", $category->getName(), "Deleted");
                $category->delete();
            } else {
                $report->entry("info", $category->getName(), $category->getProductCount());
            }
        } else {
            $report->entry("info", $category->getName(), $category->getProductCount());
        }