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


PHP io_sweepNS函数代码示例

本文整理汇总了PHP中io_sweepNS函数的典型用法代码示例。如果您正苦于以下问题:PHP io_sweepNS函数的具体用法?PHP io_sweepNS怎么用?PHP io_sweepNS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _deleteMeta

 /**
  * Deletes a meta file associated with the deleted media file
  */
 function _deleteMeta(&$event)
 {
     $id = $event->data['id'];
     $metafile = metaFN($id, '.filename');
     if (@unlink($metafile)) {
         io_sweepNS($id, 'metadir');
     }
 }
开发者ID:kazmiya,项目名称:dokuwiki-plugin-preservefilenames,代码行数:11,代码来源:action_anteater.php

示例2: _deleteMeta

 /**
  * Deletes a meta file associated with the deleted media file
  */
 function _deleteMeta(&$event)
 {
     $id = $event->data['id'];
     $metaFilePath = mediaMetaFN($id, '.filename');
     if (@unlink($metaFilePath)) {
         io_sweepNS($id, 'mediametadir');
     } else {
         parent::_deleteMeta($event);
     }
 }
开发者ID:kazmiya,项目名称:dokuwiki-plugin-preservefilenames,代码行数:13,代码来源:action_angua.php

示例3: saveWikiText

/**
 * Saves a wikitext by calling io_writeWikiPage.
 * Also directs changelog and attic updates.
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 * @author Ben Coburn <btcoburn@silicodon.net>
 */
function saveWikiText($id, $text, $summary, $minor = false)
{
    /* Note to developers:
         This code is subtle and delicate. Test the behavior of
         the attic and changelog with dokuwiki and external edits
         after any changes. External edits change the wiki page
         directly without using php or dokuwiki.
       */
    global $conf;
    global $lang;
    global $REV;
    // ignore if no changes were made
    if ($text == rawWiki($id, '')) {
        return;
    }
    $file = wikiFN($id);
    $old = @filemtime($file);
    // from page
    $wasRemoved = trim($text) == '';
    // check for empty or whitespace only
    $wasCreated = !@file_exists($file);
    $wasReverted = $REV == true;
    $newRev = false;
    $oldRev = getRevisions($id, -1, 1, 1024);
    // from changelog
    $oldRev = (int) (empty($oldRev) ? 0 : $oldRev[0]);
    if (!@file_exists(wikiFN($id, $old)) && @file_exists($file) && $old >= $oldRev) {
        // add old revision to the attic if missing
        saveOldRevision($id);
        // add a changelog entry if this edit came from outside dokuwiki
        if ($old > $oldRev) {
            addLogEntry($old, $id, DOKU_CHANGE_TYPE_EDIT, $lang['external_edit'], '', array('ExternalEdit' => true));
            // remove soon to be stale instructions
            $cache = new cache_instructions($id, $file);
            $cache->removeCache();
        }
    }
    if ($wasRemoved) {
        // Send "update" event with empty data, so plugins can react to page deletion
        $data = array(array($file, '', false), getNS($id), noNS($id), false);
        trigger_event('IO_WIKIPAGE_WRITE', $data);
        // pre-save deleted revision
        @touch($file);
        clearstatcache();
        $newRev = saveOldRevision($id);
        // remove empty file
        @unlink($file);
        // don't remove old meta info as it should be saved, plugins can use IO_WIKIPAGE_WRITE for removing their metadata...
        // purge non-persistant meta data
        p_purge_metadata($id);
        $del = true;
        // autoset summary on deletion
        if (empty($summary)) {
            $summary = $lang['deleted'];
        }
        // remove empty namespaces
        io_sweepNS($id, 'datadir');
        io_sweepNS($id, 'mediadir');
    } else {
        // save file (namespace dir is created in io_writeWikiPage)
        io_writeWikiPage($file, $text, $id);
        // pre-save the revision, to keep the attic in sync
        $newRev = saveOldRevision($id);
        $del = false;
    }
    // select changelog line type
    $extra = '';
    $type = DOKU_CHANGE_TYPE_EDIT;
    if ($wasReverted) {
        $type = DOKU_CHANGE_TYPE_REVERT;
        $extra = $REV;
    } else {
        if ($wasCreated) {
            $type = DOKU_CHANGE_TYPE_CREATE;
        } else {
            if ($wasRemoved) {
                $type = DOKU_CHANGE_TYPE_DELETE;
            } else {
                if ($minor && $conf['useacl'] && $_SERVER['REMOTE_USER']) {
                    $type = DOKU_CHANGE_TYPE_MINOR_EDIT;
                }
            }
        }
    }
    //minor edits only for logged in users
    addLogEntry($newRev, $id, $type, $summary, $extra);
    // send notify mails
    notify($id, 'admin', $old, $summary, $minor);
    notify($id, 'subscribers', $old, $summary, $minor);
    // update the purgefile (timestamp of the last time anything within the wiki was changed)
    io_saveFile($conf['cachedir'] . '/purgefile', time());
    // if useheading is enabled, purge the cache of all linking pages
    if (useHeading('content')) {
//.........这里部分代码省略.........
开发者ID:nextghost,项目名称:dokuwiki,代码行数:101,代码来源:common.php

示例4: saveWikiText

/**
 * Saves a wikitext by calling io_writeWikiPage.
 * Also directs changelog and attic updates.
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 * @author Ben Coburn <btcoburn@silicodon.net>
 */
function saveWikiText($id, $text, $summary, $minor = false)
{
    /* Note to developers:
         This code is subtle and delicate. Test the behavior of
         the attic and changelog with dokuwiki and external edits
         after any changes. External edits change the wiki page
         directly without using php or dokuwiki.
      */
    global $conf;
    global $lang;
    global $REV;
    // ignore if no changes were made
    if ($text == rawWiki($id, '')) {
        return;
    }
    $file = wikiFN($id);
    $old = @filemtime($file);
    // from page
    $wasRemoved = empty($text);
    $wasCreated = !@file_exists($file);
    $wasReverted = $REV == true;
    $newRev = false;
    $oldRev = getRevisions($id, -1, 1, 1024);
    // from changelog
    $oldRev = (int) (empty($oldRev) ? 0 : $oldRev[0]);
    if (!@file_exists(wikiFN($id, $old)) && @file_exists($file) && $old >= $oldRev) {
        // add old revision to the attic if missing
        saveOldRevision($id);
        // add a changelog entry if this edit came from outside dokuwiki
        if ($old > $oldRev) {
            addLogEntry($old, $id);
            // send notify mails
            notify($id, 'admin', $oldRev, '', false);
            notify($id, 'subscribers', $oldRev, '', false);
            // remove soon to be stale instructions
            $cache = new cache_instructions($id, $file);
            $cache->removeCache();
        }
    }
    if ($wasRemoved) {
        // pre-save deleted revision
        @touch($file);
        clearstatcache();
        $newRev = saveOldRevision($id);
        // remove empty file
        @unlink($file);
        // remove old meta info...
        $mfiles = metaFiles($id);
        $changelog = metaFN($id, '.changes');
        foreach ($mfiles as $mfile) {
            // but keep per-page changelog to preserve page history
            if (@file_exists($mfile) && $mfile !== $changelog) {
                @unlink($mfile);
            }
        }
        $del = true;
        // autoset summary on deletion
        if (empty($summary)) {
            $summary = $lang['deleted'];
        }
        // remove empty namespaces
        io_sweepNS($id, 'datadir');
        io_sweepNS($id, 'mediadir');
    } else {
        // save file (namespace dir is created in io_writeWikiPage)
        io_writeWikiPage($file, $text, $id);
        // pre-save the revision, to keep the attic in sync
        $newRev = saveOldRevision($id);
        $del = false;
    }
    // select changelog line type
    $extra = '';
    $type = 'E';
    if ($wasReverted) {
        $type = 'R';
        $extra = $REV;
    } else {
        if ($wasCreated) {
            $type = 'C';
        } else {
            if ($wasRemoved) {
                $type = 'D';
            } else {
                if ($minor && $conf['useacl'] && $_SERVER['REMOTE_USER']) {
                    $type = 'e';
                }
            }
        }
    }
    //minor edits only for logged in users
    addLogEntry($newRev, $id, $type, $summary, $extra);
    // send notify mails
    notify($id, 'admin', $old, $summary, $minor);
//.........这里部分代码省略.........
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:101,代码来源:common.php

示例5: saveWikiText

/**
 * Saves a wikitext by calling io_writeWikiPage.
 * Also directs changelog and attic updates.
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 * @author Ben Coburn <btcoburn@silicodon.net>
 *
 * @param string $id       page id
 * @param string $text     wikitext being saved
 * @param string $summary  summary of text update
 * @param bool   $minor    mark this saved version as minor update
 */
function saveWikiText($id, $text, $summary, $minor = false)
{
    /* Note to developers:
         This code is subtle and delicate. Test the behavior of
         the attic and changelog with dokuwiki and external edits
         after any changes. External edits change the wiki page
         directly without using php or dokuwiki.
       */
    global $conf;
    global $lang;
    global $REV;
    /* @var Input $INPUT */
    global $INPUT;
    // prepare data for event
    $svdta = array();
    $svdta['id'] = $id;
    $svdta['file'] = wikiFN($id);
    $svdta['revertFrom'] = $REV;
    $svdta['oldRevision'] = @filemtime($svdta['file']);
    $svdta['newRevision'] = 0;
    $svdta['newContent'] = $text;
    $svdta['oldContent'] = rawWiki($id);
    $svdta['summary'] = $summary;
    $svdta['contentChanged'] = $svdta['newContent'] != $svdta['oldContent'];
    $svdta['changeInfo'] = '';
    $svdta['changeType'] = DOKU_CHANGE_TYPE_EDIT;
    $svdta['sizechange'] = null;
    // select changelog line type
    if ($REV) {
        $svdta['changeType'] = DOKU_CHANGE_TYPE_REVERT;
        $svdta['changeInfo'] = $REV;
    } else {
        if (!file_exists($svdta['file'])) {
            $svdta['changeType'] = DOKU_CHANGE_TYPE_CREATE;
        } else {
            if (trim($text) == '') {
                // empty or whitespace only content deletes
                $svdta['changeType'] = DOKU_CHANGE_TYPE_DELETE;
                // autoset summary on deletion
                if (blank($svdta['summary'])) {
                    $svdta['summary'] = $lang['deleted'];
                }
            } else {
                if ($minor && $conf['useacl'] && $INPUT->server->str('REMOTE_USER')) {
                    //minor edits only for logged in users
                    $svdta['changeType'] = DOKU_CHANGE_TYPE_MINOR_EDIT;
                }
            }
        }
    }
    $event = new Doku_Event('COMMON_WIKIPAGE_SAVE', $svdta);
    if (!$event->advise_before()) {
        return;
    }
    // if the content has not been changed, no save happens (plugins may override this)
    if (!$svdta['contentChanged']) {
        return;
    }
    detectExternalEdit($id);
    if ($svdta['changeType'] == DOKU_CHANGE_TYPE_CREATE || $svdta['changeType'] == DOKU_CHANGE_TYPE_REVERT && !file_exists($svdta['file'])) {
        $filesize_old = 0;
    } else {
        $filesize_old = filesize($svdta['file']);
    }
    if ($svdta['changeType'] == DOKU_CHANGE_TYPE_DELETE) {
        // Send "update" event with empty data, so plugins can react to page deletion
        $data = array(array($svdta['file'], '', false), getNS($id), noNS($id), false);
        trigger_event('IO_WIKIPAGE_WRITE', $data);
        // pre-save deleted revision
        @touch($svdta['file']);
        clearstatcache();
        $data['newRevision'] = saveOldRevision($id);
        // remove empty file
        @unlink($svdta['file']);
        $filesize_new = 0;
        // don't remove old meta info as it should be saved, plugins can use IO_WIKIPAGE_WRITE for removing their metadata...
        // purge non-persistant meta data
        p_purge_metadata($id);
        // remove empty namespaces
        io_sweepNS($id, 'datadir');
        io_sweepNS($id, 'mediadir');
    } else {
        // save file (namespace dir is created in io_writeWikiPage)
        io_writeWikiPage($svdta['file'], $svdta['newContent'], $id);
        // pre-save the revision, to keep the attic in sync
        $svdta['newRevision'] = saveOldRevision($id);
        $filesize_new = filesize($svdta['file']);
    }
//.........这里部分代码省略.........
开发者ID:splitbrain,项目名称:dokuwiki,代码行数:101,代码来源:common.php

示例6: deleteAttachment

 /**
  * Deletes a file from the wiki.
  *
  * @author Gina Haeussge <osd@foosel.net>
  */
 function deleteAttachment($id)
 {
     $id = cleanID($id);
     $auth = auth_quickaclcheck(getNS($id) . ':*');
     if ($auth < AUTH_DELETE) {
         return new IXR_ERROR(1, "You don't have permissions to delete files.");
     }
     global $conf;
     global $lang;
     // check for references if needed
     $mediareferences = array();
     if ($conf['refcheck']) {
         $mediareferences = ft_mediause($id, $conf['refshow']);
     }
     if (!count($mediareferences)) {
         $file = mediaFN($id);
         if (@unlink($file)) {
             addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE);
             io_sweepNS($id, 'mediadir');
             return 0;
         }
         //something went wrong
         return new IXR_ERROR(1, 'Could not delete file');
     } else {
         return new IXR_ERROR(1, 'File is still referenced');
     }
 }
开发者ID:ryankask,项目名称:dokuwiki,代码行数:32,代码来源:xmlrpc.php

示例7: media_delete

/**
 * Handles media file deletions
 *
 * If configured, checks for media references before deletion
 *
 * @author             Andreas Gohr <andi@splitbrain.org>
 * @param string $id media id
 * @param int $auth no longer used
 * @return int One of: 0,
 *                     DOKU_MEDIA_DELETED,
 *                     DOKU_MEDIA_DELETED | DOKU_MEDIA_EMPTY_NS,
 *                     DOKU_MEDIA_NOT_AUTH,
 *                     DOKU_MEDIA_INUSE
 */
function media_delete($id, $auth)
{
    global $lang;
    $auth = auth_quickaclcheck(ltrim(getNS($id) . ':*', ':'));
    if ($auth < AUTH_DELETE) {
        return DOKU_MEDIA_NOT_AUTH;
    }
    if (media_inuse($id)) {
        return DOKU_MEDIA_INUSE;
    }
    $file = mediaFN($id);
    // trigger an event - MEDIA_DELETE_FILE
    $data['id'] = $id;
    $data['name'] = utf8_basename($file);
    $data['path'] = $file;
    $data['size'] = @file_exists($file) ? filesize($file) : 0;
    $data['unl'] = false;
    $data['del'] = false;
    $evt = new Doku_Event('MEDIA_DELETE_FILE', $data);
    if ($evt->advise_before()) {
        $old = @filemtime($file);
        if (!@file_exists(mediaFN($id, $old)) && @file_exists($file)) {
            // add old revision to the attic
            media_saveOldRevision($id);
        }
        $data['unl'] = @unlink($file);
        if ($data['unl']) {
            addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE, $lang['deleted']);
            $data['del'] = io_sweepNS($id, 'mediadir');
        }
    }
    $evt->advise_after();
    unset($evt);
    if ($data['unl'] && $data['del']) {
        return DOKU_MEDIA_DELETED | DOKU_MEDIA_EMPTY_NS;
    }
    return $data['unl'] ? DOKU_MEDIA_DELETED : 0;
}
开发者ID:yjliugit,项目名称:dokuwiki,代码行数:52,代码来源:media.php

示例8: media_delete

/**
 * Handles media file deletions
 *
 * If configured, checks for media references before deletion
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 * @return mixed false on error, true on delete or array with refs
 */
function media_delete($id, $auth)
{
    if ($auth < AUTH_DELETE) {
        return false;
    }
    if (!checkSecurityToken()) {
        return false;
    }
    global $conf;
    global $lang;
    $file = mediaFN($id);
    // trigger an event - MEDIA_DELETE_FILE
    $data['id'] = $id;
    $data['name'] = basename($file);
    $data['path'] = $file;
    $data['size'] = @file_exists($file) ? filesize($file) : 0;
    $data['unl'] = false;
    $data['del'] = false;
    $evt = new Doku_Event('MEDIA_DELETE_FILE', $data);
    if ($evt->advise_before()) {
        $data['unl'] = @unlink($file);
        if ($data['unl']) {
            addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE);
            $data['del'] = io_sweepNS($id, 'mediadir');
        }
    }
    $evt->advise_after();
    unset($evt);
    if ($data['unl'] && $data['del']) {
        // current namespace was removed. redirecting to root ns passing msg along
        send_redirect(DOKU_URL . 'lib/exe/mediamanager.php?msg1=' . rawurlencode(sprintf(noNS($id), $lang['deletesucc'])));
    }
    return $data['unl'];
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:42,代码来源:media.php

示例9: media_delete

/**
* Handles media file deletions
*
* If configured, checks for media references before deletion
*
* @author Andreas Gohr <andi@splitbrain.org>
* @return int One of: 0,
                      DOKU_MEDIA_DELETED,
                      DOKU_MEDIA_DELETED | DOKU_MEDIA_EMPTY_NS,
                      DOKU_MEDIA_NOT_AUTH,
                      DOKU_MEDIA_INUSE
*/
function media_delete($id, $auth)
{
    if ($auth < AUTH_DELETE) {
        return DOKU_MEDIA_NOT_AUTH;
    }
    if (media_inuse($id)) {
        return DOKU_MEDIA_INUSE;
    }
    $file = mediaFN($id);
    // trigger an event - MEDIA_DELETE_FILE
    $data['id'] = $id;
    $data['name'] = basename($file);
    $data['path'] = $file;
    $data['size'] = @file_exists($file) ? filesize($file) : 0;
    $data['unl'] = false;
    $data['del'] = false;
    $evt = new Doku_Event('MEDIA_DELETE_FILE', $data);
    if ($evt->advise_before()) {
        $data['unl'] = @unlink($file);
        if ($data['unl']) {
            addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE);
            $data['del'] = io_sweepNS($id, 'mediadir');
        }
    }
    $evt->advise_after();
    unset($evt);
    if ($data['unl'] && $data['del']) {
        return DOKU_MEDIA_DELETED | DOKU_MEDIA_EMPTY_NS;
    }
    return $data['unl'] ? DOKU_MEDIA_DELETED : 0;
}
开发者ID:Narrator,项目名称:dokuwiki,代码行数:43,代码来源:media.php

示例10: handle

    public function handle() {
    	global $conf, $ID;

        //$this->_debug_print_r($data);        
        //$this->_debug_print_r($_REQUEST);
        
        
        //If delete requested
        if(isset($_REQUEST['media_id_to_delete'])){

        	if(checkSecurityToken($_REQUEST['sectok'])){
        	
	        	$mediaToDelete = $_REQUEST['media_id_to_delete'];   
				
	        	$file = mediaFN($mediaToDelete);
	        	
	        	if(file_exists($file)){
	        		if(media_inuse($mediaToDelete)===false){
	
					    // trigger an event - MEDIA_DELETE_FILE
					    $data['id']   = $mediaToDelete;
					    $data['name'] = basename($file);
					    $data['path'] = $file;
					    $data['size'] = (@file_exists($file)) ? filesize($file) : 0;
					
					    $data['unl'] = false;
					    $data['del'] = false;
					    $evt = new Doku_Event('MEDIA_DELETE_FILE',$data);
					    if ($evt->advise_before()) {
					        $data['unl'] = @unlink($file);
					        if($data['unl']){
					            addMediaLogEntry(time(), $mediaToDelete, DOKU_CHANGE_TYPE_DELETE);
					            $data['del'] = io_sweepNS($mediaToDelete,'mediadir');
					        }
					    }
					    $evt->advise_after();
					    unset($evt);
	        			
						$this->ok = sprintf($this->getLang('delete_file_ok'),$mediaToDelete);
						;
	        		}else{
	        			$this->error = sprintf($this->getLang('delete_file_in_use'),$mediaToDelete);
	        		}        		
	        		
	        	}else{
	        		$this->error = sprintf($this->getLang('delete_file_not_found'),$mediaToDelete);
	        	}
        	
        	}//end of csrf check
        }
        
        
        //Searching for orphaned medias
        
        $data = array();
        
        //getting all medias
        search($data,$conf['mediadir'],'search_media', array('showmsg'=>true,'depth'=>500),str_replace(':', '/', getNS($ID)));
        

        
        
        //check if they are (still) in use or not.
        foreach($data as $media){
        	$isUsed = media_inuse($media['id']);

        	if($isUsed === false){
        		$this->orphans_medias[$media['id']] = $media;
        	}
        }
        

    }
开发者ID:Jguilbaud,项目名称:dokuwikipluginUnusedMedias,代码行数:73,代码来源:list.php

示例11: cleanMeta

 protected function cleanMeta($pageId)
 {
     $pathNS = $this->G['conf']['metadir'] . DIRECTORY_SEPARATOR . str_replace(':', DIRECTORY_SEPARATOR, getNS($pageId)) . DIRECTORY_SEPARATOR;
     $file = noNS($pageId);
     $metaFiles = ["{$file}.changes", "{$file}.indexed", "{$file}.meta"];
     foreach ($metaFiles as $f) {
         $filename = $pathNS . $f;
         if (!file_exists($filename)) {
             $this->logger('delete', 'WARNING: file not found : ' . $filename);
             continue;
         }
         $this->logger('delete', $filename);
         unlink($filename);
     }
     $this->logger('sweepNS', '[metadir]');
     io_sweepNS($pageId, 'metadir');
 }
开发者ID:yurii-github,项目名称:dokuwiki-plugin-yktools,代码行数:17,代码来源:Edit.php

示例12: moveMedia

 /**
  * Execute a media file move/rename
  *
  * @param string $src original ID
  * @param string $dst new ID
  * @return bool true if the move was successfully executed
  */
 public function moveMedia($src, $dst)
 {
     if (!$this->checkMedia($src, $dst)) {
         return false;
     }
     // get all pages using this media
     $affected_pages = idx_get_indexer()->lookupKey('relation_media', $src);
     $src_ns = getNS($src);
     $src_name = noNS($src);
     $dst_ns = getNS($dst);
     $dst_name = noNS($dst);
     // pass this info on to other plugins
     $eventdata = array('opts' => array('ns' => $src_ns, 'name' => $src_name, 'newns' => $dst_ns, 'newname' => $dst_name), 'affected_pages' => &$affected_pages, 'src_id' => $src, 'dst_id' => $dst);
     // give plugins the option to add their own meta files to the list of files that need to be moved
     // to the oldfiles/newfiles array or to adjust their own metadata, database, ...
     // and to add other pages to the affected pages
     $event = new Doku_Event('PLUGIN_MOVE_MEDIA_RENAME', $eventdata);
     if ($event->advise_before()) {
         /** @var helper_plugin_move_file $FileMover */
         $FileMover = plugin_load('helper', 'move_file');
         /** @var helper_plugin_move_rewrite $Rewriter */
         $Rewriter = plugin_load('helper', 'move_rewrite');
         // Move the Subscriptions & Indexes (new feature since Spring 2013 release)
         $Indexer = idx_get_indexer();
         if (($idx_msg = $Indexer->renameMetaValue('relation_media', $src, $dst)) !== true) {
             msg(sprintf($this->getLang('indexerror'), $idx_msg), -1);
             return false;
         }
         if (!$FileMover->moveMediaMeta($src_ns, $src_name, $dst_ns, $dst_name)) {
             msg(sprintf($this->getLang('mediametamoveerror'), $src), -1);
             return false;
         }
         // prepare directory
         io_createNamespace($dst, 'media');
         // move it FIXME this does not create a changelog entry!
         if (!io_rename(mediaFN($src), mediaFN($dst))) {
             msg(sprintf($this->getLang('mediamoveerror'), $src), -1);
             return false;
         }
         // clean up old ns
         io_sweepNS($src, 'mediadir');
         // Move the old revisions
         if (!$FileMover->moveMediaAttic($src_ns, $src_name, $dst_ns, $dst_name)) {
             // it's too late to stop the move, so just display a message.
             msg(sprintf($this->getLang('mediaatticmoveerror'), $src), -1);
         }
         // Add meta data to all affected pages, so links get updated later
         foreach ($affected_pages as $id) {
             $Rewriter->setMoveMeta($id, $src, $dst, 'media');
         }
     }
     $event->advise_after();
     // store this for later use
     $this->affectedPages = $affected_pages;
     return true;
 }
开发者ID:kochichi,项目名称:dokuwiki-plugin-move,代码行数:63,代码来源:op.php

示例13: move_media

    /**
     * Move media file
     *
     * @author  Michael Hamann <michael@content-space.de>
     *
     * @param array $opts
     * @param bool  $checkonly Only execute the checks if the media file can be moved
     * @return bool If the move was executed
     */
    public function move_media(&$opts, $checkonly = false) {
        $opts['id'] = cleanID($opts['ns'].':'.$opts['name']);
        $opts['path'] = mediaFN($opts['id']);

        // Check we have rights to move this document
        if ( !file_exists(mediaFN($opts['id']))) {
            msg(sprintf($this->getLang('medianotexist'), hsc($opts['id'])), -1);
            return false;
        }

        if ( auth_quickaclcheck($opts['ns'].':*') < AUTH_DELETE ) {
            msg(sprintf($this->getLang('nomediarights'), hsc($opts['id'])), -1);
            return false;
        }

        // Assemble media name and path
        $opts['new_id'] = cleanID($opts['newns'].':'.$opts['newname']);
        $opts['new_path'] = mediaFN($opts['new_id']);

        // Has the document name and/or namespace changed?
        if ( $opts['newns'] == $opts['ns'] && $opts['newname'] == $opts['name'] ) {
            msg($this->getLang('nomediachange'), -1);
            return false;
        }
        // Check the page does not already exist
        if ( @file_exists($opts['new_path']) ) {
            msg(sprintf($this->getLang('mediaexisting'), $opts['newname'], ($opts['newns'] == '' ? $this->getLang('root') : $opts['newns'])), -1);
            return false;
        }

        // Check if the current user can create the new page
        if (auth_quickaclcheck($opts['new_ns'].':*') < AUTH_UPLOAD) {
            msg(sprintf($this->getLang('nomediatargetperms'), $opts['new_id']), -1);
            return false;
        }

        if ($checkonly) return true;

        /**
         * End of init (checks)
         */

        $affected_pages = idx_get_indexer()->lookupKey('relation_media', $opts['id']);

        $data = array('opts' => &$opts, 'affected_pages' => &$affected_pages);
        // give plugins the option to add their own meta files to the list of files that need to be moved
        // to the oldfiles/newfiles array or to adjust their own metadata, database, ...
        // and to add other pages to the affected pages
        $event = new Doku_Event('PLUGIN_MOVE_MEDIA_RENAME', $data);
        if ($event->advise_before()) {
            // Move the Subscriptions & Indexes
            if (method_exists('Doku_Indexer', 'renamePage')) { // new feature since Spring 2013 release
                $Indexer = idx_get_indexer();
            } else {
                $Indexer = new helper_plugin_move_indexer(); // copy of the new code
            }
            if (($idx_msg = $Indexer->renameMetaValue('relation_media', $opts['id'], $opts['new_id'])) !== true) {
                msg('Error while updating the search index '.$idx_msg, -1);
                return false;
            }
            if (!$this->movemediameta($opts)) {
                msg('The meta files of the media file '.$opts['id'].' couldn\'t be moved', -1);
                return false;
            }

            // prepare directory
            io_createNamespace($opts['new_id'], 'media');

            if (!io_rename($opts['path'], $opts['new_path'])) {
                msg('Moving the media file '.$opts['id'].' failed', -1);
                return false;
            }

            io_sweepNS($opts['id'], 'mediadir');

            // Move the old revisions
            if (!$this->movemediaattic($opts)) {
                // it's too late to stop the move, so just display a message.
                msg('The attic files of media file '.$opts['id'].' couldn\'t be moved. Please move them manually.', -1);
            }

            foreach ($affected_pages as $id) {
                if (!page_exists($id, '', false)) continue;
                $meta = $this->getMoveMeta($id);
                if (!$meta) $meta = array('media_moves' => array());
                if (!isset($meta['media_moves'])) $meta['media_moves'] = array();
                $meta['media_moves'] = $this->resolve_moves($meta['media_moves'], '__');
                $meta['media_moves'][$opts['id']] = $opts['new_id'];
                //if (empty($meta['moves'])) unset($meta['moves']);
                p_set_metadata($id, array('plugin_move' => $meta), false, true);
            }
//.........这里部分代码省略.........
开发者ID:neutrinog,项目名称:Door43,代码行数:101,代码来源:helper.php

示例14: _custom_delete_page

 function _custom_delete_page($id, $summary)
 {
     global $ID, $INFO, $conf;
     // mark as nonexist to prevent indexerWebBug
     if ($id == $ID) {
         $INFO['exists'] = 0;
     }
     // delete page, meta and attic
     $file = wikiFN($id);
     $old = @filemtime($file);
     // from page
     if (file_exists($file)) {
         unlink($file);
     }
     $opts['oldname'] = $this->_FN(noNS($id));
     $opts['oldns'] = $this->_FN(getNS($id));
     if ($opts['oldns']) {
         $opts['oldns'] .= '/';
     }
     $this->_locate_filepairs($opts, 'metadir', '/^' . $opts['oldname'] . '\\.(?!mlist)\\w*?$/');
     $this->_locate_filepairs($opts, 'olddir', '/^' . $opts['oldname'] . '\\.\\d{10}\\.txt(\\.gz|\\.bz2)?$/');
     $this->_apply_deletes($opts);
     io_sweepNS($id, 'datadir');
     io_sweepNS($id, 'metadir');
     io_sweepNS($id, 'olddir');
     // send notify mails
     notify($id, 'admin', $old, $summary);
     notify($id, 'subscribers', $old, $summary);
     // update the purgefile (timestamp of the last time anything within the wiki was changed)
     io_saveFile($conf['cachedir'] . '/purgefile', time());
     // if useheading is enabled, purge the cache of all linking pages
     if (useHeading('content')) {
         $pages = ft_backlinks($id);
         foreach ($pages as $page) {
             $cache = new cache_renderer($page, wikiFN($page), 'xhtml');
             $cache->removeCache();
         }
     }
 }
开发者ID:houshuang,项目名称:folders2web,代码行数:39,代码来源:action.php

示例15: media_delete

/**
 * Handles media file deletions
 *
 * If configured, checks for media references before deletion
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 * @return mixed false on error, true on delete or array with refs
 */
function media_delete($id, $auth)
{
    if ($auth < AUTH_DELETE) {
        return false;
    }
    if (!checkSecurityToken()) {
        return false;
    }
    global $conf;
    global $lang;
    // check for references if needed
    $mediareferences = array();
    if ($conf['refcheck']) {
        require_once DOKU_INC . 'inc/fulltext.php';
        $mediareferences = ft_mediause($id, $conf['refshow']);
    }
    if (!count($mediareferences)) {
        $file = mediaFN($id);
        if (@unlink($file)) {
            msg(str_replace('%s', noNS($id), $lang['deletesucc']), 1);
            $del = io_sweepNS($id, 'mediadir');
            if ($del) {
                // current namespace was removed. redirecting to root ns passing msg along
                header('Location: ' . DOKU_URL . 'lib/exe/mediamanager.php?msg1=' . rawurlencode(str_replace('%s', noNS($id), $lang['deletesucc'])));
                exit;
            }
            return true;
        }
        //something went wrong
        msg(str_replace('%s', $file, $lang['deletefail']), -1);
        return false;
    } elseif (!$conf['refshow']) {
        msg(str_replace('%s', noNS($id), $lang['mediainuse']), 0);
        return false;
    }
    return $mediareferences;
}
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:45,代码来源:media.php


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