/** * Is binary? * * @return mixed */ public function isBinary() { return Helpers\Html::isBinary($this->get('fullPath')); }
/** * Get details on file history * * @param string $local_path file path * @param array &$versions Versions collector array * @param array &$timestamps Collector array * @param integer $original Source file? * * @return array of version info */ public function sortLocalRevisions($local_path = '', &$versions = array(), &$timestamps = array(), $original = 0) { // Get local file history $hashes = $this->getLocalFileHistory($local_path, '--'); // Binary $binary = \Components\Projects\Helpers\Html::isBinary($this->_path . DS . $local_path); // Get info for each commit if (!empty($hashes)) { $h = 1; // Get all names for this file $renames = $this->gitLog($local_path, '', 'rename'); $currentName = $local_path; $rename = 0; foreach ($hashes as $hash) { $order = $h == 1 ? 'first' : ''; $order = $h == count($hashes) ? 'last' : $order; // Dealing with renames $abbr = substr($hash, 0, 7); $name = isset($renames[$abbr]) ? $renames[$abbr] : $local_path; $parts = explode('/', $name); $serveas = trim(end($parts)); if ($name != $currentName) { $rename = 1; $currentName = $name; } $gitData = $this->gitLog($name, $hash, 'combined'); $date = isset($gitData['date']) ? $gitData['date'] : NULL; $author = isset($gitData['author']) ? $gitData['author'] : NULL; $email = isset($gitData['email']) ? $gitData['email'] : NULL; $message = $this->gitLog($name, $hash, 'message'); $content = $binary ? NULL : $this->gitLog($name, $hash, 'content'); // SFTP? if (strpos($message, '[SFTP]') !== false) { $profile = \Hubzero\User\Profile::getInstance(trim($author)); if ($profile) { $author = $profile->get('name'); $email = $profile->get('email'); } } $revision = array('date' => $date, 'author' => $author, 'email' => $email, 'hash' => $hash, 'file' => $serveas, 'base' => $local_path, 'remote' => NULL, 'local' => true, 'content' => '', 'preview' => NULL, 'original' => $original, 'hide' => 0, 'message' => $message, 'rename' => $rename, 'name' => $name, 'change' => '', 'movedTo' => '', 'size' => '', 'order' => $order, 'count' => count($hashes), 'commitStatus' => $this->gitLog($name, $hash, 'namestatus')); if (in_array($revision['commitStatus'], array('A', 'M'))) { $revision['size'] = \Hubzero\Utility\Number::formatBytes($this->gitLog($name, $hash, 'size')); } // Exctract file content for certain statuses if (in_array($revision['commitStatus'], array('A', 'M', 'R')) && $content) { $revision['content'] = self::filterASCII($content, false, false, 10000); } $versions[] = $revision; $timestamps[] = strtotime($date); $h++; } } }