Exemple #1
0
 /**
  * Get the versions that are available on Magento connect for a given Magento Connect key.
  *
  * @param Magento Connect 1.0 or 2.0 Key.
  * @author Nicholas Vahalik <*****@*****.**>
  */
 public function versionsAction($options)
 {
     if (count($options) == 0) {
         echo 'Please supply a Magento Connect 1.0 or 2.0 key.';
     }
     $key = $options[0];
     if (strpos($key, 'connect20') !== FALSE) {
         if (($releases = $this->_getReleaseInformation($key)) !== FALSE) {
             $releases = array_reverse($releases);
             foreach ($releases as $d => $a) {
                 $releases[$d]['Version'] = $a['v'];
                 $releases[$d]['Status'] = $a['s'];
                 $releases[$d]['Date'] = $a['d'];
                 unset($releases[$d]['v']);
                 unset($releases[$d]['d']);
                 unset($releases[$d]['s']);
             }
             echo Wiz::tableOutput($releases);
         } else {
             throw new Exception('Unable to find release information.  Did you pass the right URL?');
         }
     } else {
         throw new Exception('Only support MC 2.0 keys at this time.  Sorry!');
     }
 }
Exemple #2
0
 private function _getDbConfig($config = 'core')
 {
     Wiz::getMagento();
     $resources = Mage::getSingleton('core/resource');
     $connection = $resources->getConnection('core');
     $config = $connection->getConfig();
     return $config;
 }
Exemple #3
0
 /**
  * Lists all of the stores, store codes, and websites on the magento installation.
  *
  * @author Nicholas Vahalik <*****@*****.**>
  */
 public static function listAction()
 {
     Wiz::getMagento();
     $storeCollection = Mage::getModel('core/store')->getCollection();
     foreach ($storeCollection as $store) {
         $rows[] = array('Website (Id)' => $store->getWebsite()->getCode() . ' (' . $store->getWebsiteId() . ')' . ($store->getWebsite()->getIsDefault() ? ' default' : ''), 'Group (Id)' => $store->getGroup()->getName() . ' (' . $store->getGroup()->getId() . ')', 'Code (Id)' => $store->getName() . ' (' . $store->getCode() . ')', 'Active' => $store->getIsActive());
     }
     echo Wiz::tableOutput($rows);
 }
Exemple #4
0
 /**
  * Runs the cron.
  *
  * @author Nicholas Vahalik <*****@*****.**>
  */
 public function runAction($options)
 {
     Wiz::getMagento();
     Mage::app('admin')->setUseSessionInUrl(false);
     try {
         Mage::getConfig()->init()->loadEventObservers('crontab');
         Mage::app()->addEventArea('crontab');
         Mage::dispatchEvent('default');
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemple #5
0
 /**
  * Converts a Google Sitemap XML file to a CSV File.
  *
  * @param string $options 
  * @return void
  * @author Nicholas Vahalik <*****@*****.**>
  */
 public function xmlsm2csvAction($options)
 {
     $settings['path-only'] = Wiz::getWiz()->getArg('path-only');
     $filename = array_shift($options);
     switch (strtolower(substr($filename, -3))) {
         case 'xml':
             $xml = simplexml_load_file($filename);
             if ($xml->getName() != 'urlset') {
                 throw new Exception('This does not look like an XML sitemap.');
             }
             $output = fopen('php://temp', 'rw');
             foreach ($xml->url as $node) {
                 if ($settings['path-only']) {
                     $pathinfo = parse_url((string) $node->loc);
                     $url = $pathinfo['path'];
                 } else {
                     $url = (string) $node->loc;
                 }
                 fputcsv($output, array($url));
             }
             rewind($output);
             while ($stuff = fgets($output, 1024)) {
                 echo $stuff;
             }
             break;
         default:
             throw new Exception('Invalid file format.');
     }
 }
Exemple #6
0
 /**
  * Removes the maintenance flag, allowing Magento to run.
  *
  * @author Nicholas Vahalik <*****@*****.**>
  */
 function startAction()
 {
     if (($magentoRoot = Wiz::getMagentoRoot()) === FALSE) {
         throw new Exception('Unable to find Magento.');
     }
     $maintenanceFile = $magentoRoot . WIZ_DS . 'maintenance.flag';
     if (!file_exists($maintenanceFile)) {
         echo 'Maintenance file does not exist.' . PHP_EOL;
         return;
     }
     if (!is_writable($maintenanceFile)) {
         throw new Exception('Cannot remove maintenance flag file.  Is the directory writable?');
     }
     unlink($maintenanceFile);
     echo 'Magento maintenance flag has been removed.' . PHP_EOL;
 }
Exemple #7
0
 /**
  * Replace the standard 3 spaces asXml products with whatever we want.
  *
  * @param string $matches
  * @return void
  * @author Nicholas Vahalik <*****@*****.**>
  */
 protected function _replaceSpaces($matches)
 {
     $newSpaces = (int) Wiz::getWiz()->getArg('indent');
     return str_repeat(' ', strlen($matches[1]) / 3 * $newSpaces);
 }
Exemple #8
0
 /**
  * Displays a full list of resources that are defined by modules in Magento.
  *
  * @param string $options 
  * @return void
  * @author Nicholas Vahalik <*****@*****.**>
  */
 public function resourcesAction($options)
 {
     $formattedOutput = $output = array();
     Wiz::getMagento();
     $aclResources = Mage::getModel('admin/config')->getAdminhtmlConfig()->getNode("acl/resources");
     $output = $this->_recurseXmlWalkResources($aclResources->admin);
     foreach ($output as $data) {
         $formattedOutput[] = array('Path' => $data[0], 'Title' => $data[1]);
     }
     usort($formattedOutput, array($this, '_sortAclEntries'));
     echo Wiz::tableOutput($formattedOutput);
 }
Exemple #9
0
 /**
  * Disables output for a module.  This performs the same task as the Disable Module
  * Output page in the Magento backend.
  *
  * @author Nicholas Vahalik <*****@*****.**>
  */
 public static function disableoutputAction($options)
 {
     if (count($options) < 1) {
         echo 'Please provide modules names to enable.' . PHP_EOL;
     }
     $modulesDisable = $modulesAlreadyDisabled = array();
     Wiz::getMagento();
     $modules = (array) Mage::getConfig()->getNode('modules')->children();
     foreach ($options as $moduleName) {
         foreach ($modules as $systemModuleName => $moduleData) {
             if (strtolower($moduleName) == strtolower($systemModuleName)) {
                 $flag = strtolower(Mage::getConfig()->getNode('advanced/modules_disable_output/' . $systemModuleName, 'default'));
                 if (empty($flag) || 'false' === $flag) {
                     Mage::getConfig()->saveConfig('advanced/modules_disable_output/' . $systemModuleName, TRUE);
                     // self::changeModuleOutput($systemModuleName, 'disabled');
                     $modulesDisabled[] = $systemModuleName;
                 } else {
                     $modulesAlreadyDisabled[] = $systemModuleName;
                 }
                 break;
             }
         }
     }
     if (count($modulesDisabled) > 0) {
         echo 'Module(s) disabled: ' . implode(', ', $modulesDisabled) . PHP_EOL;
         Mage::getConfig()->removeCache();
     }
     if (count($modulesAlreadyDisabled)) {
         echo 'Module(s) already disabled: ' . implode(', ', $modulesAlreadyDisabled) . PHP_EOL;
     }
 }
Exemple #10
0
 /**
  * Cleans Magento's database logs.  Uses Magento's global settings.
  * 
  * Adapted from the log.php that ships with Magento.
  * 
  * @author Nicholas Vahalik <*****@*****.**>
  */
 public function cleanAction()
 {
     Wiz::getMagento('');
     $this->_getLog()->clean();
     $savedDays = Mage::getStoreConfig(Mage_Log_Model_Log::XML_LOG_CLEAN_DAYS);
     echo "Log cleaned. Log days saved: {$savedDays}" . PHP_EOL;
 }
Exemple #11
0
<?php

/**
 * Wiz
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * http://opensource.org/licenses/osl-3.0.php
 *
 * DISCLAIMER
 * 
 * This program is provided to you AS-IS.  There is no warranty.  It has not been
 * certified for any particular purpose.
 *
 * @package    Wiz
 * @author     Nick Vahalik <*****@*****.**>
 * @copyright  Copyright (c) 2012 Classy Llama Studios, LLC
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
include 'app/Wiz.php';
$wiz = Wiz::getWiz();
$wiz->run();
Exemple #12
0
 public static function batchOutput($table)
 {
     $format = Wiz::getWiz()->getArg('batch');
     if (!is_array($table) || count($table) < 1 || !is_array($table[0])) {
         $table = array(array('Result' => 'No Data'));
     }
     $keys = array_keys($table[0]);
     $delimiter = $enclosure = '"';
     array_unshift($table, $keys);
     switch ($format) {
         case 'csv':
         default:
             $delimiter = ',';
             $enclosure = '"';
             // Quickly put everything
             break;
         case 'pipe':
             $delimiter = '|';
             break;
         case 'tab':
             $delimiter = "\t";
             break;
     }
     // We use some memory here to quickly create a CSV file.
     $csv = fopen('php://temp/maxmemory:' . 5 * 1024 * 1024, 'r+');
     foreach ($table as $row) {
         fputcsv($csv, $row, $delimiter, $enclosure);
     }
     rewind($csv);
     $output = stream_get_contents($csv);
     return $output;
 }
Exemple #13
0
 /**
  * Changes the status of the indexing processes to "Manual".
  * If no processes are specified, all processes will be set.
  *
  * @param processes to index
  * @author Nicholas Vahalik <*****@*****.**>
  */
 public function manualAction($options)
 {
     Wiz::getMagento();
     $processes = $this->_parseIndexerString(count($options) == 0 ? 'all' : implode(',', $options));
     $updated = $this->_setMode($processes, Mage_Index_Model_Process::MODE_MANUAL);
     echo 'Index' . (count($updated) > 1 ? 'es' : '') . ' set to Manual: ' . implode(', ', $updated) . PHP_EOL;
 }
Exemple #14
0
 /**
  * Attempts to output a list of dispatched Magento Events.  Currently, it iterates
  * recursively over the app/ directory and looks for instances where Mage::dispatchEvent
  * is called.  It then outputs the first parameter as the "event."  Some events have
  * variables inside of them (like EAV product events and some controller events).
  *
  * @return void
  * @author Nicholas Vahalik <*****@*****.**>
  */
 public function eventsAction()
 {
     Wiz::getMagento();
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(Wiz::getMagentoRoot() . DIRECTORY_SEPARATOR . 'app'));
     foreach ($iterator as $file) {
         if (preg_match('#.php$#', $file->getFilename())) {
             $phpFiles[] = $file->getRealpath();
         }
     }
     $baseClasses = get_declared_classes();
     foreach ($phpFiles as $fileName) {
         $matches = array();
         include $fileName;
         // echo get_include_path().PHP_EOL;
         $extraClasses = get_declared_classes();
         // var_dump(array_diff($extraClasses, $baseClasses));
         $fileSource = file_get_contents($fileName);
         preg_match_all('#Mage::dispatchEvent\\((.*)\\);#m', $fileSource, $matches);
         if (count($matches) > 1 && count($matches[1]) > 1) {
             foreach ($matches[1] as $match) {
                 if (strpos($match, ',') !== FALSE) {
                     $stuff = explode(',', $match);
                     $eventName = trim($stuff[0]);
                 } else {
                     $eventName = $match;
                 }
                 if (substr($stuff[0], 0, 1) == "'" || substr($stuff[0], 0, 1) == '"') {
                     $eventName = substr(trim($stuff[0]), 1, -1);
                 }
                 $events[] = $eventName;
             }
         }
     }
     $events = array_unique($events);
     sort($events);
     foreach ($events as $eventName) {
         $eventOutput[] = array('Event Name' => $eventName);
     }
     echo Wiz::tableOutput($eventOutput);
 }