Exemplo n.º 1
0
    public static function SiteSearch()
    {
        $key = \ConfigHandler::Get('/google/cse/key');
        $min = \ConfigHandler::Get('/core/markup/minified');
        // If there's no code available, don't display anything.
        if (!$key) {
            return;
        }
        $script = <<<EOD

\t\t<script>
\t\t\t(function() {
\t\t\t\tvar cx = '{$key}';
\t\t\t\tvar gcse = document.createElement('script');
\t\t\t\tgcse.type = 'text/javascript';
\t\t\t\tgcse.async = true;
\t\t\t\tgcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
\t\t\t\t\t\t'//www.google.com/cse/cse.js?cx=' + cx;
\t\t\t\tvar s = document.getElementsByTagName('script')[0];
\t\t\t\ts.parentNode.insertBefore(gcse, s);
\t\t\t})();
\t\t</script>
EOD;
        // Just to make it a little smaller...
        if ($min) {
            $script = trim(str_replace(array("\n", "\r"), '', $script));
        }
        // Add the necessary script
        \Core\view()->addScript($script, 'foot');
        return true;
    }
Exemplo n.º 2
0
 public static function IncludeJS()
 {
     \Core\view()->addScript('js/chartist.js');
     \Core\view()->addStyle('css/chartist.css');
     // IMPORTANT!  Tells the script that the include succeeded!
     return true;
 }
/**
 * Simple smarty function to disable View caching of the current page
 *
 * @param array  $params  Associative (and/or indexed) array of smarty parameters passed in from the template
 * @param Smarty $smarty  Parent Smarty template object
 *
 * @return string
 */
function smarty_function_disable_view_cache($params, $smarty){

	$tmpl   = $smarty->getTemplateVars('__core_template');
	$view   = ($tmpl instanceof \Core\Templates\TemplateInterface) ? $tmpl->getView() : \Core\view();

	$view->disableCache();
}
Exemplo n.º 4
0
 public static function Load()
 {
     \Core\view()->addStylesheet('css/font-awesome.css');
     // Since the IE 7 version must be wrapped in the IE conditional... I need to manually resolve the asset.
     //\Core\view()->addStylesheet('<!--[if IE 7]><link rel="stylesheet" href="' . Core::ResolveAsset('css/font-awesome-ie7.css') . '"><![endif]-->');
     return true;
 }
Exemplo n.º 5
0
/**
 * @todo Finish documentation of smarty_function_head
 * @param array  $params  Associative (and/or indexed) array of smarty parameters passed in from the template
 * @param Smarty $smarty  Parent Smarty template object
 *
 * @return string
 */
function smarty_function_head($params, $smarty){

	$tmpl   = $smarty->getTemplateVars('__core_template');
	$view   = ($tmpl instanceof \Core\Templates\TemplateInterface) ? $tmpl->getView() : \Core\view();

	// Load any head elements currently in the CurrentPage cache
	return $view->getHeadContent();
}
Exemplo n.º 6
0
 public static function IncludeJPlayer()
 {
     ComponentHandler::LoadScriptLibrary('jquery');
     \Core\view()->addScript('js/jquery.jplayer.min.js');
     \Core\view()->addStylesheet('css/skin/jplayer.blue.monday.css');
     //Can has include?
     return true;
 }
 public static function Load()
 {
     // jqueryui is a dependency.
     JQuery::IncludeJQueryUI();
     \Core\view()->addScript('js/jquery/jquery.browser.js');
     \Core\view()->addScript('js/jquery/jquery.contextMenu.js');
     \Core\view()->addStylesheet('css/jquery.contextMenu.css');
     // IMPORTANT!  Tells the script that the include succeeded!
     return true;
 }
Exemplo n.º 8
0
 public static function Load2()
 {
     JQuery::IncludeJQuery();
     if (self::$_IncludedVersion === null || self::$_IncludedVersion === 2) {
         \Core\view()->addScript('js/jquery.cycle2.js');
         // IMPORTANT!  Tells the script that the include succeeded!
         self::$_IncludedVersion = 2;
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 9
0
 public static function LoadFancyIP()
 {
     // I need jquery ui first.
     \JQuery::IncludeJQueryUI();
     // And Core.Strings
     \Core::_AttachCoreStrings();
     // Add the styles
     \Core\view()->addStylesheet('assets/css/phpwhois/fancy_ip.css');
     // And the script itself
     \Core\view()->addScript('assets/js/phpwhois/fancy_ip.js');
     // IMPORTANT!  Tells the script that the include succeeded!
     return true;
 }
Exemplo n.º 10
0
 public static function Load()
 {
     // I need jquery UI as a pre-req...
     if (!JQuery::IncludeJQueryUI()) {
         return false;
     }
     if (ConfigHandler::Get('/core/javascript/minified')) {
         \Core\view()->addScript('js/jquery.lightbox-0.5.min.js');
     } else {
         \Core\view()->addScript('js/jquery.lightbox-0.5.js');
     }
     \Core\view()->addStylesheet('css/jquery.lightbox-0.5.css');
     // IMPORTANT!  Tells the script that the include succeeded!
     return true;
 }
Exemplo n.º 11
0
	/**
	 * Display a login widget with the actual login fields present.
	 */
	public function loginfull(){
		$view = $this->getView();

		// Is the user already logged in?
		if(\Core\user()->exists()){
			$view->assign('user', \Core\user());
		}
		else{
			// Display the standard login forms.

			// Set the page to use SSL if possible, since this login form has sensitive information, (username/pass).
			\Core\view()->ssl = true;

			$auths = \Core\User\Helper::GetEnabledAuthDrivers();

			$view->assign('user', false);
			$view->assign('drivers', $auths);
			$view->assign('allowregister', ConfigHandler::Get('/user/register/allowpublic'));
		}
	}
function smarty_function_progress_log_iframe($params, $smarty){

	$logname = isset($params['name']) ? $params['name'] : 'progress-log';
	$formid = isset($params['form']) ? $params['form'] : 'progress-log-form';

	$html = <<<EOD
<iframe id="$logname" name="$logname" style="display: none; width:90%; height:30em;"></iframe>
EOD;

	$script = <<<EOD
<script>
\$(function(){
	var go = null,
			log = document.getElementById('$logname'),
			\$log = $('#$logname');

		// Fix the width of the iframe.
		//log.width = $('body').width() * .8;

		$('#$formid').submit(function() {
			\$log.show();
			go = setInterval(
				function(){
					log.contentWindow.scrollBy(0,100);
				}, 25
			);
		});

		\$log.load(function(){
			clearInterval(go);
			log.contentWindow.scrollBy(0,5000);
		});
	});
</script>
EOD;

	\Core\view()->addScript('jquery');
	\Core\view()->addScript($script, 'foot');
	return $html;
}
Exemplo n.º 13
0
/**
 * Encode an email address in a way that makes it difficult for standard bots to read.
 *
 * @todo Finish documentation of smarty_function_email
 *
 * @param array  $params  Associative (and/or indexed) array of smarty parameters passed in from the template
 * @param Smarty $smarty  Parent Smarty template object
 *
 * @throws SmartyException
 *
 * @return string
 */
function smarty_function_email($params, $smarty){

	if(isset($params['address']) && $params['address']){
		$email = $params['address'];
	}
	elseif(isset($params['email']) && $params['email']){
		$email = $params['email'];
	}
	elseif(isset($params[0]) && $params[0]){
		$email = $params[0];
	}
	else{
		return '{email} Unable to encode email addresses if no email is provided!';
	}

	\Core\view()->addScript('assets/js/core.strings.js');
	\Core\view()->addScript('assets/js/core.email.js');

	$id = 'e' . \Core\random_hex(5);
	$user = str_rot13(substr($email, 0, strpos($email, '@')));
	$tld = substr($email, strrpos($email, '.')+1);

	$atts = [
		'href' => '#',
		'id' => $id,
		'data-user' => $user,
		'data-tld' => $tld,
		'data-domain' => substr($email, strlen($user) + 1, -1-strlen($tld)),
	];

	$html = '';
	foreach($atts as $k => $v){
		$html .= ' ' . $k . '="' . $v . '"';
	}
	$html = '<a' . $html . '>#</a>';

	$html .= '<script type="text/javascript">Core.Email.Assemble("' . $id . '");</script>';
	return $html;
}
Exemplo n.º 14
0
/**
 * Include a script in the main template in either the head or at the end of the body
 *
 * {script} is the preferred way to load javascript from a template.
 *
 * #### Smarty Parameters
 *
 *  * library
 *    * string, the name of the registered script library to include
 *    * ex: "jquery", "jqueryui", etc.
 *  * src
 *    * string, full resolved URL or Core-resolvable location of the asset.
 *  * location
 *    * string, "foot", or "head".  Foot will append the script block at the end of the body, head inside the &lt;head/&gt; tag.
 *
 * #### Example Usage
 *
 * Include jquery on this page.
 * <pre>
 * {script library="jquery"}{/script}
 * </pre>
 *
 * Another way to call javascript libraries
 * <pre>
 * {script library="jquery"}{/script}
 * </pre>
 *
 * Traditional "src" tags work too
 * <pre>
 * {script src="http://blah.tld/js/jquery.js"}{/script}
 * </pre>
 *
 * Because it's a block-type tag... you can also do
 * <pre>
 * {script}
 * // This section is automatically plugged into a &lt;script&gt; tag.
 * {/script}
 * </pre>
 *
 * Specifying the location of the target rendering area is also allowable.
 * This is useful for scripts that expect to be at the end of the body tag.
 * <pre>
 * {script src="js/mylib/foo.js" location="head"}{/script}
 * {script src="js/mylib/foo.js" location="foot"}{/script}
 * </pre>
 *
 * @param array       $params  Associative (and/or indexed) array of smarty parameters passed in from the template
 * @param string|null $content Null on opening pass, rendered source of the contents inside the block on closing pass
 * @param Smarty      $smarty  Parent Smarty template object
 * @param boolean     $repeat  True at the first call of the block-function (the opening tag) and
 * false on all subsequent calls to the block function (the block's closing tag).
 * Each time the function implementation returns with $repeat being TRUE,
 * the contents between {func}...{/func} are evaluated and the function implementation
 * is called again with the new block contents in the parameter $content.
 *
 * @throws SmartyException
 */
function smarty_block_script($params, $content, $smarty, &$repeat){
	// This only needs to be called once.
	if($repeat) return;

	$tmpl   = $smarty->getTemplateVars('__core_template');
	$view   = ($tmpl instanceof \Core\Templates\TemplateInterface) ? $tmpl->getView() : \Core\view();

	// A script library name is provided.
	if(isset($params['name'])){
		if(!Core::LoadScriptLibrary($params['name'])){
			throw new SmartyException('Unable to load script library ' . $params['name']);
		}
	}
	// I guess using "library" to indicate the desired library would make sense too....
	elseif(isset($params['library'])){
		if(!Core::LoadScriptLibrary($params['library'])){
			$libs = Core::GetJSLibraries();
			throw new SmartyException('Unable to load script library ' . $params['library'] . '!<br/>(Did you mean one of the following?: ' . implode(', ', array_keys($libs)) . ')');
		}
	}
	// Allow {script} tags to be called with the traditional src attribute.
	// These are most common for external resources, like facebook connect or google tools
	// but also useful for any standard asset.
	elseif(isset($params['src'])){
		$loc = (isset($params['location']))? $params['location'] : 'head';
		$view->addScript($params['src'], $loc);
	}
	// a script tag can be called with no parameters, it is after all a script tag....
	elseif($content){
		// Does this content have a <script> tag already around it?
		if(strpos($content, '<script') === false){
			$content = '<script type="text/javascript">' . $content . '</script>';
		}
		$loc = (isset($params['location']))? $params['location'] : 'head';
		$view->addScript($content, $loc);
	}
}
Exemplo n.º 15
0
	/**
	 * Get the registered view for this template, useful for setting CSS and Scripts in correct locations in the markup.
	 *
	 * If no view has been set on this template, then \Core\view() should be returned.
	 *
	 * @return \View
	 */
	public function getView() {
		return $this->_view === null ? \Core\view() : $this->_view;
	}
Exemplo n.º 16
0
	/**
	 * Render this table's foot content, (everything below the records).
	 * @return string Full HTML Markup
	 */
	private function _renderFoot(){
		$out = '';

		if($this->_editform !== null){
			$out .= '<tr class="edit edit-record-buttons"><td colspan="' . (sizeof($this->_columns) + 1) . '">' .
				'<a href="#" class="control-edit-toggle button">Cancel</a>' .
				'<input type="submit" value="Save Quick Edit"/>' .
				'</td></tr>';
		}

		$out .= '</table>';

		if($this->_editform !== null){
			$out .= $this->_editform->render('foot');
		}

		$f = $this->getFilters();
		$out .= $f->pagination();

		if($f->getTotalCount() == 0 && !$f->hasSet()){
			return '';
		}

		// Don't forget the necessary scripts!
		\Core\view()->addScript('assets/js/core.listingtable.js', 'foot');
		\Core\view()->addScript("<script>new Core.ListingTable(\$('table[data-table-name=\"" . $this->_name . "\"]'), '" . $this->getFilters()->getSortKey() . "', '" . $this->getFilters()->getSortDirection() . "');</script>", 'foot');

		return $out;
	}
Exemplo n.º 17
0
/**
 * Manually add a widget onto a template.
 *
 * @todo Finish documentation of smarty_function_widget
 *
 * @param array  $params  Associative (and/or indexed) array of smarty parameters passed in from the template
 * @param Smarty $smarty  Parent Smarty template object
 *
 * @return mixed
 *
 * @throws SmartyException
 */
function smarty_function_widget($params, $smarty){

	$assign  = (isset($params['assign']))? $params['assign'] : false;
	$tmpl    = $smarty->getTemplateVars('__core_template');
	$topview = ($tmpl instanceof \Core\Templates\TemplateInterface) ? $tmpl->getView() : \Core\view();

	// Version 2.0 uses baseurl as the defining call.
	if(isset($params['baseurl'])){
		$api = 2.0;
		$parts = WidgetModel::SplitBaseURL($params['baseurl']);
		$original = $params['baseurl'];
		$name = $parts['controller'];
		$method = $parts['method'];
		$parameters = $parts['parameters'];
	}
	// Version 1.0 uses name.
	elseif(isset($params['name'])){
		$api = 1.0;
		$original = $params['name'];
		$name = $params['name'];
		// Try to look up this requested widget.
		$name .= 'Widget';
		$parameters = null;
		$method = null;
	}
	else{
		$api = 0.0;
		$name = null;
		$original = null;
		$parameters = null;
		$method = null;
	}


	if(!class_exists($name)){
		if(DEVELOPMENT_MODE){
			return '[ERROR, Class for ' . $original . ' not found on system, widget disabled.]';
		}
		else{
			return '';
		}

		//throw new SmartyException('Unable to locate class [' . $name . '] for requested widget', null, null);
	}
	// @todo Add support for requiring instancing.

	/** @var $w Widget_2_1 */
	$w = new $name();
	// Version 1.0 API
	if($api == 1.0){
		$dat = $w->execute()->fetch();
	}
	// Version 2.0 API
	elseif($api == 2.0){
		$w->_params = $parameters;

		// Ensure that the widget's View knows it's linked to a parent!
		$w->getView()->parent = $topview;

		// Populate the request with the inbound data too.
		$request = $w->getRequest();
		if(isset($params['baseurl'])) unset($params['baseurl']);

		if($parameters) $request->parameters = array_merge($params, $parameters);
		else $request->parameters = $params;

		$return = call_user_func(array($w, $method));
		$dat = null;

		if(is_int($return)){
			throw new SmartyException("widget $name/$method returned error code $return.", null, null);
		}
		elseif($return === null){
			// Hopefully it's setup!
			$return = $w->getView();
		}
		// If it's just a string, return that.
		elseif(is_string($return)) {
			$dat = $return;
		}


		// If dat is still null, (it probably is still null btw), then render the template!
		if($dat === null){
			// Try to guess the templatename if it wasn't set.
			if($return->error == View::ERROR_NOERROR && $return->contenttype == View::CTYPE_HTML && $return->templatename === null){
				$cnameshort = (strpos($name, 'Widget') == strlen($name) - 6) ? substr($name, 0, -6) : $name;
				$return->templatename = strtolower('/widgets/' . $cnameshort . '/' . $method . '.tpl');
			}

			$dat = $return->fetch();
		}
	}
	else{
		$dat = 'Invalid API version';
	}


	return $assign ? $smarty->assign($assign, $dat) : $dat;
}
Exemplo n.º 18
0
	/**
	 * Test that a file can be sent to the user agent via the File interface.
	 */
	public function testSendToUserAgent(){
		$file = new \Core\Filestore\Backends\FileLocal('core/tests/ivak_TV_Test_Screen.png');

		ob_start();
		$file->sendToUserAgent(true);
		$contents = ob_get_clean();

		$headers = \Core\view()->headers;

		$this->assertArrayHasKey('Content-Disposition', $headers);
		$this->assertArrayHasKey('Cache-Control', $headers);
		$this->assertArrayHasKey('Content-Transfer-Encoding', $headers);
		$this->assertArrayHasKey('Content-Length', $headers);

		$this->assertEquals('image/png', \Core\view()->contenttype);

		$this->assertNotEmpty($contents);
	}
Exemplo n.º 19
0
 private static function _IncludeMode($mode)
 {
     self::IncludeCodeMirror();
     \Core\view()->addScript('libs/codemirror/mode/' . $mode . '/' . $mode . '.js');
     return true;
 }
Exemplo n.º 20
0
    public static function Includejs($async = true)
    {
        $src = 'connect.facebook.net/en_US/all.js';
        $p = SSL ? 'https://' : 'http://';
        $appid = FACEBOOK_APP_ID;
        $token = \Core\user()->get('facebook_access_token');
        $id = \Core\user()->get('facebook_id');
        if (!$token) {
            $token = "null";
        } else {
            $token = '"' . $token . '"';
        }
        if (!$id) {
            $id = "null";
        }
        // Facebook also requires a location to render to.
        \Core\view()->appendBodyContent('<div id="fb-root"></div>');
        if ($async) {
            // This script does the init and the include in one go.
            $script = <<<EOD
<script type="text/javascript">
Core.FB = {
\tstatus: "loading",
\tready: false,
\taccess_token: {$token},
\tid: {$id},
\tappid: "{$appid}",
\tonReady: function(fn){
\t\tif(Core.FB.ready) fn();
\t\telse Core.FB._onReadyStack.push(fn);
\t},
\t_onReadyStack: []
};

if(Core.FB.appid){
\twindow.fbAsyncInit = function() {
\t\tFB.init({
\t\t\tappId: '{$appid}',
\t\t\tstatus: true,
\t\t\tcookie: true,
\t\t\txfbml: true,
\t\t\toauth: true
\t\t});
\t\tCore.FB.ready = true;
\t\tCore.FB.status = 'loaded';
\t\tfor(i in Core.FB._onReadyStack){
\t\t\tif(typeof Core.FB._onReadyStack[i] == 'function') Core.FB._onReadyStack[i]();
\t\t}
\t};

\t(function() {
\t\tvar e = document.createElement('script'); e.async = true;
\t\te.src = "{$p}" + "{$src}";
\t\tdocument.getElementById('fb-root').appendChild(e);
\t}());
}
else{
\tconsole.log('Refusing to try to load facebook with no appid set.  Please configure it first!');
}


</script>
EOD;
            // Add the necessary script
            \Core\view()->addScript($script, 'foot');
        } else {
            // Just the simple script. (which is actually in 2 parts)
            $script = $p . $src;
            \Core\view()->addScript($script, 'foot');
            $script = <<<EOD
<script type="text/javascript">
\tFB.init({
\t\tappId: '{$appid}',
\t\tstatus: true,
\t\tcookie: true,
\t\txfbml: true,
\t\toauth: true
\t});
</script>
EOD;
            // And the second part.
            \Core\view()->addScript($script, 'foot');
        }
        \Core\view()->setHTMLAttribute('xmlns:fb', 'http://www.facebook.com/2008/fbml');
        return true;
    }
Exemplo n.º 21
0
 public static function Include_Icheck()
 {
     self::IncludeJQuery();
     \Core\view()->addStylesheet('css/jquery.icheck.css');
     \Core\view()->addScript('js/jquery/jquery.icheck.js');
     // IMPORTANT!  Tells the script that the include succeeded!
     return true;
 }
Exemplo n.º 22
0
	public static function _AttachJSON(){
		\Core\view()->addScript ('js/json2.js', 'head');

		// IMPORTANT!  Tells the script that the include succeeded!
		return true;
	}
Exemplo n.º 23
0
 public static function IncludeJS()
 {
     \Core\view()->addScript('assets/js/js-cookie/js.cookie.js', 'head');
     return true;
 }
Exemplo n.º 24
0
/**
 * @todo Finish documentation of smarty_function_widgetarea
 * @param array  $params  Associative (and/or indexed) array of smarty parameters passed in from the template
 * @param Smarty_Internal_Template $smarty  Parent Smarty template object
 *
 * @return string|void
 */
function smarty_function_widgetarea($params, $smarty) {
	// Get all widgets set to load in this area.

	$body     = '';
	$baseurl  = PageRequest::GetSystemRequest()->getBaseURL();
	$template = $smarty->template_resource;
	$tmpl     = $smarty->getTemplateVars('__core_template');
	$topview  = ($tmpl instanceof \Core\Templates\TemplateInterface) ? $tmpl->getView() : \Core\view();

	$parameters  = [];
	$name        = null;
	$installable = null;
	$assign      = null;
	foreach($params as $k => $v){
		switch($k){
			case 'name':
				$name = $v;
				break;
			case 'installable':
				$installable = $v;
				break;
			case 'assign':
				$assign = $v;
				break;
			default:
				$parameters[$k] = $v;
				break;
		}
	}

	// I need to resolve the page template down to the base version in order for the lookup to work.
	foreach(Core\Templates\Template::GetPaths() as $base){
		if(strpos($template, $base) === 0){
			$template = substr($template, strlen($base));
			break;
		}
	}

	// Given support for page-level widgets, this logic gets slightly more difficult...
	$factory = new ModelFactory('WidgetInstanceModel');
	$factory->order('weight');
	if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::IsEnabled()){
		$factory->whereGroup('or', ['site = -1', 'site = ' . MultiSiteHelper::GetCurrentSiteID()]);
	}

	$subwhere = new Core\Datamodel\DatasetWhereClause();
	$subwhere->setSeparator('OR');

	// First, the skin-level where clause.
	$skinwhere = new Core\Datamodel\DatasetWhereClause();
	$skinwhere->setSeparator('AND');
	$skinwhere->addWhere('template = ' . $template);
	$skinwhere->addWhere('widgetarea = ' . $name);
	$subwhere->addWhere($skinwhere);

	// And second, the page-level where clause.
	if($baseurl){
		$pagewhere = new Core\Datamodel\DatasetWhereClause();
		$pagewhere->setSeparator('AND');
		$pagewhere->addWhere('page_baseurl = ' . $baseurl);
		$pagewhere->addWhere('widgetarea = ' . $name);
		$subwhere->addWhere($pagewhere);
	}

	$factory->where($subwhere);


	$widgetcount = 0;
	try{
		$widgets = $factory->get();
	}
	catch(Exception $e){
		if(DEVELOPMENT_MODE){
			$body .= '<p class="message-error">Exception while trying to load widget area ' . $name . '!</p>';
			$body .= '<pre class="xdebug-var-dump">' . $e->getMessage() . '</pre>';
		}
		else{
			\Core\ErrorManagement\exception_handler($e, false);
		}
		$widgets = [];
		++$widgetcount;
	}


	foreach ($widgets as $wi) {
		/** @var $wi WidgetInstanceModel */
		// User cannot access this widget? Don't display it...
		if(!\Core\user()){
			continue;
		}
		if (!\Core\user()->checkAccess($wi->get('access'))){
			continue;
		}

		if($installable){
			$wi->set('installable', $installable);
		}
		$view = $wi->execute($parameters);

		// Some widgets may return simply a blank string.  Those should just be ignored.
		if ($view == ''){
			continue;
		}

		// If it's just a string, return that.
		if (is_string($view)) {
			$contents = $view;
		}
		elseif($view->error == View::ERROR_NOERROR){
			// Ensure that the widget's View knows it's linked to a parent!
			$view->parent = $topview;

			$contents = $view->fetch();
		}
		else{
			$contents = 'Error displaying widget [' . $wi->get('baseurl') . '], returned error [' . $view->error . ']';
		}
		++$widgetcount;
		
		// Does this widget have controls attached to it?
		$widget = $wi->getWidget();
		if($widget->controls instanceof ViewControls && $widget->controls->hasLinks()){
			$contents = '<div class="widget-controls-wrapper">' .
				'<menu id="widget-controls-' . $wi->get('id') . '">' . 
				$widget->controls->fetch() . 
				'</menu>' . 
				'</div>' .
				$contents;
		}

		$body .= '<div class="widget">' . $contents . '</div>';
	}

	// Do some sanitizing for the css data
	$class = 'widgetarea-' . strtolower(str_replace(' ', '', $name));

	$html = '<div class="widgetarea ' . $class . '" widgetarea="' . $name . '">' . $body . '</div>';

	// No widgets, no inner content!
	if($widgetcount == 0){
		$html = '';
	}

	if($assign){
		$smarty->assign($assign, $html);
	}
	else{
		return $html;
	}
}
Exemplo n.º 25
0
	/**
	 * @deprecated 2013.08.18
	 * @return string
	 */
	public static function GetFoot() {
		trigger_error('View::GetFoot is deprecated, please use \Core\view()->getFootContent instead!', E_USER_DEPRECATED);
		return \Core\view()->getFootContent();
	}
Exemplo n.º 26
0
 public static function Load()
 {
     $key = \ConfigHandler::Get('/google/services/public_api_key');
     \Core\view()->addScript('<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=' . $key . '"></script>', 'head');
     return true;
 }
Exemplo n.º 27
0
	public function render() {
		$out = '';
		foreach ($this->_elements as $e) {
			$out .= $e->render();
		}

		$file = $this->getTemplateName();

		// Groups may not have a template... if so just render the children directly.
		if (!$file) return $out;

		// There is a form on the page, do not allow caching.
		\Core\view()->disableCache();
		$tpl = \Core\Templates\Template::Factory($file);
		$tpl->assign('group', $this);
		$tpl->assign('elements', $out);
		return $tpl->fetch();
	}
Exemplo n.º 28
0
	/**
	 * Send a file to the user agent
	 *
	 * @param bool $forcedownload Set to true to force download instead of just sending the file.
	 *
	 * @throws \Exception
	 *
	 * @return void
	 */
	public function sendToUserAgent($forcedownload = false) {
		$view = \Core\view();
		$request = \Core\page_request();

		$view->mode = \View::MODE_NOOUTPUT;
		$view->contenttype = $this->getMimetype();
		$view->updated = $this->getMTime();
		if($forcedownload){
			$view->headers['Content-Disposition'] = 'attachment; filename="' . $this->getBasename() . '"';
			$view->headers['Cache-Control'] = 'no-cache, must-revalidate';
			$view->headers['Content-Transfer-Encoding'] = 'binary';
		}
		$view->headers['Content-Length'] = $this->getFilesize();

		// Send all the view headers
		$view->render();

		// And now the actual content if it's not a HEAD request.
		if($request->method != \PageRequest::METHOD_HEAD){
			echo $this->getContents();
		}
	}
Exemplo n.º 29
0
 public static function Load()
 {
     \Core\view()->addScript('js/jquery.hoverIntent.min.js');
     // IMPORTANT!  Tells the script that the include succeeded!
     return true;
 }
Exemplo n.º 30
0
 public static function SearchResultsTracking(SearchResults $search)
 {
     // trackSiteSearch(keyword, [category], [resultsCount]
     $snippet = '<script>if(typeof(Piwik) != "undefined"){ Piwik.getAsyncTracker().trackSiteSearch("' . htmlentities($search->query) . '", null, ' . $search->getCount() . ');}</script>';
     \Core\view()->addScript($snippet, 'foot');
     return true;
 }