Esempio n. 1
0
 /**
  * Export image to file or buffer.
  *
  * @param string|null $filename  Filename to dave to, or null for buffer
  * @return T_Image_Gd  fluent interface
  */
 protected function export($filename = null)
 {
     switch ($this->mime->getType()) {
         case T_Mime::JPEG:
             @imageinterlace($this->handle, 1);
             /* progressive JPEG on */
             $ok = @imagejpeg($this->handle, $filename, $this->quality);
             break;
         case T_Mime::PNG:
             $q = 9 - ceil($this->quality * (9 / 100));
             /* quality 0-9, 0==best, 9==maximum compression */
             $ok = @imagepng($this->handle, $filename, $q);
             break;
         case T_Mime::GIF:
             /* requires explicit separation of 2nd argument */
             if (is_null($filename)) {
                 $ok = @imagegif($this->handle);
             } else {
                 $ok = @imagegif($this->handle, $filename);
             }
             break;
         default:
             $msg = 'Illegal image MIME type ' . $this->mime->__toString();
             throw new ImageException($msg);
     }
     if (!$ok) {
         throw new T_Exception_Image("Export {$filename} failed");
     }
 }
Esempio n. 2
0
 private function _linkEdit()
 {
     $this->_modelLyLink = $this->_getGlobalData('Model_LyLink', 'object');
     $gameTypes = $this->_modelLyLink->getMyGame();
     $operators = $this->_modelLyLink->getMyOperator();
     $linkType = $this->_modelLyLink->getType();
     $selected = $this->_modelLyLink->findById($_GET['Id']);
     if (!$selected) {
         $this->_utilMsg->showMsg(Tools::getLang('LINK_DELETED', __CLASS__), -1, 2);
     }
     if ($this->_isPost()) {
         $_POST['Id'] = intval($_POST['Id']);
         if (!$this->_modelLyLink->findById($_POST['Id'])) {
             $this->_utilMsg->showMsg(Tools::getLang('LINK_DELETED', __CLASS__), -1, 2);
         }
         $_POST['game_type_id'] = intval($_POST['game_type_id']);
         if (!$_POST['game_type_id'] || !array_key_exists($_POST['game_type_id'], $gameTypes)) {
             $this->_utilMsg->showMsg(Tools::getLang('PLZ_SLT_GAME', 'Common'), -1, 2);
         }
         $_POST['operator_id'] = intval($_POST['operator_id']);
         if (!$_POST['operator_id'] || !array_key_exists($_POST['operator_id'], $operators)) {
             $this->_utilMsg->showMsg(Tools::getLang('PLZ_SLT_OPERATOR', 'Common'), -1, 2);
         }
         $_POST['link_type'] = intval($_POST['link_type']);
         if (!$_POST['link_type'] || !array_key_exists($_POST['link_type'], $linkType)) {
             $this->_utilMsg->showMsg(Tools::getLang('PLZ_SLT_LINK_TYPE', __CLASS__), -1, 2);
         }
         if (trim($_POST['title']) == '') {
             $this->_utilMsg->showMsg(Tools::getLang('TITLE_NEED', __CLASS__), -1, 2);
         }
         if (trim($_POST['href']) == '') {
             $this->_utilMsg->showMsg(Tools::getLang('LINK_NEED', __CLASS__), -1, 2);
         }
         $this->_modelLyLink->linkUpdate();
         $this->_utilMsg->showMsg(Tools::getLang('OPERATION_SUCCESS', 'Common'), 1, $this->_url['Link'], 1);
     }
     $this->_view->assign('selected', $selected);
     $this->_view->assign('gameTypes', $gameTypes);
     $this->_view->assign('operators', $operators);
     $this->_view->assign('linkType', $linkType);
     $this->_view->display();
 }
Esempio n. 3
0
 /**
  * @param unknown_type $item
  * @param AtomEntryAdapter $entry
  * @return AtomEntryAdapter
  */
 public function buildItemEntry($item, $entry = null)
 {
     $entry = $this->_prepareEntry($entry);
     switch ($item->getType()) {
         case SourceItem::STATUS_TYPE:
             return $this->buildStatusEntry($item, $entry);
             break;
         case SourceItem::BLOG_TYPE:
             return $this->buildBlogEntry($item, $entry);
             break;
         case SourceItem::LINK_TYPE:
             return $this->buildLinkEntry($item, $entry);
             break;
         case SourceItem::IMAGE_TYPE:
             return $this->buildImageEntry($item, $entry);
             break;
         case SourceItem::VIDEO_TYPE:
             return $this->buildVideoEntry($item, $entry);
             break;
         case SourceItem::AUDIO_TYPE:
             return $this->buildAudioEntry($item, $entry);
             break;
     }
 }
Esempio n. 4
0
 /**
  * Обработка редактирования топика
  *
  * @param unknown_type $oTopic
  * @return unknown
  */
 protected function SubmitEdit($oTopic)
 {
     /**
      * Проверка корректности полей формы
      */
     if (!$this->checkTopicFields()) {
         return false;
     }
     /**
      * Определяем в какой блог делаем запись
      */
     $iBlogId = getRequest('blog_id');
     if ($iBlogId == 0) {
         $oBlog = $this->Blog_GetPersonalBlogByUserId($oTopic->getUserId());
     } else {
         $oBlog = $this->Blog_GetBlogById($iBlogId);
     }
     /**
      * Если блог не определен выдаем предупреждение
      */
     if (!$oBlog) {
         $this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_unknown'), $this->Lang_Get('error'));
         return false;
     }
     /**
      * Проверяем права на постинг в блог
      */
     if (!$this->ACL_IsAllowBlog($oBlog, $this->oUserCurrent)) {
         $this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_noallow'), $this->Lang_Get('error'));
         return false;
     }
     /**
      * Проверяем разрешено ли постить топик по времени
      */
     if (isPost('submit_topic_publish') and !$oTopic->getPublishDraft() and !$this->ACL_CanPostTopicTime($this->oUserCurrent)) {
         $this->Message_AddErrorSingle($this->Lang_Get('topic_time_limit'), $this->Lang_Get('error'));
         return;
     }
     /**
      * Сохраняем старое значение идентификатора блога
      */
     $sBlogIdOld = $oTopic->getBlogId();
     /**
      * Теперь можно смело редактировать топик
      */
     $oTopic->setBlogId($oBlog->getId());
     $oTopic->setTitle(getRequest('topic_title'));
     $oTopic->setText(htmlspecialchars(getRequest('topic_text')));
     $oTopic->setTextShort(htmlspecialchars(getRequest('topic_text')));
     $oTopic->setTextSource(getRequest('topic_text'));
     $oTopic->setLinkUrl(getRequest('topic_link_url'));
     $oTopic->setTags(getRequest('topic_tags'));
     $oTopic->setUserIp(func_getIp());
     $oTopic->setTextHash(md5($oTopic->getType() . $oTopic->getText() . $oTopic->getLinkUrl()));
     /**
      * Проверяем топик на уникальность
      */
     if ($oTopicEquivalent = $this->Topic_GetTopicUnique($this->oUserCurrent->getId(), $oTopic->getTextHash())) {
         if ($oTopicEquivalent->getId() != $oTopic->getId()) {
             $this->Message_AddErrorSingle($this->Lang_Get('topic_create_text_error_unique'), $this->Lang_Get('error'));
             return false;
         }
     }
     /**
      * Публикуем или сохраняем в черновиках
      */
     $bSendNotify = false;
     if (isset($_REQUEST['submit_topic_publish'])) {
         $oTopic->setPublish(1);
         if ($oTopic->getPublishDraft() == 0) {
             $oTopic->setPublishDraft(1);
             $oTopic->setDateAdd(date("Y-m-d H:i:s"));
             $bSendNotify = true;
         }
     } else {
         $oTopic->setPublish(0);
     }
     /**
      * Принудительный вывод на главную
      */
     if ($this->ACL_IsAllowPublishIndex($this->oUserCurrent)) {
         if (getRequest('topic_publish_index')) {
             $oTopic->setPublishIndex(1);
         } else {
             $oTopic->setPublishIndex(0);
         }
     }
     /**
      * Запрет на комментарии к топику
      */
     $oTopic->setForbidComment(0);
     if (getRequest('topic_forbid_comment')) {
         $oTopic->setForbidComment(1);
     }
     $this->Hook_Run('topic_edit_before', array('oTopic' => $oTopic, 'oBlog' => $oBlog));
     /**
      * Сохраняем топик
      */
     if ($this->Topic_UpdateTopic($oTopic)) {
         $this->Hook_Run('topic_edit_after', array('oTopic' => $oTopic, 'oBlog' => $oBlog, 'bSendNotify' => &$bSendNotify));
         /**
          * Обновляем данные в комментариях, если топик был перенесен в новый блог
          */
         if ($sBlogIdOld != $oTopic->getBlogId()) {
             $this->Comment_UpdateTargetParentByTargetId($oTopic->getBlogId(), 'topic', $oTopic->getId());
             $this->Comment_UpdateTargetParentByTargetIdOnline($oTopic->getBlogId(), 'topic', $oTopic->getId());
         }
         /**
          * Обновляем количество топиков в блоге
          */
         if ($sBlogIdOld != $oTopic->getBlogId()) {
             $this->Blog_RecalculateCountTopicByBlogId($sBlogIdOld);
         }
         $this->Blog_RecalculateCountTopicByBlogId($oTopic->getBlogId());
         /**
          * Добавляем событие в ленту
          */
         $this->Stream_write($oTopic->getUserId(), 'add_topic', $oTopic->getId(), $oTopic->getPublish() && $oBlog->getType() != 'close');
         /**
          * Рассылаем о новом топике подписчикам блога
          */
         if ($bSendNotify) {
             $this->Topic_SendNotifyTopicNew($oBlog, $oTopic, $this->oUserCurrent);
         }
         if (!$oTopic->getPublish() and !$this->oUserCurrent->isAdministrator() and $this->oUserCurrent->getId() != $oTopic->getUserId()) {
             Router::Location($oBlog->getUrlFull());
         }
         Router::Location($oTopic->getUrl());
     } else {
         $this->Message_AddErrorSingle($this->Lang_Get('system_error'));
         return Router::Action('error');
     }
 }