Exemplo n.º 1
0
 public function analytics($link, $section, $count = '')
 {
     $accents = array('é', 'û');
     $noaccents = array('e', 'u');
     $today = str_replace($accents, $noaccents, $this->analyticsDate());
     $template = Atomik::get('request.template');
     $issue = Atomik::get('issue');
     $link .= "/?utm_source={$template}-{$today}&utm_medium={$template}&utm_content={$section}-{$count}&utm_campaign={$issue}";
     return $link;
 }
Exemplo n.º 2
0
	protected function _getList($field, $possibleValues)
	{
		$selectedValue = Atomik::get('request/filters/' . $field, '');
		
		$html = '<ul ' . ($selectedValue == '' ? 'style="display:none"' : '') . '>';
		foreach ($possibleValues as $label => $value) {
			$html .= '<li><a ' . ($value == $selectedValue ? 'class="current"' : '') 
				   . ' href="' . $this->_getUrl($field, $value) . '">' . $label . '</a></li>';
		}
		$html .= '</ul>';
		return $html;
	}
Exemplo n.º 3
0
 public function annonceUne($url, $img)
 {
     $data = new DataController($url);
     $db = Atomik::get('db');
     $this->title = $data->fetchTitle('h1', 1);
     $this->text = $data->fetchCalendarText();
     $this->link = $data->fetchLink();
     $funtionName = __FUNCTION__;
     $this->viewOutput = Atomik::render('blocs/leadArticle', array('title' => $this->title, 'text' => $this->text, 'link' => $this->link, 'img' => $img, 'section' => $funtionName));
     echo $this->viewOutput;
 }
Exemplo n.º 4
0
<?php

if (!Atomik::has('request/name') || !Atomik::has('request/id')) {
	Atomik::redirect('index');
}

$modelName = Atomik::get('request/name');
$returnUrl = Atomik::get('request/returnUrl', Atomik::url('models/list', array('name' => $modelName)));
$model = Atomik_Model::find($modelName, Atomik::get('request/id'));
$title = (string) $model;

if (!$model->delete()) {
	Atomik::flash(__('An error occured while deleting %s %s', strtolower($modelName), $title), 'error');
} else {
	Atomik::flash(__('%s %s successfully deleted', $modelName, $title), 'success');
	Backend_Activity::create('Models', __('%s %s has been deleted', $modelName, $title), __('Deleted by') . ' %s');
}

Atomik::redirect($returnUrl, false);
Exemplo n.º 5
0
 public function index()
 {
     $json = file_get_contents(Atomik::get('base_dir') . '/app/models/magazines.json');
     $this->newsletters = json_decode($json, true);
 }
Exemplo n.º 6
0
if (!Atomik::has('request/name')) {
	Atomik::redirect('models');
}

$modelName = Atomik::get('request/name');
$returnUrl = Atomik::get('request/returnUrl', Atomik::url('models/list', array('name' => $modelName)));
$builder = Atomik_Backend_Models::getModelBuilder($modelName);

$actionString = 'created';
$title = __('Create a new') . ' %s';
$message = __('A %s has been created', strtolower($modelName));

$model = $modelName;
if (Atomik::has('request/id')) {
	$model = Atomik_Model::find($builder, Atomik::get('request/id'));
	$actionString = 'modified';
	$title = __('Edit') . ' %s: ' . $model;
	$message = __('%s %s has been modified', $modelName, $model);
}

$form = new Atomik_Model_Form($model, array('form-', 'admin-form-'));
$form->setAction(Atomik::url());
$form->setOption('cancel-url', $returnUrl);

if ($form->hasData()) {
	if ($form->isValid()) {
		$model = $form->getModel();
		$model->save();
		Backend_Activity::create('Models', $message, __(ucfirst($actionString) . ' by') . ' %s');
		Atomik::redirect($returnUrl, false);
Exemplo n.º 7
0
 /**
  * Stops output buffering and stores output in cache
  *
  * @param bool $succes Core end success
  */
 public static function onAtomikEnd($success)
 {
 	/* checks if we cache this request */
 	if (!$success) {
 		return;
 	}
 	
 	/* gets the output and print it */
 	$output = ob_get_clean();
 	echo $output;
 	
 	$cacheFilename = self::$config['filename'];
 	$request = Atomik::get('request');
     $request = implode('.', Atomik::get('request'));
 	
 	/* checks if the current url is cacheable */
 	$requests = self::$config['requests'];
 	if (isset($requests[$request])) {
 		/* saves output to file */
 		@file_put_contents($cacheFilename, $output);
 	}
 }
Exemplo n.º 8
0
 public function offsetGet($key)
 {
     return Atomik::get($key);
 }
Exemplo n.º 9
0
<?php

/* This script fetches the cars from database, shuffles the result and picks the two topmost ones to display on the page */
$carresult = A('db:carselection');
$allcars = $carresult->fetchAll();
shuffle($allcars);
$leftcar = $allcars[0];
$rightcar = $allcars[1];
Atomik::set('scripts', array_merge(Atomik::get('scripts'), array('assets/js/create_selection_form.js')));
Exemplo n.º 10
0
<?php

if (!Atomik::has('request/name')) {
	Atomik::redirect('index');
}

$modelName = Atomik::get('request/name');
$builder = Atomik_Backend_Models::getModelBuilder($modelName);

$models = new Atomik_Model_Query();
$models->from($builder)->filter(Atomik::get('request/filters', array()));

if (isset($_POST['search'])) {
	$models->where($_POST['searchBy'] . ' LIKE ?', '%' . $_POST['search'] . '%');
}

$columns = array();
foreach ($builder->getFields() as $field) {
	if (($builder->isFieldThePrimaryKey($field) || $builder->isFieldPartOfReference($field) ||
		$field->hasOption('admin-hide-in-list')) && !$field->hasOption('admin-show-in-list')) {
			continue;
	}
	$columns[$field->name] = $field->getLabel();
}

$editUrl = Atomik::get('request/editUrl', Atomik::url('models/edit', array('name' => $modelName)));
$deleteUrl = Atomik::get('request/deleteUrl', Atomik::url('models/delete', array('name' => $modelName)));
 public function __construct()
 {
     $this->_json = file_get_contents(Atomik::get('base_dir') . '/app/models/magazines.json');
     $this->{$_magazines} = json_decode($this->_json);
 }