コード例 #1
0
 /**
  * Test minimizeUrl
  *
  * @return void
  */
 public function testMinimizeUrl()
 {
     $url = 'http://www.test.de';
     $this->assertEquals($url, $this->Text->minimizeUrl($url, 20));
     $url = 'http://www.test.de';
     $this->assertEquals($url, $this->Text->minimizeUrl($url, 18));
     $url = 'http://www.test.de';
     $this->assertEquals('www.test.de', $this->Text->minimizeUrl($url, 17));
     $url = 'http://www.testpage.de';
     $this->assertEquals('ww…ge.de', $this->Text->minimizeUrl($url, 10));
     $url = 'http://www.testpage.de';
     $this->assertEquals('ww...ge.de', $this->Text->minimizeUrl($url, 10, ['placeholder' => '...']));
     // without full http://
     $url = 'www.testpage.de';
     $this->assertEquals($url, $this->Text->minimizeUrl($url, 15));
     $url = 'www.testpage.de';
     $this->assertEquals('www.te…ge.de', $this->Text->minimizeUrl($url, 14));
 }
コード例 #2
0
 /**
  * @param string $val
  *
  * @return array
  */
 public function _fromList($val)
 {
     extract($this->_config);
     return Text::tokenize($val, $separator, $leftBound, $rightBound);
 }
コード例 #3
0
ファイル: Email.php プロジェクト: olmprakash/cakephp-tools
 /**
  * Add an inline attachment as blob
  *
  * Options:
  * - contentDisposition
  *
  * @param binary $content: blob data
  * @param string $filename to attach it
  * @param string $mimeType (leave it empty to get mimetype from $filename)
  * @param string $contentId (optional)
  * @param array $options Options
  * @return mixed resource $EmailLib or string $contentId
  */
 public function addEmbeddedBlobAttachment($content, $filename, $mimeType = null, $contentId = null, array $options = [])
 {
     if ($mimeType === null) {
         $ext = pathinfo($filename, PATHINFO_EXTENSION);
         $mimeType = $this->_getMimeByExtension($ext);
     }
     $options['data'] = $content;
     $options['mimetype'] = $mimeType;
     $options['contentId'] = $contentId ? $contentId : str_replace('-', '', Text::uuid()) . '@' . $this->_domain;
     $file = [$filename => $options];
     $res = $this->addAttachments($file);
     if ($contentId === null) {
         return $options['contentId'];
     }
     return $res;
 }
コード例 #4
0
 /**
  * @param int|array $bits
  * @param bool $contain
  * @return array SQL snippet.
  */
 protected function _containsBit($bits, $contain = true)
 {
     $bits = (array) $bits;
     $bitmask = $this->encodeBitmask($bits);
     $field = $this->_config['field'];
     $contain = $contain ? ' & ? = ?' : ' & ? != ?';
     $contain = Text::insert($contain, [$bitmask, $bitmask]);
     return ['(' . $this->_table->alias() . '.' . $field . $contain . ')'];
 }
コード例 #5
0
ファイル: TextTest.php プロジェクト: alescx/cakephp-tools
 public function testMaxWords()
 {
     $this->assertEquals('Taylor...', Text::maxWords('Taylor Otwell', 1));
     $this->assertEquals('Taylor___', Text::maxWords('Taylor Otwell', 1, ['ellipsis' => '___']));
     $this->assertEquals('Taylor Otwell', Text::maxWords('Taylor Otwell', 3));
 }
コード例 #6
0
 /**
  * @param string $val
  *
  * @return array
  */
 public function _fromList($val)
 {
     $separator = $this->_config['separator'];
     $leftBound = $this->_config['leftBound'];
     $rightBound = $this->_config['rightBound'];
     return Text::tokenize($val, $separator, $leftBound, $rightBound);
 }
コード例 #7
0
 /**
  * @param int|array $bits
  * @param bool $contain
  * @return array SQL snippet.
  */
 protected function _containsBit($bits, $contain = true)
 {
     $bits = (array) $bits;
     $bitmask = $this->encodeBitmask($bits);
     $field = $this->_config['field'];
     $contain = $contain ? ' & ? = ?' : ' & ? != ?';
     $contain = Text::insert($contain, [$bitmask, $bitmask]);
     // Hack for Postgres for now
     $connection = $this->_table->connection();
     $config = $connection->config();
     if (strpos($config['driver'], 'Postgres') !== false) {
         return ['("' . $this->_table->alias() . '"."' . $field . '"' . $contain . ')'];
     }
     return ['(' . $this->_table->alias() . '.' . $field . $contain . ')'];
 }