<commit_before><?php
/**
 * Anqh extended url helper class.
 *
 * @package    Anqh
 * @author     <NAME>
 * @copyright  (c) 2009 <NAME>
 * @license    http://www.opensource.org/licenses/mit-license.php MIT license
 */
class url extends url_Core {

	/**
	 * Transforms an database id to file path, 1234567 = 01/23/45
	 *
	 * @param  int $id
	 * @return string
	 */
	public static function id2path($id) {
		// convert numeric id to hex and split to chunks of 2
		$path = str_split(sprintf('%08x', (int)$id), 2);

		// scrap the last chunk, 256 files per dir
		array_pop($path);

		// return aa/bb/cc
		return implode('/', $path);
	}


	/**
	 * Return model specific url
	 *
	 * @param  ORM  $model
	 */
	public static function model(ORM $model) {
		$url = '';

		// sniff base url etc based on given object
		if ($model instanceof Modeler_ORM) {

			// Auto Modeler ORM object given
			$url = $model->url_base or $url = $model->object_name;

		} else if ($model instanceof ORM) {

			// ORM object given
			$url = $model->object_name;

		}

		$url .= '/' . self::title($model->id, $model->name);

		return $url;
	}


	/**
	 * Convert strings to url safe title
	 *
	 * @param   mixed
	 * @return  string
	 */
	public static function title() {
		$title = func_get_args();
		return parent::title(implode(' ', $title));
	}


	/**
	 * Get URL for user
	 *
	 * @param   mixed  $user  id, username, User_Model
	 * @return  string
	 */
	public static function user($user) {
		$prefix = '/member/';

		// User id given
		if (is_numeric($user) && (int)$user > 0) {
			$user = ORM::factory('user')->find_user($user);
			if ($user->id) {
				$user = $user->username;
			}
		}

		// User_Model given
		if ($user instanceof User_Model) {
			$user = $user->username;<commit_msg>url::back()<commit_after><?php
/**
 * Anqh extended url helper class.
 *
 * @package    Anqh
 * @author     <NAME>
 * @copyright  (c) 2009 <NAME>
 * @license    http://www.opensource.org/licenses/mit-license.php MIT license
 */
class url extends url_Core {

	/**
	 * Transforms an database id to file path, 1234567 = 01/23/45
	 *
	 * @param  int $id
	 * @return string
	 */
	public static function id2path($id) {
		// convert numeric id to hex and split to chunks of 2
		$path = str_split(sprintf('%08x', (int)$id), 2);

		// scrap the last chunk, 256 files per dir
		array_pop($path);

		// return aa/bb/cc
		return implode('/', $path);
	}


	/**
	 * Return model specific url
	 *
	 * @param  ORM  $model
	 */
	public static function model(ORM $model) {
		$url = '';

		// sniff base url etc based on given object
		if ($model instanceof Modeler_ORM) {

			// Auto Modeler ORM object given
			$url = $model->url_base or $url = $model->object_name;

		} else if ($model instanceof ORM) {

			// ORM object given
			$url = $model->object_name;

		}

		$url .= '/' . self::title($model->id, $model->name);

		return $url;
	}


	/**
	 * Redirect back to history
	 *
	 * @param  string  $default  if no history found
	 */
	public static function back($default = '/') {
		url::redirect(empty($_SESSION['history']) ? $default : $_SESSION['history']);
	}


	/**
	 * Convert strings to url safe title
	 *
	 * @param   mixed
	 * @return  string
	 */
	public static function title() {
		$title = func_get_args();
		return parent::title(implode(' ', $title));
	}


	/**
	 * Get URL for user
	 *
	 * @param   mixed  $user  id, username, User_Model
	 * @return  string
	 */
	public static function user($user) {
		$prefix = '/member/';

		// User id given
		if (is_numeric($user) && (int)$user > 0) {
			$user = ORM::factory('user')->find_user($user);
			if ($user->id) {
				$user = $user->username;
			}
		}

		// User_Model given
		if ($user instanceof User_Model) {
			$user = $user->username;
{'fraction_non_alphanumeric': 0.15994659546061415, 'fraction_numerical': 0.013885180240320427, 'mean_word_length': 2.7800201816347125, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6415195', 'n_tokens_mistral': 1449, 'n_tokens_neox': 1244, 'n_words': 371}