当前位置: 首页>>代码示例>>PHP>>正文


PHP Versions::initialize方法代码示例

本文整理汇总了PHP中Versions::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Versions::initialize方法的具体用法?PHP Versions::initialize怎么用?PHP Versions::initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Versions的用法示例。


在下文中一共展示了Versions::initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: toggleVisibility

 /**
  * Disable/enable a user group
  * @param integer
  * @param boolean
  * @param \DataContainer
  */
 public function toggleVisibility($intId, $blnVisible, DataContainer $dc = null)
 {
     // Check permissions to edit
     Input::setGet('id', $intId);
     Input::setGet('act', 'toggle');
     $this->checkPermission();
     // Check permissions to publish
     if (!$this->User->hasAccess('tl_product_price::published', 'alexf')) {
         $this->log('Not enough permissions to publish/unpublish price item ID "' . $intId . '"', __METHOD__, TL_ERROR);
         $this->redirect('contao/main.php?act=error');
     }
     $objVersions = new Versions('tl_product_price', $intId);
     $objVersions->initialize();
     // Trigger the save_callback
     if (is_array($GLOBALS['TL_DCA']['tl_product_price']['fields']['published']['save_callback'])) {
         foreach ($GLOBALS['TL_DCA']['tl_product_price']['fields']['published']['save_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $blnVisible = $this->{$callback}[0]->{$callback}[1]($blnVisible, $dc ?: $this);
             } elseif (is_callable($callback)) {
                 $blnVisible = $callback($blnVisible, $dc ?: $this);
             }
         }
     }
     // Update the database
     $this->Database->prepare("UPDATE tl_product_price SET tstamp=" . time() . ", published='" . ($blnVisible ? 1 : '') . "' WHERE id=?")->execute($intId);
     $objVersions->create();
     $this->log('A new version of record "tl_product_price.id=' . $intId . '" has been created' . $this->getParentEntries('tl_product_price', $intId), __METHOD__, TL_GENERAL);
 }
开发者ID:respinar,项目名称:contao-product,代码行数:35,代码来源:tl_product_price.php

示例2: toggleVisibility

 /**
  * Disable/enable a user group
  * @param integer
  * @param boolean
  */
 public function toggleVisibility($intId, $blnVisible)
 {
     // Check permissions to edit
     $objInput = \Input::getInstance();
     $objInput->setGet('id', $intId);
     $objInput->setGet('act', 'toggle');
     #$this->checkPermission();
     // Check permissions to publish
     if (!$this->User->isAdmin && !$this->User->hasAccess('tl_glossary_term::published', 'alexf')) {
         $this->log('Not enough permissions to publish/unpublish item ID "' . $intId . '"', 'tl_glossary_term toggleVisibility', TL_ERROR);
         $this->redirect('contao/main.php?act=error');
     }
     $objVersions = new \Versions('tl_glossary_term', $intId);
     $objVersions->initialize();
     // Trigger the save_callback
     if (is_array($GLOBALS['TL_DCA']['tl_glossary_term']['fields']['published']['save_callback'])) {
         foreach ($GLOBALS['TL_DCA']['tl_glossary_term']['fields']['published']['save_callback'] as $callback) {
             $this->import($callback[0]);
             $blnVisible = $this->{$callback}[0]->{$callback}[1]($blnVisible, $this);
         }
     }
     // Update the database
     \Database::getInstance()->prepare("UPDATE tl_glossary_term SET tstamp=" . time() . ", published='" . ($blnVisible ? 1 : '') . "' WHERE id=?")->execute($intId);
     $objVersions->create();
     $this->log('A new version of record "tl_glossary_term.id=' . $intId . '" has been created', 'tl_revolutionslider_slides toggleVisibility()', TL_GENERAL);
 }
开发者ID:w3scout,项目名称:glossary_revisited,代码行数:31,代码来源:TableGlossaryTerm.php

示例3: executePostActions

 /**
  * Execute AJAX post actions to toggle.
  *
  * @param string         $action
  * @param \DataContainer $dc
  */
 public function executePostActions($action, \DataContainer $dc)
 {
     if ($action !== 'hasteAjaxOperation') {
         return;
     }
     $id = $dc->id = \Input::post('id');
     $currentValue = \Input::post('value');
     $operation = \Input::post('operation');
     $hasteAjaxOperationSettings = $GLOBALS['TL_DCA'][$dc->table]['list']['operations'][$operation]['haste_ajax_operation'];
     if (!isset($hasteAjaxOperationSettings)) {
         return;
     }
     // Check permissions
     if (!$this->checkPermission($dc->table, $hasteAjaxOperationSettings)) {
         \System::log(sprintf('Not enough permissions to toggle field %s::%s', $dc->table, $hasteAjaxOperationSettings['field']), __METHOD__, TL_ERROR);
         \Controller::redirect('contao/main.php?act=error');
     }
     // Initialize versioning
     $versions = new \Versions($dc->table, $id);
     $versions->initialize();
     // Determine next value and icon
     $options = $this->getOptions($hasteAjaxOperationSettings);
     $nextIndex = 0;
     foreach ($options as $k => $option) {
         if ($option['value'] == $currentValue) {
             $nextIndex = $k + 1;
         }
     }
     // Make sure that if $nextIndex does not exist it's the first
     if (!isset($options[$nextIndex])) {
         $nextIndex = 0;
     }
     $value = $options[$nextIndex]['value'];
     $value = $this->executeSaveCallback($dc, $value, $hasteAjaxOperationSettings);
     // Update DB
     \Database::getInstance()->prepare('UPDATE ' . $dc->table . ' SET ' . $hasteAjaxOperationSettings['field'] . '=? WHERE id=?')->execute($value, $id);
     $versions->create();
     if ($GLOBALS['TL_DCA'][$dc->table]['config']['enableVersioning']) {
         \System::log(sprintf('A new version of record "%s.id=%s" has been created', $dc->table, $id), __METHOD__, TL_GENERAL);
     }
     $response = array('nextValue' => $options[$nextIndex]['value'], 'nextIcon' => $options[$nextIndex]['icon']);
     $response = new JsonResponse($response);
     $response->send();
 }
开发者ID:codefog,项目名称:contao-haste,代码行数:50,代码来源:AjaxOperations.php

示例4: toggleVisibility

 /**
  * Publish/unpublish rule
  * @param integer
  * @param boolean
  * @param \DataContainer
  */
 public function toggleVisibility($intId, $blnVisible, \DataContainer $dc = null)
 {
     $objVersions = new \Versions('tl_css_class_replacer', $intId);
     $objVersions->initialize();
     // Trigger the save_callback
     if (is_array($GLOBALS['TL_DCA']['tl_css_class_replacer']['fields']['published']['save_callback'])) {
         foreach ($GLOBALS['TL_DCA']['tl_css_class_replacer']['fields']['published']['save_callback'] as $callback) {
             if (is_array($callback)) {
                 $blnVisible = \System::importStatic($callback[0])->{$callback}[1]($blnVisible, $dc ?: $this);
             } elseif (is_callable($callback)) {
                 $blnVisible = $callback($blnVisible, $dc ?: $this);
             }
         }
     }
     // Update the database
     \Database::getInstance()->prepare("UPDATE tl_css_class_replacer SET tstamp=" . time() . ", published='" . ($blnVisible ? 1 : '') . "' WHERE id=?")->execute($intId);
     $objVersions->create();
     \System::log('A new version of record "tl_css_class_replacer.id=' . $intId . '" has been created', __METHOD__, TL_GENERAL);
 }
开发者ID:toflar,项目名称:contao-css-class-replacer,代码行数:25,代码来源:BackendHelper.php

示例5: toggleVisibility

 public function toggleVisibility($intId, $blnVisible)
 {
     $objUser = \BackendUser::getInstance();
     $objDatabase = \Database::getInstance();
     // Check permissions to publish
     if (!$objUser->isAdmin && !$objUser->hasAccess('tl_entity_cleaner::published', 'alexf')) {
         \Controller::log('Not enough permissions to publish/unpublish item ID "' . $intId . '"', 'tl_entity_cleaner toggleVisibility', TL_ERROR);
         \Controller::redirect('contao/main.php?act=error');
     }
     $objVersions = new Versions('tl_entity_cleaner', $intId);
     $objVersions->initialize();
     // Trigger the save_callback
     if (is_array($GLOBALS['TL_DCA']['tl_entity_cleaner']['fields']['published']['save_callback'])) {
         foreach ($GLOBALS['TL_DCA']['tl_entity_cleaner']['fields']['published']['save_callback'] as $callback) {
             $this->import($callback[0]);
             $blnVisible = $this->{$callback}[0]->{$callback}[1]($blnVisible, $this);
         }
     }
     // Update the database
     $objDatabase->prepare("UPDATE tl_entity_cleaner SET tstamp=" . time() . ", published='" . ($blnVisible ? 1 : '') . "' WHERE id=?")->execute($intId);
     $objVersions->create();
     \Controller::log('A new version of record "tl_entity_cleaner.id=' . $intId . '" has been created' . $this->getParentEntries('tl_entity_cleaner', $intId), 'tl_entity_cleaner toggleVisibility()', TL_GENERAL);
 }
开发者ID:heimrichhannot,项目名称:contao-entity_cleaner,代码行数:23,代码来源:tl_entity_cleaner.php

示例6: toggleVisibility

 /**
  * Disable/enable a user group
  *
  * @param integer       $intId
  * @param boolean       $blnVisible
  * @param DataContainer $dc
  *
  * @throws Contao\CoreBundle\Exception\AccessDeniedException
  */
 public function toggleVisibility($intId, $blnVisible, DataContainer $dc = null)
 {
     // Set the ID and action
     Input::setGet('id', $intId);
     Input::setGet('act', 'toggle');
     if ($dc) {
         $dc->id = $intId;
         // see #8043
     }
     $this->checkPermission();
     // Check the field access
     if (!$this->User->hasAccess('tl_faq::published', 'alexf')) {
         throw new Contao\CoreBundle\Exception\AccessDeniedException('Not enough permissions to publish/unpublish FAQ ID ' . $intId . '.');
     }
     $objVersions = new Versions('tl_faq', $intId);
     $objVersions->initialize();
     // Trigger the save_callback
     if (is_array($GLOBALS['TL_DCA']['tl_faq']['fields']['published']['save_callback'])) {
         foreach ($GLOBALS['TL_DCA']['tl_faq']['fields']['published']['save_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $blnVisible = $this->{$callback[0]}->{$callback[1]}($blnVisible, $dc ?: $this);
             } elseif (is_callable($callback)) {
                 $blnVisible = $callback($blnVisible, $dc ?: $this);
             }
         }
     }
     // Update the database
     $this->Database->prepare("UPDATE tl_faq SET tstamp=" . time() . ", published='" . ($blnVisible ? '1' : '') . "' WHERE id=?")->execute($intId);
     $objVersions->create();
 }
开发者ID:contao,项目名称:faq-bundle,代码行数:40,代码来源:tl_faq.php

示例7: toggleVisibility

 /**
  * Disable/enable a user group
  *
  * @param integer       $intId
  * @param boolean       $blnVisible
  * @param DataContainer $dc
  */
 public function toggleVisibility($intId, $blnVisible, DataContainer $dc = null)
 {
     // Set the ID and action
     Input::setGet('id', $intId);
     Input::setGet('act', 'toggle');
     if ($dc) {
         $dc->id = $intId;
         // see #8043
     }
     $this->checkPermission();
     // Check the field access
     if (!$this->User->hasAccess('tl_comments::published', 'alexf')) {
         $this->log('Not enough permissions to publish/unpublish comment ID "' . $intId . '"', __METHOD__, TL_ERROR);
         $this->redirect('contao/main.php?act=error');
     }
     $objVersions = new Versions('tl_comments', $intId);
     $objVersions->initialize();
     // Trigger the save_callback
     if (is_array($GLOBALS['TL_DCA']['tl_comments']['fields']['published']['save_callback'])) {
         foreach ($GLOBALS['TL_DCA']['tl_comments']['fields']['published']['save_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $blnVisible = $this->{$callback[0]}->{$callback[1]}($blnVisible, $dc ?: $this);
             } elseif (is_callable($callback)) {
                 $blnVisible = $callback($blnVisible, $dc ?: $this);
             }
         }
     }
     // Update the database
     $this->Database->prepare("UPDATE tl_comments SET tstamp=" . time() . ", published='" . ($blnVisible ? '1' : '') . "' WHERE id=?")->execute($intId);
     $objVersions->create();
 }
开发者ID:eknoes,项目名称:core,代码行数:39,代码来源:tl_comments.php

示例8: toggleVisibility

 /**
  * Disable/enable a user group
  *
  * @param integer        $intId
  * @param boolean        $blnVisible
  * @param DataContainer $dc
  */
 public function toggleVisibility($intId, $blnVisible, DataContainer $dc = null)
 {
     // Set the ID and action
     Input::setGet('id', $intId);
     Input::setGet('act', 'toggle');
     if ($dc) {
         $dc->id = $intId;
         // see #8043
     }
     $this->checkPermission();
     // Check the field access
     if (!$this->User->hasAccess('tl_calendar_events::published', 'alexf')) {
         $this->log('Not enough permissions to publish/unpublish event ID "' . $intId . '"', __METHOD__, TL_ERROR);
         $this->redirect('contao/main.php?act=error');
     }
     $objVersions = new Versions('tl_calendar_events', $intId);
     $objVersions->initialize();
     // Trigger the save_callback
     if (is_array($GLOBALS['TL_DCA']['tl_calendar_events']['fields']['published']['save_callback'])) {
         foreach ($GLOBALS['TL_DCA']['tl_calendar_events']['fields']['published']['save_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $blnVisible = $this->{$callback[0]}->{$callback[1]}($blnVisible, $dc ?: $this);
             } elseif (is_callable($callback)) {
                 $blnVisible = $callback($blnVisible, $dc ?: $this);
             }
         }
     }
     // Update the database
     $this->Database->prepare("UPDATE tl_calendar_events SET tstamp=" . time() . ", published='" . ($blnVisible ? '1' : '') . "' WHERE id=?")->execute($intId);
     $objVersions->create();
     $this->log('A new version of record "tl_calendar_events.id=' . $intId . '" has been created' . $this->getParentEntries('tl_calendar_events', $intId), __METHOD__, TL_GENERAL);
     // Update the RSS feed (for some reason it does not work without sleep(1))
     sleep(1);
     $this->import('Calendar');
     $this->Calendar->generateFeedsByCalendar(CURRENT_ID);
 }
开发者ID:bytehead,项目名称:contao-core,代码行数:44,代码来源:tl_calendar_events.php

示例9: toggleVisibility

 /**
  * Disable/enable a user group
  *
  * @param integer       $intId
  * @param boolean       $blnVisible
  * @param DataContainer $dc
  *
  * @throws Contao\CoreBundle\Exception\AccessDeniedException
  */
 public function toggleVisibility($intId, $blnVisible, DataContainer $dc = null)
 {
     // Set the ID and action
     Input::setGet('id', $intId);
     Input::setGet('act', 'toggle');
     if ($dc) {
         $dc->id = $intId;
         // see #8043
     }
     // Check the field access
     if (!$this->User->hasAccess('tl_member_group::disable', 'alexf')) {
         throw new Contao\CoreBundle\Exception\AccessDeniedException('Not enough permissions to activate/deactivate member group ID ' . $intId . '.');
     }
     $objVersions = new Versions('tl_member_group', $intId);
     $objVersions->initialize();
     // Trigger the save_callback
     if (is_array($GLOBALS['TL_DCA']['tl_member_group']['fields']['disable']['save_callback'])) {
         foreach ($GLOBALS['TL_DCA']['tl_member_group']['fields']['disable']['save_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $blnVisible = $this->{$callback[0]}->{$callback[1]}($blnVisible, $dc ?: $this);
             } elseif (is_callable($callback)) {
                 $blnVisible = $callback($blnVisible, $dc ?: $this);
             }
         }
     }
     // Update the database
     $this->Database->prepare("UPDATE tl_member_group SET tstamp=" . time() . ", disable='" . ($blnVisible ? '' : 1) . "' WHERE id=?")->execute($intId);
     $objVersions->create();
     $this->log('A new version of record "tl_member_group.id=' . $intId . '" has been created' . $this->getParentEntries('tl_member_group', $intId), __METHOD__, TL_GENERAL);
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:40,代码来源:tl_member_group.php

示例10: toggleVisibility

 /**
  * Toggle the visibility of a format definition
  *
  * @param integer       $intId
  * @param boolean       $blnVisible
  * @param DataContainer $dc
  */
 public function toggleVisibility($intId, $blnVisible, DataContainer $dc = null)
 {
     // Set the ID and action
     Input::setGet('id', $intId);
     Input::setGet('act', 'toggle');
     if ($dc) {
         $dc->id = $intId;
         // see #8043
     }
     $this->checkPermission();
     $objVersions = new Versions('tl_style', $intId);
     $objVersions->initialize();
     // Trigger the save_callback
     if (is_array($GLOBALS['TL_DCA']['tl_style']['fields']['invisible']['save_callback'])) {
         foreach ($GLOBALS['TL_DCA']['tl_style']['fields']['invisible']['save_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $blnVisible = $this->{$callback[0]}->{$callback[1]}($blnVisible, $dc ?: $this);
             } elseif (is_callable($callback)) {
                 $blnVisible = $callback($blnVisible, $dc ?: $this);
             }
         }
     }
     // Update the database
     $this->Database->prepare("UPDATE tl_style SET tstamp=" . time() . ", invisible='" . ($blnVisible ? '' : 1) . "' WHERE id=?")->execute($intId);
     $objVersions->create();
     $this->log('A new version of record "tl_style.id=' . $intId . '" has been created' . $this->getParentEntries('tl_style', $intId), __METHOD__, TL_GENERAL);
     // Recreate the style sheet
     $objStylesheet = $this->Database->prepare("SELECT pid FROM tl_style WHERE id=?")->limit(1)->execute($intId);
     if ($objStylesheet->numRows) {
         $this->import('StyleSheets');
         $this->StyleSheets->updateStyleSheet($objStylesheet->pid);
     }
 }
开发者ID:StephenGWills,项目名称:sample-contao-app,代码行数:41,代码来源:tl_style.php

示例11: createNewUser

 /**
  * Create a new user and redirect
  *
  * @param array $arrData
  */
 protected function createNewUser($arrData)
 {
     $arrData['tstamp'] = time();
     $arrData['login'] = $this->reg_allowLogin;
     $arrData['activation'] = md5(uniqid(mt_rand(), true));
     $arrData['dateAdded'] = $arrData['tstamp'];
     // Set default groups
     if (!array_key_exists('groups', $arrData)) {
         $arrData['groups'] = $this->reg_groups;
     }
     // Disable account
     $arrData['disable'] = 1;
     // Send activation e-mail
     if ($this->reg_activate) {
         // Prepare the simple token data
         $arrTokenData = $arrData;
         $arrTokenData['domain'] = \Idna::decode(\Environment::get('host'));
         $arrTokenData['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . (\Config::get('disableAlias') || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $arrData['activation'];
         $arrTokenData['channels'] = '';
         if (in_array('newsletter', \ModuleLoader::getActive())) {
             // Make sure newsletter is an array
             if (!is_array($arrData['newsletter'])) {
                 if ($arrData['newsletter'] != '') {
                     $arrData['newsletter'] = array($arrData['newsletter']);
                 } else {
                     $arrData['newsletter'] = array();
                 }
             }
             // Replace the wildcard
             if (!empty($arrData['newsletter'])) {
                 $objChannels = \NewsletterChannelModel::findByIds($arrData['newsletter']);
                 if ($objChannels !== null) {
                     $arrTokenData['channels'] = implode("\n", $objChannels->fetchEach('title'));
                 }
             }
         }
         // Backwards compatibility
         $arrTokenData['channel'] = $arrTokenData['channels'];
         $objEmail = new \Email();
         $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
         $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
         $objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['emailSubject'], \Idna::decode(\Environment::get('host')));
         $objEmail->text = \String::parseSimpleTokens($this->reg_text, $arrTokenData);
         $objEmail->sendTo($arrData['email']);
     }
     // Make sure newsletter is an array
     if (isset($arrData['newsletter']) && !is_array($arrData['newsletter'])) {
         $arrData['newsletter'] = array($arrData['newsletter']);
     }
     // Create the user
     $objNewUser = new \MemberModel();
     $objNewUser->setRow($arrData);
     $objNewUser->save();
     // Assign home directory
     if ($this->reg_assignDir) {
         $objHomeDir = \FilesModel::findByUuid($this->reg_homeDir);
         if ($objHomeDir !== null) {
             $this->import('Files');
             $strUserDir = standardize($arrData['username']) ?: 'user_' . $objNewUser->id;
             // Add the user ID if the directory exists
             while (is_dir(TL_ROOT . '/' . $objHomeDir->path . '/' . $strUserDir)) {
                 $strUserDir .= '_' . $objNewUser->id;
             }
             // Create the user folder
             new \Folder($objHomeDir->path . '/' . $strUserDir);
             $objUserDir = \FilesModel::findByPath($objHomeDir->path . '/' . $strUserDir);
             // Save the folder ID
             $objNewUser->assignDir = 1;
             $objNewUser->homeDir = $objUserDir->uuid;
             $objNewUser->save();
         }
     }
     // HOOK: send insert ID and user data
     if (isset($GLOBALS['TL_HOOKS']['createNewUser']) && is_array($GLOBALS['TL_HOOKS']['createNewUser'])) {
         foreach ($GLOBALS['TL_HOOKS']['createNewUser'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($objNewUser->id, $arrData, $this);
         }
     }
     // Create the initial version (see #7816)
     $objVersions = new \Versions('tl_member', $objNewUser->id);
     $objVersions->setUsername($objNewUser->username);
     $objVersions->setUserId(0);
     $objVersions->setEditUrl('contao/main.php?do=member&act=edit&id=%s&rt=1');
     $objVersions->initialize();
     // Inform admin if no activation link is sent
     if (!$this->reg_activate) {
         $this->sendAdminNotification($objNewUser->id, $arrData);
     }
     // Check whether there is a jumpTo page
     if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) {
         $this->jumpToOrReload($objJumpTo->row());
     }
     $this->reload();
 }
开发者ID:juergen83,项目名称:contao,代码行数:100,代码来源:ModuleRegistration.php

示例12: toggleVisibility

 /**
  * Disable/enable
  * @param integer
  * @param boolean
  */
 public function toggleVisibility($intId, $blnVisible)
 {
     // Check permissions to edit
     Input::setGet('id', $intId);
     Input::setGet('act', 'toggle');
     $objVersions = new Versions('tl_webfonts', $intId);
     $objVersions->initialize();
     // Trigger the save_callback
     if (is_array($GLOBALS['TL_DCA']['tl_webfonts']['fields']['published']['save_callback'])) {
         foreach ($GLOBALS['TL_DCA']['tl_webfonts']['fields']['published']['save_callback'] as $callback) {
             $this->import($callback[0]);
             $blnVisible = $this->{$callback}[0]->{$callback}[1]($blnVisible, $this);
         }
     }
     // Update the database
     $this->Database->prepare("UPDATE tl_webfonts SET tstamp=" . time() . ", published='" . ($blnVisible ? 1 : '') . "' WHERE id=?")->execute($intId);
     $objVersions->create();
     $this->log('A new version of record "tl_tiles.id=' . $intId . '" has been created' . $this->getParentEntries('tl_webfonts', $intId), 'tl_webfonts toggleVisibility()', TL_GENERAL);
 }
开发者ID:yfridelance,项目名称:contao-webfonts,代码行数:24,代码来源:tl_webfonts.php

示例13: edit

    /**
     * Auto-generate a form to edit the current database record
     * @param integer
     * @param integer
     * @return string
     */
    public function edit($intID = false, $ajaxId = false)
    {
        if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notEditable']) {
            \System::log('Table ' . $this->strTable . ' is not editable', __METHOD__, TL_ERROR);
            \Controller::redirect('contao/main.php?act=error');
        }
        if ($intID) {
            $this->intId = $intID;
        }
        // Get the current record
        $objRow = \Database::getInstance()->prepare("SELECT * FROM {$this->strTable} WHERE id=?")->limit(1)->execute($this->intId);
        // Redirect if there is no record with the given ID
        if ($objRow->numRows < 1) {
            \System::log('Could not load record "' . $this->strTable . '.id=' . $this->intId . '"', __METHOD__, TL_ERROR);
            \Controller::redirect('contao/main.php?act=error');
        } elseif ($objRow->language != '') {
            \System::log('Cannot edit language record "' . $this->strTable . '.id=' . $this->intId . '"', __METHOD__, TL_ERROR);
            \Controller::redirect('contao/main.php?act=error');
        }
        $this->objActiveRecord = $objRow;
        $return = '';
        $this->values[] = $this->intId;
        $this->procedure[] = 'id=?';
        $this->blnCreateNewVersion = false;
        $objVersions = new \Versions($this->strTable, $this->intId);
        // Compare versions
        if (\Input::get('versions')) {
            $objVersions->compare();
        }
        // Restore a version
        if (\Input::post('FORM_SUBMIT') == 'tl_version' && \Input::post('version') != '') {
            $objVersions->restore(\Input::post('version'));
            $this->reload();
        }
        $objVersions->initialize();
        // Load and/or change language
        $this->blnEditLanguage = false;
        if (!empty($this->arrTranslations)) {
            $blnLanguageUpdated = false;
            $session = $this->Session->getData();
            if (\Input::post('FORM_SUBMIT') == 'tl_language') {
                if (in_array(\Input::post('language'), $this->arrTranslations)) {
                    $session['language'][$this->strTable][$this->intId] = \Input::post('language');
                } else {
                    unset($session['language'][$this->strTable][$this->intId]);
                }
                $blnLanguageUpdated = true;
            } elseif (\Input::post('FORM_SUBMIT') == $this->strTable && isset($_POST['deleteLanguage'])) {
                $this->Database->prepare("DELETE FROM {$this->strTable} WHERE pid=? AND language=?")->execute($this->intId, $session['language'][$this->strTable][$this->intId]);
                unset($session['language'][$this->strTable][$this->intId]);
                $blnLanguageUpdated = true;
            }
            if ($blnLanguageUpdated) {
                $this->Session->setData($session);
                $_SESSION['TL_INFO'] = '';
                \Controller::reload();
            }
            if ($_SESSION['BE_DATA']['language'][$this->strTable][$this->intId] != '' && in_array($_SESSION['BE_DATA']['language'][$this->strTable][$this->intId], $this->arrTranslations)) {
                $objRow = $this->Database->prepare("SELECT * FROM {$this->strTable} WHERE pid=? AND language=?")->execute($this->intId, $_SESSION['BE_DATA']['language'][$this->strTable][$this->intId]);
                if (!$objRow->numRows) {
                    $intId = $this->Database->prepare("INSERT INTO {$this->strTable} (pid,tstamp,language) VALUES (?,?,?)")->execute($this->intId, time(), $_SESSION['BE_DATA']['language'][$this->strTable][$this->intId])->insertId;
                    $objRow = $this->Database->prepare("SELECT * FROM {$this->strTable} WHERE id=?")->execute($intId);
                }
                $this->objActiveRecord = $objRow;
                $this->values = array($this->intId, $_SESSION['BE_DATA']['language'][$this->strTable][$this->intId]);
                $this->procedure = array('pid=?', 'language=?');
                $this->blnEditLanguage = true;
            }
        }
        // Build an array from boxes and rows
        $this->strPalette = $this->getPalette();
        $boxes = trimsplit(';', $this->strPalette);
        $legends = array();
        if (!empty($boxes)) {
            foreach ($boxes as $k => $v) {
                $eCount = 1;
                $boxes[$k] = trimsplit(',', $v);
                foreach ($boxes[$k] as $kk => $vv) {
                    if (preg_match('/^\\[.*\\]$/i', $vv)) {
                        ++$eCount;
                        continue;
                    }
                    if (preg_match('/^\\{.*\\}$/', $vv)) {
                        $legends[$k] = substr($vv, 1, -1);
                        unset($boxes[$k][$kk]);
                    } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$vv]['exclude'] || !is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$vv])) {
                        unset($boxes[$k][$kk]);
                    } elseif ($this->blnEditLanguage && !$GLOBALS['TL_DCA'][$this->strTable]['fields'][$vv]['attributes']['multilingual']) {
                        unset($boxes[$k][$kk]);
                    }
                }
                // Unset a box if it does not contain any fields
                if (count($boxes[$k]) < $eCount) {
                    unset($boxes[$k]);
//.........这里部分代码省略.........
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:101,代码来源:DC_ProductData.php

示例14: setNewPassword

 /**
  * Set the new password
  */
 protected function setNewPassword()
 {
     $objMember = \MemberModel::findOneByActivation(\Input::get('token'));
     if ($objMember === null || $objMember->login == '') {
         $this->strTemplate = 'mod_message';
         /** @var \FrontendTemplate|object $objTemplate */
         $objTemplate = new \FrontendTemplate($this->strTemplate);
         $this->Template = $objTemplate;
         $this->Template->type = 'error';
         $this->Template->message = $GLOBALS['TL_LANG']['MSC']['accountError'];
         return;
     }
     $strTable = $objMember->getTable();
     // Initialize the versioning (see #8301)
     $objVersions = new \Versions($strTable, $objMember->id);
     $objVersions->setUsername($objMember->username);
     $objVersions->setUserId(0);
     $objVersions->setEditUrl('contao/main.php?do=member&act=edit&id=%s&rt=1');
     $objVersions->initialize();
     // Define the form field
     $arrField = $GLOBALS['TL_DCA']['tl_member']['fields']['password'];
     $arrField['eval']['tableless'] = $this->tableless;
     /** @var \Widget $strClass */
     $strClass = $GLOBALS['TL_FFL']['password'];
     // Fallback to default if the class is not defined
     if (!class_exists($strClass)) {
         $strClass = 'FormPassword';
     }
     /** @var \Widget $objWidget */
     $objWidget = new $strClass($strClass::getAttributesFromDca($arrField, 'password'));
     // Set row classes
     $objWidget->rowClass = 'row_0 row_first even';
     $objWidget->rowClassConfirm = 'row_1 odd';
     $this->Template->rowLast = 'row_2 row_last even';
     // Validate the field
     if (strlen(\Input::post('FORM_SUBMIT')) && \Input::post('FORM_SUBMIT') == $this->Session->get('setPasswordToken')) {
         $objWidget->validate();
         // Set the new password and redirect
         if (!$objWidget->hasErrors()) {
             $this->Session->set('setPasswordToken', '');
             $objMember->tstamp = time();
             $objMember->activation = '';
             $objMember->password = $objWidget->value;
             $objMember->save();
             // Create a new version
             if ($GLOBALS['TL_DCA'][$strTable]['config']['enableVersioning']) {
                 $objVersions->create();
             }
             // HOOK: set new password callback
             if (isset($GLOBALS['TL_HOOKS']['setNewPassword']) && is_array($GLOBALS['TL_HOOKS']['setNewPassword'])) {
                 foreach ($GLOBALS['TL_HOOKS']['setNewPassword'] as $callback) {
                     $this->import($callback[0]);
                     $this->{$callback[0]}->{$callback[1]}($objMember, $objWidget->value, $this);
                 }
             }
             // Redirect to the jumpTo page
             if (($objTarget = $this->objModel->getRelated('reg_jumpTo')) !== null) {
                 /** @var \PageModel $objTarget */
                 $this->redirect($objTarget->getFrontendUrl());
             }
             // Confirm
             $this->strTemplate = 'mod_message';
             /** @var \FrontendTemplate|object $objTemplate */
             $objTemplate = new \FrontendTemplate($this->strTemplate);
             $this->Template = $objTemplate;
             $this->Template->type = 'confirm';
             $this->Template->message = $GLOBALS['TL_LANG']['MSC']['newPasswordSet'];
             return;
         }
     }
     $strToken = md5(uniqid(mt_rand(), true));
     $this->Session->set('setPasswordToken', $strToken);
     $this->Template->formId = $strToken;
     $this->Template->fields = $objWidget->parse();
     $this->Template->action = \Environment::get('indexFreeRequest');
     $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['setNewPassword']);
     $this->Template->tableless = $this->tableless;
 }
开发者ID:eknoes,项目名称:core,代码行数:81,代码来源:ModulePassword.php

示例15: toggleVisibility

 /**
  * Disable/enable a user group
  * @param integer
  * @param boolean
  */
 public function toggleVisibility($intId, $blnVisible)
 {
     // Check permissions to edit
     \Input::setGet('id', $intId);
     \Input::setGet('act', 'toggle');
     $this->checkPermission();
     // Check permissions to publish
     if (!\BackendUser::getInstance()->isAdmin && !\BackendUser::getInstance()->hasAccess('tl_iso_shipping::enabled', 'alexf')) {
         \System::log('Not enough permissions to enable/disable shipping method ID "' . $intId . '"', __METHOD__, TL_ERROR);
         \Controller::redirect('contao/main.php?act=error');
     }
     $objVersions = new \Versions('tl_iso_shipping', $intId);
     $objVersions->initialize();
     // Trigger the save_callback
     if (is_array($GLOBALS['TL_DCA']['tl_iso_shipping']['fields']['enabled']['save_callback'])) {
         foreach ($GLOBALS['TL_DCA']['tl_iso_shipping']['fields']['enabled']['save_callback'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             $blnVisible = $objCallback->{$callback}[1]($blnVisible, $this);
         }
     }
     // Update the database
     \Database::getInstance()->prepare("UPDATE tl_iso_shipping SET tstamp=" . time() . ", enabled='" . ($blnVisible ? 1 : '') . "' WHERE id=?")->execute($intId);
     $objVersions->create();
     \System::log('A new version of record "tl_iso_shipping.id=' . $intId . '" has been created' . $this->getParentEntries('tl_iso_shipping', $intId), __METHOD__, TL_GENERAL);
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:30,代码来源:Callback.php


注:本文中的Versions::initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。