作者:BBK-PiJ-2014-8
项目:learning-phalco
public function initialize()
{
Tag::prependTitle('Fireball | ');
$this->assets->collection('style')->addCss('third-party/css/bootstrap.min.css', false, false)->addCss('css/style.css')->setTargetPath('css/production.css')->setTargetUri('css/production.css')->join(true)->addFilter(new \Phalcon\Assets\Filters\Cssmin());
//takes the js or css files and combines / minifies them for faster page loads
$this->assets->collection('js')->addJs('third-party/js/jquery-1.12.0.min.js', false, false)->addJs('third-party/js/bootstrap.min.js', false, false)->setTargetPath('js/production.js')->setTargetUri('js/production.js')->join(true)->addFilter(new \Phalcon\Assets\Filters\Jsmin());
}
作者:serge230
项目:madehear
public function initialize()
{
$this->view->setTemplateAfter('main');
$this->view->hdr = 'Купоны';
Tag::setTitle('Coupons Panel');
parent::initialize();
}
作者:hongke
项目:Blo
public function initialize()
{
\Phalcon\Tag::setTitle('登录');
parent::initialize();
$this->view->setTemplateAfter('login_register');
$this->operation = new UserOperation($this->di);
}
作者:kjmtru
项目:blo
public function editAction($id)
{
$fileStore = FileStore::findFirst($id);
if ($fileStore == false) {
$this->flash->error(_("Document was not found"));
return $this->dispatcher->forward(array('action' => 'index'));
}
$request = $this->request;
$userId = $this->auth->getIdentity();
$form = new FileStoreForm($fileStore, array('edit' => true));
if ($request->isPost()) {
if ($form->isValid($request->getPost()) == true && $request->hasFiles() == true) {
$fileStore = new FileStore();
foreach ($request->getUploadedFiles() as $file) {
$fileStore->assign(array('id' => $id, 'fileName' => $file->getName(), 'fileCaption' => $request->getPost('fileCaption'), 'description' => $request->getPost('description'), 'categoriesId' => $request->getPost('categoriesId'), 'userId' => $userId['id'], 'mimeType' => $file->getType(), 'fileData' => file_get_contents($file->getTempName())));
if ($fileStore->update() == true) {
$this->flash->success(_("Update Document success"));
Tag::resetInput();
return $this->dispatcher->forward(array('action' => 'index'));
}
$this->flash->error($fileStore->getMessages());
}
}
}
$this->view->form = $form;
}
作者:vnlit
项目:phalcon-angular-harryhogfootbal
/**
* The index action
*/
public function indexAction()
{
if (!$this->request->isPost()) {
Tag::setDefault('username', 'user@email.com');
Tag::setDefault('password', 'hhf');
}
}
作者:lookingatsk
项目:zhonghewanban
public function verifyAction($code)
{
if ($code) {
$results = VerifyEmail::FindFirst("verifyCode = '" . $code . "'");
if (!isset($results->cid)) {
return $this->response->redirect("index/index");
}
$form = new RegisterForm();
if (isset($results) && $results != '') {
if ($results->active == 'Y') {
if (md5($results->time . '+' . $results->email) == $code) {
$this->view->form = $form;
Tag::setDefault('password', null);
Tag::setDefault('cid', $results->cid);
Tag::setDefault('email', $results->email);
$this->view->setVar("email", $results->email);
} else {
$this->flash->error('邮箱验证错误!');
$this->response->redirect("account/index");
}
} else {
$this->flash->error('邮箱已经验证通过,请登录!');
$this->response->redirect("account/index");
}
} else {
$this->flash->error('验证码已过期!');
$this->response->redirect("index/index");
}
} else {
$this->response->redirect("index/index");
}
}
作者:atduart
项目:allso
/**
* Prints the HTML for CSS resources
*
* @param string $collectionName the name of the collection
*
* @return string the result of the collection
**/
public function outputCss($collectionName = null)
{
$collection = $this->collection($collectionName);
if ($collection->getJoin()) {
$filename = $collection->getTargetPath();
if (file_exists($filename)) {
$time = 0;
foreach ($collection->getResources() as $resource) {
$tmp = filemtime($resource->getRealTargetPath());
if ($tmp > $time) {
$time = $tmp;
}
}
// If created
if (filemtime($filename) > $time) {
$collection->setTargetUri($collection->getTargetUri() . '?' . filemtime($filename));
return Tag::stylesheetLink($collection->getTargetUri());
}
}
// Else CREATE
$res = parent::outputCss($collectionName);
return $res;
}
return parent::outputCss($collectionName);
}
作者:atnartu
项目:SimpleBannerRotato
public function statisticAction()
{
$id = $this->dispatcher->getParam('id');
$banner = Banners::findFirst($id);
if ($id && $banner && $banner->advertiser_id == $this->auth->get_user()->id) {
$this->assets->collection('bottom-js')->addJs('js/moment/moment.min.js')->addJs('js/moment/ru.js')->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js');
$this->assets->collection('css')->addCss('js/datetimepicker/css/bootstrap-datetimepicker.min.css');
if (!$this->request->getQuery('start_date')) {
if (!empty($banner->start_date)) {
$start_date = $banner->start_date;
} else {
$first_view = $banner->views->getFirst()->date;
if (!empty($first_view)) {
$start_date = $first_view;
} else {
$start_date = 0;
}
}
} else {
$start_date = date_parse_from_format('d.m.Y H:i', $this->request->getQuery('start_date'));
$start_date = mktime($start_date['hour'], $start_date['minute'], 0, $start_date['month'], $start_date['day'], $start_date['year']);
}
if (!$this->request->getQuery('end_date')) {
if (!empty($banner->end_date)) {
if ($banner->end_date > time()) {
$end_date = time();
} else {
$end_date = $banner->end_date;
}
} else {
$end_date = time();
}
} else {
$end_date = date_parse_from_format('d.m.Y H:i', $this->request->getQuery('end_date'));
$end_date = mktime($end_date['hour'], $end_date['minute'], 0, $end_date['month'], $end_date['day'], $end_date['year']);
}
$days = floor(($end_date + 10800) / 86400) - floor(($start_date + 10800) / 86400) + 1;
$days_arr = [];
if ($days > 0) {
for ($i = 0; $i < $days; $i++) {
$day = floor(($start_date + 10800) / 86400) * 86400 + $i * 86400 - 10800;
if ((!empty($banner->start_date) ? $day >= floor(($banner->start_date + 10800) / 86400) * 86400 - 10800 : true) && $day < (!empty($banner->end_date) ? $banner->end_date : time())) {
$days_arr[] = array('date' => $day, 'views' => $banner->countViews("date >= {$day} AND date < " . ($day + 86400)), 'clicks' => $banner->countViews("date >= {$day} AND date < " . ($day + 86400) . " AND clicked = 1"));
}
}
}
$this->view->days = $days_arr;
$q = "date >= {$start_date} AND date <= {$end_date}";
$this->view->views = $banner->countViews(array($q));
$q .= " AND clicked = 1";
$this->view->clicks = $banner->countViews(array($q));
$this->view->start_date = $start_date;
$this->view->end_date = $end_date;
$this->view->banner = $banner;
$this->view->title = "Статистика для баннера \"{$banner->name}\"";
\Phalcon\Tag::prependTitle("Статистика для баннера \"{$banner->name}\"");
} else {
$this->dispatcher->forward(array("namespace" => 'App\\Controllers', "controller" => "error", "action" => "notFound"));
}
}
作者:lookingatsk
项目:zhonghewanban
public function profileAction()
{
$auth = $this->session->get('auth');
$user = Users::findFirst($auth['id']);
if ($user == false) {
$this->_forward('index/index');
}
$request = $this->request;
if (!$request->isPost()) {
Tag::setDefault('name', $user->name);
Tag::setDefault('email', $user->email);
} else {
$name = $request->getPost('name', 'string');
$email = $request->getPost('email', 'email');
$name = strip_tags($name);
$user->name = $name;
$user->email = $email;
if ($user->save() == false) {
foreach ($user->getMessages() as $message) {
$this->flash->error((string) $message);
}
} else {
$this->flash->success('更新成功');
}
}
}
作者:vnlit
项目:phalcon-angular-harryhogfootbal
public function initialize()
{
Tag::setTitle('About');
parent::initialize();
$this->_bc->add('About', 'about');
$this->view->setVar('menus', $this->constructMenu($this));
}
作者:devsnippe
项目:city_sit
public function run()
{
$this->assets->outputCss();
$this->assets->outputJs();
echo Tag::textArea(array("{$this->id}", "name" => "{$this->name}"));
echo '<div class="hint"><a onclick="return setupElrteEditor(\'' . $this->id . '\', this, \'' . $this->theme . '\', \'' . $this->height . '\');">WYSIWYG</a></div>';
}
作者:enricowillems
项目:prime_admi
protected function initialize()
{
\Phalcon\Tag::prependTitle('PRIME | ');
$this->view->setViewsDir('../app/views/');
$this->view->setLayoutsDir('/layouts/');
$this->view->setTemplateAfter('main');
}
作者:gitter-badge
项目:phanboo
public function run()
{
$faker = Faker::create();
$log = new Stream('php://stdout');
$log->info('Start ' . __CLASS__);
/** @var Phalcon\Db\AdapterInterface $database */
$database = $this->getDI()->get('db');
$database->begin();
for ($i = 0; $i <= self::TAGS_TOTAL; $i++) {
$title = $faker->company;
$description = $faker->text;
$tags = new Tags();
$tags->name = $title;
$tags->slug = \Phalcon\Tag::friendlyTitle($title);
$tags->numberPosts = 0;
$tags->noBounty = 'N';
$tags->noDigest = 'N';
$tags->description = $description;
if (!$tags->save()) {
var_dump($tags->getMessages());
$database->rollback();
die;
}
$log->info('tags: ' . $tags->getName());
}
}
作者:devsnippe
项目:city_sit
/**
* Starts a session in the admin backend
*/
public function loginAction()
{
\Phalcon\Tag::appendTitle(" - Вход");
$form = new LoginForm();
try {
if (!$this->request->isPost()) {
if ($this->auth->hasRememberMe()) {
return $this->auth->loginWithRememberMe();
}
} else {
if ($form->isValid($this->request->getPost()) == false) {
foreach ($form->getMessages() as $message) {
$this->flash->error($message);
}
} else {
$this->auth->check(array('email' => $this->request->getPost('email', 'email'), 'password' => $this->request->getPost('password'), 'remember' => $this->request->getPost('remember')));
$auth = $this->session->get('auth');
$this->flashSession->notice($auth['role']);
if (!$auth) {
$this->flashSession->notice("Нужно войти или зарегистрироваться");
return $this->response->redirect("session/login");
}
if ($auth['role'] == 'Administrators') {
$this->flashSession->success("Здравствуйте администратор. Вы находитесь в области управления сайтом, в разделе Новости.");
return $this->response->redirect("backend/news");
}
return $this->response->redirect();
}
}
} catch (AuthException $e) {
$this->flash->error($e->getMessage());
}
$this->view->form = $form;
}
作者:hongke
项目:Blo
/**
* 初始化
*/
protected function initialize()
{
parent::initialize();
//Prepend the application name to the title
\Phalcon\Tag::prependTitle('Blog | ');
$this->view->setTemplateAfter('common');
}
作者:fredd-fo
项目:contratacione
public function registerAction()
{
$request = $this->request;
if ($request->isPost()) {
$name = $request->getPost('name', array('string', 'striptags'));
$username = $request->getPost('username', 'alphanum');
$email = $request->getPost('email', 'email');
$password = $request->getPost('password');
$repeatPassword = $this->request->getPost('repeatPassword');
if ($password != $repeatPassword) {
$this->flash->error('Passwords are diferent');
return false;
}
$user = new Users();
$user->username = $username;
$user->password = sha1($password);
$user->name = $name;
$user->email = $email;
$user->created_at = new Phalcon\Db\RawValue('now()');
$user->active = 'Y';
if ($user->save() == false) {
foreach ($user->getMessages() as $message) {
$this->flash->error((string) $message);
}
} else {
Tag::setDefault('email', '');
Tag::setDefault('password', '');
$this->flash->success('Thanks for sign-up, please log-in to start generating invoices');
return $this->forward('session/index');
}
}
}
作者:aisuhu
项目:phalcon-ph
/**
* Renders the element widget returning html
*
* @param array|null $attributes
* @return string
* @throws Exception
*/
public function render($attributes = null)
{
if (is_array($attributes) === false && is_null($attributes) === false) {
throw new Exception('Invalid parameter type.');
}
return Tag::numericField($this->prepareAttributes($attributes));
}
作者:hyfjjj
项目:HHA-We
public function initialize()
{
// $this->view->setTemplateAfter('main');
Resource::init($this->assets);
Tag::setTitle('Welcome');
parent::initialize();
}
作者:lookingatsk
项目:zhonghewanban
public function indexAction()
{
if (!$this->request->isPost()) {
Tag::setDefault('email', ' ');
Tag::setDefault('password', '');
}
}
作者:gitter-badge
项目:phanboo
public function run()
{
$faker = Faker::create();
$log = new Stream('php://stdout');
$log->info('Start ' . __CLASS__);
/** @var Phalcon\Db\AdapterInterface $database */
$database = $this->getDI()->get('db');
$userIds = Users::find(['columns' => 'id'])->toArray();
$database->begin();
for ($i = 0; $i <= self::POSTS_TOTAL; $i++) {
$title = $faker->company;
$userRandId = array_rand($userIds);
$posts = new Posts();
$posts->usersId = $userIds[$userRandId]['id'];
$posts->type = rand(0, 1) ? 'questions' : 'tips';
$posts->title = $title;
$posts->slug = \Phalcon\Tag::friendlyTitle($title);
$posts->numberViews = rand(5, 100);
$posts->numberReply = rand(0, 20);
$posts->content = $faker->text;
$posts->sticked = 'N';
$posts->status = 'A';
$posts->locked = 'N';
$posts->deleted = 0;
$posts->acceptedAnswer = 'N';
if (!$posts->save()) {
var_dump($posts->getMessages());
$database->rollback();
die;
}
$log->info('posts: ' . $posts->getTitle());
}
}