Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
51592f17
Commit
51592f17
authored
Dec 04, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed wrong refactoring of helpers
parent
26767735
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
46 deletions
+45
-46
create.php
extensions/gii/generators/crud/templates/views/create.php
+1
-1
update.php
extensions/gii/generators/crud/templates/views/update.php
+1
-1
BaseStringHelper.php
framework/yii/helpers/BaseStringHelper.php
+43
-44
No files found.
extensions/gii/generators/crud/templates/views/create.php
View file @
51592f17
...
...
@@ -19,7 +19,7 @@ use yii\helpers\Html;
*/
$this->title = 'Create
<?=
Inflector
::
camel2words
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
';
$this->params['breadcrumbs'][] = ['label' => '
<?=
Inflector
::
pluralize
(
Inflector
::
camel2words
(
BaseFile
Helper
::
basename
(
$generator
->
modelClass
)))
?>
', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => '
<?=
Inflector
::
pluralize
(
Inflector
::
camel2words
(
String
Helper
::
basename
(
$generator
->
modelClass
)))
?>
', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-create"
>
...
...
extensions/gii/generators/crud/templates/views/update.php
View file @
51592f17
...
...
@@ -21,7 +21,7 @@ use yii\helpers\Html;
*/
$this->title = 'Update
<?=
Inflector
::
camel2words
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
: ' . $model->
<?=
$generator
->
getNameAttribute
()
?>
;
$this->params['breadcrumbs'][] = ['label' => '
<?=
Inflector
::
pluralize
(
Inflector
::
camel2words
(
BaseFile
Helper
::
basename
(
$generator
->
modelClass
)))
?>
', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => '
<?=
Inflector
::
pluralize
(
Inflector
::
camel2words
(
String
Helper
::
basename
(
$generator
->
modelClass
)))
?>
', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->
<?=
$generator
->
getNameAttribute
()
?>
, 'url' => ['view',
<?=
$urlParams
?>
]];
$this->params['breadcrumbs'][] = 'Update';
?>
...
...
framework/yii/helpers/BaseStringHelper.php
View file @
51592f17
...
...
@@ -45,6 +45,49 @@ class BaseStringHelper
return
mb_substr
(
$string
,
$start
,
$length
,
'8bit'
);
}
/**
* Returns the trailing name component of a path.
* This method is similar to the php function `basename()` except that it will
* treat both \ and / as directory separators, independent of the operating system.
* This method was mainly created to work on php namespaces. When working with real
* file paths, php's `basename()` should work fine for you.
* Note: this method is not aware of the actual filesystem, or path components such as "..".
*
* @param string $path A path string.
* @param string $suffix If the name component ends in suffix this will also be cut off.
* @return string the trailing name component of the given path.
* @see http://www.php.net/manual/en/function.basename.php
*/
public
static
function
basename
(
$path
,
$suffix
=
''
)
{
if
((
$len
=
mb_strlen
(
$suffix
))
>
0
&&
mb_substr
(
$path
,
-
$len
)
==
$suffix
)
{
$path
=
mb_substr
(
$path
,
0
,
-
$len
);
}
$path
=
rtrim
(
str_replace
(
'\\'
,
'/'
,
$path
),
'/\\'
);
if
((
$pos
=
mb_strrpos
(
$path
,
'/'
))
!==
false
)
{
return
mb_substr
(
$path
,
$pos
+
1
);
}
return
$path
;
}
/**
* Returns parent directory's path.
* This method is similar to `dirname()` except that it will treat
* both \ and / as directory separators, independent of the operating system.
*
* @param string $path A path string.
* @return string the parent directory's path.
* @see http://www.php.net/manual/en/function.basename.php
*/
public
static
function
dirname
(
$path
)
{
$pos
=
mb_strrpos
(
str_replace
(
'\\'
,
'/'
,
$path
),
'/'
);
if
(
$pos
!==
false
)
{
return
mb_substr
(
$path
,
0
,
$pos
);
}
else
{
return
$path
;
}
}
/**
* Compares two strings or string arrays, and return their differences.
...
...
@@ -94,48 +137,4 @@ class BaseStringHelper
$diff
=
new
\Diff
(
$lines1
,
$lines2
);
return
$diff
->
render
(
$renderer
);
}
/**
* Returns the trailing name component of a path.
* This method is similar to the php function `basename()` except that it will
* treat both \ and / as directory separators, independent of the operating system.
* This method was mainly created to work on php namespaces. When working with real
* file paths, php's `basename()` should work fine for you.
* Note: this method is not aware of the actual filesystem, or path components such as "..".
*
* @param string $path A path string.
* @param string $suffix If the name component ends in suffix this will also be cut off.
* @return string the trailing name component of the given path.
* @see http://www.php.net/manual/en/function.basename.php
*/
public
static
function
basename
(
$path
,
$suffix
=
''
)
{
if
((
$len
=
mb_strlen
(
$suffix
))
>
0
&&
mb_substr
(
$path
,
-
$len
)
==
$suffix
)
{
$path
=
mb_substr
(
$path
,
0
,
-
$len
);
}
$path
=
rtrim
(
str_replace
(
'\\'
,
'/'
,
$path
),
'/\\'
);
if
((
$pos
=
mb_strrpos
(
$path
,
'/'
))
!==
false
)
{
return
mb_substr
(
$path
,
$pos
+
1
);
}
return
$path
;
}
/**
* Returns parent directory's path.
* This method is similar to `dirname()` except that it will treat
* both \ and / as directory separators, independent of the operating system.
*
* @param string $path A path string.
* @return string the parent directory's path.
* @see http://www.php.net/manual/en/function.basename.php
*/
public
static
function
dirname
(
$path
)
{
$pos
=
mb_strrpos
(
str_replace
(
'\\'
,
'/'
,
$path
),
'/'
);
if
(
$pos
!==
false
)
{
return
mb_substr
(
$path
,
0
,
$pos
);
}
else
{
return
$path
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment