/** * Check file system path * * @param string $path * @param bool $recursive * @param bool $existence * @param string $mode * @return bool */ protected function _checkPath($path, $recursive, $existence, $mode) { $res = true; $fullPath = dirname(Mage::getRoot()) . $path; if ($mode == self::MODE_WRITE) { $setError = false; if ($existence) { if (is_dir($fullPath) && !is_dir_writeable($fullPath) || !is_writable($fullPath)) { $setError = true; } } else { if (file_exists($fullPath) && !is_writable($fullPath)) { $setError = true; } } if ($setError) { $this->_getInstaller()->getDataModel()->addError(Mage::helper('install')->__('Path "%s" must be writable.', $fullPath)); $res = false; } } if ($recursive && is_dir($fullPath)) { foreach (new DirectoryIterator($fullPath) as $file) { if (!$file->isDot() && $file->getFilename() != '.svn' && $file->getFilename() != '.htaccess') { $res = $res && $this->_checkPath($path . DS . $file->getFilename(), $recursive, $existence, $mode); } } } return $res; }
/** * @magentoAppIsolation enabled */ public function testReset() { Mage::setRoot(dirname(__FILE__)); $this->assertNotNull(Mage::getRoot()); Mage::reset(); $this->assertNull(Mage::getRoot()); }
/** * Initialize default values of the options * * @param array $data */ public function __construct(array $data = array()) { $this->_io = isset($data['io']) ? $data['io'] : new Varien_Io_File(); unset($data['io']); parent::__construct($data); $appRoot = isset($data['app_dir']) ? $data['app_dir'] : Mage::getRoot(); $root = dirname($appRoot); $this->_data['app_dir'] = $appRoot; $this->_data['base_dir'] = $root; $this->_data['code_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'code'; $this->_data['design_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'design'; $this->_data['etc_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'etc'; $this->_data['lib_dir'] = $root . DIRECTORY_SEPARATOR . 'lib'; $this->_data['locale_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'locale'; $this->_data['pub_dir'] = $root . DIRECTORY_SEPARATOR . 'pub'; $this->_data['js_dir'] = $this->_data['pub_dir'] . DIRECTORY_SEPARATOR . 'lib'; $this->_data['media_dir'] = isset($data['media_dir']) ? $data['media_dir'] : $this->_data['pub_dir'] . DIRECTORY_SEPARATOR . 'media'; $this->_data['var_dir'] = $this->getVarDir(); $this->_data['tmp_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'tmp'; $this->_data['cache_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'cache'; $this->_data['log_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'log'; $this->_data['session_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'session'; $this->_data['upload_dir'] = $this->_data['media_dir'] . DIRECTORY_SEPARATOR . 'upload'; $this->_data['export_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'export'; }
public function saveMenuCache() { try { //$defaultStoreId = Mage::app()->getWebsite()->getDefaultGroup()->getDefaultStoreId(); //Mage::app()->setCurrentStore($defaultStoreId); //Mage::getSingleton('core/session', array('name'=>'frontend')); //$_layout = Mage::getSingleton('core/layout'); //$_block = $_layout->createBlock('page/html_topmenu')/*->setTemplate('page/html/topmenu.phtml')*/; //$html=$_block->getHtml(); Mage::app()->loadArea('frontend'); $layout = Mage::getSingleton('core/layout'); //load default xml layout handle and generate blocks $layout->getUpdate()->load('default'); $layout->generateXml()->generateBlocks(); //get the loaded head and header blocks and output $headerBlock = $layout->getBlock('header'); $html = $headerBlock->toHtml(); $filename = dirname(Mage::getRoot()) . DS . 'media' . DS . 'wp' . DS . 'topmenu'; file_put_contents($filename, $html); //Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); //Mage::getSingleton('core/session', array('name'=>'admintml')); } catch (Exception $e) { Mage: log($e->getMessage(), null, 'wp_menu_error.log'); } }
/** * @return array */ public function themeConfigFileDataProvider() { $result = array(); foreach (glob(Mage::getRoot() . '/design/*/*/*/theme.xml') as $file) { $result[] = array($file); } return $result; }
protected function _config() { if (is_null($this->_localConfig)) { $path = Mage::getRoot() . '/etc/local.xml'; if (file_exists($path)) { $this->_localConfig = new Zend_Config_Xml($path); } } return $this->_localConfig; }
public function __construct() { $this->_etcDir = Mage::getRoot() . '/etc/'; $this->_codeDir = Mage::getRoot() . '/code/'; $this->_rewriteDir = dirname(Mage::getRoot()) . self::REWRITE_CACHE_DIR; $this->_checkClassDir[] = $this->_codeDir . 'local/'; $this->_checkClassDir[] = $this->_codeDir . 'community/'; $this->_checkClassDir[] = $this->_codeDir . 'core/'; if (!file_exists($this->_rewriteDir)) { $this->tool()->filesystem()->mkDir($this->_rewriteDir); } }
/** * Process file * * @param string $filename Filename * * @return boolean|void */ public function processFile($filename) { $file = $this->getFilePath($filename); if ('' == $filename || !file_exists($file)) { return false; } $filename = basename($file); $this->saveProgress($filename); $suffix = '> /dev/null 2>/dev/null &'; $script = Mage::getRoot() . "/../shell/nedisimport.php --file '{$filename}'"; exec('php ' . $script . ' ' . $suffix); }
public function wpMenuCache() { try { $filename = dirname(Mage::getRoot()) . DS . 'media' . DS . 'wp' . DS . 'topmenu'; if (file_exists($filename)) { @unlink($filename); } $url = "http://" . $_SERVER['HTTP_HOST'] . "/mg2wp/index.php/?block=topmenu"; $html = @file_get_contents($url); //Mage::log($html,null,'wp_menu.log'); } catch (Exception $e) { Mage::log($e->getMessage(), null, 'wp_menu_error.log'); } }
public function __construct($options = array(), $dbSettings = array()) { $this->_defaultBackendOptions['cache_dir'] = dirname(Mage::getRoot()) . DS . 'var' . DS . 'cache'; // Initialize id prefix $this->_idPrefix = isset($options['id_prefix']) ? $options['id_prefix'] : ''; if (!$this->_idPrefix && isset($options['prefix'])) { $this->_idPrefix = $options['prefix']; } if (empty($this->_idPrefix)) { $etcDir = Mage::getRoot() . DS . 'etc'; $this->_idPrefix = substr(md5($etcDir), 0, 3) . '_'; } // init database resource $this->_resource = new Aitoc_Aitsys_Model_Core_Cache_Resource($dbSettings); // collect cache options $backend = $this->_getBackendOptions($options); $frontend = $this->_getFrontendOptions($options); $this->_frontend = Zend_Cache::factory('Varien_Cache_Core', $backend['type'], $frontend, $backend['options'], true, true, true); }
/** * Initialize default values of the options */ protected function _construct() { $appRoot = Mage::getRoot(); $root = dirname($appRoot); $this->_data['app_dir'] = $appRoot; $this->_data['base_dir'] = $root; $this->_data['code_dir'] = $appRoot . DS . 'code'; $this->_data['design_dir'] = $appRoot . DS . 'design'; $this->_data['etc_dir'] = $appRoot . DS . 'etc'; $this->_data['lib_dir'] = $root . DS . 'lib'; $this->_data['locale_dir'] = $appRoot . DS . 'locale'; $this->_data['media_dir'] = $root . DS . 'media'; $this->_data['skin_dir'] = $root . DS . 'skin'; $this->_data['var_dir'] = $this->getVarDir(); $this->_data['tmp_dir'] = $this->_data['var_dir'] . DS . 'tmp'; $this->_data['cache_dir'] = $this->_data['var_dir'] . DS . 'cache'; $this->_data['log_dir'] = $this->_data['var_dir'] . DS . 'log'; $this->_data['session_dir'] = $this->_data['var_dir'] . DS . 'session'; $this->_data['upload_dir'] = $this->_data['media_dir'] . DS . 'upload'; $this->_data['export_dir'] = $this->_data['var_dir'] . DS . 'export'; }
public function __construct($options = array()) { if (!isset($options['prefix'])) { $this->_idPrefix = md5(dirname(Mage::getRoot())); } else { $this->_idPrefix = $options['prefix']; } $backend = ''; if (isset($options['backend'])) { $backend = strtolower($options['backend']); } $backendType = ''; if (extension_loaded('apc') && ini_get('apc.enabled') && $backend == 'apc') { $backendType = 'Apc'; $backendAttributes = array('cache_prefix' => $this->_idPrefix); } elseif (extension_loaded('eaccelerator') && ini_get('eaccelerator.enable') && $backend == 'eaccelerator') { $backendType = 'Eaccelerator'; $backendAttributes = array('cache_prefix' => $this->_idPrefix); } elseif ('memcached' == $backend && extension_loaded('memcache')) { $backendType = 'Memcached'; $memcachedConfig = $options['memcached']; $backendAttributes = array('compression' => isset($memcachedConfig['compression']) ? $memcachedConfig['compression'] : false, 'cache_dir' => isset($memcachedConfig['cache_dir']) ? $memcachedConfig['cache_dir'] : '', 'hashed_directory_level' => isset($memcachedConfig['hashed_directory_level']) ? $memcachedConfig['hashed_directory_level'] : '', 'hashed_directory_umask' => isset($memcachedConfig['hashed_directory_umask']) ? $memcachedConfig['hashed_directory_umask'] : '', 'file_name_prefix' => isset($memcachedConfig['file_name_prefix']) ? $memcachedConfig['file_name_prefix'] : '', 'servers' => array()); foreach ($memcachedConfig['servers'] as $serverConfig) { $backendAttributes['servers'][] = array('host' => $serverConfig['host'], 'port' => $serverConfig['port'], 'persistent' => $serverConfig['persistent']); } } if (!$backendType) { $backendType = $this->_defaultBackend; $backendAttributes = $this->_defaultBackendOptions; $backendAttributes['cache_dir'] = dirname(Mage::getRoot()) . DS . 'var' . DS . 'cache'; } if (isset($options['lifetime'])) { $lifetime = (int) $options['lifetime']; } else { $lifetime = self::DEFAULT_LIFETIME; } $this->_frontend = Zend_Cache::factory('Core', $backendType, array('caching' => true, 'lifetime' => $lifetime, 'automatic_cleaning_factor' => 0), $backendAttributes, false, false, true); }
/** * Initialize default values of the options */ public function __construct() { parent::__construct(); $appRoot = Mage::getRoot(); $root = dirname($appRoot); $this->_data['app_dir'] = $appRoot; $this->_data['base_dir'] = $root; $this->_data['code_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'code'; $this->_data['design_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'design'; $this->_data['etc_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'etc'; $this->_data['lib_dir'] = $root . DIRECTORY_SEPARATOR . 'lib'; $this->_data['locale_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'locale'; $this->_data['pub_dir'] = $root . DIRECTORY_SEPARATOR . 'pub'; $this->_data['js_dir'] = $this->_data['pub_dir'] . DIRECTORY_SEPARATOR . 'js'; $this->_data['media_dir'] = $this->_data['pub_dir'] . DIRECTORY_SEPARATOR . 'media'; $this->_data['var_dir'] = $this->getVarDir(); $this->_data['tmp_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'tmp'; $this->_data['cache_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'cache'; $this->_data['log_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'log'; $this->_data['session_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'session'; $this->_data['upload_dir'] = $this->_data['media_dir'] . DIRECTORY_SEPARATOR . 'upload'; $this->_data['export_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'export'; }
private function __construct() { $moduleFiles = glob(Mage::getRoot() . '/etc/modules/*.xml'); $unsortedConfig = new Varien_Simplexml_Config(); $unsortedConfig->loadString('<config/>'); $fileConfig = new Varien_Simplexml_Config(); foreach ($moduleFiles as $filePath) { $fileConfig->loadFile($filePath); $unsortedConfig->extend($fileConfig); } // create sorted config [only active modules] #$sortedConfig = new Varien_Simplexml_Config(); #$sortedConfig->loadString('<config><modules/></config>'); $fileConfig = new Varien_Simplexml_Config(); foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) { if ('true' === (string) $moduleNode->active) { $codePool = (string) $moduleNode->codePool; $configPath = Mage::getRoot() . '/code/' . $codePool . '/' . uc_words($moduleName, '/') . '/etc/config.xml'; $fileConfig->loadFile($configPath); $unsortedConfig->extend($fileConfig); } } $this->_config = $unsortedConfig; }
public function suvenirparseAction() { set_time_limit(0); ini_set('memory_limit', '1024M'); $skus = array(); $qtys = array(); $prices = array(); $attrSetName = 'suvenir'; $attributeSetId = Mage::getModel('eav/entity_attribute_set')->load($attrSetName, 'attribute_set_name')->getAttributeSetId(); $products = Mage::getModel('catalog/product')->getCollection()->joinField('qty', 'cataloginventory/stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left')->addAttributeToSelect('price')->addFieldToFilter('attribute_set_id', $attributeSetId); foreach ($products as $p) { $skus[] = $p->getData('sku'); $qtys[] = $p->getQty(); $prices[] = $p->getPrice(); } $sku = ''; $appRoot = Mage::getRoot(); $root = dirname($appRoot); error_reporting(E_ALL ^ E_NOTICE); require_once $root . DS . 'lib' . DS . 'ExcelReader' . DS . 'excelreader.php'; $data = new Spreadsheet_Excel_Reader(); $data->read($_FILES['filesuvenir']['tmp_name']); $found = '0'; $csv = array(); $sku = array(); for ($i = 2; $i < $data->rowcount() + 1; $i++) { $price = str_replace(" ", "", $data->val($i, D)); $csv[$i - 2][] = "''"; //articul $csv[$i - 2][] = "'" . trim($data->val($i, B)) . "'"; //sku $csv[$i - 2][] = "'" . str_replace(',', '.', $price) . "'"; //price $csv[$i - 2][] = "'" . trim($data->val($i, E)) . "'"; //qty $csv[$i - 2][] = "'Каталог, поиск'"; //visibility $csv[$i - 2][] = "'simple'"; //type $csv[$i - 2][] = "'suvenir'"; //attribute_set $csv[$i - 2][] = "'base'"; //websites $csv[$i - 2][] = "'1'"; //is in stock $find_sku = '0'; if (in_array($data->val($i, B), $skus)) { $find_sku = '1'; $index = array_search($data->val($i, B), $skus); if ($index != false or (int) $index == 0) { // echo $data->val($data->val($i,B))."<br/>"; unset($skus[(int) $index]); unset($qtys[(int) $index]); unset($prices[(int) $index]); } } if ($find_sku == '0') { $csv[$i - 2][] = "'Отключено'"; //status $csv[$i - 2][] = "'Да'"; //new } else { $csv[$i - 2][] = "'Включено'"; //status $csv[$i - 2][] = "'Нет'"; } } //get old products to invisible foreach ($skus as $key => $value) { $i++; $csv[$i - 2][] = "''"; //articul $csv[$i - 2][] = "'" . $value . "'"; //sku $csv[$i - 2][] = "'" . $prices[(int) $key] . "'"; //price $csv[$i - 2][] = "'" . $qtys[(int) $key] . "'"; //qty $csv[$i - 2][] = "'Каталог, Поиск'"; //visibility $csv[$i - 2][] = "'simple'"; //type $csv[$i - 2][] = "'suvenir'"; //attribute_set $csv[$i - 2][] = "'base'"; //websites $csv[$i - 2][] = "'1'"; //is in stock $csv[$i - 2][] = "'Отключено'"; //status $csv[$i - 2][] = "'Нет'"; //status } $file = fopen($root . DS . 'var' . DS . 'import' . DS . 'update_suvenir.csv', 'w'); foreach ($csv as $line) { fputcsv($file, $line, "~"); } fclose($file); $data = file_get_contents($root . DS . 'var' . DS . 'import' . DS . 'update_suvenir.csv'); $data = str_replace('"', "", $data); $data = str_replace("'", "\"", $data); file_put_contents($root . DS . 'var' . DS . 'import' . DS . 'update_suvenir.csv', $data); $url = Mage::getModel('adminhtml/url')->getUrl('adminhtml/system_convert_gui/run/id/12/files/update_suvenir.csv/'); $this->_redirectUrl($url); }
/** * Check file system path * * @deprecated since 1.7.1.0 * @param string $path * @param bool $recursive * @param bool $existence * @param string $mode * @return bool */ protected function _checkPath($path, $recursive, $existence, $mode) { return $this->_checkFullPath(dirname(Mage::getRoot()) . $path, $recursive, $existence); }
/** * @return Aitoc_Aitsys_Model_Core_Cache */ public function getCache() { if (empty($this->_cache)) { $localXmlPath = Mage::getRoot() . DS . 'etc' . DS . 'local.xml'; $localXmlConfig = new Varien_Simplexml_Config($localXmlPath); if (version_compare(Mage::getVersion(), '1.4', '>=')) { $localXml = $localXmlConfig->getNode('global'); $local = $this->xmlAsArray($localXml); if (isset($local['cache'])) { $cacheOptions = $local['cache']; } else { $cacheOptions = array(); } // read db settings from app/etc/config.xml $configXmlPath = Mage::getRoot() . DS . 'etc' . DS . 'config.xml'; $configXmlConfig = new Varien_Simplexml_Config($configXmlPath); $configXml = $configXmlConfig->getNode('global'); $config = $this->xmlAsArray($configXml); $dbSettings = array(); $dbSettings['resources'] = $config['resources']; $dbSettings['resource'] = $config['resource']; // replace db settings with actual data from app/etc/local.xml foreach ($local['resources']['default_setup']['connection'] as $_key => $_value) { $dbSettings['resources']['default_setup']['connection'][$_key] = $_value; } $dbSettings['resources']['db']['table_prefix'] = $local['resources']['db']['table_prefix']; $this->_cache = new Aitoc_Aitsys_Model_Core_Cache($cacheOptions, $dbSettings); } else { $localXml = $localXmlConfig->getNode('global/cache'); if ($localXml) { $cacheOptions = $this->xmlAsArray($localXml); } else { $cacheOptions = array(); } $this->_cache = new Aitoc_Aitsys_Model_Core_Cache_Legacy($cacheOptions); } } return $this->_cache; }
public function suvenirparseAction() { $skuArray = array(); $categoryCollection = Mage::getModel('catalog/category')->getCollection(); foreach ($categoryCollection as $category) { foreach ($category->getProductCollection()->getColumnValues('sku') as $sku) { $skuArray[] = $sku; } } $sku = ''; $appRoot = Mage::getRoot(); $root = dirname($appRoot); require_once $root . DS . 'lib' . DS . 'ExcelReader' . DS . 'excelreader.php'; $data = new Spreadsheet_Excel_Reader(); $data->read($_FILES['filesuvenir']['tmp_name']); $found = '0'; $csv = array(); $images = array(); $sku = array(); $dir = $root . DS . 'media' . DS . 'import' . DS . 'suvenir' . DS; //задаём имя директории if (is_dir($dir)) { //проверяем наличие директории $files = scandir($dir); //сканируем (получаем массив файлов) array_shift($files); // удаляем из массива '.' for ($a = 0; $a < sizeof($files); $a++) { $image[] = str_replace(".jpg", "", $files[$a]); } } for ($i = 2; $i < $data->rowcount() + 1; $i++) { $price = str_replace(" ", "", $data->val($i, D)); $csv[$i - 2][] = "''"; //articul $csv[$i - 2][] = "'simple'"; //type $csv[$i - 2][] = "'suvenir'"; //attribut_set $csv[$i - 2][] = "'Отсутствует'"; //tax_class_id $csv[$i - 2][] = "'Включено'"; //status $csv[$i - 2][] = "'1'"; //weight $csv[$i - 2][] = "'" . $data->val($i, B) . "'"; //sku $csv[$i - 2][] = "'" . $data->val($i, A) . "'"; //name $csv[$i - 2][] = "'" . str_replace(',', '.', $price) . "'"; //price $csv[$i - 2][] = "'" . str_replace("/r/n", "", $data->val($i, A)) . "'"; //description $csv[$i - 2][] = "'" . str_replace("/n", "", $data->val($i, A)) . "'"; //short_description $csv[$i - 2][] = "'Каталог, поиск'"; //visibility $csv[$i - 2][] = "'" . $data->val($i, G) . "'"; //category_ids $csv[$i - 2][] = "'" . $data->val($i, E) . "'"; //qty $sku1 = str_replace(",", "", $data->val($i, B)); $sku1 = str_replace(".", "", $sku1); $sku = $sku1; $found = '0'; if (in_array($sku, $image)) { $path = "'/suvenir/" . $sku . ".jpg'"; //image $found = '1'; } if ($found == '0') { $csv[$i - 2][] = "''"; //image $csv[$i - 2][] = "''"; //small image $csv[$i - 2][] = "''"; //thumbnail } else { $csv[$i - 2][] = $path; //image $csv[$i - 2][] = $path; //small image $csv[$i - 2][] = $path; //thumbnail } $csv[$i - 2][] = "'1'"; //is_in_stock $csv[$i - 2][] = "'base'"; //websites $csv[$i - 2][] = "'" . $data->val($i, C) . "'"; //country $csv[$i - 2][] = "'" . $data->val($i, F) . "'"; //standart $find_sku = '0'; if (in_array($data->val($i, B), $skuArray)) { $find_sku = '1'; } if ($find_sku == '0') { $csv[$i - 2][] = "'Да'"; //new } else { $csv[$i - 2][] = "'Нет'"; } // $csv[$i - 2][] = "'" . str_replace('/r/n', '',$data->val($i, Q)) . "'"; //description // $csv[$i - 2][] = "'" . str_replace('/n', '',$data->val($i, Q)) . "'"; //short_description } $file = fopen($root . DS . 'var' . DS . 'import' . DS . 'suvenir.csv', 'w'); foreach ($csv as $line) { fputcsv($file, $line, "~"); } fclose($file); // fix bug with "" $data = file_get_contents($root . DS . 'var' . DS . 'import' . DS . 'suvenir.csv'); $data = str_replace('"', "", $data); $data = str_replace("'", "\"", $data); file_put_contents($root . DS . 'var' . DS . 'import' . DS . 'suvenir.csv', $data); $url = Mage::getModel('adminhtml/url')->getUrl('adminhtml/system_convert_gui/run/id/8/files/suvenir.csv/'); $this->_redirectUrl($url); }
/** * @return string * @codeCoverageIgnore */ public function getModuleStatus($method_count, $method_limit) { /* Precedence: * 1) Missing files * 2) Magento version * 3) New version on github * 4) Method limit * 5) Disabled check * 6) Deprecated files */ $core = Mage::helper('core'); // 1) Check missing files $needFiles = array(); $modFiles = array(Mage::getBaseDir('lib') . "/Mollie/src/Mollie/API/Client.php", Mage::getBaseDir('lib') . "/Mollie/src/Mollie/API/Autoloader.php", Mage::getBaseDir('lib') . "/Mollie/src/Mollie/API/Exception.php", Mage::getBaseDir('lib') . "/Mollie/src/Mollie/API/Object/Issuer.php", Mage::getBaseDir('lib') . "/Mollie/src/Mollie/API/Object/List.php", Mage::getBaseDir('lib') . "/Mollie/src/Mollie/API/Object/Method.php", Mage::getBaseDir('lib') . "/Mollie/src/Mollie/API/Object/Payment.php", Mage::getBaseDir('lib') . "/Mollie/src/Mollie/API/Resource/Base.php", Mage::getBaseDir('lib') . "/Mollie/src/Mollie/API/Resource/Issuers.php", Mage::getBaseDir('lib') . "/Mollie/src/Mollie/API/Resource/Methods.php", Mage::getBaseDir('lib') . "/Mollie/src/Mollie/API/Resource/Payments.php", Mage::getRoot() . '/design/adminhtml/default/default/template/mollie/system/config/status.phtml', Mage::getRoot() . '/design/frontend/base/default/layout/mpm.xml', Mage::getRoot() . '/design/frontend/base/default/template/mollie/page/exception.phtml', Mage::getRoot() . '/design/frontend/base/default/template/mollie/page/fail.phtml', Mage::getRoot() . '/design/frontend/base/default/template/mollie/form/details.phtml', Mage::getRoot() . '/code/community/Mollie/Mpm/Block/Adminhtml/System/Config/Status.php', Mage::getRoot() . '/code/community/Mollie/Mpm/Block/Payment/Api/Form.php', Mage::getRoot() . '/code/community/Mollie/Mpm/Block/Payment/Api/Info.php', Mage::getRoot() . '/code/community/Mollie/Mpm/controllers/ApiController.php', Mage::getRoot() . '/code/community/Mollie/Mpm/etc/adminhtml.xml', Mage::getRoot() . '/code/community/Mollie/Mpm/etc/config.xml', Mage::getRoot() . '/code/community/Mollie/Mpm/etc/system.xml', Mage::getRoot() . '/code/community/Mollie/Mpm/Helper/Data.php', Mage::getRoot() . '/code/community/Mollie/Mpm/Helper/Api.php', Mage::getRoot() . '/code/community/Mollie/Mpm/Model/Api.php', Mage::getRoot() . '/code/community/Mollie/Mpm/Model/Idl.php'); for ($i = 0; $i < $method_limit; $i++) { $I = $i < 10 ? '0' . $i : $i; $modFiles[] = Mage::getRoot() . '/code/community/Mollie/Mpm/Model/Void' . $I . '.php'; } foreach ($modFiles as $file) { if (!file_exists($file)) { $needFiles[] = '<span style="color:red">' . $file . '</span>'; } } if (count($needFiles) > 0) { return '<b>' . $core->__('Missing file(s) detected!') . '</b><br />' . implode('<br />', $needFiles); } // 2) Check magento version if (version_compare(Mage::getVersion(), '1.4.1.0', '<')) { return '<b>' . $core->__('Version incompatible!') . '</b><br /> <span style="color:red">' . $core->__('Your Magento version is incompatible with this module!') . '<br> - ' . $core->__('Minimal version requirement: ') . '1.4.1.x<br> - ' . $core->__('Current version: ') . Mage::getVersion() . ' </span> '; } // 3) Check github version if ($this->should_update === 'yes') { return '<b>' . $core->__('Status') . '</b><br /><span style="color:#EB5E00">' . $core->__('Module status: Outdated!') . '</span>'; } // 4) Check method limit if ($method_count > $method_limit) { return '<b>' . $core->__('Module outdated!') . '</b><br /> <span style="color:#EB5E00">' . sprintf($core->__('Mollie currently provides %d payment methods, while this module only supports %d method slots.'), $method_count, $method_limit) . '</span><br /> ' . $core->__('To enable all supported payment methods, get the latest Magento plugin from the <a href="https://www.mollie.nl/betaaldiensten/ideal/modules/" title="Mollie Modules">Mollie Modules list</a>.') . ' <br /> If no newer version is available, please <a href="https://www.mollie.nl/bedrijf/contact" title="Mollie Support">contact Mollie BV</a>. '; } // 5) Check if disabled if (!Mage::Helper('mpm/data')->getConfig('mollie', 'active')) { return '<b>' . $core->__('Status') . '</b><br /><span style="color:#EB5E00">' . $core->__('Module status: Disabled!') . '</span>'; } // 6) Check deprecated files $deprFiles = array(); $oldFiles = array(Mage::getRoot() . '/code/community/Mollie/Mpm/Block/Payment/Idl/Fail.php', Mage::getRoot() . '/code/community/Mollie/Mpm/Block/Payment/Idl/Form.php', Mage::getRoot() . '/code/community/Mollie/Mpm/Block/Payment/Idl/Info.php', Mage::getRoot() . '/code/community/Mollie/Mpm/controllers/IdlController.php', Mage::getRoot() . '/code/community/Mollie/Mpm/Helper/Idl.php', Mage::getRoot() . '/design/frontend/base/default/template/mollie/form/idl.phtml', Mage::getRoot() . '/design/frontend/base/default/template/mollie/form/api.phtml'); foreach ($oldFiles as $file) { if (file_exists($file)) { $deprFiles[] = '<span style="color:#EB5E00">' . $file . '</span>'; } } if (count($deprFiles) > 0) { return '<b>' . $core->__('Outdated file(s) found!') . '</b><br />' . implode('<br />', $deprFiles) . '<br />' . $core->__('These aren‘t needed any longer; you might as well delete them.'); } // All is fine return '<b>' . $core->__('Status') . '</b><br /><span style="color:green">' . $core->__('Module status: OK!') . '</span>'; }
/** * Replaces some collected classes with abstract rewrites * * @return Aitoc_Aitsys_Model_Compiler_Rules */ public function applyReplaceRule() { foreach (array_keys($this->getCompileConfig()->getNode('replace')->asArray()) as $replace) { $source = dirname(Mage::getRoot()) . Aitoc_Aitsys_Model_Rewriter_Abstract::REWRITE_CACHE_DIR . $replace . '.php'; $target = $this->getIncludeDir() . DS . $replace . '.php'; if (@file_exists($source) && @file_exists($target)) { copy($source, $target); } } return $this; }
public function getAppDir() { return $this->getDataSetDefault('app_dir', Mage::getRoot()); }
public function getLicenseDir($base = false) { if (!$this->_licenseDir) { $this->_licenseDir = dirname(Mage::getRoot()) . '/var/' . self::INSTALLATION_DIR . '/'; if (!$this->tool()->filesystem()->isWriteable($this->_licenseDir)) { throw new Aitoc_Aitsys_Model_Aitfilesystem_Exception($this->_licenseDir . " should be writeable"); } if (!file_exists($this->_licenseDir)) { $this->tool()->filesystem()->mkDir($this->_licenseDir); } } if ($base) { return $this->_licenseDir; } return rtrim($this->_licenseDir . $this->getPlatformId(), '/') . '/'; }
/** * Retrieve writable full paths for checking * * @return array */ public function getWritableFullPathsForCheck() { $paths = array(); $items = (array) $this->getNode(self::XML_PATH_CHECK_WRITEABLE); foreach ($items as $nodeKey => $item) { $value = (array) $item; if (isset($this->_optionsMapping[self::XML_PATH_CHECK_WRITEABLE][$nodeKey])) { $configKey = $this->_optionsMapping[self::XML_PATH_CHECK_WRITEABLE][$nodeKey]; $value['path'] = Mage::app()->getConfig()->getOptions()->getData($configKey); } else { $value['path'] = dirname(Mage::getRoot()) . $value['path']; } $paths[$nodeKey] = $value; } return $paths; }
/** * * @param Varien_Event_Observer $observer */ public function product_cron_sync() { ini_set("display_errors", 1); ini_set("memory_limit", "1024M"); $debug = true; $log = 'product_sync_' . date('d-m-Y') . '.log'; $path = dirname(dirname(Mage::getRoot())) . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR; $currentStore = Mage::app()->getStore()->getId(); $storeId = Mage::app()->getStore()->getStoreId(); $storeId = 1; Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $rootCategoryId = Mage::app()->getStore($storeId)->getRootCategoryId(); $parentCategory = Mage::getModel('catalog/category')->load($rootCategoryId); $erpProductCollection = Mage::getModel('idpas400/erp_products')->getCollection(); // Logging that this process is starting // if ($debug) { // Mage::log('------------------------------', null, $log); // Mage::log('Starting Cron Foreach of '.count($erpProductCollection) // .' products', null, $log); // } foreach ($erpProductCollection as $erp_product) { $_product = Mage::getModel('catalog/product'); $id = Mage::helper('idpas400')->getProductBySku($erp_product->getData('sku')); $_product->load($id); // logging to check that the product has loaded // if ($debug) // Mage::log('- Product sku ('.$erp_product->getData('sku').') load ('. // $_product->getId().')',null,$log); // initial product set foreach ((array) $erp_product->getData() as $property => $value) { $_product->setData($property, $value); } // new product setup if (!$_product->getId()) { $_product->setTypeId('simple'); $_product->setData('attribute_set_id', 4); $_product->setWebsiteIds(array(1)); // 1 => Not Visible Individually, 2 => Catalog, 3 => Search, 4 => Catalog, Search $_product->setVisibility(4); $_product->setData('page_layout', 'two_columns_left'); $_product->setData('is_salable', 1); $_product->setData('stock_data', array('manage_stock' => 1, 'use_config_manage_stock' => 0, 'qty' => $erp_product->getData('qty'), 'min_qty' => 0, 'use_config_min_qty' => 0, 'min_sale_qty' => 1, 'use_config_min_sale_qty' => 1, 'max_sale_qty' => 9999, 'use_config_max_sale_qty' => 1, 'is_qty_decimal' => 0, 'backorders' => 0, 'notify_stock_qty' => 0, 'is_in_stock' => $erp_product->getData('qty') ? 1 : 0)); } //COST if (!$_product->hasData('cost')) { $_product->setData('cost', 0); } if ($erp_product->hasData('cost')) { $_product->setData('cost', $erp_product->getData('cost')); } //PRICE if (!$_product->hasData('price')) { $_product->setData('price', 0); } if ($erp_product->hasData('price')) { $_product->setData('price', $erp_product->getData('price')); } //1=Enabled; 2=Disabled; $_product->setData('status', $erp_product->getData('status') ? 2 : 1); // Logging the status of this current record // if ($debug) // Mage::log('- status ('. $_product->getData('status').')',null,$log); // map taxes // $_product->setData('tax_class_id', $erp_product->getData('tax_yn')=='Y' ?2 :0); if ($erp_product->getData('tax_yn') == 'Y') { $taxClassId = Mage::helper('idpas400')->getTaxClassId('Avatax', $erp_product->getData('tax_category')); $_product->setData('tax_class_id', $taxClassId); } else { $_product->setData('tax_class_id', 0); } $images = array(); try { // use the directory path to images you want to save for the product foreach ((array) $erp_product->getData('images') as $filename) { $filepath_to_image = str_replace('/b4school/skuimage/', $path, $filename); if (!file_exists($filepath_to_image)) { continue; } $images[] = $filepath_to_image; } // loggin product images found // if ($debug) // Mage::log('- images found ('.count($images).')',null,$log); } catch (Exception $e) { // logging product image failed // Mage::log('Image loading failure '.$e->getMessage(),null,$log); Mage::log('Image loading failure ' . $e->getMessage(), null, 'image_failed.log'); } try { if ($images) { if ($_product->getId()) { // delete the existing images $mediaApi = Mage::getModel("catalog/product_attribute_media_api"); $items = $mediaApi->items($_product->getId()); $attributes = $_product->getTypeInstance()->getSetAttributes(); $gallery = $attributes['media_gallery']; // Other images found // if ($debug) // Mage::log('- images to remove ('.count($items).')',null,$log); foreach ($items as $item) { if ($gallery->getBackend()->getImage($_product, $item['file'])) { $gallery->getBackend()->removeImage($_product, $item['file']); } // $mediaApi->remove($_product->getId(), $item['file']); } $_product->setStoreId($currentStore)->save(); } } } catch (Exception $e) { // logging product image failed Mage::log('Image remove failure ' . $e->getMessage(), null, $log); } try { if ($images) { // actually save the images $mode = array("small_image", "thumbnail", "image"); foreach ((array) $images as $image) { // Other images found // if ($debug) // Mage::log('- saving image ('.$image.')',null,$log); $_product->addImageToMediaGallery($image, $mode, true, false); } } } catch (Exception $e) { // logging product image failed Mage::log('Image save failure ' . $e->getMessage(), null, $log); } //create/associate categories $catids = array(); for ($i = 2; $i <= 6; $i++) { $cat_slug = $_product->getData("category_{$i}"); if ($cat_slug) { $category = Mage::getModel('catalog/category')->getCollection()->addAttributeToFilter('url_key', strtolower($cat_slug))->addAttributeToFilter('parent_id', $rootCategoryId)->getFirstItem(); $cat_id = $category->getId(); if (!$cat_id) { $_description = "CTPCT{$i}"; $data = Mage::getSingleton('idpas400/db')->fetch_row("SELECT {$_description} FROM SROCTLP{$i}" . " WHERE CTPCA{$i} ='{$cat_slug}'"); $name = ucwords(strtolower(trim($data[$_description]))); $category->setUrlKey(strtolower($cat_slug)); $category->setName($name); $category->setMetaDescription($name); $category->setPath($parentCategory->getPath()); $category->setIsActive(1); $category->setIsAnchor(0); $category->setDisplayMode('PRODUCTS'); $category->setAttributeSetId($category->getDefaultAttributeSetId()); $category->save(); $cat_id = $category->getId(); } $catids[] = $cat_id; } } if (!empty($catids)) { // if ($debug) // Mage::log('- categories ('.implode(',',$catids).')',null,$log); $_product->setCategoryIds($catids); } try { if (!$_product->getId()) { $_product->getData('stock_item')->save(); $status = $_product->setStoreId($currentStore)->save(); } else { $status = $_product->setStoreId($currentStore)->save(); // $status = $_product->getResource()->save($_product); } // logging success of product save // if ($debug) // Mage::log(($status // ? '- Product saved.' // : '- Prodct FAILED to save.'),null,$log); } catch (Exception $e) { Mage::log($e->getMessage(), null, $log); } Mage::app()->setCurrentStore($currentStore); } Mage::getModel('core/session')->setData('product_cron_sync', false); }
/** * Attempts to uninstall Pear * * @param $moduleName */ protected function processFileBasedUninstall($moduleName) { $magentoRoot = dirname(Mage::getRoot()); $config = Mage::app()->getConfig(); $configModule = $config->getModuleConfig($moduleName); /* @var $configFile Mage_Core_Model_Config_Base */ $configFile = Mage::getModel('core/config_base'); /* @var $helper Hackathon_MageTrashApp_Helper_Data */ $helper = Mage::helper('magetrashapp'); // if ($configModule->is('active', true)) { // Mage::throwException( $helper->__('The module %s must be disabled before to uninstall.', $moduleName)); // return; // } $etc = $config->getModuleDir('etc', $moduleName) . DS . 'config.xml'; $configFile->loadFile($etc); $element = $configFile->getNode('uninstall'); if (!empty($element) && !$element->filename) { $filename = $element->filename; } else { $filename = 'uninstall.txt'; } $uninstallFile = $config->getModuleDir('etc', $moduleName) . DS . $filename; if (file_exists($uninstallFile)) { $handle = fopen($uninstallFile, 'r'); while ($line = fgets($handle)) { $line = preg_replace('/\\s+/', '%%%', $line); $lines = explode('%%%', $line); if (count($lines) > 2) { // modman file format, we take the second argument because it should be the path of the target installation $pathsToDelete[] = $magentoRoot . DS . trim($lines[1], '/'); } else { $pathsToDelete[] = $magentoRoot . DS . trim($lines[0], '/'); } } if (!feof($handle)) { $helper->__('A problem occured while trying to get access to the uninstall file.'); } fclose($handle); foreach ($pathsToDelete as $dest) { if (file_exists($dest) && (is_file($dest) || is_link($dest))) { unlink($dest); } else { if (file_exists($dest)) { $helper->rrmdir($dest); } } } return true; } return false; }
private function __construct() { $this->_rewriteDir = dirname(Mage::getRoot()) . Aitoc_Aitsys_Model_Rewriter_Abstract::REWRITE_CACHE_DIR; $this->_readConfig(); }
/** * Makes directory structure and sets permissions * * @param string $sPath */ public function makeDirStructure($path, $isFile = true) { $path = str_replace('\\', '/', $path); $basePath = str_replace('\\', '/', dirname(Mage::getRoot())) . '/'; $pathItems = explode('/', substr($path, strlen($basePath))); $all = $this->getPermissionsMode() == self::MODE_ALL; if ($isFile) { array_pop($pathItems); } foreach ($pathItems as $dir) { if ($dir === '') { continue; } $basePath .= $dir . '/'; if (!@file_exists($basePath) or @file_exists($basePath) and !@is_dir($basePath)) { @mkdir($basePath, self::PERM_DIR); $this->grantAll($basePath, true, $all); } } return $this; }
<?php /** @var Mage_Eav_Model_Entity_Setup */ $installer = $this; $installer->startSetup(); $installer->run("\nCREATE TABLE IF NOT EXISTS {$this->getTable('svea_webpay_paymentplan')} (\n `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n `campaincode` VARCHAR( 100 ) NOT NULL,\n `description` VARCHAR( 100 ) NOT NULL ,\n `paymentplantype` VARCHAR( 100 ) NOT NULL ,\n `contractlength` INT NOT NULL ,\n `monthlyannuityfactor` DOUBLE NOT NULL ,\n `initialfee` DOUBLE NOT NULL ,\n `notificationfee` DOUBLE NOT NULL ,\n `interestratepercentage` INT NOT NULL ,\n `interestfreemonths` INT NOT NULL ,\n `paymentfreemonths` INT NOT NULL ,\n `fromamount` DOUBLE NOT NULL ,\n `toamount` DOUBLE NOT NULL ,\n `timestamp` INT UNSIGNED NOT NULL,\n `storeid` INT NOT NULL\n);\n\nUPDATE {$this->getTable('sales_flat_order_payment')} SET method = 'svea_paymentplan' WHERE method = 'swpwspartpay';\nUPDATE {$this->getTable('sales_flat_order_payment')} SET method = 'svea_invoice' WHERE method = 'swpwsinvoice';\nUPDATE {$this->getTable('sales_flat_order_payment')} SET method = 'svea_cardpayment' WHERE method = 'swphgcard';\nUPDATE {$this->getTable('sales_flat_order_payment')} SET method = 'svea_directpayment' WHERE method = 'swphgall';\n"); //Deactivate older modules $common = Mage::getRoot() . "/etc/modules/SveaWebPay_Common.xml"; $hosted = Mage::getRoot() . "/etc/modules/SveaWebPay_Hosted.xml"; $hostedg = Mage::getRoot() . "/etc/modules/SveaWebPay_HostedG.xml"; $webservice = Mage::getRoot() . "/etc/modules/SveaWebPay_Webservice.xml"; if (file_exists($common)) { $xml = simplexml_load_file($common); $xml->modules[0]->SveaWebPay_Common[0]->active = 'false'; $output = $xml->asXML($common); } if (file_exists($hosted)) { $xml = simplexml_load_file($hosted); $xml->modules[0]->SveaWebPay_Hosted[0]->active = 'false'; $output = $xml->asXML($hosted); } if (file_exists($hostedg)) { $xml = simplexml_load_file($hostedg); $xml->modules[0]->SveaWebPay_HostedG[0]->active = 'false'; $output = $xml->asXML($hostedg); } if (file_exists($webservice)) { $xml = simplexml_load_file($webservice); $xml->modules[0]->SveaWebPay_Webservice[0]->active = 'false'; $output = $xml->asXML($webservice); }
<?php require_once Mage::getRoot() . '/code/community/Svea/WebPay/integrationLib/Includes.php'; /** * Main class for WebService payments as Invoice and PaymentPlan payment * * @category Payment * @package Svea_WebPay_Module_Magento * @author SveaWebPay <https://github.com/sveawebpay/magento-module> * @license https://github.com/sveawebpay/magento-module/blob/master/LICENSE.txt Apache License * @copyright (c) 2013, SveaWebPay (Svea Ekonomi AB) * */ abstract class Svea_WebPay_Model_Service_Abstract extends Svea_WebPay_Model_Abstract { protected $_isGateway = false; protected $_canAuthorize = true; protected $_canCapture = true; protected $_canVoid = true; /** * Convert the object returned from Svea to an array because it's easier * to handle and store * * @param object $response * @return array */ protected function _sveaResponseToArray($response) { $result = array(); foreach ($response as $key => $val) { if (!is_string($key) || is_object($val)) {
/** * This file replacement (for /app/code/core/Mage/Core/Model/App.php) is necessary for an early * launch of the Extended Rewriter (ER) subsystem developed by AITOC Inc.. The Magento system * allows only one rewrite to be used by extensions to extend some of the core Magento functionality. * Often different extensions need to use rewrites of the same class in order to work properly. * The `one rewrite` restriction leads to the situation when manual changes in extensions' class * files are required to make extensions work together. Thereby extensions' install and update * processes become much more complex. * * The ER subsystem solves conflicts between AITOCs' and 3rd-party extensions' rewrites by creating * generic chains of rewrites without making direct changes to the extensions' original class files. * It makes the process of modules installation easier and prevents many issues which could be caused * by conflicts of rewrites. * * Please note that this file replacement does NOT affect normal work of the Mageno system - it only * launches an additional subsystem during system initialization. All the extensions developed by AITOC Inc. * could work without this subsystem but it will be much harder to install them as it may be necessary * to manually solve rewrites' conflicts with 3rd-party extension. Please note that solving conflicts * with 3rd-party extensions is out of AITOC's free support policy. The ER subsystem could be disabled * by removing this file but it is strongly not recommended. */ Mage::setRoot(); require_once Mage::getRoot() . '/code/core/Mage/Core/Model/App.php'; $initProcessor = new Aitoc_Aitsys_Model_Init_Processor(); if ($initProcessor->isInstallerEnabled()) { Aitoc_Aitsys_Model_Rewriter_Autoload::register(true); $initProcessor->realize(); } Mage::register('aitsys_autoload_initialized', true); Mage::register('aitsys_autoload_initialized_base', true);