Esempio n. 1
0
 /**
  * @expectedException \Box\Spout\Writer\Exception\InvalidSheetNameException
  * @return void
  */
 public function testSetSheetNameShouldThrowWhenNameIsAlreadyUsed()
 {
     $customSheetName = 'Sheet name';
     $sheet = new Sheet(0);
     $sheet->setName($customSheetName);
     $sheet = new Sheet(1);
     $sheet->setName($customSheetName);
 }
Esempio n. 2
0
 protected function assertRowsEqual(array $expectedRowData, Sheet $sheet)
 {
     $actualRowData = array();
     foreach ($sheet->getRows() as $rowIndex => $row) {
         foreach ($row as $column => $value) {
             $actualRowData[$rowIndex][$column] = $value;
         }
     }
     return $this->assertEquals($expectedRowData, $actualRowData, 'Sheet Rows from ' . $sheet);
 }
Esempio n. 3
0
 public function dashboard()
 {
     $user = Auth::user();
     $publicnotes = Note::where('user_id', '=', Auth::user()->id)->where('public_or_private', '=', 'public')->get();
     $privatenotes = Note::where('user_id', '=', Auth::user()->id)->where('public_or_private', '=', 'private')->get();
     $publicsheets = Sheet::where('user_id', '=', Auth::user()->id)->where('public_or_private', '=', 'public')->get();
     $privatesheets = Sheet::where('user_id', '=', Auth::user()->id)->where('public_or_private', '=', 'private')->get();
     $publicmeetups = Meetup::where('admin_id', '=', Auth::user()->id)->get();
     $yournotes = Note::where('user_id', '=', Auth::user()->id)->take(5)->get();
     $yoursheets = Sheet::where('user_id', '=', Auth::user()->id)->take(5)->get();
     $yourmeetups = Meetup::where('admin_id', '=', Auth::user()->id)->take(5)->get();
     $userlists = DB::table('sheets')->where('user_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(5);
     $usernotes = DB::table('notes')->where('user_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(5);
     $alladmin = DB::table('meetups')->where('admin_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(5);
     $allmeetups = DB::table('attendees')->where('attendee_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(5);
     $meetupsyouarepartof = [];
     if ($allmeetups != null) {
         foreach ($allmeetups as $individualmeetups) {
             $meetup = Meetup::find($individualmeetups->meetup_id);
             array_push($meetupsyouarepartof, $meetup->title);
         }
     } else {
         array_push($meetupsyouarepartof, 'You are not attending any meetups, or you are admin of all of them!');
     }
     return View::make('/users/dashboard')->with('user', $user)->with('userlists', $userlists)->with('usernotes', $usernotes)->with('alladmin', $alladmin)->with('meetupsyouarepartof', $meetupsyouarepartof)->with('publicnotes', $publicnotes)->with('privatenotes', $privatenotes)->with('publicsheets', $publicsheets)->with('privatesheets', $privatesheets)->with('publicmeetups', $publicmeetups)->with('yournotes', $yournotes)->with('yoursheets', $yoursheets)->with('yourmeetups', $yourmeetups);
 }
Esempio n. 4
0
 public function isUniqueSlug($slug)
 {
     $sheets = Sheet::all();
     foreach ($sheets as $sheet) {
         if ($sheet->slug == $slug) {
             return false;
         }
     }
     return true;
 }
 public function run()
 {
     // $user = User::firstOrFail();
     $sheet1 = new Sheet();
     $sheet1->title = 'Ancient Roman Cities';
     $sheet1->public_or_private = 'private';
     $sheet1->user_id = 1;
     $sheet1->save();
     $sheet2 = new Sheet();
     $sheet2->title = 'Ancient Egypt Vocab';
     $sheet2->public_or_private = 'public';
     $sheet2->user_id = 2;
     $sheet2->save();
     $sheet3 = new Sheet();
     $sheet3->title = 'State Birds';
     $sheet3->public_or_private = 'private';
     $sheet3->user_id = 3;
     $sheet3->save();
     $sheet4 = new Sheet();
     $sheet4->title = 'European Capitals';
     $sheet4->public_or_private = 'public';
     $sheet4->user_id = 4;
     $sheet4->save();
     $sheet5 = new Sheet();
     $sheet5->title = 'Spanish Vocab List 7';
     $sheet5->public_or_private = 'public';
     $sheet5->user_id = 5;
     $sheet5->save();
     $sheet6 = new Sheet();
     $sheet6->title = 'Biology Vocab List for Big Test';
     $sheet6->public_or_private = 'public';
     $sheet6->user_id = 3;
     $sheet6->save();
     $sheet7 = new Sheet();
     $sheet7->title = 'Ancient Rome Study Sheet';
     $sheet7->public_or_private = 'public';
     $sheet7->user_id = 1;
     $sheet7->save();
 }
Esempio n. 6
0
 function __construct($xls, $marker_block_width, $marker_block_height, $marker_offset_x, $marker_offset_y, $marker_size)
 {
     parent::__construct($xls);
     // args as disp scale(without marker window)
     $this->marker_block_width = $marker_block_width;
     $this->marker_block_height = $marker_block_height;
     $this->marker_offset_x = $marker_offset_x;
     $this->marker_offset_y = $marker_offset_y;
     $this->size_of_marker = $marker_size;
     // calc sheet size
     $this->sheet_width = 0;
     $this->sheet_height = 0;
     $width_marker_window_without_offset = $this->marker_block_width + $this->marker_offset_x;
     if ($this->marker_offset_x < 0) {
         // add offset
         $this->sheet_width += abs($this->marker_offset_x);
         $width_marker_window_without_offset = $this->marker_block_width;
     }
     if ($this->disp->tblwidth > $width_marker_window_without_offset) {
         $this->sheet_width += $this->disp->tblwidth;
     } else {
         $this->sheet_width += $width_marker_window_without_offset;
     }
     $height_marker_window_without_offset = $this->marker_block_height + $this->marker_offset_y;
     if ($this->marker_offset_y < 0) {
         // add offset
         $this->sheet_height += abs($this->marker_offset_y);
         $height_marker_window_without_offset = $this->marker_block_height;
     }
     if ($this->disp->tblheight > $height_marker_window_without_offset) {
         $this->sheet_height += $this->disp->tblheight;
     } else {
         $this->sheet_height += $height_marker_window_without_offset;
     }
     // 縮小/拡大率
     $this->marker_scale = get_scaling($this->sheet_width, $this->sheet_height, 960);
     // 表示サイズ取得
     $this->disp_sheet = new DispSheetMarker($this);
 }
Esempio n. 7
0
 private function import($args, $indexStart)
 {
     if ($this->file !== null) {
         $fileName = dirname(realpath($this->file)) . DIRECTORY_SEPARATOR . $args[0];
     } else {
         $fileName = $args[0];
     }
     $sheet = new Sheet(file_get_contents($fileName), $fileName, $this->xPath, $this->valueParser);
     return $sheet->parse($indexStart);
 }
Esempio n. 8
0
 /**
  * export and download table data as *.csv
  * this is primarily used for static tables
  * @return bool
  */
 public function exportData()
 {
     $status = false;
     if (static::$enableDataExport) {
         $tableModifier = static::getTableModifier();
         $headers = $tableModifier->getCols();
         // just get the records with existing columns
         // -> no "virtual" fields or "new" columns
         $this->fields($headers);
         $allRecords = $this->find();
         if ($allRecords) {
             $tableData = $allRecords->castAll();
             // format data -> "id" must be first key
             foreach ($tableData as &$rowData) {
                 $rowData = [$this->primary => $rowData['_id']] + $rowData;
                 unset($rowData['_id']);
             }
             $sheet = \Sheet::instance();
             $data = $sheet->dumpCSV($tableData, $headers);
             header('Expires: 0');
             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
             header('Content-Type: text/csv;charset=UTF-8');
             header('Content-Disposition: attachment;filename=' . $this->getTable() . '.csv');
             echo $data;
             exit;
         }
     }
     return $status;
 }
Esempio n. 9
0
 private function import($args, $indexStart)
 {
     if ($this->file !== null) {
         $fileName = $fileName = $this->filePath->getFilePath($args[0]);
     } else {
         $fileName = $args[0];
     }
     $this->import[] = $fileName;
     $sheet = new Sheet($fileName, $this->baseDir, $this->xPath, $this->valueParser, $this->cache, $this->filePath);
     return $sheet->parse($indexStart);
 }
Esempio n. 10
0
 public function showSheets()
 {
     $sheets = Sheet::with('lines')->where('public_or_private', '=', 'public')->orderBy('id', 'desc')->paginate(10);
     return View::make('feed.sheets')->with('sheets', $sheets);
 }
Esempio n. 11
0
		public function fromJson($obj){
			$this->bookId = $obj->bookId;
			$this->bookName =$obj->bookName;
			$this->userId = $obj->userId;

			foreach ($obj->sheets as $index => $sheet){
				$newsheet = new Sheet();
				$newsheet->fromJson($sheet);
				$newsheet->bookId=$this->bookId;
				$this->addSheet($newsheet);
			}

			if (is_array($obj->fontStyles)) {
				foreach ($obj->fontStyles as $fontStyle){
					$newFontStyle = new FontStyle();
					$newFontStyle->fromJson($fontStyle);
					$newFontStyle->bookId=$this->bookId;
					$this->addFontStyle($newFontStyle);
				}
			}
		}
 public function showeditcommentsheet($id, $commentid)
 {
     $comment = Sheetcom::find($commentid);
     $sheet = Sheet::find($id);
     if (Auth::user()->id != $comment->collaborator_id) {
         if (Auth::user()->id != $sheet->user_id) {
             Session::flash('errorMessage', 'You are not authorized to edit this comment!');
             return Redirect::action('SheetsController@show', array($id));
         }
     }
     return View::make('/collaboration/editcommentsheet')->with('comment', $comment)->with('sheet', $sheet);
 }
Esempio n. 13
0
 private function import($args, $indexStart)
 {
     $sheet = new Sheet(file_get_contents($this->baseDir . trim($args, '\'" ')), $this->baseDir, $this->valueParser, $this->prefix);
     return $sheet->parse(0, [], $indexStart);
 }
Esempio n. 14
0
 public function destroy()
 {
     $id = Auth::user()->id;
     $usertodelete = User::find($id);
     $usernotes = DB::table('notes')->where('user_id', $id);
     $allnotes = Note::all();
     $allsheets = Sheet::all();
     $allmeetups = Meetup::all();
     $usermeetups = DB::table('meetups')->where('admin_id', $id);
     $userattending = DB::table('attendees')->where('attendee_id', $id);
     $usercomments = DB::table('meetcoms')->where('attendee_id', $id);
     $usernotecomments = DB::table('notecoms')->where('collaborator_id', $id);
     $usersheetcomments = DB::table('sheetcoms')->where('collaborator_id', $id);
     $sheetids = [];
     $meetupids = [];
     $noteids = [];
     $usercomments->delete();
     $usernotecomments->delete();
     $usersheetcomments->delete();
     // Collects all notes that the user has made
     foreach ($allnotes as $note) {
         if ($note->user_id == $id) {
             array_push($noteids, $note->id);
         }
     }
     // Deletes all collaborators from any notes the user has made
     foreach ($noteids as $notes) {
         $othernotecom = DB::table('notecoms')->where('note_id', $note);
         $othernotecom->delete();
     }
     // Collects all sheets that the user has made
     foreach ($allsheets as $sheet) {
         if ($sheet->user_id == $id) {
             array_push($sheetids, $sheet->id);
         }
     }
     // deletes all lines and collaboration from others in every sheet the user has made
     foreach ($sheetids as $sheets) {
         $userline = DB::table('lines')->where('sheet_id', $sheets);
         $othersheetcom = DB::table('sheetcoms')->where('sheet_id', $sheets);
         $userline->delete();
         $othersheetcom->delete();
     }
     // Collects all meetups that the user is the admin of
     foreach ($allmeetups as $meetup) {
         if ($meetup->admin_id == $id) {
             array_push($meetupids, $meetup->id);
         }
     }
     // Removes all attendees from all meetups that the user is a part of.
     foreach ($meetupids as $meetups) {
         $peopleattending = DB::table('attendees')->where('meetup_id', $meetups);
         $peopleattending->delete();
     }
     $userattending->delete();
     $usernotes->delete();
     $userssheets = DB::table('sheets')->where('user_id', $id);
     $userssheets->delete();
     $usermeetups->delete();
     $usertodelete->delete();
     Session::flash('successMessage', 'Goodbye Forever');
     return Redirect::action('UsersController@showlogin');
 }
Esempio n. 15
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $sheet = Sheet::findOrFail($id);
     $lines = Line::with('sheet')->where('sheet_id', '=', $id);
     if (Auth::user()->id != $sheet->user_id) {
         Session::flash('errorMessage', 'You are not authorized to destroy this sheet!');
         return Redirect::action('SheetsController@index');
     }
     $notescomments = DB::table('sheetcoms')->where('sheet_id', $id);
     $notescomments->delete();
     $lines->delete();
     $sheet->delete();
     Session::flash('successMessage', 'This sheet was deleted.');
     return Redirect::route('sheets.index');
 }
Esempio n. 16
0
 private function import($args)
 {
     $sheet = new Sheet(file_get_contents($this->baseDir . trim($args, '\'" ')), $this->baseDir);
     return $sheet->parse();
 }
Esempio n. 17
0
        parent::show();
        $taskP = TASK_PATH . $_GET['task'] . '/data/';
        $tableF = $taskP . $_GET['table'];
        $infoF = $taskP . $_GET['info'];
        $detail = array(ucfirst($_GET['task']), ucfirst($_GET['table']));
        //echo $tableF;
        $table = Task::ReadTable($tableF);
        //var_dump($table);
        $header = array();
        $footer = array();
        $i = 0;
        foreach ($table[0] as $k => $v) {
            $header[] = $k;
            $footer[] = '$' . chr(65 + $i++);
        }
        //echo $infoF;
        $info = BaseFile::getFileContent($infoF);
        $info = $info ? explode("\r\n", $info) : array();
        self::setTitle($detail[1] . ' - ' . $detail[0]);
        self::$smarty->assign('historyUrl', Url::getBasePhp('History'));
        self::$smarty->assign('favoriteUrl', Url::getBasePhp('Favorite'));
        self::$smarty->assign('detail', $detail);
        self::$smarty->assign('info', $info);
        self::$smarty->assign('header', $header);
        self::$smarty->assign('footer', $footer);
        self::$smarty->assign('table', $table);
        self::$smarty->display('Sheet.tpl');
    }
}
Sheet::show();
Esempio n. 18
0
 /**
  * @param string $cell
  * @param string $range
  * @param bool $expect
  * @test
  * @dataProvider provideInRangeTestData
  */
 public function test_inRange($cell, $range, $expect)
 {
     $sheetUtil = new Sheet();
     $this->assertEquals($expect, $sheetUtil->inRange($cell, $range));
 }