-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
320 additions
and
242 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
namespace yii\easyii\components; | ||
|
||
use Yii; | ||
use yii\easyii\helpers\GD; | ||
use yii\easyii\helpers\Image; | ||
use yii\easyii\helpers\Upload; | ||
use yii\helpers\FileHelper; | ||
use yii\widgets\LinkPager; | ||
|
||
class ApiObject extends \yii\base\Object | ||
{ | ||
public $source = []; | ||
public $adp; | ||
private $_seo; | ||
|
||
public function __construct($model){ | ||
if(isset($model->seo)){ | ||
$this->_seo = $model->seo; | ||
} | ||
|
||
foreach($model->attributes as $attribute => $value){ | ||
if($this->canSetProperty($attribute)){ | ||
$this->{$attribute} = $value; | ||
} else { | ||
$this->source[$attribute] = $value; | ||
} | ||
} | ||
} | ||
|
||
public function thumb($width = null, $height = null, $crop = true) | ||
{ | ||
if($this->image && ($width || $height)){ | ||
return Image::thumb(Yii::getAlias('@webroot') . $this->image, $width, $height, $crop); | ||
} | ||
return ''; | ||
} | ||
|
||
public function getPages(){ | ||
return $this->adp ? LinkPager::widget(['pagination' => $this->adp->pagination]) : ''; | ||
} | ||
|
||
public function seo($attribute){ | ||
return (!empty($this->_seo) && isset($this->_seo->{$attribute})) ? $this->_seo->{$attribute} : ''; | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
namespace yii\easyii\components; | ||
|
||
use creocoder\nestedsets\NestedSetsQueryBehavior; | ||
|
||
class NSActiveQuery extends ActiveQuery | ||
{ | ||
public function behaviors() { | ||
return [ | ||
NestedSetsQueryBehavior::className(), | ||
]; | ||
} | ||
|
||
public function sort() | ||
{ | ||
$this->orderBy('order_num DESC, lft ASC'); | ||
return $this; | ||
} | ||
} |
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,10 @@ | ||
<?php | ||
namespace yii\easyii\components; | ||
|
||
class NSActiveRecord extends ActiveRecord | ||
{ | ||
public static function find() | ||
{ | ||
return new NSActiveQuery(get_called_class()); | ||
} | ||
} |
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
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
Oops, something went wrong.