diff --git a/.htaccess.sample b/.htaccess.sample index 546f18e6f36..b8821af2226 100644 --- a/.htaccess.sample +++ b/.htaccess.sample @@ -31,8 +31,7 @@ ############################################ ## adjust memory limit -# php_value memory_limit 64M - php_value memory_limit 128M + php_value memory_limit 512M php_value max_execution_time 18000 ############################################ diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 6f87f6b1875..7025e19610d 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,3 +1,12 @@ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +] NOTE: Current Release Notes are maintained at: [ +] [ +] http://www.magentocommerce.com/knowledge-base/entry/ce-18-later-release-notes [ +] [ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ==== 1.7.0.2 ==== === Fixes === diff --git a/app/Mage.php b/app/Mage.php index bc7a6cb07a1..3849c1fb1d8 100644 --- a/app/Mage.php +++ b/app/Mage.php @@ -168,9 +168,9 @@ public static function getVersionInfo() { return array( 'major' => '1', - 'minor' => '7', + 'minor' => '8', 'revision' => '0', - 'patch' => '2', + 'patch' => '0', 'stability' => '', 'number' => '', ); @@ -695,7 +695,7 @@ public static function run($code = '', $type = 'store', $options = array()) } try { self::dispatchEvent('mage_run_exception', array('exception' => $e)); - if (!headers_sent()) { + if (!headers_sent() && self::isInstalled()) { header('Location:' . self::getUrl('install')); } else { self::printException($e); diff --git a/app/code/community/Cm/RedisSession/Model/Session.php b/app/code/community/Cm/RedisSession/Model/Session.php new file mode 100644 index 00000000000..58ceac73aca --- /dev/null +++ b/app/code/community/Cm/RedisSession/Model/Session.php @@ -0,0 +1,731 @@ +_timeStart = microtime(true); + $host = (string) (Mage::getConfig()->getNode(self::XML_PATH_HOST) ?: '127.0.0.1'); + $port = (int) (Mage::getConfig()->getNode(self::XML_PATH_PORT) ?: '6379'); + $pass = (string) (Mage::getConfig()->getNode(self::XML_PATH_PASS) ?: ''); + $timeout = (float) (Mage::getConfig()->getNode(self::XML_PATH_TIMEOUT) ?: self::DEFAULT_TIMEOUT); + $persistent = (string) (Mage::getConfig()->getNode(self::XML_PATH_PERSISTENT) ?: ''); + $this->_dbNum = (int) (Mage::getConfig()->getNode(self::XML_PATH_DB) ?: 0); + $this->_compressionThreshold = (int) (Mage::getConfig()->getNode(self::XML_PATH_COMPRESSION_THRESHOLD) ?: self::DEFAULT_COMPRESSION_THRESHOLD); + $this->_compressionLib = (string) (Mage::getConfig()->getNode(self::XML_PATH_COMPRESSION_LIB) ?: self::DEFAULT_COMPRESSION_LIB); + $this->_logLevel = (int) (Mage::getConfig()->getNode(self::XML_PATH_LOG_LEVEL) ?: self::DEFAULT_LOG_LEVEL); + $this->_maxConcurrency = (int) (Mage::getConfig()->getNode(self::XML_PATH_MAX_CONCURRENCY) ?: self::DEFAULT_MAX_CONCURRENCY); + $this->_breakAfter = (int) (Mage::getConfig()->getNode(sprintf(self::XML_PATH_BREAK_AFTER, session_name())) ?: self::DEFAULT_BREAK_AFTER); + $this->_botLifetime = (int) (Mage::getConfig()->getNode(self::XML_PATH_BOT_LIFETIME) ?: self::DEFAULT_BOT_LIFETIME); + if ($this->_botLifetime) { + $userAgent = empty($_SERVER['HTTP_USER_AGENT']) ? FALSE : $_SERVER['HTTP_USER_AGENT']; + $this->_isBot = ! $userAgent || preg_match(self::BOT_REGEX, $userAgent); + } + $this->_redis = new Credis_Client($host, $port, $timeout, $persistent); + if (!empty($pass)) { + $this->_redis->auth($pass) or Zend_Cache::throwException('Unable to authenticate with the redis server.'); + } + $this->_redis->setCloseOnDestruct(FALSE); // Destructor order cannot be predicted + $this->_useRedis = TRUE; + if ($this->_logLevel >= 7) { + Mage::log( + sprintf( + "%s: %s initialized for connection to %s:%s after %.5f seconds", + $this->_getPid(), + get_class($this), + $host, + $port, + (microtime(true) - $this->_timeStart) + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + if ($this->_isBot) { + Mage::log( + sprintf( + "%s: Bot detected for user agent: %s", + $this->_getPid(), + $userAgent + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + } + } + } + + /** + * Check DB connection + * + * @return bool + */ + public function hasConnection() + { + if( ! $this->_useRedis) return parent::hasConnection(); + + try { + $this->_redis->connect(); + if ($this->_logLevel >= 7) { + Mage::log( + sprintf("%s: Connected to Redis", + $this->_getPid() + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + // reset timer + $this->_timeStart = microtime(true); + } + return TRUE; + } + catch (Exception $e) { + Mage::logException($e); + $this->_redis = NULL; + if ($this->_logLevel >= 0) { + Mage::log( + sprintf( + "%s: Unable to connect to Redis; falling back to MySQL handler", + $this->_getPid() + ), + Zend_Log::EMERG, self::LOG_FILE + ); + } + + // Fall-back to MySQL handler. If this fails, the file handler will be used. + $this->_useRedis = FALSE; + parent::__construct(); + return parent::hasConnection(); + } + } + + /** + * Fetch session data + * + * @param string $sessionId + * @return string + */ + public function read($sessionId) + { + if ( ! $this->_useRedis) return parent::read($sessionId); + + // Get lock on session. Increment the "lock" field and if the new value is 1, we have the lock. + // If the new value is a multiple of BREAK_MODULO then we are breaking the lock. + $sessionId = self::SESSION_PREFIX.$sessionId; + $tries = $waiting = $lock = 0; + $detectZombies = FALSE; + if ($this->_logLevel >= 7) { + Mage::log( + sprintf( + "%s: Attempting read lock on ID %s", + $this->_getPid(), + $sessionId + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + // reset timer + $this->_timeStart = microtime(true); + } + if($this->_dbNum) $this->_redis->select($this->_dbNum); + while(1) + { + // Increment lock value for this session and retrieve the new value + $oldLock = $lock; + $lock = $this->_redis->hIncrBy($sessionId, 'lock', 1); + + // If we got the lock, update with our pid and reset lock and expiration + if ($lock == 1 || ($tries >= $this->_breakAfter && $lock % self::BREAK_MODULO == 0)) { + $setData = array( + 'pid' => $this->_getPid(), + 'lock' => 1, + ); + + // Save request data in session so if a lock is broken we can know which page it was for debugging + if ($this->_logLevel >= 6) + { + $additionalDetails = sprintf( + "(%s attempts)", + $tries + ); + if ($this->_logLevel >= 7) + { + $additionalDetails = sprintf( + "after %.5f seconds ", + (microtime(true) - $this->_timeStart), + $tries + ) . $additionalDetails; + } + if (empty($_SERVER['REQUEST_METHOD'])) { + $setData['req'] = $_SERVER['SCRIPT_NAME']; + } else { + $setData['req'] = "{$_SERVER['REQUEST_METHOD']} {$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}"; + } + if ($lock != 1) { + Mage::log( + sprintf("%s: Successfully broke lock for ID %s %s. Lock: %s, BREAK_MODULO: %s\nLast request of broken lock: %s", + $this->_getPid(), + $sessionId, + $additionalDetails, + $lock, + self::BREAK_MODULO, + $this->_redis->hGet($sessionId, 'req') + ), + Zend_Log::INFO, self::LOG_FILE + ); + } + } + $this->_redis->pipeline() + ->hMSet($sessionId, $setData) + ->expire($sessionId, min($this->getLifeTime(), self::MAX_LIFETIME)) + ->exec(); + $this->_hasLock = TRUE; + break; + } + + // Otherwise, add to "wait" counter and continue + else if ( ! $waiting) { + $i = 0; + do { + $waiting = $this->_redis->hIncrBy($sessionId, 'wait', 1); + if ($this->_logLevel >= 7) { + Mage::log( + sprintf( + "%s: Waiting for lock on ID %s (%s tries, %s waiting, %.5f seconds elapsed)", + $this->_getPid(), + $sessionId, + $tries, + $waiting, + (microtime(true) - $this->_timeStart) + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + } + } while (++$i < $this->_maxConcurrency && $waiting < 1); + } + + // Handle overloaded sessions + else { + // Detect broken sessions (e.g. caused by fatal errors) + if ($detectZombies) { + $detectZombies = FALSE; + if ( $lock > $oldLock // lock shouldn't be less than old lock (another process broke the lock) + && $lock + 1 < $oldLock + $waiting // lock should be old+waiting, otherwise there must be a dead process + ) { + // Reset session to fresh state + if ($this->_logLevel >= 6) + { + Mage::log( + sprintf("%s: Detected zombie waiter after %.5f seconds for ID %s (%s waiting)\n %s (%s - %s)", + $this->_getPid(), + (microtime(true) - $this->_timeStart), + $sessionId, $waiting, + Mage::app()->getRequest()->getRequestUri(), Mage::app()->getRequest()->getClientIp(), Mage::app()->getRequest()->getHeader('User-Agent') + ), + Zend_Log::INFO, self::LOG_FILE + ); + } + $waiting = $this->_redis->hIncrBy($sessionId, 'wait', -1); + continue; + } + } + + // Limit concurrent lock waiters to prevent server resource hogging + if ($waiting >= $this->_maxConcurrency) { + // Overloaded sessions get 503 errors + $this->_redis->hIncrBy($sessionId, 'wait', -1); + $this->_sessionWritten = TRUE; // Prevent session from getting written + $writes = $this->_redis->hGet($sessionId, 'writes'); + if ($this->_logLevel >= 4) + { + Mage::log( + sprintf("%s: Session concurrency exceeded for ID %s; displaying HTTP 503 (%s waiting, %s total requests)\n %s (%s - %s)", + $this->_getPid(), + $sessionId, $waiting, $writes, + Mage::app()->getRequest()->getRequestUri(), Mage::app()->getRequest()->getClientIp(), Mage::app()->getRequest()->getHeader('User-Agent') + ), + Zend_Log::WARN, self::LOG_FILE + ); + } + require_once(Mage::getBaseDir() . DS . 'errors' . DS . '503.php'); + exit; + } + } + + $tries++; + + // Detect dead waiters + if ($tries == 1 /* TODO - $tries % 10 == 0 ? */) { + $detectZombies = TRUE; + // TODO: allow configuration of sleep period? + usleep(1500000); // 1.5 seconds + } + // Detect dead processes every 10 seconds + if ($tries % self::DETECT_ZOMBIES == 0) { + if ($this->_logLevel >= 7) { + Mage::log( + sprintf( + "%s: Checking for zombies after %.5f seconds of waiting...", + $this->_getPid(), + (microtime(true) - $this->_timeStart) + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + } + $pid = $this->_redis->hGet($sessionId, 'pid'); + if ($pid && ! $this->_pidExists($pid)) { + // Allow a live process to get the lock + $this->_redis->hSet($sessionId, 'lock', 0); + if ($this->_logLevel >= 6) + { + Mage::log( + sprintf("%s: Detected zombie process (%s) for %s (%s waiting)\n %s (%s - %s)", + $this->_getPid(), + $pid, $sessionId, $waiting, + Mage::app()->getRequest()->getRequestUri(), + Mage::app()->getRequest()->getClientIp(), + Mage::app()->getRequest()->getHeader('User-Agent') + ), + Zend_Log::INFO, self::LOG_FILE + ); + } + continue; + } + } + // Timeout + if ($tries >= $this->_breakAfter+self::FAIL_AFTER) { + $this->_hasLock = FALSE; + if ($this->_logLevel >= 5) { + $additionalDetails = sprintf( + "(%s attempts)", + $tries + ); + if ($this->_logLevel >= 7) + { + $additionalDetails = sprintf( + "after %.5f seconds ", + (microtime(true) - $this->_timeStart), + $tries + ) . $additionalDetails; + } + Mage::log( + sprintf( + "%s: Giving up on read lock for ID %s %s", + $this->_getPid(), + $sessionId, + $additionalDetails + ), + Zend_Log::NOTICE, self::LOG_FILE + ); + } + break; + } + else { + // TODO: configurable wait period? + sleep(1); + } + } + self::$failedLockAttempts = $tries; + + // This process is no longer waiting for a lock + if ($tries > 0) { + $this->_redis->hIncrBy($sessionId, 'wait', -1); + } + + // Session can be read even if it was not locked by this pid! + $sessionData = $this->_redis->hGet($sessionId, 'data'); + if ($this->_logLevel >= 7) { + Mage::log( + sprintf( + "%s: Data read for ID %s after %.5f seconds", + $this->_getPid(), + $sessionId, + (microtime(true) - $this->_timeStart) + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + } + return $sessionData ? $this->_decodeData($sessionData) : ''; + } + + /** + * Update session + * + * @param string $sessionId + * @param string $sessionData + * @return boolean + */ + public function write($sessionId, $sessionData) + { + if ( ! $this->_useRedis) return parent::write($sessionId, $sessionData); + if ($this->_sessionWritten) { + if ($this->_logLevel >= 7) { + Mage::log( + sprintf( + "%s: Repeated session write detected; skipping for ID %s", + $this->_getPid(), + $sessionId + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + } + return TRUE; + } + $this->_sessionWritten = TRUE; + if ($this->_logLevel >= 7) { + Mage::log( + sprintf( + "%s: Attempting write to ID %s", + $this->_getPid(), + $sessionId + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + // reset timer + $this->_timeStart = microtime(true); + } + + // Do not overwrite the session if it is locked by another pid + try { + if($this->_dbNum) $this->_redis->select($this->_dbNum); // Prevent conflicts with other connections? + $pid = $this->_redis->hGet('sess_'.$sessionId, 'pid'); // PHP Fatal errors cause self::SESSION_PREFIX to not work.. + if ( ! $pid || $pid == $this->_getPid()) { + if ($this->_logLevel >= 7) { + Mage::log( + sprintf( + "%s: Write lock obtained on ID %s", + $this->_getPid(), + $sessionId + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + } + $this->_writeRawSession($sessionId, $sessionData, $this->getLifeTime()); + if ($this->_logLevel >= 7) { + Mage::log( + sprintf( + "%s: Data written to ID %s after %.5f seconds", + $this->_getPid(), + $sessionId, + (microtime(true) - $this->_timeStart) + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + } + } + else { + if ($this->_logLevel >= 4) { + if ($this->_hasLock) { + Mage::log( + sprintf("%s: Unable to write session after %.5f seconds, another process took the lock for ID %s", + $this->_getPid(), + (microtime(true) - $this->_timeStart), + $sessionId + ), + Zend_Log::WARN, + self::LOG_FILE + ); + } else { + Mage::log( + sprintf("%s: Unable to write session after %.5f seconds, unable to acquire lock on ID %s", + $this->_getPid(), + (microtime(true) - $this->_timeStart), + $sessionId + ), + Zend_Log::WARN, + self::LOG_FILE + ); + } + } + } + } + catch(Exception $e) { + if (class_exists('Mage', false)) { + Mage::logException($e); + } else { + error_log("$e"); + } + return FALSE; + } + return TRUE; + } + + /** + * Destroy session + * + * @param string $sessionId + * @return boolean + */ + public function destroy($sessionId) + { + if ( ! $this->_useRedis) return parent::destroy($sessionId); + + if ($this->_logLevel >= 7) { + Mage::log( + sprintf( + "%s: Destroying ID %s", + $this->_getPid(), + $sessionId + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + } + $this->_redis->pipeline(); + if($this->_dbNum) $this->_redis->select($this->_dbNum); + $this->_redis->del(self::SESSION_PREFIX.$sessionId); + $this->_redis->exec(); + return TRUE; + } + + /** + * Overridden to prevent calling getLifeTime at shutdown + * + * @return bool + */ + public function close() + { + if ( ! $this->_useRedis) return parent::close(); + if ($this->_logLevel >= 7) { + Mage::log( + sprintf( + "%s: Closing connection", + $this->_getPid() + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + } + if ($this->_redis) $this->_redis->close(); + return TRUE; + } + + /** + * Garbage collection + * + * @param int $maxLifeTime ignored + * @return boolean + */ + public function gc($maxLifeTime) + { + if ( ! $this->_useRedis) return parent::gc($maxLifeTime); + return TRUE; + } + + /** + * @return int|mixed + */ + public function getLifeTime() + { + if ($this->_isBot) { + return min(parent::getLifeTime(), $this->_botLifetime); + } + return parent::getLifeTime(); + } + + /** + * Public for testing purposes only. + * + * @param string $data + * @return string + */ + public function _encodeData($data) + { + $originalDataSize = strlen($data); + if ($this->_compressionThreshold > 0 && $this->_compressionLib != 'none' && $originalDataSize >= $this->_compressionThreshold) { + if ($this->_logLevel >= 7) { + Mage::log( + sprintf( + "%s: Compressing %s bytes with %s", + $this->_getPid(), + $originalDataSize, + $this->_compressionLib + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + // reset timer + $this->_timeStart = microtime(true); + } + switch($this->_compressionLib) { + case 'snappy': $data = snappy_compress($data); break; + case 'lzf': $data = lzf_compress($data); break; + case 'gzip': $data = gzcompress($data, 1); break; + } + if($data) { + $data = ':'.substr($this->_compressionLib,0,2).':'.$data; + if ($this->_logLevel >= 7) { + Mage::log( + sprintf( + "%s: Data compressed by %.1f percent in %.5f seconds", + $this->_getPid(), + ($originalDataSize == 0 ? 0 : (100 - (strlen($data) / $originalDataSize * 100))), + (microtime(true) - $this->_timeStart) + ), + Zend_Log::DEBUG, self::LOG_FILE + ); + } + } else if ($this->_logLevel >= 4) { + Mage::log( + sprintf("%s: Could not compress session data using %s", + $this->_getPid(), + $this->_compressionLib + ), + Zend_Log::WARN, + self::LOG_FILE + ); + } + } + return $data; + } + + /** + * Public for testing purposes only. + * + * @param string $data + * @return string + */ + public function _decodeData($data) + { + switch (substr($data,0,4)) { + // asking the data which library it uses allows for transparent changes of libraries + case ':sn:': return snappy_uncompress(substr($data,4)); + case ':lz:': return lzf_decompress(substr($data,4)); + case ':gz:': return gzuncompress(substr($data,4)); + } + return $data; + } + + /** + * Public for testing/import purposes only. + * + * @param $id + * @param $data + * @param $lifetime + * @throws Exception + */ + public function _writeRawSession($id, $data, $lifetime) + { + if ( ! $this->_useRedis) { + throw new Exception('Not connected to redis!'); + } + + $sessionId = 'sess_' . $id; + $this->_redis->pipeline() + ->select($this->_dbNum) + ->hMSet($sessionId, array( + 'data' => $this->_encodeData($data), + 'lock' => 0, // 0 so that next lock attempt will get 1 + )) + ->hIncrBy($sessionId, 'writes', 1) // For informational purposes only + ->expire($sessionId, min($lifetime, 2592000)) + ->exec(); + } + + /** + * @param string $id + * @return array + * @throws Exception + */ + public function _inspectSession($id) + { + if ( ! $this->_useRedis) { + throw new Exception('Not connected to redis!'); + } + + $sessionId = 'sess_' . $id; + $this->_redis->select($this->_dbNum); + $data = $this->_redis->hGetAll($sessionId); + if ($data && isset($data['data'])) { + $data['data'] = $this->_decodeData($data['data']); + } + return $data; + } + + /** + * @return string + */ + public function _getPid() + { + return gethostname().'|'.getmypid(); + } + + /** + * @param $pid + * @return bool + */ + public function _pidExists($pid) + { + list($host,$pid) = explode('|', $pid); + if (PHP_OS != 'Linux' || $host != gethostname()) { + return TRUE; + } + return @file_exists('/proc/'.$pid); + } + +} diff --git a/app/code/community/Cm/RedisSession/etc/config.xml b/app/code/community/Cm/RedisSession/etc/config.xml new file mode 100644 index 00000000000..8c3058ed98e --- /dev/null +++ b/app/code/community/Cm/RedisSession/etc/config.xml @@ -0,0 +1,16 @@ + + + + 0.2 + + + + + + + Cm_RedisSession_Model_Session + + + + + diff --git a/app/code/core/Mage/Admin/Model/Resource/User.php b/app/code/core/Mage/Admin/Model/Resource/User.php index 70b5f37eae8..ef497870c7a 100755 --- a/app/code/core/Mage/Admin/Model/Resource/User.php +++ b/app/code/core/Mage/Admin/Model/Resource/User.php @@ -24,7 +24,6 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - /** * ACL user resource * @@ -151,7 +150,7 @@ public function hasAssigned2Role($user) */ private function _encryptPassword($pwStr) { - return Mage::helper('core')->getHash($pwStr, 2); + return Mage::helper('core')->getHash($pwStr, Mage_Admin_Model_User::HASH_SALT_LENGTH); } /** @@ -219,7 +218,7 @@ public function delete(Mage_Core_Model_Abstract $user) } catch (Mage_Core_Exception $e) { throw $e; return false; - } catch (Exception $e){ + } catch (Exception $e) { $adapter->rollBack(); return false; } @@ -238,7 +237,7 @@ public function _saveRelations(Mage_Core_Model_Abstract $user) { $rolesIds = $user->getRoleIds(); - if( !is_array($rolesIds) || count($rolesIds) == 0 ) { + if (!is_array($rolesIds) || count($rolesIds) == 0) { return $user; } @@ -275,7 +274,7 @@ public function _saveRelations(Mage_Core_Model_Abstract $user) $adapter->commit(); } catch (Mage_Core_Exception $e) { throw $e; - } catch (Exception $e){ + } catch (Exception $e) { $adapter->rollBack(); throw $e; } @@ -331,7 +330,7 @@ public function add(Mage_Core_Model_Abstract $user) $aRoles = $this->hasAssigned2Role($user); if ( sizeof($aRoles) > 0 ) { - foreach($aRoles as $idx => $data){ + foreach ($aRoles as $idx => $data) { $conditions = array( 'role_id = ?' => $data['role_id'], ); diff --git a/app/code/core/Mage/Admin/Model/User.php b/app/code/core/Mage/Admin/Model/User.php index 34d8b355c34..c7a0e6cad30 100644 --- a/app/code/core/Mage/Admin/Model/User.php +++ b/app/code/core/Mage/Admin/Model/User.php @@ -60,18 +60,24 @@ */ class Mage_Admin_Model_User extends Mage_Core_Model_Abstract { - /** + /**#@+ * Configuration paths for email templates and identities */ const XML_PATH_FORGOT_EMAIL_TEMPLATE = 'admin/emails/forgot_email_template'; const XML_PATH_FORGOT_EMAIL_IDENTITY = 'admin/emails/forgot_email_identity'; const XML_PATH_STARTUP_PAGE = 'admin/startup/page'; + /**#@-*/ /** * Minimum length of admin password */ const MIN_PASSWORD_LENGTH = 7; + /** + * Length of salt + */ + const HASH_SALT_LENGTH = 32; + /** * Model event prefix * @@ -116,11 +122,11 @@ protected function _beforeSave() 'extra' => serialize($this->getExtra()) ); - if($this->getId() > 0) { + if ($this->getId() > 0) { $data['user_id'] = $this->getId(); } - if( $this->getUsername() ) { + if ($this->getUsername()) { $data['username'] = $this->getUsername(); } @@ -422,7 +428,18 @@ public function hasAssigned2Role($user) */ protected function _getEncodedPassword($password) { - return Mage::helper('core')->getHash($password, 2); + return $this->_getHelper('core')->getHash($password, self::HASH_SALT_LENGTH); + } + + /** + * Returns helper instance + * + * @param string $helperName + * @return Mage_Core_Helper_Abstract + */ + protected function _getHelper($helperName) + { + return Mage::helper($helperName); } /** @@ -596,5 +613,4 @@ public function isResetPasswordLinkTokenExpired() return false; } - } diff --git a/app/code/core/Mage/Admin/etc/config.xml b/app/code/core/Mage/Admin/etc/config.xml index db1f823acfe..b420845cc36 100644 --- a/app/code/core/Mage/Admin/etc/config.xml +++ b/app/code/core/Mage/Admin/etc/config.xml @@ -28,7 +28,7 @@ - 1.6.1.0 + 1.6.1.1 diff --git a/app/code/core/Mage/Admin/sql/admin_setup/upgrade-1.6.1.0-1.6.1.1.php b/app/code/core/Mage/Admin/sql/admin_setup/upgrade-1.6.1.0-1.6.1.1.php new file mode 100644 index 00000000000..2e1061ab0c5 --- /dev/null +++ b/app/code/core/Mage/Admin/sql/admin_setup/upgrade-1.6.1.0-1.6.1.1.php @@ -0,0 +1,38 @@ +startSetup(); + +//Increase password field length +$installer->getConnection()->changeColumn($installer->getTable('admin/user'), 'password', 'password', array( + 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, + 'length' => 100, + 'comment' => 'User Password' +)); + +$installer->endSetup(); diff --git a/app/code/core/Mage/Adminhtml/Block/Api/User/Edit.php b/app/code/core/Mage/Adminhtml/Block/Api/User/Edit.php index 65a41b8da33..21c2a7db6be 100644 --- a/app/code/core/Mage/Adminhtml/Block/Api/User/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Api/User/Edit.php @@ -48,7 +48,7 @@ public function __construct() public function getHeaderText() { if (Mage::registry('api_user')->getId()) { - return Mage::helper('adminhtml')->__("Edit User '%s'", $this->htmlEscape(Mage::registry('api_user')->getUsername())); + return Mage::helper('adminhtml')->__("Edit User '%s'", $this->escapeHtml(Mage::registry('api_user')->getUsername())); } else { return Mage::helper('adminhtml')->__('New User'); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Checkboxes/Tree.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Checkboxes/Tree.php index edd6c9057b3..0db2e8028dd 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Checkboxes/Tree.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Checkboxes/Tree.php @@ -58,7 +58,7 @@ public function setCategoryIds($ids) protected function _getNodeJson($node, $level = 1) { $item = array(); - $item['text']= $this->htmlEscape($node->getName()); + $item['text']= $this->escapeHtml($node->getName()); if ($this->_withProductCount) { $item['text'].= ' ('.$node->getProductCount().')'; diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Pricestep.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Pricestep.php index b6e82375ee9..9c4c2bdfa5f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Pricestep.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Pricestep.php @@ -34,6 +34,18 @@ */ class Mage_Adminhtml_Block_Catalog_Category_Helper_Pricestep extends Varien_Data_Form_Element_Text { + /** + * Returns js code that is used instead of default toggle code for "Use default config" checkbox + * + * @return string + */ + public function getToggleCode() + { + $htmlId = 'use_config_' . $this->getHtmlId(); + return "toggleValueElements(this, this.parentNode.parentNode);" + . "if (!this.checked) toggleValueElements($('$htmlId'), $('$htmlId').parentNode);"; + } + /** * Retrieve Element HTML fragment * @@ -41,26 +53,30 @@ class Mage_Adminhtml_Block_Catalog_Category_Helper_Pricestep extends Varien_Data */ public function getElementHtml() { + $elementDisabled = $this->getDisabled() == 'disabled'; $disabled = false; - if (!$this->getValue()) { + + if (!$this->getValue() || $elementDisabled) { $this->setData('disabled', 'disabled'); $disabled = true; } + parent::addClass('validate-number validate-number-range number-range-0.01-1000000000'); $html = parent::getElementHtml(); $htmlId = 'use_config_' . $this->getHtmlId(); $html .= '
getReadonly()) { + + if ($this->getReadonly() || $elementDisabled) { $html .= ' disabled="disabled"'; } + $html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />'; - $html .= ' '; - $html .= ''; + $html .= ' '; + $html .= ''; return $html; } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Available.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Available.php index f53d44f9497..6a36d88b146 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Available.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Available.php @@ -35,32 +35,47 @@ class Mage_Adminhtml_Block_Catalog_Category_Helper_Sortby_Available extends Varien_Data_Form_Element_Multiselect { -/** + /** + * Returns js code that is used instead of default toggle code for "Use default config" checkbox + * + * @return string + */ + public function getToggleCode() + { + $htmlId = 'use_config_' . $this->getHtmlId(); + return "toggleValueElements(this, this.parentNode.parentNode);" + . "if (!this.checked) toggleValueElements($('$htmlId'), $('$htmlId').parentNode);"; + } + + /** * Retrieve Element HTML fragment * * @return string */ public function getElementHtml() { + $elementDisabled = $this->getDisabled() == 'disabled'; $disabled = false; - if (!$this->getValue()) { + + if (!$this->getValue() || $elementDisabled) { $this->setData('disabled', 'disabled'); $disabled = true; } + $html = parent::getElementHtml(); $htmlId = 'use_config_' . $this->getHtmlId(); - $html .= 'getReadonly()) { + if ($this->getReadonly() || $elementDisabled) { $html .= ' disabled="disabled"'; } $html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />'; - - $html .= ' '; - $html .= ''; + $html .= ' '; + $html .= ''; return $html; } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Default.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Default.php index 5d7df5d8e70..879895e589e 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Default.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Default.php @@ -35,6 +35,18 @@ class Mage_Adminhtml_Block_Catalog_Category_Helper_Sortby_Default extends Varien_Data_Form_Element_Select { + /** + * Returns js code that is used instead of default toggle code for "Use default config" checkbox + * + * @return string + */ + public function getToggleCode() + { + $htmlId = 'use_config_' . $this->getHtmlId(); + return "toggleValueElements(this, this.parentNode.parentNode);" + . "if (!this.checked) toggleValueElements($('$htmlId'), $('$htmlId').parentNode);"; + } + /** * Retrieve Element HTML fragment * @@ -42,25 +54,28 @@ class Mage_Adminhtml_Block_Catalog_Category_Helper_Sortby_Default */ public function getElementHtml() { + $elementDisabled = $this->getDisabled() == 'disabled'; $disabled = false; - if (!$this->getValue()) { + + if (!$this->getValue() || $elementDisabled) { $this->setData('disabled', 'disabled'); $disabled = true; } + $html = parent::getElementHtml(); $htmlId = 'use_config_' . $this->getHtmlId(); - $html .= 'getReadonly()) { + + if ($this->getReadonly() || $elementDisabled) { $html .= ' disabled="disabled"'; } - $html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />'; - - - $html .= ' '; - $html .= ''; + $html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />'; + $html .= ' '; + $html .= ''; return $html; } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php index 8369c8c542a..930184f6f2b 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php @@ -111,16 +111,15 @@ protected function _prepareForm() { } $this->_setFieldset($attributes, $fieldset); - foreach ($attributes as $attribute) { + $rootId = Mage_Catalog_Model_Category::TREE_ROOT_ID; /* @var $attribute Mage_Eav_Model_Entity_Attribute */ if ($attribute->getAttributeCode() == 'url_key') { - if ($this->getCategory()->getLevel() == 1) { + if ( + (!$this->getCategory()->getId() && $this->getRequest()->getParam('parent', $rootId) == $rootId) + || ($this->getCategory()->getParentId() == $rootId) + ) { $fieldset->removeField('url_key'); - $fieldset->addField('url_key', 'hidden', array( - 'name' => 'url_key', - 'value' => $this->getCategory()->getUrlKey() - )); } else { $form->getElement('url_key')->setRenderer( $this->getLayout()->createBlock('adminhtml/catalog_form_renderer_attribute_urlkey') diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/General.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/General.php index 9e4603ef7eb..d968131f29d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/General.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/General.php @@ -123,7 +123,7 @@ protected function _getParentCategoryOptions($node=null, &$options=array()) if ($node) { $options[] = array( 'value' => $node->getPathId(), - 'label' => str_repeat(' ', max(0, 3*($node->getLevel()))) . $this->htmlEscape($node->getName()), + 'label' => str_repeat(' ', max(0, 3*($node->getLevel()))) . $this->escapeHtml($node->getName()), ); foreach ($node->getChildren() as $child) { diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php index 9f3f99bfc8e..4f2b9ac36b6 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php @@ -151,7 +151,10 @@ public function getNodesUrl() public function getSwitchTreeUrl() { - return $this->getUrl("*/catalog_category/tree", array('_current'=>true, 'store'=>null, '_query'=>false, 'id'=>null, 'parent'=>null)); + return $this->getUrl( + "*/catalog_category/tree", + array('_current'=>true, 'store'=>null, '_query'=>false, 'id'=>null, 'parent'=>null) + ); } public function getIsWasExpanded() @@ -202,7 +205,9 @@ public function getBreadcrumbsJavascript($path, $javascriptVarName) return ''; } @@ -223,7 +228,9 @@ protected function _getNodeJson($node, $level = 0) $item = array(); $item['text'] = $this->buildNodeName($node); - //$rootForStores = Mage::getModel('core/store')->getCollection()->loadByCategoryIds(array($node->getEntityId())); + /* $rootForStores = Mage::getModel('core/store') + ->getCollection() + ->loadByCategoryIds(array($node->getEntityId())); */ $rootForStores = in_array($node->getEntityId(), $this->getRootIds()); $item['id'] = $node->getId(); @@ -267,7 +274,7 @@ protected function _getNodeJson($node, $level = 0) */ public function buildNodeName($node) { - $result = $this->htmlEscape($node->getName()); + $result = $this->escapeHtml($node->getName()); if ($this->_withProductCount) { $result .= ' (' . $node->getProductCount() . ')'; } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php index bd7bf964747..4ed5bf81c07 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php @@ -140,7 +140,20 @@ public function getScopeLabel() if (!$attribute || Mage::app()->isSingleStoreMode() || $attribute->getFrontendInput()=='gallery') { return $html; } - if ($attribute->isScopeGlobal()) { + + /* + * Check if the current attribute is a 'price' attribute. If yes, check + * the config setting 'Catalog Price Scope' and modify the scope label. + */ + $isGlobalPriceScope = false; + if ($attribute->getFrontendInput() == 'price') { + $priceScope = Mage::getStoreConfig('catalog/price/scope'); + if ($priceScope == 0) { + $isGlobalPriceScope = true; + } + } + + if ($attribute->isScopeGlobal() || $isGlobalPriceScope) { $html .= Mage::helper('adminhtml')->__('[GLOBAL]'); } elseif ($attribute->isScopeWebsite()) { $html .= Mage::helper('adminhtml')->__('[WEBSITE]'); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg.php index 4933a4f3e8e..e47e4a09ae7 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg.php @@ -48,7 +48,7 @@ public function getAfterElementHtml() 'label' => Mage::helper('catalog')->__('WYSIWYG Editor'), 'type' => 'button', 'disabled' => $disabled, - 'class' => ($disabled) ? 'disabled btn-wysiwyg' : 'btn-wysiwyg', + 'class' => 'btn-wysiwyg', 'onclick' => 'catalogWysiwygEditor.open(\''.Mage::helper('adminhtml')->getUrl('*/*/wysiwyg').'\', \''.$this->getHtmlId().'\')' ))->toHtml(); } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php index 118ea38cda2..1d8b581325a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php @@ -82,7 +82,7 @@ public function getHeaderText() if (is_array($frontendLabel)) { $frontendLabel = $frontendLabel[0]; } - return Mage::helper('catalog')->__('Edit Product Attribute "%s"', $this->htmlEscape($frontendLabel)); + return Mage::helper('catalog')->__('Edit Product Attribute "%s"', $this->escapeHtml($frontendLabel)); } else { return Mage::helper('catalog')->__('New Product Attribute'); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php index b33511dff9e..17ea98f1d72 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php @@ -57,7 +57,8 @@ protected function _prepareLayout() $this->getLayout()->createBlock('adminhtml/widget_button') ->setData(array( 'label' => Mage::helper('catalog')->__('Back'), - 'onclick' => 'setLocation(\''.$this->getUrl('*/*/', array('store'=>$this->getRequest()->getParam('store', 0))).'\')', + 'onclick' => 'setLocation(\'' + . $this->getUrl('*/*/', array('store'=>$this->getRequest()->getParam('store', 0))).'\')', 'class' => 'back' )) ); @@ -107,7 +108,8 @@ protected function _prepareLayout() $this->getLayout()->createBlock('adminhtml/widget_button') ->setData(array( 'label' => Mage::helper('catalog')->__('Delete'), - 'onclick' => 'confirmSetLocation(\''.Mage::helper('catalog')->__('Are you sure?').'\', \''.$this->getDeleteUrl().'\')', + 'onclick' => 'confirmSetLocation(\'' + . Mage::helper('catalog')->__('Are you sure?').'\', \''.$this->getDeleteUrl().'\')', 'class' => 'delete' )) ); @@ -211,7 +213,7 @@ public function getHeader() { $header = ''; if ($this->getProduct()->getId()) { - $header = $this->htmlEscape($this->getProduct()->getName()); + $header = $this->escapeHtml($this->getProduct()->getName()); } else { $header = Mage::helper('catalog')->__('New Product'); @@ -235,7 +237,10 @@ public function getAttributeSetName() public function getIsConfigured() { if ($this->getProduct()->isConfigurable() - && !($superAttributes = $this->getProduct()->getTypeInstance(true)->getUsedProductAttributeIds($this->getProduct()))) { + && !($superAttributes = $this->getProduct() + ->getTypeInstance(true) + ->getUsedProductAttributeIds($this->getProduct())) + ) { $superAttributes = false; } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php index 13e35d0afbd..ff1bfe17761 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php @@ -232,7 +232,7 @@ public function getOptionValues() $value['id'] = $option->getOptionId(); $value['item_count'] = $this->getItemCount(); $value['option_id'] = $option->getOptionId(); - $value['title'] = $this->htmlEscape($option->getTitle()); + $value['title'] = $this->escapeHtml($option->getTitle()); $value['type'] = $option->getType(); $value['is_require'] = $option->getIsRequire(); $value['sort_order'] = $option->getSortOrder(); @@ -256,11 +256,11 @@ public function getOptionValues() 'item_count' => max($itemCount, $_value->getOptionTypeId()), 'option_id' => $_value->getOptionId(), 'option_type_id' => $_value->getOptionTypeId(), - 'title' => $this->htmlEscape($_value->getTitle()), + 'title' => $this->escapeHtml($_value->getTitle()), 'price' => ($showPrice) ? $this->getPriceValue($_value->getPrice(), $_value->getPriceType()) : '', 'price_type' => ($showPrice) ? $_value->getPriceType() : 0, - 'sku' => $this->htmlEscape($_value->getSku()), + 'sku' => $this->escapeHtml($_value->getSku()), 'sort_order' => $_value->getSortOrder(), ); @@ -284,7 +284,7 @@ public function getOptionValues() $value['price'] = ($showPrice) ? $this->getPriceValue($option->getPrice(), $option->getPriceType()) : ''; $value['price_type'] = $option->getPriceType(); - $value['sku'] = $this->htmlEscape($option->getSku()); + $value['sku'] = $this->escapeHtml($option->getSku()); $value['max_characters'] = $option->getMaxCharacters(); $value['file_extension'] = $option->getFileExtension(); $value['image_size_x'] = $option->getImageSizeX(); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid.php index fb3ba2da77c..58563c6c0b9 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid.php @@ -33,7 +33,16 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid extends Mage_Adminhtml_Block_Widget_Grid { + /** + * Config attribute codes + * + * @var null|array + */ + protected $_configAttributeCodes = null; + /** + * Constructor + */ public function __construct() { parent::__construct(); @@ -41,7 +50,7 @@ public function __construct() $this->setId('super_product_links'); if ($this->_getProduct()->getId()) { - $this->setDefaultFilter(array('in_products'=>1)); + $this->setDefaultFilter(array('in_products' => 1)); } } @@ -309,4 +318,87 @@ public function getGridUrl() return $this->getUrl('*/*/superConfig', array('_current'=>true)); } + /** + * Retrieving configurable attributes + * + * @return array + */ + protected function _getConfigAttributeCodes() + { + if (is_null($this->_configAttributeCodes)) { + $product = $this->_getProduct(); + $attributes = $product->getTypeInstance(true)->getConfigurableAttributes($product); + $attributeCodes = array(); + foreach ($attributes as $attribute) { + $productAttribute = $attribute->getProductAttribute(); + $attributeCodes[] = $productAttribute->getAttributeCode(); + } + $this->_configAttributeCodes = $attributeCodes; + } + return $this->_configAttributeCodes; + } + + /** + * Retrieve item row configurable attribute data + * + * @param Varien_Object $item + * @return array + */ + protected function _retrieveRowData(Varien_Object $item) + { + $attributeValues = array(); + foreach ($this->_getConfigAttributeCodes() as $attributeCode) { + $data = $item->getData($attributeCode); + if ($data) { + $attributeValues[$attributeCode] = $data; + } + } + return $attributeValues; + } + + /** + * Checking the data contains the same value of data after collection + * + * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid + */ + protected function _afterLoadCollection() + { + parent::_afterLoadCollection(); + + $attributeCodes = $this->_getConfigAttributeCodes(); + if (!$attributeCodes) { + return $this; + } + + $disableMultiSelect = false; + $ids = array(); + foreach ($this->_collection as $item) { + $ids[] = $item->getId(); + $needleAttributeValues = $this->_retrieveRowData($item); + foreach($this->_collection as $item2) { + // Skip the data if already checked + if (in_array($item2->getId(), $ids)) { + continue; + } + $attributeValues = $this->_retrieveRowData($item2); + $disableMultiSelect = ($needleAttributeValues == $attributeValues); + if ($disableMultiSelect) { + break; + } + } + if ($disableMultiSelect) { + break; + } + } + + // Disable multiselect column + if ($disableMultiSelect) { + $selectAll = $this->getColumn('in_products'); + if ($selectAll) { + $selectAll->setDisabled(true); + } + } + + return $this; + } } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit.php index a7e0e4beb5b..b887c3d89fd 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit.php @@ -49,7 +49,7 @@ public function __construct() public function getHeaderText() { if (Mage::registry('current_catalog_search')->getId()) { - return Mage::helper('catalog')->__("Edit Search '%s'", $this->htmlEscape(Mage::registry('current_catalog_search')->getQueryText())); + return Mage::helper('catalog')->__("Edit Search '%s'", $this->escapeHtml(Mage::registry('current_catalog_search')->getQueryText())); } else { return Mage::helper('catalog')->__('New Search'); diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php b/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php index cd7e9ee2047..512f4125f5f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php @@ -73,7 +73,7 @@ function saveAndContinueEdit(){ public function getHeaderText() { if (Mage::registry('cms_block')->getId()) { - return Mage::helper('cms')->__("Edit Block '%s'", $this->htmlEscape(Mage::registry('cms_block')->getTitle())); + return Mage::helper('cms')->__("Edit Block '%s'", $this->escapeHtml(Mage::registry('cms_block')->getTitle())); } else { return Mage::helper('cms')->__('New Block'); diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php index 921977fdb1d..4467dbb0558 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php @@ -71,7 +71,7 @@ public function __construct() public function getHeaderText() { if (Mage::registry('cms_page')->getId()) { - return Mage::helper('cms')->__("Edit Page '%s'", $this->htmlEscape(Mage::registry('cms_page')->getTitle())); + return Mage::helper('cms')->__("Edit Page '%s'", $this->escapeHtml(Mage::registry('cms_page')->getTitle())); } else { return Mage::helper('cms')->__('New Page'); diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php index 36ac00a8908..88d61170661 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php @@ -89,7 +89,8 @@ protected function _prepareForm() 'label' => Mage::helper('cms')->__('Custom Design From'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'format' => $dateFormatIso, - 'disabled' => $isElementDisabled + 'disabled' => $isElementDisabled, + 'class' => 'validate-date validate-date-range date-range-custom_theme-from' )); $designFieldset->addField('custom_theme_to', 'date', array( @@ -97,7 +98,8 @@ protected function _prepareForm() 'label' => Mage::helper('cms')->__('Custom Design To'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'format' => $dateFormatIso, - 'disabled' => $isElementDisabled + 'disabled' => $isElementDisabled, + 'class' => 'validate-date validate-date-range date-range-custom_theme-to' )); $designFieldset->addField('custom_theme', 'select', array( diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php index e32b93c7efd..5ab14bddb08 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php @@ -75,7 +75,7 @@ public function getCustomerId() public function getHeaderText() { if (Mage::registry('current_customer')->getId()) { - return $this->htmlEscape(Mage::registry('current_customer')->getName()); + return $this->escapeHtml(Mage::registry('current_customer')->getName()); } else { return Mage::helper('customer')->__('New Customer'); diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Newpass.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Newpass.php index 974199fb175..78eeb8d2575 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Newpass.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Newpass.php @@ -29,28 +29,40 @@ * * @category Mage * @package Mage_Adminhtml - * @author Magento Core Team + * @author Magento Core Team */ -class Mage_Adminhtml_Block_Customer_Edit_Renderer_Newpass extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface +class Mage_Adminhtml_Block_Customer_Edit_Renderer_Newpass + extends Mage_Adminhtml_Block_Abstract + implements Varien_Data_Form_Element_Renderer_Interface { - + /** + * Render block + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ public function render(Varien_Data_Form_Element_Abstract $element) { - $html = ''; - $html.= ''.$element->getLabelHtml().''; - $html.= ''.$element->getElementHtml().''; - $html.= ''."\n"; - $html.= ''; - $html.= ''; - $html.= ''.Mage::helper('customer')->__('or').''; - $html.= ''."\n"; - $html.= ''; - $html.= ''; - $html.= ' '; - $html.= ''; - $html.= ''."\n"; + $html = ''; + $html .= '' . $element->getLabelHtml() . ''; + $html .= '' . $element->getElementHtml() . ''; + $html .= '' . "\n"; + $html .= ''; + $html .= ''; + $html .= '' . Mage::helper('customer')->__('or') . ''; + $html .= '' . "\n"; + $html .= ''; + $html .= ''; + $html .= ' '; + $html .= ''; + $html .= ''."\n"; return $html; } - } diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php index 5f455f3da57..32701c34017 100755 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php @@ -33,6 +33,23 @@ class Mage_Adminhtml_Block_Customer_Edit_Renderer_Region extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface { + /** + * Factory instance + * + * @var Mage_Core_Model_Abstract + */ + protected $_factory; + + /** + * Constructor for Mage_Adminhtml_Block_Customer_Edit_Renderer_Region class + * + * @param array $args + */ + public function __construct(array $args = array()) + { + $this->_factory = !empty($args['factory']) ? $args['factory'] : Mage::getSingleton('core/factory'); + } + /** * Output the region element and javasctipt that makes it dependent from country element * @@ -41,14 +58,15 @@ class Mage_Adminhtml_Block_Customer_Edit_Renderer_Region */ public function render(Varien_Data_Form_Element_Abstract $element) { - if ($country = $element->getForm()->getElement('country_id')) { + $country = $element->getForm()->getElement('country_id'); + if (!is_null($country)) { $countryId = $country->getValue(); - } - else { + } else { return $element->getDefaultHtml(); } $regionId = $element->getForm()->getElement('region_id')->getValue(); + $quoteStoreId = $element->getEntityAttribute()->getStoreId(); $html = ''; $element->setClass('input-text'); @@ -60,13 +78,13 @@ public function render(Varien_Data_Form_Element_Abstract $element) $selectId = $element->getHtmlId() . '_id'; $html .= ''; $html .= '' . "\n"; $html .= '' . "\n"; diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php index be8efc5396c..f46247868f3 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php @@ -78,7 +78,7 @@ public function getCustomerLog() */ public function getCreateDate() { - return Mage::helper('core')->formatDate($this->getCustomer()->getCreatedAtTimestamp(), + return $this->_getCoreHelper()->formatDate($this->getCustomer()->getCreatedAt(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true); } @@ -211,4 +211,13 @@ public function isHidden() return true; } + /** + * Return instance of core helper + * + * @return Mage_Core_Helper_Data + */ + protected function _getCoreHelper() + { + return Mage::helper('core'); + } } diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php index 8b9746fb9d9..a2638c125f8 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php @@ -29,11 +29,10 @@ * * @category Mage * @package Mage_Adminhtml - * @author Magento Core Team + * @author Magento Core Team */ class Mage_Adminhtml_Block_Customer_Edit_Tab_View_Cart extends Mage_Adminhtml_Block_Widget_Grid { - public function __construct() { parent::__construct(); @@ -47,6 +46,7 @@ public function __construct() protected function _prepareCollection() { + /** @var $quote Mage_Sales_Model_Quote */ $quote = Mage::getModel('sales/quote'); // set website to quote, if any if ($this->getWebsiteId()) { @@ -54,12 +54,7 @@ protected function _prepareCollection() } $quote->loadByCustomer(Mage::registry('current_customer')); - if ($quote) { - $collection = $quote->getItemsCollection(false); - } - else { - $collection = new Varien_Data_Collection(); - } + $collection = $quote ? $quote->getItemsCollection(false) : new Varien_Data_Collection(); $collection->addFieldToFilter('parent_item_id', array('null' => true)); $this->setCollection($collection); @@ -69,55 +64,56 @@ protected function _prepareCollection() protected function _prepareColumns() { + $currencyCode = (string)Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE); $this->addColumn('product_id', array( 'header' => Mage::helper('customer')->__('Product ID'), 'index' => 'product_id', - 'width' => '100px', - )); - - $this->addColumn('name', array( + 'width' => '100px' + ))->addColumn('name', array( 'header' => Mage::helper('customer')->__('Product Name'), - 'index' => 'name', - )); - - $this->addColumn('sku', array( + 'index' => 'name' + ))->addColumn('sku', array( 'header' => Mage::helper('customer')->__('SKU'), 'index' => 'sku', - 'width' => '100px', - )); - - $this->addColumn('qty', array( + 'width' => '100px' + ))->addColumn('qty', array( 'header' => Mage::helper('customer')->__('Qty'), 'index' => 'qty', 'type' => 'number', - 'width' => '60px', - )); - - $this->addColumn('price', array( + 'width' => '60px' + ))->addColumn('price', array( 'header' => Mage::helper('customer')->__('Price'), 'index' => 'price', 'type' => 'currency', - 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE), - )); - - $this->addColumn('total', array( + 'currency_code' => $currencyCode + ))->addColumn('total', array( 'header' => Mage::helper('customer')->__('Total'), 'index' => 'row_total', 'type' => 'currency', - 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE), + 'currency_code' => $currencyCode )); return parent::_prepareColumns(); } + /** + * Retrieve row url + * + * @param Mage_Sales_Model_Quote_Item $row + * @return string + */ public function getRowUrl($row) { return $this->getUrl('*/catalog_product/edit', array('id' => $row->getProductId())); } + /** + * Check weather header should be shown + * + * @return bool + */ public function getHeadersVisibility() { return ($this->getCollection()->getSize() > 0); } - } diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Orders.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Orders.php index 2abf9a8bf84..06218662a1e 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Orders.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Orders.php @@ -71,7 +71,7 @@ protected function _prepareColumns() )); $this->addColumn('created_at', array( - 'header' => Mage::helper('customer')->__('Purchased At'), + 'header' => Mage::helper('customer')->__('Purchased On'), 'index' => 'created_at', 'type' => 'datetime', )); @@ -87,7 +87,7 @@ protected function _prepareColumns() )); $this->addColumn('grand_total', array( - 'header' => Mage::helper('customer')->__('Grand Total'), + 'header' => Mage::helper('customer')->__('Order Total'), 'index' => 'grand_total', 'type' => 'currency', 'currency' => 'order_currency_code', diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist.php index 7c6e9c2087f..d2d22b56ca1 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist.php @@ -86,7 +86,9 @@ protected function _getCustomer() */ protected function _createCollection() { - return Mage::getModel('wishlist/item')->getCollection(); + return Mage::getModel('wishlist/item')->getCollection() + ->setWebsiteId($this->_getCustomer()->getWebsiteId()) + ->setCustomerGroupId($this->_getCustomer()->getGroupId()); } /** @@ -113,13 +115,13 @@ protected function _prepareCollection() protected function _prepareColumns() { $this->addColumn('product_name', array( - 'header' => Mage::helper('catalog')->__('Product name'), + 'header' => Mage::helper('catalog')->__('Product Name'), 'index' => 'product_name', 'renderer' => 'adminhtml/customer_edit_tab_view_grid_renderer_item' )); $this->addColumn('description', array( - 'header' => Mage::helper('wishlist')->__('User description'), + 'header' => Mage::helper('wishlist')->__('User Description'), 'index' => 'description', 'renderer' => 'adminhtml/customer_edit_tab_wishlist_grid_renderer_description' )); diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit.php b/app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit.php index a6dba63d579..e3ce6001f9f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit.php @@ -52,7 +52,7 @@ public function __construct() public function getHeaderText() { if(!is_null(Mage::registry('current_group')->getId())) { - return Mage::helper('customer')->__('Edit Customer Group "%s"', $this->htmlEscape(Mage::registry('current_group')->getCustomerGroupCode())); + return Mage::helper('customer')->__('Edit Customer Group "%s"', $this->escapeHtml(Mage::registry('current_group')->getCustomerGroupCode())); } else { return Mage::helper('customer')->__('New Customer Group'); } diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Renderer/Searchquery.php b/app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Renderer/Searchquery.php index 45f269e080e..2fe5d5e81be 100644 --- a/app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Renderer/Searchquery.php +++ b/app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Renderer/Searchquery.php @@ -31,16 +31,18 @@ * @category Mage * @package Mage_Adminhtml */ -class Mage_Adminhtml_Block_Dashboard_Searches_Renderer_Searchquery extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract +class Mage_Adminhtml_Block_Dashboard_Searches_Renderer_Searchquery + extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract { public function render(Varien_Object $row) { $value = $row->getData($this->getColumn()->getIndex()); if (Mage::helper('core/string')->strlen($value) > 30) { - $value = '' . $this->htmlEscape(Mage::helper('core/string')->truncate($value, 30)) . ''; + $value = '' + . $this->escapeHtml(Mage::helper('core/string')->truncate($value, 30)) . ''; } else { - $value = $this->htmlEscape($value); + $value = $this->escapeHtml($value); } return $value; } diff --git a/app/code/core/Mage/Adminhtml/Block/Page/Menu.php b/app/code/core/Mage/Adminhtml/Block/Page/Menu.php index 5634f0a4485..812906f52eb 100644 --- a/app/code/core/Mage/Adminhtml/Block/Page/Menu.php +++ b/app/code/core/Mage/Adminhtml/Block/Page/Menu.php @@ -141,7 +141,7 @@ protected function _buildMenuArray(Varien_Simplexml_Element $parent=null, $path= } $aclResource = 'admin/' . ($child->resource ? (string)$child->resource : $path . $childName); - if (!$this->_checkAcl($aclResource)) { + if (!$this->_checkAcl($aclResource) || !$this->_isEnabledModuleOutput($child)) { continue; } @@ -307,4 +307,21 @@ public function getMenuLevel($menu, $level = 0) return $html; } + + /** + * Check is module output enabled + * + * @param Varien_Simplexml_Element $child + * @return bool + */ + protected function _isEnabledModuleOutput(Varien_Simplexml_Element $child) + { + $helperName = 'adminhtml'; + $childAttributes = $child->attributes(); + if (isset($childAttributes['module'])) { + $helperName = (string)$childAttributes['module']; + } + + return Mage::helper($helperName)->isModuleOutputEnabled(); + } } diff --git a/app/code/core/Mage/Adminhtml/Block/Permissions/User/Edit.php b/app/code/core/Mage/Adminhtml/Block/Permissions/User/Edit.php index 364074f7ab7..657dc1359d7 100644 --- a/app/code/core/Mage/Adminhtml/Block/Permissions/User/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Permissions/User/Edit.php @@ -48,7 +48,7 @@ public function __construct() public function getHeaderText() { if (Mage::registry('permissions_user')->getId()) { - return Mage::helper('adminhtml')->__("Edit User '%s'", $this->htmlEscape(Mage::registry('permissions_user')->getUsername())); + return Mage::helper('adminhtml')->__("Edit User '%s'", $this->escapeHtml(Mage::registry('permissions_user')->getUsername())); } else { return Mage::helper('adminhtml')->__('New User'); diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit.php b/app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit.php index 88ef63e3539..9ea48be11da 100644 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit.php @@ -55,7 +55,7 @@ public function __construct() public function getHeaderText() { - return Mage::helper('poll')->__("Edit Answer '%s'", $this->htmlEscape(Mage::registry('answer_data')->getAnswerTitle())); + return Mage::helper('poll')->__("Edit Answer '%s'", $this->escapeHtml(Mage::registry('answer_data')->getAnswerTitle())); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit.php b/app/code/core/Mage/Adminhtml/Block/Poll/Edit.php index fc8ccf5df67..ef2b62d3b81 100644 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Poll/Edit.php @@ -50,7 +50,7 @@ public function __construct() public function getHeaderText() { if( Mage::registry('poll_data') && Mage::registry('poll_data')->getId() ) { - return Mage::helper('poll')->__("Edit Poll '%s'", $this->htmlEscape(Mage::registry('poll_data')->getPollTitle())); + return Mage::helper('poll')->__("Edit Poll '%s'", $this->escapeHtml(Mage::registry('poll_data')->getPollTitle())); } else { return Mage::helper('poll')->__('New Poll'); } diff --git a/app/code/core/Mage/Adminhtml/Block/Rating/Edit.php b/app/code/core/Mage/Adminhtml/Block/Rating/Edit.php index 9d7d6d0188b..b281bf28be4 100644 --- a/app/code/core/Mage/Adminhtml/Block/Rating/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Rating/Edit.php @@ -57,7 +57,7 @@ public function __construct() public function getHeaderText() { if( Mage::registry('rating_data') && Mage::registry('rating_data')->getId() ) { - return Mage::helper('rating')->__("Edit Rating", $this->htmlEscape(Mage::registry('rating_data')->getRatingCode())); + return Mage::helper('rating')->__("Edit Rating", $this->escapeHtml(Mage::registry('rating_data')->getRatingCode())); } else { return Mage::helper('rating')->__('New Rating'); } diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Tag/Customer/Detail/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Tag/Customer/Detail/Grid.php index a6263a8b827..e32b1ab55be 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Tag/Customer/Detail/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Tag/Customer/Detail/Grid.php @@ -47,7 +47,6 @@ protected function _prepareCollection() ->joinAttribute('original_name', 'catalog_product/name', 'entity_id') ->addCustomerFilter($this->getRequest()->getParam('id')) ->addStatusFilter(Mage_Tag_Model_Tag::STATUS_APPROVED) - ->setDescOrder('DESC') ->addStoresVisibility() ->setActiveFilter() ->addGroupByTag() @@ -62,28 +61,25 @@ protected function _prepareColumns() { $this->addColumn('name', array( 'header' =>Mage::helper('reports')->__('Product Name'), - 'sortable' => false, 'index' =>'original_name' )); $this->addColumn('tag_name', array( 'header' =>Mage::helper('reports')->__('Tag Name'), - 'sortable' => false, 'index' =>'tag_name' )); if (!Mage::app()->isSingleStoreMode()) { $this->addColumn('visible', array( 'header' => Mage::helper('reports')->__('Visible In'), - 'sortable' => false, 'index' => 'stores', 'type' => 'store', + 'sortable' => false, 'store_view'=> true )); $this->addColumn('added_in', array( 'header' =>Mage::helper('reports')->__('Submitted In'), - 'sortable' => false, 'index' =>'store_id', 'type' =>'store', 'store_view'=>true @@ -92,7 +88,6 @@ protected function _prepareColumns() $this->addColumn('created_at', array( 'header' =>Mage::helper('reports')->__('Submitted On'), - 'sortable' => false, 'width' => '140px', 'type' => 'datetime', 'index' => 'created_at' diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Tag/Popular/Detail/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Tag/Popular/Detail/Grid.php index 93cf141ea96..ed61eb710fb 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Tag/Popular/Detail/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Tag/Popular/Detail/Grid.php @@ -50,9 +50,8 @@ protected function _prepareCollection() /* @var $collection Mage_Reports_Model_Resource_Tag_Customer_Collection */ $collection = Mage::getResourceModel('reports/tag_customer_collection'); $collection->addStatusFilter(Mage::getModel('tag/tag')->getApprovedStatus()) - ->addTagFilter($this->getRequest()->getParam('id')) - ->addDescOrder() - ->addProductName(); + ->addTagFilter($this->getRequest()->getParam('id')) + ->addProductToSelect(); $this->setCollection($collection); @@ -69,27 +68,23 @@ protected function _prepareColumns() $this->addColumn('firstname', array( 'header' =>Mage::helper('reports')->__('First Name'), - 'sortable' => false, 'index' =>'firstname' )); $this->addColumn('lastname', array( 'header' =>Mage::helper('reports')->__('Last Name'), - 'sortable' => false, 'index' =>'lastname' )); $this->addColumn('product', array( 'header' =>Mage::helper('reports')->__('Product Name'), - 'sortable' => false, - 'index' =>'product' + 'index' =>'product_name' )); if (!Mage::app()->isSingleStoreMode()) { $this->addColumn('added_in', array( 'header' => Mage::helper('reports')->__('Submitted In'), - 'sortable' => false, - 'index' => 'store_id', + 'index' => 'added_in', 'type' => 'store', 'store_view'=> true )); diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Tag/Popular/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Tag/Popular/Grid.php index 7cda22744b1..edbdcdb8966 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Tag/Popular/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Tag/Popular/Grid.php @@ -65,7 +65,6 @@ protected function _prepareColumns() { $this->addColumn('name', array( 'header' =>Mage::helper('reports')->__('Tag Name'), - 'sortable' =>false, 'index' =>'name' )); @@ -73,7 +72,6 @@ protected function _prepareColumns() 'header' =>Mage::helper('reports')->__('Popularity'), 'width' =>'50px', 'align' =>'right', - 'sortable' =>false, 'index' =>'popularity' )); diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Tag/Product/Detail/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Tag/Product/Detail/Grid.php index 46a4dc9eae0..6f8a6f543b7 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Tag/Product/Detail/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Tag/Product/Detail/Grid.php @@ -75,7 +75,7 @@ protected function _prepareColumns() $this->addColumn('visible', array( 'header' => Mage::helper('reports')->__('Visible In'), 'sortable' => false, - 'index' => 'stores', + 'index' => 'stores', 'type' => 'store', 'store_view'=> true )); diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Add/Form.php b/app/code/core/Mage/Adminhtml/Block/Review/Add/Form.php index 45ed9edf955..4fefdbe9db6 100644 --- a/app/code/core/Mage/Adminhtml/Block/Review/Add/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Review/Add/Form.php @@ -36,11 +36,6 @@ class Mage_Adminhtml_Block_Review_Add_Form extends Mage_Adminhtml_Block_Widget_F { protected function _prepareForm() { - $statuses = Mage::getModel('review/review') - ->getStatusCollection() - ->load() - ->toOptionArray(); - $form = new Varien_Data_Form(); $fieldset = $form->addFieldset('add_review_form', array('legend' => Mage::helper('review')->__('Review Details'))); @@ -61,7 +56,7 @@ protected function _prepareForm() 'label' => Mage::helper('review')->__('Status'), 'required' => true, 'name' => 'status_id', - 'values' => $statuses, + 'values' => Mage::helper('review')->getReviewStatusesOptionArray(), )); /** diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Edit.php b/app/code/core/Mage/Adminhtml/Block/Review/Edit.php index 1078043ffb2..1dcfdaddfd8 100644 --- a/app/code/core/Mage/Adminhtml/Block/Review/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Review/Edit.php @@ -46,19 +46,47 @@ public function __construct() $this->_updateButton('delete', 'label', Mage::helper('review')->__('Delete Review')); if( $this->getRequest()->getParam('productId', false) ) { - $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/catalog_product/edit', array('id' => $this->getRequest()->getParam('productId', false))) .'\')' ); + $this->_updateButton( + 'back', + 'onclick', + 'setLocation(\'' + . $this->getUrl( + '*/catalog_product/edit', + array('id' => $this->getRequest()->getParam('productId', false)) + ) + .'\')' + ); } if( $this->getRequest()->getParam('customerId', false) ) { - $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/customer/edit', array('id' => $this->getRequest()->getParam('customerId', false))) .'\')' ); + $this->_updateButton( + 'back', + 'onclick', + 'setLocation(\'' + . $this->getUrl( + '*/customer/edit', + array('id' => $this->getRequest()->getParam('customerId', false)) + ) + .'\')' + ); } if( $this->getRequest()->getParam('ret', false) == 'pending' ) { $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/*/pending') .'\')' ); - $this->_updateButton('delete', 'onclick', 'deleteConfirm(\'' . Mage::helper('review')->__('Are you sure you want to do this?') . '\', \'' . $this->getUrl('*/*/delete', array( - $this->_objectId => $this->getRequest()->getParam($this->_objectId), - 'ret' => 'pending', - )) .'\')' ); + $this->_updateButton( + 'delete', + 'onclick', + 'deleteConfirm(' + . '\'' . Mage::helper('review')->__('Are you sure you want to do this?').'\' ' + . '\'' . $this->getUrl( + '*/*/delete', + array( + $this->_objectId => $this->getRequest()->getParam($this->_objectId), + 'ret' => 'pending', + ) + ) . '\'' + . ')' + ); Mage::register('ret', 'pending'); } @@ -71,9 +99,20 @@ public function __construct() $this->_formInitScripts[] = ' var review = { updateRating: function() { - elements = [$("select_stores"), $("rating_detail").getElementsBySelector("input[type=\'radio\']")].flatten(); + elements = [ + $("select_stores"), + $("rating_detail").getElementsBySelector("input[type=\'radio\']") + ].flatten(); $(\'save_button\').disabled = true; - new Ajax.Updater("rating_detail", "'.$this->getUrl('*/*/ratingItems', array('_current'=>true)).'", {parameters:Form.serializeElements(elements), evalScripts:true, onComplete:function(){ $(\'save_button\').disabled = false; } }); + new Ajax.Updater( + "rating_detail", + "' . $this->getUrl('*/*/ratingItems', array('_current'=>true)).'", + { + parameters:Form.serializeElements(elements), + evalScripts:true, + onComplete:function(){ $(\'save_button\').disabled = false; } + } + ); } } Event.observe(window, \'load\', function(){ @@ -85,7 +124,7 @@ public function __construct() public function getHeaderText() { if( Mage::registry('review_data') && Mage::registry('review_data')->getId() ) { - return Mage::helper('review')->__("Edit Review '%s'", $this->htmlEscape(Mage::registry('review_data')->getTitle())); + return Mage::helper('review')->__("Edit Review '%s'", $this->escapeHtml(Mage::registry('review_data')->getTitle())); } else { return Mage::helper('review')->__('New Review'); } diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Review/Edit/Form.php index d9efa34bde5..05270cc5805 100644 --- a/app/code/core/Mage/Adminhtml/Block/Review/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Review/Edit/Form.php @@ -39,10 +39,6 @@ protected function _prepareForm() $review = Mage::registry('review_data'); $product = Mage::getModel('catalog/product')->load($review->getEntityPkValue()); $customer = Mage::getModel('customer/customer')->load($review->getCustomerId()); - $statuses = Mage::getModel('review/review') - ->getStatusCollection() - ->load() - ->toOptionArray(); $form = new Varien_Data_Form(array( 'id' => 'edit_form', @@ -89,7 +85,7 @@ protected function _prepareForm() 'label' => Mage::helper('review')->__('Status'), 'required' => true, 'name' => 'status_id', - 'values' => Mage::helper('review')->translateArray($statuses), + 'values' => Mage::helper('review')->getReviewStatusesOptionArray(), )); /** diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Grid.php b/app/code/core/Mage/Adminhtml/Block/Review/Grid.php index 811811080f8..d70e6d720a7 100644 --- a/app/code/core/Mage/Adminhtml/Block/Review/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Review/Grid.php @@ -76,18 +76,6 @@ protected function _prepareCollection() protected function _prepareColumns() { - $statuses = Mage::getModel('review/review') - ->getStatusCollection() - ->load() - ->toOptionArray(); - - $tmpArr = array(); - foreach( $statuses as $key => $status ) { - $tmpArr[$status['value']] = $status['label']; - } - - $statuses = $tmpArr; - $this->addColumn('review_id', array( 'header' => Mage::helper('review')->__('ID'), 'align' => 'right', @@ -110,7 +98,7 @@ protected function _prepareColumns() 'header' => Mage::helper('review')->__('Status'), 'align' => 'left', 'type' => 'options', - 'options' => $statuses, + 'options' => Mage::helper('review')->getReviewStatuses(), 'width' => '100px', 'filter_index' => 'rt.status_id', 'index' => 'status_id', @@ -232,10 +220,7 @@ protected function _prepareMassaction() 'confirm' => Mage::helper('review')->__('Are you sure?') )); - $statuses = Mage::getModel('review/review') - ->getStatusCollection() - ->load() - ->toOptionArray(); + $statuses = Mage::helper('review')->getReviewStatusesOptionArray(); array_unshift($statuses, array('label'=>'', 'value'=>'')); $this->getMassactionBlock()->addItem('update_status', array( 'label' => Mage::helper('review')->__('Update Status'), diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method/Form.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method/Form.php index f2986db4598..e8bc3faac1a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method/Form.php @@ -36,14 +36,12 @@ class Mage_Adminhtml_Block_Sales_Order_Create_Billing_Method_Form extends Mage_P /** * Check payment method model * + * @param Mage_Payment_Model_Method_Abstract|null $method * @return bool */ protected function _canUseMethod($method) { - if (!$method->canUseInternal()) { - return false; - } - return parent::_canUseMethod($method); + return $method && $method->canUseInternal() && parent::_canUseMethod($method); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Comment.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Comment.php index c570d12ee5b..7ca846e5bd0 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Comment.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Comment.php @@ -45,7 +45,7 @@ public function getHeaderText() public function getCommentNote() { - return $this->htmlEscape($this->getQuote()->getCustomerNote()); + return $this->escapeHtml($this->getQuote()->getCustomerNote()); } public function getNoteNotify() diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Address.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Address.php index b00f89d4a77..d0e820b2f80 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Address.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Address.php @@ -216,6 +216,6 @@ public function getAddressId() */ public function getAddressAsString($address) { - return $this->htmlEscape($address->format('oneline')); + return $this->escapeHtml($address->format('oneline')); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Header.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Header.php index ff2cbf72c0f..f36c028c6ae 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Header.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Header.php @@ -55,7 +55,7 @@ protected function _toHtml() else { $out.= Mage::helper('sales')->__('Create New Order'); } - $out = $this->htmlEscape($out); + $out = $this->escapeHtml($out); $out = '

' . $out . '

'; return $out; } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php index 73ac1e1a8a7..891ad449551 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php @@ -29,7 +29,7 @@ * * @category Mage * @package Mage_Adminhtml - * @author Magento Core Team + * @author Magento Core Team */ class Mage_Adminhtml_Block_Sales_Order_Create_Items_Grid extends Mage_Adminhtml_Block_Sales_Order_Create_Abstract { @@ -40,12 +40,20 @@ class Mage_Adminhtml_Block_Sales_Order_Create_Items_Grid extends Mage_Adminhtml_ */ protected $_moveToCustomerStorage = true; + /** + * Class constructor + */ public function __construct() { parent::__construct(); $this->setId('sales_order_create_search_grid'); } + /** + * Returns the items + * + * @return array + */ public function getItems() { $items = $this->getParentBlock()->getItems(); @@ -72,41 +80,69 @@ public function getItems() return $items; } + /** + * Returns the session + * + * @return Mage_Persistent_Helper_Session + */ public function getSession() { return $this->getParentBlock()->getSession(); } + /** + * Returns the item's calculation price + * + * @param Mage_Sales_Model_Quote_Item $item + * @return float + */ public function getItemEditablePrice($item) { - return $item->getCalculationPrice()*1; + return $item->getCalculationPrice() * 1; } + /** + * Returns the item's original editable price + * + * @param Mage_Sales_Model_Quote_Item $item + * @return float + */ public function getOriginalEditablePrice($item) { if ($item->hasOriginalCustomPrice()) { - $result = $item->getOriginalCustomPrice()*1; + $result = $item->getOriginalCustomPrice() * 1; } elseif ($item->hasCustomPrice()) { - $result = $item->getCustomPrice()*1; + $result = $item->getCustomPrice() * 1; } else { if (Mage::helper('tax')->priceIncludesTax($this->getStore())) { - $result = $item->getPriceInclTax()*1; + $result = $item->getPriceInclTax() * 1; } else { - $result = $item->getOriginalPrice()*1; + $result = $item->getOriginalPrice() * 1; } } return $result; } + /** + * Returns the item's original price + * + * @param Mage_Sales_Model_Quote_Item $item + * @return double + */ public function getItemOrigPrice($item) { -// return $this->convertPrice($item->getProduct()->getPrice()); return $this->convertPrice($item->getPrice()); } - public function isGiftMessagesAvailable($item=null) + /** + * Returns whether the item's gift message is available + * + * @param null|Mage_Sales_Model_Quote_Item $item + * @return bool + */ + public function isGiftMessagesAvailable($item = null) { - if(is_null($item)) { + if (is_null($item)) { return $this->helper('giftmessage/message')->getIsMessagesAvailable( 'items', $this->getQuote(), $this->getStore() ); @@ -117,6 +153,12 @@ public function isGiftMessagesAvailable($item=null) ); } + /** + * Returns whether the item is allowed for the gift message + * + * @param Mage_Sales_Model_Quote_Item $item + * @return bool + */ public function isAllowedForGiftMessage($item) { return Mage::getSingleton('adminhtml/giftmessage_save')->getIsAllowedQuoteItem($item); @@ -134,6 +176,11 @@ public function displayTotalsIncludeTax() return $res; } + /** + * Returns the subtotal + * + * @return float + */ public function getSubtotal() { $address = $this->getQuoteAddress(); @@ -148,23 +195,51 @@ public function getSubtotal() return false; } + /** + * Returns the subtotal with any discount removed + * + * @return float + */ public function getSubtotalWithDiscount() { $address = $this->getQuoteAddress(); if ($this->displayTotalsIncludeTax()) { - return $address->getSubtotal()+$address->getTaxAmount()+$this->getDiscountAmount(); + if ($this->getIsPriceInclTax()) { + return $address->getSubtotalInclTax() + $this->getDiscountAmount(); + } else { + return $address->getSubtotal() + $address->getTaxAmount() + $this->getDiscountAmount(); + } } else { - return $address->getSubtotal()+$this->getDiscountAmount(); + if ($this->getIsPriceInclTax()) { + return $address->getSubtotalInclTax() - $address->getTaxAmount() + $this->getDiscountAmount(); + } else { + return $address->getSubtotal() + $this->getDiscountAmount(); + } } } + /** + * Return whether the catalog prices include tax + * + * @return bool + */ + public function getIsPriceInclTax() + { + return Mage::getSingleton('tax/config')->priceIncludesTax($this->getStore()); + } + + /** + * Returns the discount amount + * + * @return float + */ public function getDiscountAmount() { return $this->getQuote()->getShippingAddress()->getDiscountAmount(); } /** - * Retrive quote address + * Retrieve quote address * * @return Mage_Sales_Model_Quote_Address */ @@ -200,13 +275,19 @@ public function canApplyCustomPrice($item) return !$item->isChildrenCalculated(); } + /** + * Returns the string that contains the 'quantity' title + * + * @param Mage_Sales_Model_Quote_Item $item + * @return string + */ public function getQtyTitle($item) { $prices = $item->getProduct()->getTierPrice(); if ($prices) { $info = array(); foreach ($prices as $data) { - $qty = $data['price_qty']*1; + $qty = $data['price_qty'] * 1; $price = $this->convertPrice($data['price']); $info[] = $this->helper('sales')->__('Buy %s for price %s', $qty, $price); } @@ -217,13 +298,19 @@ public function getQtyTitle($item) } } + /** + * Returns the HTML string for the tiered pricing + * + * @param Mage_Sales_Model_Quote_Item $item + * @return string + */ public function getTierHtml($item) { $html = ''; $prices = $item->getProduct()->getTierPrice(); if ($prices) { foreach ($prices as $data) { - $qty = $data['price_qty']*1; + $qty = $data['price_qty'] * 1; $price = $this->convertPrice($data['price']); $info[] = $this->helper('sales')->__('%s for %s', $qty, $price); } @@ -242,9 +329,11 @@ public function getCustomOptions(Mage_Sales_Model_Quote_Item $item) { $optionStr = ''; $this->_moveToCustomerStorage = true; - if ($optionIds = $item->getOptionByCode('option_ids')) { + $optionIds = $item->getOptionByCode('option_ids'); + if ($optionIds) { foreach (explode(',', $optionIds->getValue()) as $optionId) { - if ($option = $item->getProduct()->getOptionById($optionId)) { + $option = $item->getProduct()->getOptionById($optionId); + if ($option) { $optionValue = $item->getOptionByCode('option_' . $option->getId())->getValue(); $optionStr .= $option->getTitle() . ':'; @@ -272,6 +361,12 @@ public function getMoveToCustomerStorage() return $this->_moveToCustomerStorage; } + /** + * Returns the item's subtotal that includes tax + * + * @param Mage_Sales_Model_Quote_Item $item + * @return string + */ public function displaySubtotalInclTax($item) { if ($item->getTaxBeforeDiscount()) { @@ -282,21 +377,38 @@ public function displaySubtotalInclTax($item) return $this->formatPrice($item->getRowTotal() + $tax); } + /** + * Returns the item's original price that includes tax + * + * @param Mage_Sales_Model_Quote_Item $item + * @return double + */ public function displayOriginalPriceInclTax($item) { $tax = 0; if ($item->getTaxPercent()) { $tax = $item->getPrice() * ($item->getTaxPercent() / 100); } - return $this->convertPrice($item->getPrice()+($tax/$item->getQty())); + return $this->convertPrice($item->getPrice() + ($tax / $item->getQty())); } + /** + * Returns the item's row total with any discount and also with any tax + * + * @param Mage_Sales_Model_Quote_Item $item + * @return string + */ public function displayRowTotalWithDiscountInclTax($item) { $tax = ($item->getTaxAmount() ? $item->getTaxAmount() : 0); return $this->formatPrice($item->getRowTotal()-$item->getDiscountAmount()+$tax); } + /** + * Returns the text for the custom price (whether it includes or excludes tax) + * + * @return string + */ public function getInclExclTaxMessage() { if (Mage::helper('tax')->priceIncludesTax($this->getStore())) { @@ -306,6 +418,11 @@ public function getInclExclTaxMessage() } } + /** + * Returns the store + * + * @return Mage_Core_Model_Store + */ public function getStore() { return $this->getQuote()->getStore(); @@ -314,7 +431,7 @@ public function getStore() /** * Return html button which calls configure window * - * @param $item + * @param Mage_Sales_Model_Quote_Item $item * @return string */ public function getConfigureButtonHtml($item) diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Totals/Tax.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Totals/Tax.php index 3a209c65cc1..2419af171cd 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Totals/Tax.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Totals/Tax.php @@ -45,19 +45,22 @@ public function getFullTaxInfo() $taxClassAmount = array(); if ($source instanceof Mage_Sales_Model_Order) { - $taxClassAmount = Mage::helper('tax')->getCalculatedTaxes($source); - if (empty($taxClassAmount)) { - $rates = Mage::getModel('sales/order_tax')->getCollection()->loadByOrder($source)->toArray(); - $taxClassAmount = Mage::getSingleton('tax/calculation')->reproduceProcess($rates['items']); - } else { - $shippingTax = Mage::helper('tax')->getShippingTax($source); - $taxClassAmount = array_merge($shippingTax, $taxClassAmount); - } + $taxClassAmount = $this->_getTaxHelper()->getCalculatedTaxes($source); } return $taxClassAmount; } + /** + * Return Mage_Tax_Helper_Data instance + * + * @return Mage_Tax_Helper_Data + */ + protected function _getTaxHelper() + { + return Mage::helper('tax'); + } + /** * Display tax amount * diff --git a/app/code/core/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Link.php b/app/code/core/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Link.php index 2032329fc09..a45abe9a066 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Link.php +++ b/app/code/core/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Link.php @@ -42,7 +42,9 @@ class Mage_Adminhtml_Block_Sitemap_Grid_Renderer_Link extends Mage_Adminhtml_Blo public function render(Varien_Object $row) { $fileName = preg_replace('/^\//', '', $row->getSitemapPath() . $row->getSitemapFilename()); - $url = $this->htmlEscape(Mage::app()->getStore($row->getStoreId())->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . $fileName); + $url = $this->escapeHtml( + Mage::app()->getStore($row->getStoreId())->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . $fileName + ); if (file_exists(BP . DS . $fileName)) { return sprintf('%1$s', $url); diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field.php index c8aef7ef26f..8c359bbd1dd 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field.php @@ -118,9 +118,11 @@ public function render(Varien_Data_Form_Element_Abstract $element) // default value $html.= ''; - //$html.= ''; - $html.= ' '; - $html.= ''; + $html.= ' '; + $html.= ''; $html.= ''; } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Array/Abstract.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Array/Abstract.php index f3cfb39dda5..b42e3da2fc5 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Array/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Array/Abstract.php @@ -31,7 +31,8 @@ * @package Mage_Adminhtml * @author Magento Core Team */ -abstract class Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract extends Mage_Adminhtml_Block_System_Config_Form_Field +abstract class Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract + extends Mage_Adminhtml_Block_System_Config_Form_Field { /** * Grid columns @@ -145,7 +146,7 @@ public function getArrayRows() if ($element->getValue() && is_array($element->getValue())) { foreach ($element->getValue() as $rowId => $row) { foreach ($row as $key => $value) { - $row[$key] = $this->htmlEscape($value); + $row[$key] = $this->escapeHtml($value); } $row['_id'] = $rowId; $result[$rowId] = new Varien_Object($row); diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Select/Flatcatalog.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Select/Flatcatalog.php index c0e26de63b1..02b7ee2c49e 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Select/Flatcatalog.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Select/Flatcatalog.php @@ -32,12 +32,13 @@ * @package Mage_Adminhtml * @author Magento Core Team */ -class Mage_Adminhtml_Block_System_Config_Form_Field_Select_Flatcatalog extends Mage_Adminhtml_Block_System_Config_Form_Field +class Mage_Adminhtml_Block_System_Config_Form_Field_Select_Flatcatalog + extends Mage_Adminhtml_Block_System_Config_Form_Field { protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { - if (!Mage::helper('catalog/category_flat')->isRebuilt()) { - $element->setDisabled('disabled') + if (!Mage::helper('catalog/category_flat')->isBuilt()) { + $element->setDisabled(true) ->setValue(0); } return parent::_getElementHtml($element); diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit.php index 447ba3036d5..9f7d89728ba 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit.php @@ -58,7 +58,7 @@ public function getProfileId() public function getHeaderText() { if (Mage::registry('current_convert_profile')->getId()) { - return $this->htmlEscape(Mage::registry('current_convert_profile')->getName()); + return $this->escapeHtml(Mage::registry('current_convert_profile')->getName()); } else { return Mage::helper('adminhtml')->__('New Profile'); diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php index a74bd200980..86a3837001a 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php @@ -84,7 +84,7 @@ public function getValue($key, $default='', $defaultNew = null) } $value = $this->getData($key); - return $this->htmlEscape(strlen($value) > 0 ? $value : $default); + return $this->escapeHtml(strlen($value) > 0 ? $value : $default); } public function getSelected($key, $value) @@ -226,7 +226,9 @@ public function getStoreCollection() public function getShortDateFormat() { if (!$this->_shortDateFormat) { - $this->_shortDateFormat = Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); + $this->_shortDateFormat = Mage::app()->getLocale()->getDateStrFormat( + Mage_Core_Model_Locale::FORMAT_TYPE_SHORT + ); } return $this->_shortDateFormat; } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit.php index fc12b550dd8..8370b7706f2 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit.php @@ -58,7 +58,7 @@ public function getProfileId() public function getHeaderText() { if (Mage::registry('current_convert_profile')->getId()) { - return $this->htmlEscape(Mage::registry('current_convert_profile')->getName()); + return $this->escapeHtml(Mage::registry('current_convert_profile')->getName()); } else { return Mage::helper('adminhtml')->__('New Profile'); diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Delete.php b/app/code/core/Mage/Adminhtml/Block/System/Store/Delete.php index 75c9743648b..476404b3499 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Store/Delete.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Store/Delete.php @@ -67,8 +67,7 @@ public function __construct() */ public function getHeaderText() { - return Mage::helper('adminhtml')->__("Delete %s '%s'", $this->getStoreTypeTitle(), - $this->htmlEscape($this->getChild('form')->getDataObject()->getName())); + return Mage::helper('adminhtml')->__("Delete %s '%s'", $this->getStoreTypeTitle(), $this->escapeHtml($this->getChild('form')->getDataObject()->getName())); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php index f82065597d3..65263806362 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php @@ -98,7 +98,7 @@ public function getFormHtml() public function getHeaderText() { if ($this->getVariable()->getId()) { - return Mage::helper('adminhtml')->__('Custom Variable "%s"', $this->htmlEscape($this->getVariable()->getName())); + return Mage::helper('adminhtml')->__('Custom Variable "%s"', $this->escapeHtml($this->getVariable()->getName())); } else { return Mage::helper('adminhtml')->__('New Custom Variable'); diff --git a/app/code/core/Mage/Adminhtml/Block/Tag/Customer.php b/app/code/core/Mage/Adminhtml/Block/Tag/Customer.php index d57254688d6..cc9bf392692 100644 --- a/app/code/core/Mage/Adminhtml/Block/Tag/Customer.php +++ b/app/code/core/Mage/Adminhtml/Block/Tag/Customer.php @@ -62,7 +62,7 @@ public function __construct() $tagInfo = Mage::getModel('tag/tag') ->load(Mage::registry('tagId')); - $this->_headerText = Mage::helper('tag')->__("Customers Tagged '%s'", $this->htmlEscape($tagInfo->getName())); + $this->_headerText = Mage::helper('tag')->__("Customers Tagged '%s'", $this->escapeHtml($tagInfo->getName())); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php b/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php index 24526307e23..2dfbc968f08 100644 --- a/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php @@ -80,7 +80,7 @@ protected function _prepareLayout() public function getHeaderText() { if (Mage::registry('current_tag')->getId()) { - return Mage::helper('tag')->__("Edit Tag '%s'", $this->htmlEscape(Mage::registry('current_tag')->getName())); + return Mage::helper('tag')->__("Edit Tag '%s'", $this->escapeHtml(Mage::registry('current_tag')->getName())); } return Mage::helper('tag')->__('New Tag'); } diff --git a/app/code/core/Mage/Adminhtml/Block/Tag/Product.php b/app/code/core/Mage/Adminhtml/Block/Tag/Product.php index 31d27bb64ea..3908aceea26 100644 --- a/app/code/core/Mage/Adminhtml/Block/Tag/Product.php +++ b/app/code/core/Mage/Adminhtml/Block/Tag/Product.php @@ -60,7 +60,7 @@ public function __construct() $tagInfo = Mage::getModel('tag/tag') ->load(Mage::registry('tagId')); - $this->_headerText = Mage::helper('tag')->__("Products Tagged with '%s'", $this->htmlEscape($tagInfo->getName())); + $this->_headerText = Mage::helper('tag')->__("Products Tagged with '%s'", $this->escapeHtml($tagInfo->getName())); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Tag/Tag/Edit.php b/app/code/core/Mage/Adminhtml/Block/Tag/Tag/Edit.php index f3d12669f05..2ab0be30bf6 100644 --- a/app/code/core/Mage/Adminhtml/Block/Tag/Tag/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Tag/Tag/Edit.php @@ -90,7 +90,7 @@ public function getFormHtml() public function getHeaderText() { if (Mage::registry('tag_tag')->getId()) { - return Mage::helper('tag')->__("Edit Tag '%s'", $this->htmlEscape(Mage::registry('tag_tag')->getName())); + return Mage::helper('tag')->__("Edit Tag '%s'", $this->escapeHtml(Mage::registry('tag_tag')->getName())); } else { return Mage::helper('tag')->__('New Tag'); diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Class/Edit.php b/app/code/core/Mage/Adminhtml/Block/Tax/Class/Edit.php index 4555c276bfb..7005237a942 100644 --- a/app/code/core/Mage/Adminhtml/Block/Tax/Class/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Tax/Class/Edit.php @@ -48,7 +48,7 @@ public function __construct() public function getHeaderText() { if (Mage::registry('tax_class')->getId()) { - return Mage::helper('tax')->__("Edit Class '%s'", $this->htmlEscape(Mage::registry('tax_class')->getClassName())); + return Mage::helper('tax')->__("Edit Class '%s'", $this->escapeHtml(Mage::registry('tax_class')->getClassName())); } else { return Mage::helper('tax')->__('New Class'); diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Edit/Form.php index ba8b3c20d6d..7d622a111af 100644 --- a/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Edit/Form.php @@ -29,14 +29,12 @@ * * @category Mage * @package Mage_Adminhtml - * @author Magento Core Team + * @author Magento Core Team */ - class Mage_Adminhtml_Block_Tax_Rule_Edit_Form extends Mage_Adminhtml_Block_Widget_Form { /** * Init class - * */ public function __construct() { @@ -73,9 +71,12 @@ protected function _prepareForm() ->setClassTypeFilter(Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER) ->toOptionArray(); + /** + * Get rates array without memory leak + */ $rates = Mage::getModel('tax/calculation_rate') ->getCollection() - ->toOptionArray(); + ->getOptionRates(); $fieldset->addField('code', 'text', array( @@ -128,6 +129,15 @@ protected function _prepareForm() 'note' => Mage::helper('tax')->__('Tax rates at the same priority are added, others are compounded.'), ) ); + + $fieldset->addField('calculate_subtotal', 'checkbox', + array( + 'name' => 'calculate_subtotal', + 'label' => Mage::helper('tax')->__('Calculate off subtotal only'), + 'onclick' => 'this.value = this.checked ? 1 : 0;', + 'checked' => $model->getCalculateSubtotal() + ) + ); $fieldset->addField('position', 'text', array( 'name' => 'position', diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Grid.php b/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Grid.php index b33b4e888ca..61fec8d3798 100644 --- a/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Grid.php @@ -25,7 +25,9 @@ */ class Mage_Adminhtml_Block_Tax_Rule_Grid extends Mage_Adminhtml_Block_Widget_Grid { - + /** + * Set default value + */ public function __construct() { parent::__construct(); @@ -35,6 +37,11 @@ public function __construct() $this->setSaveParametersInSession(true); } + /** + * Prepare grid collection + * + * @return Mage_Adminhtml_Block_Tax_Rule_Grid + */ protected function _prepareCollection() { $collection = Mage::getModel('tax/calculation_rule') @@ -50,6 +57,12 @@ protected function _prepareCollection() return $this; } + /** + * Add filter + * + * @param Mage_Adminhtml_Block_Widget_Grid_Column $column + * @return Mage_Adminhtml_Block_Widget_Grid + */ protected function _addColumnFilterToCollection($column) { if ($this->getCollection()) { @@ -71,11 +84,16 @@ protected function _addColumnFilterToCollection($column) return parent::_addColumnFilterToCollection($column); } + /** + * Prepare grid columns + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ protected function _prepareColumns() { $this->addColumn('code', array( - 'header'=>Mage::helper('tax')->__('Name'), + 'header' => Mage::helper('tax')->__('Name'), 'align' =>'left', 'index' => 'code', 'filter_index' => 'code', @@ -84,27 +102,29 @@ protected function _prepareColumns() $this->addColumn('customer_tax_classes', array( - 'header'=>Mage::helper('tax')->__('Customer Tax Class'), + 'header' => Mage::helper('tax')->__('Customer Tax Class'), 'sortable' => false, 'align' =>'left', 'index' => 'customer_tax_classes', 'filter_index' => 'ctc.customer_tax_class_id', 'type' => 'options', 'show_missing_option_values' => true, - 'options' => Mage::getModel('tax/class')->getCollection()->setClassTypeFilter(Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER)->toOptionHash(), + 'options' => Mage::getModel('tax/class')->getCollection() + ->setClassTypeFilter(Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER)->toOptionHash(), ) ); $this->addColumn('product_tax_classes', array( - 'header'=>Mage::helper('tax')->__('Product Tax Class'), + 'header' => Mage::helper('tax')->__('Product Tax Class'), 'sortable' => false, 'align' =>'left', 'index' => 'product_tax_classes', 'filter_index' => 'ptc.product_tax_class_id', 'type' => 'options', 'show_missing_option_values' => true, - 'options' => Mage::getModel('tax/class')->getCollection()->setClassTypeFilter(Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT)->toOptionHash(), + 'options' => Mage::getModel('tax/class')->getCollection() + ->setClassTypeFilter(Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT)->toOptionHash(), ) ); @@ -123,15 +143,23 @@ protected function _prepareColumns() $this->addColumn('priority', array( - 'header'=>Mage::helper('tax')->__('Priority'), + 'header' => Mage::helper('tax')->__('Priority'), 'width' => '50px', 'index' => 'priority' ) ); + $this->addColumn('calculate_subtotal', + array( + 'header' => Mage::helper('tax')->__('Subtotal only'), + 'width' => '50px', + 'index' => 'calculate_subtotal' + ) + ); + $this->addColumn('position', array( - 'header'=>Mage::helper('tax')->__('Sort Order'), + 'header' => Mage::helper('tax')->__('Sort Order'), 'width' => '50px', 'index' => 'position' ) @@ -142,6 +170,12 @@ protected function _prepareColumns() return parent::_prepareColumns(); } + /** + * Return url + * + * @param Mage_Core_Model_Abstract $row + * @return string + */ public function getRowUrl($row) { return $this->getUrl('*/*/edit', array('rule' => $row->getId())); diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Link.php b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Link.php index 545566c608d..faac783c5f9 100644 --- a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Link.php +++ b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Link.php @@ -42,7 +42,7 @@ protected function _toHtml() { if ($this->getItem()) { return '

' . $this->getLabel() . ' ' - . $this->htmlEscape($this->getItem()->getName()) . '

'; + . $this->escapeHtml($this->getItem()->getName()) . '

'; } } } diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php index c5c38be9b0c..cea67d2193e 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php @@ -496,7 +496,7 @@ protected function _setCollectionOrder($column) /** * Prepare grid collection object * - * @return this + * @return Mage_Adminhtml_Block_Widget_Grid */ protected function _prepareCollection() { diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php index a25feddcd84..7f87c5178c5 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php @@ -32,7 +32,8 @@ * @author Magento Core Team * @todo date format */ -class Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Date extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract +class Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Date + extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract { protected $_locale; @@ -48,17 +49,24 @@ public function getHtml() { $htmlId = $this->_getHtmlId() . microtime(true); $format = $this->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); - $html = '
- ' . Mage::helper('adminhtml')->__('From').': - - -
'; - $html.= '
- ' . Mage::helper('adminhtml')->__('To').' : - - -
'; - $html.= ''; + $html = '
' + . '' . Mage::helper('adminhtml')->__('From').':' + . '' + . '' + . '
'; + $html.= '
' + . '' . Mage::helper('adminhtml')->__('To').' :' + . '' + . '' + . '
'; + $html.= ''; $html.= ' js_cssprototype/windows/themes/default.css - lib/prototype/windows/themes/magento.css + js_cssprototype/windows/themes/magento.css @@ -97,19 +98,20 @@ + + + + - - imagesaccordion_images themesaccordion_themes tabsaccordion_tabs - @@ -132,11 +134,15 @@ cache_sectionmobile_edit_tab_cache social_sectionmobile_edit_tab_social notification_sectionmobile_edit_tab_notification + + + + xmlconnect/dropdown.css xmlconnect/styles.css @@ -188,6 +194,7 @@ home + @@ -199,6 +206,7 @@ home + @@ -234,4 +242,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/design/adminhtml/default/default/template/bundle/product/edit/bundle.phtml b/app/design/adminhtml/default/default/template/bundle/product/edit/bundle.phtml index 9fdcb2ed8de..93054c5916b 100644 --- a/app/design/adminhtml/default/default/template/bundle/product/edit/bundle.phtml +++ b/app/design/adminhtml/default/default/template/bundle/product/edit/bundle.phtml @@ -71,6 +71,15 @@ $('product_bundle_container').select('input', 'select', 'textarea', 'button').ea } }); +Validation.add('validate-greater-zero-based-on-option', '__('Please enter a number greater 0 in this field.') ?>', function(v, el) { + var optionType = $(el).up('div.grid').previous('table.option-header').select('select.select-product-option-type')[0], + v = Number(v) || 0; + + if (optionType && (optionType.value == 'checkbox' || optionType.value == 'multi') && v <= 0) { + return false; + } + return true; +});
diff --git a/app/design/adminhtml/default/default/template/bundle/product/edit/bundle/option/selection.phtml b/app/design/adminhtml/default/default/template/bundle/product/edit/bundle/option/selection.phtml index 2928b455848..b722153fb9f 100644 --- a/app/design/adminhtml/default/default/template/bundle/product/edit/bundle/option/selection.phtml +++ b/app/design/adminhtml/default/default/template/bundle/product/edit/bundle/option/selection.phtml @@ -66,7 +66,7 @@ var bundleTemplateRow ='' + '' + - '' + + '' + 'getQtyTypeSelectHtml() ?>' + '' + '' + diff --git a/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/create/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/create/items/renderer.phtml index c854d4cbb53..c7ac4d20861 100644 --- a/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/create/items/renderer.phtml +++ b/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/create/items/renderer.phtml @@ -64,10 +64,10 @@ > getOrderItem()->getParentItem()): ?> -
htmlEscape($_item->getName()) ?>
+
escapeHtml($_item->getName()) ?>
helper('sales')->__('SKU') ?>: - ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?> + ', Mage::helper('catalog')->splitSku($this->escapeHtml($_item->getSku()))); ?>
@@ -397,7 +397,7 @@   - htmlEscape($_item->getDescription()) ?> + escapeHtml($_item->getDescription()) ?>     diff --git a/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/view/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/view/items/renderer.phtml index d1c8eddab9f..f6b334b0e35 100644 --- a/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/view/items/renderer.phtml +++ b/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/view/items/renderer.phtml @@ -62,10 +62,10 @@ > getOrderItem()->getParentItem()): ?> -
htmlEscape($_item->getName()) ?>
+
escapeHtml($_item->getName()) ?>
helper('sales')->__('SKU') ?>: - ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?> + ', Mage::helper('catalog')->splitSku($this->escapeHtml($_item->getSku()))); ?>
@@ -329,7 +329,7 @@ - htmlEscape($this->getItem()->getDescription()) ?> + escapeHtml($this->getItem()->getDescription()) ?>     diff --git a/app/design/adminhtml/default/default/template/bundle/sales/invoice/create/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/invoice/create/items/renderer.phtml index 7b8b2ef72f5..9860dbea3a9 100644 --- a/app/design/adminhtml/default/default/template/bundle/sales/invoice/create/items/renderer.phtml +++ b/app/design/adminhtml/default/default/template/bundle/sales/invoice/create/items/renderer.phtml @@ -63,10 +63,10 @@ > getOrderItem()->getParentItem()): ?> -
htmlEscape($_item->getName()) ?>
+
escapeHtml($_item->getName()) ?>
helper('sales')->__('SKU') ?>: - ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?> + ', Mage::helper('catalog')->splitSku($this->escapeHtml($_item->getSku()))); ?>
@@ -385,7 +385,7 @@   - htmlEscape($_item->getDescription()) ?> + escapeHtml($_item->getDescription()) ?>     diff --git a/app/design/adminhtml/default/default/template/bundle/sales/invoice/view/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/invoice/view/items/renderer.phtml index 942e164b86d..ce048052169 100644 --- a/app/design/adminhtml/default/default/template/bundle/sales/invoice/view/items/renderer.phtml +++ b/app/design/adminhtml/default/default/template/bundle/sales/invoice/view/items/renderer.phtml @@ -62,10 +62,10 @@ > getOrderItem()->getParentItem()): ?> -
htmlEscape($_item->getName()) ?>
+
escapeHtml($_item->getName()) ?>
helper('sales')->__('SKU') ?>: - ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?> + ', Mage::helper('catalog')->splitSku($this->escapeHtml($_item->getSku()))); ?>
getValueHtml($_item)?>
@@ -328,7 +328,7 @@ - htmlEscape($this->getItem()->getDescription()) ?> + escapeHtml($this->getItem()->getDescription()) ?>     diff --git a/app/design/adminhtml/default/default/template/bundle/sales/order/view/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/order/view/items/renderer.phtml index 08392a41176..d046e2ec3c9 100644 --- a/app/design/adminhtml/default/default/template/bundle/sales/order/view/items/renderer.phtml +++ b/app/design/adminhtml/default/default/template/bundle/sales/order/view/items/renderer.phtml @@ -67,11 +67,11 @@ getParentItem()): ?>
- htmlEscape($_item->getName()) ?> + escapeHtml($_item->getName()) ?>
helper('sales')->__('SKU') ?>: - ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?> + ', Mage::helper('catalog')->splitSku($this->escapeHtml($_item->getSku()))); ?>
@@ -400,7 +400,7 @@   - htmlEscape($_item->getDescription()) ?> + escapeHtml($_item->getDescription()) ?>     diff --git a/app/design/adminhtml/default/default/template/bundle/sales/shipment/create/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/shipment/create/items/renderer.phtml index 43ca313847a..754d5736c35 100644 --- a/app/design/adminhtml/default/default/template/bundle/sales/shipment/create/items/renderer.phtml +++ b/app/design/adminhtml/default/default/template/bundle/sales/shipment/create/items/renderer.phtml @@ -58,10 +58,10 @@ getOrderItem()->getParentItem()): ?> -
htmlEscape($_item->getName()) ?>
+
escapeHtml($_item->getName()) ?>
helper('sales')->__('SKU') ?>: - ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?> + ', Mage::helper('catalog')->splitSku($this->escapeHtml($_item->getSku()))); ?>
@@ -110,7 +110,7 @@   - htmlEscape($_item->getDescription()) ?> + escapeHtml($_item->getDescription()) ?>     diff --git a/app/design/adminhtml/default/default/template/bundle/sales/shipment/view/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/shipment/view/items/renderer.phtml index 68234fa4d20..5348e8927f5 100644 --- a/app/design/adminhtml/default/default/template/bundle/sales/shipment/view/items/renderer.phtml +++ b/app/design/adminhtml/default/default/template/bundle/sales/shipment/view/items/renderer.phtml @@ -59,10 +59,10 @@ > getParentItem()): ?> -
htmlEscape($_item->getName()) ?>
+
escapeHtml($_item->getName()) ?>
helper('sales')->__('SKU') ?>: - ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?> + ', Mage::helper('catalog')->splitSku($this->escapeHtml($_item->getSku()))); ?>
@@ -108,7 +108,7 @@ - htmlEscape($_item->getDescription()) ?> + escapeHtml($_item->getDescription()) ?>   diff --git a/app/design/adminhtml/default/default/template/catalog/category/edit/form.phtml b/app/design/adminhtml/default/default/template/catalog/category/edit/form.phtml index 6af041c5235..8d725603058 100644 --- a/app/design/adminhtml/default/default/template/catalog/category/edit/form.phtml +++ b/app/design/adminhtml/default/default/template/catalog/category/edit/form.phtml @@ -26,7 +26,7 @@ ?>
-

htmlEscape($this->getHeader()) . ($this->getCategoryId() ? ' (' . Mage::helper('catalog')->__('ID: %s', $this->getCategoryId()) . ')' : '') ?>

+

escapeHtml($this->getHeader()) . ($this->getCategoryId() ? ' (' . Mage::helper('catalog')->__('ID: %s', $this->getCategoryId()) . ')' : '') ?>

getResetButtonHtml() ?> getCategoryId()): ?> diff --git a/app/design/adminhtml/default/default/template/catalog/form/renderer/fieldset/element.phtml b/app/design/adminhtml/default/default/template/catalog/form/renderer/fieldset/element.phtml index e3305ad1cb2..934e6b0c1dc 100644 --- a/app/design/adminhtml/default/default/template/catalog/form/renderer/fieldset/element.phtml +++ b/app/design/adminhtml/default/default/template/catalog/form/renderer/fieldset/element.phtml @@ -31,6 +31,10 @@ ?> getElement() ?> checkFieldDisable() ?> +getToggleCode() ? $_element->getToggleCode() + : 'toggleValueElements(this, this.parentNode.parentNode)'; +?> getType()=='hidden'): ?> @@ -48,7 +52,7 @@ getScopeLabel() ?> canDisplayUseDefault()): ?> - getReadonly()):?> disabled="disabled" type="checkbox" name="use_default[]" id="getHtmlId() ?>_default"usedDefault()): ?> checked="checked" onclick="toggleValueElements(this, this.parentNode.parentNode)" value="getAttributeCode() ?>"/> + getReadonly()):?> disabled="disabled" type="checkbox" name="use_default[]" id="getHtmlId() ?>_default"usedDefault()): ?> checked="checked" onclick="" value="getAttributeCode() ?>"/> diff --git a/app/design/adminhtml/default/default/template/catalog/product/attribute/options.phtml b/app/design/adminhtml/default/default/template/catalog/product/attribute/options.phtml index 9d6abd958dd..5d50bcc689f 100644 --- a/app/design/adminhtml/default/default/template/catalog/product/attribute/options.phtml +++ b/app/design/adminhtml/default/default/template/catalog/product/attribute/options.phtml @@ -28,6 +28,7 @@ /** * Attribute options control * + * @deprecated after 1.7.0.2 The file is moved * @see Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options */ ?> @@ -57,7 +58,7 @@ getLabelValues() ?> getStores() as $_store): ?> - getReadOnly()):?> disabled="disabled"/> + getReadOnly()):?> disabled="disabled"/> diff --git a/app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml b/app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml index 08ea9dd23f7..b2bf7d44c0b 100644 --- a/app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml +++ b/app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml @@ -27,7 +27,7 @@

- + ' + ' style="display:none">' + '' + '' + '

htmlEscape($this->_getHeader()) ?>

escapeHtml($this->_getHeader()) ?>

getBackButtonHtml() ?> getResetButtonHtml() ?> diff --git a/app/design/adminhtml/default/default/template/catalog/product/composite/fieldset/options/type/file.phtml b/app/design/adminhtml/default/default/template/catalog/product/composite/fieldset/options/type/file.phtml index af12f083946..97c26e1eb4e 100644 --- a/app/design/adminhtml/default/default/template/catalog/product/composite/fieldset/options/type/file.phtml +++ b/app/design/adminhtml/default/default/template/catalog/product/composite/fieldset/options/type/file.phtml @@ -74,7 +74,7 @@ //]]> -
+
getFormatedPrice() ?>
decoratedIsLast){?> class="last"> diff --git a/app/design/adminhtml/default/default/template/catalog/product/edit/price/tier.phtml b/app/design/adminhtml/default/default/template/catalog/product/edit/price/tier.phtml index 23a7fcdbf7c..59a5a11f5b3 100644 --- a/app/design/adminhtml/default/default/template/catalog/product/edit/price/tier.phtml +++ b/app/design/adminhtml/default/default/template/catalog/product/edit/price/tier.phtml @@ -71,12 +71,12 @@ var tierPriceRowTemplate = '
' diff --git a/app/design/adminhtml/default/default/template/catalog/product/helper/gallery.phtml b/app/design/adminhtml/default/default/template/catalog/product/helper/gallery.phtml index a7640c83dc2..10db07f0cde 100644 --- a/app/design/adminhtml/default/default/template/catalog/product/helper/gallery.phtml +++ b/app/design/adminhtml/default/default/template/catalog/product/helper/gallery.phtml @@ -116,8 +116,8 @@ $_block = $this;
- - + + diff --git a/app/design/adminhtml/default/default/template/giftmessage/helper.phtml b/app/design/adminhtml/default/default/template/giftmessage/helper.phtml index af8c873b5a9..a2980de5756 100644 --- a/app/design/adminhtml/default/default/template/giftmessage/helper.phtml +++ b/app/design/adminhtml/default/default/template/giftmessage/helper.phtml @@ -55,11 +55,11 @@ getMessage()): ?> - htmlEscape($_giftMessage->getSender()) ?> + escapeHtml($_giftMessage->getSender()) ?> - htmlEscape($_giftMessage->getRecipient()) ?> + escapeHtml($_giftMessage->getRecipient()) ?> @@ -77,11 +77,11 @@ - htmlEscape($_giftMessage->getSender()) ?> + escapeHtml($_giftMessage->getSender()) ?> - htmlEscape($_giftMessage->getRecipient()) ?> + escapeHtml($_giftMessage->getRecipient()) ?> diff --git a/app/design/adminhtml/default/default/template/importexport/import/form/before.phtml b/app/design/adminhtml/default/default/template/importexport/import/form/before.phtml index c29b9aa9e82..80a5973c8a7 100644 --- a/app/design/adminhtml/default/default/template/importexport/import/form/before.phtml +++ b/app/design/adminhtml/default/default/template/importexport/import/form/before.phtml @@ -107,7 +107,14 @@ break; case 'innerHTML': case 'value': - $H(pair.value).each(function(val) {if ($(val.key)) $(val.key)[pair.key] = val.value;}); + $H(pair.value).each(function(val) { + var el = $(val.key); + if (el) { + el[pair.key] = val.value; + // if element does not visible + el.offsetWidth || el.up('div.entry-edit').show(); + } + }); break; case 'removeClassName': case 'addClassName': diff --git a/app/design/adminhtml/default/default/template/login.phtml b/app/design/adminhtml/default/default/template/login.phtml index aeecd052fbb..c3fddb6fbef 100644 --- a/app/design/adminhtml/default/default/template/login.phtml +++ b/app/design/adminhtml/default/default/template/login.phtml @@ -25,7 +25,7 @@ */ ?> - + <?php echo Mage::helper('adminhtml')->__('Log into Magento Admin Page') ?> @@ -47,7 +47,7 @@