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


PHP Formatter::truncateText方法代码示例

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


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

示例1: getCredentialOptions

 /**
  * @param CModel $model Model whose attribute is being used to specify a set of credentials
  * @param string $name Attribute storing the ID of the credentials record
  * @param string $type Keyword specifying the "service type" (i.e. "email" encompasess 
  *  credentials 
  *  with modelClass "EmailAccount" and "GMailAccount"
  * @param integer $uid The user ID or system role ID for which the input is being generated
  * @param array $htmlOptions HTML options to pass to {@link CHtml::activeDropDownList()}
  * @param boolean $getNameEmailsArr if true, returned array will include array indexed by 
  *  credId which 
  *  contains associated email and name
  * @return array containing values which can be used to instantiate an activeDropDownList.
  *  This inludes an array of credential names as well an array of the options' selected 
  *  attributes.
  */
 public static function getCredentialOptions($model, $name, $type = 'email', $uid = null, $htmlOptions = array(), $excludeLegacy = false, $imapOnly = false)
 {
     // First get credentials available to the user:
     $defaultUserId = in_array($uid, self::$sysUseId) ? $uid : ($uid !== null ? $uid : Yii::app()->user->id);
     // The "user" (actual user or system role)
     $uid = Yii::app()->user->id;
     // The actual user
     // Users can always use their own credentials, it's assumed
     $criteria = new CDbCriteria(array('params' => array(':uid' => $uid)));
     $staticModel = self::model();
     $staticModel->userId = self::SYS_ID;
     $criteria->addCondition('userId=:uid');
     // Exclude accounts types that do not support IMAP if requested
     if ($imapOnly) {
         $criteria->addInCondition('modelClass', self::$imapModels);
     }
     // Include system-owned credentials
     if (Yii::app()->user->checkAccess('CredentialsSelectSystemwide', array('model' => $staticModel))) {
         $criteria->addCondition('userId=' . self::SYS_ID, 'OR');
     } else {
         // Select the user's own default
         $defaultUserId = $uid;
     }
     $staticModel->private = 0;
     // Include non-private credentials if the user has access to them
     if (Yii::app()->user->checkAccess('CredentialsSelectNonPrivate', array('model' => $staticModel))) {
         $criteria->addCondition('private=0', 'OR');
     }
     /* Cover only credentials for the given type of third-party service for which the selector 
        field is being used: */
     $criteria->addInCondition('modelClass', $staticModel->defaultSubstitutes[$type]);
     $credRecords = $staticModel->findAll($criteria);
     $credentials = array();
     if ($model === null || $model->{$name} == null) {
         // Figure out which one is default since it hasn't been set yet
         $defaultCreds = $staticModel->getDefaultCredentials();
         if ($type == 'email') {
             $selectedCredentials = self::LEGACY_ID;
         }
         if (array_key_exists($defaultUserId, $defaultCreds)) {
             if (array_key_exists($type, $defaultCreds[$defaultUserId])) {
                 $selectedCredentials = $defaultCreds[$defaultUserId][$type];
             }
         }
     } else {
         // Use the one previously set
         $selectedCredentials = $model->{$name};
     }
     // Compose options for the selector
     foreach ($credRecords as $cred) {
         $credentials[$cred->id] = $cred->name;
         if ($type == 'email') {
             $credentials[$cred->id] = Formatter::truncateText($credentials[$cred->id] . ' : "' . $cred->auth->senderName . '" <' . $cred->auth->email . '>', 50);
         }
     }
     if ($type == 'email' && !$excludeLegacy) {
         // Legacy email delivery method(s)
         $credentials[self::LEGACY_ID] = Yii::t('app', 'System default (legacy)');
     }
     $options = array();
     $selectedOption = $selectedCredentials;
     foreach ($credentials as $credId => $label) {
         if ($credId == $selectedCredentials) {
             $options[$credId] = array('selected' => 'selected');
         } else {
             $options[$credId] = array('selected' => false);
         }
     }
     if ($type == 'email') {
         $options[self::LEGACY_ID]['class'] = 'legacy-email';
     }
     $htmlOptions['options'] = $options;
     $retDict = array('credentials' => $credentials, 'htmlOptions' => $htmlOptions, 'selectedOption' => $selectedOption);
     return $retDict;
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:90,代码来源:Credentials.php

示例2: getName

 public function getName()
 {
     if (!empty($this->subject)) {
         return $this->subject;
     } else {
         if ($this->type == 'email') {
             return Formatter::parseEmail($this->actionDescription);
         } else {
             return Formatter::truncateText($this->actionDescription, 40);
         }
     }
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:12,代码来源:Actions.php

示例3: assertRecursiveCcopy

 /**
  * Make sure ccopy can properly create subdirectories and follows all
  * expected behavior.
  *
  * Note, per the specification of ccopy, relTarget cannot be enabled when
  * the target path given is relative. When $C, test-FileUtil-subdir should
  * be filled with the contents of the test directory. When not $C, it should
  * contain a copy of the test directory itself.
  *
  * @param bool $SR source path given is relative
  * @param bool $TR target path given is relative
  * @param bool $RT enable $relTarget argument
  * @param bool $C enbale $contents argument
  * @param bool $tss include trailing slash in the source path
  * @param bool $tst include trailing slash in the target path
  */
 public function assertRecursiveCcopy($SR, $TR, $RT, $C, $tss, $tst)
 {
     // A thing to note: the current working directory is protected/tests
     $relSource = implode(DIRECTORY_SEPARATOR, array('data', 'output', 'test-' . $this->testTime));
     $absSource = realpath('.') . DIRECTORY_SEPARATOR . $relSource;
     $relTarget = implode(DIRECTORY_SEPARATOR, array('..', 'test-FileUtil', 'test-FileUtil-subdir'));
     $absTarget = implode(DIRECTORY_SEPARATOR, array(Yii::app()->basePath, 'test-FileUtil', 'test-FileUtil-subdir'));
     $source = $SR ? $relSource : $absSource;
     $target = $TR ? $relTarget : $absTarget;
     $source .= $tss ? DIRECTORY_SEPARATOR : '';
     $target .= $tst ? DIRECTORY_SEPARATOR : '';
     // Run the copy operation:
     if (self::CCOPY_VERBOSE) {
         echo "copying " . Formatter::truncateText($source) . " to " . Formatter::truncateText($target);
     }
     FileUtil::ccopy($source, $target, $RT, $C);
     $basePath = $target;
     if (!$C) {
         $basePath = rtrim($basePath, DIRECTORY_SEPARATOR);
         $basePath .= DIRECTORY_SEPARATOR . 'test-' . $this->testTime;
     }
     // Check that the base path was copied:
     $this->assertTrue(is_dir($basePath), "Target base path {$basePath} not created.");
     foreach (array_merge($this->files, $this->subDirs) as $path) {
         $this->assertFileExists($basePath . DIRECTORY_SEPARATOR . FileUtil::rpath($path), "File/directory {$path} not copied.");
     }
     // Done.
     FileUtil::rrmdir(implode(DIRECTORY_SEPARATOR, array(Yii::app()->basePath, 'test-FileUtil')));
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:45,代码来源:FileUtilTest.php


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