/** * Lists the event listeners that will execute when cron runs. * * @author Nicholas Vahalik <*****@*****.**> */ public function listenersAction() { $modelMapping = array(); Wiz::getMagento(); $modelMapping = $this->getCrontabEvents(); echo Wiz::tableOutput($modelMapping); }
/** * 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!'); } }
/** * Displays the status of the specified indexing processes. * If no processes are specified, all will be shown. * * @return status of index processes * @author Nicholas Vahalik <*****@*****.**> */ public function statusAction($options) { Wiz::getMagento(); $processes = $this->_parseIndexerString(count($options) == 0 ? 'all' : implode(',', $options)); foreach ($processes as $process) { $row = array(); /* @var $process Mage_Index_Model_Process */ $status = 'Unknown'; switch ($process->getStatus()) { case Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX: $status = 'Require Reindex'; break; case Mage_Index_Model_Process::STATUS_RUNNING: $status = 'Processing'; break; case Mage_Index_Model_Process::STATUS_PENDING: $status = 'Ready'; break; } $mode = 'Unknown'; switch ($process->getMode()) { case Mage_Index_Model_Process::MODE_REAL_TIME: $mode = 'Update on Save'; break; case Mage_Index_Model_Process::MODE_MANUAL: $mode = 'Manual Update'; break; } $row['Name (code)'] = $process->getIndexer()->getName() . ' (' . $process->getIndexerCode() . ')'; $row['Status'] = $status; $row['Mode'] = $mode; $rows[] = $row; } echo Wiz::tableOutput($rows); }
/** * 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); }
/** * Lists all of the modules that are currently installed on the Magento installation, * the version in their xml file, the version of the setup resource in the database, * their code pool, and what their active flag is. * * @author Nicholas Vahalik <*****@*****.**> */ public static function listAction() { Wiz::getMagento(); $modules = (array) Mage::getConfig()->getNode('modules')->children(); $moduleList = array(); $coreResource = Mage::getSingleton('core/resource'); $connection = Mage::getSingleton('core/resource')->getConnection('core_read'); $select = $connection->select()->from($coreResource->getTableName('core/resource'), array('code', 'version')); $result = $connection->fetchPairs($select); foreach (Mage::getConfig()->getNode('global/resources')->children() as $resourceData) { $resourceMappings[(string) $resourceData->setup->module] = $resourceData->getName(); } foreach ($modules as $moduleName => $moduleData) { $flag = strtolower(Mage::getConfig()->getNode('advanced/modules_disable_output/' . $moduleName, 'default')); $moduleList[] = array('Module Name' => $moduleName, 'Version (xml)' => (string) $moduleData->version, 'Version (db)' => $resourceMappings[$moduleName] != '' ? (string) $result[$resourceMappings[$moduleName]] : 'n/a', 'Active' => $moduleData->active ? 'Active' : 'Disabled', 'Output' => !empty($flag) && 'false' !== $flag ? 'Disabled' : 'Enabled', 'Code Pool' => $moduleData->codePool); } echo Wiz::tableOutput($moduleList); }
/** * Displays the Varien_Profiler data to the screen. If it is not enabled, it will * indicate that it is disabled. * * @author Ben Robie <*****@*****.**> **/ function _flushProfileData() { $timers = Varien_Profiler::getTimers(); foreach ($timers as $name => $timer) { $sum = Varien_Profiler::fetch($name, 'sum'); $count = Varien_Profiler::fetch($name, 'count'); $realmem = Varien_Profiler::fetch($name, 'realmem'); $emalloc = Varien_Profiler::fetch($name, 'emalloc'); if ($sum < 0.001 && $count < 10 && $emalloc < 10000) { continue; } $output[] = array('Code Profiler' => $name, 'Time' => $sum, 'Cnt' => (string) $count, 'Emalloc' => (string) number_format($emalloc), 'RealMem' => (string) number_format($realmem)); } echo Wiz::tableOutput($output); }
/** * Retrieve a single store configuration node path. * * Example: config-storget sales_email/order/enabled * This will return the value in the configuration if the order e-mails are enabled. * * Options: * --all Returns the value for all stores in the Magento installation. * * @param Node path string. * @author Nicholas Vahalik <*****@*****.**> */ public function storegetAction($options) { $stores = $output = array(); Wiz::getMagento(); if (Wiz::getWiz()->getArg('all')) { $storeCollection = Mage::getModel('core/store')->getCollection(); foreach ($storeCollection as $store) { $stores[] = $store->getCode(); } } elseif (count($options) > 1) { $stores = array(array_shift($options)); } else { $stores = array('default'); } $path = array_shift($options); foreach ($stores as $store) { $output[] = array('Store Id' => $store, $path => Mage::getStoreConfig($path, $store)); // echo "($store) $path" . ' = ' . Mage::getStoreConfig($path, $store);// Wiz::getMagento()-> } echo Wiz::tableOutput($output); echo PHP_EOL; }
/** * 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); }
/** * Displays statistics for each log table. * * Adapted from the log.php that ships with Magento. * * @author Nicholas Vahalik <*****@*****.**> */ public function statusAction() { Wiz::getMagento(); $resource = $this->_getLog()->getResource(); $adapter = $resource->getReadConnection(); // log tables $tables = array($resource->getTable('log/customer'), $resource->getTable('log/visitor'), $resource->getTable('log/visitor_info'), $resource->getTable('log/url_table'), $resource->getTable('log/url_info_table'), $resource->getTable('log/quote_table'), $resource->getTable('reports/viewed_product_index'), $resource->getTable('reports/compared_product_index'), $resource->getTable('reports/event'), $resource->getTable('catalog/compare_item')); $rows = 0; $dataLength = 0; $indexLength = 0; $rowData = array(); foreach ($tables as $table) { $query = $adapter->quoteInto('SHOW TABLE STATUS LIKE ?', $table); $status = $adapter->fetchRow($query); if (!$status) { continue; } $rows += $status['Rows']; $dataLength += $status['Data_length']; $indexLength += $status['Index_length']; $rowData[] = array('Table Name' => $table, 'Rows' => $this->_humanCount($status['Rows']), 'Data Size' => $this->_humanSize($status['Data_length']), 'Index Size' => $this->_humanSize($status['Index_length'])); } $rowData[] = '-'; $rowData[] = array('Table Name' => 'Totals', 'Rows' => $this->_humanCount($rows), 'Data Size' => $this->_humanSize($dataLength), 'Index Size' => $this->_humanSize($indexLength)); echo Wiz::tableOutput($rowData); }
/** * 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); }