本文整理汇总了PHP中Toolbox类的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox类的具体用法?PHP Toolbox怎么用?PHP Toolbox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Toolbox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayTabContentForItem
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
{
echo "<form name='notificationtargets_form' id='notificationtargets_form'\n method='post' action=' ";
echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class ='tab_cadre_fixe'>";
echo '<tr><th colspan="2">' . __('Access type', 'formcreator') . '</th></tr>';
echo '<td>' . __('Access', 'formcreator') . '</td>';
echo '<td>';
Dropdown::showFromArray('access_rights', array(PluginFormcreatorForm::ACCESS_PUBLIC => __('Public access', 'formcreator'), PluginFormcreatorForm::ACCESS_PRIVATE => __('Private access', 'formcreator'), PluginFormcreatorForm::ACCESS_RESTRICTED => __('Restricted access', 'formcreator')), array('value' => isset($item->fields["access_rights"]) ? $item->fields["access_rights"] : 1));
echo '</td>';
if ($item->fields["access_rights"] == PluginFormcreatorForm::ACCESS_RESTRICTED) {
echo '<tr><th colspan="2">' . self::getTypeName(2) . '</th></tr>';
$table = getTableForItemType(__CLASS__);
$table_profile = getTableForItemType('Profile');
$query = "SELECT p.`id`, p.`name`, IF(f.`plugin_formcreator_profiles_id` IS NOT NULL, 1, 0) AS `profile`\n FROM {$table_profile} p\n LEFT JOIN {$table} f\n ON p.`id` = f.`plugin_formcreator_profiles_id`\n AND f.`plugin_formcreator_forms_id` = " . (int) $item->fields['id'];
$result = $GLOBALS['DB']->query($query);
while (list($id, $name, $profile) = $GLOBALS['DB']->fetch_array($result)) {
$checked = $profile ? ' checked' : '';
echo '<tr><td colspan="2"><label>';
echo '<input type="checkbox" name="profiles_id[]" value="' . $id . '" ' . $checked . '> ';
echo $name;
echo '</label></td></tr>';
}
}
echo '<tr>';
echo '<td class="center" colspan="2">';
echo '<input type="hidden" name="profiles_id[]" value="0" />';
echo '<input type="hidden" name="form_id" value="' . (int) $item->fields['id'] . '" />';
echo '<input type="submit" name="update" value="' . __('Save') . '" class="submit" />';
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
示例2: showForm
/**
* Show form
*
* @global type $CFG_GLPI
* @param type $ID
* @param type $options
*/
function showForm($ID = 0, $options = array())
{
global $CFG_GLPI;
echo "<div class='center first-bloc'>";
echo "<form name='field_form' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<th>" . self::getTypeName() . "</th>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td class='tab_bg_2 center'>";
echo PluginShellcommandsCommandGroup::getTypeName(1) . " ";
Dropdown::show('PluginShellcommandsCommandGroup', array('entity' => $_SESSION['glpiactive_entity'], 'width' => 200));
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td class='tab_bg_2 center'>";
$this->getEditValue();
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class='tab_bg_2 center'>";
echo "<input type='button' class='submit' onclick='shellcommand_advanced_execution(\"" . $CFG_GLPI['root_doc'] . "\",\"field_form\", \"advanced_execution_result\");' name='advanced_execution' value='" . __('Execute') . "'/>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
echo "<div class='spaced' id='advanced_execution_result'></div>";
}
示例3: showForDocumentCategory
static function showForDocumentCategory($item)
{
$documentCategory = new self();
if (!$documentCategory->getFromDBByQuery(" WHERE `documentcategories_id` = " . $item->fields['id'])) {
$documentCategory->getEmpty();
}
echo "<form name='form' method='post' action='" . Toolbox::getItemTypeFormURL($documentCategory->getType()) . "'>";
echo "<div align='center'><table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2'>" . __('Document category prefix', 'order') . "</th></tr>";
echo "<tr class='tab_bg_1'>";
// Dropdown group
echo "<td>";
echo __('Document category prefix', 'order');
echo "</td>";
echo "<td>";
echo "<input type='text' name='documentcategories_prefix' value='" . $documentCategory->fields['documentcategories_prefix'] . "'>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class='tab_bg_2 center' colspan='6'>";
echo "<input type='submit' name='update' class='submit' value='" . _sx('button', 'Save') . "' >";
echo "<input type='hidden' name='documentcategories_id' class='submit' value='" . $item->fields['id'] . "' >";
echo "</td>";
echo "</tr>";
echo "</table></div>";
Html::closeForm();
}
示例4: showForm
public function showForm($ID, $options = array())
{
if (!$this->isNewID($ID)) {
$this->check($ID, READ);
} else {
$this->check(-1, UPDATE);
}
$options['colspan'] = 2;
$options['target'] = Toolbox::getItemTypeFormURL(__CLASS__);
$this->showFormHeader($options);
echo '<table class="tab_cadre_fixe">';
echo "<tr class='line0'><td>" . __('Name') . "</td>";
echo "<td>";
Html::autocompletionTextField($this, "name");
echo "</td>";
echo "</tr>";
echo "<tr class='line1'><td>" . __('Content') . "</td>";
echo "<td>";
echo "<textarea name='comment' id ='comment' >" . $this->fields['comment'] . "</textarea>";
Html::initEditorSystem('comment');
echo "</td>";
echo "</tr>";
$this->showFormButtons($options);
return true;
}
示例5: __construct
/**
* Constructor
*
**/
function __construct()
{
global $CFG_GLPI;
$this->WordWrap = 80;
$this->CharSet = "utf-8";
// Comes from config
$this->SetLanguage("en", Config::getLibraryDir("PHPMailer") . "/language/");
if ($CFG_GLPI['smtp_mode'] != MAIL_MAIL) {
$this->Mailer = "smtp";
$this->Host = $CFG_GLPI['smtp_host'] . ':' . $CFG_GLPI['smtp_port'];
if ($CFG_GLPI['smtp_username'] != '') {
$this->SMTPAuth = true;
$this->Username = $CFG_GLPI['smtp_username'];
$this->Password = Toolbox::decrypt($CFG_GLPI['smtp_passwd'], GLPIKEY);
}
if ($CFG_GLPI['smtp_mode'] == MAIL_SMTPSSL) {
$this->SMTPSecure = "ssl";
}
if ($CFG_GLPI['smtp_mode'] == MAIL_SMTPTLS) {
$this->SMTPSecure = "tls";
}
if (!$CFG_GLPI['smtp_check_certificate']) {
$this->SMTPOptions = array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true));
}
}
if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
$this->do_debug = 3;
}
}
示例6: parseLine
/**
* CSV File parsing methods
*
* @param $fic
* @param $data
* @param $encoding (default 1)
**/
static function parseLine($fic, $data, $encoding = 1)
{
global $DB;
$csv = array();
$num = count($data);
for ($c = 0; $c < $num; $c++) {
//If field is not the last, or if field is the last of the line and is not empty
if ($c < $num - 1 || $c == $num - 1 && $data[$num - 1] != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE) {
$tmp = trim($DB->escape($data[$c]));
switch ($encoding) {
//If file is ISO8859-1 : encode the datas in utf8
case PluginDatainjectionBackend::ENCODING_ISO8859_1:
if (!Toolbox::seems_utf8($tmp)) {
$csv[0][] = utf8_encode($tmp);
} else {
$csv[0][] = $tmp;
}
break;
case PluginDatainjectionBackend::ENCODING_UFT8:
$csv[0][] = $tmp;
break;
default:
//PluginDatainjectionBackend :: ENCODING_AUTO :
$csv[0][] = PluginDatainjectionBackend::toUTF8($tmp);
}
}
}
return $csv;
}
示例7: logIfExtradebug
/**
* Log when extra-debug is activated
*/
static function logIfExtradebug($file, $message)
{
if (!PluginFusioninventoryConfig::isExtradebugActive()) {
return;
}
Toolbox::logInFile($file, $message);
}
示例8: showForGroup
static function showForGroup(Group $group)
{
global $DB;
$ID = $group->getField('id');
if (!$group->can($ID, READ)) {
return false;
}
$canedit = $group->can($ID, UPDATE);
if ($canedit) {
// Get data
$item = new self();
if (!$item->getFromDB($ID)) {
$item->getEmpty();
}
$rand = mt_rand();
echo "<form name='group_level_form{$rand}' id='group_level_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='" . self::$items_id . "' value='{$ID}' />";
echo "<div class='spaced'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th>" . __('Level attribution', 'itilcategorygroups') . "</th></tr>";
echo "<tr class='tab_bg_2'><td class='center'>";
Dropdown::showFromArray('lvl', array(NULL => "---", 1 => __('Level 1', 'itilcategorygroups'), 2 => __('Level 2', 'itilcategorygroups'), 3 => __('Level 3', 'itilcategorygroups'), 4 => __('Level 4', 'itilcategorygroups')), array('value' => $item->fields['lvl']));
echo "</td></tr>";
echo "</td><td class='center'>";
if ($item->fields["id"]) {
echo "<input type='hidden' name='id' value='" . $item->fields["id"] . "'>";
echo "<input type='submit' name='update' value=\"" . __('Save') . "\"\n class='submit'>";
} else {
echo "<input type='submit' name='add' value=\"" . __('Save') . "\" class='submit'>";
}
echo "</td></tr>";
echo "</table></div>";
Html::closeForm();
}
}
示例9: sendProlog
function sendProlog($input)
{
$input = gzcompress($input);
$fp = fsockopen($this->server_ip, 80, $errno, $errstr, 30);
if (!$fp) {
echo "{$errstr} ({$errno})\n";
} else {
$out = "POST " . $this->server_urlpath . " HTTP/1.1\r\n";
$out .= "Host: " . $this->server_ip . " \r\n";
$out .= "Content-Length: " . strlen($input) . "\r\n";
$out .= "Connection: close\r\n\r\n";
fputs($fp, $out . $input);
$zipped = "";
while (!feof($fp)) {
$line = fgets($fp, 4096);
$zipped .= $line;
if ($line == "\r\n") {
$zipped = "";
}
}
fclose($fp);
Toolbox::logInFile("RETSERV", $zipped . "\n");
if (!gzuncompress($zipped)) {
echo $zipped;
}
return gzuncompress($zipped);
}
}
示例10: testSlugify
public function testSlugify()
{
$original = 'My - string èé Ê À ß';
$expected = 'my-string-ee-e-a-sz';
$result = Toolbox::slugify($original);
$this->assertEquals($expected, $result);
}
示例11: pdfMain
static function pdfMain(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
{
global $DB;
$ID = $item->getField('id');
if (!Session::haveRight('knowbase', 'r') || !Session::haveRight('faq', 'r')) {
return false;
}
$knowbaseitemcategories_id = $item->getField('knowbaseitemcategories_id');
$fullcategoryname = Html::clean(getTreeValueCompleteName("glpi_knowbaseitemcategories", $knowbaseitemcategories_id));
$question = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('name'), ENT_QUOTES, "UTF-8")));
$answer = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('answer'), ENT_QUOTES, "UTF-8")));
$pdf->setColumnsSize(100);
if (Toolbox::strlen($fullcategoryname) > 0) {
$pdf->displayTitle('<b>' . __('Category name') . '</b>');
$pdf->displayLine($fullcategoryname);
}
if (Toolbox::strlen($question) > 0) {
$pdf->displayTitle('<b>' . __('Subject') . '</b>');
$pdf->displayText('', $question, 5);
} else {
$pdf->displayTitle('<b>' . __('No question found', 'pdf') . '</b>');
}
if (Toolbox::strlen($answer) > 0) {
$pdf->displayTitle('<b>' . __('Content') . '</b>');
$pdf->displayText('', $answer, 5);
} else {
$pdf->displayTitle('<b>' . __('No answer found') . '</b>');
}
$pdf->setColumnsSize(50, 15, 15, 10, 10);
$pdf->displayTitle(__('Writer'), __('Creation date'), __('Last update'), __('FAQ'), _n('View', 'Views', 2));
$pdf->displayLine(getUserName($item->fields["users_id"]), Html::convDateTime($item->fields["date"]), Html::convDateTime($item->fields["date_mod"]), Dropdown::getYesNo($item->fields["is_faq"]), $item->fields["view"]);
$pdf->displaySpace();
}
示例12: prepareInputForAdd
/**
* @see CommonDBTM::prepareInputForAdd()
**/
function prepareInputForAdd($input)
{
//LDAP parameters MUST be in lower case
//because the are retieved in lower case from the directory
$input["value"] = Toolbox::strtolower($input["value"]);
return $input;
}
示例13: getMenuContent
static function getMenuContent()
{
global $CFG_GLPI;
$menu = array();
$menu['title'] = self::getMenuName();
$menu['page'] = '/plugins/datainjection/front/clientinjection.form.php';
if (Session::haveRight(static::$rightname, READ)) {
$image_model = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv.png' title='";
$image_model .= PluginDatainjectionModel::getTypeName();
$image_model .= "' alt='" . PluginDatainjectionModel::getTypeName() . "'>";
$image_import = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/actualiser.png' title='";
$image_import .= __s('Injection of the file', 'datainjection');
$image_import .= "' alt='" . __s('Injection of the file', 'datainjection') . "'>";
$menu['options']['client']['title'] = self::getMenuName();
$menu['options']['client']['page'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
$menu['options']['client']['links']['search'] = '/plugins/datainjection/front/clientinjection.form.php';
if (Session::haveRight('plugin_datainjection_model', READ)) {
$menu['options']['model']['title'] = PluginDatainjectionModel::getTypeName();
$menu['options']['model']['page'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
$menu['options']['model']['links']['search'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
$menu['options']['client']['links'][$image_model] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
}
//$menu['options']['client']['links'][$image_model] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
$menu['options']['model']['links'][$image_import] = '/plugins/datainjection/front/clientinjection.form.php';
if (Session::haveRight('plugin_datainjection_model', UPDATE) || Session::haveRight('plugin_datainjection_model', CREATE)) {
$menu['options']['model']['links']['add'] = Toolbox::getItemTypeFormUrl('PluginDatainjectionModel', false);
$menu['options']['client']['links'][$image_model] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
}
}
return $menu;
}
示例14: update_password
public function update_password($password, $email)
{
$password = Toolbox::helper('Hash')->encrypt($password);
$q = "UPDATE users SET password = ? WHERE email = ?";
$r = $this->db->prepare($q);
$r->execute(array($password, $email));
}
示例15: getDatasForTemplate
function getDatasForTemplate($event, $options = array())
{
global $CFG_GLPI;
if ($event == 'AlertNotValidatedTypology') {
$this->datas['##typology.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
$this->datas['##lang.typology.entity##'] = __('Entity');
$this->datas['##typology.action##'] = __('Elements not match with the typology', 'typology');
$this->datas['##lang.typology.name##'] = PluginTypologyTypology::getTypeName(1);
$this->datas['##lang.typology.itemtype##'] = __('Type');
$this->datas['##lang.typology.items_id##'] = __('Name');
$this->datas['##lang.typology.error##'] = __('Error');
$this->datas['##lang.typology.url##'] = __('Link to the typology', 'typology');
$this->datas['##lang.typology.itemurl##'] = __('Link to the element', 'typology');
$this->datas['##lang.typology.itemuser##'] = __('User');
$this->datas['##lang.typology.itemlocation##'] = __('Location');
foreach ($options['items'] as $id => $item) {
$tmp = array();
$tmp['##typology.name##'] = $item['name'];
$itemtype = new $item['itemtype']();
$itemtype->getFromDB($item["items_id"]);
$tmp['##typology.itemtype##'] = $itemtype->getTypeName();
$tmp['##typology.items_id##'] = $itemtype->getName();
$tmp['##typology.error##'] = PluginTypologyTypology_Item::displayErrors($item['error'], false);
$tmp['##typology.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_typology_" . $item['plugin_typology_typologies_id']);
$tmp['##typology.itemurl##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=" . Toolbox::strtolower($item['itemtype']) . "_" . $item["items_id"]);
$tmp['##typology.itemuser##'] = getUserName($itemtype->fields["users_id"]);
$tmp['##typology.itemlocation##'] = Dropdown::getDropdownName("glpi_locations", $itemtype->fields['locations_id']);
$this->datas['typologyitems'][] = $tmp;
}
}
}