當前位置: 首頁>>代碼示例>>PHP>>正文


PHP KTUtil::randomString方法代碼示例

本文整理匯總了PHP中KTUtil::randomString方法的典型用法代碼示例。如果您正苦於以下問題:PHP KTUtil::randomString方法的具體用法?PHP KTUtil::randomString怎麽用?PHP KTUtil::randomString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在KTUtil的用法示例。


在下文中一共展示了KTUtil::randomString方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ZipFolder

 /**
  * Constructor
  *
  * @param string $sZipFileName The name of the zip file - gets ignored at the moment.
  * @param string $exportCode The code to use if a zip file has already been created.
  */
 function ZipFolder($sZipFileName = null, $exportCode = null, $extension = 'zip')
 {
     $this->oKTConfig =& KTConfig::getSingleton();
     $this->oStorage =& KTStorageManagerUtil::getSingleton();
     $this->sOutputEncoding = $this->oKTConfig->get('export/encoding', 'UTF-8');
     $this->extension = $extension;
     $this->sPattern = "[\\*|\\%|\\\\|\\/|\\<|\\>|\\+|\\:|\\?|\\||\\'|\"]";
     $this->sFolderPattern = "[\\*|\\%|\\<|\\>|\\+|\\:|\\?|\\||\\'|\"]";
     if (!empty($exportCode)) {
         $this->exportCode = $exportCode;
     } else {
         $this->exportCode = KTUtil::randomString();
     }
     // Check if the temp directory has been created and stored in session
     $aData = KTUtil::arrayGet($_SESSION['zipcompression'], $exportCode);
     if (!empty($aData) && isset($aData['dir'])) {
         $sTmpPath = $aData['dir'];
     } else {
         $sBasedir = $this->oKTConfig->get("urls/tmpDirectory");
         $sTmpPath = tempnam($sBasedir, 'kt_compress_zip');
         unlink($sTmpPath);
         mkdir($sTmpPath, 0755);
     }
     // Hard coding the zip file name.
     // It normally uses the folder name but if there are special characters in the name then it doesn't download properly.
     $sZipFileName = 'kt_zip';
     $this->sTmpPath = $sTmpPath;
     $this->sZipFileName = $sZipFileName;
     $this->aPaths = array();
     $aReplace = array("[" => "[[]", " " => "[ ]", "*" => "[*]", "?" => "[?]");
     $this->aReplaceKeys = array_keys($aReplace);
     $this->aReplaceValues = array_values($aReplace);
 }
開發者ID:5haman,項目名稱:knowledgetree,代碼行數:39,代碼來源:compressionArchiveUtil.inc.php

示例2: KTForm

 function &form_step1()
 {
     $oForm = new KTForm();
     $oForm->setOptions(array('action' => 'process_step1', 'cancel_url' => KTUtil::addQueryStringSelf(''), 'fail_action' => 'main', 'label' => _kt('Workflow Details'), 'submit_label' => _kt('Next'), 'description' => _kt('This first step requires that you provide basic details about the workflow: its name, etc.'), 'context' => $this));
     $oForm->setWidgets(array(array('ktcore.widgets.string', array('label' => _kt('Workflow Name'), 'description' => _kt('Each workflow must have a unique name.'), 'required' => true, 'name' => 'workflow_name')), array('ktcore.widgets.text', array('label' => _kt('States'), 'description' => _kt('As documents progress through their lifecycle, they pass through a number of <strong>states</strong>.  These states describe a step in the process the document must follow.  Examples of states include "reviewed","submitted" or "pending".  Please enter a list of states, one per line.  State names must be unique.'), 'important_description' => _kt('Note that the first state you list is the one in which documents will start the workflow - this can be changed later on. '), 'required' => true, 'name' => 'states', 'rows' => 15)), array('ktcore.widgets.text', array('label' => _kt('Transitions'), 'description' => _kt('In order to move between states, users will cause "transitions" to occur.  These transitions represent processes followed, e.g. "review document", "distribute invoice" or "publish".  Please enter a list of transitions, one per line.  Transition names must be unique.  You\'ll assign transitions to states in the next step.'), 'required' => false, 'name' => 'transitions')), array('ktcore.widgets.hidden', array('required' => false, 'name' => 'fWizardKey', 'value' => KTUtil::randomString()))));
     $oForm->setValidators(array(array('ktcore.validators.string', array('test' => 'workflow_name', 'output' => 'workflow_name')), array('ktcore.validators.string', array('test' => 'fWizardKey', 'output' => 'fWizardKey')), array('ktcore.validators.string', array('test' => 'states', 'output' => 'states', 'max_length' => 9999)), array('ktcore.validators.string', array('test' => 'transitions', 'output' => 'transitions', 'max_length' => 9999))));
     return $oForm;
 }
開發者ID:5haman,項目名稱:knowledgetree,代碼行數:8,代碼來源:newworkflow.inc.php

示例3: KTEntityList

 function KTEntityList($aDocumentIds = false, $aFolderIds = false)
 {
     $this->sCode = KTUtil::randomString();
     if ($aDocumentIds !== false) {
         $this->aDocumentIds =& $aDocumentIds;
     }
     if ($aFolderIds !== false) {
         $this->aFolderIds =& $aFolderIds;
     }
     $this->serialize();
 }
開發者ID:5haman,項目名稱:knowledgetree,代碼行數:11,代碼來源:entitylist.php

示例4: KTPclZip

 /**
  * Constructor
  *
  * @param string $sZipFileName The name of the zip file.
  * @param string $exportCode The code to use if a zip file has already been created.
  */
 function KTPclZip($sZipFileName = 'kt_pclzip', $exportCode = null, $extension = 'zip')
 {
     //TODO: Cherry pick some of this logic borrowed from lib/foldremanagement/compressionArchiveUtil.inc.php
     $this->oKTConfig =& KTConfig::getSingleton();
     $this->oStorage =& KTStorageManagerUtil::getSingleton();
     $this->sOutputEncoding = $this->oKTConfig->get('export/encoding', 'UTF-8');
     $this->extension = $extension;
     $this->sPattern = "[\\*|\\%|\\\\|\\/|\\<|\\>|\\+|\\:|\\?|\\||\\'|\"]";
     $this->sFolderPattern = "[\\*|\\%|\\<|\\>|\\+|\\:|\\?|\\||\\'|\"]";
     if (!empty($exportCode)) {
         $this->exportCode = $exportCode;
     } else {
         $this->exportCode = KTUtil::randomString();
     }
     // Check if the temp directory has been created and stored in session
     $aData = KTUtil::arrayGet($_SESSION['zipcompression'], $exportCode);
     if (!empty($aData) && isset($aData['dir'])) {
         $sTmpPath = $aData['dir'];
     } else {
         $sBasedir = $this->oKTConfig->get("urls/tmpDirectory");
         $sTmpPath = tempnam($sBasedir, 'kt_compress_zip');
         unlink($sTmpPath);
         mkdir($sTmpPath, 0755);
     }
     $this->sTmpPath = $sTmpPath;
     $this->sZipFileName = $sZipFileName;
     $this->aPaths = array();
     $this->_pclZip = new PclZip($sZipFileName);
     /* //TODO: Cherry pick some of this logic borrowed from lib/foldremanagement/compressionArchiveUtil.inc.php
     		
     		$aReplace = array ("[" => "[[]", " " => "[ ]", "*" => "[*]", "?" => "[?]" );
     		
     		$this->aReplaceKeys = array_keys ( $aReplace );
     		$this->aReplaceValues = array_values ( $aReplace );
     		*/
 }
開發者ID:5haman,項目名稱:knowledgetree,代碼行數:42,代碼來源:ktpclzip.inc.php

示例5: do_login

 function do_login()
 {
     $aExtra = array();
     if (!loginUtil::check() && $_SESSION['userID'] != -2) {
         // bounce here, potentially.
         // User is already logged in - get the redirect
         $redirect = strip_tags(KTUtil::arrayGet($_REQUEST, 'redirect'));
         $cookietest = KTUtil::randomString();
         setcookie("CookieTestCookie", $cookietest, 0);
         $this->redirectTo('checkCookie', array('cookieVerify' => $cookietest, 'redirect' => $redirect));
         exit(0);
     }
     global $default;
     $language = KTUtil::arrayGet($_REQUEST, 'language');
     if (empty($language)) {
         $language = $default->defaultLanguage;
     }
     setcookie("kt_language", $language, 2147483647, '/');
     $redirect = strip_tags(KTUtil::arrayGet($_REQUEST, 'redirect'));
     $url = $_SERVER["PHP_SELF"];
     $queryParams = array();
     if (!empty($redirect)) {
         $queryParams[] = 'redirect=' . urlencode($redirect);
     }
     $username = KTUtil::arrayGet($_REQUEST, 'username');
     $password = KTUtil::arrayGet($_REQUEST, 'password');
     if (empty($username)) {
         $this->simpleRedirectToMain(_kt('Please enter your username.'), $url, $queryParams);
     }
     $oUser =& User::getByUsername($username);
     if (PEAR::isError($oUser) || $oUser === false) {
         if (is_a($oUser, 'ktentitynoobjects')) {
             loginUtil::handleUserDoesNotExist($username, $password, $aExtra);
         }
         $this->simpleRedirectToMain(_kt('Login failed.  Please check your username and password, and try again.'), $url, $queryParams);
         exit(0);
     }
     if (empty($password)) {
         $this->simpleRedirectToMain(_kt('Please enter your password.'), $url, $queryParams);
     }
     $authenticated = KTAuthenticationUtil::checkPassword($oUser, $password);
     if (PEAR::isError($authenticated)) {
         $this->simpleRedirectToMain(_kt('Authentication failure.  Please try again.'), $url, $queryParams);
         exit(0);
     }
     if ($authenticated !== true) {
         $this->simpleRedirectToMain(_kt('Login failed.  Please check your username and password, and try again.'), $url, $queryParams);
         exit(0);
     }
     $res = loginUtil::performLogin($oUser);
     if ($res) {
         $this->simpleRedirectToMain($res->getMessage(), $url, $queryParams);
         exit(0);
     }
 }
開發者ID:sfsergey,項目名稱:knowledgetree,代碼行數:55,代碼來源:loginResetDispatcher.php

示例6: performLogin

 /**
  * Log the user into the system
  *
  * @param unknown_type $oUser
  * @return unknown
  */
 function performLogin(&$oUser)
 {
     if (!is_a($oUser, 'User')) {
     }
     $session = new Session();
     $sessionID = $session->create($oUser);
     if (PEAR::isError($sessionID)) {
         return $sessionID;
     }
     $redirect = strip_tags(KTUtil::arrayGet($_REQUEST, 'redirect'));
     // DEPRECATED initialise page-level authorisation array
     $_SESSION["pageAccess"] = NULL;
     $cookietest = KTUtil::randomString();
     setcookie("CookieTestCookie", $cookietest, 0);
     $this->redirectTo('checkCookie', array('cookieVerify' => $cookietest, 'redirect' => $redirect));
     exit(0);
 }
開發者ID:jpbauer,項目名稱:knowledgetree,代碼行數:23,代碼來源:loginResetDispatcher.php

示例7: performLogin

 function performLogin(&$oUser)
 {
     if (!is_a($oUser, 'User')) {
         #var_dump($oUser);
         #var_dump(PEAR::raiseError());
     }
     /*
     Removing the code that redirects to the dashboard as it breaks linking in from external documents.
     The fix below doesn't work if the users are behind a proxy server.
     
     // If the last user from the same IP address timed out within the last hour then redirect to the dashboard
     // Otherwise allow any other redirect to continue.
     // The user might still be taken to the last page of the previous users session but
     // if we always redirect to dashboard then we break other features such as linking in from emails or documents.
     if (checkLastSessionUserID($oUser->getId()))
     {
     	$_REQUEST['redirect'] = generateControllerLink('dashboard');
     }
     */
     $session = new Session();
     $sessionID = $session->create($oUser);
     if (PEAR::isError($sessionID)) {
         return $sessionID;
     }
     $redirect = strip_tags(KTUtil::arrayGet($_REQUEST, 'redirect'));
     // DEPRECATED initialise page-level authorisation array
     $_SESSION["pageAccess"] = NULL;
     $cookietest = KTUtil::randomString();
     setcookie("CookieTestCookie", $cookietest, 0);
     $this->redirectTo('checkCookie', array('cookieVerify' => $cookietest, 'redirect' => $redirect));
     exit(0);
 }
開發者ID:5haman,項目名稱:knowledgetree,代碼行數:32,代碼來源:login.php

示例8: createZipFile

 /**
  * Zip the temp folder
  */
 function createZipFile($bEchoStatus = FALSE)
 {
     if (empty($this->aPaths)) {
         return PEAR::raiseError(_kt("No folders or documents found to compress"));
     }
     // Set environment language to output character encoding
     $loc = $this->sOutputEncoding;
     putenv("LANG={$loc}");
     putenv("LANGUAGE={$loc}");
     $loc = setlocale(LC_ALL, $loc);
     $sManifest = sprintf("%s/%s", $this->sTmpPath, "MANIFEST");
     file_put_contents($sManifest, join("\n", $this->aPaths));
     $sZipFile = sprintf("%s/%s.zip", $this->sTmpPath, $this->sZipFileName);
     $sZipFile = str_replace('<', '', str_replace('</', '', str_replace('>', '', $sZipFile)));
     $sZipCommand = KTUtil::findCommand("export/zip", "zip");
     $aCmd = array($sZipCommand, "-r", $sZipFile, ".", "-i@MANIFEST");
     $sOldPath = getcwd();
     chdir($this->sTmpPath);
     // Note that the popen means that pexec will return a file descriptor
     $aOptions = array('popen' => 'r');
     $fh = KTUtil::pexec($aCmd, $aOptions);
     if ($bEchoStatus) {
         $last_beat = time();
         while (!feof($fh)) {
             if ($i % 1000 == 0) {
                 $this_beat = time();
                 if ($last_beat + 1 < $this_beat) {
                     $last_beat = $this_beat;
                     print "&nbsp;";
                 }
             }
             $contents = fread($fh, 4096);
             if ($contents) {
                 print nl2br($this->_convertEncoding($contents, false));
             }
             $i++;
         }
     }
     pclose($fh);
     // Save the zip file and path into session
     $_SESSION['zipcompression'] = KTUtil::arrayGet($_SESSION, 'zipcompression', array());
     $sExportCode = KTUtil::randomString();
     $_SESSION['zipcompression'][$sExportCode] = array('file' => $sZipFile, 'dir' => $this->sTmpPath);
     $_SESSION['zipcompression']['exportcode'] = $sExportCode;
     $this->sZipFile = $sZipFile;
     return $sExportCode;
 }
開發者ID:sfsergey,項目名稱:knowledgetree,代碼行數:50,代碼來源:compressionArchiveUtil.inc.php

示例9: configure

 function configure($aOptions)
 {
     $aOptions['broken_name'] = KTUtil::arrayGet($aOptions, 'broken_name', true, false);
     $res = parent::configure($aOptions);
     if (PEAR::isError($res)) {
         return $res;
     }
     $this->oCollection = KTUtil::arrayGet($aOptions, 'collection');
     if (empty($this->oCollection)) {
         return PEAR::raiseError(_kt('No collection specified.'));
     }
     $this->iFolderId = KTUtil::arrayGet($aOptions, 'folder_id');
     if (empty($this->iFolderId)) {
         return PEAR::raiseError(_kt('No initial folder specified specified.'));
     }
     $this->aBCUrlParams = KTUtil::arrayGet($aOptions, 'bcurl_params', array());
     $this->aCols = array();
     foreach ($this->oCollection->columns as $oCol) {
         $this->aCols[] = $oCol->namespace;
     }
     $this->sCode = KTUtil::randomString();
     $this->sCollection = serialize($this->oCollection);
     $_SESSION['collection_widgets'][$this->sCode] = serialize($this);
     $this->requireJSResource('resources/js/collectionframe.js');
 }
開發者ID:jpbauer,項目名稱:knowledgetree,代碼行數:25,代碼來源:KTWidgets.php

示例10: do_main

 function do_main()
 {
     // store referer
     $sBackKey = KTUtil::arrayGet($_REQUEST, 'back_key', false);
     $sSubPath = KTUtil::arrayGet($_SERVER, 'PATH_INFO');
     // we want to be able to say "i left the system at point x.  go back there"
     if (!$sBackKey) {
         $sReferer = KTUtil::arrayGet($_SERVER, 'HTTP_REFERER');
         $sBackKey = KTUtil::randomString();
         $_SESSION[$sBackKey] = $sReferer;
     }
     // no path specified
     if (empty($sSubPath)) {
         $this->oPage->setTitle(_kt('No help page specified.'));
         $this->oPage->addError(_kt('No help page specified.'));
         return '&nbsp;';
     }
     // simple test to see if this user is active.
     $bCanEdit = Permission::userIsSystemAdministrator($_SESSION['userID']);
     global $default;
     $sLangCode = $default->defaultLanguage;
     /* 
       now we need to know a few things.  
          1. can we find this help file?
          2. if we can, display it
             2.1 images directly
             2.2 html wrapped.
          3. if now, fail out.
          
       this is essentially handled by asking help.inc.php for the 
       subpath we've been given, PLUS THE LANGUAGE, and checking for 
       a PEAR::raiseError.
       
       The "Correct" response we care about is a dictionary:
       
          {
              'is_image': string
              'title': string
              'body': string
          }
     */
     $aHelpData = KTHelp::getHelpInfo($sSubPath);
     if (PEAR::isError($aHelpData)) {
         $this->oPage->setTitle($aHelpData->getMessage());
         $this->oPage->addError($aHelpData->getMessage());
         return '&nbsp';
     }
     $aLocInfo = KTHelp::_getLocationInfo($sSubPath);
     if ($aHelpData['is_image']) {
         KTHelp::outputHelpImage($sSubPath);
         exit(0);
         // done.
     } else {
         $this->oPage->setTitle($aHelpData['title']);
         $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => $aHelpData['title']);
         $oTemplating =& KTTemplating::getSingleton();
         $oTemplate = $oTemplating->loadTemplate('ktcore/help_with_edit');
         $aTemplateData = array('context' => $this, 'help_body' => $aHelpData['body'], 'help_title' => $aHelpData['title'], 'target_name' => KTUtil::arrayGet($aLocInfo, 'subpath'), 'back_key' => $sBackKey, 'can_edit' => $bCanEdit);
         return $oTemplate->render($aTemplateData);
     }
     /*
             $help_path = KTHelp::getHelpSubPath($pathinfo);
     
             if ($help_path == false) {
                 $this->oPage->setTitle(_kt('Invalid help location specified.'));
                 $this->oPage->addError(_kt('Invalid help location specified.'));
                 return '&nbsp';
             }
     // We now check for substitute help files.  try to generate an error.
             $oReplacementHelp = KTHelpReplacement::getByName($help_path);
     
             if (KTHelp::isImageFile($help_path)) {
                 KTHelp::outputHelpImage($help_path);
             } else {
                 // not an image, so:
                 $aHelpInfo = KTHelp::getHelpFromFile($pathinfo)
             }
     
             // NORMAL users never see edit-option.
             if (!$can_edit) {
                 if (!PEAR::isError($oReplacementHelp)) {
                     $this->oPage->setTitle($oReplacementHelp->getTitle());
                     //return $oReplacementHelp->getDescription();
                 } elseif ($aHelpInfo != false) {
                     $this->oPage->setTitle($aHelpInfo['title']);
                     //return $aHelpInfo['body'];
                 } else {
                     $this->oPage->setTitle(_kt('Invalid help location specified.'));
                     $this->oPage->addError(_kt('Invalid help location specified.'));
                     return '&nbsp';
                 }
             } 
     if (!PEAR::isError($oReplacementHelp)) {
                 $aHelpInfo['title'] = $oReplacementHelp->getTitle();
                 $aHelpInfo['body'] = $oReplacementHelp->getDescription();
             }
             // we now _can_ edit.
     
     $this->oPage->setTitle($aHelpInfo['title']);
             $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => $aHelpInfo['title']);
//.........這裏部分代碼省略.........
開發者ID:sfsergey,項目名稱:knowledgetree,代碼行數:101,代碼來源:help.php

示例11: do_main

    function do_main()
    {
        $config = KTConfig::getSingleton();
        $useQueue = $config->get('export/useDownloadQueue', true);
        // Create the export code
        $exportCode = KTUtil::randomString();
        $this->oZip = new ZipFolder('', $exportCode);
        if (!$this->oZip->checkConvertEncoding()) {
            redirect(KTBrowseUtil::getUrlForFolder($this->oFolder));
            exit(0);
        }
        $bNoisy = $config->get("tweaks/noisyBulkOperations");
        $bNotifications = $config->get('export/enablenotifications', 'on') == 'on' ? true : false;
        $sCurrentFolderId = $this->oFolder->getId();
        $url = KTUtil::addQueryStringSelf(sprintf('action=downloadZipFile&fFolderId=%d&exportcode=%s', $sCurrentFolderId, $exportCode));
        $folderurl = KTBrowseUtil::getUrlForFolder($this->oFolder);
        if ($useQueue) {
            DownloadQueue::addItem($exportCode, $sCurrentFolderId, $sCurrentFolderId, 'folder');
            $task_url = KTUtil::kt_url() . '/bin/ajaxtasks/downloadTask.php';
            $oTemplating =& KTTemplating::getSingleton();
            $oTemplate = $oTemplating->loadTemplate('ktcore/action/bulk_download');
            $aParams = array('folder_url' => $folderurl, 'url' => $task_url, 'code' => $exportCode, 'download_url' => $url);
            return $oTemplate->render($aParams);
        }
        // Get all folders and sub-folders
        $sWhereClause = "parent_folder_ids = '{$sCurrentFolderId}' OR\n        parent_folder_ids LIKE '{$sCurrentFolderId},%' OR\n        parent_folder_ids LIKE '%,{$sCurrentFolderId},%' OR\n        parent_folder_ids LIKE '%,{$sCurrentFolderId}'";
        $aFolderList = $this->oFolder->getList($sWhereClause);
        // Get any folder shortcuts within the folders
        $aLinkedFolders = KTBulkAction::getLinkingEntities($aFolderList);
        $aFolderList = array_merge($aFolderList, $aLinkedFolders);
        // Add the folders to the zip file
        $aFolderObjects = array($sCurrentFolderId => $this->oFolder);
        if (!empty($aFolderList)) {
            foreach ($aFolderList as $oFolderItem) {
                $itemId = $oFolderItem->getId();
                $linkedFolder = $oFolderItem->getLinkedFolderId();
                // If the folder has been added or is a shortcut then skip
                // The shortcut folders don't need to be added as their targets will be added.
                if (array_key_exists($itemId, $aFolderObjects) || !empty($linkedFolder)) {
                    continue;
                }
                $this->oZip->addFolderToZip($oFolderItem);
                $aFolderObjects[$oFolderItem->getId()] = $oFolderItem;
            }
        }
        // Get the list of folder ids
        $aFolderIds = array_keys($aFolderObjects);
        // Get all documents in the folder list
        $aQuery = $this->buildQuery($aFolderIds);
        $aDocumentIds = DBUtil::getResultArrayKey($aQuery, 'id');
        if (PEAR::isError($aDocumentIds)) {
            $this->addErrorMessage(_kt('There was a problem exporting the documents: ') . $aDocumentIds->getMessage());
            redirect(KTBrowseUtil::getUrlForFolder($this->oFolder));
            exit(0);
        }
        // Redirect if there are no documents and no folders to export
        if (empty($aDocumentIds) && empty($aFolderList)) {
            $this->addErrorMessage(_kt("No documents found to export"));
            redirect(KTBrowseUtil::getUrlForFolder($this->oFolder));
            exit(0);
        }
        $this->oPage->template = "kt3/minimal_page";
        $this->handleOutput("");
        // Add the documents to the zip file
        if (!empty($aDocumentIds)) {
            foreach ($aDocumentIds as $iId) {
                $oDocument = Document::get($iId);
                $sFolderId = $oDocument->getFolderID();
                if (!KTWorkflowUtil::actionEnabledForDocument($oDocument, 'ktcore.actions.document.view')) {
                    $this->addErrorMessage($oDocument->getName() . ': ' . _kt('Document cannot be exported as it is restricted by the workflow.'));
                    continue;
                }
                $oFolder = isset($aFolderObjects[$sFolderId]) ? $aFolderObjects[$sFolderId] : Folder::get($sFolderId);
                if ($bNoisy) {
                    $oDocumentTransaction =& new DocumentTransaction($oDocument, "Document part of bulk export", 'ktstandard.transactions.bulk_export', array());
                    $oDocumentTransaction->create();
                }
                // fire subscription alerts for the downloaded document
                if ($bNotifications) {
                    //$oSubscriptionEvent = new SubscriptionEvent();
                    //$oSubscriptionEvent->DownloadDocument($oDocument, $oFolder);
                }
                $this->oZip->addDocumentToZip($oDocument, $oFolder);
            }
        }
        $sExportCode = $this->oZip->createZipFile(TRUE);
        $oTransaction = KTFolderTransaction::createFromArray(array('folderid' => $this->oFolder->getId(), 'comment' => "Bulk export", 'transactionNS' => 'ktstandard.transactions.bulk_export', 'userid' => $_SESSION['userID'], 'ip' => Session::getClientIP()));
        $sReturn = '<p>' . _kt('Creating zip file. Compressing and archiving in progress ...') . '</p>';
        $sReturn .= "<p style='margin-bottom: 10px;'><br /><b>" . _kt('Warning! Please wait for archiving to complete before closing the page.') . '</b><br />' . _kt('Note: Closing the page before the download link displays will cancel your Bulk Download.') . '</p>';
        $sReturn .= '<p>' . _kt('Once your download is complete, click <a href="' . $folderurl . '">here</a> to return to the original folder') . "</p>\n";
        print $sReturn;
        printf("</div></div></body></html>\n");
        printf('<script language="JavaScript">
                function kt_bulkexport_redirect() {
                    document.location.href = "%s";
                }
                callLater(2, kt_bulkexport_redirect);

                </script>', $url);
        exit(0);
//.........這裏部分代碼省略.........
開發者ID:jpbauer,項目名稱:knowledgetree,代碼行數:101,代碼來源:KTBulkExportPlugin.php

示例12: generateFormName

 function generateFormName($sIdentifier = null)
 {
     if (!is_null($sIdentifier)) {
         // try use the existing one from the request.
         $existing = KTUtil::arrayGet($_REQUEST, '_kt_form_name');
         if (!empty($existing)) {
             // check that its the same form
             $data = KTUtil::arrayGet($_SESSION['_kt_old_data'], $existing);
             if ($data['identifier'] == $sIdentifier) {
                 return $existing;
             }
         }
     }
     return KTUtil::randomString(32);
     // unique 32 char string
 }
開發者ID:sfsergey,項目名稱:knowledgetree,代碼行數:16,代碼來源:forms.inc.php

示例13: do_processInitialData

 function do_processInitialData()
 {
     $oForm = $this->form_initialdata();
     $res = $oForm->validate();
     if (!empty($res['errors'])) {
         if (!isset($res['errors']['file'])) {
             $aError['file'] = array(_kt('Please reselect the file to upload.'));
         }
         return $oForm->handleError('', $aError);
     }
     $data = $res['results'];
     $key = KTUtil::randomString(32);
     // joy joy, we need to store the file first, or PHP will (helpfully)
     // clean it up for us
     $oKTConfig =& KTConfig::getSingleton();
     $sBasedir = $oKTConfig->get("urls/tmpDirectory");
     $sFilename = tempnam($sBasedir, 'kt_storecontents');
     //$oContents = new KTFSFileLike($data['file']['tmp_name']);
     //$oOutputFile = new KTFSFileLike($sFilename);
     //$res = KTFileLikeUtil::copy_contents($oContents, $oOutputFile);
     //if (PEAR::isError($res)) {
     //    $oForm->handleError(sprintf(_kt("Failed to store file: %s"), $res->getMessage()));
     //}
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $oStorage->uploadTmpFile($data['file']['tmp_name'], $sFilename);
     $data['file']['tmp_name'] = $sFilename;
     $_SESSION['_add_data'] = array($key => $data);
     // if we don't need metadata
     $fieldsets = $this->getFieldsetsForType($data['document_type']);
     if (empty($fieldsets)) {
         return $this->successRedirectTo('finalise', _kt("File uploaded successfully. Processing."), sprintf("fFileKey=%s", $key));
     }
     // if we need metadata
     $this->successRedirectTo('metadata', _kt("File uploaded successfully.  Please fill in the metadata below."), sprintf("fFileKey=%s", $key));
 }
開發者ID:sfsergey,項目名稱:knowledgetree,代碼行數:35,代碼來源:addDocument.php

示例14: do_performaction

 function do_performaction()
 {
     $config = KTConfig::getSingleton();
     $useQueue = $config->get('export/useDownloadQueue', true);
     // Create the export code
     $this->sExportCode = KTUtil::randomString();
     $_SESSION['exportcode'] = $this->sExportCode;
     // Save the return url in session so it is not lost when doing the download
     $folderurl = $this->getReturnUrl();
     $_SESSION['export_return_url'] = $folderurl;
     $download_url = KTUtil::addQueryStringSelf("action=downloadZipFile&fFolderId={$this->oFolder->getId()}&exportcode={$this->sExportCode}");
     if ($useQueue) {
         $result = parent::do_performaction();
         $url = KTUtil::kt_url() . '/presentation/lookAndFeel/knowledgeTree/bulkdownload/downloadTask.php';
         $oTemplating =& KTTemplating::getSingleton();
         $oTemplate = $oTemplating->loadTemplate('ktcore/action/bulk_download');
         $aParams = array('folder_url' => $folderurl, 'url' => $url, 'code' => $this->sExportCode, 'download_url' => $download_url);
         return $oTemplate->render($aParams);
     }
     $this->oZip = new ZipFolder('', $this->sExportCode);
     $res = $this->oZip->checkConvertEncoding();
     if (PEAR::isError($res)) {
         $this->addErrorMessage($res->getMessage());
         return $sReturn;
     }
     $this->startTransaction();
     $result = parent::do_performaction();
     $sExportCode = $this->oZip->createZipFile();
     if (PEAR::isError($sExportCode)) {
         $this->addErrorMessage($sExportCode->getMessage());
         $this->rollbackTransaction();
         return $sReturn;
     }
     $oTransaction = KTFolderTransaction::createFromArray(array('folderid' => $this->oFolder->getId(), 'comment' => "Bulk export", 'transactionNS' => 'ktstandard.transactions.bulk_export', 'userid' => $_SESSION['userID'], 'ip' => Session::getClientIP()));
     $this->commitTransaction();
     $str = '<p>' . _kt('Creating zip file. Compressing and archiving in progress ...') . '</p>';
     $str .= "<p style='margin-bottom: 10px;'><br /><b>" . _kt('Warning! Please wait for archiving to complete before closing the page.') . '</b><br />' . _kt('Note: Closing the page before the download link displays will cancel your Bulk Download.') . '</p>';
     $str .= sprintf('<p>' . _kt('Once your download is complete, click <a href="%s">here</a> to return to the original folder') . "</p>\n", $folderurl);
     $str .= sprintf('<script language="JavaScript">
             function kt_bulkexport_redirect() {
                 document.location.href = "%s";
             }
             callLater(5, kt_bulkexport_redirect);
             </script>', $download_url);
     return $str;
 }
開發者ID:5haman,項目名稱:knowledgetree,代碼行數:46,代碼來源:KTBulkActions.php


注:本文中的KTUtil::randomString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。