Example #1
0
 public static function boot()
 {
     parent::boot();
     static::deleted(function (MenuItem $menuItem) {
         $log = 'Menu Item \'' . Path::getFullName($menuItem->page_id) . '\' deleted from \'' . Menu::name($menuItem->menu_id) . '\'';
         $menuItem->addLogWithBackup($log, $menuItem);
     });
 }
 public function postSaveLevels()
 {
     $itemId = substr(Request::input('id'), 5);
     $item = MenuItem::find($itemId);
     if (!empty($item)) {
         $menu = Menu::find($item->menu_id);
         $item->sub_levels = Request::input('sub_level') > $menu->max_sublevel ? $menu->max_sublevel : Request::input('sub_level');
         $item->save();
         // log action
         AdminLog::new_log('Change sub levels for menu item \'' . Path::getFullName($item->page_id) . '\' in \'' . Menu::name($item->menu_id) . '\' to ' . $item->sub_levels);
         return 1;
     }
     return null;
 }
Example #3
0
 public static function getPageListView($listPages, $tree = false, $level = 1, $cat_url = '')
 {
     $listPages = is_array($listPages) ? collect($listPages) : $listPages;
     if (!$listPages->isEmpty()) {
         $pages_li = '';
         foreach ($listPages as $page) {
             if (config('coaster::admin.advanced_permissions') && !Auth::action('pages', ['page_id' => $page->id])) {
                 continue;
             }
             $permissions = [];
             $permissions['add'] = Auth::action('pages.add', ['page_id' => $page->id]) && $page->parent != -1;
             $permissions['edit'] = Auth::action('pages.edit', ['page_id' => $page->id]);
             $permissions['delete'] = Auth::action('pages.delete', ['page_id' => $page->id]);
             $permissions['group'] = Auth::action('groups.pages', ['page_id' => $page->id]);
             $permissions['galleries'] = Auth::action('gallery.edit', ['page_id' => $page->id]);
             $permissions['forms'] = Auth::action('forms.submissions', ['page_id' => $page->id]);
             $permissions['blog'] = Auth::action('system.wp_login');
             $page_lang = PageLang::preload($page->id);
             $li_info = new \stdClass();
             $li_info->leaf = '';
             $li_info->altName = '';
             if ($tree) {
                 $li_info->preview_link = $cat_url . '/' . $page_lang->url;
                 $li_info->preview_link = $li_info->preview_link == '//' ? '/' : $li_info->preview_link;
                 $childPages = self::getChildPages($page->id);
                 $li_info->leaf = self::getPageListView($childPages, true, $level + 1, $li_info->preview_link);
             } else {
                 $li_info->preview_link = Path::getFullUrl($page->id);
                 $li_info->altName = Path::getFullName($page->id);
             }
             $li_info->number_of_forms = Template::preload_blocks_of_type('form', $page->template);
             $li_info->number_of_galleries = Template::preload_blocks_of_type('gallery', $page->template);
             if (trim($page_lang->url, '/') == '' && $page->parent == 0 && $page->link == 0) {
                 $permissions['add'] = false;
             }
             if ($page->group_container > 0) {
                 $li_info->type = 'type_group';
                 $li_info->group = PageGroup::preload($page->group_container);
                 $li_info->group = $li_info->group->exists ? $li_info->group : '';
             } else {
                 if ($page->link == 1) {
                     $li_info->preview_link = $page_lang->url;
                     $li_info->type = 'type_link';
                 } else {
                     $li_info->type = 'type_normal';
                 }
                 $li_info->group = '';
             }
             if (trim($li_info->preview_link, '/') != '' && trim($li_info->preview_link, '/') == trim(config('coaster::blog.url'), '/')) {
                 $li_info->blog = route('coaster.admin.system.wp-login');
             } else {
                 $li_info->blog = '';
             }
             if (!$page->is_live()) {
                 $li_info->type = 'type_hidden';
                 if ($page->link == 0) {
                     if ($liveVersion = PageVersion::getLiveVersion($page->id)) {
                         $li_info->preview_link .= '?preview=' . $liveVersion->preview_key;
                     }
                 }
             }
             $pages_li .= View::make('coaster::partials.pages.li', array('page' => $page, 'page_lang' => $page_lang, 'li_info' => $li_info, 'permissions' => $permissions))->render();
         }
         return View::make('coaster::partials.pages.ol', array('pages_li' => $pages_li, 'level' => $level))->render();
     }
     return null;
 }
                    <th>Requested By</th>
                @endif
                @if ($show['status'])
                    <th>Status</th>
                @endif
                <th>Actions</th>
            </tr>
            </thead>

            <tbody>
            @foreach($requests as $request)
                <tr>
                    <td>{!! $request->page_version->version_id !!}</td>
                    <td>{!! $request->page_version->getName() !!}</td>
                    <?php 
$page_name = \CoasterCms\Helpers\Cms\Page\Path::getFullName($request->page_version->page_id);
?>
                    @if ($show['page'])
                        <td>{!! $page_name !!}</td>
                    @endif
                    <td>{!! $request->note !!}</td>
                    @if ($show['requested_by'])
                        <td>{!! $request->user?$request->user->email:'Undefined' !!}</td>
                    @endif
                    @if ($show['status'])
                        <td>{!! $request->status !!}</td>
                    @endif
                    <td>
                        <a href="{{ CoasterCms\Helpers\Cms\Page\Path::getFullUrl($request->page_version->page_id).'?preview='.$request->page_version->preview_key }}"
                           target="_blank"><i class="glyphicon glyphicon-eye-open itemTooltip" title="Preview"></i></a>
                        <a href="{{ route('coaster.admin.pages.edit', ['pageId' => $request->page_version->page_id, 'version' => $request->page_version->version_id]) }}"><i
 public static function preload($addMissing = false)
 {
     if (!isset(self::$_beacons)) {
         self::$_beacons = [];
         foreach (self::all() as $beacon) {
             self::$_beacons[$beacon->unique_id] = $beacon;
         }
         try {
             $devicesData = json_decode(self::_client()->request('GET', 'device')->getBody());
             $pendingConfigs = [];
             $getPendingConfigs = json_decode(self::_client()->request('GET', 'config', ['query' => ['deviceType' => 'beacon']])->getBody());
             foreach ($getPendingConfigs->configs as $pendingConfig) {
                 if (!empty($pendingConfig->url)) {
                     $pendingConfigs[$pendingConfig->uniqueId] = $pendingConfig;
                 }
             }
             foreach ($devicesData->devices as $device) {
                 if (!empty($pendingConfigs[$device->uniqueId]) && isset($device->url) && $pendingConfigs[$device->uniqueId]->url != $device->url) {
                     $device->url = $pendingConfigs[$device->uniqueId]->url;
                     $device->pending = true;
                 } else {
                     $device->pending = false;
                 }
                 if (isset(self::$_beacons[$device->uniqueId])) {
                     if (!self::$_beacons[$device->uniqueId]->visible && $addMissing) {
                         self::$_beacons[$device->uniqueId]->removed = 0;
                         self::$_beacons[$device->uniqueId]->save();
                     }
                     if (self::$_beacons[$device->uniqueId]->url != self::_getUrl($device)) {
                         self::$_beacons[$device->uniqueId]->page_id = 0;
                         self::$_beacons[$device->uniqueId]->url = self::_getUrl($device);
                         self::$_beacons[$device->uniqueId]->save();
                     }
                     self::$_beacons[$device->uniqueId]->device = $device;
                 } elseif ($addMissing) {
                     $newBeacon = new self();
                     $newBeacon->unique_id = $device->uniqueId;
                     $newBeacon->url = self::_getUrl($device);
                     $newBeacon->page_id = 0;
                     $newBeacon->removed = 0;
                     $newBeacon->save();
                     self::$_beacons[$device->uniqueId] = $newBeacon;
                     self::$_beacons[$device->uniqueId]->device = $device;
                 }
             }
             foreach (self::$_beacons as $k => $beacon) {
                 if (empty($beacon->device)) {
                     unset(self::$_beacons[$k]);
                     continue;
                 }
                 $beacon->page_name = '';
                 if ($beacon->url == self::_getUrl($beacon->device) && !empty($beacon->page_id)) {
                     $beacon->page_name = Path::getFullName($beacon->page_id);
                 } else {
                     $beacon->page_id = 0;
                 }
             }
         } catch (RequestException $e) {
             self::$_beacons = [];
             return 0;
         }
     }
     return 1;
 }
 public function getCsv($pageId = 0, $blockId = 0)
 {
     $block_data = Block::getBlockOnPage($blockId, $pageId);
     if (empty($block_data) || $block_data->type != 'form') {
         \abort('404', 'Form not found on page');
     } else {
         $csv = array();
         $columns = array();
         $column = 2;
         $row = 1;
         $submissions = FormSubmission::where('form_block_id', '=', $blockId)->orderBy('id', 'desc')->get();
         if (!$submissions->isEmpty()) {
             foreach ($submissions as $submission) {
                 $csv[$row] = array();
                 $csv[$row][0] = $submission->created_at;
                 $csv[$row][1] = !empty($submission->from_page_id) ? Path::getFullName($submission->from_page_id) : '-';
                 $form_data = @unserialize($submission->content);
                 if (!empty($form_data)) {
                     foreach ($form_data as $k => $v) {
                         if (!isset($columns[$k])) {
                             $columns[$k] = $column;
                             $column++;
                         }
                         if (is_array($v)) {
                             $v = implode(", ", $v);
                         }
                         $csv[$row][$columns[$k]] = $v;
                     }
                 } else {
                     preg_match_all('/\\"(.*?)\\";s:\\d*:\\"(.*?)\\";/si', $submission->content, $matches);
                     foreach ($matches[1] as $k => $field_key) {
                         if (!isset($columns[$field_key])) {
                             $columns[$field_key] = $column;
                             $column++;
                         }
                         $csv[$row][$columns[$field_key]] = $matches[2][$k];
                     }
                 }
                 $row++;
             }
             // add row titles
             $csv[0][0] = 'Date/Time';
             $csv[0][1] = 'Page';
             foreach ($columns as $name => $col) {
                 $csv[0][$col] = ucwords($name);
             }
             $numb_columns = count($columns);
             foreach ($csv as $row_id => $csv_row) {
                 for ($i = 0; $i < $numb_columns; $i++) {
                     if (!isset($csv_row[$i])) {
                         $csv[$row_id][$i] = '';
                     }
                 }
                 ksort($csv[$row_id]);
             }
             ksort($csv);
             $block_data = Block::find($blockId);
             header("Content-type: text/csv");
             header("Content-Disposition: attachment; filename=" . $block_data->name . ".csv");
             header("Pragma: no-cache");
             header("Expires: 0");
             $output = fopen("php://output", "w");
             foreach ($csv as $csv_row) {
                 fputcsv($output, $csv_row);
                 // here you can change delimiter/enclosure
             }
             fclose($output);
         }
         exit;
     }
 }
 /**
  * @param int $pageId
  * @param bool $noOverride
  * @param string $sep
  * @return string
  */
 public function pageFullName($pageId = 0, $noOverride = false, $sep = ' &raquo; ')
 {
     $pageId = $pageId ?: $this->pageId($noOverride);
     return $pageId ? Path::getFullName($pageId, $sep) : '';
 }