Skip to content

Commit

Permalink
Import Magento Release 1.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Magento Mirror committed Jan 17, 2009
1 parent 3fed190 commit 6bfe398
Show file tree
Hide file tree
Showing 38 changed files with 645 additions and 540 deletions.
2 changes: 1 addition & 1 deletion app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ final class Mage {

public static function getVersion()
{
return '1.1.5';
return '1.1.6';
}

/**
Expand Down
39 changes: 38 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,45 @@ public function getRootIds()
return $ids;
}

protected function _getNodeJson($node, $level=0)
/**
* Get JSON of array of categories, that are breadcrumbs for specified category path
*
* @param string $path
* @param string $javascriptVarName
* @return string
*/
public function getBreadcrumbsJavascript($path, $javascriptVarName)
{
if (empty($path)) {
return '';
}
$categories = Mage::getResourceSingleton('catalog/category_tree')->loadBreadcrumbsArray($path);
if (empty($categories)) {
return '';
}
foreach ($categories as $key => $category) {
$categories[$key] = $this->_getNodeJson($category);
}
return
'<script type="text/javascript">'
. $javascriptVarName . ' = ' . Zend_Json::encode($categories) . ';'
. '</script>';
}

/**
* Get JSON of a tree node or an associative array
*
* @param Varien_Data_Tree_Node|array $node
* @param int $level
* @return string
*/
protected function _getNodeJson($node, $level = 0)
{
// create a node from data array
if (is_array($node)) {
$node = new Varien_Data_Tree_Node($node, 'entity_id', new Varien_Data_Tree);
}

$item = array();
$item['text']= $this->htmlEscape($node->getName());

Expand Down
15 changes: 2 additions & 13 deletions app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ protected function _beforeToHtml()
'index'=>'type',
'type' => 'options',
'options' => array(
'c' => Mage::helper('customer')->__('Customer'),
'v' => Mage::helper('customer')->__('Visitor'),
Mage_Log_Model_Visitor::VISITOR_TYPE_CUSTOMER => Mage::helper('customer')->__('Customer'),
Mage_Log_Model_Visitor::VISITOR_TYPE_VISITOR => Mage::helper('customer')->__('Visitor'),
),
'renderer'=>'adminhtml/customer_online_grid_renderer_type',
));
Expand All @@ -146,15 +146,4 @@ public function getRowUrl($row)
{
return ( intval($row->getCustomerId()) > 0 ) ? $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId())) : '';
}

protected function _addColumnFilterToCollection($column)
{
if($column->getId()=='type') {
$this->getCollection()->addFieldToFilter($column->getIndex(), $column->getFilter()->getValue());
} else {
$this->getCollection()->addFieldToFilter($column->getIndex(), $column->getFilter()->getCondition());
}
return $this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
* @package Mage_Adminhtml
* @author Magento Core Team <[email protected]>
*/
class Mage_Adminhtml_Block_Extensions_Custom_Edit_Tab_Grid
extends Mage_Adminhtml_Block_Widget_Grid
class Mage_Adminhtml_Block_Extensions_Custom_Edit_Tab_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
protected $_defaultLimit = 200;

public function __construct()
{
parent::__construct();
Expand Down Expand Up @@ -68,9 +69,6 @@ public function getCurrentUrl($params=array())

public function getRowUrl($row)
{
return $this->getUrl('*/*/load', array(
'id' => $row->getFilenameId(),
));
return $this->getUrl('*/*/load') . '?id=' . urlencode($row->getFilenameId());
}

}
102 changes: 0 additions & 102 deletions app/code/core/Mage/Adminhtml/Helper/Dashboard/Visitor.php

This file was deleted.

16 changes: 15 additions & 1 deletion app/code/core/Mage/Adminhtml/Model/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ public function savePackage()
$fileName = $this->getName();
}

if (!preg_match('/^[a-z0-9]+[a-z0-9\-\_\.]*(\/[a-z0-9]+[a-z0-9\-\_\.]*)*$/i', $fileName)) {
return false;
}

if (!$this->getPackageXml()) {
$this->generatePackageXml();
}
Expand All @@ -285,7 +289,17 @@ public function savePackage()
$this->unsRoles();
$xml = Mage::helper('core')->assocToXml($this->getData());

if (!@file_put_contents($dir.DS.$fileName.'.xml', $xml->asXML())) {
// prepare dir to save
$parts = explode('/', $fileName);
array_pop($parts);
$newDir = implode(DS, $parts);
if ((!empty($newDir)) && (!is_dir($dir . DS . $newDir))) {
if (!@mkdir($dir . DS . $newDir, 0777, true)) {
return false;
}
}

if (!@file_put_contents($dir . DS . $fileName . '.xml', $xml->asXML())) {
return false;
}

Expand Down
108 changes: 95 additions & 13 deletions app/code/core/Mage/Adminhtml/Model/Extension/Collection.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,105 @@
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Extension packages files collection
*
*/
class Mage_Adminhtml_Model_Extension_Collection extends Mage_Adminhtml_Model_Extension_Collection_Abstract
{
public static $allowDirs = '/^[a-z0-9\.\-]+$/i';
public static $allowFiles = '/^[a-z0-9\.\-\_]+\.(xml|ser)$/i';
public static $disallowFiles = '/^package\.xml$/i';

/**
* Get all packages identifiers
*
* @return array
*/
protected function _fetchPackages()
{
$_files = @glob(Mage::getBaseDir('var') . DS . 'pear' . DS . '{*\.ser,*\.xml}', GLOB_BRACE);
$_items = array();
foreach ($_files as $_file) {
$_file = str_replace(Mage::getBaseDir('var') . DS . 'pear' . DS, '', $_file);
if ($_file == 'package.xml') {
continue;
}
$_file = preg_replace('/\.ser|\.xml/', '', $_file);
$_items[] = array(
'filename' => $_file,
'filename_id' => $_file
$baseDir = Mage::getBaseDir('var') . DS . 'pear';
$files = array();
$this->_collectRecursive($baseDir, $files);
$result = array();
foreach ($files as $file) {
$file = preg_replace(array('/^' . preg_quote($baseDir . DS, '/') . '/', '/\.(xml|ser)$/'), '', $file);
$result[] = array(
'filename' => $file,
'filename_id' => $file
);
}
return $result;
}

return $_items;
/**
* Get package files from directory recursively
*
* @param string $dir
* @param array &$result
* @param bool $dirsFirst
*/
protected function _collectRecursive($dir, &$result, $dirsFirst = true)
{
$_result = glob($dir . DS . '*');
if (!$dirsFirst) {
// collect all the stuff recursively
foreach ($_result as $item) {
if (is_dir($item) && preg_match(self::$allowDirs, basename($item))) {
$this->_collectRecursive($item, $result, $dirsFirst);
}
elseif (is_file($item)
&& preg_match(self::$allowFiles, basename($item))
&& !preg_match(self::$disallowFiles, basename($item))) {
$result[] = $item;
}
}
}
else {
// collect directories first
$dirs = array();
$files = array();
foreach ($_result as $item) {
if (is_dir($item) && preg_match(self::$allowDirs, basename($item))) {
$dirs[] = $item;
}
elseif (is_file($item)
&& preg_match(self::$allowFiles, basename($item))
&& !preg_match(self::$disallowFiles, basename($item))) {
$files[] = $item;
}
}
// search directories recursively
foreach ($dirs as $item) {
$this->_collectRecursive($item, $result, $dirsFirst);
}
// add files
foreach ($files as $item) {
$result[] = $item;
}
}
}
}
}
Loading

0 comments on commit 6bfe398

Please sign in to comment.