public function actionCustomize() { $id = Yii::app()->request->getParam('id'); $qr = $this->loadModel($id); $just_saved = false; if (isset($_POST['customize'])) { $customize_what = $_POST['customize']; $type = $_POST['type']; $shape = $_POST['shape']; $color = $_POST['color']; if ($customize_what == 'shape') { if ($type && $shape) { $qr->{$type} = $shape; $qr->save(); $just_saved = true; } } else { if ($customize_what == 'color') { if ($type && $color) { $type = $type . 'Color'; $qr->{$type} = $color; $qr->save(); $just_saved = true; } } } } if (isset($_POST['customize']) && $customize_what == $_POST['customize'] && $_FILES['logo']['error'] == 0 || $qr->logo_image) { if ($just_saved == false) { $qr->save(); } $saved_logo_image = $qr->logo_image; if (isset($_FILES['logo']) && $_FILES['logo']['error'] == 0) { $qr->deleteLogos(); $ext = strtolower(pathinfo($_FILES['logo']['name'], PATHINFO_EXTENSION)); $logo_path = Yii::getPathOfAlias("webroot.logos.{$id}") . '.' . $ext; move_uploaded_file($_FILES['logo']['tmp_name'], $logo_path); } else { if ($saved_logo_image) { $ext = pathinfo($saved_logo_image, PATHINFO_EXTENSION); $logo_path = $saved_logo_image; } } Qr::embedLogo($qr->image_path, $logo_path); } $this->render('customize', array('qr' => $qr, 'shapes' => QrTag::installedShapes(), 'shape_url' => QrTag::publishFiles())); }
public function generate($file, $size) { $qr = new QrTag(); $qr->bgColor = $this->backgroundColor; if (class_exists($this->frame_dot)) { $dotShape = new $this->dot(); } else { $dotShape = new QrTagDotSquare(); } $dotShape->color = $this->dotColor; $dotShape->size = $size; $qr->text = $this->tag_url; $qr->setDot($dotShape); if (class_exists($this->frame_dot)) { $qr->frameDot = new $this->frame_dot(); } else { $qr->frameDot = new QrTagFrameDotSquare(); } $qr->frameDot->color = $this->frame_dotColor; if (class_exists($this->frame_dot)) { $qr->frame = new $this->frame(); } else { $qr->frame = new QrTagFrameSquare(); } $qr->frame->color = $this->frameColor; $qr->file = $file; $qr->generate(); if ($logo_image = $this->getLogo_image()) { self::embedLogo($file, $logo_image); } }
switch ($sizestr) { case 'medium': $size = 30; break; case 'large': $size = 50; break; case 'xlarge': $size = 60; break; default: $size = 14; break; } // ======================= Initialization ======================= $qr = new QrTag(); $qr->bgColor = $backgroundColor; if (class_exists($frame_dot)) { $dotShape = new $dot(); } else { $dotShape = new QrTagDotSquare(); } $dotShape->color = $dotColor; $dotShape->size = $size; $qr->text = "Hi...."; $qr->setDot($dotShape); if (class_exists($frame_dot)) { $qr->frameDot = new $frame_dot(); } else { $qr->frameDot = new QrTagFrameDotSquare(); }