本文整理汇总了PHP中Sites::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Sites::model方法的具体用法?PHP Sites::model怎么用?PHP Sites::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sites
的用法示例。
在下文中一共展示了Sites::model方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeFind
public function beforeFind()
{
$attrs = $this->attributeLabels();
if ($this->tableName() != "sites") {
if (@$attrs['site_id']) {
$this->getDbCriteria()->mergeWith(array('alias' => 't', 'condition' => "t.site_id=" . (int) Sites::model()->getCurrentSite()->id));
}
}
//var_dump($this->dbCriteria);
parent::beforeFind();
}
示例2: init
public function init()
{
$site = Sites::model()->getCurrentSite();
//echo $site->theme;
Yii::app()->theme = $site->theme;
$this->site_id = $site->id;
Yii::import('application.extensions.sesmail.*');
require_once 'vendors/aws-sdk/sdk.class.php';
$this->ses = new YiiSesMail();
if (stristr($_SERVER['REQUEST_URI'], 'admin')) {
//if(!Yii::app()->user->isSuperUser) {
// $this->redirect("/");
// exit;
//}
$session = new CHttpSession();
$session->open();
$site_id = $session['site_id'];
// override the site_id (since switched)
if ($site_id) {
$this->site_id = $site_id;
}
$this->sites = CHtml::listData(Sites::model()->findAll(), 'id', 'name');
$this->admin = 1;
$this->layout = '//layouts/admin';
} else {
$this->isEditor = Yii::app()->user->checkAccess('admin');
$this->niches = Offers::model()->getNiches($this->site_id);
//$this->site_id = $site->getCurrentSite();
//Yii::import('application.extensions.sesmail.*');
//require_once('protected/extensions/sesmail/YiiSesMail.php');
//require_once('vendors/aws-sdk/sdk.class.php');
$session = new CHttpSession();
$session->open();
$seenOffer = $session['seenBackout'];
if ($seenOffer) {
$this->hideBackout = true;
}
Yii::import('application.modules.user.models.*');
$this->registration_model = new RegistrationForm();
$this->login_model = new UserLogin();
}
parent::init();
}
示例3: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Sites::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例4: search
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria = new CDbCriteria();
if (@$_GET['term']) {
//$this->title = CHtml::encode($_GET['term']);
$criteria->addSearchCondition('title', CHtml::encode($_GET['term']));
$criteria->addSearchCondition('slug', CHtml::encode($_GET['term']));
//$this->url = CHtml::encode($_GET['term']);
//$this->slug = CHtml::encode($_GET['term']);
}
$criteria->compare('site_id', (int) Sites::model()->getCurrentSite()->id);
$criteria->compare('id', $this->id);
$criteria->compare('title', $this->title, true);
$criteria->compare('description', $this->description, true);
$criteria->compare('featured', $this->featured);
$criteria->compare('taken_count', $this->taken_count);
$criteria->compare('taken_max', $this->taken_max);
$criteria->compare('slug', $this->slug, true);
$criteria->compare('url', $this->url, true);
$criteria->compare('our_price', $this->our_price, true);
$criteria->compare('regular_price', $this->regular_price, true);
$criteria->compare('valid_from', $this->valid_from, true);
$criteria->compare('valid_to', $this->valid_to, true);
$criteria->compare('created', $this->created, true);
$criteria->compare('updated', $this->updated, true);
return new CActiveDataProvider($this, array('criteria' => $criteria));
}
示例5: getAllSites
public function getAllSites()
{
$sites = CHtml::listData(Sites::model()->findAll(), 'id', 'name');
return $sites;
}
示例6: array
<?php
echo $form->errorSummary($model);
?>
<?php
echo $form->textFieldRow($model, 'name', array('class' => 'span5', 'maxlength' => 255));
?>
<?php
echo $form->label($model, 'site_id');
?>
<?php
echo $form->dropDownList($model, 'site_id', Sites::model()->getAllSites());
?>
<br />
<div class="form-actions">
<?php
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Create' : 'Save'));
?>
</div>
<?php
$this->endWidget();
?>
示例7: scopes
public function scopes()
{
return array('published' => array('condition' => 'published = 1'), 'currentSite' => array('condition' => 'site_id = :siteId', 'params' => array(':siteId' => (int) Sites::model()->getCurrentSite()->id)));
}