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


PHP AdminHelper::objectToArray方法代码示例

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


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

示例1: getParentData

 public function getParentData($modelConfig = NULL)
 {
     $parentIdProperty = NULL;
     $parentId = NULL;
     $parent = NULL;
     $parentObject = NULL;
     $parentFound = false;
     $allParents = NULL;
     $reflection = new \ReflectionClass($this);
     $objectClass = $reflection->getShortName();
     if (!$modelConfig) {
         $modelConfig = AdminHelper::modelExists($objectClass);
     }
     if ($modelConfig->getModelParents() || $modelConfig->parent) {
         $parentIdProperties = AdminHelper::objectToArray($modelConfig->getModelParents());
         if (!$parentIdProperties) {
             $parentIdProperties = array($modelConfig->parent->property);
         }
         if (!empty($_GET)) {
             foreach ($_GET as $parentIdProperty => $id) {
                 if (in_array($parentIdProperty, $parentIdProperties) && is_numeric($id)) {
                     /** @var ModelConfig $parentModelConfig */
                     $parentModelConfig = AdminHelper::modelExists($parentIdProperty, 'id');
                     /** @var BaseModel $parentModel */
                     $parentModel = $parentModelConfig->myFullEntityName();
                     $parentObject = $parentModel::find($id);
                     if ($parentObject) {
                         $parentId = $id;
                         $parentFound = true;
                         if ($modelConfig->standalone === false || isset($_GET['addToParent'])) {
                             $allParents[$parentIdProperty] = $id;
                         }
                     } else {
                         $parentIdProperty = NULL;
                         $parentObject = NULL;
                     }
                 } else {
                     $parentIdProperty = NULL;
                 }
                 // Break after first iteration because first $_GET must be the parent
                 break;
             }
         }
         if (!empty($_POST)) {
             foreach ($_POST as $parentIdPropertyFromPost => $idFromPost) {
                 if (in_array($parentIdPropertyFromPost, $parentIdProperties) && is_numeric($idFromPost)) {
                     /** @var ModelConfig $parentModelConfig */
                     $parentModelConfig = AdminHelper::modelExists($parentIdPropertyFromPost, 'id');
                     $parentModel = $parentModelConfig->myFullEntityName();
                     /** @var BaseModel $parentModel */
                     $parentObject = $parentModel::find($idFromPost);
                     if ($parentObject) {
                         $allParents[$parentIdPropertyFromPost] = $idFromPost;
                     }
                 }
             }
         }
     }
     if (!$parentFound && $modelConfig->index == 'tree') {
         $parentIdProperty = $modelConfig->parent->property;
         $parentId = $this->{$parentIdProperty};
     }
     $data = array('parentIdProperty' => $parentIdProperty, 'parentId' => $parentId, 'parent' => $parent, 'parentObject' => $parentObject, 'allParents' => $allParents);
     return $data;
 }
开发者ID:gtcrais,项目名称:gtcms,代码行数:65,代码来源:BaseModel.php

示例2: trans

             if ($dimensions[2] == 'minWidth') {
                 $infoSpans .= "<span class='info " . $infoWidthClass . "'>" . trans('gtcms.minimumDimensions') . ": <strong>" . $dimensions[0] . "px width</strong></span>";
             } else {
                 if ($dimensions[2] == 'minHeight') {
                     $infoSpans .= "<span class='info " . $infoWidthClass . "'>" . trans('gtcms.minimumDimensions') . ": <strong>" . $dimensions[1] . "px height</strong></span>";
                 } else {
                     $infoSpans .= "<span class='info " . $infoWidthClass . "'>" . trans('gtcms.minimumDimensions') . ": <strong>" . $dimensions[0] . "px</strong> x <strong>" . $dimensions[1] . "px</strong></span>";
                 }
             }
         }
     } else {
         if ($type == 'image' && $modelConfig->name != 'ModelImage') {
             foreach ($field->sizes as $size) {
                 break;
             }
             $dimensions = AdminHelper::objectToArray($size);
             if ($dimensions[2] == 'resize') {
                 $infoSpans .= "<span class='info " . $infoWidthClass . "'>" . trans('gtcms.minimumDimensions') . ": <strong>" . (is_null($dimensions[0]) ? 1 : $dimensions[0]) . "px width</strong> OR <strong>" . (is_null($dimensions[1]) ? 1 : $dimensions[1]) . "px height</strong></span>";
             } else {
                 $infoSpans .= "<span class='info " . $infoWidthClass . "'>" . trans('gtcms.minimumDimensions') . ": <strong>" . (is_null($dimensions[0]) ? 1 : $dimensions[0]) . "px</strong> x <strong>" . (is_null($dimensions[1]) ? 1 : $dimensions[1]) . "px</strong></span>";
             }
         }
     }
 }
 if ($field->specialInfo) {
     $infoSpans .= "<span class='info specialInfo  " . $infoWidthClass . "'>" . $field->specialInfo . "</span>";
 }
 $ctrlGroup = " " . $containerClass;
 $property = $field->property;
 if ($add && $field->default) {
     $originalValue = $field->default;
开发者ID:gtcrais,项目名称:gtcms,代码行数:31,代码来源:editContentFormFields.blade.php

示例3: firstParamIsParent

 public static function firstParamIsParent(ModelConfig $modelConfig, $returnParentIdValue = false)
 {
     if ($modelConfig->getModelParents() || $modelConfig->parent) {
         $parentIdProperties = AdminHelper::objectToArray($modelConfig->getModelParents());
         if (!$parentIdProperties) {
             $parentIdProperties = array($modelConfig->parent->property);
         }
         if (!empty($_GET)) {
             foreach ($_GET as $parentIdProperty => $id) {
                 if (in_array($parentIdProperty, $parentIdProperties) && is_numeric($id)) {
                     if ($returnParentIdValue) {
                         return $id;
                     }
                     return $parentIdProperty;
                 }
                 // Break after first iteration because first $_GET must be the parent
                 break;
             }
         }
     }
     return false;
 }
开发者ID:gtcrais,项目名称:gtcms,代码行数:22,代码来源:AdminHelper.php

示例4: getFormFields

 public function getFormFields($fieldType, $parseFromTo = false)
 {
     if ($parseFromTo && !$this->fromToParsed) {
         $formFields = array();
         foreach ($this->formFields as $field) {
             if ($field->fromTo && $field->search) {
                 $newField = AdminHelper::objectToArray($field);
                 $newField['hidden'] = array('add' => true, 'edit' => true, 'view' => true);
                 $fromField = $newField;
                 $fromField['property'] = $field->property . "_fieldFrom";
                 $fromField['label'] = $newField['label'] . " " . trans('gtcms.from');
                 if (isset($fromField['search']['label'])) {
                     $fromField['search']['label'] = $fromField['search']['label'] . " " . trans('gtcms.from');
                 }
                 $fromField['search']['fieldFrom'] = true;
                 $fromField['table'] = false;
                 $fromField['sideTable'] = false;
                 $fromField = AdminHelper::arrayToObject($fromField);
                 $toField = $newField;
                 $toField['property'] = $field->property . "_fieldTo";
                 $toField['label'] = $newField['label'] . " " . trans('gtcms.to');
                 if (isset($toField['search']['label'])) {
                     $toField['search']['label'] = $toField['search']['label'] . " " . trans('gtcms.to');
                 }
                 $toField['search']['fieldTo'] = true;
                 $toField['table'] = false;
                 $toField['sideTable'] = false;
                 $toField = AdminHelper::arrayToObject($toField);
                 $formFields[] = $fromField;
                 $formFields[] = $toField;
                 $field->search = false;
                 $formFields[] = $field;
             } else {
                 $formFields[] = $field;
             }
         }
         $this->fromToParsed = true;
         $this->formFields = $formFields;
     }
     if ($fieldType == 'all') {
         return $this->formFields;
     } else {
         if ($fieldType == 'regular') {
             $fields = array();
             foreach ($this->formFields as $field) {
                 if (!$field->langDependent) {
                     $fields[] = $field;
                 }
             }
             return $fields;
         } else {
             if ($fieldType == 'langDependent') {
                 $fields = array();
                 foreach ($this->formFields as $field) {
                     if (config('gtcms.premium') && $field->langDependent) {
                         $fields[] = $field;
                     }
                 }
                 return $fields;
             } else {
                 Dbar::error("ModelConfig - getFormFields: fieldType is incorrect! - " . $fieldType);
             }
         }
     }
     return false;
 }
开发者ID:gtcrais,项目名称:gtcms,代码行数:66,代码来源:ModelConfig.php

示例5: process

 public static function process($modelConfig, $imageFields, $parentProperty)
 {
     $imageData = array();
     $counter = 0;
     foreach ($imageFields as $imageField) {
         $imageData[$counter]['property'] = $imageField->property;
         if (\Request::hasFile($imageField->property)) {
             $ext = \Request::file($imageField->property)->getClientOriginalExtension();
             if (!in_array(strtolower($ext), array('jpg', 'jpeg', 'gif', 'png'))) {
                 throw new \Exception("File is not an image");
             } else {
                 $basePath = public_path() . "/img/modelImages/" . $modelConfig->name . "/";
                 $dirs = [public_path("img"), public_path("img/modelImages"), public_path("img/modelImages/" . $modelConfig->name), public_path("img/modelImages/" . $modelConfig->name . "/original"), public_path("img/modelImages/" . $modelConfig->name . "/gtcmsThumb")];
                 foreach ($dirs as $dir) {
                     if (!is_dir($dir)) {
                         mkdir($dir, 0755);
                     }
                 }
                 //here check if file exists
                 do {
                     $name = str_random(32) . "." . $ext;
                 } while (file_exists($basePath . "original/" . $name));
                 //end check
                 //copy the image to the original folder
                 \Image::make(\Request::file($imageField->property)->getRealPath())->save($basePath . "original/" . $name);
                 $img = \Image::make($basePath . "original/" . $name);
                 if ($parentProperty && $modelConfig->name == 'ModelImage') {
                     $parentModelConfig = AdminHelper::modelExists($parentProperty, 'id');
                     if (config('gtcms.premium') && $parentModelConfig->keyBasedSizes) {
                         $sizes = GtcmsPremium::getKeyBasedImageSizes($parentModelConfig);
                     } else {
                         $sizes = $parentModelConfig->imageSizes;
                     }
                 } else {
                     $sizes = $imageField->sizes;
                 }
                 if (!$sizes) {
                     throw new \Exception("Sizes not found!");
                 }
                 // Get the first size, which has the min/max dimensions
                 foreach ($sizes as $size) {
                     break;
                 }
                 $size = AdminHelper::objectToArray($size);
                 $minWidth = $size[0];
                 $minHeight = $size[1];
                 $transformMethod = $size[2];
                 if (in_array($transformMethod, array('resizeCanvas', 'resize'))) {
                     if ($img->width() < $minWidth && $img->height() < $minHeight) {
                         throw new \Exception(trans('gtcms.imageTooSmall'), self::DIM_ERROR);
                     }
                 }
                 if (in_array($transformMethod, array('minWidth'))) {
                     if ($img->width() < $minWidth) {
                         throw new \Exception(trans('gtcms.imageTooSmall'), self::DIM_ERROR);
                     }
                 }
                 if (in_array($transformMethod, array('minHeight'))) {
                     if ($img->height() < $minHeight) {
                         throw new \Exception(trans('gtcms.imageTooSmall'), self::DIM_ERROR);
                     }
                 } else {
                     if ($img->width() < $minWidth || $img->height() < $minHeight) {
                         throw new \Exception(trans('gtcms.imageTooSmall'), self::DIM_ERROR);
                     }
                 }
                 $returnFolder = 'gtcmsThumb';
                 $gtcmsSize = array(80, 80, 'resizeCanvas', 'gtcmsThumb', 100);
                 $sizes = AdminHelper::objectToArray($sizes);
                 array_unshift($sizes, $gtcmsSize);
                 foreach ($sizes as $size) {
                     $newImg = clone $img;
                     $size = AdminHelper::objectToArray($size);
                     if (!is_dir($basePath . $size[3])) {
                         mkdir($basePath . $size[3], 0755);
                     }
                     if ($size[2] == 'crop') {
                         $newImg->fit($size[0], $size[1])->save($basePath . $size[3] . "/" . $name, $size[4]);
                     } else {
                         if (in_array($size[2], array('resize', 'minWidth', 'minHeight'))) {
                             $newImg->resize($size[0], $size[1], function ($constraint) {
                                 $constraint->aspectRatio();
                                 $constraint->upsize();
                             })->save($basePath . $size[3] . "/" . $name, $size[4]);
                         } else {
                             if ($size[2] == 'resizeCanvas') {
                                 $newImg->resize($size[0], null, function ($constraint) {
                                     $constraint->aspectRatio();
                                     $constraint->upsize();
                                 });
                                 $newImg->resize(null, $size[1], function ($constraint) {
                                     $constraint->aspectRatio();
                                     $constraint->upsize();
                                 });
                                 if ($newImg->width() < $size[0] || $newImg->height() < $size[1]) {
                                     $newImg = \Image::canvas($size[0], $size[1], '#FFFFFF')->insert($newImg, 'center');
                                 }
                                 $newImg->save($basePath . $size[3] . "/" . $name, $size[4]);
                             } else {
                                 $newImg->save($basePath . $size[3] . "/" . $name, $size[4]);
//.........这里部分代码省略.........
开发者ID:gtcrais,项目名称:gtcms,代码行数:101,代码来源:ImageHandler.php


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