Example #1
0
 public function toArray()
 {
     $array = array('title' => $this->title);
     if ($this->subarea != null) {
         $array['subarea'] = $this->subarea->toArray();
     }
     if ($this->file != null) {
         $array['file'] = $this->file->toArray();
     }
     if ($this->state != null) {
         $array['state'] = $this->state->toArray();
     }
     if ($this->date != null) {
         $array['date'] = $this->date();
     }
     if ($this->type != null) {
         $array['type'] = $this->getType();
     }
     if ($this->year != null) {
         $array['year'] = $this->getYear();
     }
     if ($this->event != null) {
         $array['event'] = $this->getEvent();
     }
     return $array;
 }
Example #2
0
 /**
  * Solves the challenge
  */
 public function solve()
 {
     $filePath = Cli::getArgument(0);
     $file = new File($filePath);
     $numbers = $file->toArray();
     foreach ($numbers as $number) {
         $number = $this->filter($number);
         $isReal = $this->isReal($number);
         $status = $isReal ? 'Real' : 'Fake';
         print $status . PHP_EOL;
     }
 }
Example #3
0
 public function startup()
 {
     $this->data['generator'] = 'harrison ' . AppController::VERSION . ', ephFrame';
     $this->data['contact'] = Registry::get('ContactEmail');
     // iterate over metatags to find @[files] ?
     foreach ($this->data as $key => $value) {
         if (!is_string($value) || !($filename = preg_match_first($value, '/^@(.+)/'))) {
             continue;
         }
         $File = new File($filename);
         if ($File->exists()) {
             $this->data[$key] = $File->toArray();
         } else {
             $this->data[$key] = '';
         }
     }
     return parent::startup();
 }
 public function testWrite()
 {
     $file = new File('/tmp/test');
     $this->assertEquals(true, $file->append("test\n"));
     $this->assertEquals(true, $file->append("test\n"));
     $this->assertEquals(true, $file->copy('/tmp/test2'));
     $this->assertEquals(true, $file->delete());
     $file = new File('/tmp/test2');
     $linecount = 0;
     foreach ($file->lines() as $line) {
         $linecount = $linecount + 1;
     }
     $array = $file->toArray();
     $this->assertEquals(2, count($array));
     $this->assertEquals(2, $linecount);
     $this->assertEquals(true, $file->delete());
     $this->assertEquals(false, $file->isFile());
 }
Example #5
0
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  *                    Defaults to BasePeer::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return    array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['StatusAction'][$this->getPrimaryKey()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['StatusAction'][$this->getPrimaryKey()] = true;
     $keys = StatusActionPeer::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getUserId(), $keys[2] => $this->getRepositoryId(), $keys[3] => $this->getBranchId(), $keys[4] => $this->getFileId(), $keys[5] => $this->getMessage(), $keys[6] => $this->getOldStatus(), $keys[7] => $this->getNewStatus(), $keys[8] => $this->getCreatedAt());
     if ($includeForeignObjects) {
         if (null !== $this->asfGuardUser) {
             $result['sfGuardUser'] = $this->asfGuardUser->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aRepository) {
             $result['Repository'] = $this->aRepository->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aBranch) {
             $result['Branch'] = $this->aBranch->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aFile) {
             $result['File'] = $this->aFile->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
     }
     return $result;
 }
Example #6
0
 /**
  * Convert to array
  * @return array
  */
 public function toArray()
 {
     $array = array('id_folio_import_file' => $this->getIdFolioImportFile(), 'id_file' => $this->getIdFile(), 'id_folio_import' => $this->getIdFolioImport(), 'document_type' => $this->getDocumentType());
     return array_merge(parent::toArray(), $array);
 }
Example #7
0
 /**
  * Convert to array
  * @return array
  */
 public function toArray()
 {
     $array = array('id_purchase_order_file' => $this->getIdPurchaseOrderFile(), 'id_purchase_order' => $this->getIdPurchaseOrder(), 'id_file' => $this->getIdFile(), 'document_type' => $this->getDocumentType());
     return array_merge(parent::toArray(), $array);
 }
Example #8
0
 /**
  * Add an embedded image
  * @param File $attachment
  * @return Message
  */
 public function embedImage(File $image)
 {
     $this->struct['images'][] = $image->toArray();
     return $this;
 }
Example #9
0
 /**
  * Convert to array
  * @return array
  */
 public function toArray()
 {
     $array = array('id_booking_file' => $this->getIdBookingFile(), 'id_booking' => $this->getIdBooking(), 'id_file' => $this->getIdFile(), 'document_type' => $this->getDocumentType());
     return array_merge(parent::toArray(), $array);
 }
Example #10
0
<?php

$MODULE = array('getContent' => function () {
    $path = post('path');
    $FILE = new File($path);
    if ($FILE->type == 'folder') {
        throw new Exception("C'est un dossier ! '{$path}'");
    }
    return array('info' => $FILE->toArray());
}, 'rewrite' => function () {
    $path = post('path');
    if (!($content = post('content'))) {
        throw new Exception("Attention, contenu vide...");
    }
    $FILE = new File($path);
    if ($FILE->type == 'folder') {
        throw new Exception("C'est un dossier ! '{$path}'");
    }
    $FILE->write($content);
    return array('info' => $FILE->toArray());
});
 public function executeUpload(sfWebRequest $request)
 {
     // for apiKey check
     $memberId = $this->getUser()->getMember();
     if ('1' === $request->getParameter('forceHtml')) {
         // workaround for some browsers
         $this->getResponse()->setContentType('text/html');
     }
     if (!$_FILES) {
         return $this->renderJSON(array('status' => 'error', 'message' => 'null file'));
     }
     if (!$_FILES['upfile']) {
         return $this->renderJSON(array('status' => 'error', 'message' => 'null file'));
     }
     $filename = basename($_FILES['upfile']['name']);
     if (!$filename) {
         return $this->renderJSON(array('status' => 'error', 'message' => 'null file'));
     }
     $tmpFileName = $request->getParameter('changedname');
     if ($filename != $tmpFileName) {
         $separates = $separates = explode('.', $filename);
         $cnt = count($separates);
         $fname = '';
         $ext = '';
         if (1 == $cnt) {
             $fname = $value;
         } else {
             $fname = join('', array_slice($separates, 0, $cnt - 1));
             $ext = '.' . $separates[$cnt - 1];
         }
         if ('' == $fname) {
             $filename = $tmpFileName;
         }
     }
     $filename = preg_replace('/\\|\\/|\\*|:|\\?|\\&|\'|\\"|>|<|undefined|\\|/', '-', urldecode($filename));
     $communityId = (int) $request->getParameter('community_id');
     if (1 <= (int) $communityId) {
         $community = Doctrine::getTable('Community')->find($communityId);
         if (!$community->isPrivilegeBelong($this->getUser()->getMember()->getId())) {
             return $this->renderJSON(array('status' => 'error', 'message' => 'you are not this community member.'));
         }
         $dirname = '/c' . $communityId;
     } else {
         $dirname = '/m' . $this->getUser()->getMember()->getId();
     }
     //validate $filepath
     if (!preg_match('/^\\/[mc][0-9]+/', $dirname)) {
         return $this->renderJSON(array('status' => 'error', 'message' => 'file path error. ' . $dirname));
     }
     $f = new File();
     $f->setOriginalFilename($filename);
     $f->setType($_FILES['upfile']['type']);
     $f->setName($dirname . '/' . time() . $filename);
     $f->setFilesize($_FILES['upfile']['size']);
     if ($stream = fopen($_FILES['upfile']['tmp_name'], 'r')) {
         $bin = new FileBin();
         $bin->setBin(stream_get_contents($stream));
         $f->setFileBin($bin);
         $f->save();
         $response = true;
     } else {
         //file open error
         $response = false;
     }
     if (true === $response) {
         return $this->renderJSON(array('status' => 'success', 'message' => 'file up success ' . $response, 'file' => $f->toArray(false)));
     } else {
         return $this->renderJSON(array('status' => 'error', 'message' => 'file upload error'));
     }
 }
Example #12
0
<?php

$MODULE = array('getImage' => function () {
    $path = post('path');
    $FILE = new File($path);
    if (!$FILE->isImg()) {
        throw new Exception("C'est pas une image ! '{$path}'");
    }
    return array('info' => $FILE->toArray(), 'vtff' => 'Kilian est une pute    . :, ;:!');
});
Example #13
0
 /**
  * Convert to array
  * @return array
  */
 public function toArray()
 {
     $array = array('id_supplier_file' => $this->getIdSupplierFile(), 'id_file' => $this->getIdFile(), 'id_supplier' => $this->getIdSupplier(), 'document_type' => $this->getDocumentType());
     return array_merge(parent::toArray(), $array);
 }
Example #14
0
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  *                    Defaults to BasePeer::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return    array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['Comment'][$this->getPrimaryKey()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['Comment'][$this->getPrimaryKey()] = true;
     $keys = CommentPeer::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getUserId(), $keys[2] => $this->getBranchId(), $keys[3] => $this->getFileId(), $keys[4] => $this->getPosition(), $keys[5] => $this->getLine(), $keys[6] => $this->getType(), $keys[7] => $this->getCommit(), $keys[8] => $this->getValue(), $keys[9] => $this->getRootCommentId(), $keys[10] => $this->getCheckUserId(), $keys[11] => $this->getCheckedAt(), $keys[12] => $this->getCreatedAt(), $keys[13] => $this->getUpdatedAt());
     if ($includeForeignObjects) {
         if (null !== $this->asfGuardUserRelatedByUserId) {
             $result['sfGuardUserRelatedByUserId'] = $this->asfGuardUserRelatedByUserId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aBranch) {
             $result['Branch'] = $this->aBranch->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aFile) {
             $result['File'] = $this->aFile->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->asfGuardUserRelatedByCheckUserId) {
             $result['sfGuardUserRelatedByCheckUserId'] = $this->asfGuardUserRelatedByCheckUserId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
     }
     return $result;
 }
Example #15
0
 /**
  * Convert to array
  * @return array
  */
 public function toArray()
 {
     $array = array('id_warehouse_entrance_file' => $this->getIdWarehouseEntranceFile(), 'id_warehouse_entrance_claim_report' => $this->getIdWarehouseEntranceClaimReport(), 'id_file' => $this->getIdFile(), 'document_type' => $this->getDocumentType());
     return array_merge(parent::toArray(), $array);
 }
Example #16
0
 /**
  * Convert to array
  * @return array
  */
 public function toArray()
 {
     $array = array('id_inspection_file' => $this->getIdInspectionFile(), 'id_inspection' => $this->getIdInspection(), 'id_file' => $this->getIdFile(), 'document_type' => $this->getDocumentType());
     return array_merge(parent::toArray(), $array);
 }
 /**
  * Convert to array
  * @return array
  */
 public function toArray()
 {
     $array = array('id_product_printing_area_file' => $this->getIdProductPrintingAreaFile(), 'id_product_printing_area' => $this->getIdProductPrintingArea(), 'id_file' => $this->getIdFile(), 'document_type' => $this->getDocumentType());
     return array_merge(parent::toArray(), $array);
 }
Example #18
0
 /**
  * Returns an array representation of the file.
  * (This is used by the generic listing module vidi when displaying file records.)
  *
  * @return array Array of main data of the file. Don't rely on all data to be present here, it's just a selection of the most relevant information.
  */
 public function toArray()
 {
     $array = array_merge($this->originalFile->toArray(), $this->propertiesOfFileReference);
     return $array;
 }