/** * Render * * @return string */ public function render() { $this->options['lang'] = config('site.locale', 'en'); extract((array) $this->options); cogear()->elfinder->load(); inline_js("\$(document).ready(\r\n\t\tfunction()\r\n\t\t{\r\n var opts = {\r\n lang: '{$lang}',\r\n styleWithCSS: " . ($styleWithCSS ? 'true' : 'false') . ",\r\n width: '{$width}',\r\n height: {$height},\r\n toolbar: '{$toolbar}',\r\n cssfiles : ['" . Url::gear('elrte') . "/css/elrte-inner.css'],\r\n fmAllow: true,\r\n fmOpen: function(callback){\r\n \$(\"<div id='{$this->getId()}-elfinder'>\").elfinder({\r\n url: '" . Url::gear('elfinder') . "connector/',\r\n lang: '{$lang}',\r\n dialog : { width : 900, modal : true, title : '" . t('Files') . "' }, // открываем в диалоговом окне\r\n closeOnEditorCallback : true, // закрываем после выбора файла\r\n editorCallback : callback\r\n })\r\n }\r\n };\r\n \$('#{$this->getId()} textarea').elrte(opts);\r\n\t\t}\r\n\t);"); event('elRTE.load', $this); return parent::render(); }
/** * Initializing menu system * * @param type $name * @param type $menu */ public function menu($name, $menu) { if ($name == 'install') { $root = Url::gear('install'); $menu->{$root . 'welcome'} = t('1. Welcome.'); $menu->{$root . 'requirements'} = t('2. Requirements.'); $menu->{$root . 'site'} = t('3. Site info.'); $menu->{$root . 'finish'} = t('10. Finish.'); } }
/** * Prepare menues */ public function prepare(){ $cogear = getInstance(); $menu = new Menu('admin.sidebar'); $root = Url::gear('admin'); $menu->{$root} = icon('dashboard','fugue').t('Dashboard'); $menu->{$root.'gears'} = icon('gear','fugue').t('Gears'); $menu->{$root.'theme'} = icon('layout').t('Theme'); $menu->{$root.'site'} = icon('toolbox','fugue').t('Site'); $menu->{$root.'site/clear_cache'} = icon('bin').t('Clear cache'); prepend('sidebar',$menu->render('Admin_Menu.sidebar_menu')); css($this->folder.'/css/menu.css'); $menu = new Menu('admin.top'); Template::bindGlobal('top_menu',$menu); }
/** * Add Control Panel to user panel */ public function menu($name, &$menu) { switch ($name) { case 'user': if ($this->user->id && access('admin')) { $menu->{Url::gear('admin')} = t('Control Panel'); $menu->{Url::gear('admin')}->order = 99; } break; case 'admin': $menu->{'dashboard'} = t('Dashboard'); break; } }
public function index($action = NULL) { switch ($action) { case 'file': $tpl = new Template('Upload.file'); $tpl->show(); break; case 'image': $image = new Upload_Image('file', array('preset' => 'post', 'path' => UPLOADS . DS . 'posts' . DS . date('Y/m/d'))); if ($result = $image->upload()) { exit(HTML::img($result)); } break; default: append('content', HTML::a(Url::gear('upload') . '/file?iframe', t('Upload'), array('rel' => 'modal', 'class' => 'button'))); } }
/** * Poor man's cron * * Call cron process via image tag */ public function poorMansCron() { echo '<img src="' . Url::gear('cron') . 'run/' . $this->key . '">'; }
/** * Constructor * * @param array $options */ public function __construct($options = array()) { $this->options['image_upload'] = Url::gear('upload') . 'image'; parent::__construct($options); }
public function admin($action = 'active') { new Menu_Tabs('gears', Url::gear('admin') . 'gears'); d('Admin Gears'); $all_gears = $this->getAllGears(); $active_gears = $this->getActiveGears(); $inactive_gears = array_diff($all_gears, $active_gears); $doaction = NULL; if (!empty($_REQUEST['action-top'])) { $doaction = $_REQUEST['action-top']; } if (!empty($_REQUEST['action-bottom'])) { $doaction = $_REQUEST['action-bottom']; } if (!empty($_REQUEST['action'])) { $doaction = $_REQUEST['action']; } if ($doaction && isset($_REQUEST['gears'])) { $gears = $this->filter_gears($_REQUEST['gears']); switch ($doaction) { case 'activate': $this->activate_gears($gears); break; case 'deactivate': $this->deactivate_gears($gears); break; case 'update': $this->update_gears($_REQUEST['gears']); break; } back(); } switch ($action) { case 'index': case 'active': $gears = array(); foreach ($active_gears as $gear => $class) { if (class_exists($class)) { $object = new $class(); $object->active = TRUE; $gears[$object->package][$gear] = $object; } } $tpl = new Template('Gears.list'); $tpl->packages = $gears; $tpl->link = Url::gear('admin') . '/gears'; append('content', $tpl->render()); break; case 'all': $gears = array(); foreach ($all_gears as $gear => $class) { if (class_exists($class)) { $object = new $class(); $object->active = ($object->package == 'Core' or $object->type == Gear::CORE or in_array($gear, array_keys($active_gears))); $gears[$object->package][$gear] = $object; } } $tpl = new Template('Gears.list'); $tpl->packages = $gears; $tpl->link = Url::gear('admin') . '/gears'; append('content', $tpl->render()); break; case 'inactive': $gears = array(); foreach ($inactive_gears as $gear => $class) { if (class_exists($class)) { $object = new $class(); $object->active = ($object->package == 'Core' or $object->type == Gear::CORE or in_array($gear, array_keys($active_gears))); $gears[$object->package][$gear] = $object; } } $tpl = new Template('Gears.list'); $tpl->packages = $gears; $tpl->link = Url::gear('admin') . '/gears'; append('content', $tpl->render()); break; case 'new': $gears = array(); $new_period = 60 * 60 * 7; // Gears that has been updated last week are to be new foreach ($all_gears as $gear => $class) { $object = new $class(); if (time() - $object->file->getMTime() <= $new_period) { if (!($object->active = ($object->package == 'Core' or $object->type == Gear::CORE or in_array($gear, array_keys($active_gears))))) { $gears[$object->package][$gear] = $object; } } } $tpl = new Template('Gears.list'); $tpl->packages = $gears; $tpl->link = Url::gear('admin') . '/gears'; append('content', $tpl->render()); break; } }
public function adminMenuLink($menu) { $root = Url::gear('admin'); $menu['10.1'] = new Menu_Item($root . 'layout', icon('application_view_gallery') . t('Layout')); }
public function gears($action = 'index') { d('Admin Gears'); $cogear = getInstance(); $all_gears = $cogear->getAllGears(); $active_gears = $cogear->getActiveGears(); $inactive_gears = array_diff($all_gears, $active_gears); $all_count = sizeof($all_gears); $active_count = sizeof($active_gears); $inactive_count = sizeof($inactive_gears); $top_menu = Template::getGlobal('top_menu'); $root = Url::gear('admin'); $top_menu->{$root . 'gears'} = t('Active'); $top_menu->{$root . 'gears'}->count = $active_count; $top_menu->{$root . 'gears/all'} = t('All'); $top_menu->{$root . 'gears/all'}->count = $all_count; $top_menu->{$root . 'gears/inactive'} = t('Inactive'); $top_menu->{$root . 'gears/inactive'}->count = $inactive_count; $top_menu->{$root . 'gears/new'} = t('New'); $top_menu->{$root . 'gears/updates'} = t('Updates'); $top_menu->{$root . 'gears/add'} = t('Add'); $doaction = NULL; if (!empty($_REQUEST['action-top'])) $doaction = $_REQUEST['action-top']; if (!empty($_REQUEST['action-bottom'])) $doaction = $_REQUEST['action-bottom']; if (!empty($_REQUEST['action'])) $doaction = $_REQUEST['action']; if ($doaction && isset($_REQUEST['gears'])) { $gears = $this->filter_gears($_REQUEST['gears']); switch ($doaction) { case 'activate': $this->activate_gears($gears); break; case 'deactivate': $this->deactivate_gears($gears); break; case 'update': $this->update_gears($_REQUEST['gears']); break; } back(); } switch ($action) { case 'index': $gears = array(); foreach ($active_gears as $gear => $class) { $object = new $class; $object->active = TRUE; $gears[$object->package][$gear] = $object; } $tpl = new Template('Admin_Theme.gears'); $tpl->packages = $gears; $tpl->link = Url::gear('admin') . '/gears'; append('content', $tpl->render()); break; case 'all': $gears = array(); foreach ($all_gears as $gear => $class) { $object = new $class; $object->active = ($object->package == 'Core' OR $object->type == Gear::CORE OR in_array($gear, array_keys($active_gears))); $gears[$object->package][$gear] = $object; } $tpl = new Template('Admin_Theme.gears'); $tpl->packages = $gears; $tpl->link = Url::gear('admin') . '/gears'; append('content', $tpl->render()); break; case 'inactive': $gears = array(); foreach ($inactive_gears as $gear => $class) { $object = new $class; $object->active = ($object->package == 'Core' OR $object->type == Gear::CORE OR in_array($gear, array_keys($active_gears))); $gears[$object->package][$gear] = $object; } $tpl = new Template('Admin_Theme.gears'); $tpl->packages = $gears; $tpl->link = Url::gear('admin') . '/gears'; append('content', $tpl->render()); break; case 'new': $gears = array(); $new_period = 60 * 60 * 7; // Gears that has been updated last week are to be new foreach ($all_gears as $gear => $class) { $object = new $class; if (time() - $object->file->getMTime() <= $new_period) { if (!$object->active = ($object->package == 'Core' OR $object->type == Gear::CORE OR in_array($gear, array_keys($active_gears)))) { $gears[$object->package][$gear] = $object; } } } $tpl = new Template('Admin_Theme.gears'); $tpl->packages = $gears; $tpl->link = Url::gear('admin') . '/gears'; append('content', $tpl->render()); break; } }
<div class="page"> <div class="page-title"> <? $title = new Stack('Page.title') ?> <? $title->name = '<h1>' . ($item->in_grid ? HTML::a($item->getUrl(), $item->name) : $item->name) . '</h1>' ?> <? if ($cogear->user->id === $item->aid OR access('pages edit_all')) { $title->edit = HTML::a(Url::gear('pages') . 'edit/' . $item->id, t('[edit]'),array('class'=>'edit')); } ?> <?php echo $title; ?> </div> <div class="page-content"> <?php echo $item->body; ?> </div> <div class="page-info"> <? $info = new Stack('Page.info'); $info->object($item); $info->created_date = '<span class="created_date">' . df($item->created_date) . '</span>' ?> <? $user = new User_Object($item->aid); $info->author = '<span class="author">' .$user->getAvatarLinked().' '.$user->getLink() . '</span>'; ?> <?php echo $info->render(); ?> </div> </div>
/** * Default dispatcher * * @param string $action */ public function index_action($action = '', $subaction = NULL) { if (!empty($_POST['token'])) { // Get the profile of authorized user $UserProfile = $this->api->getAuthInfo($_POST['token']); // Check for errors if (!empty($UserProfile->error_type)) { // Debug info for developer error(t($UserProfile->error_type . ": " . $UserProfile->error_message)); } elseif (empty($UserProfile)) { error(t('Temporary error with Loginza authentification.')); } else { $this->session->loginza = $UserProfile; } } if ($loginza = $this->session->loginza) { /** * There we have 3 ways of workflow * * 1. User is logged in. Add new identity to database if it's not exist. * 2. User is registred. Authorize. * 3. User is not registred. Show register form connected and fullfilled with Loginza data (login, e-mail and so on). */ $user = new Db_ORM('users_loginza'); $user->identity = $loginza->identity; // If user is logged in if ($this->user->id) { // If integration is found if ($user->find()) { // If integration belongs to the current user if ($user->uid == $this->user->id) { $user->loginza->data = json_encode($loginza); $user->update(); flash_info(t('Your integration with profile <b>%s</b> was updated successfully.', 'Loginza', $loginza->identity), t('Updated succeed.')); } else { flash_error(t('Profile <b>%s</b> is integrated with sombody else account. You cannot use it before someone would left it out.', 'Loginza', $loginza->identity), t('Update failure.')); } } else { // Create new database record $user->uid = $this->user->id; $user->provider = $loginza->provider; $UserProfile = new Loginza_UserProfile($loginza); isset($loginza->photo) && ($user->photo = $loginza->photo); $user->full_name = $UserProfile->genFullName(); $user->data = json_encode($loginza); $user->save(); } $this->session->loginza = NULL; // Redirect to user profile redirect(Url::gear('user') . 'edit/#tab-social'); } else { // Record found → try to log in if ($user->find()) { $search = new User_Object(); $search->id = $user->uid; if ($search->find()) { $this->user->forceLogin($user->uid, 'id'); } else { flash_error(t('Cannot find user with id <b>%s</b>.', 'Loginza', $user->uid)); } $this->session->loginza = NULL; // This tiny little redirect caused error by Loginza "Invalid / empty session data! Retry auth.: // Left it where it is for memories. // Important! Do not uncomment! //back(); } else { if (!access('user register')) { return info('You don\'t have an access to registration'); } success('First step of registration is done. Please, fill some fields to complete your registration.'); $form = new Form('User.register'); $UserProfile = new Loginza_UserProfile($loginza); $tpl = new Template('Loginza.register'); $tpl->loginza = $loginza; $tpl->profile = $UserProfile; append('content', $tpl->render()); $data['login'] = $UserProfile->genFullName(); isset($loginza->email) && ($data['email'] = $loginza->email); $form->setValues($data); if ($data = $form->result()) { $this->user->object($data); $this->user->hashPassword(); if ($uid = $this->user->save()) { // Create new database record $user->uid = $uid; $user->provider = $loginza->provider; $UserProfile = new Loginza_UserProfile($loginza); isset($loginza->photo) && ($user->photo = $loginza->photo); $user->full_name = $UserProfile->genFullName(); $user->data = json_encode($loginza); $user->save(); } $this->session->loginza = NULL; flash_success('User was successfully registered! Please, check your email for further instructions.', 'Registration succeed.'); redirect(); } append('content', $form->render()); } } } }
<sup class="gear-version"><?php echo $version; ?> </sup> <?if($type != Gear::CORE):?> <a class="edit ajaxed" href="#/gears/<?php echo ($active ? 'deactivate' : 'activate') . '/' . $gear; ?> ">[<?php echo t($active ? 'deactivate' : 'activate'); ?> ]</a> <?endif;?> <?if($has_admin):?> <a class="edit" href="<?php echo Url::gear('admin') . strtolower($gear); ?> ">[<?php echo t('Control panel'); ?> ]</a> <?endif;?> </div> <div class="gear-description"><?php echo $description; ?> </div> <div class="gear-info"> <b><?php echo t('Author: '); ?>
/** * Show pages * * @param string $type */ public function index($action = '', $subaction = NULL) { new Menu_Tabs('pages', Url::gear('pages')); switch ($action) { case 'create': if (!page_access('pages create')) { return; } $form = new Form('Pages.createdit'); if ($result = $form->result()) { $page = new Pages_Object(); $page->object($result); $page->aid = cogear()->user->id; $page->created_date = time(); $page->last_update = time(); $page->save(); flash_success(t('New page has been successfully added!', 'Pages')); redirect($page->getUrl()); } append('content', $form->render()); break; case 'show': $this->showPage($subaction); break; case 'edit': $page = new Pages_Object(); $page->where('id', intval($subaction)); if ($page->find()) { if (access('pages edit_all') or $cogear->user->id == $page->aid) { $form = new Form('Pages.createdit'); $form->init(); if (access('pages delete')) { $form->addElement('delete', array('label' => t('Delete'), 'type' => 'submit')); } $form->setValues($page->object()); if ($result = $form->result()) { if ($result->delete) { $page->delete(); redirect(Url::gear('pages')); } $page->object()->mix($result); $page->last_update = time(); $page->update(); $link = $page->getUrl(); success(t('Page has been update. You can visit it by link <a href="%s">%s</a>', 'Pages', $link, $link)); //redirect($page->getUrl()); } $form->elements->submit->setValue(t('Update')); append('content', $form->render()); } else { return _403(); } } else { return _404(); } break; default: $this->showPages($action); } }
/** * Конструктор */ public function __construct() { parent::__construct('admin', 'Admin/templates/menu', Url::gear('admin')); }
/** * Administrate users * * @param string $action */ public function admin($action = '') { new Menu_Tabs('admin_user', Url::gear('admin') . 'user'); switch ($action) { case 'add': $this->admin_add(); break; default: $this->users(); } }
/** * Constructor */ public function __construct() { parent::__construct('admin', 'Admin.menu', Url::gear('admin')); hook('menu.user', array($this, 'mixWith'), NULL, 'user', 'admin'); }
/** * Get user panel — for profile and other pages * * @return string */ public function getPanel() { $cogear = getInstance(); $panel = new Stack('user.panel'); $avatar = $this->getAvatar(); $panel->avatar = $avatar; $panel->login = HTML::a($this->getProfileLink(), $this->login, array('class' => 'implicit login')); if (access('user edit_all') or $this->id == $cogear->user->id) { $panel->edit = HTML::a(Url::gear('user') . 'edit/' . $this->id, t('[edit]'), array('class' => 'edit')); } return $panel->render(); }