mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
- AuthLib is loaded only in fhcauth_helper, PermissionLib and REST_Controller
- Removed all the NOT usefull loads of helpers and libraries - Fixed undefined index in controllers/system/UDF and model system/UDF_model - APIv1_Controller now loads helper fhcauth - FHC_Controller now loads ithe fhc and session helpers too - Added/Fixed comments - PermissionLib does NOT use anymore the getAuthUID function from the fhcauth helper, now relies on AuthLib directly - REST_Controller loads directly the AuthLib when is needed
This commit is contained in:
@@ -22,13 +22,13 @@ class MailJob extends FHC_Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
// Loads MessageLib
|
||||
$this->load->library("MessageLib");
|
||||
$this->load->library('MessageLib');
|
||||
}
|
||||
|
||||
|
||||
public function sendMessages($numberToSent = null, $numberPerTimeRange = null, $email_time_range = null, $email_from_system = null)
|
||||
{
|
||||
$this->messagelib->sendAll($numberToSent, $numberPerTimeRange, $email_time_range, $email_from_system);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,6 @@ class CheckUserAuth extends APIv1_Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Loads the authentication library
|
||||
$this->load->library('AuthLib');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,7 @@ class Basic extends CI_Controller
|
||||
parent::__construct();
|
||||
|
||||
$this->load->library(array('rdf'));
|
||||
$this->load->helper(array('form', 'url'));
|
||||
$this->load->helper('form');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -25,7 +25,7 @@ class Basic extends CI_Controller
|
||||
$d['content'] = $this->load->view('rdf/basic', $d, true);
|
||||
$this->load->view('home', $d);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load Sparql-View
|
||||
* @return void
|
||||
@@ -37,7 +37,7 @@ class Basic extends CI_Controller
|
||||
$d['content'] = $this->load->view('rdf/basic_sparql', $d, true);
|
||||
$this->load->view('home', $d);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load foaf-View
|
||||
* @return void
|
||||
@@ -60,7 +60,7 @@ class Basic extends CI_Controller
|
||||
$d['content'] = $this->load->view('rdf/foafmaker', $d, true);
|
||||
$this->load->view('home', $d);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load converter View
|
||||
* @return void
|
||||
|
||||
@@ -2,25 +2,19 @@
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class UDF extends VileSci_Controller
|
||||
class UDF extends VileSci_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Load session library
|
||||
$this->load->library('session');
|
||||
|
||||
// Loads the UDF library
|
||||
$this->load->library('UDFLib');
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@@ -33,7 +27,7 @@ class UDF extends VileSci_Controller
|
||||
}
|
||||
unset($this->session->person_id);
|
||||
}
|
||||
|
||||
|
||||
$prestudent_id = $this->input->get('prestudent_id');
|
||||
if (isset($this->session->prestudent_id))
|
||||
{
|
||||
@@ -43,16 +37,16 @@ class UDF extends VileSci_Controller
|
||||
}
|
||||
unset($this->session->prestudent_id);
|
||||
}
|
||||
|
||||
|
||||
$result = null;
|
||||
if (isset($this->session->result))
|
||||
{
|
||||
$result = clone $this->session->result;
|
||||
$this->session->set_userdata('result', null);
|
||||
}
|
||||
|
||||
|
||||
$data = array('result' => $result);
|
||||
|
||||
|
||||
if (isset($person_id) && is_numeric($person_id))
|
||||
{
|
||||
if ($this->PersonModel->hasUDF())
|
||||
@@ -62,7 +56,7 @@ class UDF extends VileSci_Controller
|
||||
$data['personUdfs'] = $personUdfs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($prestudent_id) && is_numeric($prestudent_id))
|
||||
{
|
||||
if ($this->PrestudentModel->hasUDF())
|
||||
@@ -72,54 +66,54 @@ class UDF extends VileSci_Controller
|
||||
$data['prestudentUdfs'] = $prestudentUdfs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->load->view('system/udf', $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function saveUDF()
|
||||
{
|
||||
$udfs = $this->input->post();
|
||||
$validation = $this->_validate($udfs);
|
||||
|
||||
|
||||
$userdata = array(
|
||||
'person_id' => $udfs['person_id'],
|
||||
'prestudent_id' => $udfs['prestudent_id']
|
||||
'person_id' => $this->input->post('person_id'),
|
||||
'prestudent_id' => $this->input->post('prestudent_id')
|
||||
);
|
||||
|
||||
|
||||
if (isSuccess($validation))
|
||||
{
|
||||
// Load model UDF_model
|
||||
$this->load->model('system/UDF_model', 'UDFModel');
|
||||
|
||||
|
||||
$result = $this->UDFModel->saveUDFs($udfs);
|
||||
|
||||
|
||||
$userdata['result'] = $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$userdata['result'] = $validation;
|
||||
}
|
||||
|
||||
|
||||
$this->session->set_userdata($userdata);
|
||||
redirect('system/UDF');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private function _validate($udfs)
|
||||
{
|
||||
$validation = error('person_id or prestudent_id is missing');
|
||||
|
||||
|
||||
if((isset($udfs['person_id']) && !(is_null($udfs['person_id'])) && ($udfs['person_id'] != ''))
|
||||
|| (isset($udfs['prestudent_id']) && !(is_null($udfs['prestudent_id'])) && ($udfs['prestudent_id'] != '')))
|
||||
{
|
||||
$validation = success(true);
|
||||
}
|
||||
|
||||
|
||||
return $validation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class Manager extends VileSci_Controller
|
||||
parent::__construct();
|
||||
|
||||
// Load helpers to upload files
|
||||
$this->load->helper(array('form', 'url'));
|
||||
$this->load->helper('form');
|
||||
|
||||
// Loads the extensions library
|
||||
$this->load->library('ExtensionsLib');
|
||||
|
||||
@@ -10,10 +10,13 @@ class APIv1_Controller extends REST_Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
// Loads helper fhcauth to manage the authentication
|
||||
$this->load->helper('fhcauth');
|
||||
|
||||
// Loads return messages
|
||||
$this->load->helper('message');
|
||||
|
||||
|
||||
log_message('debug', 'Called API: '.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,10 @@ class FHC_Controller extends CI_Controller
|
||||
private $_controllerId; // contains the unique identifier of a call to a controller
|
||||
|
||||
/**
|
||||
* Standard construct for all the controllers, loads the authentication system
|
||||
* Standard construct for all the controllers
|
||||
* - initialize the object properties
|
||||
* - loads the authentication system
|
||||
* - loads all the helpers that later are always needed
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -22,6 +25,12 @@ class FHC_Controller extends CI_Controller
|
||||
|
||||
// Loads helper message to manage returning messages
|
||||
$this->load->helper('message');
|
||||
|
||||
// Loads helper with generic utility function
|
||||
$this->load->helper('fhc');
|
||||
|
||||
// Loads helper session to manage the php session
|
||||
$this->load->helper('session');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -61,7 +61,7 @@ if ( ! function_exists('auth'))
|
||||
function getAuthUID()
|
||||
{
|
||||
$ci =& get_instance(); // get CI instance
|
||||
$ci->load->library('AuthLib'); // load session library
|
||||
$ci->load->library('AuthLib'); // load authentication library
|
||||
|
||||
return $ci->authlib->getUser();
|
||||
}
|
||||
|
||||
@@ -733,7 +733,7 @@ class ExtensionsLib
|
||||
);
|
||||
if (!$_addSoftLinks)
|
||||
{
|
||||
log_message('error','Failed to create Symlink to '.$extensionPath.$targetDirectory);
|
||||
log_message('error', 'Failed to create Symlink to '.$extensionPath.$targetDirectory);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +80,6 @@ class FiltersLib
|
||||
{
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
// Loads helper session to manage the php session
|
||||
$this->_ci->load->helper('session');
|
||||
|
||||
$this->_filterUniqueId = $this->_getFilterUniqueId($params); // sets the id for the related filter widget
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,6 @@ class MessageLib
|
||||
$this->ci->load->model('system/Recipient_model', 'RecipientModel');
|
||||
$this->ci->load->model('system/Attachment_model', 'AttachmentModel');
|
||||
|
||||
// Loads fhc helper
|
||||
$this->ci->load->helper('fhc');
|
||||
|
||||
// Loads phrases
|
||||
$this->ci->lang->load('message');
|
||||
}
|
||||
|
||||
@@ -32,9 +32,6 @@ class NavigationLib
|
||||
// Loads navigation configs
|
||||
$this->_ci->config->load('navigation');
|
||||
|
||||
// Loads helper session to manage the php session
|
||||
$this->_ci->load->helper('session');
|
||||
|
||||
// Loads library ExtensionsLib
|
||||
$this->_ci->load->library('ExtensionsLib');
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ class PermissionLib
|
||||
const DELETE_RIGHT = 'd';
|
||||
const REPLACE_RIGHT = 'ui';
|
||||
|
||||
private $_ci; // CI instance
|
||||
private $acl; // conversion array from a source to a permission
|
||||
private static $bb; // benutzerberechtigung
|
||||
|
||||
@@ -40,22 +41,20 @@ class PermissionLib
|
||||
public function __construct()
|
||||
{
|
||||
// Loads CI instance
|
||||
$this->ci =& get_instance();
|
||||
|
||||
// Loads the library to manage the rights system
|
||||
//$this->ci->load->library('FHC_DB_ACL');
|
||||
|
||||
// Loads the auth helper
|
||||
$this->ci->load->helper('fhcauth');
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
// Loads the array of resources
|
||||
$this->acl = $this->ci->config->item('fhc_acl');
|
||||
$this->acl = $this->_ci->config->item('fhc_acl');
|
||||
|
||||
// Loads authentication library
|
||||
$this->_ci->load->library('AuthLib');
|
||||
|
||||
// If it's NOT called from command line
|
||||
if (!is_cli())
|
||||
{
|
||||
// API Caller rights initialization
|
||||
self::$bb = new benutzerberechtigung();
|
||||
self::$bb->getBerechtigungen(getAuthUID());
|
||||
self::$bb->getBerechtigungen($this->_ci->authlib->getUser());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1814,6 +1814,9 @@ abstract class REST_Controller extends CI_Controller {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Loads authentication library
|
||||
$this->load->library('AuthLib');
|
||||
|
||||
if (is_callable([$auth_library_class, $auth_library_function]) === FALSE)
|
||||
{
|
||||
$this->load->library($auth_library_class);
|
||||
|
||||
@@ -53,8 +53,6 @@ class UDFLib
|
||||
public function __construct()
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
$this->_ci->load->helper('fhc');
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -20,8 +20,6 @@ class VorlageLib
|
||||
|
||||
$this->ci->load->model('system/Vorlage_model', 'VorlageModel');
|
||||
$this->ci->load->model('system/Vorlagestudiengang_model', 'VorlageStudiengangModel');
|
||||
|
||||
$this->ci->load->helper('language');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
* @author Jens Segers
|
||||
* @link http://www.jenssegers.be
|
||||
* @license MIT License Copyright (c) 2012 Jens Segers
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@@ -30,16 +30,16 @@ class WidgetLib
|
||||
{
|
||||
const DIR_HTML_WIDGETS = 'html';
|
||||
const HTML_WIDGET_NAME = 'HTMLWidget';
|
||||
|
||||
|
||||
/* default values */
|
||||
private $_template = 'template';
|
||||
private $_parser = false;
|
||||
private $_cache_ttl = 0;
|
||||
private $_widget_path = '';
|
||||
|
||||
|
||||
private $_ci;
|
||||
private $_partials = array();
|
||||
|
||||
|
||||
/**
|
||||
* Construct with configuration array. Codeigniter will use the config file otherwise
|
||||
* @param array $config
|
||||
@@ -47,23 +47,19 @@ class WidgetLib
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->_ci = & get_instance();
|
||||
|
||||
$this->_ci->load->helper('fhc');
|
||||
|
||||
|
||||
// Set the default widget path with APPPATH
|
||||
$this->_widget_path = APPPATH.'widgets/';
|
||||
|
||||
|
||||
// Loads widgets to render HTML elements
|
||||
// NOTE: the first one to be loaded must be HTMLWidget
|
||||
loadResource($this->_widget_path.WidgetLib::DIR_HTML_WIDGETS, WidgetLib::HTML_WIDGET_NAME);
|
||||
loadResource($this->_widget_path.WidgetLib::DIR_HTML_WIDGETS);
|
||||
|
||||
if (!empty($config))
|
||||
$this->initialize($config);
|
||||
|
||||
log_message('debug', 'Template library initialized');
|
||||
|
||||
// If config are given then initialize this lib with the given config
|
||||
if (!empty($config)) $this->initialize($config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize with configuration array
|
||||
* @param array $config
|
||||
@@ -73,14 +69,14 @@ class WidgetLib
|
||||
{
|
||||
foreach ($config as $key => $val)
|
||||
$this->{'_'.$key} = $val;
|
||||
|
||||
|
||||
if ($this->_widget_path == '')
|
||||
$this->_widget_path = APPPATH.'widgets/';
|
||||
|
||||
|
||||
if ($this->_parser && !class_exists('CI_Parser'))
|
||||
$this->_ci->load->library('parser');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a partial's content. This will create a new partial when not existing
|
||||
* @param string $index
|
||||
@@ -90,7 +86,7 @@ class WidgetLib
|
||||
{
|
||||
$this->partial($name)->set($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Access to partials for method chaining
|
||||
* @param string $name
|
||||
@@ -100,7 +96,7 @@ class WidgetLib
|
||||
{
|
||||
return $this->partial($name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a partial exists
|
||||
* @param string $index
|
||||
@@ -110,7 +106,7 @@ class WidgetLib
|
||||
{
|
||||
return array_key_exists($index, $this->_partials);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the template file
|
||||
* @param string $template
|
||||
@@ -119,7 +115,7 @@ class WidgetLib
|
||||
{
|
||||
$this->_template = $template;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Publish the template with the current partials
|
||||
* You can manually pass a template file with extra data, or use the default template from the config file
|
||||
@@ -136,12 +132,12 @@ class WidgetLib
|
||||
{
|
||||
$this->_template = $template;
|
||||
}
|
||||
|
||||
|
||||
if (!$this->_template)
|
||||
{
|
||||
show_error('There was no template file selected for the current template');
|
||||
}
|
||||
|
||||
|
||||
if (is_array($data) || is_object($data))
|
||||
{
|
||||
foreach ($data as $name => $content)
|
||||
@@ -149,9 +145,9 @@ class WidgetLib
|
||||
$this->partial($name)->set($content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unset($data);
|
||||
|
||||
|
||||
if ($this->_parser)
|
||||
{
|
||||
$this->_ci->parser->parse($this->_template, $this->_partials);
|
||||
@@ -161,7 +157,7 @@ class WidgetLib
|
||||
$this->_ci->load->view($this->_template, $this->_partials);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a partial object with an optional default content
|
||||
* Can be usefull to use straight from the template file
|
||||
@@ -183,24 +179,24 @@ class WidgetLib
|
||||
{
|
||||
$partial->cache($this->_cache_ttl);
|
||||
}
|
||||
|
||||
|
||||
// detect local triggers
|
||||
if (method_exists($this, 'trigger_'.$name))
|
||||
{
|
||||
$partial->bind($this, 'trigger_'.$name);
|
||||
}
|
||||
|
||||
|
||||
$this->_partials[$name] = $partial;
|
||||
}
|
||||
|
||||
|
||||
if (!$partial->content() && $default)
|
||||
{
|
||||
$partial->set($default);
|
||||
}
|
||||
|
||||
|
||||
return $partial;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a widget object with optional parameters
|
||||
* Can be usefull to use straight from the template file
|
||||
@@ -213,15 +209,15 @@ class WidgetLib
|
||||
{
|
||||
// Loads the widget file, trying to find it also in the subdirectories
|
||||
loadResource($this->_widget_path, $name, true);
|
||||
|
||||
|
||||
if (!class_exists($name))
|
||||
{
|
||||
show_error("Widget '".$name."' was not found.");
|
||||
}
|
||||
|
||||
|
||||
return new $name($name, $data, $htmlArgs);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable cache for all partials with TTL, default TTL is 60
|
||||
* @param int $ttl
|
||||
@@ -233,10 +229,10 @@ class WidgetLib
|
||||
{
|
||||
$partial->cache($ttl, $identifier);
|
||||
}
|
||||
|
||||
|
||||
$this->_cache_ttl = $ttl;
|
||||
}
|
||||
|
||||
|
||||
// ---- TRIGGERS -----------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -255,27 +251,27 @@ class WidgetLib
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
if (!stristr($url, 'http://') && !stristr($url, 'https://') && substr($url, 0, 2) != '//')
|
||||
{
|
||||
$url = $this->_ci->config->item('base_url').$url;
|
||||
}
|
||||
|
||||
|
||||
// legacy support for media
|
||||
if (is_string($attributes))
|
||||
{
|
||||
$attributes = array('media' => $attributes);
|
||||
}
|
||||
|
||||
|
||||
if (is_array($attributes))
|
||||
{
|
||||
$attributeString = "";
|
||||
|
||||
|
||||
foreach ($attributes as $key => $value)
|
||||
{
|
||||
$attributeString .= $key.'="'.$value.'" ';
|
||||
}
|
||||
|
||||
|
||||
return '<link rel="stylesheet" href="'.htmlspecialchars(strip_tags($url)).'" '.$attributeString.'>'."\n\t";
|
||||
}
|
||||
else
|
||||
@@ -283,7 +279,7 @@ class WidgetLib
|
||||
return '<link rel="stylesheet" href="'.htmlspecialchars(strip_tags($url)).'">'."\n\t";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Javascript trigger
|
||||
* @param string $source
|
||||
@@ -300,15 +296,15 @@ class WidgetLib
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
if (!stristr($url, 'http://') && !stristr($url, 'https://') && substr($url, 0, 2) != '//')
|
||||
{
|
||||
$url = $this->_ci->config->item('base_url').$url;
|
||||
}
|
||||
|
||||
|
||||
return '<script src="'.htmlspecialchars(strip_tags($url)).'"></script>'."\n\t";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Meta trigger
|
||||
* @param string $name
|
||||
@@ -319,12 +315,12 @@ class WidgetLib
|
||||
{
|
||||
$name = htmlspecialchars(strip_tags($name));
|
||||
$value = htmlspecialchars(strip_tags($value));
|
||||
|
||||
|
||||
if ($name == 'keywords' and !strpos($value, ','))
|
||||
{
|
||||
$content = preg_replace('/[\s]+/', ', ', trim($value));
|
||||
}
|
||||
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'meta' :
|
||||
@@ -334,10 +330,10 @@ class WidgetLib
|
||||
$content = '<link rel="'.$name.'" href="'.$value.'">'."\n\t";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Title trigger, keeps it clean
|
||||
* @param string $name
|
||||
@@ -348,7 +344,7 @@ class WidgetLib
|
||||
{
|
||||
return htmlspecialchars(strip_tags($title));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Title trigger, keeps it clean
|
||||
* @param string $name
|
||||
@@ -366,7 +362,7 @@ class Partial
|
||||
{
|
||||
protected $_ci, $_content, $_name, $_cache_ttl = 0, $_cached = false, $_identifier, $_trigger;
|
||||
protected $_args = array();
|
||||
|
||||
|
||||
/**
|
||||
* Construct with optional parameters
|
||||
* @param array $args
|
||||
@@ -377,7 +373,7 @@ class Partial
|
||||
$this->_args = $args;
|
||||
$this->_name = $name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gives access to codeigniter's functions from this class if needed
|
||||
* This will be handy in extending classes
|
||||
@@ -387,7 +383,7 @@ class Partial
|
||||
{
|
||||
return $this->_ci->$name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Alias methods
|
||||
*/
|
||||
@@ -403,7 +399,7 @@ class Partial
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the content when converted to a string
|
||||
* @return string
|
||||
@@ -412,7 +408,7 @@ class Partial
|
||||
{
|
||||
return (string) $this->content();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the content
|
||||
* @return string
|
||||
@@ -423,10 +419,10 @@ class Partial
|
||||
{
|
||||
$this->cache->save($this->cache_id(), $this->_content, $this->_cache_ttl);
|
||||
}
|
||||
|
||||
|
||||
return $this->_content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overwrite the content
|
||||
* @param mixed $content
|
||||
@@ -438,10 +434,10 @@ class Partial
|
||||
{
|
||||
$this->_content = (string) $this->trigger(func_get_args());
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Append something to the content
|
||||
* @param mixed $content
|
||||
@@ -453,10 +449,10 @@ class Partial
|
||||
{
|
||||
$this->_content .= (string) $this->trigger(func_get_args());
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepend something to the content
|
||||
* @param mixed $content
|
||||
@@ -468,10 +464,10 @@ class Partial
|
||||
{
|
||||
$this->_content = (string) $this->trigger(func_get_args()).$this->_content;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set content if partial is empty
|
||||
* @param mixed $default
|
||||
@@ -486,10 +482,10 @@ class Partial
|
||||
$this->_content = $default;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load a view inside this partial, overwrite if wanted
|
||||
* @param string $view
|
||||
@@ -511,9 +507,9 @@ class Partial
|
||||
}
|
||||
$data = $array;
|
||||
}
|
||||
|
||||
|
||||
$content = $this->_ci->load->view($view, $data, true);
|
||||
|
||||
|
||||
if ($overwrite)
|
||||
{
|
||||
$this->set($content);
|
||||
@@ -525,7 +521,7 @@ class Partial
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parses a view inside this partial, overwrite if wanted
|
||||
* @param string $view
|
||||
@@ -541,7 +537,7 @@ class Partial
|
||||
{
|
||||
$this->_ci->load->library('parser');
|
||||
}
|
||||
|
||||
|
||||
// better object to array
|
||||
if (is_object($data))
|
||||
{
|
||||
@@ -552,9 +548,9 @@ class Partial
|
||||
}
|
||||
$data = $array;
|
||||
}
|
||||
|
||||
|
||||
$content = $this->_ci->parser->parse($view, $data, true);
|
||||
|
||||
|
||||
if ($overwrite)
|
||||
{
|
||||
$this->set($content);
|
||||
@@ -564,10 +560,10 @@ class Partial
|
||||
$this->append($content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads a widget inside this partial, overwrite if wanted
|
||||
* @param string $name
|
||||
@@ -580,7 +576,7 @@ class Partial
|
||||
if (!$this->_cached)
|
||||
{
|
||||
$widget = $this->template->widget($name, $data);
|
||||
|
||||
|
||||
if ($overwrite)
|
||||
{
|
||||
$this->set($widget->content());
|
||||
@@ -592,7 +588,7 @@ class Partial
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable cache with TTL, default TTL is 60
|
||||
* @param int $ttl
|
||||
@@ -604,10 +600,10 @@ class Partial
|
||||
{
|
||||
$this->_ci->load->driver('cache', array('adapter' => 'file'));
|
||||
}
|
||||
|
||||
|
||||
$this->_cache_ttl = $ttl;
|
||||
$this->_identifier = $identifier;
|
||||
|
||||
|
||||
if ($cached = $this->_ci->cache->get($this->cache_id()))
|
||||
{
|
||||
$this->_cached = true;
|
||||
@@ -615,7 +611,7 @@ class Partial
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used for cache identification
|
||||
* @return string
|
||||
@@ -631,7 +627,7 @@ class Partial
|
||||
return $this->_name.'_'.md5(get_class($this).implode('', $this->_args));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Trigger returns the result if a trigger is set
|
||||
* @param array $args
|
||||
@@ -648,7 +644,7 @@ class Partial
|
||||
return call_user_func_array($this->_trigger, $args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bind a trigger function
|
||||
* Can be used like bind($this, "function") or bind("function")
|
||||
@@ -663,12 +659,12 @@ class Partial
|
||||
$args = func_get_args();
|
||||
$obj = array_shift($args);
|
||||
$func = array_pop($args);
|
||||
|
||||
|
||||
foreach ($args as $trigger)
|
||||
{
|
||||
$obj = $obj->$trigger;
|
||||
}
|
||||
|
||||
|
||||
$this->_trigger = array($obj, $func);
|
||||
}
|
||||
else
|
||||
@@ -703,8 +699,8 @@ class Widget extends Partial
|
||||
ob_start();
|
||||
$this->display($this->_args);
|
||||
$buffer = ob_get_clean();
|
||||
|
||||
// if no content is produced but there was direct ouput we set
|
||||
|
||||
// if no content is produced but there was direct ouput we set
|
||||
// that output as content
|
||||
if (!$this->_content && $buffer)
|
||||
{
|
||||
@@ -712,7 +708,7 @@ class Widget extends Partial
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return parent::content();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,10 +51,12 @@ class UDF_model extends DB_Model
|
||||
$resultPerson = success('person');
|
||||
$resultPrestudent = success('prestudent');
|
||||
|
||||
$person_id = $udfs['person_id'];
|
||||
$person_id = null;
|
||||
if (isset($udfs['person_id'])) $person_id = $udfs['person_id'];
|
||||
unset($udfs['person_id']);
|
||||
|
||||
$prestudent_id = $udfs['prestudent_id'];
|
||||
$prestudent_id = null;
|
||||
if (isset($udfs['prestudent_id'])) $prestudent_id = $udfs['prestudent_id'];
|
||||
unset($udfs['prestudent_id']);
|
||||
|
||||
$jsons = array();
|
||||
|
||||
@@ -10,7 +10,7 @@ class Seed_Message
|
||||
$this->fhc =& get_instance();
|
||||
$this->fhc->load->helper('fhc');
|
||||
}
|
||||
|
||||
|
||||
public function seed($limit = 50)
|
||||
{
|
||||
echo "Seeding $limit messages ";
|
||||
@@ -18,11 +18,11 @@ class Seed_Message
|
||||
$db = $this->fhc->db->query('SELECT person_id FROM public.tbl_person LIMIT 100;');
|
||||
$person = $db->result();
|
||||
$num_persons = $db->num_rows();
|
||||
|
||||
|
||||
for ($i = 0; $i < $limit; $i++)
|
||||
{
|
||||
echo ".";
|
||||
|
||||
|
||||
$data = array
|
||||
(
|
||||
'subject' => $this->fhc->faker->sentence(4, true),
|
||||
@@ -43,9 +43,9 @@ class Seed_Message
|
||||
if (!$recipient)
|
||||
show_error($recipient);
|
||||
}
|
||||
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function truncate()
|
||||
@@ -53,4 +53,3 @@ class Seed_Message
|
||||
$this->fhc->db->query('DELETE FROM public.msg_message;');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user