本文整理汇总了PHP中deserialize函数的典型用法代码示例。如果您正苦于以下问题:PHP deserialize函数的具体用法?PHP deserialize怎么用?PHP deserialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deserialize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* {@inheritdoc}
*/
public function handle(\Input $input)
{
$this->handleRunOnce();
// PATCH
if ($input->post('FORM_SUBMIT') == 'database-update') {
$count = 0;
$sql = deserialize($input->post('sql'));
if (is_array($sql)) {
foreach ($sql as $key) {
if (isset($_SESSION['sql_commands'][$key])) {
$this->Database->query(str_replace('DEFAULT CHARSET=utf8;', 'DEFAULT CHARSET=utf8 COLLATE ' . $GLOBALS['TL_CONFIG']['dbCollation'] . ';', $_SESSION['sql_commands'][$key]));
$count++;
}
}
}
$_SESSION['sql_commands'] = array();
Messages::addConfirmation(sprintf($GLOBALS['TL_LANG']['composer_client']['databaseUpdated'], $count));
$this->reload();
}
/** @var \Contao\Database\Installer $installer */
$installer = \System::importStatic('Database\\Installer');
$form = $installer->generateSqlForm();
if (empty($form)) {
Messages::addInfo($GLOBALS['TL_LANG']['composer_client']['databaseUptodate']);
$this->redirect('contao/main.php?do=composer');
}
$form = preg_replace('#(<label for="sql_\\d+")>(CREATE TABLE)#', '$1 class="create_table">$2', $form);
$form = preg_replace('#(<label for="sql_\\d+")>(ALTER TABLE `[^`]+` ADD)#', '$1 class="alter_add">$2', $form);
$form = preg_replace('#(<label for="sql_\\d+")>(ALTER TABLE `[^`]+` DROP)#', '$1 class="alter_drop">$2', $form);
$form = preg_replace('#(<label for="sql_\\d+")>(DROP TABLE)#', '$1 class="drop_table">$2', $form);
$template = new \BackendTemplate('be_composer_client_update');
$template->composer = $this->composer;
$template->form = $form;
return $template->parse();
}
示例2: compile
protected function compile()
{
$this->newsletters = deserialize($this->newsletters);
parent::compile();
// add custom newsletter subscription Checkbox to the Form
if (in_array('newsletter', $this->Config->getActiveModules())) {
// newsletter subscription
if (is_array($this->newsletters) && !empty($this->newsletters)) {
$objChannels = $this->Database->execute('SELECT * FROM tl_newsletter_channel WHERE id IN (' . implode(',', $this->newsletters) . ')');
if ($objChannels->numRows) {
$strForm = '<label for="ctrl_channels_' . $this->id . '" class="invisible">' . $this->channelsLabel . '</label>';
$strForm .= '<div id="ctrl_channels_' . $this->id . '" class="checkbox_container">';
if ($objChannels->numRows == 1) {
$strForm .= '<span><input type="checkbox" name="newsletter" id="opt_newsletter_' . $this->id . '_' . $objChannels->id . '" value="' . $objChannels->id . '" class="checkbox"><label for="opt_newsletter_' . $this->id . '_' . $objChannels->id . '">' . $objChannels->checkbox_label . '</label></span>';
} else {
while ($objChannels->next()) {
$strForm .= '<span><input type="checkbox" name="newsletter[]" id="opt_newsletter_' . $this->id . '_' . $objChannels->id . '" value="' . $objChannels->id . '" class="checkbox"><label for="opt_newsletter_' . $this->id . '_' . $objChannels->id . '">' . $objChannels->checkbox_label . '</label></span>';
}
}
$strForm .= '</div>';
}
}
$this->Template->fields .= $strForm;
}
}
示例3: generate
/**
* Display a wildcard in the back end
*
* @return string
*/
public function generate()
{
if (TL_MODE == 'BE') {
/** @var \BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['newsreader'][0]) . ' ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
return $objTemplate->parse();
}
// Set the item from the auto_item parameter
if (!isset($_GET['items']) && \Config::get('useAutoItem') && isset($_GET['auto_item'])) {
\Input::setGet('items', \Input::get('auto_item'));
}
// Do not index or cache the page if no news item has been specified
if (!\Input::get('items')) {
/** @var \PageModel $objPage */
global $objPage;
$objPage->noSearch = 1;
$objPage->cache = 0;
return '';
}
$this->news_archives = $this->sortOutProtected(deserialize($this->news_archives));
// Do not index or cache the page if there are no archives
if (!is_array($this->news_archives) || empty($this->news_archives)) {
/** @var \PageModel $objPage */
global $objPage;
$objPage->noSearch = 1;
$objPage->cache = 0;
return '';
}
return parent::generate();
}
示例4: compile
/**
* Generate the module
*/
protected function compile()
{
$this->Template->size = '';
// Set the size
if ($this->playerSize != '') {
$size = deserialize($this->playerSize);
if (is_array($size)) {
$this->Template->size = ' width="' . $size[0] . 'px" height="' . $size[1] . 'px"';
}
}
$this->Template->poster = false;
// Optional poster
if ($this->posterSRC != '') {
if (($objFile = \FilesModel::findByPk($this->posterSRC)) !== null) {
$this->Template->poster = $objFile->path;
}
}
// Pre-sort the array by preference
if (in_array($this->objFiles->extension, array('mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv'))) {
$this->Template->isVideo = true;
$arrFiles = array('mp4' => null, 'm4v' => null, 'mov' => null, 'wmv' => null, 'webm' => null, 'ogv' => null);
} else {
$this->Template->isVideo = false;
$arrFiles = array('m4a' => null, 'mp3' => null, 'wma' => null, 'mpeg' => null, 'wav' => null);
}
$this->objFiles->reset();
// Pass File objects to the template
while ($this->objFiles->next()) {
$objFile = new \File($this->objFiles->path);
$arrFiles[$objFile->extension] = $objFile;
}
$this->Template->files = array_values(array_filter($arrFiles));
$this->Template->autoplay = $this->autoplay;
}
示例5: run
/**
* Run the controller
*/
public function run()
{
$objInstalledTabControl = $this->Database->query("SELECT version FROM tl_repository_installs WHERE extension='tabcontrol' LIMIT 1");
if ($objInstalledTabControl->version <= '30000009') {
if (!$this->Database->fieldExists('tab_tabs', 'tl_content')) {
$this->Database->query("ALTER TABLE tl_content ADD tab_tabs blob NULL");
}
if (!$this->Database->fieldExists('tab_template', 'tl_content')) {
$this->Database->query("ALTER TABLE tl_content ADD tab_template varchar(64) NOT NULL default 'ce_tabcontrol_tab'");
}
if (!$this->Database->fieldExists('tab_template_start', 'tl_content')) {
$this->Database->query("ALTER TABLE tl_content ADD tab_template_start varchar(64) NOT NULL default 'ce_tabcontrol_start'");
}
if (!$this->Database->fieldExists('tab_template_stop', 'tl_content')) {
$this->Database->query("ALTER TABLE tl_content ADD tab_template_stop varchar(64) NOT NULL default 'ce_tabcontrol_stop'");
}
if (!$this->Database->fieldExists('tab_template_end', 'tl_content')) {
$this->Database->query("ALTER TABLE tl_content ADD tab_template_end varchar(64) NOT NULL default 'ce_tabcontrol_end'");
}
$objTabControl = $this->Database->query("SELECT * FROM tl_content WHERE type='tabcontrol' AND tabType='tabcontroltab'");
while ($objTabControl->next()) {
if ($this->Database->fieldExists('tabTitles', 'tl_content')) {
$arrTabs = array();
$arrTabTitles = deserialize($objTabControl->tabTitles);
foreach ($arrTabTitles as $title) {
$arrTabs[] = array('tab_tabs_name' => $title, 'tab_tabs_cookies_value' => '', 'tab_tabs_default' => '');
}
$this->Database->query("UPDATE tl_content SET tab_tabs='" . serialize($arrTabs) . "' WHERE id=" . $objTabControl->id . "");
}
}
}
}
示例6: convertSerializedValues
/**
* Multiple-fields (e.g. select or checkbox) with numberic keys are stored as CSV to improve filters.
*/
private function convertSerializedValues()
{
$t = Attribute::getTable();
$fields = array();
$attributes = Attribute::findBy(array("{$t}.multiple='1' AND {$t}.optionsSource='foreignKey'"), null);
if (null !== $attributes) {
/** @var Attribute $attribute */
foreach ($attributes as $attribute) {
if ($attribute instanceof IsotopeAttributeWithOptions) {
$fields[] = $attribute->field_name;
}
}
}
if (!empty($fields)) {
/** @var \Database\Result|object $products */
$products = $this->db->execute("\n SELECT id, " . implode(', ', $fields) . "\n FROM tl_iso_product\n WHERE " . implode(" IS NOT NULL OR ", $fields) . " IS NOT NULL\n ");
while ($products->next()) {
$set = array();
foreach ($fields as $field) {
$value = deserialize($products->{$field});
if (!empty($value) && is_array($value)) {
$set[$field] = implode(',', $value);
}
}
if (!empty($set)) {
$this->db->prepare("UPDATE tl_iso_product %s WHERE id=?")->set($set)->execute($products->id);
}
}
}
}
示例7: saveLayerRelations
/**
* Save layer relations.
*
* @param mixed $layerId The layer id values.
* @param \DataContainer $dataContainer The dataContainer driver.
*
* @return null
*/
public function saveLayerRelations($layerId, $dataContainer)
{
$new = deserialize($layerId, true);
$values = array();
$result = $this->database->prepare('SELECT * FROM tl_leaflet_map_layer WHERE mid=? order BY sorting')->execute($dataContainer->id);
while ($result->next()) {
$values[$result->lid] = $result->row();
}
$sorting = 0;
foreach ($new as $layerId) {
if (!isset($values[$layerId])) {
$this->database->prepare('INSERT INTO tl_leaflet_map_layer %s')->set(array('tstamp' => time(), 'lid' => $layerId, 'mid' => $dataContainer->id, 'sorting' => $sorting))->execute();
$sorting += 128;
} else {
if ($values[$layerId]['sorting'] <= $sorting - 128 || $values[$layerId]['sorting'] >= $sorting + 128) {
$this->database->prepare('UPDATE tl_leaflet_map_layer %s WHERE id=?')->set(array('tstamp' => time(), 'sorting' => $sorting))->execute($values[$layerId]['id']);
}
$sorting += 128;
unset($values[$layerId]);
}
}
$ids = array_map(function ($item) {
return $item['id'];
}, $values);
if ($ids) {
$this->database->query('DELETE FROM tl_leaflet_map_layer WHERE id IN(' . implode(',', $ids) . ')');
}
return null;
}
示例8: isAvailableForCollection
/**
* Returns true if the product is available
* ALMOST THE SAME AS THE PARENT, EXCEPT WE DON'T CHECK FOR PRICE
*
* @param IsotopeProductCollection|\Isotope\Model\ProductCollection $objCollection
*
* @return bool
*/
public function isAvailableForCollection(IsotopeProductCollection $objCollection)
{
if ($objCollection->isLocked()) {
return true;
}
if (BE_USER_LOGGED_IN !== true && !$this->isPublished()) {
return false;
}
// Show to guests only
if ($this->arrData['guests'] && $objCollection->member > 0 && BE_USER_LOGGED_IN !== true && !$this->arrData['protected']) {
return false;
}
// Protected product
if (BE_USER_LOGGED_IN !== true && $this->arrData['protected']) {
if ($objCollection->member == 0) {
return false;
}
$groups = deserialize($this->arrData['groups']);
$memberGroups = deserialize($objCollection->getRelated('member')->groups);
if (!is_array($groups) || empty($groups) || !is_array($memberGroups) || empty($memberGroups) || !count(array_intersect($groups, $memberGroups))) {
return false;
}
}
// Check that the product is in any page of the current site
if (count(\Isotope\Frontend::getPagesInCurrentRoot($this->getCategories(), $objCollection->getRelated('member'))) == 0) {
return false;
}
// Check if "advanced price" is available
//if (null === $this->getPrice($objCollection) && (in_array('price', $this->getAttributes()) || $this->hasVariantPrices())) {
// return false;
//}
return true;
}
示例9: __set
/**
* Add specific attributes
*
* @param string $strKey The attribute name
* @param mixed $varValue The attribute value
*/
public function __set($strKey, $varValue)
{
switch ($strKey) {
case 'mandatory':
if ($varValue) {
$this->arrAttributes['required'] = 'required';
} else {
unset($this->arrAttributes['required']);
}
parent::__set($strKey, $varValue);
break;
case 'mSize':
if ($this->multiple) {
$this->arrAttributes['size'] = $varValue;
}
break;
case 'multiple':
if ($varValue != '') {
$this->arrAttributes['multiple'] = 'multiple';
}
break;
case 'options':
$this->arrOptions = deserialize($varValue);
break;
case 'rgxp':
case 'minlength':
case 'maxlength':
// Ignore
break;
default:
parent::__set($strKey, $varValue);
break;
}
}
示例10: validate
/**
* Validate input and set value
*/
public function validate()
{
$mandatory = $this->mandatory;
$options = deserialize($this->getPost($this->strName));
// Check keys only (values can be empty)
if (is_array($options)) {
foreach ($options as $key => $option) {
// Unset empty rows
if ($option['key'] == '') {
unset($options[$key]);
continue;
}
$options[$key]['key'] = trim($option['key']);
$options[$key]['value'] = trim($option['value']);
if ($options[$key]['key'] != '') {
$this->mandatory = false;
}
}
}
$options = array_values($options);
$varInput = $this->validator($options);
if (!$this->hasErrors()) {
$this->varValue = $varInput;
}
// Reset the property
if ($mandatory) {
$this->mandatory = true;
}
}
示例11: validate
/**
* Validate input and set value
*/
public function validate()
{
$mandatory = $this->mandatory;
$options = deserialize($this->getPost($this->strName));
// Check labels only (values can be empty)
if (is_array($options)) {
foreach ($options as $key => $option) {
// Unset empty rows
if ($option['label'] == '') {
$this->addError($GLOBALS['TL_LANG']['FFL']['tl_form_field']['nlChannels']['error']['emptyDescription']);
unset($options[$key]);
continue;
}
$options[$key]['label'] = trim($option['label']);
$options[$key]['value'] = trim($option['value']);
if ($options[$key]['label'] != '') {
$this->mandatory = false;
}
}
}
$options = array_values($options);
$varInput = $this->validator($options);
if (!$this->hasErrors()) {
$this->varValue = $varInput;
}
// Reset the property
if ($mandatory) {
$this->mandatory = true;
}
}
示例12: modelSaved
/**
* {@inheritdoc}
*/
public function modelSaved($objItem)
{
// Alias already defined and no update forced, get out!
if ($objItem->get($this->getColName()) && !$this->get('force_alias')) {
return;
}
// Item is a variant but no overriding allowed, get out!
if ($objItem->isVariant() && !$this->get('isvariant')) {
return;
}
$arrAlias = '';
foreach (deserialize($this->get('alias_fields')) as $strAttribute) {
$arrValues = $objItem->parseAttribute($strAttribute['field_attribute'], 'text', null);
$arrAlias[] = $arrValues['text'];
}
$dispatcher = $this->getMetaModel()->getServiceContainer()->getEventDispatcher();
$replaceEvent = new ReplaceInsertTagsEvent(implode('-', $arrAlias));
$dispatcher->dispatch(ContaoEvents::CONTROLLER_REPLACE_INSERT_TAGS, $replaceEvent);
// Implode with '-', replace inserttags and strip HTML elements.
$strAlias = standardize(strip_tags($replaceEvent->getBuffer()));
// We need to fetch the attribute values for all attributes in the alias_fields and update the database and the
// model accordingly.
if ($this->get('isunique')) {
// Ensure uniqueness.
$strBaseAlias = $strAlias;
$arrIds = array($objItem->get('id'));
$intCount = 2;
while (array_diff($this->searchFor($strAlias), $arrIds)) {
$strAlias = $strBaseAlias . '-' . $intCount++;
}
}
$this->setDataFor(array($objItem->get('id') => $strAlias));
$objItem->set($this->getColName(), $strAlias);
}
示例13: generate
/**
* Return if there are no files
* @return string
*/
public function generate()
{
// Use the home directory of the current user as file source
if ($this->useHomeDir && FE_USER_LOGGED_IN) {
$this->import('FrontendUser', 'User');
if ($this->User->assignDir && is_dir(TL_ROOT . '/' . $this->User->homeDir)) {
$this->multiSRC = array($this->User->homeDir);
}
} else {
$this->multiSRC = deserialize($this->multiSRC);
}
// Return if there are no files
if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
return '';
}
// Check for version 3 format
if (!is_numeric($this->multiSRC[0])) {
return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
// Get the file entries from the database
$this->objFiles = \FilesModel::findMultipleByIds($this->multiSRC);
if ($this->objFiles === null) {
return '';
}
return parent::generate();
}
示例14: modelSaved
/**
* {@inheritdoc}
*/
public function modelSaved($objItem)
{
// combined values already defined and no update forced, get out!
if ($objItem->get($this->getColName()) && !$this->get('force_combinedvalues')) {
return;
}
$arrCombinedValues = array();
foreach (deserialize($this->get('combinedvalues_fields')) as $strAttribute) {
if ($this->isMetaField($strAttribute['field_attribute'])) {
$strField = $strAttribute['field_attribute'];
$arrCombinedValues[] = $objItem->get($strField);
} else {
$arrValues = $objItem->parseAttribute($strAttribute['field_attribute'], 'text', null);
$arrCombinedValues[] = $arrValues['text'];
}
}
$strCombinedValues = vsprintf($this->get('combinedvalues_format'), $arrCombinedValues);
$strCombinedValues = trim($strCombinedValues);
// we need to fetch the attribute values for all attribs in the combinedvalues_fields and update the database
// and the model accordingly.
if ($this->get('isunique')) {
// ensure uniqueness.
$strLanguage = $this->getMetaModel()->getActiveLanguage();
$strBaseCombinedValues = $strCombinedValues;
$arrIds = array($objItem->get('id'));
$intCount = 2;
while (array_diff($this->searchForInLanguages($strCombinedValues, array($strLanguage)), $arrIds)) {
$intCount++;
$strCombinedValues = $strBaseCombinedValues . ' (' . $intCount . ')';
}
}
$arrData = $this->widgetToValue($strCombinedValues, $objItem->get('id'));
$this->setTranslatedDataFor(array($objItem->get('id') => $arrData), $this->getMetaModel()->getActiveLanguage());
$objItem->set($this->getColName(), $arrData);
}
示例15: disableOldClientHook
public function disableOldClientHook()
{
// disable the repo client
$reset = false;
$activeModules = $this->Config->getActiveModules();
$inactiveModules = deserialize($GLOBALS['TL_CONFIG']['inactiveModules']);
if (in_array('rep_base', $activeModules)) {
$inactiveModules[] = 'rep_base';
$reset = true;
}
if (in_array('rep_client', $activeModules)) {
$inactiveModules[] = 'rep_client';
$reset = true;
}
if (in_array('repository', $activeModules)) {
$inactiveModules[] = 'repository';
$skipFile = new \File('system/modules/repository/.skip');
$skipFile->write('Remove this file to enable the module');
$skipFile->close();
$reset = true;
}
if ($reset) {
$this->Config->update("\$GLOBALS['TL_CONFIG']['inactiveModules']", serialize($inactiveModules));
$this->reload();
}
unset($GLOBALS['TL_HOOK']['loadLanguageFiles']['composer']);
}