Skip to content

Commit

Permalink
Merge pull request #20 from sexnothing/master
Browse files Browse the repository at this point in the history
Upgrade Bootstrap to 2.3.1 and Backbone to 1.0.0
  • Loading branch information
taiwen committed Apr 2, 2013
2 parents 82e6cd4 + 4021ac7 commit 5861c03
Show file tree
Hide file tree
Showing 21 changed files with 4,610 additions and 1,809 deletions.
49 changes: 48 additions & 1 deletion lib/Pi/File/Transfer/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,51 @@ public function getUploaded($name = null, $path = false)
}
return $result;
}
}

/**
* Get file(s) info
*
* @return array
*/
public function getInfo()
{
$ret = array();
$files = $this->getAdapter()->getFileList();
foreach ($files as $key => $data) {
$ret['name'] = $data['name'];
$ret['size'] = $data['size'];
$ret['type'] = $data['type'];
}
return $ret;
}

/**
* Get file size
*
* @return size number
*/
public function getSize()
{
return $this->getInfo()['size'];
}

/**
* Get file name
*
* @return file name
*/
public function getName()
{
return $this->getInfo()['name'];
}

/**
* Get file Type
*
* @return file Type
*/
public function getType()
{
return $this->getInfo()['type'];
}
}
92 changes: 92 additions & 0 deletions lib/Pi/Mvc/Controller/Plugin/Alias.php
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("&nbsp;","\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;
}
}
73 changes: 73 additions & 0 deletions lib/Pi/Mvc/Controller/Plugin/Meta.php
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("&nbsp;","\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;
}
}
Loading

0 comments on commit 5861c03

Please sign in to comment.