Yiiウィジェットクラスから派生した基本的なユーザープロファイルを表示する拡張機能があります。私の拡張機能は次のように定義されています。
class BasicProfile extends CWidget
{
public $user_id;
private $userinfo = array();
private $userdetail = array();
private $availibility = array();
private $availabletime = array();
private $usereducation = array();
private $userlanguages = array();
private $userlivingplace = array();
public function init()
{
$this->userinfo = $users = Users::model()->findByPk($this->user_id);
$this->userdetail = $users->profile;
$this->availibility = $users->user_availibility;
$this->availabletime = $users->user_availabletime;
$this->usereducation = $users->user_education;
$this->userlanguages = $users->user_languagues;
$this->userlivingplace = $users->user_livingplaces;
}
public function run() {
$this->getUserDetail();
}
public function getUserDetail(){
$basic = $this->userinfo;
$detail = $this->userdetail;
$availibility = $this->availibility;
$availabletime = $this->availabletime;
$usereducation = $this->usereducation;
$userlanguages = $this->userlanguages;
$userlivingplaces = $this->userlivingplace;
$age = getAge(strtotime($detail['date_of_birth']));
$is_smoker = isSmoker($detail['is_smoker']);
$education = '';
foreach ($usereducation as $ue)
{
$e = $ue->educ;
$education .= $e['edu_name']. ', ';
}
$education = substr($education, 0, -2);
$languages = '';
foreach ($userlanguages as $ul)
{
$l = $ul->lang;
$languages .= $l['language_title']. ', ';
}
$languages = substr($languages, 0, -2);
$condition = array('where_condition'=>'up.user_id=:id AND up.is_currently_own=:own', 'where_data'=>array(':id'=>(int)$this->user_id, ':own'=>'Yes'));
$user_pets = Users::model()->getUserPets($condition);
$profile_images = UserProfileImages::model()->getProfileImages( array('select'=>'all'), $this->user_id );
foreach( $profile_images as $profile_img ) {
$images[] = $profile_img->profile_image;
}
$image = '';
if( $images ){
$main_image = HTTP_HOST . PROFILE_IMAGES_THUMB . $images[0];
$image = '<img src="'. $main_image .'" />';
}
$address1 = $basic['address1'];
if($basic['address2'] != "")
$address1 .= ", ".$basic['address2'];
$address2 = $basic['city']." ".$basic['state'].", ". $basic['zip'];
$editprofile = url('/users/account');
$editimglink = url('/images/icons/Modify.png');
}
}
私の目標は、私の見解では、この拡張機能を次のように単純に呼び出すことです。
$this->widget('ext.UserProfile.BasicProfile',array('user_id'=>$user_id));
しかし、私の拡張機能が画像ローテーターをカプセル化するのに適切な場所であるかどうか疑問に思っていますか?ローテーターはエクステンションに含める必要がありますか、それともビューの一部として含める必要がありますか?一般的なJQuery画像ローテーターを使用する必要がありますか、それともYii Frameworkでうまく機能するものがありますか?