/** * * @param Picture $picture_ * @throws InvalidArgumentException */ public function updatePicture(Picture $picture_) { try { if (isset($this->table) && is_null($this->table)) { throw new InvalidArgumentException('Attribute "table" can\'t be NULL !'); } if (isset($this->id) && !is_null($this->id)) { $where = 'id = ' . $this->id; } //Existance test $picture = $this->selectPicture(); if (!emptyObjectMethod($picture)) { $picture = $this->selectPicture(); $path = $picture->getPath(); $title = $picture->getTitle(); $ext = $picture->getExtension(); if (file_exists(UPLOAD_PATH . $path . $title . '.' . $ext)) { if (!is_null($picture_->getTitle()) && $title !== $picture_->getTitle()) { if (!rename(UPLOAD_PATH . $path . $title . '.' . $ext, UPLOAD_PATH . $path . $picture_->getTitle() . '.' . $ext)) { throw new Exception('A problem occurred when renaming !'); } } } } else { throw new Exception('Picture doesn\'t exist !'); } return parent::update($this->table, $picture_, $where); } catch (InvalidArgumentException $e) { print $e->getMessage(); exit; } catch (Exception $e) { print $e->getMessage(); exit; } }
function __construct($content, $title) { parent::__construct(); define(GOOGLE_CODE_TRACKER_NOT_ACTIF, true); $this->render = new Table(); $this->render->setWidth("100%"); // Header if (defined('SITE_META_OPENGRAPH_IMAGE') && SITE_META_OPENGRAPH_IMAGE != "") { $logo = new Picture(SITE_META_OPENGRAPH_IMAGE); } else { $logo = new Picture("img/logo_128x400_" . $_SESSION['lang'] . ".png", 128, 400); } $logo->setTitle(__(SITE_NAME)); $logo_link = new Link($this->getPage()->getBaseLanguageURL(), Link::TARGET_NONE, $logo); $img_obj = new Object($logo_link); $img_obj->add("<br/><br/>"); $this->render->addRow($img_obj); $this->render->addRow(); // Error message $small_img = new Picture("wsp/img/warning_16.png", 16, 16, 0, "absmiddle"); $title_header = new Object($small_img, $title); $error_box = new Box($title_header, true, Box::STYLE_MAIN, Box::STYLE_MAIN, '', 'error_box', 700); $error_box->setContent($content); $this->render->addRow($error_box); }
function __construct() { // Header $logo = new Picture("img/logo_128x400_" . $_SESSION['lang'] . ".png", 128, 400); $logo->setTitle(__(SITE_NAME)); $logo_link = new Link(BASE_URL . $_SESSION['lang'] . "/", Link::TARGET_NONE, $logo); $img_obj = new Object($logo_link); $img_obj->add("<br/><br/>"); $this->render = $img_obj; }
/** * Displays a single Picture model. * @param integer $id * @return mixed */ public function actionPicture($id, $size = 'full') { if (($model = Picture::findOne($id)) === null) { throw new NotFoundHttpException('The requested page does not exist.'); } if (!$model) { $model = new Picture(); } $this->redirect($model->directlink($size), 301); }
public function run() { DB::statement("TRUNCATE TABLE images"); $image = new Picture(); $image->image_path = 'asset/upload/D4C21840-5F68-48EA-A63E-7AC4C3D9B43A.JPG'; $image->created_at = new DateTime(); $image->updated_at = new DateTime(); $image->big_path = 'asset/upload/D4C21840-5F68-48EA-A63E-7AC4C3D9B43A.JPG'; $image->save(); }
function display() { $p = new Picture(); if (!$p->get($this->user->getLogin())) { $this->view->assign('getavatar', $this->call('ajaxGetAvatar')); $this->view->assign('form', $this->prepareForm(new \modl\Contact())); } else { $this->view->assign('getavatar', ''); } }
/** * Load image * * @access private * @param Picture $picture */ private function load(Picture $picture) { $this->width = $picture->width; $this->height = $picture->height; $this->mime_type = $picture->mime_type; $this->image = $this->open($picture->get_path()); if ($this->image === false) { throw new \Exception('Is not a valid picture'); } }
function getList($params = NULL, $proyection = '*', $order = '1', $limit = '') { if ($this->db != NULL) { $this->db->read($this->table, $proyection, $params); $r = array(); while ($param = $this->db->getRow()) { $picture = new Picture(); $picture->set($param); $r[] = $picture; } return $r; } return NULL; }
public function handle($stanza, $parent = false) { $jid = current(explode('/', (string) $parent->attributes()->from)); $evt = new \Event(); $cd = new \modl\ContactDAO(); $c = $cd->get($jid); if ($c == null) { $c = new \modl\Contact(); } $p = new \Picture(); $p->fromBase((string) $stanza->items->item->data); $p->set($jid); $evt->runEvent('vcard', $c); }
public function run() { Picture::create(['album_id' => 1, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_03.png']); Picture::create(['album_id' => 1, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_03.png']); Picture::create(['album_id' => 1, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_03.png']); Picture::create(['album_id' => 1, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_03.png']); Picture::create(['album_id' => 5, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 5, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 5, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 5, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 9, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 9, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 9, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 9, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']); }
public function getIndex() { if (Auth::guest() || Auth::user()->isAdmin == 0) { return Redirect::secure('/'); } // layouts variables $this->layout->title = 'Админ панел | Нещо Шантаво'; $this->layout->canonical = 'https://neshto.shantavo.com/admin/'; $this->layout->robots = 'noindex,nofollow,noodp,noydir'; $users = count(User::all()); $admins = count(User::where('isAdmin', ">", 0)->get()); $categories = count(Category::all()); $albums = count(Album::all()); $votes = count(DB::table('votes')->get()); $pictures = count(Picture::all()); $pictureSize = 0; foreach (Picture::all() as $p) { $pictureSize += $p->size; } // get disqus stats include app_path() . '/config/_disqus.php'; $disqus = new DisqusAPI(getDisqusKey()); $disqus->setSecure(false); $comments = $disqus->posts->list(array('forum' => 'shantavo')); // nesting the view into the layout $this->layout->nest('content', 'admin.index', array('users' => $users, 'admins' => $admins, 'votes' => $votes, 'categories' => $categories, 'albums' => $albums, 'pictures' => $pictures, 'pictureSize' => $pictureSize, 'comments' => $comments)); }
protected function compile() { if ($this->defineRoot) { $objPage = \PageModel::findByPk($this->rootPage); } else { global $objPage; } if (null === $objPage) { return; } $intOffset = (int) $this->levelOffset; // Random image if ($this->randomPageImage) { $intOffset = -1; } $arrImage = PageImage::getOne($objPage, $intOffset, (bool) $this->inheritPageImage); if (null === $arrImage) { return; } $arrSize = deserialize($this->imgSize); $arrImage['src'] = $this->getImage($arrImage['path'], $arrSize[0], $arrSize[1], $arrSize[2]); $this->Template->setData($arrImage); $picture = \Picture::create($arrImage['path'], $arrSize)->getTemplateData(); $picture['alt'] = specialchars($arrImage['alt']); $this->Template->picture = $picture; if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($arrImage['src']))) !== false) { $this->Template->size = ' ' . $imgSize[3]; } // Add page information to template global $objPage; $this->Template->currentPage = $objPage->row(); }
public function isLiked($user_id) { $picture = $this; return Picture::whereHas('likes', function ($q) use($picture, $user_id) { $q->whereRaw('user_id = ? and picture_id = ?', array($user_id, $picture->id)); })->exists(); }
public function loadModel($id) { if (($model = Picture::model()->findByPk($id)) === null) { throw new CHttpException(404, 'Страница не найдена'); } return $model; }
public function gallary() { $album_id = Input::get("album_id"); $user_id = Input::get("user_id"); $photos = Picture::where("album_id", "=", $album_id)->get(); return View::make('userCenter.gallary')->with(array("photos" => $photos, "user_id" => $user_id, "album_id" => $album_id)); }
public function run() { $models = Picture::model()->published()->onMainPage()->with('category')->findAll(array('order' => 'category.sort ASC, t.sort ASC', 'limit' => (int) $this->limit)); if (empty($models)) { return; } $this->render($this->view, array('models' => $models)); }
public function getFileSrc() { if (!$this->isNew()) { return Picture::getInstance('', $this->getObject()->getPicture(), '', 50, 50)->getRawLink('resize'); } else { return ''; } }
/** * 构造函数 * @param int $pic_id 图片ID * @param int|bool $page 当前页面数 * @param array $info 图片的相关信息 * @throws \Exception */ function __construct($pic_id, $page = false, $info = NULL) { parent::__construct("pictures_has_comments", "pictures_id", intval($pic_id), "pictures"); $this->page = intval($page); $this->action_method = "post_picture"; $this->router = lib()->using('router'); if ($info === NULL) { lib()->load('Picture'); $pic = new Picture(); $this->picture_info = $pic->get_simple_pic($pic_id); } else { $this->picture_info = $info; } if (!isset($this->picture_info['pic_id'])) { throw new \Exception("Picture comment load error."); } }
/** * Smarty page modifier plugin * * Type: modifier<br> * Name: psize<br> * Date: Oct 14, 2008 * Purpose: get size of picture * Example: {$url|psize:0} * @version 1.0 * @param (string) $url| 图片的url地址 * @param (int) $type| 需要返回的类型:0表示宽,1表示高 * @return (int) 返回指定类型的大小 */ function smarty_modifier_psize($url, $type = 0) { $size = Picture::GetSize($url, $type); if (0 == $type) { return $size['width']; } else { return $size['height']; } }
public function getFileSrc($pic) { $method = $pic == 'picture' ? 'getPicture' : 'getPictureInactive'; if (!$this->isNew() && $this->getObject()->{$method}()) { return Picture::getInstance('', $this->getObject()->{$method}(), '', 50, 50)->getRawLink('resize'); } else { return ''; } }
/** * Show artist profile picture * * @return Response */ public function profilepicture($id, $type) { $pic = Picture::find($id); if ($pic) { return Response::download(storage_path() . "/pictures/" . $pic->name . "-" . $type . $pic->extension); } else { return Response::download(storage_path() . "/no-user.png"); } }
/** * Show hub picture * * @return Response */ public function picture($id) { $pic = Picture::find($id); if ($pic) { return Response::download(storage_path() . "/pictures/" . $pic->name . ".png"); } else { return App::abort(404); } }
public function getRandomInfoPicture($type) { $pictures = $this->getInfoPictures($type); if (empty($pictures)) { $picture = Picture::getDefault($type); return $picture; } return $pictures[array_rand($pictures)]; }
/** * Constructor * * @param string $content_id Content id * * @return void */ protected function __construct($content_id) { parent::__construct($content_id); /* * A SimplePicture is NEVER persistent */ parent::setIsPersistent(false); $this->setFileMetadataVerbose(false); }
public function post5_submit() { $pic = $this->input_post('pic', true, true); $picture = Picture::create(array('file_name' => '')); $picture->file_name->put($pic); echo '<meta http-equiv="Content-type" content="text/html; charset=utf-8" /><pre>'; var_dump($picture->file_name->url()); echo "</pre><hr/><a href='" . base_url(array($this->get_class())) . "'>back</a>"; }
function test_custom_attributes() { $element = Picture::create('element', $this->attachment, array('sizes' => array('thumbnail', 'medium', 'large'), 'attributes' => array('picture' => array('id' => 'custom-id', 'class' => 'picture-element'), 'source' => array('data-foo' => 'bar'), 'img' => array('id' => 'responsive-image')))); $expected = '<picture id="custom-id" class="picture-element">'; $expected .= '<source data-foo="bar" srcset="http://example.org/wp-content/uploads/IMG_2089-1024x1365.jpg" media="(min-width: 600px)">'; $expected .= '<source data-foo="bar" srcset="http://example.org/wp-content/uploads/IMG_2089-600x800.jpg" media="(min-width: 480px)">'; $expected .= '<img src="http://example.org/wp-content/uploads/IMG_2089-480x640.jpg" id="responsive-image">'; $expected .= '</picture>'; $this->assertEquals($expected, $element); }
public function Loaded() { $nb_banned_visitors = 0; foreach ($this->array_wsp_banned_users as $ip => $array_ip_info) { if ($array_ip_info['cnt'] >= MAX_BAD_URL_BEFORE_BANNED) { $btn_authorize = new Picture("img/wsp-admin/button_ok_16.png", 16, 16, 0, Picture::ALIGN_ABSMIDDLE, __(AUTHORIZE)); $btn_authorize->onClick($this, "onAuthorizeVisitor", $ip)->setAjaxEvent(); if (!$btn_authorize->isClicked()) { $link_ip = new Link("http://www.infosniper.net/index.php?ip_address=" . $ip, Link::TARGET_BLANK, $ip); $row = $this->table_ban->addRowColumns($link_ip, $array_ip_info['dte'], $array_ip_info['len'], $btn_authorize); $row->setColumnAlign(3, RowTable::ALIGN_CENTER); $nb_banned_visitors++; } } } if ($nb_banned_visitors == 0) { $this->table_ban->addRowColumns(" ", __(NO_BANNED_VISITORS), " ", " "); } }
function ajaxSend($to, $pack, $file) { if (!$this->validateJid($to)) { return; } list($key, $ext) = explode('.', $file); $filepath = dirname(__FILE__) . '/stickers/' . $pack . '/' . $key . '.png'; if (!file_exists($filepath)) { return; } // We get the base64 $base64 = base64_encode(file_get_contents($filepath)); // Caching the picture if (!file_exists(CACHE_PATH . md5($key) . '.png')) { $p = new Picture(); $p->fromBase($base64); $p->set($key, 'png'); } // Creating a message $m = new \Modl\Message(); $m->session = $this->user->getLogin(); $m->jidto = echapJid($to); $m->jidfrom = $this->user->getLogin(); $m->sticker = $key; $m->body = $this->__('sticker.sent'); $m->published = gmdate('Y-m-d H:i:s'); $session = \Session::start(); $m->id = Uuid::uuid4(); $m->type = 'chat'; $m->resource = $session->get('resource'); // Sending the sticker $html = "<p><img alt='Sticker' src='cid:sha1+" . $key . "@bob.xmpp.org'/></p>"; $p = new Publish(); $p->setTo($m->jidto)->setContent($m->body)->setHTML($html)->setId($m->id)->request(); $md = new \Modl\MessageDAO(); $md->set($m); // Sending it to Chat $packet = new Moxl\Xec\Payload\Packet(); $packet->content = $m; $c = new Chat(); $c->onMessage($packet); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { if (!is_null($request->file('thumbnail'))) { $im = $request->file('thumbnail'); // estension de l'image $ext = $im->getClientOriginalExtension(); $uri = str_random(12) . '.' . $ext; $im->move(env('UPLOAD_PATH', './uploads'), $uri); Picture::create(['uri' => $uri, 'size' => $im->getSize(), 'type' => $ext, 'product_id' => $product->id]); } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $model = array(); $model['publishers'] = count(Publishing::model()->findAll()); $model['authors'] = count(Author::model()->findAll()); $model['books'] = count(Book::model()->findAll()); $model['pictures'] = count(Picture::model()->findAll()); // renders the view file 'protected/views/site/index.php' // using the default layout 'protected/views/layouts/main.php' $this->render('index', ['model' => $model]); }