@param string $snippet
@param array  $params

@throws \Http\Client\Exception

@return array
430437
public function update(string $snippet, array $params = [])
    {
        $path = $this->buildUsersPath($snippet);

        return $this->post($path, $params);
    }
768170
public void deleteSnippet(Integer snippetId) throws GitLabApiException {

        if (snippetId == null) {
            throw new RuntimeException("snippetId can't be null");
        }

        delete(Response.Status.NO_CONTENT, null, "snippets", snippetId);
    }
1173555
public function getHtmlToutesLesActualites($params = array())
	{
		$html = "<h1>"._("Actualités")."</h1>";

		$d = new dateObject();
		$pagination = new paginationObject();
		$resDernieresActualites = $this->getDernieresActualites(array('sqlFields'=>'0', "returnAsMysqlRes"=>true));
		$nbEnregistrementTotaux = mysql_num_rows($resDernieresActualites);


		$nbEnregistrementsParPage=15;

		$arrayPagination=$pagination->pagination(
				array(
						'nomParamPageCourante'=>'page',
						'nbEnregistrementsParPage'=>$nbEnregistrementsParPage,
						'nbEnregistrementsTotaux'=>$nbEnregistrementTotaux,
						'typeLiens'=>'noformulaire'
				)
		);



		$arrayActus = $this->getDernieresActualites(array("sqlWhere"=>" AND desactive<>'1' ", "sqlLimit"=>"LIMIT ".mysql_real_escape_string($arrayPagination['limitSqlDebut']).", ".$nbEnregistrementsParPage));

		$tab = new tableau();

		foreach ($arrayActus as $indice => $value) {
			if ($value['urlFichier']!='') {
				$url = $value['urlFichier'];
			} else {
				$url = $this->creerUrl('', 'afficherActualite', array('archiIdActualite'=>$value['idActualite']));
			}

			$tab->addValue("<a href='".$url."'>".$d->toFrenchAffichage($value['date'])." ".stripslashes($value['titre'])."</a>");

			if ($value['photoIllustration']!='') {
				list($w, $h) = getimagesize(
						$this->getCheminPhysique()."images/actualites/".
						$value['idActualite']."/".$value['photoIllustration']
				);
				if ($w>$h) {
					$dimension = "width=80";
				} else {
					$dimension = "height=80";
				}

				$tab->addValue(
						"<img src='".$this->urlImages."actualites/".
						$value['idActualite']."/".
						$value['photoIllustration']."' $dimension>"
				);
			} else {
				$tab->addValue("&nbsp;");
			}
		}

		$html.=$arrayPagination['html'];
		$html.=$tab->createHtmlTableFromArray(
				2, 'margin:0;padding:0;', '', '', " border=''"
		);


		return $html;

	}
860575
public function snippet($field, $tag = 'b', $separator = '...', $maxSize = 200, $maxNumber = 1, $fragmenter = self::SNIPPET_NO_FRAGMENTER) {
		if(empty($this->data['snippets'])) {
			$this->data['snippets'] = array();
		}
		$this->data['snippets'][] = array(
			'field' => $field,
			'tag' => $tag,
			'separator' => $separator,
			'maxSize' => $maxSize,
			'maxNumber' => $maxNumber,
			'fragmenter' => $fragmenter,
		);
		return $this;
	}
193062
private function thumbnail(array $params)
    {
        $mode = isset($params['mode']) ? $params['mode'] : self::THUMBNAIL_OUTBOUND;

        $width = (isset($params['width']) && is_numeric($params['width'])) ? $params['width'] : null;
        $height = (isset($params['height']) && is_numeric($params['height'])) ? $params['height'] : null;

        if (is_null($width) || is_null($height)) {
            throw new Exception('Wrong thumbnail width or height');
        }

        $this->image = $this->image->thumbnail(new Box($width, $height), $mode);
    }
1306985
public function getField($identifier, $fieldName) {
        $snippetModel = $this->_getSnippetModel();
        $snippet = $snippetModel->fetchByIdentifier($identifier);

        if (!isset($snippet->{$fieldName})) {
            throw new Exception(sprintf(self::EXCEPTION_MISSING_FIELD, $snippet->id, $fieldName));
        }
        return $snippet->{$fieldName};
    }
457258
public function setSnippets( $snippets )
    {
        if ( is_string( $snippets ) )
        {
            $snippets = explode( "\n", $snippets );
        }
        else if ( is_null( $snippets ) || is_scalar( $snippets ) )
        {
            $snippets = (array) $snippets;
        }

        $this->snippets = array_unique(
            array_map(
                'strval',
                array_filter( ArrayUtils::iteratorToArray( $snippets ) )
            )
        );

        return $this;
    }
209010
static function snippet($text, $keywords, $limit, $max_length, $around = array('<b>', '</b>'))
	{
		$result = array();

		$keywords = self::normalize($keywords);
		list($pre, $post) = $around;
		$prev = array();
		$after = false;

		foreach(self::normalize_hash($text) as $word_orig => $word_norm)
		{
			$is_kw = false;
			if(in_array($word_norm, $keywords))
			{
				$prev[] = $pre.$word_orig.$post;
				$is_kw = true;
			}
			else
				$prev[] = $word_orig;

			if($is_kw)
			{
				if($after)
				{
					$result = array_merge($result, $prev);
					$prev = array();
				}
				else
				{
					$result = array_merge($result, count($prev) > $limit ? array('&#133') : array(), array_slice($prev, -$limit-1));
					$prev = array();
				}

				$after = true;
			}
			else
			{
				if($after && count($prev) >= $limit)
				{
					$after = false;
					$result = array_merge($result, $prev);
					$prev = array();
				}
			}
		}

		if($after)
			$result = array_merge($result, array('&#133'), $prev);

		return strip_text(join(' ', $result).'&#133;', $max_length);
	}
261937
public String getSnippetContent(Integer snippetId) throws GitLabApiException {
        Response response = get(Response.Status.OK, null, "snippets", snippetId, "raw");
        return (response.readEntity(String.class));
    }
1181740
def visit_snippet(self, node):
    
    lang = self.highlightlang
    linenos = node.rawsource.count('\n') >= self.highlightlinenothreshold - 1
    fname = node['filename']
    highlight_args = node.get('highlight_args', {})
    if 'language' in node:
        # code-block directives
        lang = node['language']
        highlight_args['force'] = True
    if 'linenos' in node:
        linenos = node['linenos']

    def warner(msg):
        self.builder.warn(msg, (self.builder.current_docname, node.line))

    highlighted = self.highlighter.highlight_block(node.rawsource, lang,
                                                   warn=warner,
                                                   linenos=linenos,
                                                   **highlight_args)
    starttag = self.starttag(node, 'div', suffix='',
                             CLASS='highlight-%s snippet' % lang)
    self.body.append(starttag)
    self.body.append('<div class="snippet-filename">%s</div>\n''' % (fname,))
    self.body.append(highlighted)
    self.body.append('</div>\n')
    raise nodes.SkipNode
879692
private function appendSnippet(AggregateSnippet $snippet)
    {
        foreach ($this->appenders as $appender) {
            if (!$appender->supportsSnippet($snippet)) {
                continue;
            }

            $appender->appendSnippet($snippet);
        }
    }
256140
function (snippets, options) {
    if (typeof snippets === 'string') {
      var glob = lazy.glob();
      var files = glob.sync(snippets, options);
      files.forEach(function (fp) {
        var key = fp.split('.').join('\\.');
        this.set(key, {path: fp});
      }.bind(this));
    }
    return this;
  }
833443
def deletesnippet(self, project_id, snippet_id):
        
        request = requests.delete(
            '{0}/{1}/snippets/{2}'.format(self.projects_url, project_id, snippet_id),
            headers=self.headers, verify=self.verify_ssl, auth=self.auth, timeout=self.timeout)

        return request.status_code == 200
420406
public function getAction(Request $request, $id = null)
    {
        $locale = $this->getLocale($request);

        $snippet = $this->findDocument($id, $locale);
        $view = View::create($snippet);

        return $this->viewHandler->handle($view);
    }
146877
public function add($snippet, Callable $callable=null) {
		if (is_object($snippet) && $snippet instanceof Snippets) {
			$this->addSnippetClass($snippet);
		}
		if (is_string($snippet) && is_callable($callable)) {
			// '$snippet' is a tag name: register $callable
			$this->snippets[$snippet] = $callable;
		}
	}
540800
public function export_snippet(SS_HTTPRequest $request) {
        if($request->getVar('s')) {
            //Use the session id in the request
            Session::start($request->getVar('s'));
        }
        
        
        if(!Permission::check('CODE_BANK_ACCESS')) {
            header("HTTP/1.1 401 Unauthorized");
            
            
            //Save session and exit
            Session::save();
            exit;
        }
        
        
        try {
            $snippet=Snippet::get()->byID(intval($request->getVar('id')));
            if(empty($snippet) || $snippet===false || $snippet->ID==0) {
                header("HTTP/1.1 404 Not Found");
                
                
                //Save session and exit
                Session::save();
                exit;
            }
            
            
            $urlFilter=URLSegmentFilter::create();
            $fileID=$urlFilter->filter($snippet->Title);
            
            
            //If the temp dir doesn't exist create it
            if(!file_exists(ASSETS_PATH.'/.codeBankTemp')) {
                mkdir(ASSETS_PATH.'/.codeBankTemp', Config::inst()->get('Filesystem', 'folder_create_mask'));
            }
            
            
            if($snippet->Language()->Name=='ActionScript 3') {
                $zip=new ZipArchive();
                
                $res=$zip->open(ASSETS_PATH.'/.codeBankTemp/'.$fileID.'.zip', ZIPARCHIVE::CREATE);
                
                if($res===true) {
                    $path='';
                    $text=preg_split("/[\n\r]/", $snippet->getSnippetText());
                    $folder=str_replace('.', '/', trim(preg_replace('/^package (.*?)((\s*)\{)?$/i', '\\1', $text[0])));
                    
                    $className=array_values(preg_grep('/(\s*|\t*)public(\s+)class(\s+)(.*?)(\s*)((extends|implements)(.*?)(\s*))*\{/i', $text));
                    
                    if(count($className)==0) {
                        throw new Exception('Class definition could not be found');
                    }
                    
                    $className=trim(preg_replace('/(\s*|\t*)public(\s+)class(\s+)(.*?)(\s*)((extends|implements)(.*?)(\s*))*\{/i','\\4', $className[0]));
                    
                    if($className=="") {
                        throw new Exception('Class definition could not be found');
                    }
                    
                    $zip->addFromString($folder.'/'.$className.'.'.$snippet->Language()->FileExtension, $snippet->getSnippetText());
                    
                    if($zip->Close()!==false) {
                        chmod(ASSETS_PATH.'/.codeBankTemp/'.$fileID.'.zip',0600);
                        
                        
                        //Send File
                        SS_HTTPRequest::send_file(file_get_contents(ASSETS_PATH.'/.codeBankTemp/'.$fileID.'.zip'), $fileID.'.zip', 'application/octet-stream')->output();
                        unlink(ASSETS_PATH.'/.codeBankTemp/'.$fileID.'.zip');
                    }else {
                        header("HTTP/1.1 500 Internal Server Error");
                    }
                }else {
                    header("HTTP/1.1 500 Internal Server Error");
                }
            }else {
                SS_HTTPRequest::send_file($snippet->getSnippetText(), $fileID.'.'.$snippet->Language()->FileExtension, 'text/plain')->output();
            }
        }catch (Exception $e) {
            header("HTTP/1.1 500 Internal Server Error");
        }
        
        
        //Save session and exit
        Session::save();
        exit;
    }
1026975
private function logSnippetAddition(AggregateSnippet $snippet, $path)
    {
        if (!$this->logger) {
            return;
        }

        $steps = $snippet->getSteps();
        $reason = sprintf("`<comment>%s</comment>` definition added", $steps[0]->getText());

        $this->logger->fileUpdated($path, $reason);
    }