コード例 #1
0
ファイル: google.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * 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;
     }
 }