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


PHP FilesModel::findOneBy方法代码示例

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


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

示例1: updateFormPaginators

 private function updateFormPaginators()
 {
     // As of Contao 3 tl_form_field.singleSRC and tl_form_field.efgBackSingleSRC use database assisted fileTree
     // .. these fields normally should have been transformed already by the Contao install routine
     if (!$this->Database->fieldExists('efgBackSingleSRC', 'tl_form_field')) {
         return;
     }
     $blnTransform = false;
     $arrTransformFields = array();
     $arrFilesDone = array();
     $sql = "SELECT singleSRC, efgBackSingleSRC FROM tl_form_field WHERE `type`='efgFormPaginator' AND ((singleSRC != '' AND singleSRC != '0') OR (efgBackSingleSRC != '' AND efgBackSingleSRC != '0'))";
     $objResult = $this->Database->prepare($sql)->execute();
     if ($objResult->numRows) {
         while ($objResult->next()) {
             if ($objResult->singleSRC != '' && !is_numeric($objResult->singleSRC)) {
                 $arrTransformFields['singleSRC'][$objResult->singleSRC] = $objResult->singleSRC;
                 $blnTransform = true;
             }
             if ($objResult->efgBackSingleSRC != '' && !is_numeric($objResult->efgBackSingleSRC)) {
                 $arrTransformFields['efgBackSingleSRC'][$objResult->efgBackSingleSRC] = $objResult->efgBackSingleSRC;
                 $blnTransform = true;
             }
         }
     }
     if (!$blnTransform) {
         return;
     }
     if (!empty($arrTransformFields)) {
         foreach ($arrTransformFields as $strField => $arrFiles) {
             if (!empty($arrFiles)) {
                 foreach ($arrFiles as $strFileOld => $strFile) {
                     if (!isset($arrFilesDone[$strFileOld])) {
                         $objFileModel = \FilesModel::findOneBy('path', $strFileOld);
                         if ($objFileModel !== null) {
                             $arrTransformFields[$strField][$strFileOld] = $objFileModel->id;
                         }
                     } else {
                         $arrTransformFields[$strField][$strFileOld] = $arrFilesDone[$strFileOld];
                     }
                     $arrFilesDone[$strFileOld] = $arrTransformFields[$strField][$strFileOld];
                 }
             }
         }
         // Update tl_form_field
         foreach ($arrTransformFields as $strField => $arrFiles) {
             if (!empty($arrFiles)) {
                 foreach ($arrFiles as $strFileOld => $strFile) {
                     if (is_numeric($strFile)) {
                         $objResult = $this->Database->prepare("UPDATE tl_form_field %s WHERE `type`='efgFormPaginator' AND " . $strField . "=?")->set(array($strField => (string) $strFile))->execute((string) $strFileOld);
                     }
                 }
             }
         }
     }
 }
开发者ID:byteworks-ch,项目名称:contao-efg,代码行数:55,代码来源:runonce.php

示例2: prepareDatabaseValueForWidget

 /**
  * Prepare database value from tl_formdata / tl_formdata_details for widget
  * @param mixed $varValue Stored value
  * @param array|boolean $arrField Form field properties (NOTE: set from dca or from tl_form_field, with differences in the structure)
  * @param mixed $varFile File
  * @return mixed
  */
 public function prepareDatabaseValueForWidget($varValue = '', $arrField = false, $varFile = false)
 {
     if (!is_array($arrField)) {
         return false;
     }
     $strType = $arrField['type'];
     if (TL_MODE == 'FE' && !empty($arrField['formfieldType'])) {
         $strType = $arrField['formfieldType'];
     } elseif (TL_MODE == 'BE' && !empty($arrField['inputType'])) {
         $strType = $arrField['inputType'];
     }
     $varVal = $varValue;
     if (in_array($strType, $this->arrFFstorable)) {
         switch ($strType) {
             case 'efgLookupCheckbox':
             case 'checkbox':
             case 'condition':
                 // conditionalforms
                 // conditionalforms
             // conditionalforms
             // conditionalforms
             case 'efgLookupRadio':
             case 'radio':
             case 'efgLookupSelect':
             case 'conditionalselect':
             case 'countryselect':
             case 'fp_preSelectMenu':
             case 'select':
                 $strSep = isset($arrField['eval']['csv']) ? $arrField['eval']['csv'] : '|';
                 if ($arrField['options']) {
                     $arrOptions = deserialize($arrField['options']);
                 } else {
                     $arrOptions = $this->prepareWidgetOptions($arrField);
                 }
                 if (is_string($varVal)) {
                     $varVal = explode($strSep, $varVal);
                 }
                 if (is_array($arrOptions)) {
                     $arrTempOptions = array();
                     foreach ($arrOptions as $sK => $mxVal) {
                         $arrTempOptions[$mxVal['value']] = $mxVal['label'];
                     }
                 }
                 if (is_array($varVal)) {
                     foreach ($varVal as $k => $v) {
                         $sNewVal = array_search($v, $arrTempOptions);
                         if ($sNewVal) {
                             $varVal[$k] = $sNewVal;
                         }
                     }
                 }
                 break;
             case 'efgImageSelect':
             case 'fileTree':
                 $strSep = isset($arrField['eval']['csv']) ? $arrField['eval']['csv'] : '|';
                 if (is_string($varVal) && strpos($varVal, $strSep) !== false) {
                     $varVal = explode($strSep, $varVal);
                 } elseif (is_array($varVal)) {
                     $varVal = array_filter($varVal);
                 } elseif (strlen($varVal)) {
                     $varVal = deserialize($varValue);
                 }
                 if (!empty($varVal)) {
                     if (is_array($varVal)) {
                         foreach ($varVal as $key => $varFile) {
                             $objFileModel = null;
                             if (\Validator::isUuid($varFile) || is_numeric($varFile)) {
                                 $objFileModel = \FilesModel::findById($varFile);
                             } else {
                                 $objFileModel = \FilesModel::findOneBy('path', $varFile);
                             }
                             if ($objFileModel !== null) {
                                 $varVal[$key] = TL_MODE == 'FE' ? $objFileModel->path : $objFileModel->uuid;
                             }
                         }
                     } elseif (is_string($varVal)) {
                         $objFileModel = null;
                         if (\Validator::isUuid($varVal) || is_numeric($varVal)) {
                             $objFileModel = \FilesModel::findById($varVal);
                         } else {
                             $objFileModel = \FilesModel::findOneBy('path', $varVal);
                         }
                         if ($objFileModel !== null) {
                             $varVal = TL_MODE == 'FE' ? $objFileModel->path : $objFileModel->uuid;
                         }
                     }
                 }
                 break;
             case 'cm_alternative':
                 // cm_alternativeforms
                 if ($arrField['options']) {
                     $arrOptions = deserialize($arrField['options']);
                 } else {
//.........这里部分代码省略.........
开发者ID:Jobu,项目名称:core,代码行数:101,代码来源:Formdata.php

示例3: getMetadata

 /**
  * {@inheritDoc}
  */
 public function getMetadata($pathOrUuid)
 {
     $path = $this->convertToPath($pathOrUuid);
     $this->guardNoInvalidUuid($pathOrUuid, $path);
     $this->guardInUploadPath($path);
     $metadata = $this->adapter->getMetadata($path);
     if ($metadata) {
         if (\Validator::isUuid($pathOrUuid)) {
             $model = \FilesModel::findByUuid($pathOrUuid);
         } else {
             $model = \FilesModel::findOneBy('path', $path);
         }
         if ($model) {
             $metadata['id'] = (int) $model->id;
             $metadata['uuid'] = \String::binToUuid($model->uuid);
             $metadata['hash'] = $model->hash;
             $metadata['meta'] = deserialize($model->meta, true);
             $metadata['importantPart'] = array('x' => $model->importantPartX, 'y' => $model->importantPartY, 'width' => $model->importantPartWidth, 'height' => $model->importantPartHeight);
         }
     }
     return $metadata;
 }
开发者ID:netzmacht,项目名称:contao-flysystem,代码行数:25,代码来源:DbafsAdapter.php


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