forked from pi-engine/pi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from sexnothing/master
Upgrade Bootstrap to 2.3.1 and Backbone to 1.0.0
- Loading branch information
Showing
21 changed files
with
4,610 additions
and
1,809 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
/** | ||
* Controller plugin Alias class | ||
* | ||
* You may not change or alter any portion of this comment or credits | ||
* of supporting developers from this source code or any supporting source code | ||
* which is considered copyrighted (c) material of the original comment or credit authors. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* | ||
* @copyright Copyright (c) Pi Engine http://www.xoopsengine.org | ||
* @license http://www.xoopsengine.org/license New BSD License | ||
* @author Hossein Azizabadi <[email protected]> | ||
* @since 3.0 | ||
* @package Pi\Mvc | ||
* @version $Id$ | ||
*/ | ||
|
||
namespace Pi\Mvc\Controller\Plugin; | ||
|
||
use Pi; | ||
use Zend\Mvc\Controller\Plugin\AbstractPlugin; | ||
use Zend\Mvc\MvcEvent; | ||
|
||
class Alias extends AbstractPlugin | ||
{ | ||
public $_search = array(" ","\t","\r\n","\r","\n",",",".","'",";",":",")", | ||
"(",'"','?','!','{','}','[',']','<','>','/','+','-','_', | ||
'\\','*','=','@','#','$','%','^','&'); | ||
public $_replace = array(' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', | ||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', | ||
' ',' ',' ',' ',' ',''); | ||
|
||
/* | ||
* $this->alias($alias); | ||
*/ | ||
public function __invoke($alias, $id, $model) | ||
{ | ||
$alias = $this->setAlias($alias); | ||
$alias = $this->checkAlias($alias, $id, $model); | ||
return $alias; | ||
} | ||
|
||
/** | ||
* Returns the alias | ||
* | ||
* @return boolean | ||
*/ | ||
public function setAlias($alias) | ||
{ | ||
$alias = strip_tags($alias); | ||
$alias = strtolower($alias); | ||
$alias = htmlentities($alias, ENT_COMPAT, 'utf-8'); | ||
$alias = preg_replace('`\[.*\]`U', ' ', $alias); | ||
$alias = preg_replace('`&(amp;)?#?[a-z0-9]+;`i', ' ', $alias); | ||
$alias = preg_replace('`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig);`i', '\\1', $alias); | ||
$alias = str_replace($this->_search, $this->_replace, $alias); | ||
$alias = explode(' ',$alias); | ||
foreach($alias as $word) { | ||
if(!empty($word)) { | ||
$key[] = $word; | ||
} | ||
} | ||
$alias = implode('-',$key); | ||
return $alias; | ||
} | ||
|
||
/** | ||
* Check alias exit ot not | ||
* | ||
* @return boolean | ||
*/ | ||
public function checkAlias($alias, $id, $model) | ||
{ | ||
if (empty($id)) { | ||
$select = $model->select()->columns(array('id', 'alias'))->where(array('alias' => $alias)); | ||
} else { | ||
$select = $model->select()->columns(array('id', 'alias'))->where(array('alias' => $alias, 'id != ?' => $id)); | ||
} | ||
$rowset = $model->selectWith($select); | ||
if($rowset->count()) { | ||
/* | ||
* This part need improvment | ||
* replace rand function whit method for add number | ||
*/ | ||
$alias = $this->setAlias($alias . ' ' . rand(1, 9999)); | ||
$alias = $this->checkAlias($alias, $id, $model); | ||
} | ||
return $alias; | ||
} | ||
} |
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,73 @@ | ||
<?php | ||
/** | ||
* Controller plugin Meta class | ||
* | ||
* You may not change or alter any portion of this comment or credits | ||
* of supporting developers from this source code or any supporting source code | ||
* which is considered copyrighted (c) material of the original comment or credit authors. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* | ||
* @copyright Copyright (c) Pi Engine http://www.xoopsengine.org | ||
* @license http://www.xoopsengine.org/license New BSD License | ||
* @author Hossein Azizabadi <[email protected]> | ||
* @since 3.0 | ||
* @package Pi\Mvc | ||
* @version $Id$ | ||
*/ | ||
|
||
namespace Pi\Mvc\Controller\Plugin; | ||
|
||
use Zend\Mvc\Controller\Plugin\AbstractPlugin; | ||
|
||
class Meta extends AbstractPlugin | ||
{ | ||
public $_search = array(" ","\t","\r\n","\r","\n",",",".","'",";",":",")", | ||
"(",'"','?','!','{','}','[',']','<','>','/','+','-','_', | ||
'\\','*','=','@','#','$','%','^','&'); | ||
public $_replace = array(' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', | ||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', | ||
' ',' ',' ',' ',' ',''); | ||
|
||
/* | ||
* $this->meta()->keywords($keywords); | ||
* $this->meta()->keywords($keywords, $number, $limit); | ||
*/ | ||
public function keywords($keywords, $number = '6', $limit = '3') | ||
{ | ||
$keywords = strip_tags($keywords); | ||
$keywords = strtolower($keywords); | ||
$keywords = htmlentities($keywords, ENT_COMPAT, 'utf-8'); | ||
$keywords = preg_replace('`\[.*\]`U', '', $keywords); | ||
$keywords = preg_replace('`&(amp;)?#?[a-z0-9]+;`i', '', $keywords); | ||
$keywords = preg_replace('`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig);`i', '\\1', $keywords); | ||
$keywords = str_replace($this->_search, $this->_replace, $keywords); | ||
$keywords = explode(' ',$keywords); | ||
$keywords = array_unique($keywords); | ||
foreach($keywords as $keyword) { | ||
if(mb_strlen($keyword) >= $limit && !empty($keyword) && !is_numeric($keyword)) { | ||
$key[] = $keyword; | ||
} | ||
} | ||
$key = array_slice($key, 0, $number); | ||
$keywords = implode(',',$key); | ||
$keywords = trim($keywords, ','); | ||
return $keywords; | ||
} | ||
|
||
/* | ||
* $this->meta()->description($description); | ||
*/ | ||
public function description($description) | ||
{ | ||
$description = strip_tags($description); | ||
$description = strtolower($description); | ||
$description = htmlentities($description, ENT_COMPAT, 'utf-8'); | ||
$description = preg_replace('`\[.*\]`U', '', $description); | ||
$description = preg_replace('`&(amp;)?#?[a-z0-9]+;`i', '-', $description); | ||
$description = preg_replace('`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig);`i', '\\1', $description); | ||
$description = str_replace($this->_search, $this->_replace, $description); | ||
return $description; | ||
} | ||
} |
Oops, something went wrong.