当前位置: 首页>>代码示例>>PHP>>正文


PHP Banner::findById方法代码示例

本文整理汇总了PHP中Banner::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP Banner::findById方法的具体用法?PHP Banner::findById怎么用?PHP Banner::findById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Banner的用法示例。


在下文中一共展示了Banner::findById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit

 public function edit($id)
 {
     if (!($banner = Banner::findById($id))) {
         Flash::set('error', __('Banner not found!'));
         redirect(get_url('banner'));
     }
     // check if trying to save
     if (get_request_method() == 'POST') {
         return $this->_edit($id);
     }
     $this->display('banner/view', array('banner' => $banner));
 }
开发者ID:sindotnet,项目名称:hotelyan,代码行数:12,代码来源:BannerController.php

示例2: banner_count_display

function banner_count_display($args) {

	//	check for banner click
	if (preg_match('#^/banner-show/(\d+)$#i',$args,$matches)) {
		
		//	update the click count of the banner
		$id = (int)$matches[1];
		$banner = Banner::findById($id);
		$banner->ccount++;
		$banner->save();
		
		//	get image uri
		$imguri = Plugin::getSetting('imguri','banner');
		
		//	redirect to the requested url
		header ('HTTP/1.1 301 Moved Permanently', true);
		header ("Location: /{$imguri}/{$banner->image}");

		exit;
	}
	
	//	no click so keep going
	return $args;
}
开发者ID:realslacker,项目名称:Banner-Plugin,代码行数:24,代码来源:index.php

示例3: banner_update

	/**
	 * Processes an update to the banner and redirects back to the edit page
	 *
	 * @param int $id
	 */
	public function banner_update($id=null) {
		if (is_null($id)){
				Flash::set('error','Banners - '.__('No ID specified!'));
				redirect(get_url('plugin/banner/banner_list'));
			}
		
		//	retrieve the current banner settings from the database
		if (!$current = Banner::findById($id)) {
				Flash::set('error','Banners - '.__('Could not find banner!'));
				redirect(get_url('plugin/banner/banner_list'));
			}
		
		//	retrieve the new banner settings from $_POST
		$_POST['id'] = $id;
		$input = $this->__validate($_POST);
		
		//	rename the current image with the new settings
		$newname = $this->__imgname($input,'.'.pathinfo($current->image,PATHINFO_EXTENSION));
		$oldname = $current->image;
		if ($newname !== $oldname) {
			if (!$this->__rename($oldname,$newname)) {
				Flash::set('error','Banners - '.__('Could not rename image!'));
				redirect(get_url('plugin/banner/banner_edit/'.$id));
			}
			$current->image = $newname;
			if (!$current->save()) {
				$this->__rename($newname,$oldname);
				Flash::set('error','Banners - '.__('Could not save new image name in database!'));
				redirect(get_url('plugin/banner/banner_edit/'.$id));
			}
		}
		
		//	attempt to upload a new banner image
		if ($newname = $this->__upload('banner',$input,$current->image)) $current->image = $newname;
		
		//	update banner in database
		$current = Banner::findById($id);
		$current->updated = date('Y-m-d H:i:s');
		foreach ($input as $key => $value) {
			$current->$key = $value;
		}
		
		if (!$current->save()) {
			Flash::set('error','Banners - '.__('Could not update the banner in the database.'));
			redirect(get_url('plugin/banner/banner_edit/'.$id));
		}
		
		Flash::set('success','Banners - '.__('banner saved!'));
		redirect(get_url('plugin/banner/banner_edit/'.$id));
	}//*/
开发者ID:realslacker,项目名称:Banner-Plugin,代码行数:55,代码来源:BannerController.php


注:本文中的Banner::findById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。