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


PHP Media::model方法代码示例

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


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

示例1: actionShow

 public function actionShow($key, $id)
 {
     $pageModel = Media::model()->findByPk($id);
     $this->pageTitle .= ' - Фото та відео - ' . $pageModel->getTitle();
     /** @var $cs CClientScript */
     Yii::app()->getClientScript()->registerMetaTag($pageModel->getMetaDescription(), 'description')->registerMetaTag($pageModel->getMetaKeyWords(), 'keywords');
     $lastNews = Media::model()->last(Yii::app()->params['frontend']['itemsPerPage'])->notIn(array($id))->findAll();
     $this->breadcrumbs = array('Головна' => $this->createUrl('site/index'), 'Фото та відео' => $this->createUrl('index'), $pageModel->getTitle(100, TRUE));
     $this->render('show', array('pageModel' => $pageModel, 'lastModels' => $lastNews, 'archiveYears' => Media::getYearsForArchive()));
 }
开发者ID:andrelinoge,项目名称:rezydent,代码行数:10,代码来源:MediaController.php

示例2: deleteMedia

 private function deleteMedia($id)
 {
     /** @var $model Media [ ] */
     $model = Media::model()->findByPk($id);
     $this->assertNotEmpty($model, " media record does not exist");
     $this->assertTrue($model->delete(), " record not deleted");
     foreach ($model->getImageSizes() as $imageSize) {
         $this->assertEquals(false, $model->getFullPath($imageSize), $imageSize . " is not deleted");
     }
 }
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:10,代码来源:MediaTest.php

示例3: collectGarbage

 /**
  * Called after removing media or changing the filename field. Checks for existing references
  * to filename and deletes file if none exist.
  */
 private function collectGarbage(array $exclude = array())
 {
     if (!in_array($this->getPath(), $exclude) && file_exists($this->getPath())) {
         $media = Media::model()->findByAttributes(array('uploadedBy' => $this->uploadedBy, 'fileName' => $this->fileName));
         // Only delete the file if it is the last media object
         // To use it.
         if (!$media) {
             unlink($this->getPath());
         }
     }
 }
开发者ID:xl602,项目名称:X2CRM,代码行数:15,代码来源:Media.php

示例4: openBodyTag

 public static function openBodyTag(array $preferences, array $htmlOptions = array())
 {
     $cs = Yii::app()->clientScript;
     $baseUrl = $cs->baseUrl;
     $fullscreen = $cs->fullscreen;
     $style = '';
     $classes = 'enable-search-bar-modes';
     $noBorders = false;
     if ($preferences != null && $preferences['backgroundColor']) {
         $style .= 'background-color:#' . $preferences['backgroundColor'] . ';';
     }
     if ($preferences != null && $preferences['backgroundImg']) {
         if (Yii::app()->user->isGuest) {
             $media = Media::model()->findByAttributes(array('id' => $preferences['backgroundImg']));
             if ($media) {
                 $mediaUrl = $media->getPublicUrl();
             }
         } else {
             $mediaUrl = $baseUrl . Yii::app()->request->scriptUrl . '/media/getFile/' . $preferences['backgroundImg'];
         }
         if (isset($mediaUrl)) {
             $style .= 'background-image:url(' . $mediaUrl . ');';
             $classes .= ' custom-background-image';
         }
         switch ($bgTiling = $preferences['backgroundTiling']) {
             case 'repeat-x':
             case 'repeat-y':
             case 'repeat':
                 $style .= 'background-repeat:' . $bgTiling . ';';
                 break;
             case 'center':
                 $style .= 'background-repeat:no-repeat;background-position:center center;';
                 break;
             case 'stretch':
             default:
                 $style .= 'background-attachment:fixed;background-size:cover;';
                 $noBorders = true;
         }
     }
     if ($noBorders) {
         $classes .= ' no-borders';
     }
     if ($fullscreen) {
         $classes .= ' no-widgets';
     } else {
         $classes .= ' show-widgets';
     }
     if (!RESPONSIVE_LAYOUT) {
         $classes .= ' disable-mobile-layout';
     }
     $classes .= ' not-mobile-body';
     $htmlOptions = self::mergeHtmlOptions(array('class' => $classes, 'style' => $style), $htmlOptions);
     return self::openTag('body', $htmlOptions);
 }
开发者ID:shuvro35,项目名称:X2CRM,代码行数:54,代码来源:X2Html.php

示例5: beginRequest

	/**
	 * Load configuration that cannot be put in config/main
	 */
	public function beginRequest() {
	
		$prof=Profile::model()->findByPk(Yii::app()->user->getId());
		if (isset($prof->language))
			$this->owner->language=$prof->language;
                else{
                    $adminProf=ProfileChild::model()->findByPk(1);
                    $this->owner->language=$adminProf->language;
                }
		if(isset($prof->timeZone) && $prof->timeZone!='')
			date_default_timezone_set($prof->timeZone);
		$adminProf=ProfileChild::model()->findByAttributes(array('username'=>'admin'));
		$logo=Media::model()->findByAttributes(array('associationId'=>$adminProf->id,'associationType'=>'logo'));
		if(isset($logo)){
			$this->owner->params->logo=$logo->fileName;
		}
		
		$admin = CActiveRecord::model('Admin')->findByPk(1);
		$this->owner->params->currency = $admin->currency;
    }
开发者ID:ruchida,项目名称:X2Engine,代码行数:23,代码来源:ApplicationConfigBehavior.php

示例6: afterDelete

 public function afterDelete()
 {
     parent::afterDelete();
     // Reset path if name was changed:
     $this->_path = null;
     if (file_exists($this->getPath())) {
         $media = Media::model()->findByAttributes(array('uploadedBy' => $this->uploadedBy, 'fileName' => $this->fileName));
         // Only delete the file if it is the last media object
         // To use it.
         if (!$media) {
             unlink($this->getPath());
         }
     }
     // if theme is deleted which is default, unset default theme setting
     if ($this->id === Yii::app()->settings->defaultTheme) {
         Yii::app()->settings->defaultTheme = null;
         Yii::app()->settings->enforceDefaultTheme = false;
         Yii::app()->settings->save();
     }
 }
开发者ID:shuvro35,项目名称:X2CRM,代码行数:20,代码来源:Media.php

示例7: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Topics();
     $fileCreation = false;
     if (isset($_FILES['upload']) || isset($_POST['Topics'])) {
         $data = array();
         $topicText = null;
         if (isset($_FILES['upload'])) {
             $fileCreation = true;
             $data = array('name' => $_POST['topicName']);
             $topicText = $_POST['topicText'];
         } else {
             if (isset($_POST['Topics'])) {
                 $data = $_POST['Topics'];
                 $topicText = $_POST['TopicReplies']['text'];
             }
         }
         $data['text'] = $topicText;
         $model->setX2Fields($data, false, true);
         if (isset($_POST['x2ajax'])) {
             $ajaxErrors = $this->quickCreate($model);
         } else {
             if ($model->save()) {
                 if ($fileCreation) {
                     $media = new Media();
                     $username = Yii::app()->user->getName();
                     // file uploaded through form
                     $temp = CUploadedFile::getInstanceByName('upload');
                     if ($temp && ($tempName = $temp->getTempName()) && !empty($tempName)) {
                         $name = $temp->getName();
                         $name = str_replace(' ', '_', $name);
                         $check = Media::model()->findAllByAttributes(array('fileName' => $name));
                         // rename file if there name conflicts by suffixing "(n)"
                         if (count($check) != 0) {
                             $count = 1;
                             $newName = $name;
                             $arr = explode('.', $name);
                             $name = $arr[0];
                             while (count($check) != 0) {
                                 $newName = $name . '(' . $count . ').' . $temp->getExtensionName();
                                 $check = Media::model()->findAllByAttributes(array('fileName' => $newName));
                                 $count++;
                             }
                             $name = $newName;
                         }
                     }
                     if (FileUtil::ccopy($tempName, "uploads/protected/media/{$username}/{$name}")) {
                         $media->associationType = 'topicReply';
                         $media->associationId = $model->originalPost->id;
                         $media->uploadedBy = $username;
                         $media->createDate = time();
                         $media->lastUpdated = time();
                         $media->fileName = $name;
                         $media->mimetype = $temp->type;
                         if ($media->save()) {
                             echo $model->id;
                             Yii::app()->end();
                         }
                     }
                 } else {
                     $this->redirect(array('view', 'id' => $model->id));
                 }
             } elseif ($model->hasErrors('text')) {
                 Yii::app()->user->setFlash('error', 'Original post text cannot be blank.');
             }
         }
     }
     if (isset($_POST['x2ajax']) || isset($_FILES['upload'])) {
         $this->renderInlineForm($model);
     } else {
         $this->render('create', array('model' => $model));
     }
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:77,代码来源:TopicsController.php

示例8: actionPreviewTheme

 public function actionPreviewTheme($themeName)
 {
     $theme = Media::model()->findByAttributes(array('associationType' => 'theme ', 'fileName' => $themeName));
     if ($theme) {
         $settings = CJSON::decode($theme->description);
         ThemeGenerator::previewTheme($settings);
     }
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:8,代码来源:ProfileController.php

示例9: run

 public function run()
 {
     if (Yii::app()->user->isGuest) {
         Yii::app()->controller->redirect(Yii::app()->controller->createUrl('/site/login'));
     }
     $this->attachBehaviors($this->behaviors);
     // Safety net of handlers - they ensure that errors can be caught and seen easily:
     $scenario = 'custom';
     if (empty($this->model)) {
         $model = new InlineEmail();
     } else {
         $model = $this->model;
     }
     if (isset($_POST['contactFlag'])) {
         $model->contactFlag = $_POST['contactFlag'];
     }
     $makeEvent = isset($_GET['skipEvent']) ? !(bool) $_GET['skipEvent'] : 1;
     // Check to see if the user is requesting a new template
     if (isset($_GET['template'])) {
         $scenario = 'template';
     }
     $model->setScenario($scenario);
     $attachments = array();
     if (isset($_POST['InlineEmail'])) {
         // This could indicate either a template change or a form submission.
         $model->attributes = $_POST['InlineEmail'];
         // Prepare attachments that may have been uploaded on-the-fly (?)
         $mediaLibraryUsed = false;
         // is there an attachment from the media library?
         if (isset($_POST['AttachmentFiles'], $_POST['AttachmentFiles']['id'], $_POST['AttachmentFiles']['types'])) {
             $ids = $_POST['AttachmentFiles']['id'];
             $types = $_POST['AttachmentFiles']['types'];
             $attachments = array();
             for ($i = 0; $i < count($ids); $i++) {
                 $type = $types[$i];
                 switch ($type) {
                     case 'temp':
                         // attachment is a temp file
                         $tempFile = TempFile::model()->findByPk($ids[$i]);
                         $attachments[] = array('filename' => $tempFile->name, 'folder' => $tempFile->folder, 'type' => $type, 'id' => $tempFile->id);
                         break;
                     case 'media':
                         // attachment is from media library
                         $mediaLibraryUsed = true;
                         $media = Media::model()->findByPk($ids[$i]);
                         $attachments[] = array('filename' => $media->fileName, 'folder' => $media->uploadedBy, 'type' => $type, 'id' => $media->id);
                         break;
                     default:
                         throw new CException('Invalid attachment type: ' . $type);
                 }
             }
         }
         $model->attachments = $attachments;
         // Validate/prepare the body, and send if no problems occur:
         $sendStatus = array_fill_keys(array('code', 'message'), '');
         $failed = false;
         $message = '';
         $postReplace = isset($_GET['postReplace']) ? $_GET['postReplace'] : 0;
         if (isset($_GET['loadTemplate'])) {
             // A special override for when it's not possible to include the template in $_POST
             $model->template = $_GET['loadTemplate'];
         }
         if ($model->prepareBody($postReplace)) {
             if ($scenario != 'template') {
                 // Sending the email, not merely requesting a template change
                 //
                 // First check that the user has permission to use the
                 // specified credentials:
                 if ($model->credId != Credentials::LEGACY_ID) {
                     if (!Yii::app()->user->checkAccess('CredentialsSelect', array('model' => $model->credentials))) {
                         $this->respond(Yii::t('app', 'Did not send email because you do not have ' . 'permission to use the specified credentials.'), 1);
                     }
                 }
                 $sendStatus = $model->send($makeEvent);
                 // $sendStatus = array('code'=>'200','message'=>'sent (testing)');
                 $failed = $sendStatus['code'] != '200';
                 $message = $sendStatus['message'];
             } else {
                 if ($model->modelName == 'Quote' && empty($model->template)) {
                     // Fill in the gap with the default / "semi-legacy" quotes view
                     $model->message = $this->controller->renderPartial('application.modules.quotes.views.quotes.print', array('model' => $model->targetModel, 'email' => true), true);
                     // Add a linebreak at the beginning for user-entered notes in the email:
                     $model->insertInBody('<br />', 1);
                 }
             }
         }
         // Populate response data:
         $modelHasErrors = $model->hasErrors();
         $failed = $failed || $modelHasErrors;
         $response = array('scenario' => $scenario, 'sendStatus' => $sendStatus, 'attributes' => $model->attributes, 'modelErrors' => $model->errors, 'modelHasErrors' => $modelHasErrors, 'modelErrorHtml' => CHtml::errorSummary($model, Yii::t('app', "Please fix the following errors:"), null, array('style' => 'margin-bottom: 5px;')));
         if ($scenario == 'template') {
             // There's a chance the inline email form is switching gears into
             // quote mode, in which case we need to include templates and
             // insertable attributes for setting it all up properly:
             $response['insertableAttributes'] = $model->insertableAttributes;
             $templates = array(0 => Yii::t('docs', 'Custom Message')) + Docs::getEmailTemplates($model->modelName == 'Quote' ? 'quote' : 'email', $_POST['associationType']);
             $response['templateList'] = array();
             foreach ($templates as $id => $templateName) {
                 $response['templateList'][] = array('id' => $id, 'name' => $templateName);
             }
//.........这里部分代码省略.........
开发者ID:keyeMyria,项目名称:CRM,代码行数:101,代码来源:InlineEmailAction.php

示例10: beginRequest

 /**
  * Load dynamic app configuration.
  *
  * Per the onBeginRequest key in the array returned by {@link events()},
  * this method will be called when the request has begun. It allows for
  * many extra configuration tasks to be run on a per-request basis
  * without having to extend {@link Yii} and override its methods.
  */
 public function beginRequest()
 {
     // About the "noSession" property/variable:
     //
     // This variable, if true, indicates that the application is running in
     // the context of either an API call or a console command, in which case
     // there would not be the typical authenticated user and session
     // variables one would need in a web request
     //
     // It's necessary because originally this method was written with
     // absolutely no regard for compatibility with the API or Yii console,
     // and thus certain lines of code that make references to the usual web
     // environment with cookie-based authentication (which would fail in
     // those cases) needed to be kept inside of conditional statements that
     // are skipped over if in the console/API.
     $this->owner->params->noSession = $this->owner->params->noSession || strpos($this->owner->request->getPathInfo(), 'api/') === 0 || strpos($this->owner->request->getPathInfo(), 'api2/') === 0;
     $noSession = $this->owner->params->noSession;
     if (!$noSession) {
         if ($this->owner->request->getPathInfo() == 'notifications/get') {
             // skip all the loading if this is a chat/notification update
             Yii::import('application.components.util.AuxLib');
             Yii::import('application.models.Roles');
             Yii::import('application.components.X2AuthManager');
             Yii::import('application.components.X2Html');
             Yii::import('application.components.X2WebUser');
             Yii::import('application.components.sortableWidget.*');
             Yii::import('application.components.sortableWidget.profileWidgets.*');
             Yii::import('application.components.sortableWidget.recordViewWidgets.*');
             Yii::import('application.components.X2Settings.*');
             Yii::import('application.components.X2MessageSource');
             Yii::import('application.components.Formatter');
             Yii::import('application.components.X2Html');
             Yii::import('application.components.JSONEmbeddedModelFieldsBehavior');
             Yii::import('application.components.TransformedFieldStorageBehavior');
             Yii::import('application.components.EncryptedFieldsBehavior');
             Yii::import('application.components.permissions.*');
             Yii::import('application.models.Modules');
             if (!$this->owner->user->getIsGuest()) {
                 $profData = $this->owner->db->createCommand()->select('timeZone, language')->from('x2_profile')->where('id=' . $this->owner->user->getId())->queryRow();
             }
             // set the timezone to the admin's
             if (isset($profData)) {
                 if (isset($profData['timeZone'])) {
                     $timezone = $profData['timeZone'];
                 }
                 if (isset($profData['language'])) {
                     $language = $profData['language'];
                 } else {
                 }
             }
             if (!isset($timezone)) {
                 $timezone = 'UTC';
             }
             if (!isset($language)) {
                 $language = 'en';
             }
             date_default_timezone_set($timezone);
             $this->owner->language = $language;
             Yii::import('application.models.X2Model');
             Yii::import('application.models.Dropdowns');
             Yii::import('application.models.Admin');
             $this->cryptInit();
             // Yii::import('application.models.*');
             // foreach(scandir('protected/modules') as $module){
             // if(file_exists('protected/modules/'.$module.'/register.php'))
             // Yii::import('application.modules.'.$module.'.models.*');
             // }
             return;
         }
     } else {
         Yii::import('application.models.Profile');
         Yii::import('application.components.sortableWidget.*');
         Yii::import('application.components.X2Settings.*');
         Yii::import('application.components.TransformedFieldStorageBehavior');
         // Set time zone based on the default value
         date_default_timezone_set(Profile::model()->tableSchema->getColumn('timeZone')->defaultValue);
     }
     $this->importDirectories();
     $this->cryptInit();
     if (YII_DEBUG) {
         $this->owner->params->timer = new TimerUtil();
     }
     $this->owner->messages->onMissingTranslation = array(new TranslationLogger(), 'log');
     // Set profile
     //
     // Get the Administrator's and the current user's profile.
     $adminProf = Profile::model()->findByPk(1);
     $this->owner->params->adminProfile = $adminProf;
     if (!$noSession) {
         // Typical web session:
         $notGuest = !$this->owner->user->getIsGuest();
         if ($notGuest) {
//.........这里部分代码省略.........
开发者ID:shayanyi,项目名称:CRM,代码行数:101,代码来源:ApplicationConfigBehavior.php

示例11: loadModel

	/**
	 * Returns the data model based on the primary key given in the GET variable.
	 * If the data model is not found, an HTTP exception will be raised.
	 * @param integer the ID of the model to be loaded
	 */
	public function loadModel($id) {
		$model=Media::model()->findByPk((int)$id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}
开发者ID:ruchida,项目名称:X2Engine,代码行数:11,代码来源:MediaController.php

示例12: foreach

Yii::app()->clientScript->registerPackage('X2CSS');
Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/profileSettings.js', CClientScript::POS_END);
Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/profileSettings.css');
Tours::tips(array(array('content' => Yii::t('app', 'You can disable tips like this by unchecking this box.'), 'target' => '#Profile_showTours')));
$preferences = $model->theme;
$miscLayoutSettings = $model->miscLayoutSettings;
$passVariablesToClientScript = "\n    x2.profileSettings.checkerImagePath = '" . Yii::app()->theme->getBaseUrl() . "/images/checkers.gif';\n    x2.profileSettings.createThemeHint = '" . Yii::t('profile', 'Save your current theme settings as a predefined theme.') . "';\n    x2.profileSettings.saveThemeHint = '" . Yii::t('profile', 'Update the settings of the currently selected predefined theme.') . "';\n    x2.profileSettings.normalizedUnhideTagUrl = '" . CHtml::normalizeUrl(array("/profile/unhideTag")) . "';\n    x2.profileSettings.translations = {\n        themeImportDialogTitle: '" . Yii::t('profile', 'Import a Theme') . "',\n        close: '" . Yii::t('app', 'close') . "',\n    };\n    x2.profileSettings.uploadedByAttrs = {};\n";
// pass array of predefined theme uploadedBy attributes to client
foreach ($myThemes->data as $theme) {
    $passVariablesToClientScript .= "x2.profileSettings.uploadedByAttrs['" . $theme->id . "'] = '" . $theme->uploadedBy . "';";
}
Yii::app()->clientScript->registerScript('passVariablesToClientScript', $passVariablesToClientScript, CClientScript::POS_END);
// If the user was redirected from /site/upload and the "useId" parameter is
// available, set the background to that so they get instant feedback
if (isset($_GET['bgId'])) {
    $media = Media::model()->findByPk($_GET['bgId']);
    if ($media instanceof Media) {
        Yii::app()->clientScript->registerScript('setBackgroundToUploaded', '$("select#backgroundImg").val(' . $media->id . ').trigger("change");', CClientScript::POS_READY);
    }
}
?>

<?php 
$form = $this->beginWidget('X2ActiveForm', array('id' => 'settings-form', 'enableAjaxValidation' => false));
echo $form->errorSummary($model);
?>

<div id="profile-settings" class="form">
    <?php 
echo X2Html::getFlashes();
?>
开发者ID:tymiles003,项目名称:X2CRM,代码行数:31,代码来源:_settings.php

示例13: getActionHeader

 /**
  * Magic getter for {@link actionHeader}
  *
  * Composes an informative header for the action record.
  *
  * @return type
  */
 public function getActionHeader()
 {
     if (!isset($this->_actionHeader)) {
         $recipientContacts = $this->recipientContacts;
         // Add email headers to the top of the action description's body
         // so that the resulting recorded action has all the info of the
         // original email.
         $fromString = $this->from['address'];
         if (!empty($this->from['name'])) {
             $fromString = '"' . $this->from['name'] . '" <' . $fromString . '>';
         }
         $header = CHtml::tag('strong', array(), Yii::t('app', 'Subject: ')) . CHtml::encode($this->subject) . '<br />';
         $header .= CHtml::tag('strong', array(), Yii::t('app', 'From: ')) . CHtml::encode($fromString) . '<br />';
         // Put in recipient lists, and if any correspond to contacts, make links
         // to them in place of their names.
         foreach (array('to', 'cc', 'bcc') as $recList) {
             if (!empty($this->mailingList[$recList])) {
                 $header .= CHtml::tag('strong', array(), ucfirst($recList) . ': ');
                 foreach ($this->mailingList[$recList] as $target) {
                     if ($recipientContacts[$target[1]] != null) {
                         $header .= $recipientContacts[$target[1]]->link;
                     } else {
                         $header .= CHtml::encode("\"{$target[0]}\"");
                     }
                     $header .= CHtml::encode(" <{$target[1]}>,");
                 }
                 $header = rtrim($header, ', ') . '<br />';
             }
         }
         // Include special quote information if it's a quote being issued or emailed to a random contact
         if ($this->modelName == 'Quote') {
             $header .= '<br /><hr />';
             $header .= CHtml::tag('strong', array(), Yii::t('quotes', $this->targetModel->type == 'invoice' ? 'Invoice' : 'Quote')) . ':';
             $header .= ' ' . $this->targetModel->link . ($this->targetModel->status ? ' (' . $this->targetModel->status . '), ' : ' ') . Yii::t('app', 'Created') . ' ' . $this->targetModel->renderAttribute('createDate') . ';';
             $header .= ' ' . Yii::t('app', 'Updated') . ' ' . $this->targetModel->renderAttribute('lastUpdated') . ' by ' . $this->userProfile->fullName . '; ';
             $header .= ' ' . Yii::t('quotes', 'Expires') . ' ' . $this->targetModel->renderAttribute('expirationDate');
             $header .= '<br />';
         }
         // Attachments info
         if (!empty($this->attachments)) {
             $header .= '<br /><hr />';
             $header .= CHtml::tag('strong', array(), Yii::t('media', 'Attachments:')) . "<br />";
             $i = 0;
             foreach ($this->attachments as $attachment) {
                 if ($i++) {
                     $header .= '<br />';
                 }
                 if ($attachment['type'] === 'temp') {
                     // attempt to convert temporary file to media record
                     if ($this->modelId && $this->modelName) {
                         $associationId = $this->modelId;
                         $associationType = X2Model::getAssociationType($this->modelName);
                     } elseif ($contact = reset($recipientContacts)) {
                         $associationId = $contact->id;
                         $associationType = 'contacts';
                     }
                     if (isset($associationId) && ($media = $attachment['model']->convertToMedia(array('associationType' => $associationType, 'associationId' => $associationId)))) {
                         $attachment['type'] = 'media';
                         $attachment['id'] = $media->id;
                     }
                 }
                 if ($attachment['type'] === 'media' && ($media = Media::model()->findByPk($attachment['id']))) {
                     $header .= $media->getLink() . '&nbsp;|&nbsp;' . $media->getDownloadLink();
                 } else {
                     $header .= CHtml::tag('span', array('class' => 'email-attachment-text'), $attachment['filename']) . '<br />';
                 }
             }
         }
         $this->_actionHeader = $header . '<br /><hr />';
     }
     return $this->_actionHeader;
 }
开发者ID:shuvro35,项目名称:X2CRM,代码行数:79,代码来源:InlineEmail.php

示例14: foreach

        ?>
-media" class="user-media-list">
                    <?php 
        foreach ($userMediaItems as $item) {
            if (!$item['private'] || $admin) {
                $baseId = "{$user['username']}-media-id-{$item['id']}";
                $jsSelectorId = CJSON::encode("#{$baseId}");
                $propertyId = addslashes($baseId);
                $desc = CHtml::encode($item['description']);
                echo '<span class="x2-pillbox media-item">';
                $path = Media::getFilePath($item['uploadedBy'], $item['fileName']);
                $filename = $item['drive'] ? $item['name'] : $item['fileName'];
                if (mb_strlen($filename, 'UTF-8') > 35) {
                    $filename = mb_substr($filename, 0, 32, 'UTF-8') . '…';
                }
                echo CHtml::link($filename, array('/media', 'view' => $item['id']), array('class' => 'x2-link media media-library-item' . (Media::isImageExt($item['fileName']) ? ' image-file' : ''), 'id' => $baseId, 'data-url' => Media::model()->findByPk($item['id'])->getPublicUrl()));
                echo '</span>';
                if (Media::isImageExt($item['fileName'])) {
                    $imageLink = Media::getFileUrl($path);
                    $image = CHtml::image($imageLink, '', array('class' => 'media-hover-image'));
                    $imageStr = CJSON::encode($image);
                    if ($item['description']) {
                        $content = CJSON::encode("<span style=\"max-width: 200px;\">{$image} {$desc}</span>");
                        $imageTooltips .= "\$({$jsSelectorId}).qtip({content: {$content}, position: {my: 'top right', at: 'bottom left'}});\n";
                    } else {
                        $imageTooltips .= "\$({$jsSelectorId}).qtip({content: {$imageStr}, position: {my: 'top right', at: 'bottom left'}});\n";
                    }
                } else {
                    if ($item['description']) {
                        $content = CJSON::encode($desc);
                        $imageTooltips .= "\$({$jsSelectorId}).qtip({content: {$content}, position: {my: 'top right', at: 'bottom left'}});\n";
开发者ID:tymiles003,项目名称:X2CRM,代码行数:31,代码来源:mediaBox.php

示例15: actionChangeArea

 public function actionChangeArea()
 {
     if (!isset($_POST['id'])) {
         return;
     }
     $model = Media::model()->findByPk($_POST['id']);
     if (!$model) {
         return;
     }
     $model->med_dims = $_POST['value'];
     if ($model->save()) {
         echo 'done';
     } else {
         echo 'error';
     }
 }
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:16,代码来源:MediaController.php


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