예제 #1
0
 public static function getAllMeta($objectId, $metaKey, $valueWhere = false)
 {
     $obj = ObjectMeta::where('object_id', $objectId)->where('meta_key', $metaKey);
     if ($valueWhere) {
         $obj->where('meta_value', $valueWhere);
     }
     return $obj;
 }
예제 #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param $id
  * @return Response
  */
 public function postDelete(DeleteRequest $request, $id)
 {
     if ($object = object::find($id)) {
         $object->delete();
         ObjectMeta::where('object_id', $id)->delete();
         return redirect('admin/objects')->with('message', 'Type deleted successfully');
     }
 }
예제 #3
0
                    echo '<div style="color: cornflowerblue; font-family: Arial, Helvetica, sans-serif;">' . '<div style="float: left; padding: 20px 10px 5px 5px;">' . '<span> #' . $index . '</span>' . '</div>' . '<div style="float: left;">' . '<span>ID: </span>' . $item['id'] . '<br>' . '<span>File name: </span>' . $item['filename'] . '<br>' . '<span>Error message: </span>' . $item['error'] . '</div>' . '</div>';
                    echo '<br>';
                }
            }
        }
    }
    if ($refreshThisPage) {
        die('<meta http-equiv="refresh" content="2">');
    } else {
        die('Done!');
    }
});
/* Crop and resize images */
Route::get('/crop', function () {
    ini_set('memory_limit', '1G');
    $results = \App\ObjectMeta::where('object_meta.meta_key', '_file_path')->join('object_meta AS om', function ($join) {
        $join->on('object_meta.object_id', '=', 'om.object_id')->where('om.meta_key', '=', '_image_info');
    })->join('object_meta AS om2', 'object_meta.object_id', '=', 'om2.meta_value')->join('objects as obj', 'obj.id', '=', 'om2.object_id')->select('object_meta.object_id', 'object_meta.meta_value AS path', 'om2.meta_key AS type', 'om2.object_id AS parentObjectID', 'obj.type AS parentObjectType')->groupBy('path')->get();
    //    dd($results->get()->toArray());
    if (isset($_GET['type']) && $_GET['type'] == 'content') {
        $content = $results->reject(function (&$v) {
            $v->info = unserialize($v->info);
            return $v->type == '_featured_image';
        });
        ini_set('max_execution_time', 300);
        $failed = array();
        foreach ($content as $image) {
            $x = autoCrop(0, $image->path, $image->type);
            //            echo $image->path . '<br>';
            //            echo $image->type . '<br>';
            //            var_dump($x);
예제 #4
0
 private function processObject2(&$object, $getAll = true)
 {
     $objectData = ObjectMeta::where('object_id', '=', $object->id)->orWhere('object_id', '=', $object->objectTypeID)->get();
     $objectFinal = $object->toArray();
     if ($getAll) {
         $objectTypeData = $objectData->filter(function ($v) use($object) {
             if ($v->object_id == $object->objectTypeID) {
                 return true;
             }
             return false;
         });
         foreach ($objectTypeData as $item) {
             // Get categories
             if ($item->meta_key == '_category_id') {
                 if (isset($objectFinal['categories'])) {
                     $objectFinal['categories'][] = $item->meta_value;
                 } else {
                     $objectFinal['categories'] = array($item->meta_value);
                 }
                 continue;
             }
             // Get fields
             if (strpos($item->meta_key, '_field_') === 0) {
                 $content = unserialize($item->meta_value);
                 if (isset($objectFinal['fields'])) {
                     $objectFinal['fields'][$content['name']] = $content;
                 } else {
                     $objectFinal['fields'] = array($content['name'] => $content);
                 }
             }
         }
     }
     //        dd($objectFinal);
     $objectData = $objectData->filter(function ($v) use($object) {
         if ($v->object_id == $object->id) {
             return true;
         }
         return false;
     });
     $objectFinal['map'] = false;
     //        dd($objectData->toArray());
     foreach ($objectData as $item) {
         $itemKey = $item->meta_key;
         $itemVal = $item->meta_value;
         // Address
         if (strpos($itemKey, '_field_address') === 0) {
             // Get the current key
             $key = str_replace(array('_field_address-'), '', $itemKey);
             // check if map exists
             if ($key == 'location-g' || $key == 'location-k') {
                 if ($itemVal == '') {
                     $objectFinal['map'] = false;
                 } else {
                     $objectFinal['map'] = true;
                 }
                 $key = str_replace('-', '_', $key);
             }
             // add the current address data to the array
             if (isset($objectFinal['address'])) {
                 $objectFinal['address'][$key] = $itemVal;
             } else {
                 $objectFinal['address'] = array($key => $itemVal);
             }
             continue;
         }
         // Images
         if ($itemKey == '_content_image' || $itemKey == '_featured_image') {
             $objectFinal[$itemKey] = 'cropped/' . getTheImageSize(getImageSrc($itemVal), $itemKey);
             //                $objectFinal[$itemKey] = getImageSrc($itemVal, 'medium');
             continue;
         }
         if ($getAll) {
             // Set phone
             if ($itemKey == '_field_phone') {
                 $objectFinal['phone'] = $itemVal;
                 continue;
             }
             // Set email
             if ($itemKey == '_field_email') {
                 $objectFinal['phone'] = $itemVal;
                 continue;
             }
             /* Get more info */
             if ($itemKey == '_field_occupation' && trim($itemVal) != '') {
                 //                        var_dump($itemVal);
                 if (isset($objectFinal['more'])) {
                     array_unshift($objectFinal['more'], array('type' => 'text', 'key' => 'Occupation', 'value' => $itemVal));
                 } else {
                     $objectFinal['more'] = array(array('type' => 'text', 'key' => 'Occupation', 'value' => $itemVal));
                 }
                 continue;
             }
             if ($itemKey == '_field_french_speakers' && (bool) $itemVal) {
                 if (isset($objectFinal['more'])) {
                     array_unshift($objectFinal['more'], array('type' => 'checkbox', 'key' => 'francophone', 'value' => (bool) $itemVal));
                 } else {
                     $objectFinal['more'] = array(array('type' => 'checkbox', 'key' => 'francophone', 'value' => (bool) $itemVal));
                 }
                 continue;
             }
             // extra fields
             if (strpos($itemKey, '_field_') === 0) {
                 $key = str_replace('_field_', '', $itemKey);
                 if (isset($objectFinal['fields'][$key])) {
                     $current = $objectFinal['fields'][$key];
                     $type = $current['type'];
                     $label = $current['label'];
                     $ignoreTypes = array('select', 'radio', 'map');
                     if (in_array($type, $ignoreTypes)) {
                         continue;
                     }
                     if (!(bool) $itemVal || !trim($itemVal)) {
                         continue;
                     }
                     if (isset($objectFinal['more'])) {
                         $objectFinal['more'][] = array('type' => $type, 'key' => $label, 'value' => $type == 'checkbox' ? (bool) $itemVal : $itemVal);
                     } else {
                         $objectFinal['more'] = array(array('type' => $type, 'key' => $label, 'value' => $type == 'checkbox' ? (bool) $itemVal : $itemVal));
                     }
                 }
             }
         }
     }
     if ($getAll) {
         $objectFinal['hasContact'] = (bool) (isset($objectFinal['email']) && $objectFinal['email']) || isset($objectFinal['phone']) && $objectFinal['phone'];
         $objectFinal['hasContactAddress'] = (bool) isset($objectFinal['address']) && (isset($objectFinal['address']['address']) && $objectFinal['address']['address'] || isset($objectFinal['address']['city']) && $objectFinal['address']['city']);
         $objectFinal['hasMore'] = (bool) isset($objectFinal['more']);
     }
     unset($objectFinal['fields']);
     $object = $objectFinal;
 }
예제 #5
0
 public static function getFields($id)
 {
     return ObjectMeta::where('object_id', $id)->where('meta_key', 'LIKE', '_field_%');
 }
예제 #6
0
 public static function getMeta($objectId, $metaKey)
 {
     return ObjectMeta::where('object_id', $objectId)->where('meta_key', $metaKey)->first();
 }
예제 #7
0
파일: Object.php 프로젝트: Avimunk/jini_1
 public static function getField($id, $name)
 {
     return ObjectMeta::where('object_id', $id);
     //->where('meta_key', '=', '_field_'. $name);
 }
예제 #8
0
 public function getCategories($id)
 {
     if ($objectType = Object::find($id)) {
         $categories = ObjectMeta::where('object_id', $id)->where('meta_key', '_category_id')->select(array('id', 'meta_value'))->get();
         //$cc
         $c = array();
         foreach ($categories as $categoryId) {
             $c[] = $categoryId->meta_value;
         }
         $categories = Object::where('type', 'category')->whereIn('id', $c)->select('id', 'title')->get();
         return Datatables::of($categories)->add_column('actions', '<a href="{{{ URL::to(\'admin/object-types/\' . $id . \'/delete\' ) }}}" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash"></span> {{ trans("admin/modal.delete") }}</a>')->remove_column('id')->make();
     }
     //        $objecttypes = ObjectType::select(array('object_types.id','object_types.name','object_types.display_name', 'object_types.created_at'));
     //
     //        return Datatables::of($objecttypes)
     //            ->add_column('actions', '@if ($id>"4")<a href="{{{ URL::to(\'admin/object-types/\' . $id . \'/edit\' ) }}}" class="btn btn-success btn-sm" ><span class="glyphicon glyphicon-pencil"></span>  {{ trans("admin/modal.edit") }}</a>
     //                    <a href="{{{ URL::to(\'admin/object-types/\' . $id . \'/delete\' ) }}}" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash"></span> {{ trans("admin/modal.delete") }}</a>
     //                @endif')
     //            ->remove_column('id')
     //
     //            ->make();
 }
예제 #9
0
 public function getCategories($id)
 {
     if ($objectType = Object::find($id)) {
         $this->fetchCategories();
         $this->itemArray();
         $categoriesOrig = $this->items->getDictionary();
         $categories = ObjectMeta::where('object_id', $id)->where('meta_key', '_category_id')->select(array('id', 'meta_value'))->get();
         //$cc
         $c = array();
         foreach ($categories as $categoryId) {
             $c[] = $categoryId->meta_value;
         }
         $categories = Object::where('type', 'category')->whereIn('id', $c)->select('id', 'title')->get();
         foreach ($categories as &$v) {
             $v->title = '';
             if (isset($this->itemsParents[$v->id])) {
                 foreach ($this->itemsParents[$v->id] as $item_id) {
                     if (isset($categoriesOrig[$item_id])) {
                         $v->title .= ($v->title ? ' \\ ' : '') . $categoriesOrig[$item_id]->title;
                     }
                 }
             }
         }
         return Datatables::of($categories)->add_column('actions', '<a href="{{{ URL::to(\'admin/object-types/' . $id . '/deleteCategory/\' . $id ) }}}" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash"></span> {{ trans("admin/modal.delete") }}</a>')->remove_column('id')->make();
     }
     //        $objecttypes = ObjectType::select(array('object_types.id','object_types.name','object_types.display_name', 'object_types.created_at'));
     //
     //        return Datatables::of($objecttypes)
     //            ->add_column('actions', '@if ($id>"4")<a href="{{{ URL::to(\'admin/object-types/\' . $id . \'/edit\' ) }}}" class="btn btn-success btn-sm" ><span class="glyphicon glyphicon-pencil"></span>  {{ trans("admin/modal.edit") }}</a>
     //                    <a href="{{{ URL::to(\'admin/object-types/\' . $id . \'/delete\' ) }}}" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash"></span> {{ trans("admin/modal.delete") }}</a>
     //                @endif')
     //            ->remove_column('id')
     //
     //            ->make();
 }