Example #1
0
 public static function installation()
 {
     if (!is_installed()) {
         echo View::create('intro')->render();
         exit(0);
     }
 }
Example #2
0
 private function processForm(Task $task)
 {
     $logger = $this->get('logger');
     $em = $this->getDoctrine()->getManager();
     $statusCode = $task->getId() < 0 ? 201 : 204;
     $logger->info("1");
     try {
         $form = $this->createForm(new TaskType(), $task);
         $logger->info("2 " . $this->getRequest());
         $request = $this->getRequest();
         $form->bind($request);
         $logger->info($this->getRequest()->attributes->count());
         if ($form->isValid()) {
             $em->persist($task);
             $em->flush();
             $response = new Response();
             $response->setStatusCode($statusCode);
             $response->headers->set('Location', $this->generateUrl('mtoltodo_get', array('id' => $task->getId()), true));
             $logger->info('done');
             return $response;
         }
     } catch (Exception $e) {
         $logger->info($e->getMessage());
     }
     return View::create($form, 400);
 }
 public function indexAction()
 {
     $elements = array();
     $elements[] = Bootstrap::row()->add(12, Bootstrap::h(1, 'Internet providers'));
     $elements[] = BootstrapUI::tableRemote()->title('List of providers')->column('name', 'provider name')->column('total', 'count', 70)->column('action', '', 30)->sortableColumns(array('name', 'total'))->searchable()->sortField('name', 'asc');
     return View::create('base')->with('title', 'Internet providers')->with('content', $elements);
 }
 public function indexAction()
 {
     $elements = array();
     $elements[] = Bootstrap::row()->add(12, Bootstrap::h(1, 'Stack traces')->secondaryText('This is list of collected stack trace summaries'));
     $table = BootstrapUI::tableRemote()->title('List of stack trace summaries')->searchable()->column('id')->column('summary')->column('total', 'count', 70)->sortableColumns(array('id', 'total'))->sortField('id', 'desc');
     $elements[] = $table;
     return View::create('base')->with('title', 'Stack traces')->with('content', $elements);
 }
Example #5
0
 public function send()
 {
     if (Config::db('profiling')) {
         $profile = View::create('profile', array('profile' => DB::profile()))->render();
         $this->output = preg_replace('#</body>#', $profile . '</body>', $this->output);
     }
     return parent::send();
 }
Example #6
0
 /**
  * Printed out the errors to the error view
  */
 public function print_error()
 {
     //check if there was no failure in the template, render it, print out failure.
     //If we have errors in the template, then render the error-view without a template
     if (strpos($this->m_code, 'TEMPLATE') !== false) {
         View::create('error')->bind_by_name('s_error_message', $this->message)->bind_by_name('s_error_code', $this->m_code)->render(false);
     } else {
         View::create('error')->bind_by_name('s_error_message', $this->message)->bind_by_name('s_error_code', $this->m_code)->bind_by_name('s_error_file', $this->file)->bind_by_name('s_error_line', $this->line)->render();
     }
     exit(1);
 }
Example #7
0
 /**
  *
  */
 private function is_session_expired()
 {
     $a_return_values = array();
     $b_session_valid = true;
     $o_session = \Session::get_session();
     if (!$o_session->is_session_valid()) {
         $s_message = \View::create('message')->render(false, true);
         $b_session_valid = false;
         $o_session->create_new_session();
         $a_return_values['message'] = $s_message;
     }
     $a_return_values['session_valid'] = $b_session_valid;
     echo json_encode($a_return_values);
 }
Example #8
0
 /**
  * Constructor
  */
 function __construct()
 {
     // Merge GET and POST params
     $oRequest = new Request(array_merge($_GET, $_POST));
     // Create main view
     $this->oMainView = new View('gabarit');
     $this->oMainView->addData('title', Config::get('sitetitle'));
     try {
         // Create associated controller
         $this->createController($oRequest);
         // Execute controller
         $this->oController->procede();
         $this->oMainView->addData('menuItems', $this->createMenu());
         $this->oMainView->addData('login', $this->oController->getCurrentUser()->getLogin());
         $this->oMainView->addData('body', $this->oController->getView());
         $this->oMainView->addData('script', $this->oController->getJS());
     } catch (Error $e) {
         $this->oMainView->addAlert($e, 'danger');
     } finally {
         // Create the main view
         $this->oMainView->create();
     }
 }
 /**
  * Handle article PUT
  */
 public function putDocumentAction(Request $request, $id)
 {
     $path = '/' . $id;
     $data = $request->request->all();
     $session = $this->registry->getConnection($this->name);
     $node = $session->getNode($path);
     if (empty($node)) {
         throw new ResourceNotFoundException($path . ' not found');
     }
     $this->fromJsonLD($node, $data);
     $session->save();
     // return the updated version
     $view = View::create($this->toJsonLd($node))->setFormat('json');
     return $this->viewHandler->handle($view, $request);
 }
 public function stackTracesAction()
 {
     $osVersionId = (int) Url::getVar('os_version_id');
     if ($osVersionId <= 0) {
         Application::throwError(400, 'Bad request');
     }
     $osVersion = Version::fetchOne($osVersionId);
     if ($osVersion === false) {
         Application::throwError(404, 'Can not find os_version');
     }
     $title = "Stack traces for {$osVersion->os} {$osVersion->name}";
     $elements = array();
     $elements[] = Bootstrap::row()->add(12, Bootstrap::h(1, $title)->secondaryText("Total {$osVersion->total} reports"));
     $elements[] = Bootstrap::row()->add(12, BootstrapUI::tableRemote()->title('Most common stack traces')->column('total', 'count', 80)->column('summary', 'stack trace summary')->column('action', '', 30)->sortableColumns(array('summary', 'total'))->sortField('total', 'desc')->extraParam('os_version_id', $osVersionId));
     return View::create('base')->with('title', $title)->with('content', $elements);
 }
 /**
  * @param User $user
  *
  * @return Response
  */
 protected function processForm(User $user)
 {
     $statusCode = $user->isNew() ? 201 : 204;
     $form = $this->createForm(new UserType(), $user);
     $form->handleRequest($this->getRequest());
     if ($form->isValid()) {
         $user->save();
         $response = new Response();
         $response->setStatusCode($statusCode);
         // set the `Location` header only when creating new resources
         if (201 === $statusCode) {
             $response->headers->set('Location', $this->generateUrl('acme_demo_user_get', array('id' => $user->getId()), true));
         }
         return $response;
     }
     return View::create($form, 400);
 }
 /**
  * PATCH Route annotation.
  * @Rest\Patch("/users/edit/{id}.{_format}")
  * @Rest\View
  * @return array
  */
 public function editAction(Request $request, $id)
 {
     $em = $this->getDoctrine()->getManager();
     $user = $em->getRepository('AppBundle:User')->find($id);
     if (!$user) {
         throw $this->createNotFoundException('User not found!');
     }
     $form = $this->createForm(new \ApiBundle\Form\Type\RegistrationFormType(), $user, array('method' => 'PATCH'));
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($user);
         $em->flush();
         return array('user' => $user);
     }
     return View::create($form, 400);
 }
 public function versionsAction()
 {
     $packageId = (int) Url::getVar('package_id');
     if ($packageId <= 0) {
         Application::throwError(400, 'Bad request');
     }
     $package = Package::fetchOne($packageId);
     if ($package === false) {
         Application::throwError(404, 'Can not find package');
     }
     $last = Url::getVar('last');
     $title = 'Package versions for ' . $package->name;
     $elements = array();
     $elements[] = Bootstrap::row()->add(12, Bootstrap::h(1, $title));
     $elements[] = Bootstrap::row()->add(12, Bootstrap::buttonGroup()->add(Bootstrap::anchor('Last 12 hours', Url::href('packages', 'versions', array('package_id' => $packageId, 'last' => '12-hour')))->asButton()->color($last == '12-hour' ? 'blue' : 'default'))->add(Bootstrap::anchor('Last day', Url::href('packages', 'versions', array('package_id' => $packageId, 'last' => 'day')))->asButton()->color($last == 'day' ? 'blue' : 'default'))->add(Bootstrap::anchor('Last week', Url::href('packages', 'versions', array('package_id' => $packageId, 'last' => 'week')))->asButton()->color($last == 'week' ? 'blue' : 'default'))->add(Bootstrap::anchor('Last 2 weeks', Url::href('packages', 'versions', array('package_id' => $packageId, 'last' => '2-weeks')))->asButton()->color($last == '2-weeks' ? 'blue' : 'default'))->add(Bootstrap::anchor('Last month', Url::href('packages', 'versions', array('package_id' => $packageId, 'last' => 'month')))->asButton()->color($last == 'month' ? 'blue' : 'default'))->add(Bootstrap::anchor('Last 2 months', Url::href('packages', 'versions', array('package_id' => $packageId, 'last' => '2-months')))->asButton()->color($last == '2-months' ? 'blue' : 'default'))->add(Bootstrap::anchor('All', Url::href('packages', 'versions', array('package_id' => $packageId)))->asButton()->color($last == null ? 'blue' : 'default'))->setAttribute('style', 'margin-bottom: 10px'));
     $elements[] = BootstrapUI::tableRemote()->title('Most common versions')->column('total', 'count', 80)->column('name', 'package version')->column('action', '', 30)->sortableColumns(array('name', 'total'))->sortField('total', 'desc')->extraParam('package_id', $packageId)->extraParam('last', $last);
     return View::create('base')->with('title', $title)->with('content', $elements);
 }
Example #14
0
 /**
  * the constructor of this installer-class.
  * it initialize all needed values and set the hidden fields for the template
  */
 public function __construct()
 {
     //Initialize the installer with the current-needed POST and Session values
     $this->init();
     //set a common title
     $this->s_step_title = __('install_common_title', 'install');
     //set the hidden fields, which we don't need for the installation
     \Replacer::set_hidden_fields(array('character', 'online', 'more'));
     if ($this->check_dbconfig_file() !== array()) {
         \Replacer::page_header($this->s_step_title);
         $message = __('Probleme mit der ".dbconfig.default' . EXT . '". <br>Folgende Konstanten haben andere Werte als die ursprüngliche Datei');
         throw new \LOGD_Exception($message);
     }
     //switch/case for the step and go to the right method
     switch ($this->i_step) {
         case 0:
             $this->step_0();
             break;
     }
     //set the page header and render the install view
     \Replacer::page_header($this->s_step_title);
     \View::create('install')->bind_by_value('i_step', $this->i_step)->render();
 }
Example #15
0
 /**
  * Créer la Popup d'ajout d'un utilisateur
  * @param \Rank $p_aRanks Rangs possibles
  * @return string
  */
 private function createAddPopup($p_aRanks)
 {
     $oPopupAdd = new View('popup');
     $oPopupAdd->addData('id', 'adduser');
     $oPopupAdd->addData('buttonstyle', 'btn-success');
     $oPopupAdd->addData('buttonicon', 'fa-plus');
     $oPopupAdd->addData('buttontext', 'Ajouter');
     $oPopupAdd->addData('title', 'Ajouter un utilisateur');
     $oFormAdd = new FormGenerator();
     $oFormAdd->setAction('index.php?p=adminusers');
     $oFormAdd->addInput('Identifiant', 'login', true, false, 'text', 'Identifiant ...');
     $oFormAdd->addInput('Password', 'password', true, false, 'password', 'Password ...');
     $oFormAdd->addInput('Confirmation', 'confirmation', true, false, 'password', 'Confirmation ...');
     $oFormAdd->addInput('Email', 'mail', true, false, 'text', 'Email ...');
     $oFormAdd->addSelect('Rang', 'rank', $p_aRanks, Rank::getDefaultRank()->getId());
     $oFormAdd->create();
     $oPopupAdd->addData('content', $oFormAdd->getCode());
     $oPopupAdd->create();
     return $oPopupAdd->getCode();
 }
 /**
  * Show the page to add new user
  */
 public function addUserAction()
 {
     $title = 'Add new user';
     $content = array(Bootstrap::row()->add(8, \Bootstrap::h(1, $title), 2));
     $content[] = Bootstrap::row()->add(8, Bootstrap::panel('New user', $this->getUserForm())->color('blue'), 2);
     return View::create('base')->with('title', $title)->with('content', $content);
 }
Example #17
0
 public static function create($path, $vars = array())
 {
     return View::create($path, $vars)->partial('header', 'partials/header', $vars)->partial('footer', 'partials/footer', $vars);
 }
Example #18
0
/**
 * install the group homepage view
 * This creates a template at system level
 * which is subsequently copied to group hompages
 *
 * @return int the id of the new template
 */
function install_system_grouphomepage_view()
{
    $dbtime = db_format_timestamp(time());
    // create a system template for group homepage views
    require_once get_config('libroot') . 'view.php';
    $view = View::create(array('type' => 'grouphomepage', 'owner' => 0, 'numcolumns' => 2, 'numrows' => 1, 'columnsperrow' => array((object) array('row' => 1, 'columns' => 1)), 'template' => 1, 'title' => get_string('grouphomepage', 'view')));
    $view->set_access(array(array('type' => 'loggedin')));
    $blocktypes = array(array('blocktype' => 'groupinfo', 'title' => '', 'row' => 1, 'column' => 1, 'config' => null), array('blocktype' => 'recentforumposts', 'title' => '', 'row' => 1, 'column' => 1, 'config' => null), array('blocktype' => 'groupviews', 'title' => '', 'row' => 1, 'column' => 1, 'config' => array('showgroupviews' => 1, 'showsharedviews' => 1, 'showsharedcollections' => 1)), array('blocktype' => 'groupmembers', 'title' => '', 'row' => 1, 'column' => 1, 'config' => null));
    $installed = get_column_sql('SELECT name FROM {blocktype_installed}');
    $weights = array(1 => 0);
    foreach ($blocktypes as $blocktype) {
        if (in_array($blocktype['blocktype'], $installed)) {
            $weights[$blocktype['column']]++;
            $newblock = new BlockInstance(0, array('blocktype' => $blocktype['blocktype'], 'title' => $blocktype['title'], 'view' => $view->get('id'), 'row' => $blocktype['row'], 'column' => $blocktype['column'], 'order' => $weights[$blocktype['column']], 'configdata' => $blocktype['config']));
            $newblock->commit();
        }
    }
    return $view->get('id');
}
Example #19
0
<?php

Route::collection(array('before' => 'auth,install_exists'), function () {
    /*
        List Menu Items
    */
    Route::get('admin/menu', function () {
        $vars['pages'] = Page::where('show_in_menu', '=', 1)->sort('menu_order')->get();
        return View::create('menu/index', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
    });
    /*
        Update order
    */
    Route::post('admin/menu/update', function () {
        $sort = Input::get('sort');
        foreach ($sort as $index => $id) {
            Page::where('id', '=', $id)->update(array('menu_order' => $index));
        }
        return Response::json(array('result' => true));
    });
});
Example #20
0
 private function createTagsEdit()
 {
     //Suppression d'un tag
     $sTags = '';
     foreach ($this->oRelease->getTags() as $iTagId => $oRegex) {
         $oButton = new View('button');
         $oButton->addData('link', 'index.php?p=modrelease&a=deletetag&id=' . $this->oRelease->getId() . '&tag=' . $iTagId);
         $oButton->addData('icon', 'fa-times');
         $oButton->addData('style', 'info');
         $oButton->addData('text', $oRegex->getName());
         $oButton->create();
         $sTags .= $oButton->getCode() . '&nbsp;';
     }
     //Ajout d'un tag
     $aRegex = Regex::getSelectRegex();
     $oPopupAdd = new View('popup');
     $oPopupAdd->addData('id', 'addtag');
     $oPopupAdd->addData('buttonstyle', 'btn-success');
     $oPopupAdd->addData('buttonicon', 'fa-plus');
     $oPopupAdd->addData('buttontext', 'Ajouter');
     $oPopupAdd->addData('title', 'Ajouter un tag');
     $oFormAdd = new FormGenerator();
     $oFormAdd->setAction('index.php?p=modrelease&a=addtag&id=' . $this->oRelease->getId());
     $oFormAdd->addSelect('Tag', 'tag', $aRegex);
     $oFormAdd->create();
     $oPopupAdd->addData('content', $oFormAdd->getCode());
     $oPopupAdd->create();
     $sTags .= $oPopupAdd->getCode();
     $this->oView->addData('tagsdelete', $sTags);
 }
Example #21
0
 /**
  * Create an empty view
  * @param array $record
  * @throws SystemException if creating failed
  * @return int new view id
  */
 public function create_view($record)
 {
     switch ($record['ownertype']) {
         case 'institution':
             if (empty($record['ownername'])) {
                 $record['institution'] = 'mahara';
                 break;
             }
             if ($institutionid = $this->get_institution_id($record['ownername'])) {
                 $record['institution'] = $record['ownername'];
                 // Find one of the institution admins
                 if (!($userid = $this->get_first_institution_admin_id($record['ownername']))) {
                     // Find one of site admins
                     $userid = $this->get_first_site_admin_id();
                 }
             } else {
                 throw new SystemException("The institution '" . $record['ownername'] . "' does not exist.");
             }
             break;
         case 'group':
             if ($groupid = $this->get_group_id($record['ownername'])) {
                 $record['group'] = $groupid;
                 // Find one of the group admins
                 if (!($userid = $this->get_first_group_admin_id($groupid))) {
                     throw new SystemException("The group '" . $record['ownername'] . "' must have at least one administrator.");
                 }
             } else {
                 throw new SystemException("The group '" . $record['ownername'] . "' does not exist.");
             }
             break;
         case 'user':
         default:
             if ($ownerid = get_field('usr', 'id', 'username', $record['ownername'])) {
                 $record['owner'] = $ownerid;
                 // Find one of the site admins
                 $userid = $this->get_first_site_admin_id();
             } else {
                 throw new SystemException("The user '" . $record['ownername'] . "' does not exist.");
             }
             break;
     }
     if (empty($userid)) {
         $userid = $this->get_first_site_admin_id();
     }
     require_once 'view.php';
     $view = View::create($record, $userid);
 }
Example #22
0
 /**
  * Create ADD popup
  * @return string Code HTML
  */
 private function createAddPopup()
 {
     //Popup d'ajout
     $oPopupAdd = new View('popup');
     $oPopupAdd->addData('id', 'addkey');
     $oPopupAdd->addData('buttonstyle', 'btn-success');
     $oPopupAdd->addData('buttonicon', 'fa-plus');
     $oPopupAdd->addData('buttontext', Language::translate('API_ADMIN_ADD_ADD'));
     $oPopupAdd->addData('title', Language::translate('API_ADMIN_ADD_TITLE'));
     $oFormAdd = new FormGenerator();
     $oFormAdd->setAction('index.php?p=adminapi');
     $aOptions = User::getUsersSelect();
     $oFormAdd->addSelect(Language::translate('API_ADMIN_ADD_USER'), 'user', $aOptions);
     $oFormAdd->addCheckbox(Language::translate('API_ADMIN_ADD_READ'), 'read', true);
     $oFormAdd->addCheckbox(Language::translate('API_ADMIN_ADD_WRITE'), 'write', false);
     $oFormAdd->create();
     $oPopupAdd->addData('content', $oFormAdd->getCode());
     $oPopupAdd->create();
     return $oPopupAdd->getCode();
 }
Example #23
0
 /**
  * Given a data structure like the one created by {@link export_config},
  * creates and returns a View object representing the config.
  *
  * @param array $config The config, as generated by export_config. Note
  *                      that if you miss fields, this method will throw
  *                      warnings.
  * @param int $userid   The user who issued the command to do the import
  *                      (defaults to the logged in user)
  * @return View The created view
  */
 public static function import_from_config(array $config, $userid = null, $format = '')
 {
     $viewdata = array('title' => $config['title'], 'description' => $config['description'], 'type' => $config['type'], 'layout' => $config['layout'], 'tags' => $config['tags'], 'numrows' => $config['numrows'], 'ownerformat' => $config['ownerformat']);
     if (isset($config['owner'])) {
         $viewdata['owner'] = $config['owner'];
     }
     if (isset($config['group'])) {
         $viewdata['group'] = $config['group'];
     }
     if (isset($config['institution'])) {
         $viewdata['institution'] = $config['institution'];
     }
     $view = View::create($viewdata, $userid);
     foreach ($config['rows'] as $rowkey => $row) {
         foreach ($row['columns'] as $colkey => $column) {
             $order = 1;
             foreach ($column as $blockinstance) {
                 safe_require('blocktype', $blockinstance['type']);
                 $classname = generate_class_name('blocktype', $blockinstance['type']);
                 $method = 'import_create_blockinstance';
                 if (method_exists($classname, $method . "_{$format}")) {
                     $method .= "_{$format}";
                 }
                 $bi = call_static_method($classname, $method, $blockinstance, $config);
                 if ($bi) {
                     $bi->set('title', $blockinstance['title']);
                     $bi->set('row', $rowkey);
                     $bi->set('column', $colkey);
                     $bi->set('order', $order);
                     $view->addblockinstance($bi);
                     $order++;
                 } else {
                     log_debug("Blocktype {$blockinstance['type']}'s import_create_blockinstance did not give us a blockinstance, so not importing this block");
                 }
             }
         }
         // cols
     }
     // rows
     if ($viewdata['type'] == 'profile') {
         $view->set_access(array(array('type' => 'loggedin', 'startdate' => null, 'stopdate' => null)));
     }
     return $view;
 }
Example #24
0
 /*
 	Add new post
 */
 Route::get('admin/posts/add', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['page'] = Registry::get('posts_page');
     // extended fields
     $vars['fields'] = Extend::fields('post');
     $vars['statuses'] = array('published' => __('global.published'), 'draft' => __('global.draft'), 'archived' => __('global.archived'));
     $vars['categories'] = Category::dropdown();
     $vars['companies'] = Company::dropdown();
     $vars['departments'] = Department::dropdown();
     // echo '<pre>';
     // print_r($vars);exit;
     return View::create('posts/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer')->partial('editor', 'partials/editor');
 });
 Route::post('admin/posts/add', function () {
     $input = Input::get(array('title', 'slug', 'description', 'created', 'html', 'css', 'js', 'category', 'status', 'comments', 'company', 'department'));
     // if there is no slug try and create one from the title
     if (empty($input['slug'])) {
         $input['slug'] = $input['title'];
     }
     // convert to ascii
     $input['slug'] = slug($input['slug']);
     // encode title
     $input['title'] = e($input['title'], ENT_COMPAT);
     $validator = new Validator($input);
     $validator->add('duplicate', function ($str) {
         return Post::where('slug', '=', $str)->count() == 0;
     });
/**
 * This function installs the site's default dashboard view
 *
 * @throws SystemException if the system dashboard view is already installed
 */
function install_system_dashboard_view()
{
    $viewid = get_field('view', 'id', 'owner', 0, 'type', 'dashboard');
    if ($viewid) {
        throw new SystemException('A system dashboard view already seems to be installed');
    }
    require_once get_config('libroot') . 'view.php';
    require_once get_config('docroot') . 'blocktype/lib.php';
    $view = View::create(array('type' => 'dashboard', 'owner' => 0, 'numcolumns' => 2, 'ownerformat' => FORMAT_NAME_PREFERREDNAME, 'title' => get_string('dashboardviewtitle', 'view'), 'template' => 1));
    $view->set_access(array(array('type' => 'loggedin')));
    $blocktypes = array(array('blocktype' => 'newviews', 'title' => get_string('title', 'blocktype.newviews'), 'column' => 1, 'config' => array('limit' => 5)), array('blocktype' => 'myviews', 'title' => get_string('title', 'blocktype.myviews'), 'column' => 1, 'config' => null), array('blocktype' => 'inbox', 'title' => get_string('recentactivity'), 'column' => 2, 'config' => array('feedback' => true, 'groupmessage' => true, 'institutionmessage' => true, 'maharamessage' => true, 'usermessage' => true, 'viewaccess' => true, 'watchlist' => true, 'maxitems' => '5')), array('blocktype' => 'inbox', 'title' => get_string('topicsimfollowing'), 'column' => 2, 'config' => array('newpost' => true, 'maxitems' => '5')));
    $installed = get_column_sql('SELECT name FROM {blocktype_installed}');
    $weights = array(1 => 0, 2 => 0);
    foreach ($blocktypes as $blocktype) {
        if (in_array($blocktype['blocktype'], $installed)) {
            $weights[$blocktype['column']]++;
            $newblock = new BlockInstance(0, array('blocktype' => $blocktype['blocktype'], 'title' => $blocktype['title'], 'view' => $view->get('id'), 'column' => $blocktype['column'], 'order' => $weights[$blocktype['column']], 'configdata' => $blocktype['config']));
            $newblock->commit();
        }
    }
    return $view->get('id');
}
Example #26
0
     return Response::redirect('admin/extend/fields');
 });
 /*
     Edit Field
 */
 Route::get('admin/extend/fields/edit/(:num)', function ($id) {
     $vars['token'] = Csrf::token();
     $vars['types'] = Extend::$types;
     $vars['fields'] = Extend::$field_types;
     $extend = Extend::find($id);
     if ($extend->attributes) {
         $extend->attributes = Json::decode($extend->attributes);
     }
     $vars['field'] = $extend;
     $vars['pagetypes'] = Query::table(Base::table('pagetypes'))->sort('key')->get();
     return View::create('extend/fields/edit', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
 });
 Route::post('admin/extend/fields/edit/(:num)', function ($id) {
     $input = Input::get(array('type', 'field', 'key', 'label', 'attributes', 'pagetype'));
     if (empty($input['key'])) {
         $input['key'] = $input['label'];
     }
     $input['key'] = slug($input['key'], '_');
     array_walk_recursive($input, function (&$value) {
         $value = eq($value);
     });
     $validator = new Validator($input);
     $validator->add('valid_key', function ($str) use($id, $input) {
         return Extend::where('key', '=', $str)->where('type', '=', $input['type'])->where('id', '<>', $id)->count() == 0;
     });
     $validator->check('key')->is_max(1, __('extend.key_missing'))->is_valid_key(__('extend.key_exists'));
Example #27
0
     if ($password_reset) {
         $input['password'] = Hash::make($input['password']);
     }
     User::update($id, $input);
     Notify::success(__('users.updated'));
     return Response::redirect('admin/users/edit/' . $id);
 });
 /*
 	Add user
 */
 Route::get('admin/users/add', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['statuses'] = array('inactive' => __('global.inactive'), 'active' => __('global.active'));
     $vars['roles'] = array('administrator' => __('global.administrator'), 'editor' => __('global.editor'), 'user' => __('global.user'));
     return View::create('users/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
 });
 Route::post('admin/users/add', function () {
     $input = Input::get(array('username', 'email', 'real_name', 'password', 'bio', 'status', 'role'));
     $validator = new Validator($input);
     $validator->check('username')->is_max(3, __('users.username_missing', 2));
     $validator->check('email')->is_email(__('users.email_missing'));
     $validator->check('password')->is_max(6, __('users.password_too_short', 6));
     if ($errors = $validator->errors()) {
         Input::flash();
         Notify::error($errors);
         return Response::redirect('admin/users/add');
     }
     $input['password'] = Hash::make($input['password']);
     User::create($input);
     Notify::success(__('users.created'));
Example #28
0
 /**
  * Create ADD Popup
  * @param array $aTrackersSelect
  * @param array $aCategoriesSelect
  * @return string Code HTML
  */
 private function createAddPopup($aTrackersSelect, $aCategoriesSelect)
 {
     $oPopupAdd = new View('popup');
     $oPopupAdd->addData('id', 'addrss');
     $oPopupAdd->addData('buttonstyle', 'btn-success');
     $oPopupAdd->addData('buttonicon', 'fa-plus');
     $oPopupAdd->addData('buttontext', Language::translate('RSS_ADMIN_ADD_ADD'));
     $oPopupAdd->addData('title', Language::translate('RSS_ADMIN_ADD_TITLE'));
     $oFormAdd = new FormGenerator();
     $oFormAdd->setAction('index.php?p=adminrss');
     $oFormAdd->addSelect(Language::translate('RSS_ADMIN_ADD_TRACKER'), 'tracker', $aTrackersSelect);
     $oFormAdd->addSelect(Language::translate('RSS_ADMIN_ADD_ENCODE'), 'encoding', Config::getEncodes());
     $oFormAdd->addInput(Language::translate('RSS_ADMIN_ADD_URL'), 'url', true, false, 'text', 'URL ...');
     $oFormAdd->addInput(Language::translate('RSS_ADMIN_ADD_MASK'), 'mask', true, false, 'text', 'http://montracker.fr/download/{PASSKEY}/{IDTORRENT}');
     $oFormAdd->addCheckbox(Language::translate('RSS_ADMIN_ADD_DATE'), 'forcedate');
     $oFormAdd->create();
     $oPopupAdd->addData('content', $oFormAdd->getCode());
     $oPopupAdd->create();
     return $oPopupAdd->getCode();
 }
Example #29
0
 public function procede()
 {
     if (!$this->oRequest->existParam('key')) {
         throw new Error('Vous devez renseigner la clé.', 3003);
     }
     if ($this->oRequest->getParam('key', 'string') != Config::get('ingestkey')) {
         throw new Error('La clé est invalide.', 3003);
     }
     //Ajoute du titre
     $this->oView->addData('titre', 'Analyse des flux RSS');
     //On récupère les éléments pour les statistiques
     $iNbReleases = Release::getCount();
     $iNbTorrents = Torrent::getCount();
     $iStartTime = time();
     //Traitement des Trackers
     $aTrackers = Tracker::getTrackers();
     //Ajout des flux
     $aRssList = Rss::getFlux();
     foreach ($aRssList as $oRss) {
         $aTrackers[$oRss->getTrackerId()]->addFlux($oRss);
     }
     //Parsage des flux
     $aResults = array();
     foreach ($aTrackers as $oTracker) {
         $aResults = array_merge($aResults, $oTracker->parseRss());
     }
     //Traitement des résultats
     $oTable = new TableGenerator();
     $oTable->setId(md5('Ingest'));
     $oTable->addColumn('Tags');
     $oTable->addColumn('Tracker');
     $oTable->addColumn('Release');
     foreach ($aResults as $oResult) {
         if (is_string($oResult)) {
             Logger::log('ingest', $oResult);
             $this->oView->addAlert($oResult, 'danger');
         } else {
             $oResult->store();
             $sTags = '';
             foreach ($oResult->getTags() as $oTag) {
                 $oTagView = new View('label');
                 $oTagView->addData('type', 'info');
                 $oTagView->addData('text', $oTag->getName());
                 $oTagView->create();
                 $sTags .= $oTagView->getCode() . '&nbsp;';
             }
             $oTable->addLine(array($sTags, $aTrackers[$oResult->getTracker()]->getName(), $oResult->getReleaseName()));
         }
     }
     //Statistiques
     $iNewReleases = Release::getCount() - $iNbReleases;
     $iNewTorrents = Torrent::getCount() - $iNbTorrents;
     Stats::storeIngestStats($iNewReleases, $iNewTorrents, date("Y-m-j G:i:s", $iStartTime));
     //Enregistrement de la dernière date de vérification
     Rss::updateLastCheck(date("Y-m-j G:i:s", $iStartTime));
     Logger::log('ingest', $iNewReleases . ' nouvelles releases et ' . $iNewTorrents . ' nouveaux torrents.');
     $oTable->setBottom($iNewReleases . ' nouvelles releases et ' . $iNewTorrents . ' nouveaux torrents.');
     $oTable->create();
     $this->oView->addData('content', $oTable->getCode());
     $this->oView->Create();
 }
Example #30
0
<?php

Route::collection(array('before' => 'auth,csrf,install_exists'), function () {
    /*
        List all plugins
    */
    Route::get('admin/extend/plugins', function ($page = 1) {
        $vars['token'] = Csrf::token();
        return View::create('extend/plugins/index', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
    });
});