-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
verschiedene Filter hinzugefügt, andere AddOns können Filter via EP b…
…ereitstellen
- Loading branch information
Showing
13 changed files
with
356 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Sprog package. | ||
* | ||
* @author (c) Thomas Blum <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sprog\Filter; | ||
|
||
use Sprog\Filter; | ||
|
||
class Format extends Filter | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function name() | ||
{ | ||
return 'format'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fire($value, $arguments) | ||
{ | ||
if ($arguments == '') { | ||
return $value; | ||
} | ||
|
||
return vsprintf($value, explode(',', $arguments)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Sprog package. | ||
* | ||
* @author (c) Thomas Blum <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sprog\Filter; | ||
|
||
use Sprog\Filter; | ||
|
||
class Limit extends Filter | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function name() | ||
{ | ||
return 'limit'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fire($value, $arguments) | ||
{ | ||
if ($arguments == '') { | ||
return $value; | ||
} | ||
|
||
$parts = explode(',', $arguments); | ||
$limit = (int)$parts[0]; | ||
$end = isset($parts[1]) ? $parts[1] : ''; | ||
|
||
if (mb_strwidth($value, 'UTF-8') <= $limit) { | ||
return $value; | ||
} | ||
return rtrim(mb_strimwidth($value, 0, $limit, '', 'UTF-8')) . $end; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Sprog package. | ||
* | ||
* @author (c) Thomas Blum <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sprog\Filter; | ||
|
||
use Sprog\Filter; | ||
|
||
class Lower extends Filter | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function name() | ||
{ | ||
return 'lower'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fire($value, $arguments) | ||
{ | ||
return mb_strtolower($value, 'UTF-8'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Sprog package. | ||
* | ||
* @author (c) Thomas Blum <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sprog\Filter; | ||
|
||
use Sprog\Filter; | ||
|
||
class Markdown extends Filter | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function name() | ||
{ | ||
return 'markdown'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fire($value, $arguments) | ||
{ | ||
return \rex_markdown::factory()->parse($value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Sprog package. | ||
* | ||
* @author (c) Thomas Blum <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sprog\Filter; | ||
|
||
use Sprog\Filter; | ||
|
||
class Raw extends Filter | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function name() | ||
{ | ||
return 'raw'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fire($value, $arguments) | ||
{ | ||
return $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Sprog package. | ||
* | ||
* @author (c) Thomas Blum <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sprog\Filter; | ||
|
||
use Sprog\Filter; | ||
|
||
class Title extends Filter | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function name() | ||
{ | ||
return 'title'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fire($value, $arguments) | ||
{ | ||
return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Sprog package. | ||
* | ||
* @author (c) Thomas Blum <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sprog\Filter; | ||
|
||
use Sprog\Filter; | ||
|
||
class Upper extends Filter | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function name() | ||
{ | ||
return 'upper'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fire($value, $arguments) | ||
{ | ||
return mb_strtoupper($value, 'UTF-8'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Sprog package. | ||
* | ||
* @author (c) Thomas Blum <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sprog\Filter; | ||
|
||
use Sprog\Filter; | ||
|
||
class Words extends Filter | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function name() | ||
{ | ||
return 'words'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fire($value, $arguments) | ||
{ | ||
if ($arguments == '') { | ||
return $value; | ||
} | ||
|
||
$parts = explode(',', $arguments); | ||
$words = (int)$parts[0]; | ||
$end = isset($parts[1]) ? $parts[1] : ''; | ||
|
||
preg_match('/^\s*+(?:\S++\s*+){1,' . $words . '}/u', $value, $matches); | ||
if (!isset($matches[0]) || mb_strlen($value) === mb_strlen($matches[0])) { | ||
return $value; | ||
} | ||
return rtrim($matches[0]) . $end; | ||
} | ||
} |
Oops, something went wrong.