Libs and Vorlagen

This commit is contained in:
Paminger
2016-06-17 00:12:46 +02:00
parent 7766595c5d
commit 4c58b95728
22 changed files with 967 additions and 4 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ $autoload['packages'] = array();
*/
//$autoload['libraries'] = array();
$autoload['libraries'] = array('Session', 'FHC_Auth');
$autoload['libraries'] = array('Session', 'FHC_Auth', 'TemplateLib');
/*
| -------------------------------------------------------------------
+69
View File
@@ -0,0 +1,69 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Messages extends FHC_Controller
{
public function __construct()
{
parent::__construct();
$this->load->library('messaging');
//$this->load->model('person/Person_model');
//$this->load->model('system/Message_model');
}
public function index()
{
//$messages = $this->Message_model->getMessages();
$msg = $this->Message_model->load(1);
if ($msg->error)
show_error($msg->retval);
$data = array
(
'message' => $msg->retval[0]
);
$v = $this->load->view('message.php', $data);
}
public function view($msg_id)
{
$msg = $this->messaging->getMessage($msg_id);
//var_dump($msg);
if ($msg->error)
show_error($msg->retval);
if (count($msg->retval) != 1)
show_error('Nachricht nicht vorhanden! ID: '.$msg_id);
$data = array
(
'message' => $msg->retval[0]
);
//var_dump($data['message']);
$v = $this->load->view('system/messageView', $data);
}
public function write($vorlage_kurzbz = null)
{
$data = array
(
'subject' => 'TestSubject',
'body' => 'TestDevelopmentBodyText'
);
$v = $this->load->view('system/messageWrite', $data);
}
public function send()
{
$body = $this->input->post('body', TRUE);
$subject = $this->input->post('subject', TRUE);
if (! $this->messaging->addRecipient(1))
show_error('Error: AddRecipient');
$msg = $this->messaging->sendMessage(1,$body ,$subject);
if ($msg->error)
show_error($msg->retval);
$msg_id = $msg->retval;
redirect('/system/Message/view/'.$msg_id);
}
}
+80
View File
@@ -0,0 +1,80 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Templates extends FHC_Controller
{
public function __construct()
{
parent::__construct();
$this->load->library('VorlageLib');
}
public function index()
{
$this->load->view('system/templates.php');
}
public function table()
{
$mimetype = $this->input->post('mimetype', TRUE);
if (is_null($mimetype))
$mimetype = 'text/html';
if ($mimetype == '')
$mimetype = null;
$vorlage = $this->vorlagelib->getVorlageByMimetype($mimetype);
if ($vorlage->error)
show_error($vorlage->retval);
//var_dump($vorlage);
$data = array
(
'mimetype' => $mimetype,
'vorlage' => $vorlage->retval
);
$v = $this->load->view('system/templatesList.php', $data);
}
public function edit($vorlage_kurzbz = null)
{
if (empty($vorlage_kurzbz))
exit;
$vorlage = $this->vorlagelib->getVorlage($vorlage_kurzbz);
//var_dump($vorlage);
if ($vorlage->error)
show_error($vorlage->retval);
if (count($vorlage->retval) != 1)
show_error('Nachricht nicht vorhanden! ID: '.$vorlage_kurzbz);
$data = array
(
'vorlage' => $vorlage->retval[0]
);
//var_dump($data['message']);
$v = $this->load->view('system/templatesEdit', $data);
}
public function write($vorlage_kurzbz = null)
{
$data = array
(
'subject' => 'TestSubject',
'body' => 'TestDevelopmentBodyText'
);
$v = $this->load->view('system/messageWrite', $data);
}
public function save()
{
$vorlage_kurzbz = $this->input->post('vorlage_kurzbz', TRUE);
$data['bezeichnung'] = $this->input->post('bezeichnung', TRUE);
$data['anmerkung'] = $this->input->post('anmerkung', TRUE);
$data['mimetype'] = $this->input->post('mimetype', TRUE);
$vorlage = $this->vorlagelib->saveVorlage($vorlage_kurzbz, $data);
if ($vorlage->error)
show_error($vorlage->retval);
$vorlage_kurzbz = $vorlage->retval;
redirect('/system/Templates/edit/'.$vorlage_kurzbz);
}
}
-1
View File
@@ -8,7 +8,6 @@ class FHC_Controller extends CI_Controller
function __construct()
{
parent::__construct();
$this->load->library('template');
$this->load->library('session');
//$this->load->helper('language');
+311
View File
@@ -0,0 +1,311 @@
<?php
if (! defined('BASEPATH'))
exit('No direct script access allowed');
/**
* Name: Messaging Library for FH-Complete
*
*
*/
class MessageLib
{
private $recipients = array();
public function __construct()
{
require_once APPPATH.'config/message.php';
$this->ci =& get_instance();
//$this->ci->load->model('person/Person_model', 'PersonModel');
$this->ci->load->model('system/Message_model', 'MessageModel');
$this->ci->load->model('system/MsgStatus_model', 'MsgStatusModel');
$this->ci->load->model('system/Recipient_model', 'RecipientModel');
$this->ci->load->model('system/Attachment_model', 'AttachmentModel');
$this->ci->load->helper('language');
$this->ci->lang->load('message');
}
// ------------------------------------------------------------------------
/**
* get_message() - will return a single message, including the status for specified user.
*
* @param integer $msg_id REQUIRED
* @return array
*/
function getMessage($msg_id)
{
if (!is_numeric($msg_id))
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
$this->ci->MessageModel->addJoin('public.tbl_person', 'person_id');
$msg = $this->ci->MessageModel->loadWhere(array('message_id' => $msg_id));
//$msg = $this->ci->MessageModel->getMessage($msg_id);
$stat = $this->ci->MsgStatusModel->loadWhere(array('message_id' => $msg_id));
$msg->retval[0]->stat = $stat->retval;
$recp = $this->ci->RecipientModel->loadWhere(array('message_id' => $msg_id));
$msg->retval[0]->recp = $recp->retval;
$attm = $this->ci->AttachmentModel->loadWhere(array('message_id' => $msg_id));
$msg->retval[0]->attm = $attm->retval;
// General Error Occurred
return $msg;
}
// ------------------------------------------------------------------------
/**
* getSubMessages() - will return all Messages subordinated from a specified message.
*
* @param integer $msg_id REQUIRED
* @return array
*/
function getSubMessages($msg_id)
{
if (!is_numeric($msg_id))
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
$msg = $this->getMessage($msg_id);
return $msg;
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
/**
* updateMessageStatus() - will change status on message for particular user
*
* @param integer $msg_id REQUIRED
* @param integer $user_id REQUIRED
* @param integer $status_id REQUIRED - should come from config/message.php list of constants
* @return array
*/
function updateMessageStatus($msg_id, $user_id, $status_id )
{
if (empty($msg_id))
{
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
}
if (empty($user_id))
{
return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
}
if (empty($status_id))
{
return $this->_invalid_id(MSG_ERR_INVALID_STATUS_ID);
}
if ($this->ci->message_model->update_message_status($msg_id, $user_id, $status_id))
{
return $this->_success(NULL, MSG_STATUS_UPDATE);
}
// General Error Occurred
return $this->_general_error();
}
// ------------------------------------------------------------------------
/**
* add_participant() - adds user to existing thread
*
* @param integer $thread_id REQUIRED
* @param integer $user_id REQUIRED
* @return array
*/
function addRecipient($person_id)
{
if (!is_numeric($person_id))
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
$this->recipients[] = $person_id;
return true;
}
// ------------------------------------------------------------------------
/**
* sendMessage() - sends new internal message. This function will create a new thread
*
* @param integer $sender_id REQUIRED
* @param mixed $recipients REQUIRED - a single integer or an array of integers, representing user_ids
* @param string $subject
* @param string $body
* @param integer $priority
* @return array
*/
function sendMessage($sender_id, $subject = '', $body = '', $priority = PRIORITY_NORMAL, $relationmessage_id = null, $oe_kurzbz = null)
{
if (!is_numeric($sender_id))
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
if (empty($this->recipients))
return $this->_error('No Recipients! Use addRecipient()', MSG_ERR_INVALID_RECIPIENTS);
// Start sending Message
$this->ci->db->trans_start(false);
//save Message
$data = array(
'person_id' => $sender_id,
'subject' => $subject,
'body' => $body,
'priority' => $priority,
'relationmessage_id' => $relationmessage_id,
'oe_kurzbz' => $oe_kurzbz);
if (! $msg = $this->ci->MessageModel->insert($data))
return $this->_error($msg->msg.$msg->retval, MSG_ERR_GENERAL);
$msg_id = $msg->retval;
$this->ci->db->trans_complete();
if ($this->ci->db->trans_status() === FALSE)
{
// generate an error... or use the log_message() function to log your error
// General Error Occurred
return $this->_error();
}
else
return $this->_success($msg_id);
}
// ------------------------------------------------------------------------
/**
* reply_to_message() - replies to internal message. This function will NOT create a new thread or participant list
*
* @param integer $msg_id REQUIRED
* @param integer $sender_id REQUIRED
* @param string $subject
* @param string $body
* @param integer $priority
* @return array
*/
function reply_to_message($msg_id, $sender_id, $subject = '', $body = '', $priority = PRIORITY_NORMAL)
{
if (empty($sender_id))
{
return $this->_invalid_id(MSG_ERR_INVALID_SENDER_ID);
}
if (empty($msg_id))
{
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
}
if ($new_msg_id = $this->ci->message_model->reply_to_message($msg_id, $sender_id, $body, $priority))
{
return $this->_success($new_msg_id, MSG_MESSAGE_SENT);
}
// General Error Occurred
return $this->_general_error();
}
// ------------------------------------------------------------------------
/**
* get_participant_list() - returns list of participants on given thread. If sender_id set, sender_id will be left off list
*
* @param integer $thread_id REQUIRED
* @param integer $sender_id REQUIRED
* @return array
*/
function get_participant_list($thread_id, $sender_id = 0)
{
if (empty($thread_id))
{
return $this->_invalid_id(MSG_ERR_INVALID_THREAD_ID);
}
if ($participants = $this->ci->message_model-> get_participant_list($thread_id, $sender_id))
{
return $this->_success($participants);
}
// General Error Occurred
return $this->_general_error();
}
// ------------------------------------------------------------------------
/**
* get_msg_count() - returns integer with count of message for user, by status. defaults to new messages
*
* @param integer $user_id REQUIRED
* @param integer $status_id OPTIONAL - defaults to "Unread"
* @return array
*/
function get_msg_count($user_id, $status_id = MSG_STATUS_UNREAD)
{
if (empty($user_id))
{
return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
}
if (is_numeric($message = $this->ci->message_model->get_msg_count($user_id, $status_id)))
{
return $this->_success($message);
}
// General Error Occurred
return $this->_general_error();
}
// ------------------------------------------------------------------------
// Private Functions from here out!
// ------------------------------------------------------------------------
/** ---------------------------------------------------------------
* Success
*
* @param mixed $retval
* @return array
*/
protected function _success($retval, $message = MSG_SUCCESS)
{
$return = new stdClass();
$return->error = EXIT_SUCCESS;
$return->Code = $message;
$return->msg = lang('message_' . $message);
$return->retval = $retval;
return $return;
}
/** ---------------------------------------------------------------
* General Error
*
* @return array
*/
protected function _error($retval = '', $message = MSG_ERROR_GENERAL)
{
$return = new stdClass();
$return->error = EXIT_ERROR;
$return->Code = $message;
$return->msg = lang('message_' . $message);
$return->retval = $retval;
return $return;
}
/**
* Invalid ID
*
* @param integer config.php error code numbers
* @return array
*/
private function _invalid_id($error = '')
{
return array(
'err' => 1,
'code' => $error,
'msg' => lang('message_'.$error)
);
}
}
+78
View File
@@ -0,0 +1,78 @@
<?php
/**
* FH-Complete
*
* @package FHC-Helper
* @author FHC-Team
* @copyright Copyright (c) 2016 fhcomplete.org
* @license GPLv3
* @link https://fhcomplete.org
* @since Version 1.0.0
* @filesource
*/
if (! defined('FCPATH'))
exit('No direct script access allowed');
require_once(FCPATH.'include/basis_db.class.php');
require_once(FCPATH.'include/organisationseinheit.class.php');
require_once(FCPATH.'include/studiengang.class.php');
require_once(FCPATH.'include/fachbereich.class.php');
require_once(FCPATH.'include/functions.inc.php');
require_once(FCPATH.'include/wawi_kostenstelle.class.php');
require_once(FCPATH.'include/benutzerberechtigung.class.php');
/**
* FHC-Auth Helpers
*
* @package FH-Complete
* @subpackage Libraries
* @category Library
* @author FHC-Team
* @link http://fhcomplete.org/user_guide/helpers/fhcauth_helper.html
*/
// ------------------------------------------------------------------------
class PermissionLib
{
public $bb;
protected $_uid;
/**
* Auth Username, Password over FH-Complete
*
* @param string $username
* @param string $password
* @return bool
*/
function __construct($param = null)
{
if (is_array($param) && isset($param['uid']))
$this->_uid = $param['uid'];
}
function isBerechtigt($berechtigung_kurzbz, $art=null, $oe_kurzbz=null, $kostenstelle_id=null)
{
$this->bb->getBerechtigungen($this->_uid);
return $this->bb->isBerechtigt($berechtigung_kurzbz, $oe_kurzbz=null, $art=null, $kostenstelle_id=null);
}
function getPermissions($uid)
{
}
function isEntitled($berechtigung_kurzbz, $oe_kurzbz=null, $art=null, $kostenstelle_id=null)
{
}
/** ---------------------------------------------------------------
* Set UID
*
* @param string $uid
* @return bool
*/
public function setUID($uid)
{
return $this->_uid = $uid;
}
}
@@ -11,7 +11,7 @@
*/
require_once APPPATH."../vendor/easyrdf/easyrdf/lib/EasyRdf.php";
class Rdf
class RdfLib
{
@@ -27,7 +27,7 @@
if (!defined("BASEPATH"))
exit("No direct script access allowed");
class Template
class TemplateLib
{
/* default values */
+95
View File
@@ -0,0 +1,95 @@
<?php
if (! defined('BASEPATH'))
exit('No direct script access allowed');
/**
* Name: Messaging Library for FH-Complete
*
*
*/
class VorlageLib
{
private $recipients = array();
public function __construct()
{
require_once APPPATH.'config/message.php';
$this->ci =& get_instance();
$this->ci->load->model('system/Vorlage_model', 'VorlageModel');
$this->ci->load->helper('language');
$this->ci->lang->load('message');
}
/**
* getVorlage() - will load a spezific Template
*
* @param integer $vorlage_kurzbz REQUIRED
* @return struct
*/
function getVorlage($vorlage_kurzbz)
{
if (empty($vorlage_kurzbz))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
$vorlage = $this->ci->VorlageModel->load($vorlage_kurzbz);
return $vorlage;
}
/**
* getSubMessages() - will return all Messages subordinated from a specified message.
*
* @param integer $msg_id REQUIRED
* @return array
*/
function getVorlageByMimetype($mimetype = null)
{
$vorlage = $this->ci->VorlageModel->loadWhere(array('mimetype' => $mimetype));
return $vorlage;
}
/**
* saveVorlage() - will save a spezific Template.
*
* @param array $data REQUIRED
* @return array
*/
function saveVorlage($vorlage_kurzbz, $data)
{
if (empty($data))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
$vorlage = $this->ci->VorlageModel->update($vorlage_kurzbz, $data);
return $vorlage;
}
/** ---------------------------------------------------------------
* Success
*
* @param mixed $retval
* @return array
*/
protected function _success($retval, $message = MSG_SUCCESS)
{
$return = new stdClass();
$return->error = EXIT_SUCCESS;
$return->Code = $message;
$return->msg = lang('message_' . $message);
$return->retval = $retval;
return $return;
}
/** ---------------------------------------------------------------
* General Error
*
* @return array
*/
protected function _error($retval = '', $message = MSG_ERROR_GENERAL)
{
$return = new stdClass();
$return->error = EXIT_ERROR;
$return->Code = $message;
$return->msg = lang('message_' . $message);
$return->retval = $retval;
return $return;
}
}
@@ -0,0 +1,16 @@
<?php
if ( ! defined('BASEPATH'))
exit('No direct script access allowed');
class Attachment_model extends DB_Model
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->dbTable = 'public.tbl_msg_attachment';
$this->pk = 'attachment_id';
}
}
@@ -0,0 +1,18 @@
<?php
if ( ! defined('BASEPATH'))
exit('No direct script access allowed');
class MsgStatus_model extends DB_Model
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->dbTable = 'public.tbl_msg_status';
$this->pk = array('message_id', 'person_id');
$this->hasSequence = false;
}
}
+14
View File
@@ -0,0 +1,14 @@
<script type="text/javascript" src="<?php echo base_url('vendor/tinymce/tinymce/tinymce.min.js');?>"></script>
<div class="row">
<div class="span4">
<h2>Nachricht <?php echo $message->message_id,': ',$message->subject; ?></h2>
Absender: <?php echo $message->person_id; ?><br/>
Betreff: <?php echo $message->subject; ?><br/>
Text: <?php echo $message->body; ?><br/>
<?php
// This is an example to show that you can load stuff from inside the template file
echo $this->template->widget("organisationseinheit_widget", array('title' => 'Organisationseinheit', 'oe_kurzbz' => $message->oe_kurzbz));
?>
</div>
+20
View File
@@ -0,0 +1,20 @@
<script type="text/javascript" src="<?php echo base_url('vendor/tinymce/tinymce/tinymce.min.js');?>"></script>
<div class="row">
<div class="span4">
<h2>Neue Nachricht</h2>
<form method="post" action="send">
Absender: <?php //echo $message->person_id; ?><br/>
<?php
// This is an example to show that you can load stuff from inside the template file
//echo $this->template->widget("organisationseinheit_widget", array('title' => 'Organisationseinheit', 'oe_kurzbz' => $message->oe_kurzbz));
?>
Betreff: <input type="text" name="subject" value="<?php echo $subject; ?>" /></input>
<?php
// This is an example to show that you can load stuff from inside the template file
echo $this->template->widget("tinymce_widget", array());
?>
<textarea name="body" style="width:100%"><?php echo $body; ?></textarea>
<button type="submit">send Message!</button>
</form>
</div>
</div>
+22
View File
@@ -0,0 +1,22 @@
<script type="text/javascript" src="<?php echo base_url('vendor/tinymce/tinymce/tinymce.min.js');?>"></script>
<div class="row">
<div class="span4">
<h2>Nachricht <?php echo $message->message_id,': ',$message->subject; ?></h2>
Absender: <?php echo $message->person_id; ?><br/>
Betreff: <?php echo $message->subject; ?><br/>
Text: <?php echo $message->body; ?><br/>
<?php
// This is an example to show that you can load stuff from inside the template file
echo $this->template->widget("organisationseinheit_widget", array('title' => 'Organisationseinheit', 'oe_kurzbz' => $message->oe_kurzbz));
?>
<form method="post" action="system/Message/send">
<?php
// This is an example to show that you can load stuff from inside the template file
echo $this->template->widget("tinymce_widget", array());
?>
<input type="text" name="subject"></input>
<textarea name="body" style="width:100%"></textarea>
<button type="submit">send Message!</button>
</form>
</div>
+20
View File
@@ -0,0 +1,20 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
<html lang="de_AT">
<head>
<title>VileSci - Templates</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<frameset rows="30%,*">
<frame src="Templates/table" id="TemplatesTop" name="TemplatesTop" frameborder="0" />
<frame src="Templates/edit" id="TemplatesBottom" name="TemplatesBottom" frameborder="0" />
<noframes>
<body bgcolor="#FFFFFF">
This application works only with a frames-enabled browser.<br />
<a href="TemplatesList">Use without frames</a>
</body>
</noframes>
</frameset>
</html>
@@ -0,0 +1,18 @@
<?php
$this->load->view('templates/header', array('title' => 'TemplateEdit'));
?>
<div class="row">
<div class="span4">
<h2>Vorlage: <?php echo $vorlage->vorlage_kurzbz; ?></h2>
<form method="post" action="../save">
Bezeichnung: <input type="text" name="bezeichnung" value="<?php echo $vorlage->bezeichnung; ?>" />
Anmerkung: <input type="text" name="anmerkung" value="<?php echo $vorlage->anmerkung; ?>" />
MimeType:<?php echo $this->templatelib->widget("mimetype_widget", array('mimetype' => $vorlage->mimetype)); ?>
<input type="hidden" name="vorlage_kurzbz" value="<?php echo $vorlage->vorlage_kurzbz; ?>" />
<button type="submit">Save</button>
</form>
</div>
</div>
</body>
</html>
@@ -0,0 +1,37 @@
<?php
$this->load->view('templates/header', array('title' => 'TemplateList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}'));
?>
<div class="row">
<div class="span4">
<h2>Vorlagen</h2>
MimeType <form method="post" action="">
<?php
// This is an example to show that you can load stuff from inside the template file
echo $this->templatelib->widget("mimetype_widget", array('mimetype' => $mimetype));
?>
<button type="submit">Filter</button>
</form>
<table id="t1" class="tablesorter">
<thead>
<tr><th class='table-sortable:default'>Vorlage</th>
<th class='table-sortable:default'>Bezeichnung</th>
<th>Anmerkung</th><th>MimeType</th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($vorlage as $v): ?>
<tr><td><a href="edit/<?php echo $v->vorlage_kurzbz; ?>" target="TemplatesBottom"><?php echo $v->vorlage_kurzbz; ?></a></td>
<td><?php echo $v->bezeichnung; ?></td>
<td><?php echo $v->anmerkung; ?></td>
<td><?php echo $v->mimetype; ?></td>
<td><a href="edit/<?php echo $v->vorlage_kurzbz; ?>" target="TemplatesBottom">Edit</a></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
</div>
</body>
</html>
+7
View File
@@ -0,0 +1,7 @@
<select name="mimetype">
<?php foreach($items as $item): ?>
<option value="<?php echo $item['value']; ?>" <?php if ($item['selected']) echo 'selected'?>>
<?php echo $item['name']; ?>
</option>
<?php endforeach; ?>
</select>
+9
View File
@@ -0,0 +1,9 @@
<script type="text/javascript">
tinymce.init({
selector: "<?php echo $selector; ?>",
plugins: [<?php echo $plugins; ?>],
toolbar: "<?php echo $toolbar; ?>"
});
</script>
+28
View File
@@ -0,0 +1,28 @@
<?php
/*
* MimeType widget
*/
class mimetype_widget extends Widget
{
public function display($data)
{
if (is_null($data['mimetype']))
$data['mimetype'] = '';
$this->load->model('system/Vorlage_model');
$res = $this->Vorlage_model->getMimeTypes();
//var_dump($res);
foreach ($res->retval->result() as $obj)
{
$item = array('name' => $obj->mimetype, 'value' => $obj->mimetype);
if (isset($data['mimetype']) && $obj->mimetype == $data['mimetype'])
$item['selected'] = true;
else
$item['selected'] = false;
$data['items'][] = $item;
}
$this->view('widgets/mimetype', $data);
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
/*
* TinyMCE widget
*/
class tinymce_widget extends Widget
{
public function display($data)
{
if (! isset($data['selector']))
$data['selector'] = 'textarea';
if (! isset($data['plugins']))
$data['plugins'] = '
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"';
if (! isset($data['toolbar']))
$data['toolbar'] = 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image';
$this->view('widgets/tinymce', $data);
}
}
@@ -0,0 +1,99 @@
<?php
/**
* Squiz_Sniffs_Classes_ValidClassNameSniff.
*
* PHP version 5
*
* @category PHP
* @package PHP_CodeSniffer
* @author Greg Sherwood <gsherwood@squiz.net>
* @author Marc McIntyre <mmcintyre@squiz.net>
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
/**
* Squiz_Sniffs_Classes_ValidClassNameSniff.
*
* Ensures classes are in camel caps, and the first letter is capitalised
*
* @category PHP
* @package PHP_CodeSniffer
* @author Greg Sherwood <gsherwood@squiz.net>
* @author Marc McIntyre <mmcintyre@squiz.net>
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
* @version Release: @package_version@
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class FHComplete_Sniffs_NamingConventions_ValidClassNameSniff implements PHP_CodeSniffer_Sniff
{
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
*/
public function register()
{
return array(
T_CLASS,
T_INTERFACE,
);
}//end register()
/**
* Processes this test, when one of its tokens is encountered.
*
* @param PHP_CodeSniffer_File $phpcsFile The current file being processed.
* @param int $stackPtr The position of the current token in the
* stack passed in $tokens.
*
* @return void
*/
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
if (isset($tokens[$stackPtr]['scope_opener']) === false) {
$error = 'Possible parse error: %s missing opening or closing brace';
$data = array($tokens[$stackPtr]['content']);
$phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $data);
return;
}
// Determine the name of the class or interface. Note that we cannot
// simply look for the first T_STRING because a class name
// starting with the number will be multiple tokens.
$opener = $tokens[$stackPtr]['scope_opener'];
$nameStart = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), $opener, true);
$nameEnd = $phpcsFile->findNext(T_WHITESPACE, $nameStart, $opener);
if ($nameEnd === false) {
$name = $tokens[$nameStart]['content'];
} else {
$name = trim($phpcsFile->getTokensAsString($nameStart, ($nameEnd - $nameStart)));
}
// Check for camel caps format.
$valid = PHP_CodeSniffer::isCamelCaps($name, true, true, false);
if ($valid === false) {
$type = ucfirst($tokens[$stackPtr]['content']);
$error = '%s name "%s" is not in camel caps format';
$data = array(
$type,
$name,
);
$phpcsFile->addWarning($error, $stackPtr, 'NotCamelCaps', $data);
$phpcsFile->recordMetric($stackPtr, 'CamelCase class name', 'no');
} else {
$phpcsFile->recordMetric($stackPtr, 'CamelCase class name', 'yes');
}
}//end process()
}//end class