本文整理汇总了PHP中Url::getPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::getPrimaryKey方法的具体用法?PHP Url::getPrimaryKey怎么用?PHP Url::getPrimaryKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Url
的用法示例。
在下文中一共展示了Url::getPrimaryKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAjaxUpload
/**
* Method to handle file upload thought XHR2
* On success returns JSON object with image info.
* @param $album_foto_id string Gallery Id to upload images
* @throws CHttpException
*/
public function actionAjaxUpload($album_foto_id = null)
{
$album_foto = AlbumFoto::model()->findByPk($album_foto_id);
$imageFile = CUploadedFile::getInstanceByName('image');
$time = time() + rand();
$base = Yii::getPathOfAlias('webroot') . '/' . $this->galleryDir . '/' . $album_foto->directorio;
$src = $time . '.' . $this->galleryExt;
$thumb = $time . '_thumb.' . $this->galleryExt;
$image = new Image($imageFile->getTempName());
$image->save($base . $src);
$image_thumb = new Image($imageFile->getTempName());
$image_thumb->resize(300, null);
$image_thumb->save($base . $thumb);
//Yii::app()->image->load($imageFile->getTempName())->save($src);
//Yii::app()->image->load($imageFile->getTempName())->resize(300, null)->save($thumb);
$model = new Foto();
$model->album_foto_id = $album_foto_id;
$url = new Url();
$slug = '#imagenes/' . $this->slugger($album_foto->nombre) . '/' . $this->slugger($time);
$slug = $this->verificarSlug($slug);
$url->slug = $slug;
$url->tipo_id = 6;
//Foto
$url->estado = 1;
$url->save();
$model->url_id = $url->getPrimaryKey();
$model->src = $src;
$model->thumb = $thumb;
$model->nombre = $time;
$model->descripcion = '';
$model->ancho = $image->width;
$model->alto = $image->height;
$model->orden = 0;
$model->estado = 1;
$model->destacado = 0;
$model->save();
header("Content-Type: application/json");
echo CJSON::encode(array('id' => $model->id, 'rank' => $model->orden, 'name' => (string) $model->nombre, 'description' => (string) $model->descripcion, 'preview' => bu($this->galleryDir . '/' . $album_foto->directorio . $thumb)));
}
示例2: beforeSave
protected function beforeSave()
{
if (parent::beforeSave()) {
if ($this->isNewRecord) {
$url = new Url();
$slug = '#imagenes/' . $this->slugger($this->nombre);
$slug = $this->verificarSlug($slug);
$url->slug = $slug;
$url->tipo_id = 5;
//Álbum de fotos
$url->estado = 1;
$url->save();
$this->url_id = $url->getPrimaryKey();
$this->creado = date('Y-m-d H:i:s');
} else {
$this->modificado = date('Y-m-d H:i:s');
}
return true;
} else {
return false;
}
}
示例3: beforeSave
protected function beforeSave()
{
if ($this->isNewRecord) {
$album_video = AlbumVideo::model()->findByPk($this->album_video_id);
$url = new Url();
$slug = '#videos/' . $this->slugger($album_video->nombre) . '/' . $this->slugger($this->nombre);
$slug = $this->verificarSlug($slug);
$url->slug = $slug;
$url->tipo_id = 9;
//Video
$url->estado = 1;
if ($url->save()) {
$this->url_id = $url->getPrimaryKey();
} else {
return false;
}
$this->creado = date('Y-m-d H:i:s');
} else {
$this->modificado = date('Y-m-d H:i:s');
}
return parent::beforeSave();
}
示例4: beforeSave
protected function beforeSave()
{
if ($this->isNewRecord) {
$micrositio = Micrositio::model()->findByPk($this->micrositio_id);
$url = new Url();
if ($micrositio->seccion->nombre == 'sin-seccion') {
$slug = $this->slugger($micrositio->nombre) . '/' . $this->slugger($this->nombre);
} else {
$slug = $this->slugger($micrositio->seccion->nombre) . '/' . $this->slugger($micrositio->nombre) . '/' . $this->slugger($this->nombre);
}
$slug = $this->verificarSlug($slug);
$url->slug = $slug;
$url->tipo_id = 3;
//Página
$url->estado = 1;
if ($url->save()) {
$this->url_id = $url->getPrimaryKey();
} else {
return false;
}
$this->usuario_id = Yii::app()->user->getState('usuario_id');
$this->revision_id = NULL;
$this->creado = date('Y-m-d H:i:s');
if (!$this->estado) {
$this->estado = 0;
}
} else {
//Crear la revisión
$this->revision_id = NULL;
$this->modificado = date('Y-m-d H:i:s');
}
return parent::beforeSave();
}
示例5: beforeSave
protected function beforeSave()
{
if ($this->isNewRecord) {
$seccion = Seccion::model()->findByPk($this->seccion_id);
$url = new Url();
$slug = $this->slugger($seccion->nombre) . '/' . $this->slugger($this->nombre);
$slug = $this->verificarSlug($slug);
$url->slug = $slug;
$url->tipo_id = 2;
//Micrositio
$url->estado = 1;
$url->save();
$this->url_id = $url->getPrimaryKey();
$this->usuario_id = Yii::app()->user->getState('usuario_id');
$this->pagina_id = NULL;
$this->menu_id = NULL;
$this->creado = date('Y-m-d H:i:s');
} else {
$this->modificado = date('Y-m-d H:i:s');
}
return parent::beforeSave();
}
示例6: beforeSave
protected function beforeSave()
{
if ($this->isNewRecord) {
$parent = Carpeta::model()->with('url')->findByPk($this->item_id);
$this->pagina_id = $parent->pagina_id;
$this->hijos = 0;
$url = new Url();
$nombre_slug = $this->slugger($this->carpeta);
$url->slug = $this->verificarSlug($parent->url->slug . '/' . $nombre_slug);
$url->tipo_id = 10;
//Carpeta
$url->estado = 1;
if ($url->save()) {
$this->url_id = $url->getPrimaryKey();
} else {
return false;
}
$this->creado = date('Y-m-d H:i:s');
} else {
$this->modificado = date('Y-m-d H:i:s');
}
return parent::beforeSave();
}