Пример #1
0
 /**
  * Build local path for remote items with the same name
  *
  * @param	   string		$id				Remote ID
  * @param	   string		$fpath			File path
  * @param	   string		$format			mime type
  * @param	   array		$connections	Array of local-remote connections
  * @param	   array		&$remotes		Collector array for active items
  * @param	   array		&$duplicates	Collector array for duplicates
  *
  * @return	 void
  */
 public static function buildDuplicatePath($id = 0, $fpath, $format = '', $connections, &$remotes, &$duplicates)
 {
     // Do we have a record with another ID linked to the same path?
     $pathTaken = isset($connections['paths'][$fpath]) && $connections['paths'][$fpath]['remote_id'] != $id && $connections['paths'][$fpath]['format'] == $format ? true : false;
     // Deal with duplicate names
     if (isset($remotes[$fpath]) && $remotes[$fpath]['mimeType'] == $format || $pathTaken == true) {
         if (isset($duplicates[$fpath])) {
             $duplicates[$fpath][] = $id;
         } else {
             $duplicates[$fpath] = array();
             $duplicates[$fpath][] = $id;
         }
         // Append duplicate count to file name
         $appended = \Components\Projects\Helpers\Html::getAppendedNumber($fpath);
         $num = $appended ? $appended + 1 : 1;
         if ($appended) {
             $fpath = \Components\Projects\Helpers\Html::cleanFileNum($fpath, $appended);
         }
         $fpath = \Components\Projects\Helpers\Html::fixFileName($fpath, '-' . $num);
         // Check that new path isn't used either
         return self::buildDuplicatePath($id, $fpath, $format, $connections, $remotes, $duplicates);
     } else {
         return $fpath;
     }
 }
Пример #2
0
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */
// No direct access
defined('_HZEXEC_') or die;
if ($this->getError()) {
    echo '<p class="error">' . $this->getError() . '</p>';
    return;
}
$name = $this->file->get('name');
// Is this a duplicate remote?
if ($this->file->get('remote') && $this->file->get('name') != $this->file->get('remoteTitle')) {
    $append = \Components\Projects\Helpers\Html::getAppendedNumber($this->file->get('name'));
    if ($append > 0) {
        $name = \Components\Projects\Helpers\Html::fixFileName($this->file->get('remoteTitle'), ' (' . $append . ')', $this->file->get('ext'));
    }
}
// Do not display Google native extension
$native = \Components\Projects\Helpers\Google::getGoogleNativeExts();
if (in_array($this->file->get('ext'), $native)) {
    $name = preg_replace("/." . $this->file->get('ext') . "\\z/", "", $name);
}
?>
	<h4><img src="<?php 
echo $this->file->getIcon();
?>
" alt="<?php 
echo $this->file->get('ext');
Пример #3
0
 /**
  * Add to zip bundle
  *
  * @return  boolean
  */
 public function addToBundle($zip, $attachments, $element, $elementId, $pub, $blockParams, &$readme, $bundleDir)
 {
     // Get configs
     $configs = $this->getConfigs($element->params, $elementId, $pub, $blockParams);
     $filePath = NULL;
     if ($configs->includeInPackage == false) {
         return false;
     }
     // Add inside bundles
     if ($configs->multiZip == 1 && $attachments && count($attachments) > 1) {
         $filePath = $this->bundle($attachments, $configs, false);
         $bPath = $configs->pubBase . DS . 'bundles';
         if (is_file($filePath)) {
             $where = $bundleDir;
             if ($configs->bundleDirectory) {
                 $where .= DS . $configs->bundleDirectory;
             }
             if ($configs->directory && strtolower($configs->bundleDirectory) != strtolower($configs->directory)) {
                 $where .= $configs->directory != $pub->secret ? DS . $configs->directory : '';
             }
             $where .= DS . basename($filePath);
             $zip->addFile($filePath, $where);
             $readme .= "\n" . $element->label . ': ' . "\n";
             $readme .= '>>> ' . str_replace($bPath . DS, '', $filePath) . "\n";
         }
     } elseif ($attachments) {
         $readme .= "\n" . $element->label . ': ' . "\n";
         $added = array();
         // Add separately
         foreach ($attachments as $attach) {
             $filePath = $this->getFilePath($attach->path, $attach->id, $configs, $attach->params);
             $fileinfo = pathinfo($filePath);
             $a_dir = $fileinfo['dirname'];
             $a_dir = trim(str_replace($configs->pubPath, '', $a_dir), DS);
             $fPath = $a_dir && $a_dir != '.' ? $a_dir . DS : '';
             $fPath .= basename($filePath);
             if (!$configs->bundleDirHierarchy) {
                 $fPath = basename($filePath);
                 if (in_array($fPath, $added)) {
                     $num = \Components\Projects\Helpers\Html::getAppendedNumber($fPath);
                     $num = $num ? $num : 1;
                     $fPath = \Components\Projects\Helpers\Html::fixFileName($fPath, '-' . $num);
                 } else {
                     $added[] = $fPath;
                 }
             }
             $where = $bundleDir;
             if ($configs->bundleDirectory) {
                 $where .= DS . $configs->bundleDirectory;
             }
             if ($configs->directory && strtolower($configs->bundleDirectory) != strtolower($configs->directory)) {
                 $where .= $configs->directory != $pub->secret ? DS . $configs->directory : '';
             }
             $where .= $configs->subdir ? DS . $configs->subdir : '';
             $where .= DS . $fPath;
             if ($zip->addFile($filePath, $where)) {
                 $readme .= '>>> ' . str_replace($bundleDir . DS, '', $where) . "\n";
             }
         }
     }
     return true;
 }