当前位置: 首页>>代码示例>>PHP>>正文


PHP Stream::getStream方法代码示例

本文整理汇总了PHP中Stream::getStream方法的典型用法代码示例。如果您正苦于以下问题:PHP Stream::getStream方法的具体用法?PHP Stream::getStream怎么用?PHP Stream::getStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stream的用法示例。


在下文中一共展示了Stream::getStream方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: extract

 /**
  * Extract a Bzip2 compressed file to a given path
  *
  * @param   string  $archive      Path to Bzip2 archive to extract
  * @param   string  $destination  Path to extract archive to
  *
  * @return  boolean  True if successful
  *
  * @since   1.0
  * @throws  Exception
  */
 public function extract($archive, $destination)
 {
     $this->data = null;
     $this->options['use_streams'] = false;
     if (!isset($this->options['use_streams']) || $this->options['use_streams'] == false) {
         // Old style: read the whole file and then parse it
         $this->data = file_get_contents($archive);
         if (!$this->data) {
             throw new Exception('Unable to read archive');
         }
         $buffer = bzdecompress($this->data);
         unset($this->data);
         if (empty($buffer)) {
             throw new Exception('Unable to decompress data');
         }
         if (xapp_File2::write($destination, $buffer) === false) {
             throw new Exception('Unable to write archive');
         }
     } else {
         // New style! streams!
         $input = Stream::getStream();
         // Use bzip
         $input->set('processingmethod', 'bz');
         if (!$input->open($archive)) {
             throw new Exception('Unable to read archive (bz2)');
         }
         $output = Stream::getStream();
         if (!$output->open($destination, 'w')) {
             $input->close();
             throw new Exception('Unable to write archive (bz2)');
         }
         do {
             $this->data = $input->read($input->get('chunksize', 8196));
             if ($this->data) {
                 if (!$output->write($this->data)) {
                     $input->close();
                     throw new Exception('Unable to write archive (bz2)');
                 }
             }
         } while ($this->data);
         $output->close();
         $input->close();
     }
     // @codeCoverageIgnoreEnd
     return true;
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:57,代码来源:Bzip2.php

示例2: extract

 /**
  * Extract a Gzip compressed file to a given path
  *
  * @param   string  $archive      Path to ZIP archive to extract
  * @param   string  $destination  Path to extract archive to
  *
  * @return  boolean  True if successful
  *
  * @since   1.0
  * @throws  Exception
  */
 public function extract($archive, $destination)
 {
     $this->data = null;
     $this->options['use_streams'] = false;
     if (!isset($this->options['use_streams']) || $this->options['use_streams'] == false) {
         $this->data = file_get_contents($archive);
         if (!$this->data) {
             throw new Exception('Unable to read archive');
         }
         $position = $this->getFilePosition();
         $buffer = gzinflate(substr($this->data, $position, strlen($this->data) - $position));
         if (empty($buffer)) {
             throw new Exception('Unable to decompress data');
         }
         if (xapp_File2::write($destination, $buffer) === false) {
             throw new Exception('Unable to write archive');
         }
     } else {
         // New style! streams!
         $input = Stream::getStream();
         // Use gz
         $input->set('processingmethod', 'gz');
         if (!$input->open($archive)) {
             throw new Exception('Unable to read archive (gz)');
         }
         $output = Stream::getStream();
         if (!$output->open($destination, 'w')) {
             $input->close();
             throw new Exception('Unable to write archive (gz)');
         }
         do {
             $this->data = $input->read($input->get('chunksize', 8196));
             if ($this->data) {
                 if (!$output->write($this->data)) {
                     $input->close();
                     throw new Exception('Unable to write file (gz)');
                 }
             }
         } while ($this->data);
         $output->close();
         $input->close();
     }
     // @codeCoverageIgnoreEnd
     return true;
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:56,代码来源:Gzip.php

示例3: stream

 /**
  * Get details of a specific data Stream associated with the
  * distribution.
  *
  * @param string $name
  * @return Stream
  */
 public function stream($name)
 {
     return Stream::getStream($this->client, $this, $name);
 }
开发者ID:attm2x,项目名称:m2x-php,代码行数:11,代码来源:Distribution.php

示例4: move

 /**
  * Moves a folder.
  *
  * @param   string   $src          The path to the source folder.
  * @param   string   $dest         The path to the destination folder.
  * @param   string   $path         An optional base path to prefix to the file names.
  * @param   boolean  $use_streams  Optionally use streams.
  *
  * @return  mixed  Error message on false or boolean true on success.
  *
  * @since   1.0
  */
 public static function move($src, $dest, $path = '', $use_streams = false)
 {
     if ($path) {
         $src = Path::clean($path . '/' . $src);
         $dest = Path::clean($path . '/' . $dest);
     }
     if (!is_dir(Path::clean($src))) {
         return 'Cannot find source folder';
     }
     if (is_dir(Path::clean($dest))) {
         return 'Folder already exists';
     }
     if ($use_streams) {
         $stream = Stream::getStream();
         if (!$stream->move($src, $dest)) {
             return 'Rename failed: ' . $stream->getError();
         }
         return true;
     } else {
         if (!@rename($src, $dest)) {
             return 'Rename failed';
         }
         return true;
     }
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:37,代码来源:Folder.php

示例5: generateStream

 private function generateStream($offset = 0)
 {
     require_once FRAMEWORK_PATH . 'models/stream.php';
     $stream = new Stream($this->registry);
     $stream->buildStream($this->registry->getObject('authenticate')->getUser()->getUserID(), $offset);
     if (!$stream->isEmpty()) {
         $this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'stream/main.tpl.php', 'footer.tpl.php');
         $streamdata = $stream->getStream();
         $IDs = $stream->getIDs();
         $cacheableIDs = array();
         foreach ($IDs as $id) {
             $i = array();
             $i['status_id'] = $id;
             $cacheableIDs[] = $i;
         }
         $cache = $this->registry->getObject('db')->cacheData($cacheableIDs);
         $this->registry->getObject('template')->getPage()->addTag('stream', array('DATA', $cache));
         foreach ($streamdata as $data) {
             $datatags = array();
             foreach ($data as $tag => $value) {
                 $datatags['status' . $tag] = $value;
             }
             // your own status updates
             if ($data['profile'] == $this->registry->getObject('authenticate')->getUser()->getUserID() && $data['poster'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
                 // it was a present...from me to me!
                 // http://www.imdb.com/title/tt0285403/quotes?qt0473119
                 $this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'stream/types/' . $data['type_reference'] . '-Spongebob-Squarepants-Costume-gift.tpl.php', $datatags);
             } elseif ($data['profile'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
                 // updates to you
                 $this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'stream/types/' . $data['type_reference'] . '-toself.tpl.php', $datatags);
             } elseif ($data['poster'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
                 // updates by you
                 $this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'stream/types/' . $data['type_reference'] . '-fromself.tpl.php', $datatags);
             } elseif ($data['poster'] == $data['profile']) {
                 $this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'stream/types/' . $data['type_reference'] . '-user.tpl.php', $datatags);
             } else {
                 // network updates
                 $this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'stream/types/' . $data['type_reference'] . '.tpl.php', $datatags);
             }
         }
         // stream comments, likes and dislikes
         $status_ids = implode(',', $IDs);
         $start = array();
         foreach ($IDs as $id) {
             $start[$id] = array();
         }
         // comments
         $comments = $start;
         $sql = "SELECT p.name as commenter, c.profile_post, c.comment FROM profile p, comments c WHERE p.user_id=c.creator AND c.approved=1 AND c.profile_post IN ({$status_ids})";
         $this->registry->getObject('db')->executeQuery($sql);
         if ($this->registry->getObject('db')->numRows() > 0) {
             while ($comment = $this->registry->getObject('db')->getRows()) {
                 $comments[$comment['profile_post']][] = $comment;
             }
         }
         foreach ($comments as $status => $comments) {
             $cache = $this->registry->getObject('db')->cacheData($comments);
             $this->registry->getObject('template')->getPage()->addTag('comments-' . $status, array('DATA', $cache));
         }
         // likes + dislikes
         $likes = $start;
         $dislikes = $start;
         $sql = "SELECT i.status, p.name as iker, i.iker as iker_id, i.type as type FROM profile p, ikes i WHERE p.user_id=i.iker AND i.status IN ({$status_ids}) ";
         $this->registry->getObject('db')->executeQuery($sql);
         if ($this->registry->getObject('db')->numRows() > 0) {
             while ($ike = $this->registry->getObject('db')->getRows()) {
                 if ($ike['type'] == 'likes') {
                     $likes[$ike['status']][] = $ike;
                 } else {
                     $dislikes[$ike['status']][] = $ike;
                 }
             }
         }
         foreach ($likes as $status => $likeslist) {
             $cache = $this->registry->getObject('db')->cacheData($likeslist);
             $this->registry->getObject('template')->getPage()->addTag('likes-' . $status, array('DATA', $cache));
         }
         foreach ($dislikes as $status => $dislikeslist) {
             $cache = $this->registry->getObject('db')->cacheData($dislikeslist);
             $this->registry->getObject('template')->getPage()->addTag('dislikes-' . $status, array('DATA', $cache));
         }
     } else {
         $this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'stream/none.tpl.php', 'footer.tpl.php');
     }
 }
开发者ID:simontakite,项目名称:cookbooks,代码行数:85,代码来源:controller.php

示例6: addStatus

 private function addStatus($array, $user)
 {
     $loggedIn = $this->registry->getObject('authenticate')->isLoggedIn();
     if ($loggedIn == true) {
         require_once 'status.php';
         if (isset($_POST['status_type']) && $_POST['status_type'] != 'update') {
             if ($_POST['status_type'] == 'image') {
                 require_once 'imagestatus.php';
                 $status = new Imagestatus($this->registry, 0, $user);
                 $status->processImage('image_file');
             } elseif ($_POST['status_type'] == 'video') {
                 require_once 'videostatus.php';
                 $status = new Videostatus($this->registry, 0, $user);
                 $status->setVideoIdFromURL($_POST['video_url']);
             } elseif ($_POST['status_type'] == 'link') {
                 require_once 'linkstatus.php';
                 $status = new Linkstatus($this->registry, 0);
                 $status->setURL($this->registry->getObject('db')->sanitizeData($_POST['link_url']));
                 $status->setDescription($this->registry->getObject('db')->sanitizeData($_POST['link_description']));
             }
         } else {
             $status = new Status($this->registry, 0);
         }
         $status->setProfile($user);
         $status->setPoster($user);
         if (isset($_POST['status'])) {
             $status->setStatus($this->registry->getObject('db')->sanitizeData($_POST['status']));
         }
         $status->generateType();
         $status->save();
         $newAddID = $status->getID();
         //Status Wierdness Start
         $this->registry->getObject('template')->getPage()->addTag('referer', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
         require_once 'stream.php';
         $stream = new Stream($this->registry);
         $status = $stream->getStatusByID($newAddID);
         $statusTypes = $stream->getStatusType();
         if (!$stream->isEmpty()) {
             $this->registry->getObject('template')->buildFromTemplate('stream_more.php');
         }
         $streamdata = $stream->getStream();
         $IDs = $stream->getIDs();
         $cacheableIDs = array();
         foreach ($IDs as $id) {
             $i = array();
             $i['status_id'] = $id;
             $cacheableIDs[] = $i;
         }
         $cache = $this->registry->getObject('db')->cacheData($cacheableIDs);
         $this->registry->getObject('template')->getPage()->addTag('stream', array('DATA', $cache));
         //var_dump($cacheableIDs);
         foreach ($streamdata as $data) {
             $datatags = array();
             foreach ($data as $tag => $value) {
                 $datatags['status' . $tag] = $value;
             }
             //var_dump($datatags);
             // your own status updates
             if ($data['profile'] == 0) {
                 // network updates
                 $this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-general.php', $datatags);
             } elseif ($data['profile'] == $this->registry->getObject('authenticate')->getUser()->getUserID() && $data['poster'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
                 $this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-self.php', $datatags);
             } elseif ($data['profile'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
                 // updates to you
                 $this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-toSelf.php', $datatags);
             } elseif ($data['poster'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
                 // updates by you
                 $this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-fromSelf.php', $datatags);
             } elseif ($data['poster'] == $data['profile']) {
                 $this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-user.php', $datatags);
             } else {
                 // network updates
                 $this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '.php', $datatags);
             }
         }
         // stream comments, likes and dislikes
         $status_ids = implode(',', $IDs);
         $start = array();
         foreach ($IDs as $id) {
             $start[$id] = array();
         }
         // comments
         $this->generateComments($start, $status_ids);
         //rates
         $this->getRates('status', $IDs);
         //$this->getRates('comments', $IDs);
         $this->registry->getObject('template')->getPage()->addTag('offset', 20);
         //$offset +
         $this->registry->getObject('template')->parseOutput();
         $this->registry->ajaxReply(array('content' => $this->registry->getObject('template')->getPage()->getContentToPrint(), 'status' => 'Status Added'));
         //$this->registry->ajaxReply(array('content' => '<script>$(document).ready(function(){window.location.reload();})</script>', 'status' => 'Status Added'));
         //Status Wierdness End
         // success message display
         //$this->registry->ajaxReply( array('status'=>'Status Added', 'content'=>'') );
         //$this->registry->getObject('template')->addTemplateBit( 'status_update_message', 'profile_status_update_confirm.php' );
     } else {
         //$this->registry->ajaxReply( array('status'=>'Access Denied', 'content'=>'') );
         $this->registry->errorPage('Access Denied', 'Login to continue');
     }
//.........这里部分代码省略.........
开发者ID:maxzeroedge,项目名称:social,代码行数:101,代码来源:streamController.php

示例7: upload

 /**
  * Moves an uploaded file to a destination folder
  *
  * @param   string   $src          The name of the php (temporary) uploaded file
  * @param   string   $dest         The path (including filename) to move the uploaded file to
  * @param   boolean  $use_streams  True to use streams
  *
  * @return  boolean  True on success
  *
  * @since   1.0
  * @throws  FilesystemException
  */
 public static function upload($src, $dest, $use_streams = false)
 {
     // Ensure that the path is valid and clean
     $dest = Path::clean($dest);
     // Create the destination directory if it does not exist
     $baseDir = dirname($dest);
     if (!file_exists($baseDir)) {
         Folder::create($baseDir);
     }
     if ($use_streams) {
         $stream = Stream::getStream();
         if (!$stream->upload($src, $dest)) {
             throw new FilesystemException(__METHOD__ . ': ' . $stream->getError());
         }
         return true;
     } else {
         if (is_writeable($baseDir) && move_uploaded_file($src, $dest)) {
             // Short circuit to prevent file permission errors
             if (Path::setPermissions($dest)) {
                 return true;
             } else {
                 throw new FilesystemException(__METHOD__ . ': Failed to change file permissions.');
             }
         } else {
             throw new FilesystemException(__METHOD__ . ': Failed to move file.');
         }
         return false;
     }
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:41,代码来源:File.php


注:本文中的Stream::getStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。