예제 #1
0
 /**
  * Duplicate given object and copy files needed.
  * @param Object $origLayout
  */
 public function duplicateLayout($origLayout)
 {
     // Convert the orig layout to an array
     $origData = $origLayout->toArray();
     // Store this for later use
     $origType = $origData['layout_type'];
     // Unset pieces not needed and reset some pieces
     unset($origData['layout_id']);
     $origData['layout_type'] = Layouts_Model_Layout::CUSTOM;
     $layoutPath = $this->fetchLayoutPath($origType, $origData['layout_module']);
     // Set our source file
     $sourceFile = $layoutPath . $origLayout->createFilename($origData['layout_title_orig']);
     // New Path
     $newPath = $this->fetchLayoutPath(Layouts_Model_Layout::CUSTOM, $origData['layout_module']);
     // Make sure we don't have the same filename
     while (is_file($newPath . $origData['layout_filename'])) {
         $origData['layout_title'] .= ' copy';
         $origData['layout_filename'] = $origLayout->createFilename($origData['layout_title']);
     }
     $newFile = $newPath . $origData['layout_filename'];
     // Do the copy
     $copyResult = copy($sourceFile, $newFile);
     if (!$copyResult) {
         throw new FFR_Model_Exception('There was a problem copying the file.');
     }
     // Save the new DB record
     $newLayout = $this->create($origData);
     $newLayout->save();
     return true;
 }
예제 #2
0
파일: Row.php 프로젝트: yrizos/table
 /**
  * @return array
  */
 public function toArray()
 {
     $array = parent::toArray();
     $array['cells'] = array_map(function ($cell) {
         return $cell->toArray();
     }, $this->cells);
     return $array;
 }
예제 #3
0
 /**
  * Prepare params.
  *
  * @return array $params
  */
 private function prepareParams()
 {
     $params = array_merge(['loginemail' => self::$loginemail, 'password' => self::$password], $this->object->toArray(), ['thumbnail";filename="' . $this->object->getThumbnail()->getFilename() => $this->object->getThumbnail()->getData()]);
     if ($this->object->getSubimage()) {
         foreach ($this->object->getSubimage() as $image) {
             $params['subimage[]";filename="' . $image->getFilename()] = $image->getData();
         }
     }
     return $params;
 }
예제 #4
0
 /**
  * Send object.
  *
  * @param bool $isTest
  *
  * @return bool
  *
  * @throws TransportException
  * @throws InvalidParamException
  * @throws ImageException
  */
 public function send($isTest = false)
 {
     $params = $this->object->toArray();
     $aboutme = $params['aboutme'];
     unset($params['aboutme']);
     if ($isTest) {
         return true;
     }
     $this->object->setUploadedLink();
     $response = $this->request(self::$url . self::$registerApi, $params);
     $params = ['token' => $response['data']['token']];
     $params['property'] = 'aboutme';
     $params['value'] = $aboutme;
     $this->request(self::$url . self::$aboutmeApi, $params);
     /*if ($this->object->getThumbnail()) {
           $photo = $this->object->getThumbnail();
           $response = $this->request(self::$url . self::$uploadApi, ['file' => new \CURLFile($photo->getLocalFile())]);
           $this->request(self::$url . self::$photoApi, ['token' => $response['data']['token'], 'photo' => $response]);
       }*/
     return true;
 }
예제 #5
0
 public function toArray()
 {
     $array = parent::toArray();
     if (array_key_exists('Cheaters', $array)) {
         $array = array_merge($array, $array['Cheaters']);
     }
     return $array;
 }
예제 #6
0
 public function toArray()
 {
     // remove sensitive stuff
     return array_diff_key(parent::toArray(), array("id" => true, "password" => true));
 }
예제 #7
0
파일: Table.php 프로젝트: yrizos/table
 /**
  * @return array
  */
 public function toArray()
 {
     $header = $this->getHeader();
     $rows = $this->getRows();
     $c_header = count($header);
     $c_rows = !empty($rows) ? max(array_map('count', $rows)) : 0;
     $c_max = max($c_header, $c_rows);
     $header = self::fillRow($header, $c_max)->toArray();
     $rows = array_map(function ($row) use($c_max) {
         return self::fillRow($row, $c_max)->toArray();
     }, $rows);
     $array = parent::toArray();
     $array['header'] = $header;
     $array['rows'] = $rows;
     return $array;
 }