Ejemplo n.º 1
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return GHEADER_CLASS_CreditsBridge
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Ejemplo n.º 2
0
 public function fullInit()
 {
     //FULL INIT
     $this->genericInit();
     //OVerwrite
     require_once $this->getPlugin()->getRootDir() . 'overwrite' . DS . 'components' . DS . 'brief_info.php';
     // Bridges
     GHEADER_CLASS_PhotoBridge::getInstance()->init();
     GHEADER_CLASS_NewsfeedBridge::getInstance()->init();
     GHEADER_CLASS_NotificationsBridge::getInstance()->init();
     GHEADER_CLASS_CommentsBridge::getInstance()->init();
     GHEADER_CLASS_CreditsBridge::getInstance()->init();
     OW::getEventManager()->bind('admin.add_auth_labels', array($this, 'onAddAuthLabels'));
 }
Ejemplo n.º 3
0
 public function addFromPhotos($query)
 {
     $photoId = $query['photoId'];
     $groupId = $query['groupId'];
     if (!GHEADER_CLASS_CreditsBridge::getInstance()->credits->isAvaliable(GHEADER_CLASS_Credits::ACTION_ADD)) {
         $error = GHEADER_CLASS_CreditsBridge::getInstance()->credits->getErrorMessage(GHEADER_CLASS_Credits::ACTION_ADD);
         throw new InvalidArgumentException($error);
     }
     $sourcePath = GHEADER_CLASS_PhotoBridge::getInstance()->pullPhoto($photoId);
     if ($sourcePath === null) {
         throw new InvalidArgumentException("The requested photo wasn't find");
     }
     $canvasWidth = $query['width'];
     $canvasHeight = OW::getConfig()->getValue('gheader', 'cover_height');
     $coverImage = new UTIL_Image($sourcePath);
     $imageHeight = $coverImage->getHeight();
     $imageWidth = $coverImage->getWidth();
     $css = array('width' => 'auto', 'height' => 'auto');
     $tmp = $canvasWidth * $imageHeight / $imageWidth;
     if ($tmp >= $canvasHeight) {
         $css['width'] = '100%';
     } else {
         $css['height'] = '100%';
     }
     $this->validateImage($coverImage, $canvasWidth, $canvasHeight);
     $cover = $this->service->findCoverByGroupId($groupId, GHEADER_BOL_Cover::STATUS_TMP);
     if ($cover === null) {
         $cover = new GHEADER_BOL_Cover();
     }
     $extension = UTIL_File::getExtension($sourcePath);
     $cover->file = uniqid('cover-' . $groupId . '-') . '.' . $extension;
     $cover->groupId = $groupId;
     $cover->status = GHEADER_BOL_Cover::STATUS_TMP;
     $cover->timeStamp = time();
     $dimensions = array('height' => $imageHeight, 'width' => $imageWidth);
     $cover->setSettings(array('photoId' => $photoId, 'dimensions' => $dimensions, 'css' => $css, 'canvas' => array('width' => $canvasWidth, 'height' => $canvasHeight), 'position' => array('top' => 0, 'left' => 0)));
     $this->service->saveCover($cover);
     $coverPath = $this->service->getCoverPath($cover);
     OW::getStorage()->copyFile($sourcePath, $coverPath);
     @unlink($sourcePath);
     $coverUrl = $this->service->getCoverUrl($cover);
     return array('src' => $coverUrl, 'data' => $cover->getSettings());
 }