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


PHP System::__get方法代码示例

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


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

示例1: __get

 /**
  * Return an object property
  *
  * @param string $strKey The property name
  *
  * @return mixed The property value
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'size':
         case 'filesize':
             return filesize(TL_ROOT . '/' . $this->strFile);
             break;
         case 'name':
         case 'basename':
             if (!isset($this->arrPathinfo[$strKey])) {
                 $this->arrPathinfo = $this->getPathinfo();
             }
             return $this->arrPathinfo['basename'];
             break;
         case 'dirname':
         case 'filename':
             if (!isset($this->arrPathinfo[$strKey])) {
                 $this->arrPathinfo = $this->getPathinfo();
             }
             return $this->arrPathinfo[$strKey];
         case 'extension':
             if (!isset($this->arrPathinfo['extension'])) {
                 $this->arrPathinfo = $this->getPathinfo();
             }
             return strtolower($this->arrPathinfo['extension']);
             break;
         case 'origext':
             if (!isset($this->arrPathinfo['extension'])) {
                 $this->arrPathinfo = $this->getPathinfo();
             }
             return $this->arrPathinfo['extension'];
             break;
         case 'tmpname':
             return basename($this->strTmp);
             break;
         case 'path':
         case 'value':
             return $this->strFile;
             break;
         case 'mime':
             return $this->getMimeType();
             break;
         case 'hash':
             return $this->getHash();
             break;
         case 'ctime':
             return filectime(TL_ROOT . '/' . $this->strFile);
             break;
         case 'mtime':
             return filemtime(TL_ROOT . '/' . $this->strFile);
             break;
         case 'atime':
             return fileatime(TL_ROOT . '/' . $this->strFile);
             break;
         case 'icon':
             return $this->getIcon();
             break;
         case 'dataUri':
             return 'data:' . $this->mime . ';base64,' . base64_encode($this->getContent());
             break;
         case 'imageSize':
             if (empty($this->arrImageSize)) {
                 if ($this->isGdImage) {
                     $this->arrImageSize = @getimagesize(TL_ROOT . '/' . $this->strFile);
                 } elseif ($this->isSvgImage) {
                     $doc = new \DOMDocument();
                     if ($this->extension == 'svgz') {
                         $doc->loadXML(gzdecode($this->getContent()));
                     } else {
                         $doc->loadXML($this->getContent());
                     }
                     $svgElement = $doc->documentElement;
                     if ($svgElement->getAttribute('width') && $svgElement->getAttribute('height') && substr(rtrim($svgElement->getAttribute('width')), -1) != '%' && substr(rtrim($svgElement->getAttribute('height')), -1) != '%') {
                         $this->arrImageSize = array(\Image::getPixelValue($svgElement->getAttribute('width')), \Image::getPixelValue($svgElement->getAttribute('height')));
                     }
                     if ($this->arrImageSize && $this->arrImageSize[0] && $this->arrImageSize[1]) {
                         $this->arrImageSize[2] = 0;
                         // replace this with IMAGETYPE_SVG when it becomes available
                         $this->arrImageSize[3] = 'width="' . $this->arrImageSize[0] . '" height="' . $this->arrImageSize[1] . '"';
                         $this->arrImageSize['bits'] = 8;
                         $this->arrImageSize['channels'] = 3;
                         $this->arrImageSize['mime'] = $this->getMimeType();
                     } else {
                         $this->arrImageSize = false;
                     }
                 }
             }
             return $this->arrImageSize;
             break;
         case 'width':
             return $this->imageSize[0];
             break;
         case 'height':
//.........这里部分代码省略.........
开发者ID:bytehead,项目名称:core-bundle,代码行数:101,代码来源:File.php

示例2: __get

 /**
  * Return an object property
  *
  * @param string $strKey The property name
  *
  * @return mixed The property value
  */
 public function __get($strKey)
 {
     if (isset($this->arrData[$strKey])) {
         return $this->arrData[$strKey];
     }
     return parent::__get($strKey);
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:14,代码来源:User.php


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