예제 #1
0
	/**
	 * Get the device component of this useragent as pretty HTML.
	 *
	 * @return string
	 */
	private function _getAsHTMLDevice(){
		// Piwik can provide pretty icons!
		$icon  = (\Core::IsComponentAvailable('piwik-analytics') && $this->device_maker) ? 'assets/images/brand/' . $this->device_maker . '.gif' : null;
		$title = '';
		$text  = '';
		$out   = '';
		$class = 'useragent-pretty-device';
		
		if($this->device_maker && $this->device_name){
			$title .= $this->device_maker . ' ' . $this->device_name;
			$text .= $this->device_name;
		}
		elseif($this->device_maker){
			$title .= $this->device_maker;
			$text .= $this->device_maker;
		}

		// Start compiling this attribute together.
		$out .= '<span class="' . $class . '" title="' . $title . '">';
		if($icon){
			$out .= '<img src="' . \Core\resolve_asset($icon) . '"/> ';
		}
		$out .= $text;
		$out .= '</span>';

		return $out;
	}
예제 #2
0
	/**
	 * Resolve an asset to a fully-resolved URL.
	 *
	 * @deprecated
	 * @see \Core\resolve_asset
	 *
	 * @param string $asset
	 *
	 * @return string The full url of the asset, including the http://...
	 */
	public static function ResolveAsset($asset) {
		trigger_error('Core::ResolveAsset is deprecated, please use \\Core\\resolve_asset() instead.', E_USER_DEPRECATED);
		return \Core\resolve_asset($asset);
	}
예제 #3
0
	/**
	 * Add a linked stylesheet file to the global View object.
	 *
	 * @param string $link The link of the stylesheet
	 * @param string $media Media to display the stylesheet with.
	 */
	public function addStylesheet($link, $media = "all") {
		if (strpos($link, '<style') === 0) {
			// This is a style tag, not a stylesheet.  Use that method instead.
			$this->addStyle($link);
			return;
		}

		if (strpos($link, '<link') === false) {

			// Is this a CSS file or a LESS file?
			if(strripos($link, '.less') == strlen($link)-5 ){
				$rel = 'stylesheet/less';
				Core::_AttachLessJS();
			}
			else{
				$rel = 'stylesheet';
			}

			// Resolve the script and wrap it with a script block.
			$link = '<link type="text/css" href="' . \Core\resolve_asset($link) . '" media="' . $media . '" rel="' . $rel . '"/>';
		}

		// This snippet is to allow AddStylesheet to be called statically.
		// Core <= 2.6.0 used this method, and components built on it will be expecting this functionality.
		// ! IMPORTANT ! Do NOT remove this until if/else block until 2.6.0 is no longer supported!
		// 2013.08.18 - cpowell
		if(isset($this)){
			$styles =& $this->stylesheets;
		}
		else{
			$styles =& \Core\view()->stylesheets;
		}

		// I can check to see if this script has been loaded before.
		if (!in_array($link, $styles)) $styles[] = $link;
	}
예제 #4
0
	private function _getAsImageHTML(){
		if(sizeof($this->getMetas())){
			// If there are no meta tags associated, nothing to do!
			$metatitle   = $this->getMetaTitle('title');
			$metaauthor  = $this->getMetaTitle('author');
			$metalicense = $this->getMeta('license');
			$metaurl     = $this->getMetaTitle('url');
			$metatags    = $this->getMetaTitle('keywords');
			$url         = $this->_file->getURL();

			$metacredithtml = '';
			if($metaauthor){
				$metacredithtml .=
					'Photo by <span itemprop="author">' .
					($metaurl ? '<a href="' . $metaurl . '" target="_BLANK">' . $metaauthor . '</a>' : $metaauthor) .
					'</span>';
			}
			if($metalicense){
				$lic = \Core\Licenses\Factory::GetLicense($metalicense->get('meta_value'));
				$licimg = \Core\resolve_asset('assets/images/licenses/' . $metalicense->get('meta_value') . '-sm.png');

				if($lic){
					$metacredithtml .= ($metacredithtml ? ' ' : '') . '<a href="' . $lic['url'] . '" target="_BLANK"><img src="' . $licimg . '" alt="' . $lic['title'] . '" title="' . $lic['title'] . '"/></a>';
				}
				else{
					$metacredithtml .= ($metacredithtml ? ' // ' : '') . $metalicense->get('meta_value_title');
				}
			}

			// Wrap it!
			$metaheader = '<div class="image-metadata" itemscope itemtype="http://schema.org/ImageObject">';
			$metafooter = '</div><!-- END .image-metadata-wrapper -->';

			// Some extra inline attributes
			$metacredithtml .=
				'<meta itemprop="image" content="' . $url . '"/>' .
				'<meta itemprop="url" content="' . ($metaurl ? $metaurl : $url) . '"/>' .
				($metatitle ? '<meta itemprop="name" content="' . $metatitle . '"/>' : '') .
				(is_array($metatags) && sizeof($metatags) ? '<meta itemprop="keywords" content="' . htmlspecialchars(implode(', ', $metatags)) . '"/>' : '');


			// Merge everything together!
			return $metaheader . $metacredithtml . $metafooter;
		}
	}
예제 #5
0
    public static function IncludeTinyMCE()
    {
        \ComponentHandler::LoadScriptLibrary('jquery');
        /** @var \View $view */
        $view = \Core\view();
        /** @var \UserModel $user */
        $user = \Core\user();
        // I need to include both versions of TinyMCE so that
        // 1) the tinymce object is visible in the global scope at the time of execution and
        // 2) so I can target all inputs by their class name instead of the ID.
        $view->addScript('js/tinymce/tinymce.min.js');
        $view->addScript('js/tinymce/jquery.tinymce.min.js');
        $view->addStylesheet('css/tinymce/overrides.css');
        // Yes, the string needs quotes inside of quotes!  It's to be read by javascript after all.
        $browsable = \Core::IsComponentAvailable('media-manager') && $user->checkAccess('p:/mediamanager/browse');
        $filebrowsercallback = $browsable ? "Core.TinyMCE.FileBrowserCallback" : 'null';
        $loc = \Core\resolve_asset('js/tinymce/tinymce.min.js');
        $content = \Core\resolve_asset('css/tinymce/content.css');
        $pages = \PageModel::GetPagesAsOptions();
        $links = [];
        foreach ($pages as $url => $title) {
            // Trim off the "(...)" at the end of the title.
            // Core adds that as a benefit for knowing
            $links[] = ['title' => html_entity_decode(preg_replace('/(.*) \\([^\\)]*\\)/', '$1', $title)), 'value' => \Core\resolve_link($url)];
        }
        // And json the data.
        $links = json_encode($links);
        // Create the list of plugins
        // Start with standard and tack on any custom ones.
        $plugins = ['advlist', 'anchor', 'autolink', 'charmap', 'code', 'colorpicker', 'contextmenu', 'fullscreen', 'hr', 'image', 'imagetools', 'insertdatetime', 'link', 'lists', 'media', 'pagebreak', 'paste', 'preview', 'searchreplace', 'table', 'textcolor', 'visualblocks', 'visualchars', 'wordcount'];
        $customIncludes = '';
        foreach (self::$CustomPlugins as $name => $src) {
            // The "-" is required to inform TinyMCE not to load the plugin again.
            // It'll be loaded manually via the .load() method as it has a custom URL.
            $plugins[] = '-' . $name;
            // Resolve this src to an absolute URL
            $src = \Core\resolve_asset($src);
            $customIncludes .= 'tinymce.PluginManager.load("' . $name . '", "' . $src . '");';
        }
        // And make them something that javascript can understand.
        $plugins = json_encode($plugins);
        $script = <<<EOD
<script type="text/javascript">

\tCore.TinyMCEDefaults = {
\t\t// Location of TinyMCE script
\t\tscript_url : '{$loc}',

\t\t// General options

\t\tplugins: {$plugins},
\t    toolbar: "undo redo | styleselect | forecolor backcolor bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",

\t\ttheme : "modern",

\t\t// Required to not mungle links.
\t\tconvert_urls: false,

\t\t// Requires to support <script/> tags.
\t\textended_valid_elements : "script[language|type|src]",

\t\t// Core Media Manager integration
\t\tfile_browser_callback: {$filebrowsercallback},

\t\t// Example content CSS (should be your site CSS)
\t\tcontent_css : "{$content}",

\t\t// Drop lists for link/image/media/template dialogs
\t\t//template_external_list_url : "lists/template_list.js",
\t\t//external_link_list_url : "lists/link_list.js",
\t\t//external_image_list_url : "lists/image_list.js",
\t\t//media_external_list_url : "lists/media_list.js",
\t\t link_list: {$links},

\t\t// Replace values for the template plugin
\t\t//template_replace_values : {
\t\t//\tusername : "******",
\t\t//\tstaffid : "991234"
\t\t//}

\t\t__dummy: null
\t};

\t\$(function(){
\t\t{$customIncludes}
\t\t\$('textarea.tinymce').tinymce(Core.TinyMCEDefaults);
\t});
</script>\t
EOD;
        // Add the necessary script
        $view->addScript('assets/js/tinymce/coreplus_functions.js', 'head');
        $view->addScript($script, 'foot');
        // IMPORTANT!  Tells the script that the include succeeded!
        return true;
    }