Ejemplo n.º 1
0
	/**
	 * Make a valid URI for an uploaded File
	 *
	 * @param string $file The filepath
	 * @param array $prm Array to overwritte default uri construction
	 * @return string The valid URI
	 */
	public static function uploadedUri($file, array $prm = array()) {
		return self::uri(array_merge(array(
					'lang'=>false,
					'module'=>'nyroUtils',
					'action'=>'uploadedFiles',
					'param'=>str_replace(array('/', '\\'), array(request::getCfg('sepParam'), request::getCfg('sepParam')), $file),
					'out'=>false
				), $prm));
	}
Ejemplo n.º 2
0
	/**
	 * Get an URL for a CSS or JS file.
	 *
	 * @param string $type (css|js)
	 * @param array|string $files List of files or a single file path
	 * @param string $dir Where to get the file (nyro|web)
	 * @return string
	 */
	public function getUrlFile($type, $files, $dir = 'nyro') {
		$prm = $this->cfg->get($type);
		$url = $dir == 'web'
					? request::get('path').$prm['dirWeb']
					: request::getPathControllerUri().$prm['dirUriNyro'];
		if (request::isAbsolutizeAllUris())
			$url = request::get('domain').$url;
		$url.= '/'.(is_array($files)? implode(request::getCfg('sepParam'), $files) : $files);
		$url.= '.'.$prm['ext'];
		return $url;
	}
Ejemplo n.º 3
0
	/**
	 * Get an icon
	 *
	 * @param array $prm Icon configuration. Available key:
	 *  - string name: action name (required)
	 *  - string type: icon type
	 *  - bool imgTag: true if the return should be a valid html img tag. if false, will return he url
	 *  - string alt: alt text for the image, used only if imgTag = true
	 *  - array attr: attributes added to the img tag
	 * @return unknown
	 */
	public static function getIcon(array $prm) {
		$ret = null;

		static $cfg;
		if (!$cfg)
			$cfg = factory::loadCfg('icons', false);

		if (config::initTab($prm, array(
			'name'=>null,
			'type'=>$cfg['default'],
			'imgTag'=>true,
			'alt'=>'',
			'attr'=>array(),
		))) {
			if (array_key_exists($prm['type'], $cfg['icons'])
				&& is_array($cfg['icons'][$prm['type']])
				&& in_array($prm['name'], $cfg['icons'][$prm['type']])) {
					$ret = request::get('path').$cfg['dir'].'/'.$prm['type'].request::getCfg('sepParam').$prm['name'].$cfg['ext'];
			} else if ($prm['type'] != $cfg['default']) {
				$ret = self::getIcon(array('name'=>$prm['name'], 'imgTag'=>false));
			}

			if ($ret && $prm['imgTag']) {
				$alt = $prm['alt']? $prm['alt'] : ucFirst($prm['name']);
				$ret = self::htmlTag('img', array_merge(array(
					'src'=>$ret,
					'alt'=>$alt
				), $prm['attr']));
			}
		}
		return $ret;
	}