repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
yeephp/yeephp
Yee/Yee.php
Yee.config
public function config($name, $value = null) { $c = $this->container; if (is_array($name)) { if (true === $value) { $c['settings'] = array_merge_recursive($c['settings'], $name); } else { $c['settings'] = array_merge($c['settings'], $name); } } elseif (func_num_args() === 1) { return isset($c['settings'][$name]) ? $c['settings'][$name] : null; } else { $settings = $c['settings']; $settings[$name] = $value; $c['settings'] = $settings; } }
php
public function config($name, $value = null) { $c = $this->container; if (is_array($name)) { if (true === $value) { $c['settings'] = array_merge_recursive($c['settings'], $name); } else { $c['settings'] = array_merge($c['settings'], $name); } } elseif (func_num_args() === 1) { return isset($c['settings'][$name]) ? $c['settings'][$name] : null; } else { $settings = $c['settings']; $settings[$name] = $value; $c['settings'] = $settings; } }
[ "public", "function", "config", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "$", "c", "=", "$", "this", "->", "container", ";", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "if", "(", "true", "===", "$", "value", ")",...
Configure Yee Settings This method defines application settings and acts as a setter and a getter. If only one argument is specified and that argument is a string, the value of the setting identified by the first argument will be returned, or NULL if that setting does not exist. If only one argument is specified and that argument is an associative array, the array will be merged into the existing application settings. If two arguments are provided, the first argument is the name of the setting to be created or updated, and the second argument is the setting value. @param string|array $name If a string, the name of the setting to set or retrieve. Else an associated array of setting names and values @param mixed $value If name is a string, the value of the setting identified by $name @return mixed The value of a setting if only one argument is a string
[ "Configure", "Yee", "Settings" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L343-L360
yeephp/yeephp
Yee/Yee.php
Yee.mapRoute
protected function mapRoute($args) { $pattern = array_shift($args); $callable = array_pop($args); $route = new \Yee\Route($pattern, $callable, $this->settings['routes.case_sensitive']); $this->router->map($route); if (count($args) > 0) { $route->setMiddleware($args); } return $route; }
php
protected function mapRoute($args) { $pattern = array_shift($args); $callable = array_pop($args); $route = new \Yee\Route($pattern, $callable, $this->settings['routes.case_sensitive']); $this->router->map($route); if (count($args) > 0) { $route->setMiddleware($args); } return $route; }
[ "protected", "function", "mapRoute", "(", "$", "args", ")", "{", "$", "pattern", "=", "array_shift", "(", "$", "args", ")", ";", "$", "callable", "=", "array_pop", "(", "$", "args", ")", ";", "$", "route", "=", "new", "\\", "Yee", "\\", "Route", "(...
Add GET|POST|PUT|PATCH|DELETE route Adds a new route to the router with associated callable. This route will only be invoked when the HTTP request's method matches this route's method. ARGUMENTS: First: string The URL pattern (REQUIRED) In-Between: mixed Anything that returns TRUE for `is_callable` (OPTIONAL) Last: mixed Anything that returns TRUE for `is_callable` (REQUIRED) The first argument is required and must always be the route pattern (ie. '/books/:id'). The last argument is required and must always be the callable object to be invoked when the route matches an HTTP request. You may also provide an unlimited number of in-between arguments; each interior argument must be callable and will be invoked in the order specified before the route's callable is invoked. USAGE: Yee::get('/foo'[, middleware, middleware, ...], callable); @param array (See notes above) @return \Yee\Route
[ "Add", "GET|POST|PUT|PATCH|DELETE", "route" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L446-L457
yeephp/yeephp
Yee/Yee.php
Yee.put
public function put() { $args = func_get_args(); return $this->mapRoute($args)->via(\Yee\Http\Request::METHOD_PUT); }
php
public function put() { $args = func_get_args(); return $this->mapRoute($args)->via(\Yee\Http\Request::METHOD_PUT); }
[ "public", "function", "put", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "return", "$", "this", "->", "mapRoute", "(", "$", "args", ")", "->", "via", "(", "\\", "Yee", "\\", "Http", "\\", "Request", "::", "METHOD_PUT", ")", ";"...
Add PUT route @see mapRoute() @return \Yee\Route
[ "Add", "PUT", "route" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L500-L505
yeephp/yeephp
Yee/Yee.php
Yee.patch
public function patch() { $args = func_get_args(); return $this->mapRoute($args)->via(\Yee\Http\Request::METHOD_PATCH); }
php
public function patch() { $args = func_get_args(); return $this->mapRoute($args)->via(\Yee\Http\Request::METHOD_PATCH); }
[ "public", "function", "patch", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "return", "$", "this", "->", "mapRoute", "(", "$", "args", ")", "->", "via", "(", "\\", "Yee", "\\", "Http", "\\", "Request", "::", "METHOD_PATCH", ")", ...
Add PATCH route @see mapRoute() @return \Yee\Route
[ "Add", "PATCH", "route" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L512-L517
yeephp/yeephp
Yee/Yee.php
Yee.error
public function error($argument = null) { if (is_callable($argument)) { //Register error handler $this->error = $argument; } else { //Invoke error handler $this->response->status(500); $this->response->body(''); $this->response->write($this->callErrorHandler($argument)); $this->stop(); } }
php
public function error($argument = null) { if (is_callable($argument)) { //Register error handler $this->error = $argument; } else { //Invoke error handler $this->response->status(500); $this->response->body(''); $this->response->write($this->callErrorHandler($argument)); $this->stop(); } }
[ "public", "function", "error", "(", "$", "argument", "=", "null", ")", "{", "if", "(", "is_callable", "(", "$", "argument", ")", ")", "{", "//Register error handler", "$", "this", "->", "error", "=", "$", "argument", ";", "}", "else", "{", "//Invoke erro...
Error Handler This method defines or invokes the application-wide Error handler. There are two contexts in which this method may be invoked: 1. When declaring the handler: If the $argument parameter is callable, this method will register the callable to be invoked when an uncaught Exception is detected, or when otherwise explicitly invoked. The handler WILL NOT be invoked in this context. 2. When invoking the handler: If the $argument parameter is not callable, Yee assumes you want to invoke an already-registered handler. If the handler has been registered and is callable, it is invoked and passed the caught Exception as its one and only argument. The error handler's output is captured into an output buffer and sent as the body of a 500 HTTP Response. @param mixed $argument Callable|\Exception
[ "Error", "Handler" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L636-L648
yeephp/yeephp
Yee/Yee.php
Yee.callErrorHandler
protected function callErrorHandler($argument = null) { ob_start(); if (is_callable($this->error)) { call_user_func_array($this->error, array($argument)); } else { call_user_func_array(array($this, 'defaultError'), array($argument)); } return ob_get_clean(); }
php
protected function callErrorHandler($argument = null) { ob_start(); if (is_callable($this->error)) { call_user_func_array($this->error, array($argument)); } else { call_user_func_array(array($this, 'defaultError'), array($argument)); } return ob_get_clean(); }
[ "protected", "function", "callErrorHandler", "(", "$", "argument", "=", "null", ")", "{", "ob_start", "(", ")", ";", "if", "(", "is_callable", "(", "$", "this", "->", "error", ")", ")", "{", "call_user_func_array", "(", "$", "this", "->", "error", ",", ...
Call error handler This will invoke the custom or default error handler and RETURN its output. @param \Exception|null $argument @return string
[ "Call", "error", "handler" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L659-L669
yeephp/yeephp
Yee/Yee.php
Yee.lastModified
public function lastModified($time) { if (is_integer($time)) { $this->response->headers->set('Last-Modified', gmdate('D, d M Y H:i:s T', $time)); if ($time === strtotime($this->request->headers->get('IF_MODIFIED_SINCE'))) { $this->halt(304); } } else { throw new \InvalidArgumentException('Yee::lastModified only accepts an integer UNIX timestamp value.'); } }
php
public function lastModified($time) { if (is_integer($time)) { $this->response->headers->set('Last-Modified', gmdate('D, d M Y H:i:s T', $time)); if ($time === strtotime($this->request->headers->get('IF_MODIFIED_SINCE'))) { $this->halt(304); } } else { throw new \InvalidArgumentException('Yee::lastModified only accepts an integer UNIX timestamp value.'); } }
[ "public", "function", "lastModified", "(", "$", "time", ")", "{", "if", "(", "is_integer", "(", "$", "time", ")", ")", "{", "$", "this", "->", "response", "->", "headers", "->", "set", "(", "'Last-Modified'", ",", "gmdate", "(", "'D, d M Y H:i:s T'", ","...
Set Last-Modified HTTP Response Header Set the HTTP 'Last-Modified' header and stop if a conditional GET request's `If-Modified-Since` header matches the last modified time of the resource. The `time` argument is a UNIX timestamp integer value. When the current request includes an 'If-Modified-Since' header that matches the specified last modified time, the application will stop and send a '304 Not Modified' response to the client. @param int $time The last modified UNIX timestamp @throws \InvalidArgumentException If provided timestamp is not an integer
[ "Set", "Last", "-", "Modified", "HTTP", "Response", "Header" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L784-L794
yeephp/yeephp
Yee/Yee.php
Yee.expires
public function expires($time) { if (is_string($time)) { $time = strtotime($time); } $this->response->headers->set('Expires', gmdate('D, d M Y H:i:s T', $time)); }
php
public function expires($time) { if (is_string($time)) { $time = strtotime($time); } $this->response->headers->set('Expires', gmdate('D, d M Y H:i:s T', $time)); }
[ "public", "function", "expires", "(", "$", "time", ")", "{", "if", "(", "is_string", "(", "$", "time", ")", ")", "{", "$", "time", "=", "strtotime", "(", "$", "time", ")", ";", "}", "$", "this", "->", "response", "->", "headers", "->", "set", "("...
Set Expires HTTP response header The `Expires` header tells the HTTP client the time at which the current resource should be considered stale. At that time the HTTP client will send a conditional GET request to the server; the server may return a 200 OK if the resource has changed, else a 304 Not Modified if the resource has not changed. The `Expires` header should be used in conjunction with the `etag()` or `lastModified()` methods above. @param string|int $time If string, a time to be parsed by `strtotime()`; If int, a UNIX timestamp;
[ "Set", "Expires", "HTTP", "response", "header" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L848-L854
yeephp/yeephp
Yee/Yee.php
Yee.getCookie
public function getCookie($name, $deleteIfInvalid = true) { // Get cookie value $value = $this->request->cookies->get($name); // Decode if encrypted if ($this->config('cookies.encrypt')) { $value = \Yee\Http\Util::decodeSecureCookie( $value, $this->config('cookies.secret_key'), $this->config('cookies.cipher'), $this->config('cookies.cipher_mode') ); if ($value === false && $deleteIfInvalid) { $this->deleteCookie($name); } } return $value; }
php
public function getCookie($name, $deleteIfInvalid = true) { // Get cookie value $value = $this->request->cookies->get($name); // Decode if encrypted if ($this->config('cookies.encrypt')) { $value = \Yee\Http\Util::decodeSecureCookie( $value, $this->config('cookies.secret_key'), $this->config('cookies.cipher'), $this->config('cookies.cipher_mode') ); if ($value === false && $deleteIfInvalid) { $this->deleteCookie($name); } } return $value; }
[ "public", "function", "getCookie", "(", "$", "name", ",", "$", "deleteIfInvalid", "=", "true", ")", "{", "// Get cookie value", "$", "value", "=", "$", "this", "->", "request", "->", "cookies", "->", "get", "(", "$", "name", ")", ";", "// Decode if encrypt...
Get value of HTTP cookie from the current HTTP request Return the value of a cookie from the current HTTP request, or return NULL if cookie does not exist. Cookies created during the current request will not be available until the next request. @param string $name @param bool $deleteIfInvalid @return string|null
[ "Get", "value", "of", "HTTP", "cookie", "from", "the", "current", "HTTP", "request" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L898-L917
yeephp/yeephp
Yee/Yee.php
Yee.setEncryptedCookie
public function setEncryptedCookie($name, $value, $expires = null, $path = null, $domain = null, $secure = false, $httponly = false) { $this->setCookie($name, $value, $expires, $path, $domain, $secure, $httponly); }
php
public function setEncryptedCookie($name, $value, $expires = null, $path = null, $domain = null, $secure = false, $httponly = false) { $this->setCookie($name, $value, $expires, $path, $domain, $secure, $httponly); }
[ "public", "function", "setEncryptedCookie", "(", "$", "name", ",", "$", "value", ",", "$", "expires", "=", "null", ",", "$", "path", "=", "null", ",", "$", "domain", "=", "null", ",", "$", "secure", "=", "false", ",", "$", "httponly", "=", "false", ...
DEPRECATION WARNING! Use `setCookie` with the `cookies.encrypt` app setting set to `true`. Set encrypted HTTP cookie @param string $name The cookie name @param mixed $value The cookie value @param mixed $expires The duration of the cookie; If integer, should be UNIX timestamp; If string, converted to UNIX timestamp with `strtotime`; @param string $path The path on the server in which the cookie will be available on @param string $domain The domain that the cookie is available to @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client @param bool $httponly When TRUE the cookie will be made accessible only through the HTTP protocol
[ "DEPRECATION", "WARNING!", "Use", "setCookie", "with", "the", "cookies", ".", "encrypt", "app", "setting", "set", "to", "true", "." ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L935-L938
yeephp/yeephp
Yee/Yee.php
Yee.deleteCookie
public function deleteCookie($name, $path = null, $domain = null, $secure = null, $httponly = null) { $settings = array( 'domain' => is_null($domain) ? $this->config('cookies.domain') : $domain, 'path' => is_null($path) ? $this->config('cookies.path') : $path, 'secure' => is_null($secure) ? $this->config('cookies.secure') : $secure, 'httponly' => is_null($httponly) ? $this->config('cookies.httponly') : $httponly ); $this->response->cookies->remove($name, $settings); }
php
public function deleteCookie($name, $path = null, $domain = null, $secure = null, $httponly = null) { $settings = array( 'domain' => is_null($domain) ? $this->config('cookies.domain') : $domain, 'path' => is_null($path) ? $this->config('cookies.path') : $path, 'secure' => is_null($secure) ? $this->config('cookies.secure') : $secure, 'httponly' => is_null($httponly) ? $this->config('cookies.httponly') : $httponly ); $this->response->cookies->remove($name, $settings); }
[ "public", "function", "deleteCookie", "(", "$", "name", ",", "$", "path", "=", "null", ",", "$", "domain", "=", "null", ",", "$", "secure", "=", "null", ",", "$", "httponly", "=", "null", ")", "{", "$", "settings", "=", "array", "(", "'domain'", "=...
Delete HTTP cookie (encrypted or unencrypted) Remove a Cookie from the client. This method will overwrite an existing Cookie with a new, empty, auto-expiring Cookie. This method's arguments must match the original Cookie's respective arguments for the original Cookie to be removed. If any of this method's arguments are omitted or set to NULL, the default Cookie setting values (set during Yee::init) will be used instead. @param string $name The cookie name @param string $path The path on the server in which the cookie will be available on @param string $domain The domain that the cookie is available to @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client @param bool $httponly When TRUE the cookie will be made accessible only through the HTTP protocol
[ "Delete", "HTTP", "cookie", "(", "encrypted", "or", "unencrypted", ")" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L974-L983
yeephp/yeephp
Yee/Yee.php
Yee.halt
public function halt($status, $message = '') { $this->cleanBuffer(); $this->response->status($status); $this->response->body($message); $this->stop(); }
php
public function halt($status, $message = '') { $this->cleanBuffer(); $this->response->status($status); $this->response->body($message); $this->stop(); }
[ "public", "function", "halt", "(", "$", "status", ",", "$", "message", "=", "''", ")", "{", "$", "this", "->", "cleanBuffer", "(", ")", ";", "$", "this", "->", "response", "->", "status", "(", "$", "status", ")", ";", "$", "this", "->", "response",...
Halt Stop the application and immediately send the response with a specific status and body to the HTTP client. This may send any type of response: info, success, redirect, client error, or server error. If you need to render a template AND customize the response status, use the application's `render()` method instead. @param int $status The HTTP response status @param string $message The HTTP response body
[ "Halt" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L1039-L1045
yeephp/yeephp
Yee/Yee.php
Yee.urlFor
public function urlFor($name, $params = array()) { return $this->request->getRootUri() . $this->router->urlFor($name, $params); }
php
public function urlFor($name, $params = array()) { return $this->request->getRootUri() . $this->router->urlFor($name, $params); }
[ "public", "function", "urlFor", "(", "$", "name", ",", "$", "params", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "request", "->", "getRootUri", "(", ")", ".", "$", "this", "->", "router", "->", "urlFor", "(", "$", "name", ",", ...
Get the URL for a named route @param string $name The route name @param array $params Associative array of URL parameters and replacement values @throws \RuntimeException If named route does not exist @return string
[ "Get", "the", "URL", "for", "a", "named", "route" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L1087-L1090
yeephp/yeephp
Yee/Yee.php
Yee.redirect
public function redirect($url, $status = 302) { $this->response->redirect($url, $status); $this->halt($status); }
php
public function redirect($url, $status = 302) { $this->response->redirect($url, $status); $this->halt($status); }
[ "public", "function", "redirect", "(", "$", "url", ",", "$", "status", "=", "302", ")", "{", "$", "this", "->", "response", "->", "redirect", "(", "$", "url", ",", "$", "status", ")", ";", "$", "this", "->", "halt", "(", "$", "status", ")", ";", ...
Redirect This method immediately redirects to a new URL. By default, this issues a 302 Found response; this is considered the default generic redirect response. You may also specify another valid 3xx status code if you want. This method will automatically set the HTTP Location header for you using the URL parameter. @param string $url The destination URL @param int $status The HTTP redirect status code (optional)
[ "Redirect" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L1104-L1108
yeephp/yeephp
Yee/Yee.php
Yee.flash
public function flash($key, $value) { if (isset($this->environment['yee.flash'])) { $this->environment['yee.flash']->set($key, $value); } }
php
public function flash($key, $value) { if (isset($this->environment['yee.flash'])) { $this->environment['yee.flash']->set($key, $value); } }
[ "public", "function", "flash", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "environment", "[", "'yee.flash'", "]", ")", ")", "{", "$", "this", "->", "environment", "[", "'yee.flash'", "]", "->", "set", ...
Set flash message for subsequent request @param string $key @param mixed $value
[ "Set", "flash", "message", "for", "subsequent", "request" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L1119-L1124
yeephp/yeephp
Yee/Yee.php
Yee.flashNow
public function flashNow($key, $value) { if (isset($this->environment['yee.flash'])) { $this->environment['yee.flash']->now($key, $value); } }
php
public function flashNow($key, $value) { if (isset($this->environment['yee.flash'])) { $this->environment['yee.flash']->now($key, $value); } }
[ "public", "function", "flashNow", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "environment", "[", "'yee.flash'", "]", ")", ")", "{", "$", "this", "->", "environment", "[", "'yee.flash'", "]", "->", "now",...
Set flash message for current request @param string $key @param mixed $value
[ "Set", "flash", "message", "for", "current", "request" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L1131-L1136
yeephp/yeephp
Yee/Yee.php
Yee.call
public function call() { try { if (isset($this->environment['yee.flash'])) { $this->view()->setData('flash', $this->environment['yee.flash']); } $this->applyHook('yee.before'); ob_start(); $this->applyHook('yee.before.router'); $dispatched = false; $matchedRoutes = $this->router->getMatchedRoutes($this->request->getMethod(), $this->request->getResourceUri()); foreach ($matchedRoutes as $route) { try { $this->applyHook('yee.before.dispatch'); $dispatched = $route->dispatch(); $this->applyHook('yee.after.dispatch'); if ($dispatched) { break; } } catch (\Yee\Exception\Pass $e) { continue; } } if (!$dispatched) { $this->notFound(); } $this->applyHook('yee.after.router'); $this->stop(); } catch (\Yee\Exception\Stop $e) { $this->response()->write(ob_get_clean()); } catch (\Exception $e) { if ($this->config('debug')) { throw $e; } else { try { $this->error($e); } catch (\Yee\Exception\Stop $e) { // Do nothing } } } }
php
public function call() { try { if (isset($this->environment['yee.flash'])) { $this->view()->setData('flash', $this->environment['yee.flash']); } $this->applyHook('yee.before'); ob_start(); $this->applyHook('yee.before.router'); $dispatched = false; $matchedRoutes = $this->router->getMatchedRoutes($this->request->getMethod(), $this->request->getResourceUri()); foreach ($matchedRoutes as $route) { try { $this->applyHook('yee.before.dispatch'); $dispatched = $route->dispatch(); $this->applyHook('yee.after.dispatch'); if ($dispatched) { break; } } catch (\Yee\Exception\Pass $e) { continue; } } if (!$dispatched) { $this->notFound(); } $this->applyHook('yee.after.router'); $this->stop(); } catch (\Yee\Exception\Stop $e) { $this->response()->write(ob_get_clean()); } catch (\Exception $e) { if ($this->config('debug')) { throw $e; } else { try { $this->error($e); } catch (\Yee\Exception\Stop $e) { // Do nothing } } } }
[ "public", "function", "call", "(", ")", "{", "try", "{", "if", "(", "isset", "(", "$", "this", "->", "environment", "[", "'yee.flash'", "]", ")", ")", "{", "$", "this", "->", "view", "(", ")", "->", "setData", "(", "'flash'", ",", "$", "this", "-...
Call This method finds and iterates all route objects that match the current request URI.
[ "Call" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L1319-L1360
yoanm/symfony-jsonrpc-http-server
src/DependencyInjection/JsonRpcMethodDefinitionHelper.php
JsonRpcMethodDefinitionHelper.findAndValidateJsonRpcMethodDefinition
public function findAndValidateJsonRpcMethodDefinition(ContainerBuilder $container) : array { $definitionList = []; $taggedServiceList = $container->findTaggedServiceIds(JsonRpcHttpServerExtension::JSONRPC_METHOD_TAG); foreach ($taggedServiceList as $serviceId => $tagAttributeList) { $this->validateJsonRpcMethodDefinition($serviceId, $container->getDefinition($serviceId)); foreach ($tagAttributeList as $tagAttributeKey => $tagAttributeData) { $this->validateJsonRpcMethodTagAttributes($serviceId, $tagAttributeData); $methodName = $tagAttributeData[JsonRpcHttpServerExtension::JSONRPC_METHOD_TAG_METHOD_NAME_KEY]; $definitionList[$serviceId][] = $methodName; } } return $definitionList; }
php
public function findAndValidateJsonRpcMethodDefinition(ContainerBuilder $container) : array { $definitionList = []; $taggedServiceList = $container->findTaggedServiceIds(JsonRpcHttpServerExtension::JSONRPC_METHOD_TAG); foreach ($taggedServiceList as $serviceId => $tagAttributeList) { $this->validateJsonRpcMethodDefinition($serviceId, $container->getDefinition($serviceId)); foreach ($tagAttributeList as $tagAttributeKey => $tagAttributeData) { $this->validateJsonRpcMethodTagAttributes($serviceId, $tagAttributeData); $methodName = $tagAttributeData[JsonRpcHttpServerExtension::JSONRPC_METHOD_TAG_METHOD_NAME_KEY]; $definitionList[$serviceId][] = $methodName; } } return $definitionList; }
[ "public", "function", "findAndValidateJsonRpcMethodDefinition", "(", "ContainerBuilder", "$", "container", ")", ":", "array", "{", "$", "definitionList", "=", "[", "]", ";", "$", "taggedServiceList", "=", "$", "container", "->", "findTaggedServiceIds", "(", "JsonRpc...
@param ContainerBuilder $container @return array
[ "@param", "ContainerBuilder", "$container" ]
train
https://github.com/yoanm/symfony-jsonrpc-http-server/blob/e6a9df43aa1e944966a790140546b9aeb98b6a53/src/DependencyInjection/JsonRpcMethodDefinitionHelper.php#L19-L36
yoanm/symfony-jsonrpc-http-server
src/DependencyInjection/JsonRpcMethodDefinitionHelper.php
JsonRpcMethodDefinitionHelper.validateJsonRpcMethodDefinition
private function validateJsonRpcMethodDefinition(string $serviceId, Definition $definition) : void { if (!in_array(JsonRpcMethodInterface::class, class_implements($definition->getClass()))) { throw new LogicException(sprintf( 'Service "%s" is taggued as JSON-RPC method but does not implement %s', $serviceId, JsonRpcMethodInterface::class )); } }
php
private function validateJsonRpcMethodDefinition(string $serviceId, Definition $definition) : void { if (!in_array(JsonRpcMethodInterface::class, class_implements($definition->getClass()))) { throw new LogicException(sprintf( 'Service "%s" is taggued as JSON-RPC method but does not implement %s', $serviceId, JsonRpcMethodInterface::class )); } }
[ "private", "function", "validateJsonRpcMethodDefinition", "(", "string", "$", "serviceId", ",", "Definition", "$", "definition", ")", ":", "void", "{", "if", "(", "!", "in_array", "(", "JsonRpcMethodInterface", "::", "class", ",", "class_implements", "(", "$", "...
@param string $serviceId @param Definition $definition @throws \LogicException In case definition is not valid
[ "@param", "string", "$serviceId", "@param", "Definition", "$definition" ]
train
https://github.com/yoanm/symfony-jsonrpc-http-server/blob/e6a9df43aa1e944966a790140546b9aeb98b6a53/src/DependencyInjection/JsonRpcMethodDefinitionHelper.php#L60-L69
simplesamlphp/simplesamlphp-module-aggregator
lib/Aggregator.php
sspmod_aggregator_Aggregator.exclude
public function exclude($exclude) { $this->excludeTags = array_merge($this->excludeTags, SimpleSAML_Utilities::arrayize($exclude)); }
php
public function exclude($exclude) { $this->excludeTags = array_merge($this->excludeTags, SimpleSAML_Utilities::arrayize($exclude)); }
[ "public", "function", "exclude", "(", "$", "exclude", ")", "{", "$", "this", "->", "excludeTags", "=", "array_merge", "(", "$", "this", "->", "excludeTags", ",", "SimpleSAML_Utilities", "::", "arrayize", "(", "$", "exclude", ")", ")", ";", "}" ]
Add tag to excelude when collecting source metadata. $exclude May be string or array identifying a tag to exclude.
[ "Add", "tag", "to", "excelude", "when", "collecting", "source", "metadata", "." ]
train
https://github.com/simplesamlphp/simplesamlphp-module-aggregator/blob/1afd0913392193bc4d0b94cfc9a5020daac0fdbe/lib/Aggregator.php#L70-L72
simplesamlphp/simplesamlphp-module-aggregator
lib/Aggregator.php
sspmod_aggregator_Aggregator.getSources
public function getSources() { $sourcesDef = $this->aConfig->getArray('sources'); try { $sources = SimpleSAML_Metadata_MetaDataStorageSource::parseSources($sourcesDef); } catch (Exception $e) { throw new Exception('Invalid aggregator source configuration for aggregator ' . var_export($id, TRUE) . ': ' . $e->getMessage()); } /* Find list of all available entities. */ $entities = array(); foreach ($sources as $source) { foreach ($this->sets as $set) { foreach ($source->getMetadataSet($set) as $entityId => $metadata) { $metadata['entityid'] = $entityId; $metadata['metadata-set'] = $set; if (isset($metadata['tags']) && count(array_intersect($this->excludeTags, $metadata['tags'])) > 0) { \SimpleSAML\Logger::debug('Excluding entity ID [' . $entityId . '] becuase it is tagged with one of [' . var_export($this->excludeTags, TRUE) . ']'); continue; } else { #echo('<pre>'); print_r($metadata); exit; } if (!array_key_exists($entityId, $entities)) $entities[$entityId] = array(); if (array_key_exists($set, $entities[$entityId])) { /* Entity already has metadata for the given set. */ continue; } $entities[$entityId][$set] = $metadata; } } } return $entities; }
php
public function getSources() { $sourcesDef = $this->aConfig->getArray('sources'); try { $sources = SimpleSAML_Metadata_MetaDataStorageSource::parseSources($sourcesDef); } catch (Exception $e) { throw new Exception('Invalid aggregator source configuration for aggregator ' . var_export($id, TRUE) . ': ' . $e->getMessage()); } /* Find list of all available entities. */ $entities = array(); foreach ($sources as $source) { foreach ($this->sets as $set) { foreach ($source->getMetadataSet($set) as $entityId => $metadata) { $metadata['entityid'] = $entityId; $metadata['metadata-set'] = $set; if (isset($metadata['tags']) && count(array_intersect($this->excludeTags, $metadata['tags'])) > 0) { \SimpleSAML\Logger::debug('Excluding entity ID [' . $entityId . '] becuase it is tagged with one of [' . var_export($this->excludeTags, TRUE) . ']'); continue; } else { #echo('<pre>'); print_r($metadata); exit; } if (!array_key_exists($entityId, $entities)) $entities[$entityId] = array(); if (array_key_exists($set, $entities[$entityId])) { /* Entity already has metadata for the given set. */ continue; } $entities[$entityId][$set] = $metadata; } } } return $entities; }
[ "public", "function", "getSources", "(", ")", "{", "$", "sourcesDef", "=", "$", "this", "->", "aConfig", "->", "getArray", "(", "'sources'", ")", ";", "try", "{", "$", "sources", "=", "SimpleSAML_Metadata_MetaDataStorageSource", "::", "parseSources", "(", "$",...
Returns a list of entities with metadata
[ "Returns", "a", "list", "of", "entities", "with", "metadata" ]
train
https://github.com/simplesamlphp/simplesamlphp-module-aggregator/blob/1afd0913392193bc4d0b94cfc9a5020daac0fdbe/lib/Aggregator.php#L77-L122
louvian/pururin-crawler
src/Pururin/Crawlers/Content.php
Content.action
public function action() { if (! isset($this->ins->result['info']['Pages']) || $this->pointer <= $this->ins->result['info']['Pages']) { $ch = new Curl("http://pururin.us/assets/images/data/".$this->ins->id."/".$this->pointer.".jpg"); $ch->setOpt( [ CURLOPT_REFERER => $this->ins->url, CURLOPT_CONNECTTIMEOUT => 1000, CURLOPT_TIMEOUT => 1000 ] ); $this->binary = $ch->exec(); if ($ch->errno()) { $ex = new PururinException($ch->error(), 1); $ex->pointer($this->pointer); throw $ex; } $info = $ch->info(); if ($info['http_code'] !== 200) { return false; } return true; } return false; }
php
public function action() { if (! isset($this->ins->result['info']['Pages']) || $this->pointer <= $this->ins->result['info']['Pages']) { $ch = new Curl("http://pururin.us/assets/images/data/".$this->ins->id."/".$this->pointer.".jpg"); $ch->setOpt( [ CURLOPT_REFERER => $this->ins->url, CURLOPT_CONNECTTIMEOUT => 1000, CURLOPT_TIMEOUT => 1000 ] ); $this->binary = $ch->exec(); if ($ch->errno()) { $ex = new PururinException($ch->error(), 1); $ex->pointer($this->pointer); throw $ex; } $info = $ch->info(); if ($info['http_code'] !== 200) { return false; } return true; } return false; }
[ "public", "function", "action", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "ins", "->", "result", "[", "'info'", "]", "[", "'Pages'", "]", ")", "||", "$", "this", "->", "pointer", "<=", "$", "this", "->", "ins", "->", "result...
Action
[ "Action" ]
train
https://github.com/louvian/pururin-crawler/blob/1a8e5d606fc9e0f494aaceaf192d08265e8b8d26/src/Pururin/Crawlers/Content.php#L29-L53
morilog/InfinityCache
src/Builder.php
Builder.get
public function get($columns = ['*']) { $cacheKey = $this->generateCacheKey(); if (null === ($results = $this->cache->tags($this->cacheTag)->get($cacheKey))) { $results = parent::get($columns); if ($this->isTimeAwareQuery) { // Cache results for $cacheLifeTime minutes $this->cache->tags($this->cacheTag)->put($cacheKey, $results, $this->cacheLifeTime); } else { // Cache results forever $this->cache->tags($this->cacheTag)->forever($cacheKey, $results); } } return $results; }
php
public function get($columns = ['*']) { $cacheKey = $this->generateCacheKey(); if (null === ($results = $this->cache->tags($this->cacheTag)->get($cacheKey))) { $results = parent::get($columns); if ($this->isTimeAwareQuery) { // Cache results for $cacheLifeTime minutes $this->cache->tags($this->cacheTag)->put($cacheKey, $results, $this->cacheLifeTime); } else { // Cache results forever $this->cache->tags($this->cacheTag)->forever($cacheKey, $results); } } return $results; }
[ "public", "function", "get", "(", "$", "columns", "=", "[", "'*'", "]", ")", "{", "$", "cacheKey", "=", "$", "this", "->", "generateCacheKey", "(", ")", ";", "if", "(", "null", "===", "(", "$", "results", "=", "$", "this", "->", "cache", "->", "t...
Execute the query as a "select" statement. All Cached results will be flushed after every CUD operations @param array $columns @return array|static[]
[ "Execute", "the", "query", "as", "a", "select", "statement", ".", "All", "Cached", "results", "will", "be", "flushed", "after", "every", "CUD", "operations" ]
train
https://github.com/morilog/InfinityCache/blob/c87231b9995fbbcfdd0a67ab5ffc2697382031d7/src/Builder.php#L64-L82
morilog/InfinityCache
src/Builder.php
Builder.newQuery
public function newQuery() { return new static( $this->cache, $this->connection, $this->grammar, $this->processor, $this->cacheTag ); }
php
public function newQuery() { return new static( $this->cache, $this->connection, $this->grammar, $this->processor, $this->cacheTag ); }
[ "public", "function", "newQuery", "(", ")", "{", "return", "new", "static", "(", "$", "this", "->", "cache", ",", "$", "this", "->", "connection", ",", "$", "this", "->", "grammar", ",", "$", "this", "->", "processor", ",", "$", "this", "->", "cacheT...
Get a new instance of the query builder. @return Builder
[ "Get", "a", "new", "instance", "of", "the", "query", "builder", "." ]
train
https://github.com/morilog/InfinityCache/blob/c87231b9995fbbcfdd0a67ab5ffc2697382031d7/src/Builder.php#L89-L98
morilog/InfinityCache
src/Builder.php
Builder.generateCacheKey
protected function generateCacheKey() { $bindings = array_map(function ($param) { // Round datetime if ($param instanceof \DateTime) { $this->isTimeAwareQuery = true; return $this->getRoundedDateTime($param); } return $param; }, $this->getBindings()); return sha1($this->connection->getName() . $this->toSql() . serialize($bindings)); }
php
protected function generateCacheKey() { $bindings = array_map(function ($param) { // Round datetime if ($param instanceof \DateTime) { $this->isTimeAwareQuery = true; return $this->getRoundedDateTime($param); } return $param; }, $this->getBindings()); return sha1($this->connection->getName() . $this->toSql() . serialize($bindings)); }
[ "protected", "function", "generateCacheKey", "(", ")", "{", "$", "bindings", "=", "array_map", "(", "function", "(", "$", "param", ")", "{", "// Round datetime", "if", "(", "$", "param", "instanceof", "\\", "DateTime", ")", "{", "$", "this", "->", "isTimeA...
Generate unique cache key from query and it bindings parameters @return string
[ "Generate", "unique", "cache", "key", "from", "query", "and", "it", "bindings", "parameters" ]
train
https://github.com/morilog/InfinityCache/blob/c87231b9995fbbcfdd0a67ab5ffc2697382031d7/src/Builder.php#L105-L121
budde377/Part
lib/model/page/PageImpl.php
PageImpl.getTemplate
public function getTemplate() { if($this->template != ''){ return $this->template; } if(($defaultTemplate = $this->container->getConfigInstance()->getDefaultTemplateName()) == null){ return ''; } return $defaultTemplate; }
php
public function getTemplate() { if($this->template != ''){ return $this->template; } if(($defaultTemplate = $this->container->getConfigInstance()->getDefaultTemplateName()) == null){ return ''; } return $defaultTemplate; }
[ "public", "function", "getTemplate", "(", ")", "{", "if", "(", "$", "this", "->", "template", "!=", "''", ")", "{", "return", "$", "this", "->", "template", ";", "}", "if", "(", "(", "$", "defaultTemplate", "=", "$", "this", "->", "container", "->", ...
The return string should match a template in some config. @return string
[ "The", "return", "string", "should", "match", "a", "template", "in", "some", "config", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageImpl.php#L91-L102
budde377/Part
lib/model/page/PageImpl.php
PageImpl.setID
public function setID($page_id) { if ($page_id == $this->page_id) { return true; } if (!$this->isValidId($page_id)) { return false; } if(!$this->pageOrder->changeId($this, $page_id)){ return false; } $this->page_id = $page_id; return true; }
php
public function setID($page_id) { if ($page_id == $this->page_id) { return true; } if (!$this->isValidId($page_id)) { return false; } if(!$this->pageOrder->changeId($this, $page_id)){ return false; } $this->page_id = $page_id; return true; }
[ "public", "function", "setID", "(", "$", "page_id", ")", "{", "if", "(", "$", "page_id", "==", "$", "this", "->", "page_id", ")", "{", "return", "true", ";", "}", "if", "(", "!", "$", "this", "->", "isValidId", "(", "$", "page_id", ")", ")", "{",...
Set the id of the page. The ID should be of type [a-zA-Z0-9-_]+ If the id does not conform to above, it will return FALSE, else, TRUE Also the ID must be unique, if not it will fail and return FALSE @param $page_id string @return bool
[ "Set", "the", "id", "of", "the", "page", ".", "The", "ID", "should", "be", "of", "type", "[", "a", "-", "zA", "-", "Z0", "-", "9", "-", "_", "]", "+", "If", "the", "id", "does", "not", "conform", "to", "above", "it", "will", "return", "FALSE", ...
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageImpl.php#L120-L136
budde377/Part
lib/model/page/PageImpl.php
PageImpl.setTemplate
public function setTemplate($template) { $updateTemplateStm = $this->connection->prepare("UPDATE Page SET template = :template WHERE page_id = :page_id"); $updateTemplateStm->bindParam(":template", $this->template); $updateTemplateStm->bindParam(":page_id", $this->page_id); $this->template = $template; $updateTemplateStm->execute(); }
php
public function setTemplate($template) { $updateTemplateStm = $this->connection->prepare("UPDATE Page SET template = :template WHERE page_id = :page_id"); $updateTemplateStm->bindParam(":template", $this->template); $updateTemplateStm->bindParam(":page_id", $this->page_id); $this->template = $template; $updateTemplateStm->execute(); }
[ "public", "function", "setTemplate", "(", "$", "template", ")", "{", "$", "updateTemplateStm", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"UPDATE Page SET template = :template WHERE page_id = :page_id\"", ")", ";", "$", "updateTemplateStm", "->", "b...
Set the template, the template should match element in config. @param $template string @return void
[ "Set", "the", "template", "the", "template", "should", "match", "element", "in", "config", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageImpl.php#L157-L164
budde377/Part
lib/model/page/PageImpl.php
PageImpl.setAlias
public function setAlias($alias) { if (!$this->isValidAlias($alias)) { return false; } $updateAliasStm = $this->connection->prepare("UPDATE Page SET alias = :alias WHERE page_id = :page_id"); $updateAliasStm->bindParam(":alias", $this->alias); $updateAliasStm->bindParam(":page_id", $this->page_id); $this->alias = $alias; $updateAliasStm->execute(); return true; }
php
public function setAlias($alias) { if (!$this->isValidAlias($alias)) { return false; } $updateAliasStm = $this->connection->prepare("UPDATE Page SET alias = :alias WHERE page_id = :page_id"); $updateAliasStm->bindParam(":alias", $this->alias); $updateAliasStm->bindParam(":page_id", $this->page_id); $this->alias = $alias; $updateAliasStm->execute(); return true; }
[ "public", "function", "setAlias", "(", "$", "alias", ")", "{", "if", "(", "!", "$", "this", "->", "isValidAlias", "(", "$", "alias", ")", ")", "{", "return", "false", ";", "}", "$", "updateAliasStm", "=", "$", "this", "->", "connection", "->", "prepa...
Will set the alias. This should support RegEx @param $alias string @return bool
[ "Will", "set", "the", "alias", ".", "This", "should", "support", "RegEx" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageImpl.php#L171-L184
budde377/Part
lib/model/page/PageImpl.php
PageImpl.hide
public function hide() { if ($this->isHidden()) return; $updateHiddenStm = $this->connection->prepare("UPDATE Page SET hidden=? WHERE page_id = ?"); $updateHiddenStm->bindParam(1, $this->hidden); $updateHiddenStm->bindParam(2, $this->page_id); $this->hidden = true; $updateHiddenStm->execute(); }
php
public function hide() { if ($this->isHidden()) return; $updateHiddenStm = $this->connection->prepare("UPDATE Page SET hidden=? WHERE page_id = ?"); $updateHiddenStm->bindParam(1, $this->hidden); $updateHiddenStm->bindParam(2, $this->page_id); $this->hidden = true; $updateHiddenStm->execute(); }
[ "public", "function", "hide", "(", ")", "{", "if", "(", "$", "this", "->", "isHidden", "(", ")", ")", "return", ";", "$", "updateHiddenStm", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"UPDATE Page SET hidden=? WHERE page_id = ?\"", ")", ";...
This will mark the page as hidden. If the page is already hidden, nothing will happen. @return void
[ "This", "will", "mark", "the", "page", "as", "hidden", ".", "If", "the", "page", "is", "already", "hidden", "nothing", "will", "happen", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageImpl.php#L278-L288
budde377/Part
lib/model/page/PageImpl.php
PageImpl.show
public function show() { if (!$this->isHidden()) return; $updateHiddenStm = $this->connection->prepare("UPDATE Page SET hidden=? WHERE page_id = ?"); $updateHiddenStm->bindParam(1, $this->hidden); $updateHiddenStm->bindParam(2, $this->page_id); $this->hidden = false; $updateHiddenStm->execute(); }
php
public function show() { if (!$this->isHidden()) return; $updateHiddenStm = $this->connection->prepare("UPDATE Page SET hidden=? WHERE page_id = ?"); $updateHiddenStm->bindParam(1, $this->hidden); $updateHiddenStm->bindParam(2, $this->page_id); $this->hidden = false; $updateHiddenStm->execute(); }
[ "public", "function", "show", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isHidden", "(", ")", ")", "return", ";", "$", "updateHiddenStm", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"UPDATE Page SET hidden=? WHERE page_id = ?\"", ")...
This will un-mark the page as hidden, iff it is hidden. If the page is not hidden, nothing will happen. @return void
[ "This", "will", "un", "-", "mark", "the", "page", "as", "hidden", "iff", "it", "is", "hidden", ".", "If", "the", "page", "is", "not", "hidden", "nothing", "will", "happen", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageImpl.php#L295-L305
budde377/Part
lib/model/page/PageImpl.php
PageImpl.modify
public function modify() { $updLastModStm = $this->connection->prepare("UPDATE Page SET last_modified=FROM_UNIXTIME(?) WHERE page_id=?"); $updLastModStm->bindParam(1, $this->lastModified); $updLastModStm->bindParam(2, $this->page_id); $this->lastModified = time(); $updLastModStm->execute(); return $this->lastModified; }
php
public function modify() { $updLastModStm = $this->connection->prepare("UPDATE Page SET last_modified=FROM_UNIXTIME(?) WHERE page_id=?"); $updLastModStm->bindParam(1, $this->lastModified); $updLastModStm->bindParam(2, $this->page_id); $this->lastModified = time(); $updLastModStm->execute(); return $this->lastModified; }
[ "public", "function", "modify", "(", ")", "{", "$", "updLastModStm", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"UPDATE Page SET last_modified=FROM_UNIXTIME(?) WHERE page_id=?\"", ")", ";", "$", "updLastModStm", "->", "bindParam", "(", "1", ",", ...
Will update the page with a new modify timestamp @return int New modified time
[ "Will", "update", "the", "page", "with", "a", "new", "modify", "timestamp" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageImpl.php#L331-L340
budde377/Part
lib/model/page/PageImpl.php
PageImpl.getContentLibrary
public function getContentLibrary() { return $this->contentLibrary == null ? $this->contentLibrary = new PageContentLibraryImpl($this->container, $this) : $this->contentLibrary; }
php
public function getContentLibrary() { return $this->contentLibrary == null ? $this->contentLibrary = new PageContentLibraryImpl($this->container, $this) : $this->contentLibrary; }
[ "public", "function", "getContentLibrary", "(", ")", "{", "return", "$", "this", "->", "contentLibrary", "==", "null", "?", "$", "this", "->", "contentLibrary", "=", "new", "PageContentLibraryImpl", "(", "$", "this", "->", "container", ",", "$", "this", ")",...
Will return and reuse a ContentLibrary instance. @return ContentLibrary
[ "Will", "return", "and", "reuse", "a", "ContentLibrary", "instance", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageImpl.php#L354-L359
cevou/BehatScreenshotCompareExtension
src/Cevou/Behat/ScreenshotCompareExtension/Context/Initializer/ScreenshotCompareAwareInitializer.php
ScreenshotCompareAwareInitializer.initializeContext
public function initializeContext(Context $context) { if (!$context instanceof ScreenshotCompareAwareContext) { return; } $context->setScreenshotCompareConfigurations($this->configurations); $context->setScreenshotCompareParameters($this->parameters); }
php
public function initializeContext(Context $context) { if (!$context instanceof ScreenshotCompareAwareContext) { return; } $context->setScreenshotCompareConfigurations($this->configurations); $context->setScreenshotCompareParameters($this->parameters); }
[ "public", "function", "initializeContext", "(", "Context", "$", "context", ")", "{", "if", "(", "!", "$", "context", "instanceof", "ScreenshotCompareAwareContext", ")", "{", "return", ";", "}", "$", "context", "->", "setScreenshotCompareConfigurations", "(", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/cevou/BehatScreenshotCompareExtension/blob/b10465b0c69d237f8608c78e829bc6f10c31455a/src/Cevou/Behat/ScreenshotCompareExtension/Context/Initializer/ScreenshotCompareAwareInitializer.php#L30-L38
wardrobecms/core-archived
src/Wardrobe/Core/Facades/Wardrobe.php
Wardrobe.route
public function route($route, $param = null) { if($route == '/') { return route('wardrobe.index'); } else { return \URL::route('wardrobe.'.$route, $param); } }
php
public function route($route, $param = null) { if($route == '/') { return route('wardrobe.index'); } else { return \URL::route('wardrobe.'.$route, $param); } }
[ "public", "function", "route", "(", "$", "route", ",", "$", "param", "=", "null", ")", "{", "if", "(", "$", "route", "==", "'/'", ")", "{", "return", "route", "(", "'wardrobe.index'", ")", ";", "}", "else", "{", "return", "\\", "URL", "::", "route"...
Generate a route to a named group @param string $route @param mixed $param @return string
[ "Generate", "a", "route", "to", "a", "named", "group" ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Facades/Wardrobe.php#L66-L76
skrz/meta
gen-src/Google/Protobuf/Meta/EnumOptionsMeta.php
EnumOptionsMeta.create
public static function create() { switch (func_num_args()) { case 0: return new EnumOptions(); case 1: return new EnumOptions(func_get_arg(0)); case 2: return new EnumOptions(func_get_arg(0), func_get_arg(1)); case 3: return new EnumOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new EnumOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new EnumOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new EnumOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new EnumOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new EnumOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new EnumOptions(); case 1: return new EnumOptions(func_get_arg(0)); case 2: return new EnumOptions(func_get_arg(0), func_get_arg(1)); case 3: return new EnumOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new EnumOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new EnumOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new EnumOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new EnumOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new EnumOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "EnumOptions", "(", ")", ";", "case", "1", ":", "return", "new", "EnumOptions", "(", "func_get_arg", "(", "0...
Creates new instance of \Google\Protobuf\EnumOptions @throws \InvalidArgumentException @return EnumOptions
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "EnumOptions" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumOptionsMeta.php#L59-L83
skrz/meta
gen-src/Google/Protobuf/Meta/EnumOptionsMeta.php
EnumOptionsMeta.reset
public static function reset($object) { if (!($object instanceof EnumOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\EnumOptions.'); } $object->allowAlias = NULL; $object->deprecated = NULL; $object->uninterpretedOption = NULL; }
php
public static function reset($object) { if (!($object instanceof EnumOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\EnumOptions.'); } $object->allowAlias = NULL; $object->deprecated = NULL; $object->uninterpretedOption = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "EnumOptions", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\\EnumOpt...
Resets properties of \Google\Protobuf\EnumOptions to default values @param EnumOptions $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "EnumOptions", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumOptionsMeta.php#L96-L104
skrz/meta
gen-src/Google/Protobuf/Meta/EnumOptionsMeta.php
EnumOptionsMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->allowAlias) && ($filter === null || isset($filter['allowAlias']))) { $output .= "\x10"; $output .= Binary::encodeVarint((int)$object->allowAlias); } if (isset($object->deprecated) && ($filter === null || isset($filter['deprecated']))) { $output .= "\x18"; $output .= Binary::encodeVarint((int)$object->deprecated); } if (isset($object->uninterpretedOption) && ($filter === null || isset($filter['uninterpretedOption']))) { foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $k => $v) { $output .= "\xba\x3e"; $buffer = UninterpretedOptionMeta::toProtobuf($v, $filter === null ? null : $filter['uninterpretedOption']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->allowAlias) && ($filter === null || isset($filter['allowAlias']))) { $output .= "\x10"; $output .= Binary::encodeVarint((int)$object->allowAlias); } if (isset($object->deprecated) && ($filter === null || isset($filter['deprecated']))) { $output .= "\x18"; $output .= Binary::encodeVarint((int)$object->deprecated); } if (isset($object->uninterpretedOption) && ($filter === null || isset($filter['uninterpretedOption']))) { foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $k => $v) { $output .= "\xba\x3e"; $buffer = UninterpretedOptionMeta::toProtobuf($v, $filter === null ? null : $filter['uninterpretedOption']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "allowAlias", ")", "&&", "(", "$", "filter", "===", "null", "|...
Serialized \Google\Protobuf\EnumOptions to Protocol Buffers message. @param EnumOptions $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "EnumOptions", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumOptionsMeta.php#L239-L263
fedemotta/yii2-gridstack
Gridstack.php
Gridstack.beginWidget
public function beginWidget($options=[],$tag='div') { $widget = Html::beginTag($tag,$options); $this->_widgets[] = $widget; return $widget; }
php
public function beginWidget($options=[],$tag='div') { $widget = Html::beginTag($tag,$options); $this->_widgets[] = $widget; return $widget; }
[ "public", "function", "beginWidget", "(", "$", "options", "=", "[", "]", ",", "$", "tag", "=", "'div'", ")", "{", "$", "widget", "=", "Html", "::", "beginTag", "(", "$", "tag", ",", "$", "options", ")", ";", "$", "this", "->", "_widgets", "[", "]...
Generates a gridstack widget begin tag. This method will create a new gridstack widget and returns its opening tag. You should call [[endWidget()]] afterwards. @param array $options @param string $tag @return string the generated tag @see endWidget()
[ "Generates", "a", "gridstack", "widget", "begin", "tag", ".", "This", "method", "will", "create", "a", "new", "gridstack", "widget", "and", "returns", "its", "opening", "tag", ".", "You", "should", "call", "[[", "endWidget", "()", "]]", "afterwards", "." ]
train
https://github.com/fedemotta/yii2-gridstack/blob/66bf91eaa53d680e926c23745d9293408d1f298e/Gridstack.php#L72-L78
fedemotta/yii2-gridstack
Gridstack.php
Gridstack.endWidget
public function endWidget($tag='div') { $widget = array_pop($this->_widgets); if (!is_null($widget)) { return Html::endTag($tag); } else { throw new InvalidCallException('Mismatching endWidget() call.'); } }
php
public function endWidget($tag='div') { $widget = array_pop($this->_widgets); if (!is_null($widget)) { return Html::endTag($tag); } else { throw new InvalidCallException('Mismatching endWidget() call.'); } }
[ "public", "function", "endWidget", "(", "$", "tag", "=", "'div'", ")", "{", "$", "widget", "=", "array_pop", "(", "$", "this", "->", "_widgets", ")", ";", "if", "(", "!", "is_null", "(", "$", "widget", ")", ")", "{", "return", "Html", "::", "endTag...
Generates a gridstack widget end tag. @param string $tag @return string the generated tag @see beginWidget()
[ "Generates", "a", "gridstack", "widget", "end", "tag", "." ]
train
https://github.com/fedemotta/yii2-gridstack/blob/66bf91eaa53d680e926c23745d9293408d1f298e/Gridstack.php#L85-L93
fedemotta/yii2-gridstack
Gridstack.php
Gridstack.init
public function init() { if (!isset($this->options['id'])) { $this->options['id'] = $this->getId(); } echo self::beginContainer($this->options,$this->tag); }
php
public function init() { if (!isset($this->options['id'])) { $this->options['id'] = $this->getId(); } echo self::beginContainer($this->options,$this->tag); }
[ "public", "function", "init", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "'id'", "]", ")", ")", "{", "$", "this", "->", "options", "[", "'id'", "]", "=", "$", "this", "->", "getId", "(", ")", ";", "}", "ec...
Initializes the widget. This method will register the bootstrap asset bundle. If you override this method, make sure you call the parent implementation first.
[ "Initializes", "the", "widget", ".", "This", "method", "will", "register", "the", "bootstrap", "asset", "bundle", ".", "If", "you", "override", "this", "method", "make", "sure", "you", "call", "the", "parent", "implementation", "first", "." ]
train
https://github.com/fedemotta/yii2-gridstack/blob/66bf91eaa53d680e926c23745d9293408d1f298e/Gridstack.php#L99-L105
fedemotta/yii2-gridstack
Gridstack.php
Gridstack.run
public function run() { if (!empty($this->_widgets)) { throw new InvalidCallException('Each beginWidget() should have a matching endWidget() call.'); } $id = $this->options['id']; $view = $this->getView(); $options = !empty($this->clientOptions) ? Json::encode($this->clientOptions) : Json::encode([]); GridstackAsset::register($view); $view->registerJs("jQuery('#$id').gridstack($options);"); echo self::endContainer($this->tag); }
php
public function run() { if (!empty($this->_widgets)) { throw new InvalidCallException('Each beginWidget() should have a matching endWidget() call.'); } $id = $this->options['id']; $view = $this->getView(); $options = !empty($this->clientOptions) ? Json::encode($this->clientOptions) : Json::encode([]); GridstackAsset::register($view); $view->registerJs("jQuery('#$id').gridstack($options);"); echo self::endContainer($this->tag); }
[ "public", "function", "run", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "_widgets", ")", ")", "{", "throw", "new", "InvalidCallException", "(", "'Each beginWidget() should have a matching endWidget() call.'", ")", ";", "}", "$", "id", "=",...
Runs the widget. This registers the necessary javascript code and renders the gridstack close tag. @throws InvalidCallException if `beginWidget()` and `endWidget()` calls are not matching
[ "Runs", "the", "widget", ".", "This", "registers", "the", "necessary", "javascript", "code", "and", "renders", "the", "gridstack", "close", "tag", "." ]
train
https://github.com/fedemotta/yii2-gridstack/blob/66bf91eaa53d680e926c23745d9293408d1f298e/Gridstack.php#L111-L122
yarcode/yii2-email-manager
src/commands/EmailCommand.php
EmailCommand.actionRunSpoolDaemon
public function actionRunSpoolDaemon($loopLimit = 1000, $chunkSize = 100) { set_time_limit(0); for ($i = 1; $i < $loopLimit; $i++) { $this->runChunk($chunkSize); sleep(1); } }
php
public function actionRunSpoolDaemon($loopLimit = 1000, $chunkSize = 100) { set_time_limit(0); for ($i = 1; $i < $loopLimit; $i++) { $this->runChunk($chunkSize); sleep(1); } }
[ "public", "function", "actionRunSpoolDaemon", "(", "$", "loopLimit", "=", "1000", ",", "$", "chunkSize", "=", "100", ")", "{", "set_time_limit", "(", "0", ")", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "$", "loopLimit", ";", "$", "i"...
Run daemon based on "for cycle" @param int $loopLimit @param int $chunkSize
[ "Run", "daemon", "based", "on", "for", "cycle" ]
train
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/commands/EmailCommand.php#L25-L32
yarcode/yii2-email-manager
src/commands/EmailCommand.php
EmailCommand.actionRunLoopDaemon
public function actionRunLoopDaemon() { $loop = Factory::create(); $loop->addPeriodicTimer(1, function() { $this->runChunk(); }); $loop->run(); }
php
public function actionRunLoopDaemon() { $loop = Factory::create(); $loop->addPeriodicTimer(1, function() { $this->runChunk(); }); $loop->run(); }
[ "public", "function", "actionRunLoopDaemon", "(", ")", "{", "$", "loop", "=", "Factory", "::", "create", "(", ")", ";", "$", "loop", "->", "addPeriodicTimer", "(", "1", ",", "function", "(", ")", "{", "$", "this", "->", "runChunk", "(", ")", ";", "}"...
Run daemon based on ReactPHP loop
[ "Run", "daemon", "based", "on", "ReactPHP", "loop" ]
train
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/commands/EmailCommand.php#L37-L45
yarcode/yii2-email-manager
src/commands/EmailCommand.php
EmailCommand.runChunk
protected function runChunk($chunkSize = 100) { for ($i = 0; $i < $chunkSize; $i++) { $r = $this->sendOne(); if (!$r) return false; } return true; }
php
protected function runChunk($chunkSize = 100) { for ($i = 0; $i < $chunkSize; $i++) { $r = $this->sendOne(); if (!$r) return false; } return true; }
[ "protected", "function", "runChunk", "(", "$", "chunkSize", "=", "100", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "chunkSize", ";", "$", "i", "++", ")", "{", "$", "r", "=", "$", "this", "->", "sendOne", "(", ")", ";",...
Tries to run sendOne $chunkSize times @param int $chunkSize @return bool @throws \Exception
[ "Tries", "to", "run", "sendOne", "$chunkSize", "times" ]
train
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/commands/EmailCommand.php#L63-L71
yarcode/yii2-email-manager
src/commands/EmailCommand.php
EmailCommand.sendOne
public function sendOne() { $db = \Yii::$app->db; $transaction = $db->beginTransaction(); try { $id = $db->createCommand('SELECT id FROM {{%email_message}} WHERE status=:status ORDER BY priority DESC, id ASC LIMIT 1 FOR UPDATE', [ 'status' => Message::STATUS_NEW, ])->queryScalar(); if ($id === false) { $transaction->rollback(); return false; } /** @var Message $model */ $model = Message::findOne($id); $model->status = Message::STATUS_IN_PROGRESS; $model->updateAttributes(['status']); $transaction->commit(); } catch (\Exception $e) { $transaction->rollback(); throw $e; } $transaction = $db->beginTransaction(); try { $result = EmailManager::getInstance()->send( $model->from, $model->to, $model->subject, $model->text, $model->files, $model->bcc ); if ($result) { $model->sentAt = new Expression('NOW()'); $model->status = Message::STATUS_SENT; } else { $model->status = Message::STATUS_ERROR; } $model->updateAttributes(['sentAt', 'status']); $transaction->commit(); } catch (\Exception $e) { $transaction->rollback(); throw $e; } return true; }
php
public function sendOne() { $db = \Yii::$app->db; $transaction = $db->beginTransaction(); try { $id = $db->createCommand('SELECT id FROM {{%email_message}} WHERE status=:status ORDER BY priority DESC, id ASC LIMIT 1 FOR UPDATE', [ 'status' => Message::STATUS_NEW, ])->queryScalar(); if ($id === false) { $transaction->rollback(); return false; } /** @var Message $model */ $model = Message::findOne($id); $model->status = Message::STATUS_IN_PROGRESS; $model->updateAttributes(['status']); $transaction->commit(); } catch (\Exception $e) { $transaction->rollback(); throw $e; } $transaction = $db->beginTransaction(); try { $result = EmailManager::getInstance()->send( $model->from, $model->to, $model->subject, $model->text, $model->files, $model->bcc ); if ($result) { $model->sentAt = new Expression('NOW()'); $model->status = Message::STATUS_SENT; } else { $model->status = Message::STATUS_ERROR; } $model->updateAttributes(['sentAt', 'status']); $transaction->commit(); } catch (\Exception $e) { $transaction->rollback(); throw $e; } return true; }
[ "public", "function", "sendOne", "(", ")", "{", "$", "db", "=", "\\", "Yii", "::", "$", "app", "->", "db", ";", "$", "transaction", "=", "$", "db", "->", "beginTransaction", "(", ")", ";", "try", "{", "$", "id", "=", "$", "db", "->", "createComma...
Send one email from queue @return bool @throws \Exception @throws \yii\db\Exception
[ "Send", "one", "email", "from", "queue" ]
train
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/commands/EmailCommand.php#L79-L130
MW-Peachy/Peachy
Includes/Page.php
Page.history
public function history( $count = 1, $dir = "older", $content = false, $revid = null, $rollback_token = false, $recurse = false ) { if( !$this->exists ) return array(); $historyArray = array( 'action' => 'query', 'prop' => 'revisions', 'titles' => $this->title, 'rvprop' => 'timestamp|ids|user|comment', 'rawcontinue' => 1, 'rvdir' => $dir, ); if( $content ) $historyArray['rvprop'] .= "|content"; if( !is_null( $revid ) ) $historyArray['rvstartid'] = $revid; if( !is_null( $count ) ) $historyArray['rvlimit'] = $count; if( $rollback_token ) $historyArray['rvtoken'] = 'rollback'; if( !$recurse ) pecho( "Getting page history for {$this->title}..\n\n", PECHO_NORMAL ); if( is_null( $count ) ) { $history = $ei = $this->history( $this->wiki->get_api_limit() + 1, $dir, $content, $revid, $rollback_token, true ); while( !is_null( $ei[1] ) ){ $ei = $this->history( $this->wiki->get_api_limit() + 1, $dir, $content, $ei[1], $rollback_token, true ); foreach( $ei[0] as $eg ){ $history[0][] = $eg; } } return $history[0]; } $historyResult = $this->wiki->apiQuery( $historyArray ); if( $recurse ) { if( isset( $historyResult['query-continue'] ) ) { return array( $historyResult['query']['pages'][$this->pageid]['revisions'], $historyResult['query-continue']['revisions']['rvcontinue'] ); } return array( $historyResult['query']['pages'][$this->pageid]['revisions'], null ); } return $historyResult['query']['pages'][$this->pageid]['revisions']; }
php
public function history( $count = 1, $dir = "older", $content = false, $revid = null, $rollback_token = false, $recurse = false ) { if( !$this->exists ) return array(); $historyArray = array( 'action' => 'query', 'prop' => 'revisions', 'titles' => $this->title, 'rvprop' => 'timestamp|ids|user|comment', 'rawcontinue' => 1, 'rvdir' => $dir, ); if( $content ) $historyArray['rvprop'] .= "|content"; if( !is_null( $revid ) ) $historyArray['rvstartid'] = $revid; if( !is_null( $count ) ) $historyArray['rvlimit'] = $count; if( $rollback_token ) $historyArray['rvtoken'] = 'rollback'; if( !$recurse ) pecho( "Getting page history for {$this->title}..\n\n", PECHO_NORMAL ); if( is_null( $count ) ) { $history = $ei = $this->history( $this->wiki->get_api_limit() + 1, $dir, $content, $revid, $rollback_token, true ); while( !is_null( $ei[1] ) ){ $ei = $this->history( $this->wiki->get_api_limit() + 1, $dir, $content, $ei[1], $rollback_token, true ); foreach( $ei[0] as $eg ){ $history[0][] = $eg; } } return $history[0]; } $historyResult = $this->wiki->apiQuery( $historyArray ); if( $recurse ) { if( isset( $historyResult['query-continue'] ) ) { return array( $historyResult['query']['pages'][$this->pageid]['revisions'], $historyResult['query-continue']['revisions']['rvcontinue'] ); } return array( $historyResult['query']['pages'][$this->pageid]['revisions'], null ); } return $historyResult['query']['pages'][$this->pageid]['revisions']; }
[ "public", "function", "history", "(", "$", "count", "=", "1", ",", "$", "dir", "=", "\"older\"", ",", "$", "content", "=", "false", ",", "$", "revid", "=", "null", ",", "$", "rollback_token", "=", "false", ",", "$", "recurse", "=", "false", ")", "{...
Returns page history. Can be specified to return content as well @param int $count Revisions to return (default: 1) @param string $dir Direction to return revisions (default: "older") @param bool $content Should content of that revision be returned as well (default: false) @param int $revid Revision ID to start from (default: null) @param bool $rollback_token Should a rollback token be returned (default: false) @param bool $recurse Used internally to provide more results than can be returned with a single API query @return array Revision data
[ "Returns", "page", "history", ".", "Can", "be", "specified", "to", "return", "content", "as", "well" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L319-L366
MW-Peachy/Peachy
Includes/Page.php
Page.get_text
public function get_text( $force = false, $section = null ) { pecho( "Getting page content for {$this->title}..\n\n", PECHO_NOTICE ); if( !$this->exists ) return null; if( !is_null( $section ) ) { if( empty( $this->content ) ) { $this->content = $this->history( 1, "older", true ); $this->content = $this->content[0]['*']; } $sections = $this->wiki->apiQuery( array( 'action' => 'parse', 'page' => $this->title, 'prop' => 'sections' ) ); if( !is_numeric( $section ) ) { foreach( $sections['parse']['sections'] as $section3 ){ if( $section3['line'] == $section ) { $section = $section3['number']; } } } if( !is_numeric( $section ) ) { pecho( "Warning: Section not found.\n\n", PECHO_WARN ); return false; } $offsets = array( '0' => '0' ); if( $this->wiki->get_mw_version() < '1.16' ) { //FIXME: Implement proper notice suppression $ids = array(); foreach( $sections['parse']['sections'] as $section3 ){ $ids[$section3['line']] = $section3['number']; } $regex = '/^(=+)\s*(.*?)\s*(\1)\s*/m'; preg_match_all( $regex, $this->content, $m, PREG_OFFSET_CAPTURE | PREG_SET_ORDER ); foreach( $m as $id => $match ){ $offsets[$id + 1] = $match[0][1]; } } else { foreach( $sections['parse']['sections'] as $section2 ){ $offsets[$section2['number']] = $section2['byteoffset']; } } if( intval( $section ) != count( $offsets ) - 1 ) { $length = $offsets[$section + 1] - $offsets[$section]; } if( isset( $length ) ) { $substr = mb_substr( $this->content, $offsets[$section], $length ); } else { $substr = mb_substr( $this->content, $offsets[$section] ); } return $substr; } else { if( !$force && $this->content !== null ) { return $this->content; } $this->content = $this->history( 1, "older", true ); $this->content = $this->content[0]['*']; return $this->content; } }
php
public function get_text( $force = false, $section = null ) { pecho( "Getting page content for {$this->title}..\n\n", PECHO_NOTICE ); if( !$this->exists ) return null; if( !is_null( $section ) ) { if( empty( $this->content ) ) { $this->content = $this->history( 1, "older", true ); $this->content = $this->content[0]['*']; } $sections = $this->wiki->apiQuery( array( 'action' => 'parse', 'page' => $this->title, 'prop' => 'sections' ) ); if( !is_numeric( $section ) ) { foreach( $sections['parse']['sections'] as $section3 ){ if( $section3['line'] == $section ) { $section = $section3['number']; } } } if( !is_numeric( $section ) ) { pecho( "Warning: Section not found.\n\n", PECHO_WARN ); return false; } $offsets = array( '0' => '0' ); if( $this->wiki->get_mw_version() < '1.16' ) { //FIXME: Implement proper notice suppression $ids = array(); foreach( $sections['parse']['sections'] as $section3 ){ $ids[$section3['line']] = $section3['number']; } $regex = '/^(=+)\s*(.*?)\s*(\1)\s*/m'; preg_match_all( $regex, $this->content, $m, PREG_OFFSET_CAPTURE | PREG_SET_ORDER ); foreach( $m as $id => $match ){ $offsets[$id + 1] = $match[0][1]; } } else { foreach( $sections['parse']['sections'] as $section2 ){ $offsets[$section2['number']] = $section2['byteoffset']; } } if( intval( $section ) != count( $offsets ) - 1 ) { $length = $offsets[$section + 1] - $offsets[$section]; } if( isset( $length ) ) { $substr = mb_substr( $this->content, $offsets[$section], $length ); } else { $substr = mb_substr( $this->content, $offsets[$section] ); } return $substr; } else { if( !$force && $this->content !== null ) { return $this->content; } $this->content = $this->history( 1, "older", true ); $this->content = $this->content[0]['*']; return $this->content; } }
[ "public", "function", "get_text", "(", "$", "force", "=", "false", ",", "$", "section", "=", "null", ")", "{", "pecho", "(", "\"Getting page content for {$this->title}..\\n\\n\"", ",", "PECHO_NOTICE", ")", ";", "if", "(", "!", "$", "this", "->", "exists", ")...
Retrieves text from a page, or a cached copy unless $force is true @param bool $force Grab text from the API, don't use the cached copy (default: false) @param string|int $section Section title or ID to retrieve @return string|bool Page content
[ "Retrieves", "text", "from", "a", "page", "or", "a", "cached", "copy", "unless", "$force", "is", "true" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L375-L454
MW-Peachy/Peachy
Includes/Page.php
Page.get_links
public function get_links( $force = false, $namespace = array(), $titles = array() ) { if( !$force && $this->links !== null ) { return $this->links; } $this->links = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'links', 'titles' => $this->title, '_code' => 'pl', '_lhtitle' => 'links' ); if( !empty( $namespace ) ) $tArray['plnamespace'] = implode( '|', $namespace ); if( !empty( $titles ) ) $tArray['pltitles'] = implode( '|', $titles ); pecho( "Getting internal links on {$this->title}..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result[0] as $link ){ $this->links[] = $link['title']; } } return $this->links; }
php
public function get_links( $force = false, $namespace = array(), $titles = array() ) { if( !$force && $this->links !== null ) { return $this->links; } $this->links = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'links', 'titles' => $this->title, '_code' => 'pl', '_lhtitle' => 'links' ); if( !empty( $namespace ) ) $tArray['plnamespace'] = implode( '|', $namespace ); if( !empty( $titles ) ) $tArray['pltitles'] = implode( '|', $titles ); pecho( "Getting internal links on {$this->title}..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result[0] as $link ){ $this->links[] = $link['title']; } } return $this->links; }
[ "public", "function", "get_links", "(", "$", "force", "=", "false", ",", "$", "namespace", "=", "array", "(", ")", ",", "$", "titles", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "links", "!==", "null"...
Returns links on the page. @link http://www.mediawiki.org/wiki/API:Query_-_Properties#links_.2F_pl @param bool $force Force use of API, won't use cached copy (default: false) @param array $namespace Show links in this namespace(s) only. Default array() @param array $titles Only list links to these titles. Default array() @return bool|array False on error, array of link titles
[ "Returns", "links", "on", "the", "page", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L494-L524
MW-Peachy/Peachy
Includes/Page.php
Page.get_templates
public function get_templates( $force = false, $namespace = array(), $template = array() ) { if( !$force && $this->templates !== null && empty( $namespace ) && empty( $template ) ) { return $this->templates; } $this->templates = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'templates', 'titles' => $this->title, '_code' => 'tl', '_lhtitle' => 'templates' ); if( !empty( $namespace ) ) $tArray['tlnamespace'] = implode( '|', $namespace ); if( !empty( $template ) ) $tArray['tltemplates'] = implode( '|', $template ); pecho( "Getting templates transcluded on {$this->title}..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result as $template ){ $this->templates[] = $template['title']; } } return $this->templates; }
php
public function get_templates( $force = false, $namespace = array(), $template = array() ) { if( !$force && $this->templates !== null && empty( $namespace ) && empty( $template ) ) { return $this->templates; } $this->templates = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'templates', 'titles' => $this->title, '_code' => 'tl', '_lhtitle' => 'templates' ); if( !empty( $namespace ) ) $tArray['tlnamespace'] = implode( '|', $namespace ); if( !empty( $template ) ) $tArray['tltemplates'] = implode( '|', $template ); pecho( "Getting templates transcluded on {$this->title}..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result as $template ){ $this->templates[] = $template['title']; } } return $this->templates; }
[ "public", "function", "get_templates", "(", "$", "force", "=", "false", ",", "$", "namespace", "=", "array", "(", ")", ",", "$", "template", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "templates", "!=="...
Returns templates on the page @link http://www.mediawiki.org/wiki/API:Query_-_Properties#templates_.2F_tl @param bool $force Force use of API, won't use cached copy (default: false) @param array $namespace Show templates in this namespace(s) only. Default array(). @param array $template Only list these templates. Default array() @return bool|array False on error, array of template titles
[ "Returns", "templates", "on", "the", "page" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L535-L564
MW-Peachy/Peachy
Includes/Page.php
Page.get_properties
public function get_properties( $force = false ) { if( !$force && $this->properties !== null ) { return $this->properties; } $this->properties = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'pageprops', 'titles' => $this->title, '_code' => 'pp' ); pecho( "Getting page properties on {$this->title}..\n\n", PECHO_NORMAL ); $this->properties = $this->wiki->listHandler( $tArray ); return $this->properties; }
php
public function get_properties( $force = false ) { if( !$force && $this->properties !== null ) { return $this->properties; } $this->properties = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'pageprops', 'titles' => $this->title, '_code' => 'pp' ); pecho( "Getting page properties on {$this->title}..\n\n", PECHO_NORMAL ); $this->properties = $this->wiki->listHandler( $tArray ); return $this->properties; }
[ "public", "function", "get_properties", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "properties", "!==", "null", ")", "{", "return", "$", "this", "->", "properties", ";", "}", "$", "this", "->", ...
Get various properties defined in the page content @link https://www.mediawiki.org/wiki/API:Properties#pageprops_.2F_pp @param bool $force Force use of API, won't use cached copy (default: false) @return bool|array False on error, array of template titles
[ "Get", "various", "properties", "defined", "in", "the", "page", "content" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L573-L593
MW-Peachy/Peachy
Includes/Page.php
Page.get_categories
public function get_categories( $force = false, $prop = array( 'sortkey', 'timestamp', 'hidden' ), $hidden = false ) { if( !$force && $this->categories !== null ) { return $this->categories; } $this->categories = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'categories', 'titles' => $this->title, '_code' => 'cl', '_lhtitle' => 'categories', 'clprop' => implode( '|', $prop ) ); if( $hidden ) $tArray['clshow'] = ''; pecho( "Getting categories {$this->title} is part of..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result as $category ){ $this->categories[] = $category['title']; } } return $this->categories; }
php
public function get_categories( $force = false, $prop = array( 'sortkey', 'timestamp', 'hidden' ), $hidden = false ) { if( !$force && $this->categories !== null ) { return $this->categories; } $this->categories = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'categories', 'titles' => $this->title, '_code' => 'cl', '_lhtitle' => 'categories', 'clprop' => implode( '|', $prop ) ); if( $hidden ) $tArray['clshow'] = ''; pecho( "Getting categories {$this->title} is part of..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result as $category ){ $this->categories[] = $category['title']; } } return $this->categories; }
[ "public", "function", "get_categories", "(", "$", "force", "=", "false", ",", "$", "prop", "=", "array", "(", "'sortkey'", ",", "'timestamp'", ",", "'hidden'", ")", ",", "$", "hidden", "=", "false", ")", "{", "if", "(", "!", "$", "force", "&&", "$", ...
Returns categories of page @link http://www.mediawiki.org/wiki/API:Query_-_Properties#categories_.2F_cl @param bool $force Force use of API, won't use cached copy (default: false) @param array|string $prop Which additional properties to get for each category. Default all @param bool $hidden Show hidden categories. Default false @return bool|array False on error, returns array of categories
[ "Returns", "categories", "of", "page" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L604-L637
MW-Peachy/Peachy
Includes/Page.php
Page.get_images
public function get_images( $force = false, $images = null ) { if( !$force && $this->images !== null ) { return $this->images; } $this->images = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'images', 'titles' => $this->title, '_code' => 'im', '_lhtitle' => 'images' ); if( !is_null( $images ) ) { if( is_array( $images ) ) { $tArray['imimages'] = implode( '|', $images ); } else $tArray['imimage'] = $images; } pecho( "Getting images used on {$this->title}..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result[0] as $image ){ $this->images[] = $image['title']; } } return $this->images; }
php
public function get_images( $force = false, $images = null ) { if( !$force && $this->images !== null ) { return $this->images; } $this->images = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'images', 'titles' => $this->title, '_code' => 'im', '_lhtitle' => 'images' ); if( !is_null( $images ) ) { if( is_array( $images ) ) { $tArray['imimages'] = implode( '|', $images ); } else $tArray['imimage'] = $images; } pecho( "Getting images used on {$this->title}..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result[0] as $image ){ $this->images[] = $image['title']; } } return $this->images; }
[ "public", "function", "get_images", "(", "$", "force", "=", "false", ",", "$", "images", "=", "null", ")", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "images", "!==", "null", ")", "{", "return", "$", "this", "->", "images", ";", ...
Returns images used in the page @link http://www.mediawiki.org/wiki/API:Query_-_Properties#images_.2F_im @param bool $force Force use of API, won't use cached copy (default: false) @param string|array $images Only list these images. Default null. @return bool|array False on error, returns array of image titles
[ "Returns", "images", "used", "in", "the", "page" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L647-L682
MW-Peachy/Peachy
Includes/Page.php
Page.get_extlinks
public function get_extlinks( $force = false ) { if( !$force && $this->extlinks !== null ) { return $this->extlinks; } $this->extlinks = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'extlinks', 'titles' => $this->title, '_code' => 'el', '_lhtitle' => 'extlinks' ); pecho( "Getting external links used on {$this->title}..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result as $extlink ){ $this->extlinks[] = $extlink['*']; } } return $this->extlinks; }
php
public function get_extlinks( $force = false ) { if( !$force && $this->extlinks !== null ) { return $this->extlinks; } $this->extlinks = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'extlinks', 'titles' => $this->title, '_code' => 'el', '_lhtitle' => 'extlinks' ); pecho( "Getting external links used on {$this->title}..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result as $extlink ){ $this->extlinks[] = $extlink['*']; } } return $this->extlinks; }
[ "public", "function", "get_extlinks", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "extlinks", "!==", "null", ")", "{", "return", "$", "this", "->", "extlinks", ";", "}", "$", "this", "->", "extl...
Returns external links used in the page @link http://www.mediawiki.org/wiki/API:Query_-_Properties#extlinks_.2F_el @param bool $force Force use of API, won't use cached copy (default: false) @return bool|array False on error, returns array of URLs
[ "Returns", "external", "links", "used", "in", "the", "page" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L691-L718
MW-Peachy/Peachy
Includes/Page.php
Page.get_langlinks
public function get_langlinks( $force = false, $fullurl = false, $title = null, $lang = null ) { if( !$force && $this->langlinks !== null ) { return $this->langlinks; } $this->langlinks = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'langlinks', 'titles' => $this->title, '_code' => 'll', '_lhtitle' => 'langlinks' ); if( !is_null( $lang ) ) $tArray['lllang'] = $lang; if( !is_null( $title ) ) $tArray['lltitle'] = $title; if( $fullurl ) $tArray['llurl'] = ''; pecho( "Getting all interlanguage links for {$this->title}..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result[0] as $langlink ){ if( $fullurl ) { $this->langlinks[] = array( 'link' => $langlink['lang'] . ":" . $langlink['*'], 'url' => $langlink['url'] ); } else $this->langlinks[] = $langlink['lang'] . ":" . $langlink['*']; } } return $this->langlinks; }
php
public function get_langlinks( $force = false, $fullurl = false, $title = null, $lang = null ) { if( !$force && $this->langlinks !== null ) { return $this->langlinks; } $this->langlinks = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'langlinks', 'titles' => $this->title, '_code' => 'll', '_lhtitle' => 'langlinks' ); if( !is_null( $lang ) ) $tArray['lllang'] = $lang; if( !is_null( $title ) ) $tArray['lltitle'] = $title; if( $fullurl ) $tArray['llurl'] = ''; pecho( "Getting all interlanguage links for {$this->title}..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result[0] as $langlink ){ if( $fullurl ) { $this->langlinks[] = array( 'link' => $langlink['lang'] . ":" . $langlink['*'], 'url' => $langlink['url'] ); } else $this->langlinks[] = $langlink['lang'] . ":" . $langlink['*']; } } return $this->langlinks; }
[ "public", "function", "get_langlinks", "(", "$", "force", "=", "false", ",", "$", "fullurl", "=", "false", ",", "$", "title", "=", "null", ",", "$", "lang", "=", "null", ")", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "langlinks", ...
Returns interlanguage links on the page @link http://www.mediawiki.org/wiki/API:Query_-_Properties#langlinks_.2F_ll @param bool $force Force use of API, won't use cached copy (default: false) @param bool $fullurl Include a list of full of URLs. Output formatting changes. Requires force parameter to be true to return a different result. @param string $title Link to search for. Must be used with $lang. Default null @param string $lang Language code. Default null @return bool|array False on error, returns array of links in the form of lang:title
[ "Returns", "interlanguage", "links", "on", "the", "page" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L730-L764
MW-Peachy/Peachy
Includes/Page.php
Page.get_interwikilinks
public function get_interwikilinks( $force = false, $fullurl = false, $title = null, $prefix = null ) { if( !$force && $this->iwlinks !== null ) { return $this->iwlinks; } $this->iwlinks = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'iwlinks', 'titles' => $this->title, '_code' => 'iw', '_lhtitle' => 'iwlinks' ); if( !is_null( $prefix ) ) $tArray['iwprefix'] = $prefix; if( !is_null( $title ) ) $tArray['iwtitle'] = $title; if( $fullurl ) $tArray['iwurl'] = ''; pecho( "Getting all interwiki links for {$this->title}..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result[0] as $iwlinks ){ if( $fullurl ) { $this->iwlinks[] = array( 'link' => $iwlinks['prefix'] . ":" . $iwlinks['*'], 'url' => $iwlinks['url'] ); } else $this->iwlinks[] = $iwlinks['prefix'] . ":" . $iwlinks['*']; } } return $this->iwlinks; }
php
public function get_interwikilinks( $force = false, $fullurl = false, $title = null, $prefix = null ) { if( !$force && $this->iwlinks !== null ) { return $this->iwlinks; } $this->iwlinks = array(); if( !$this->exists ) return array(); $tArray = array( 'prop' => 'iwlinks', 'titles' => $this->title, '_code' => 'iw', '_lhtitle' => 'iwlinks' ); if( !is_null( $prefix ) ) $tArray['iwprefix'] = $prefix; if( !is_null( $title ) ) $tArray['iwtitle'] = $title; if( $fullurl ) $tArray['iwurl'] = ''; pecho( "Getting all interwiki links for {$this->title}..\n\n", PECHO_NORMAL ); $result = $this->wiki->listHandler( $tArray ); if( count( $result ) > 0 ) { foreach( $result[0] as $iwlinks ){ if( $fullurl ) { $this->iwlinks[] = array( 'link' => $iwlinks['prefix'] . ":" . $iwlinks['*'], 'url' => $iwlinks['url'] ); } else $this->iwlinks[] = $iwlinks['prefix'] . ":" . $iwlinks['*']; } } return $this->iwlinks; }
[ "public", "function", "get_interwikilinks", "(", "$", "force", "=", "false", ",", "$", "fullurl", "=", "false", ",", "$", "title", "=", "null", ",", "$", "prefix", "=", "null", ")", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "iwlin...
Returns interwiki links on the page @link http://www.mediawiki.org/wiki/API:Query_-_Properties#langlinks_.2F_ll @param bool $force Force use of API, won't use cached copy (default: false) @param bool $fullurl Include a list of full of URLs. Output formatting changes. Requires force parameter to be true to return a different result. @param string $title Interwiki link to search for. Must be used with $prefix. Default null @param string $prefix Prefix for the interwiki. Default null @return bool|array False on error, returns array of links in the form of lang:title
[ "Returns", "interwiki", "links", "on", "the", "page" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L776-L811
MW-Peachy/Peachy
Includes/Page.php
Page.get_protection
public function get_protection( $force = false ) { if( !$force && $this->protection !== null ) { return $this->protection; } $this->protection = array(); $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'protection', 'titles' => $this->title, ); pecho( "Getting protection levels for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); $this->protection = $tRes['query']['pages'][$this->pageid]['protection']; return $this->protection; }
php
public function get_protection( $force = false ) { if( !$force && $this->protection !== null ) { return $this->protection; } $this->protection = array(); $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'protection', 'titles' => $this->title, ); pecho( "Getting protection levels for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); $this->protection = $tRes['query']['pages'][$this->pageid]['protection']; return $this->protection; }
[ "public", "function", "get_protection", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "protection", "!==", "null", ")", "{", "return", "$", "this", "->", "protection", ";", "}", "$", "this", "->", ...
Returns the protection level of the page @link http://www.mediawiki.org/wiki/API:Query_-_Properties#info_.2F_in @param bool $force Force use of API, won't use cached copy (default: false) @return bool|array False on error, returns array with protection levels
[ "Returns", "the", "protection", "level", "of", "the", "page" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L820-L843
MW-Peachy/Peachy
Includes/Page.php
Page.get_talkID
public function get_talkID( $force = false ) { if( !$force ) { return $this->talkid; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'talkid', 'titles' => $this->title, ); pecho( "Getting talk page ID for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['talkid'] ) ) { $this->talkid = $tRes['query']['pages'][$this->pageid]['talkid']; } else $this->talkid = null; return $this->talkid; }
php
public function get_talkID( $force = false ) { if( !$force ) { return $this->talkid; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'talkid', 'titles' => $this->title, ); pecho( "Getting talk page ID for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['talkid'] ) ) { $this->talkid = $tRes['query']['pages'][$this->pageid]['talkid']; } else $this->talkid = null; return $this->talkid; }
[ "public", "function", "get_talkID", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "force", ")", "{", "return", "$", "this", "->", "talkid", ";", "}", "$", "tArray", "=", "array", "(", "'action'", "=>", "'query'", ",", "'prop'", "=...
Returns the page ID of the talk page for each non-talk page @link http://www.mediawiki.org/wiki/API:Query_-_Properties#info_.2F_in @param bool $force Force use of API, won't use cached copy (default: false) @return int Null or empty if no id exists.
[ "Returns", "the", "page", "ID", "of", "the", "talk", "page", "for", "each", "non", "-", "talk", "page" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L852-L874
MW-Peachy/Peachy
Includes/Page.php
Page.is_watched
public function is_watched( $force = false ) { if( !$force && $this->watched !== null ) { return $this->watched; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'watched', 'titles' => $this->title, ); pecho( "Getting watch status for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['watched'] ) ) { $this->watched = true; } else $this->watched = false; return $this->watched; }
php
public function is_watched( $force = false ) { if( !$force && $this->watched !== null ) { return $this->watched; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'watched', 'titles' => $this->title, ); pecho( "Getting watch status for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['watched'] ) ) { $this->watched = true; } else $this->watched = false; return $this->watched; }
[ "public", "function", "is_watched", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "watched", "!==", "null", ")", "{", "return", "$", "this", "->", "watched", ";", "}", "$", "tArray", "=", "array",...
Returns the watch status of the page @link http://www.mediawiki.org/wiki/API:Query_-_Properties#info_.2F_in @param bool $force Force use of API, won't use cached copy (default: false) @return bool
[ "Returns", "the", "watch", "status", "of", "the", "page" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L883-L905
MW-Peachy/Peachy
Includes/Page.php
Page.get_watchcount
public function get_watchcount( $force = false ) { if( !$force && $this->watchers !== null ) { return $this->watchers; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'watchers', 'titles' => $this->title, ); pecho( "Getting watch count for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['watchers'] ) ) { $this->watchers = $tRes['query']['pages'][$this->pageid]['watchers']; } else $this->watchers = 0; return $this->watchers; }
php
public function get_watchcount( $force = false ) { if( !$force && $this->watchers !== null ) { return $this->watchers; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'watchers', 'titles' => $this->title, ); pecho( "Getting watch count for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['watchers'] ) ) { $this->watchers = $tRes['query']['pages'][$this->pageid]['watchers']; } else $this->watchers = 0; return $this->watchers; }
[ "public", "function", "get_watchcount", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "watchers", "!==", "null", ")", "{", "return", "$", "this", "->", "watchers", ";", "}", "$", "tArray", "=", "a...
Returns the count for the number of watchers of a page. @link http://www.mediawiki.org/wiki/API:Query_-_Properties#info_.2F_in @param bool $force Force use of API, won't use cached copy (default: false) @return int
[ "Returns", "the", "count", "for", "the", "number", "of", "watchers", "of", "a", "page", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L914-L936
MW-Peachy/Peachy
Includes/Page.php
Page.get_notificationtimestamp
public function get_notificationtimestamp( $force = false ) { if( !$force ) { return $this->watchlisttimestamp; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'notificationtimestamp', 'titles' => $this->title, ); pecho( "Getting the notification timestamp for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['notificationtimestamp'] ) ) { $this->watchlisttimestamp = $tRes['query']['pages'][$this->pageid]['notificationtimestamp']; } else $this->watchlisttimestamp = 0; return $this->watchlisttimestamp; }
php
public function get_notificationtimestamp( $force = false ) { if( !$force ) { return $this->watchlisttimestamp; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'notificationtimestamp', 'titles' => $this->title, ); pecho( "Getting the notification timestamp for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['notificationtimestamp'] ) ) { $this->watchlisttimestamp = $tRes['query']['pages'][$this->pageid]['notificationtimestamp']; } else $this->watchlisttimestamp = 0; return $this->watchlisttimestamp; }
[ "public", "function", "get_notificationtimestamp", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "force", ")", "{", "return", "$", "this", "->", "watchlisttimestamp", ";", "}", "$", "tArray", "=", "array", "(", "'action'", "=>", "'query...
Returns the watchlist notification timestamp of each page. @link http://www.mediawiki.org/wiki/API:Query_-_Properties#info_.2F_in @param bool $force Force use of API, won't use cached copy (default: false) @return string
[ "Returns", "the", "watchlist", "notification", "timestamp", "of", "each", "page", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L945-L967
MW-Peachy/Peachy
Includes/Page.php
Page.get_subjectid
public function get_subjectid( $force = false ) { if( !$force ) { return $this->subjectid; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'subjectid', 'titles' => $this->title, ); pecho( "Getting the parent page ID for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['subjectid'] ) ) { $this->subjectid = $tRes['query']['pages'][$this->pageid]['subjectid']; } else $this->subjectid = null; return $this->subjectid; }
php
public function get_subjectid( $force = false ) { if( !$force ) { return $this->subjectid; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'subjectid', 'titles' => $this->title, ); pecho( "Getting the parent page ID for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['subjectid'] ) ) { $this->subjectid = $tRes['query']['pages'][$this->pageid]['subjectid']; } else $this->subjectid = null; return $this->subjectid; }
[ "public", "function", "get_subjectid", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "force", ")", "{", "return", "$", "this", "->", "subjectid", ";", "}", "$", "tArray", "=", "array", "(", "'action'", "=>", "'query'", ",", "'prop'"...
Returns the page ID of the parent page for each talk page. @link http://www.mediawiki.org/wiki/API:Query_-_Properties#info_.2F_in @param bool $force Force use of API, won't use cached copy (default: false) @return int Null if it doesn't exist.
[ "Returns", "the", "page", "ID", "of", "the", "parent", "page", "for", "each", "talk", "page", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L976-L998
MW-Peachy/Peachy
Includes/Page.php
Page.get_urls
public function get_urls( $force = false ) { if( !$force && $this->urls !== null ) { return $this->urls; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'url', 'titles' => $this->title, ); pecho( "Getting the URLs for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); $info = $tRes['query']['pages'][$this->pageid]; $this->urls = array(); if( isset( $info['fullurl'] ) ) $this->urls['full'] = $info['fullurl']; if( isset( $info['editurl'] ) ) $this->urls['edit'] = $info['editurl']; return $this->urls; }
php
public function get_urls( $force = false ) { if( !$force && $this->urls !== null ) { return $this->urls; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'url', 'titles' => $this->title, ); pecho( "Getting the URLs for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); $info = $tRes['query']['pages'][$this->pageid]; $this->urls = array(); if( isset( $info['fullurl'] ) ) $this->urls['full'] = $info['fullurl']; if( isset( $info['editurl'] ) ) $this->urls['edit'] = $info['editurl']; return $this->urls; }
[ "public", "function", "get_urls", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "urls", "!==", "null", ")", "{", "return", "$", "this", "->", "urls", ";", "}", "$", "tArray", "=", "array", "(", ...
Gives a full URL to the page, and also an edit URL. @link http://www.mediawiki.org/wiki/API:Query_-_Properties#info_.2F_in @param bool $force Force use of API, won't use cached copy (default: false) @return array
[ "Gives", "a", "full", "URL", "to", "the", "page", "and", "also", "an", "edit", "URL", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1007-L1031
MW-Peachy/Peachy
Includes/Page.php
Page.get_readability
public function get_readability( $force = false ) { if( !$force && $this->readable !== null ) { return $this->readable; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'readable', 'titles' => $this->title, ); pecho( "Getting the readability status for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['readable'] ) ) { $this->readable = true; } else $this->readable = false; return $this->readable; }
php
public function get_readability( $force = false ) { if( !$force && $this->readable !== null ) { return $this->readable; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'readable', 'titles' => $this->title, ); pecho( "Getting the readability status for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['readable'] ) ) { $this->readable = true; } else $this->readable = false; return $this->readable; }
[ "public", "function", "get_readability", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "readable", "!==", "null", ")", "{", "return", "$", "this", "->", "readable", ";", "}", "$", "tArray", "=", "...
Returns whether the user can read this page. @link http://www.mediawiki.org/wiki/API:Query_-_Properties#info_.2F_in @param bool $force Force use of API, won't use cached copy (default: false) @return boolean Null if it doesn't exist.
[ "Returns", "whether", "the", "user", "can", "read", "this", "page", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1040-L1062
MW-Peachy/Peachy
Includes/Page.php
Page.get_preload
public function get_preload( $force = false ) { if( !$force ) { return $this->preload; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'preload', 'titles' => $this->title, ); pecho( "Getting the preload text for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['preload'] ) ) { $this->preload = $tRes['query']['pages'][$this->pageid]['preload']; } else $this->preload = null; return $this->preload; }
php
public function get_preload( $force = false ) { if( !$force ) { return $this->preload; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'preload', 'titles' => $this->title, ); pecho( "Getting the preload text for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['preload'] ) ) { $this->preload = $tRes['query']['pages'][$this->pageid]['preload']; } else $this->preload = null; return $this->preload; }
[ "public", "function", "get_preload", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "force", ")", "{", "return", "$", "this", "->", "preload", ";", "}", "$", "tArray", "=", "array", "(", "'action'", "=>", "'query'", ",", "'prop'", ...
Gives the text returned by EditFormPreloadText. @link http://www.mediawiki.org/wiki/API:Query_-_Properties#info_.2F_in @param bool $force Force use of API, won't use cached copy (default: false) @return string
[ "Gives", "the", "text", "returned", "by", "EditFormPreloadText", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1071-L1093
MW-Peachy/Peachy
Includes/Page.php
Page.get_displaytitle
public function get_displaytitle( $force = false ) { if( !$force ) { return $this->displaytitle; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'displaytitle', 'titles' => $this->title, ); pecho( "Getting the title formatting for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['displaytitle'] ) ) { $this->displaytitle = $tRes['query']['pages'][$this->pageid]['displaytitle']; } else $this->displaytitle = null; return $this->displaytitle; }
php
public function get_displaytitle( $force = false ) { if( !$force ) { return $this->displaytitle; } $tArray = array( 'action' => 'query', 'prop' => 'info', 'inprop' => 'displaytitle', 'titles' => $this->title, ); pecho( "Getting the title formatting for {$this->title}..\n\n", PECHO_NORMAL ); $tRes = $this->wiki->apiQuery( $tArray ); if( isset( $tRes['query']['pages'][$this->pageid]['displaytitle'] ) ) { $this->displaytitle = $tRes['query']['pages'][$this->pageid]['displaytitle']; } else $this->displaytitle = null; return $this->displaytitle; }
[ "public", "function", "get_displaytitle", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "force", ")", "{", "return", "$", "this", "->", "displaytitle", ";", "}", "$", "tArray", "=", "array", "(", "'action'", "=>", "'query'", ",", "'...
Gives the way the page title is actually displayed. @link http://www.mediawiki.org/wiki/API:Query_-_Properties#info_.2F_in @param bool $force Force use of API, won't use cached copy (default: false) @return string
[ "Gives", "the", "way", "the", "page", "title", "is", "actually", "displayed", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1102-L1124
MW-Peachy/Peachy
Includes/Page.php
Page.edit
public function edit( $text, $summary = "", $minor = false, $bot = true, $force = false, $pend = "", $create = false, $section = null, $sectiontitle = null, $watch = null ) { global $pgNotag, $pgTag; $tokens = $this->wiki->get_tokens(); if( !$pgNotag ) { $summary = substr( $summary . $pgTag, 0, 255 ); } if( $tokens['edit'] == '' ) { pecho( "User is not allowed to edit {$this->title}\n\n", PECHO_FATAL ); return false; } if( mb_strlen( $summary, '8bit' ) > 255 ) { pecho( "Summary is over 255 bytes, the maximum allowed.\n\n", PECHO_FATAL ); return false; } $editarray = array( 'title' => $this->title, 'action' => 'edit', 'token' => $tokens['edit'], 'basetimestamp' => $this->lastedit, 'md5' => md5( $text ), 'text' => $text ); if( !is_null( $this->starttimestamp ) ) $editarray['starttimestamp'] = $this->starttimestamp; if( !is_null( $section ) ) { if( $section == 'new' ) { if( is_null( $sectiontitle ) ) { pecho("Error: sectionTitle parameter must be specified. Aborting...\n\n", PECHO_FATAL); return false; } else { $editarray['section'] = 'new'; $editarray['sectionTitle'] = $sectiontitle; } } else $editarray['section'] = $section; } if( $pend == "pre" ) { $editarray['prependtext'] = $text; } elseif( $pend == "ap" ) { $editarray['appendtext'] = $text; } if( !is_null( $watch ) ) { if( $watch ) { $editarray['watchlist'] = 'watch'; } elseif( !$watch ) $editarray['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $editarray['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } if( $create == "never" ) { $editarray['nocreate'] = ''; } elseif( $create == "only" ) $editarray['createonly'] = ''; elseif( $create == "recreate" ) $editarray['recreate'] = ''; if( $this->wiki->get_maxlag() ) $editarray['maxlag'] = $this->wiki->get_maxlag(); if( !empty( $summary ) ) $editarray['summary'] = $summary; if( $minor ) { $editarray['minor'] = ''; } else $editarray['notminor'] = ''; if( $bot ) $editarray['bot'] = ''; if( !$force ) { try{ $this->preEditChecks( "Edit" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } } Hooks::runHook( 'StartEdit', array( &$editarray ) ); pecho( "Making edit to {$this->title}..\n\n", PECHO_NOTICE ); $result = $this->wiki->apiQuery( $editarray, true ); if( isset( $result['edit'] ) ) { if( $result['edit']['result'] == "Success" ) { if (array_key_exists('nochange', $result['edit'])) { return $this->lastedit; } $this->__construct( $this->wiki, null, $this->pageid ); if( !is_null( $this->wiki->get_edit_rate() ) && $this->wiki->get_edit_rate() != 0 ) { sleep( intval( 60 / $this->wiki->get_edit_rate() ) - 1 ); } return $result['edit']['newrevid']; } else { pecho( "Edit error...\n\n" . print_r( $result['edit'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Edit error...\n\n" . print_r( $result['edit'], true ) . "\n\n", PECHO_FATAL ); return false; } }
php
public function edit( $text, $summary = "", $minor = false, $bot = true, $force = false, $pend = "", $create = false, $section = null, $sectiontitle = null, $watch = null ) { global $pgNotag, $pgTag; $tokens = $this->wiki->get_tokens(); if( !$pgNotag ) { $summary = substr( $summary . $pgTag, 0, 255 ); } if( $tokens['edit'] == '' ) { pecho( "User is not allowed to edit {$this->title}\n\n", PECHO_FATAL ); return false; } if( mb_strlen( $summary, '8bit' ) > 255 ) { pecho( "Summary is over 255 bytes, the maximum allowed.\n\n", PECHO_FATAL ); return false; } $editarray = array( 'title' => $this->title, 'action' => 'edit', 'token' => $tokens['edit'], 'basetimestamp' => $this->lastedit, 'md5' => md5( $text ), 'text' => $text ); if( !is_null( $this->starttimestamp ) ) $editarray['starttimestamp'] = $this->starttimestamp; if( !is_null( $section ) ) { if( $section == 'new' ) { if( is_null( $sectiontitle ) ) { pecho("Error: sectionTitle parameter must be specified. Aborting...\n\n", PECHO_FATAL); return false; } else { $editarray['section'] = 'new'; $editarray['sectionTitle'] = $sectiontitle; } } else $editarray['section'] = $section; } if( $pend == "pre" ) { $editarray['prependtext'] = $text; } elseif( $pend == "ap" ) { $editarray['appendtext'] = $text; } if( !is_null( $watch ) ) { if( $watch ) { $editarray['watchlist'] = 'watch'; } elseif( !$watch ) $editarray['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $editarray['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } if( $create == "never" ) { $editarray['nocreate'] = ''; } elseif( $create == "only" ) $editarray['createonly'] = ''; elseif( $create == "recreate" ) $editarray['recreate'] = ''; if( $this->wiki->get_maxlag() ) $editarray['maxlag'] = $this->wiki->get_maxlag(); if( !empty( $summary ) ) $editarray['summary'] = $summary; if( $minor ) { $editarray['minor'] = ''; } else $editarray['notminor'] = ''; if( $bot ) $editarray['bot'] = ''; if( !$force ) { try{ $this->preEditChecks( "Edit" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } } Hooks::runHook( 'StartEdit', array( &$editarray ) ); pecho( "Making edit to {$this->title}..\n\n", PECHO_NOTICE ); $result = $this->wiki->apiQuery( $editarray, true ); if( isset( $result['edit'] ) ) { if( $result['edit']['result'] == "Success" ) { if (array_key_exists('nochange', $result['edit'])) { return $this->lastedit; } $this->__construct( $this->wiki, null, $this->pageid ); if( !is_null( $this->wiki->get_edit_rate() ) && $this->wiki->get_edit_rate() != 0 ) { sleep( intval( 60 / $this->wiki->get_edit_rate() ) - 1 ); } return $result['edit']['newrevid']; } else { pecho( "Edit error...\n\n" . print_r( $result['edit'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Edit error...\n\n" . print_r( $result['edit'], true ) . "\n\n", PECHO_FATAL ); return false; } }
[ "public", "function", "edit", "(", "$", "text", ",", "$", "summary", "=", "\"\"", ",", "$", "minor", "=", "false", ",", "$", "bot", "=", "true", ",", "$", "force", "=", "false", ",", "$", "pend", "=", "\"\"", ",", "$", "create", "=", "false", "...
Edits the page @link http://www.mediawiki.org/wiki/API:Edit_-_Create%26Edit_pages @param string $text Text of the page that will be saved @param string $summary Summary of the edit (default: "") @param bool $minor Minor edit (default: false) @param bool $bot Mark as bot edit (default: true) @param bool $force Override nobots check (default: false) @param string $pend Set to 'pre' or 'ap' to prepend or append, respectively (default: "") @param bool $create Set to 'never', 'only', or 'recreate' to never create a new page, only create a new page, or override errors about the page having been deleted, respectively (default: false) @param string $section Section number. 0 for the top section, 'new' for a new section. Default null. @param string $sectiontitle The title for a new section. Default null. @param string|bool $watch Unconditionally add or remove the page from your watchlist, use preferences or do not change watch. Default: go by user preference. @return string|int|bool The revision id of the successful edit, false on failure.
[ "Edits", "the", "page" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1142-L1265
MW-Peachy/Peachy
Includes/Page.php
Page.prepend
public function prepend( $text, $summary = "", $minor = false, $bot = true, $force = false, $create = false, $watch = null ) { return $this->edit( $text, $summary, $minor, $bot, $force, 'pre', $create, null, null, $watch ); }
php
public function prepend( $text, $summary = "", $minor = false, $bot = true, $force = false, $create = false, $watch = null ) { return $this->edit( $text, $summary, $minor, $bot, $force, 'pre', $create, null, null, $watch ); }
[ "public", "function", "prepend", "(", "$", "text", ",", "$", "summary", "=", "\"\"", ",", "$", "minor", "=", "false", ",", "$", "bot", "=", "true", ",", "$", "force", "=", "false", ",", "$", "create", "=", "false", ",", "$", "watch", "=", "null",...
Add text to the beginning of the page. Shortcut for Page::edit() @link http://www.mediawiki.org/wiki/API:Edit_-_Create%26Edit_pages @param string $text Text of the page that will be saved @param string $summary Summary of the edit (default: "") @param bool $minor Minor edit (default: false) @param bool $bot Mark as bot edit (default: true) @param bool $force Override nobots check (default: false) @param bool $create Set to 'never', 'only', or 'recreate' to never create a new page, only create a new page, or override errors about the page having been deleted, respectively (default: false) @param string|bool $watch Unconditionally add or remove the page from your watchlist, use preferences or do not change watch. Default: go by user preference. @return int|bool The revision id of the successful edit, false on failure.
[ "Add", "text", "to", "the", "beginning", "of", "the", "page", ".", "Shortcut", "for", "Page", "::", "edit", "()" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1280-L1282
MW-Peachy/Peachy
Includes/Page.php
Page.newsection
public function newsection( $text, $sectionTitle, $summary = null, $minor = false, $bot = true, $force = false, $create = false, $watch = null ) { if (is_null($summary)) { $summary = "/* " . $sectionTitle . " */ new section"; } return $this->edit($text, $summary, $minor, $bot, $force, false, $create, 'new', $sectionTitle, $watch); }
php
public function newsection( $text, $sectionTitle, $summary = null, $minor = false, $bot = true, $force = false, $create = false, $watch = null ) { if (is_null($summary)) { $summary = "/* " . $sectionTitle . " */ new section"; } return $this->edit($text, $summary, $minor, $bot, $force, false, $create, 'new', $sectionTitle, $watch); }
[ "public", "function", "newsection", "(", "$", "text", ",", "$", "sectionTitle", ",", "$", "summary", "=", "null", ",", "$", "minor", "=", "false", ",", "$", "bot", "=", "true", ",", "$", "force", "=", "false", ",", "$", "create", "=", "false", ",",...
Create a new section. Shortcut for Page::edit() @link http://www.mediawiki.org/wiki/API:Edit_-_Create%26Edit_pages @param string $text Text of the page that will be saved @param string $sectionTitle The title for a new section. Default null. @param string $summary Summary of the edit (default: "") @param bool $minor Minor edit (default: false) @param bool $bot Mark as bot edit (default: true) @param bool $force Override nobots check (default: false) @param bool $create Set to 'never', 'only', or 'recreate' to never create a new page, only create a new page, or override errors about the page having been deleted, respectively (default: false) @param string|bool $watch Unconditionally add or remove the page from your watchlist, use preferences or do not change watch. Default: go by user preference. @return int|bool The revision ID of the successful edit, false on failure.
[ "Create", "a", "new", "section", ".", "Shortcut", "for", "Page", "::", "edit", "()" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1318-L1333
MW-Peachy/Peachy
Includes/Page.php
Page.undo
public function undo($summary = null, $revisions = 1, $force = false, $watch = null ) { global $pgNotag, $pgTag; $info = $this->history( $revisions ); $oldrev = $info[( count( $info ) - 1 )]['revid']; $newrev = $info[0]['revid']; $tokens = $this->wiki->get_tokens(); if( $tokens['edit'] == '+\\' ) { pecho( "User has logged out.\n\n", PECHO_FATAL ); return false; } elseif( $tokens['edit'] == '' ) { pecho( "User is not allowed to edit {$this->title}\n\n", PECHO_FATAL ); return false; } $params = array( 'title' => $this->title, 'action' => 'edit', 'token' => $tokens['edit'], 'basetimestamp' => $this->lastedit, 'undo' => $oldrev, 'undoafter' => $newrev ); if( !is_null( $this->starttimestamp ) ) $params['starttimestamp'] = $this->starttimestamp; if( !is_null( $summary ) ) { if( mb_strlen( $summary, '8bit' ) > 255 ) { pecho( "Summary is over 255 bytes, the maximum allowed.\n\n", PECHO_FATAL ); return false; } if( !$pgNotag ) $summary .= $pgTag; $params['summary'] = $summary; } if( !is_null( $watch ) ) { if( $watch ) { $editarray['watchlist'] = 'watch'; } elseif( !$watch ) $editarray['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $editarray['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } if( !$force ) { try{ $this->preEditChecks( "Undo" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } } pecho( "Undoing revision(s) on {$this->title}...\n\n", PECHO_NORMAL ); $result = $this->wiki->apiQuery( $params, true ); if( $result['edit']['result'] == "Success") { if (array_key_exists('nochange', $result['edit'])) return $this->lastedit; $this->__construct( $this->wiki, null, $this->pageid ); if( !is_null( $this->wiki->get_edit_rate() ) && $this->wiki->get_edit_rate() != 0 ) { sleep( intval( 60 / $this->wiki->get_edit_rate() ) - 1 ); } return $result['edit']['newrevid']; } else { pecho( "Undo error...\n\n" . print_r( $result['edit'], true ) . "\n\n", PECHO_FATAL ); return false; } }
php
public function undo($summary = null, $revisions = 1, $force = false, $watch = null ) { global $pgNotag, $pgTag; $info = $this->history( $revisions ); $oldrev = $info[( count( $info ) - 1 )]['revid']; $newrev = $info[0]['revid']; $tokens = $this->wiki->get_tokens(); if( $tokens['edit'] == '+\\' ) { pecho( "User has logged out.\n\n", PECHO_FATAL ); return false; } elseif( $tokens['edit'] == '' ) { pecho( "User is not allowed to edit {$this->title}\n\n", PECHO_FATAL ); return false; } $params = array( 'title' => $this->title, 'action' => 'edit', 'token' => $tokens['edit'], 'basetimestamp' => $this->lastedit, 'undo' => $oldrev, 'undoafter' => $newrev ); if( !is_null( $this->starttimestamp ) ) $params['starttimestamp'] = $this->starttimestamp; if( !is_null( $summary ) ) { if( mb_strlen( $summary, '8bit' ) > 255 ) { pecho( "Summary is over 255 bytes, the maximum allowed.\n\n", PECHO_FATAL ); return false; } if( !$pgNotag ) $summary .= $pgTag; $params['summary'] = $summary; } if( !is_null( $watch ) ) { if( $watch ) { $editarray['watchlist'] = 'watch'; } elseif( !$watch ) $editarray['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $editarray['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } if( !$force ) { try{ $this->preEditChecks( "Undo" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } } pecho( "Undoing revision(s) on {$this->title}...\n\n", PECHO_NORMAL ); $result = $this->wiki->apiQuery( $params, true ); if( $result['edit']['result'] == "Success") { if (array_key_exists('nochange', $result['edit'])) return $this->lastedit; $this->__construct( $this->wiki, null, $this->pageid ); if( !is_null( $this->wiki->get_edit_rate() ) && $this->wiki->get_edit_rate() != 0 ) { sleep( intval( 60 / $this->wiki->get_edit_rate() ) - 1 ); } return $result['edit']['newrevid']; } else { pecho( "Undo error...\n\n" . print_r( $result['edit'], true ) . "\n\n", PECHO_FATAL ); return false; } }
[ "public", "function", "undo", "(", "$", "summary", "=", "null", ",", "$", "revisions", "=", "1", ",", "$", "force", "=", "false", ",", "$", "watch", "=", "null", ")", "{", "global", "$", "pgNotag", ",", "$", "pgTag", ";", "$", "info", "=", "$", ...
Undoes one or more edits. (Subject to standard editing restrictions.) @param string $summary Override the default edit summary (default null). @param int $revisions The number of revisions to undo (default 1). @param bool $force Force an undo, despite e.g. new messages (default false). @param bool|string $watch Unconditionally add or remove the page from your watchlist, use preferences or do not change watch. Default: goes by user preference. @return bool|int The new revision id of the page edited. @throws AssertFailure @throws LoggedOut @throws MWAPIError @throws NoTitle
[ "Undoes", "one", "or", "more", "edits", ".", "(", "Subject", "to", "standard", "editing", "restrictions", ".", ")" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1349-L1423
MW-Peachy/Peachy
Includes/Page.php
Page.get_discussion
public function get_discussion() { if( $this->namespace_id < 0 ) { // No discussion page exists // Guessing we want to error throw new BadEntryError( "get_discussion", "Tried to find the discussion page of a page which could never have one" ); } else { $namespaces = $this->wiki->get_namespaces(); if( $this->is_discussion() ) { return $namespaces[( $this->namespace_id - 1 )] . ":" . $this->title_wo_namespace; } else { return $namespaces[( $this->namespace_id + 1 )] . ":" . $this->title_wo_namespace; } } }
php
public function get_discussion() { if( $this->namespace_id < 0 ) { // No discussion page exists // Guessing we want to error throw new BadEntryError( "get_discussion", "Tried to find the discussion page of a page which could never have one" ); } else { $namespaces = $this->wiki->get_namespaces(); if( $this->is_discussion() ) { return $namespaces[( $this->namespace_id - 1 )] . ":" . $this->title_wo_namespace; } else { return $namespaces[( $this->namespace_id + 1 )] . ":" . $this->title_wo_namespace; } } }
[ "public", "function", "get_discussion", "(", ")", "{", "if", "(", "$", "this", "->", "namespace_id", "<", "0", ")", "{", "// No discussion page exists", "// Guessing we want to error", "throw", "new", "BadEntryError", "(", "\"get_discussion\"", ",", "\"Tried to find t...
Returns the title of the discussion (talk) page associated with a page, if it exists. @return string Title of discussion page @throws BadEntryError
[ "Returns", "the", "title", "of", "the", "discussion", "(", "talk", ")", "page", "associated", "with", "a", "page", "if", "it", "exists", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1450-L1463
MW-Peachy/Peachy
Includes/Page.php
Page.move
public function move( $newTitle, $reason = '', $movetalk = true, $movesubpages = true, $noredirect = false, $watch = null, $nowarnings = false ) { global $pgNotag, $pgTag; $tokens = $this->wiki->get_tokens(); if( $tokens['move'] == '+\\' ) { pecho( "User has logged out.\n\n", PECHO_FATAL ); return false; } elseif( $tokens['move'] == '' ) { pecho( "User is not allowed to move {$this->title}\n\n", PECHO_FATAL ); return false; } if( mb_strlen( $reason, '8bit' ) > 255 ) { pecho( "Reason is over 255 bytes, the maximum allowed.\n\n", PECHO_FATAL ); return false; } try{ $this->preEditChecks( "Move" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } pecho( "Moving {$this->title} to $newTitle...\n\n", PECHO_NOTICE ); $editarray = array( 'from' => $this->title, 'to' => $newTitle, 'action' => 'move', 'token' => $tokens['move'], ); if( !is_null( $watch ) ) { if( $watch ) { $editarray['watchlist'] = 'watch'; } elseif( !$watch ) $editarray['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $editarray['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } if( $nowarnings ) $editarray['ignorewarnings'] = ''; if( !$pgNotag ) $reason .= $pgTag; if( !empty( $reason ) ) $editarray['reason'] = $reason; if( $movetalk ) $editarray['movetalk'] = ''; if( $movesubpages ) $editarray['movesubpages'] = ''; if( $noredirect ) $editarray['noredirect'] = ''; if( $this->wiki->get_maxlag() ) { $editarray['maxlag'] = $this->wiki->get_maxlag(); } Hooks::runHook( 'StartMove', array( &$editarray ) ); $result = $this->wiki->apiQuery( $editarray, true ); if( isset( $result['move'] ) ) { if( isset( $result['move']['to'] ) ) { $this->__construct( $this->wiki, null, $this->pageid ); return true; } else { pecho( "Move error...\n\n" . print_r( $result['move'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Move error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
php
public function move( $newTitle, $reason = '', $movetalk = true, $movesubpages = true, $noredirect = false, $watch = null, $nowarnings = false ) { global $pgNotag, $pgTag; $tokens = $this->wiki->get_tokens(); if( $tokens['move'] == '+\\' ) { pecho( "User has logged out.\n\n", PECHO_FATAL ); return false; } elseif( $tokens['move'] == '' ) { pecho( "User is not allowed to move {$this->title}\n\n", PECHO_FATAL ); return false; } if( mb_strlen( $reason, '8bit' ) > 255 ) { pecho( "Reason is over 255 bytes, the maximum allowed.\n\n", PECHO_FATAL ); return false; } try{ $this->preEditChecks( "Move" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } pecho( "Moving {$this->title} to $newTitle...\n\n", PECHO_NOTICE ); $editarray = array( 'from' => $this->title, 'to' => $newTitle, 'action' => 'move', 'token' => $tokens['move'], ); if( !is_null( $watch ) ) { if( $watch ) { $editarray['watchlist'] = 'watch'; } elseif( !$watch ) $editarray['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $editarray['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } if( $nowarnings ) $editarray['ignorewarnings'] = ''; if( !$pgNotag ) $reason .= $pgTag; if( !empty( $reason ) ) $editarray['reason'] = $reason; if( $movetalk ) $editarray['movetalk'] = ''; if( $movesubpages ) $editarray['movesubpages'] = ''; if( $noredirect ) $editarray['noredirect'] = ''; if( $this->wiki->get_maxlag() ) { $editarray['maxlag'] = $this->wiki->get_maxlag(); } Hooks::runHook( 'StartMove', array( &$editarray ) ); $result = $this->wiki->apiQuery( $editarray, true ); if( isset( $result['move'] ) ) { if( isset( $result['move']['to'] ) ) { $this->__construct( $this->wiki, null, $this->pageid ); return true; } else { pecho( "Move error...\n\n" . print_r( $result['move'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Move error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
[ "public", "function", "move", "(", "$", "newTitle", ",", "$", "reason", "=", "''", ",", "$", "movetalk", "=", "true", ",", "$", "movesubpages", "=", "true", ",", "$", "noredirect", "=", "false", ",", "$", "watch", "=", "null", ",", "$", "nowarnings",...
Moves a page to a new location. @param string $newTitle The new title to which to move the page. @param string $reason A descriptive reason for the move. @param bool $movetalk Whether or not to move any associated talk (discussion) page. @param bool $movesubpages Whether or not to move any subpages. @param bool $noredirect Whether or not to suppress the leaving of a redirect to the new title at the old title. @param string|bool $watch Unconditionally add or remove the page from your watchlist, use preferences or do not change watch. Default: go by user preference. @param bool $nowarnings Ignore any warnings. Default false. @return bool True on success
[ "Moves", "a", "page", "to", "a", "new", "location", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1477-L1552
MW-Peachy/Peachy
Includes/Page.php
Page.protect
public function protect( $levels = null, $reason = null, $expiry = 'indefinite', $cascade = false, $watch = null ) { global $pgNotag, $pgTag; if( !in_array( 'protect', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to protect pages", PECHO_FATAL ); return false; } if( $levels === null ){ $levels = array( 'edit' => 'sysop', 'move' => 'sysop' ); } $tokens = $this->wiki->get_tokens(); if( !$pgNotag ) $reason .= $pgTag; $editarray = array( 'action' => 'protect', 'title' => $this->title, 'token' => $tokens['protect'], 'reason' => $reason, 'protections' => array(), 'expiry' => $expiry ); foreach( $levels as $type => $level ){ $editarray['protections'][] = "$type=$level"; } $editarray['protections'] = implode( "|", $editarray['protections'] ); if( $cascade ) $editarray['cascade'] = ''; if( !is_null( $watch ) ) { if( $watch ) { $editarray['watchlist'] = 'watch'; } elseif( !$watch ) $editarray['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $editarray['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } try{ $this->preEditChecks( "Protect" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } if( !$editarray['protections'] == array() ) { pecho( "Protecting {$this->title}...\n\n", PECHO_NOTICE ); } else pecho( "Unprotecting {$this->title}...\n\n", PECHO_NOTICE ); Hooks::runHook( 'StartProtect', array( &$editarray ) ); $result = $this->wiki->apiQuery( $editarray, true ); if( isset( $result['protect'] ) ) { if( isset( $result['protect']['title'] ) ) { $this->__construct( $this->wiki, $this->title ); return true; } else { pecho( "Protect error...\n\n" . print_r( $result['protect'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Protect error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
php
public function protect( $levels = null, $reason = null, $expiry = 'indefinite', $cascade = false, $watch = null ) { global $pgNotag, $pgTag; if( !in_array( 'protect', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to protect pages", PECHO_FATAL ); return false; } if( $levels === null ){ $levels = array( 'edit' => 'sysop', 'move' => 'sysop' ); } $tokens = $this->wiki->get_tokens(); if( !$pgNotag ) $reason .= $pgTag; $editarray = array( 'action' => 'protect', 'title' => $this->title, 'token' => $tokens['protect'], 'reason' => $reason, 'protections' => array(), 'expiry' => $expiry ); foreach( $levels as $type => $level ){ $editarray['protections'][] = "$type=$level"; } $editarray['protections'] = implode( "|", $editarray['protections'] ); if( $cascade ) $editarray['cascade'] = ''; if( !is_null( $watch ) ) { if( $watch ) { $editarray['watchlist'] = 'watch'; } elseif( !$watch ) $editarray['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $editarray['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } try{ $this->preEditChecks( "Protect" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } if( !$editarray['protections'] == array() ) { pecho( "Protecting {$this->title}...\n\n", PECHO_NOTICE ); } else pecho( "Unprotecting {$this->title}...\n\n", PECHO_NOTICE ); Hooks::runHook( 'StartProtect', array( &$editarray ) ); $result = $this->wiki->apiQuery( $editarray, true ); if( isset( $result['protect'] ) ) { if( isset( $result['protect']['title'] ) ) { $this->__construct( $this->wiki, $this->title ); return true; } else { pecho( "Protect error...\n\n" . print_r( $result['protect'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Protect error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
[ "public", "function", "protect", "(", "$", "levels", "=", "null", ",", "$", "reason", "=", "null", ",", "$", "expiry", "=", "'indefinite'", ",", "$", "cascade", "=", "false", ",", "$", "watch", "=", "null", ")", "{", "global", "$", "pgNotag", ",", ...
Protects the page. @param array $levels Array of protections levels. The key is the type, the value is the level. Default: array( 'edit' => 'sysop', 'move' => 'sysop' ) @param string $reason Reason for protection. Default null @param string $expiry Expiry time. Default 'indefinite' @param bool $cascade Whether or not to enable cascade protection. Default false @param string|bool $watch Unconditionally add or remove the page from your watchlist, use preferences or do not change watch. Default: go by user preference. @return bool True on success
[ "Protects", "the", "page", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1564-L1632
MW-Peachy/Peachy
Includes/Page.php
Page.unprotect
public function unprotect( $reason = null, $watch = null ) { return $this->protect( array(), $reason, 'indefinite', false, $watch ); }
php
public function unprotect( $reason = null, $watch = null ) { return $this->protect( array(), $reason, 'indefinite', false, $watch ); }
[ "public", "function", "unprotect", "(", "$", "reason", "=", "null", ",", "$", "watch", "=", "null", ")", "{", "return", "$", "this", "->", "protect", "(", "array", "(", ")", ",", "$", "reason", ",", "'indefinite'", ",", "false", ",", "$", "watch", ...
Unprotects the page. @param string $reason A reason for the unprotection. Defaults to null (blank). @param string|bool $watch Unconditionally add or remove the page from your watchlist, use preferences or do not change watch. Default: go by user preference. @return bool True on success
[ "Unprotects", "the", "page", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1641-L1643
MW-Peachy/Peachy
Includes/Page.php
Page.delete
public function delete( $reason = null, $watch = null, $oldimage = null ) { global $pgNotag, $pgTag; if( !in_array( 'delete', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to delete pages", PECHO_FATAL ); return false; } $tokens = $this->wiki->get_tokens(); if( !$pgNotag ) $reason .= $pgTag; $editarray = array( 'action' => 'delete', 'title' => $this->title, 'token' => $tokens['delete'], 'reason' => $reason ); if( !is_null( $watch ) ) { if( $watch ) { $editarray['watchlist'] = 'watch'; } elseif( !$watch ) $editarray['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $editarray['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } if( !is_null( $oldimage ) ) $editarray['oldimage'] = $oldimage; Hooks::runHook( 'StartDelete', array( &$editarray ) ); try{ $this->preEditChecks( "Delete" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } pecho( "Deleting {$this->title}...\n\n", PECHO_NOTICE ); $result = $this->wiki->apiQuery( $editarray, true ); if( isset( $result['delete'] ) ) { if( isset( $result['delete']['title'] ) ) { $this->__construct( $this->wiki, $this->title ); return true; } else { pecho( "Delete error...\n\n" . print_r( $result['delete'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Delete error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
php
public function delete( $reason = null, $watch = null, $oldimage = null ) { global $pgNotag, $pgTag; if( !in_array( 'delete', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to delete pages", PECHO_FATAL ); return false; } $tokens = $this->wiki->get_tokens(); if( !$pgNotag ) $reason .= $pgTag; $editarray = array( 'action' => 'delete', 'title' => $this->title, 'token' => $tokens['delete'], 'reason' => $reason ); if( !is_null( $watch ) ) { if( $watch ) { $editarray['watchlist'] = 'watch'; } elseif( !$watch ) $editarray['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $editarray['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } if( !is_null( $oldimage ) ) $editarray['oldimage'] = $oldimage; Hooks::runHook( 'StartDelete', array( &$editarray ) ); try{ $this->preEditChecks( "Delete" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } pecho( "Deleting {$this->title}...\n\n", PECHO_NOTICE ); $result = $this->wiki->apiQuery( $editarray, true ); if( isset( $result['delete'] ) ) { if( isset( $result['delete']['title'] ) ) { $this->__construct( $this->wiki, $this->title ); return true; } else { pecho( "Delete error...\n\n" . print_r( $result['delete'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Delete error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
[ "public", "function", "delete", "(", "$", "reason", "=", "null", ",", "$", "watch", "=", "null", ",", "$", "oldimage", "=", "null", ")", "{", "global", "$", "pgNotag", ",", "$", "pgTag", ";", "if", "(", "!", "in_array", "(", "'delete'", ",", "$", ...
Deletes the page. @param string $reason A reason for the deletion. Defaults to null (blank). @param string|bool $watch Unconditionally add or remove the page from your watchlist, use preferences or do not change watch. Default: go by user preference. @param string $oldimage The name of the old image to delete as provided by iiprop=archivename @return bool True on success
[ "Deletes", "the", "page", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1653-L1709
MW-Peachy/Peachy
Includes/Page.php
Page.undelete
public function undelete( $reason = null, $timestamps = null, $watch = null ) { global $pgNotag, $pgTag; if( !in_array( 'undelete', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to undelete pages", PECHO_FATAL ); return false; } $tokens = $this->wiki->get_tokens(); if( !$pgNotag ) $reason .= $pgTag; $undelArray = array( 'action' => 'undelete', 'title' => $this->title, 'token' => $tokens['delete'], //Using the delete token, it's the exact same, and we don't have to do another API call 'reason' => $reason ); if( !is_null( $timestamps ) ) { $undelArray['timestamps'] = $timestamps; if( is_array( $timestamps ) ) { $undelArray['timestamps'] = implode( '|', $timestamps ); } } if( !is_null( $watch ) ) { if( $watch ) { $undelArray['watchlist'] = 'watch'; } elseif( !$watch ) $undelArray['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $undelArray['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } try{ $this->preEditChecks( "Undelete" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } pecho( "Undeleting {$this->title}...\n\n", PECHO_NOTICE ); Hooks::runHook( 'StartUndelete', array( &$undelArray ) ); $result = $this->wiki->apiQuery( $undelArray, true ); if( isset( $result['undelete'] ) ) { if( isset( $result['undelete']['title'] ) ) { $this->__construct( $this->wiki, $this->title ); return true; } else { pecho( "Undelete error...\n\n" . print_r( $result['undelete'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Undelete error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
php
public function undelete( $reason = null, $timestamps = null, $watch = null ) { global $pgNotag, $pgTag; if( !in_array( 'undelete', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to undelete pages", PECHO_FATAL ); return false; } $tokens = $this->wiki->get_tokens(); if( !$pgNotag ) $reason .= $pgTag; $undelArray = array( 'action' => 'undelete', 'title' => $this->title, 'token' => $tokens['delete'], //Using the delete token, it's the exact same, and we don't have to do another API call 'reason' => $reason ); if( !is_null( $timestamps ) ) { $undelArray['timestamps'] = $timestamps; if( is_array( $timestamps ) ) { $undelArray['timestamps'] = implode( '|', $timestamps ); } } if( !is_null( $watch ) ) { if( $watch ) { $undelArray['watchlist'] = 'watch'; } elseif( !$watch ) $undelArray['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $undelArray['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } try{ $this->preEditChecks( "Undelete" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } pecho( "Undeleting {$this->title}...\n\n", PECHO_NOTICE ); Hooks::runHook( 'StartUndelete', array( &$undelArray ) ); $result = $this->wiki->apiQuery( $undelArray, true ); if( isset( $result['undelete'] ) ) { if( isset( $result['undelete']['title'] ) ) { $this->__construct( $this->wiki, $this->title ); return true; } else { pecho( "Undelete error...\n\n" . print_r( $result['undelete'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Undelete error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
[ "public", "function", "undelete", "(", "$", "reason", "=", "null", ",", "$", "timestamps", "=", "null", ",", "$", "watch", "=", "null", ")", "{", "global", "$", "pgNotag", ",", "$", "pgTag", ";", "if", "(", "!", "in_array", "(", "'undelete'", ",", ...
Undeletes the page @param string $reason Reason for undeletion @param array $timestamps Array of timestamps to selectively restore @param string|bool $watch Unconditionally add or remove the page from your watchlist, use preferences or do not change watch. Default: go by user preference. @return bool
[ "Undeletes", "the", "page" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1719-L1780
MW-Peachy/Peachy
Includes/Page.php
Page.deletedrevs
public function deletedrevs( $content = false, $user = null, $excludeuser = null, $start = null, $end = null, $dir = 'older', $prop = array( 'revid', 'user', 'parsedcomment', 'minor', 'len', 'content', 'token' ) ) { if( !in_array( 'deletedhistory', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to view deleted revisions", PECHO_FATAL ); return false; } if( $content ) $prop[] = 'content'; $drArray = array( '_code' => 'dr', 'list' => 'deletedrevs', 'titles' => $this->title, 'drprop' => implode( '|', $prop ), 'drdir' => $dir ); if( !is_null( $user ) ) $drArray['druser'] = $user; if( !is_null( $excludeuser ) ) $drArray['drexcludeuser'] = $excludeuser; if( !is_null( $start ) ) $drArray['drstart'] = $start; if( !is_null( $end ) ) $drArray['drend'] = $end; pecho( "Getting deleted revisions of {$this->title}...\n\n", PECHO_NORMAL ); return $this->wiki->listHandler( $drArray ); }
php
public function deletedrevs( $content = false, $user = null, $excludeuser = null, $start = null, $end = null, $dir = 'older', $prop = array( 'revid', 'user', 'parsedcomment', 'minor', 'len', 'content', 'token' ) ) { if( !in_array( 'deletedhistory', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to view deleted revisions", PECHO_FATAL ); return false; } if( $content ) $prop[] = 'content'; $drArray = array( '_code' => 'dr', 'list' => 'deletedrevs', 'titles' => $this->title, 'drprop' => implode( '|', $prop ), 'drdir' => $dir ); if( !is_null( $user ) ) $drArray['druser'] = $user; if( !is_null( $excludeuser ) ) $drArray['drexcludeuser'] = $excludeuser; if( !is_null( $start ) ) $drArray['drstart'] = $start; if( !is_null( $end ) ) $drArray['drend'] = $end; pecho( "Getting deleted revisions of {$this->title}...\n\n", PECHO_NORMAL ); return $this->wiki->listHandler( $drArray ); }
[ "public", "function", "deletedrevs", "(", "$", "content", "=", "false", ",", "$", "user", "=", "null", ",", "$", "excludeuser", "=", "null", ",", "$", "start", "=", "null", ",", "$", "end", "=", "null", ",", "$", "dir", "=", "'older'", ",", "$", ...
List deleted revisions of the page @param bool $content Whether or not to retrieve the content of each revision, Default false @param string $user Only list revisions by this user. Default null. @param string $excludeuser Don't list revisions by this user. Default null @param string $start Timestamp to start at. Default null @param string $end Timestamp to end at. Default null @param string $dir Direction to enumerate. Default 'older' @param array $prop Properties to retrieve. Default array( 'revid', 'user', 'parsedcomment', 'minor', 'len', 'content', 'token' ) @return array List of deleted revisions
[ "List", "deleted", "revisions", "of", "the", "page" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1794-L1820
MW-Peachy/Peachy
Includes/Page.php
Page.watch
public function watch( $lang = null ) { Hooks::runHook( 'StartWatch' ); pecho( "Watching {$this->title}...\n\n", PECHO_NOTICE ); $tokens = $this->wiki->get_tokens(); if( $tokens['watch'] == '+\\' ) { pecho( "User has logged out.\n\n", PECHO_FATAL ); return false; } $apiArray = array( 'action' => 'watch', 'token' => $tokens['watch'], 'title' => $this->title ); if( !is_null( $lang ) ) $apiArray['uselang'] = $lang; $result = $this->wiki->apiQuery( $apiArray, true ); if( isset( $result['watch'] ) ) { if( isset( $result['watch']['watched'] ) ) { return true; } else { pecho( "Watch error...\n\n" . print_r( $result['watch'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Watch error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
php
public function watch( $lang = null ) { Hooks::runHook( 'StartWatch' ); pecho( "Watching {$this->title}...\n\n", PECHO_NOTICE ); $tokens = $this->wiki->get_tokens(); if( $tokens['watch'] == '+\\' ) { pecho( "User has logged out.\n\n", PECHO_FATAL ); return false; } $apiArray = array( 'action' => 'watch', 'token' => $tokens['watch'], 'title' => $this->title ); if( !is_null( $lang ) ) $apiArray['uselang'] = $lang; $result = $this->wiki->apiQuery( $apiArray, true ); if( isset( $result['watch'] ) ) { if( isset( $result['watch']['watched'] ) ) { return true; } else { pecho( "Watch error...\n\n" . print_r( $result['watch'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Watch error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
[ "public", "function", "watch", "(", "$", "lang", "=", "null", ")", "{", "Hooks", "::", "runHook", "(", "'StartWatch'", ")", ";", "pecho", "(", "\"Watching {$this->title}...\\n\\n\"", ",", "PECHO_NOTICE", ")", ";", "$", "tokens", "=", "$", "this", "->", "wi...
Adds the page to the logged in user's watchlist @param string $lang The code for the language to show any error message in (default: user preference) @return bool True on success
[ "Adds", "the", "page", "to", "the", "logged", "in", "user", "s", "watchlist" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1842-L1877
MW-Peachy/Peachy
Includes/Page.php
Page.get_namespace
public function get_namespace( $id = true ) { if( $id ) { return $this->namespace_id; } else { $namespaces = $this->wiki->get_namespaces(); return $namespaces[$this->namespace_id]; } }
php
public function get_namespace( $id = true ) { if( $id ) { return $this->namespace_id; } else { $namespaces = $this->wiki->get_namespaces(); return $namespaces[$this->namespace_id]; } }
[ "public", "function", "get_namespace", "(", "$", "id", "=", "true", ")", "{", "if", "(", "$", "id", ")", "{", "return", "$", "this", "->", "namespace_id", ";", "}", "else", "{", "$", "namespaces", "=", "$", "this", "->", "wiki", "->", "get_namespaces...
Gets ID or name of the namespace @param bool $id Set to true to get namespace ID, set to false to get namespace name. Default true @return int|string
[ "Gets", "ID", "or", "name", "of", "the", "namespace" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L1959-L1967
MW-Peachy/Peachy
Includes/Page.php
Page.get_metadata
protected function get_metadata( $pageInfoArray2 = null ) { $pageInfoArray = array( 'action' => 'query', 'prop' => "info" ); $pageInfoArray['inprop'] = 'protection|talkid|watched|watchers|notificationtimestamp|subjectid|url|readable|preload|displaytitle'; if( $pageInfoArray2 != null ) { $pageInfoArray = array_merge( $pageInfoArray, $pageInfoArray2 ); } else { $pageInfoArray['titles'] = $this->title; } $pageInfoRes = $this->wiki->apiQuery( $pageInfoArray ); if( isset( $pageInfoRes['warnings']['query']['*'] ) && in_string( 'special pages', $pageInfoRes['warnings']['query']['*'] ) ) { pecho( "Special pages are not currently supported by the API.\n\n", PECHO_ERROR ); $this->exists = false; $this->special = true; } if( isset( $pageInfoRes['query']['redirects'][0] ) ) { $this->redirectFollowed = true; } foreach( $pageInfoRes['query']['pages'] as $key => $info ){ $this->pageid = $key; if( $this->pageid > 0 ) { $this->exists = true; $this->lastedit = $info['touched']; $this->hits = isset( $info['counter'] ) ? $info['counter'] : ''; $this->length = $info['length']; } else { $this->pageid = 0; $this->lastedit = ''; $this->hits = ''; $this->length = ''; $this->starttimestamp = ''; } if( isset( $info['missing'] ) ) $this->exists = false; if( isset( $info['invalid'] ) ) throw new BadTitle( $this->title ); $this->title = $info['title']; $this->namespace_id = $info['ns']; if( $this->namespace_id != 0) { $title_wo_namespace = explode(':', $this->title, 2); $this->title_wo_namespace = $title_wo_namespace[1]; } else { $this->title_wo_namespace = $this->title; } if( isset( $info['special'] ) ) $this->special = true; if( isset( $info['protection'] ) ) $this->protection = $info['protection']; if( isset( $info['talkid'] ) ) $this->talkid = $info['talkid']; if( isset( $info['watched'] ) ) $this->watched = true; if( isset( $info['watchers'] ) ) $this->watchers = $info['watchers']; if( isset( $info['notificationtimestamp'] ) ) $this->watchlisttimestamp = $info['notificationtimestamp']; if( isset( $info['subjectid'] ) ) $this->subjectid = $info['subjectid']; if( isset( $info['fullurl'] ) ) $this->urls['full'] = $info['fullurl']; if( isset( $info['editurl'] ) ) $this->urls['edit'] = $info['editurl']; if( isset( $info['readable'] ) ) $this->readable = true; if( isset( $info['preload'] ) ) $this->preload = $info['preload']; if( isset( $info['displaytitle'] ) ) $this->displaytitle = $info['displaytitle']; } }
php
protected function get_metadata( $pageInfoArray2 = null ) { $pageInfoArray = array( 'action' => 'query', 'prop' => "info" ); $pageInfoArray['inprop'] = 'protection|talkid|watched|watchers|notificationtimestamp|subjectid|url|readable|preload|displaytitle'; if( $pageInfoArray2 != null ) { $pageInfoArray = array_merge( $pageInfoArray, $pageInfoArray2 ); } else { $pageInfoArray['titles'] = $this->title; } $pageInfoRes = $this->wiki->apiQuery( $pageInfoArray ); if( isset( $pageInfoRes['warnings']['query']['*'] ) && in_string( 'special pages', $pageInfoRes['warnings']['query']['*'] ) ) { pecho( "Special pages are not currently supported by the API.\n\n", PECHO_ERROR ); $this->exists = false; $this->special = true; } if( isset( $pageInfoRes['query']['redirects'][0] ) ) { $this->redirectFollowed = true; } foreach( $pageInfoRes['query']['pages'] as $key => $info ){ $this->pageid = $key; if( $this->pageid > 0 ) { $this->exists = true; $this->lastedit = $info['touched']; $this->hits = isset( $info['counter'] ) ? $info['counter'] : ''; $this->length = $info['length']; } else { $this->pageid = 0; $this->lastedit = ''; $this->hits = ''; $this->length = ''; $this->starttimestamp = ''; } if( isset( $info['missing'] ) ) $this->exists = false; if( isset( $info['invalid'] ) ) throw new BadTitle( $this->title ); $this->title = $info['title']; $this->namespace_id = $info['ns']; if( $this->namespace_id != 0) { $title_wo_namespace = explode(':', $this->title, 2); $this->title_wo_namespace = $title_wo_namespace[1]; } else { $this->title_wo_namespace = $this->title; } if( isset( $info['special'] ) ) $this->special = true; if( isset( $info['protection'] ) ) $this->protection = $info['protection']; if( isset( $info['talkid'] ) ) $this->talkid = $info['talkid']; if( isset( $info['watched'] ) ) $this->watched = true; if( isset( $info['watchers'] ) ) $this->watchers = $info['watchers']; if( isset( $info['notificationtimestamp'] ) ) $this->watchlisttimestamp = $info['notificationtimestamp']; if( isset( $info['subjectid'] ) ) $this->subjectid = $info['subjectid']; if( isset( $info['fullurl'] ) ) $this->urls['full'] = $info['fullurl']; if( isset( $info['editurl'] ) ) $this->urls['edit'] = $info['editurl']; if( isset( $info['readable'] ) ) $this->readable = true; if( isset( $info['preload'] ) ) $this->preload = $info['preload']; if( isset( $info['displaytitle'] ) ) $this->displaytitle = $info['displaytitle']; } }
[ "protected", "function", "get_metadata", "(", "$", "pageInfoArray2", "=", "null", ")", "{", "$", "pageInfoArray", "=", "array", "(", "'action'", "=>", "'query'", ",", "'prop'", "=>", "\"info\"", ")", ";", "$", "pageInfoArray", "[", "'inprop'", "]", "=", "'...
(Re)generates lastedit, length, and hits @param array $pageInfoArray2 Array of values to merge with defaults (default: null) @throws BadTitle
[ "(", "Re", ")", "generates", "lastedit", "length", "and", "hits" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L2011-L2079
MW-Peachy/Peachy
Includes/Page.php
Page.get_backlinks
public function get_backlinks( $namespaces = array( 0 ), $redirects = 'all', $followredir = true ) { $leArray = array( 'list' => 'backlinks', '_code' => 'bl', 'blnamespace' => $namespaces, 'blfilterredir' => $redirects, 'bltitle' => $this->title ); if( $followredir ) $leArray['blredirect'] = ''; Hooks::runHook( 'PreQueryBacklinks', array( &$leArray ) ); pecho( "Getting all links to {$this->title}...\n\n", PECHO_NORMAL ); return $this->wiki->listHandler( $leArray ); }
php
public function get_backlinks( $namespaces = array( 0 ), $redirects = 'all', $followredir = true ) { $leArray = array( 'list' => 'backlinks', '_code' => 'bl', 'blnamespace' => $namespaces, 'blfilterredir' => $redirects, 'bltitle' => $this->title ); if( $followredir ) $leArray['blredirect'] = ''; Hooks::runHook( 'PreQueryBacklinks', array( &$leArray ) ); pecho( "Getting all links to {$this->title}...\n\n", PECHO_NORMAL ); return $this->wiki->listHandler( $leArray ); }
[ "public", "function", "get_backlinks", "(", "$", "namespaces", "=", "array", "(", "0", ")", ",", "$", "redirects", "=", "'all'", ",", "$", "followredir", "=", "true", ")", "{", "$", "leArray", "=", "array", "(", "'list'", "=>", "'backlinks'", ",", "'_c...
Returns all links to the page @param array $namespaces Namespaces to get. Default array( 0 ); @param string $redirects How to handle redirects. 'all' = List all pages. 'redirects' = Only list redirects. 'nonredirects' = Don't list redirects. Default 'all' @param bool $followredir List links through redirects to the page @return array List of backlinks
[ "Returns", "all", "links", "to", "the", "page" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L2089-L2105
MW-Peachy/Peachy
Includes/Page.php
Page.rollback
public function rollback( $force = false, $summary = null, $markbot = false, $watch = null ) { global $pgNotag, $pgTag; if( !in_array( 'rollback', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to rollback edits", PECHO_FATAL ); return false; } if( !$force ) { try{ $this->preEditChecks(); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } } $history = $this->history( 1, 'older', false, null, true ); $params = array( 'action' => 'rollback', 'title' => $this->title, 'user' => $history[0]['user'], 'token' => $history[0]['rollbacktoken'], ); if( !is_null( $summary ) ) { if( mb_strlen( $summary, '8bit' ) > 255 ) { pecho( "Summary is over 255 bytes, the maximum allowed.\n\n", PECHO_FATAL ); return false; } if( !$pgNotag ) $summary .= $pgTag; $params['summary'] = $summary; } if( $markbot ) $params['markbot'] = ''; if( !is_null( $watch ) ) { if( $watch ) { $params['watchlist'] = 'watch'; } elseif( !$watch ) $params['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $params['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } try{ $this->preEditChecks( "Rollback" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } Hooks::runHook( 'PreRollback', array( &$params ) ); pecho( "Rolling back {$this->title}...\n\n", PECHO_NOTICE ); $result = $this->wiki->apiQuery( $params, true ); if( isset( $result['rollback'] ) ) { if( isset( $result['rollback']['title'] ) ) { $this->__construct( $this->wiki, $this->title ); return true; } else { pecho( "Rollback error...\n\n" . print_r( $result['rollback'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Rollback error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
php
public function rollback( $force = false, $summary = null, $markbot = false, $watch = null ) { global $pgNotag, $pgTag; if( !in_array( 'rollback', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to rollback edits", PECHO_FATAL ); return false; } if( !$force ) { try{ $this->preEditChecks(); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } } $history = $this->history( 1, 'older', false, null, true ); $params = array( 'action' => 'rollback', 'title' => $this->title, 'user' => $history[0]['user'], 'token' => $history[0]['rollbacktoken'], ); if( !is_null( $summary ) ) { if( mb_strlen( $summary, '8bit' ) > 255 ) { pecho( "Summary is over 255 bytes, the maximum allowed.\n\n", PECHO_FATAL ); return false; } if( !$pgNotag ) $summary .= $pgTag; $params['summary'] = $summary; } if( $markbot ) $params['markbot'] = ''; if( !is_null( $watch ) ) { if( $watch ) { $params['watchlist'] = 'watch'; } elseif( !$watch ) $params['watchlist'] = 'nochange'; elseif( in_array( $watch, array( 'watch', 'unwatch', 'preferences', 'nochange' ) ) ) { $params['watchlist'] = $watch; } else pecho( "Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN ); } try{ $this->preEditChecks( "Rollback" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } Hooks::runHook( 'PreRollback', array( &$params ) ); pecho( "Rolling back {$this->title}...\n\n", PECHO_NOTICE ); $result = $this->wiki->apiQuery( $params, true ); if( isset( $result['rollback'] ) ) { if( isset( $result['rollback']['title'] ) ) { $this->__construct( $this->wiki, $this->title ); return true; } else { pecho( "Rollback error...\n\n" . print_r( $result['rollback'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Rollback error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
[ "public", "function", "rollback", "(", "$", "force", "=", "false", ",", "$", "summary", "=", "null", ",", "$", "markbot", "=", "false", ",", "$", "watch", "=", "null", ")", "{", "global", "$", "pgNotag", ",", "$", "pgTag", ";", "if", "(", "!", "i...
Rollbacks the latest edit(s) to a page. @see http://www.mediawiki.org/wiki/API:Edit_-_Rollback @param bool $force Whether to force an (attempt at an) edit, regardless of news messages, etc. @param string $summary Override the default edit summary for this rollback. Default null. @param bool $markbot If set, both the rollback and the revisions being rolled back will be marked as bot edits. @param string|bool $watch Unconditionally add or remove the page from your watchlist, use preferences or do not change watch. Default preferences. @return array Details of the rollback perform. ['revid']: The revision ID of the rollback. ['old_revid']: The revision ID of the first (most recent) revision that was rolled back. ['last_revid']: The revision ID of the last (oldest) revision that was rolled back.
[ "Rollbacks", "the", "latest", "edit", "(", "s", ")", "to", "a", "page", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L2117-L2190
MW-Peachy/Peachy
Includes/Page.php
Page.preEditChecks
protected function preEditChecks( $action = "Edit" ) { $this->wiki->preEditChecks( $action, $this->title, $this->pageid ); }
php
protected function preEditChecks( $action = "Edit" ) { $this->wiki->preEditChecks( $action, $this->title, $this->pageid ); }
[ "protected", "function", "preEditChecks", "(", "$", "action", "=", "\"Edit\"", ")", "{", "$", "this", "->", "wiki", "->", "preEditChecks", "(", "$", "action", ",", "$", "this", "->", "title", ",", "$", "this", "->", "pageid", ")", ";", "}" ]
Performs nobots checking, new message checking, etc @param string $action @throws EditError
[ "Performs", "nobots", "checking", "new", "message", "checking", "etc" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L2198-L2200
MW-Peachy/Peachy
Includes/Page.php
Page.embeddedin
public function embeddedin( $namespace = null, $limit = null ) { $eiArray = array( 'list' => 'embeddedin', '_code' => 'ei', 'eititle' => $this->title, '_lhtitle' => 'title', '_limit' => $limit ); if( !is_null( $namespace ) ) { $eiArray['einamespace'] = $namespace; } Hooks::runHook( 'PreQueryEmbeddedin', array( &$eiArray ) ); pecho( "Getting list of pages that include {$this->title}...\n\n", PECHO_NORMAL ); return $this->wiki->listHandler( $eiArray ); }
php
public function embeddedin( $namespace = null, $limit = null ) { $eiArray = array( 'list' => 'embeddedin', '_code' => 'ei', 'eititle' => $this->title, '_lhtitle' => 'title', '_limit' => $limit ); if( !is_null( $namespace ) ) { $eiArray['einamespace'] = $namespace; } Hooks::runHook( 'PreQueryEmbeddedin', array( &$eiArray ) ); pecho( "Getting list of pages that include {$this->title}...\n\n", PECHO_NORMAL ); return $this->wiki->listHandler( $eiArray ); }
[ "public", "function", "embeddedin", "(", "$", "namespace", "=", "null", ",", "$", "limit", "=", "null", ")", "{", "$", "eiArray", "=", "array", "(", "'list'", "=>", "'embeddedin'", ",", "'_code'", "=>", "'ei'", ",", "'eititle'", "=>", "$", "this", "->"...
Returns array of pages that embed (transclude) the page given. @param array $namespace Which namespaces to search (default: null). @param int $limit How many results to retrieve (default: null i.e. all). @return array A list of pages the title is transcluded in.
[ "Returns", "array", "of", "pages", "that", "embed", "(", "transclude", ")", "the", "page", "given", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L2209-L2227
MW-Peachy/Peachy
Includes/Page.php
Page.parse
public function parse( $summary = null, $id = null, $prop = null, $uselang = 'en', $section = null ) { if( $prop === null ){ $prop = array( 'text', 'langlinks', 'categories', 'links', 'templates', 'images', 'externallinks', 'sections', 'revid', 'displaytitle', 'headitems', 'headhtml', 'iwlinks', 'wikitext', 'properties' ); } return $this->wiki->parse( null, null, $summary, false, false, $prop, $uselang, $this->title, $id, null, false, $section ); }
php
public function parse( $summary = null, $id = null, $prop = null, $uselang = 'en', $section = null ) { if( $prop === null ){ $prop = array( 'text', 'langlinks', 'categories', 'links', 'templates', 'images', 'externallinks', 'sections', 'revid', 'displaytitle', 'headitems', 'headhtml', 'iwlinks', 'wikitext', 'properties' ); } return $this->wiki->parse( null, null, $summary, false, false, $prop, $uselang, $this->title, $id, null, false, $section ); }
[ "public", "function", "parse", "(", "$", "summary", "=", "null", ",", "$", "id", "=", "null", ",", "$", "prop", "=", "null", ",", "$", "uselang", "=", "'en'", ",", "$", "section", "=", "null", ")", "{", "if", "(", "$", "prop", "===", "null", ")...
Parses wikitext and returns parser output. Shortcut for Wiki::parse @param string $summary Summary to parse. Default null. @param string $id Parse the content of this revision @param array $prop Properties to retrieve. array( 'text', 'langlinks', 'categories', 'links', 'templates', 'images', 'externallinks', 'sections', 'revid', 'displaytitle', 'headitems', 'headhtml', 'iwlinks', 'wikitext', 'properties' ) @param string $uselang Code of the language to use in interface messages, etc. (where applicable). Default 'en'. @param string $section Only retrieve the content of this section number. Default null. @return array
[ "Parses", "wikitext", "and", "returns", "parser", "output", ".", "Shortcut", "for", "Wiki", "::", "parse" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Page.php#L2249-L2259
scherersoftware/cake-model-history
src/Controller/ModelHistoryController.php
ModelHistoryController.index
public function index( string $model = null, string $foreignKey = null, int $limit = null, int $page = null, bool $showFilterBox = null, bool $showCommentBox = null, $includeAssociated = null, string $columnClass = '' ): void { $this->ModelHistory->belongsTo('Users', [ 'foreignKey' => 'user_id' ]); $entity = $this->ModelHistory->getEntityWithHistory($model, $foreignKey); if ($this->request->is('post')) { $return = TableRegistry::get($model)->addCommentToHistory($entity, $this->request->data['data']); if (empty($return->errors())) { $this->Flash->success(__('forms.data_saved')); } else { $this->Flash->error(__('forms.data_not_saved')); } } $modelHistory = $this->ModelHistory->getModelHistory($model, $foreignKey, $limit, $page, [], ['includeAssociated' => (bool)$includeAssociated]); $entries = TableRegistry::get('ModelHistory.ModelHistory')->getModelHistoryCount($model, $foreignKey, [], ['includeAssociated' => (bool)$includeAssociated]); $showNextEntriesButton = $entries > 0 && $limit * $page < $entries; $showPrevEntriesButton = $page > 1; $contexts = []; if (method_exists($entity, 'getContexts')) { $contexts = $entity::getContexts(); } $this->FrontendBridge->setBoth('contexts', $contexts); $this->FrontendBridge->setBoth('modelHistory', $modelHistory); $this->FrontendBridge->setBoth('showNextEntriesButton', $showNextEntriesButton); $this->FrontendBridge->setBoth('showPrevEntriesButton', $showPrevEntriesButton); $this->FrontendBridge->setBoth('showFilterBox', $showFilterBox); $this->FrontendBridge->setBoth('showCommentBox', $showCommentBox); $this->FrontendBridge->setBoth('includeAssociated', $includeAssociated); $this->FrontendBridge->setBoth('model', $model); $this->FrontendBridge->setBoth('foreignKey', $foreignKey); $this->FrontendBridge->setBoth('limit', $limit); $this->FrontendBridge->setBoth('columnClass', $columnClass); $this->FrontendBridge->setBoth('page', $page); $this->FrontendBridge->setBoth('searchableFields', TableRegistry::get($entity->source())->getTranslatedFields()); }
php
public function index( string $model = null, string $foreignKey = null, int $limit = null, int $page = null, bool $showFilterBox = null, bool $showCommentBox = null, $includeAssociated = null, string $columnClass = '' ): void { $this->ModelHistory->belongsTo('Users', [ 'foreignKey' => 'user_id' ]); $entity = $this->ModelHistory->getEntityWithHistory($model, $foreignKey); if ($this->request->is('post')) { $return = TableRegistry::get($model)->addCommentToHistory($entity, $this->request->data['data']); if (empty($return->errors())) { $this->Flash->success(__('forms.data_saved')); } else { $this->Flash->error(__('forms.data_not_saved')); } } $modelHistory = $this->ModelHistory->getModelHistory($model, $foreignKey, $limit, $page, [], ['includeAssociated' => (bool)$includeAssociated]); $entries = TableRegistry::get('ModelHistory.ModelHistory')->getModelHistoryCount($model, $foreignKey, [], ['includeAssociated' => (bool)$includeAssociated]); $showNextEntriesButton = $entries > 0 && $limit * $page < $entries; $showPrevEntriesButton = $page > 1; $contexts = []; if (method_exists($entity, 'getContexts')) { $contexts = $entity::getContexts(); } $this->FrontendBridge->setBoth('contexts', $contexts); $this->FrontendBridge->setBoth('modelHistory', $modelHistory); $this->FrontendBridge->setBoth('showNextEntriesButton', $showNextEntriesButton); $this->FrontendBridge->setBoth('showPrevEntriesButton', $showPrevEntriesButton); $this->FrontendBridge->setBoth('showFilterBox', $showFilterBox); $this->FrontendBridge->setBoth('showCommentBox', $showCommentBox); $this->FrontendBridge->setBoth('includeAssociated', $includeAssociated); $this->FrontendBridge->setBoth('model', $model); $this->FrontendBridge->setBoth('foreignKey', $foreignKey); $this->FrontendBridge->setBoth('limit', $limit); $this->FrontendBridge->setBoth('columnClass', $columnClass); $this->FrontendBridge->setBoth('page', $page); $this->FrontendBridge->setBoth('searchableFields', TableRegistry::get($entity->source())->getTranslatedFields()); }
[ "public", "function", "index", "(", "string", "$", "model", "=", "null", ",", "string", "$", "foreignKey", "=", "null", ",", "int", "$", "limit", "=", "null", ",", "int", "$", "page", "=", "null", ",", "bool", "$", "showFilterBox", "=", "null", ",", ...
Index function @param string $model Name of the model @param string $foreignKey Id of the entity @param int $limit Items to show @param int $page Current page @param bool $showFilterBox Show Filter Box @param bool $showCommentBox Show comment Box @param mixed $includeAssociated Included Assocation @param string $columnClass Div classes for column @return void
[ "Index", "function" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Controller/ModelHistoryController.php#L48-L94
scherersoftware/cake-model-history
src/Controller/ModelHistoryController.php
ModelHistoryController.filter
public function filter( string $model = null, string $foreignKey = null, int $limit = null, int $page = null, bool $showFilterBox = null, bool $showCommentBox = null, $includeAssociated = null, string $columnClass = '' ): Response { $this->request->allowMethod(['post']); $filterConditions = []; if (isset($this->request->data['filter'])) { foreach ($this->request->data['filter'] as $filterName => $filterValue) { if (empty($filterValue)) { continue; } switch ($filterName) { case 'fields': $filterConditions = Hash::merge([ '`data` LIKE' => Text::insert('%:fieldName%', ['fieldName' => $filterValue]) ], $filterConditions); break; } } } // Prepare conditions $searchConditions = []; if (isset($this->request->data['search'])) { foreach ($this->request->data['search'] as $searchName => $searchValue) { if (empty($searchValue)) { continue; } switch ($searchName) { case 'date': if (!empty($searchValue['from']['year']) && !empty($searchValue['from']['month']) && !empty($searchValue['from']['day'])) { $fromDate = Time::now() ->year($searchValue['from']['year']) ->month($searchValue['from']['month']) ->day($searchValue['from']['day']) ->hour(0) ->minute(0) ->second(0); $searchConditions = Hash::merge([ 'ModelHistory.created >=' => $fromDate ], $searchConditions); } if (!empty($searchValue['to']['year']) && !empty($searchValue['to']['month']) && !empty($searchValue['to']['day'])) { $toDate = Time::now() ->year($searchValue['to']['year']) ->month($searchValue['to']['month']) ->day($searchValue['to']['day']) ->hour(23) ->minute(59) ->second(59); $searchConditions = Hash::merge([ 'ModelHistory.created <=' => $toDate ], $searchConditions); } break; case 'context_type': $searchConditions = Hash::merge([ 'context_type' => $searchValue ], $searchConditions); break; case 'context_slug': $searchConditions = Hash::merge([ 'context_slug' => $searchValue ], $searchConditions); break; } } } $conditions = Hash::merge($filterConditions, $searchConditions); $modelHistory = $this->ModelHistory->getModelHistory($model, $foreignKey, $limit, $page, $conditions, ['includeAssociated' => (bool)$includeAssociated]); $entries = TableRegistry::get('ModelHistory.ModelHistory')->getModelHistoryCount($model, $foreignKey, $conditions, ['includeAssociated' => (bool)$includeAssociated]); $showNextEntriesButton = $entries > 0 && $limit * $page < $entries; $showPrevEntriesButton = $page > 1; $this->FrontendBridge->setBoth('showPrevEntriesButton', $showPrevEntriesButton); $this->FrontendBridge->setBoth('showNextEntriesButton', $showNextEntriesButton); $this->FrontendBridge->setBoth('showFilterBox', $showFilterBox); $this->FrontendBridge->setBoth('showCommentBox', $showCommentBox); $this->FrontendBridge->setBoth('includeAssociated', $includeAssociated); $this->FrontendBridge->setBoth('modelHistory', $modelHistory); $this->FrontendBridge->setBoth('limit', $limit); $this->FrontendBridge->setBoth('model', $model); $this->FrontendBridge->setBoth('page', $page); $this->FrontendBridge->setBoth('columnClass', $columnClass); $this->FrontendBridge->setBoth('foreignKey', $foreignKey); $this->FrontendBridge->setBoth('searchableFields', TableRegistry::get($model)->getTranslatedFields()); $this->FrontendBridge->set('filter', isset($this->request->data['filter']) ? $this->request->data['filter'] : []); $entity = $this->ModelHistory->getEntityWithHistory($model, $foreignKey); $contexts = []; if (method_exists($entity, 'getContexts')) { $contexts = $entity::getContexts(); } $this->FrontendBridge->setBoth('contexts', $contexts); return $this->render('index'); }
php
public function filter( string $model = null, string $foreignKey = null, int $limit = null, int $page = null, bool $showFilterBox = null, bool $showCommentBox = null, $includeAssociated = null, string $columnClass = '' ): Response { $this->request->allowMethod(['post']); $filterConditions = []; if (isset($this->request->data['filter'])) { foreach ($this->request->data['filter'] as $filterName => $filterValue) { if (empty($filterValue)) { continue; } switch ($filterName) { case 'fields': $filterConditions = Hash::merge([ '`data` LIKE' => Text::insert('%:fieldName%', ['fieldName' => $filterValue]) ], $filterConditions); break; } } } // Prepare conditions $searchConditions = []; if (isset($this->request->data['search'])) { foreach ($this->request->data['search'] as $searchName => $searchValue) { if (empty($searchValue)) { continue; } switch ($searchName) { case 'date': if (!empty($searchValue['from']['year']) && !empty($searchValue['from']['month']) && !empty($searchValue['from']['day'])) { $fromDate = Time::now() ->year($searchValue['from']['year']) ->month($searchValue['from']['month']) ->day($searchValue['from']['day']) ->hour(0) ->minute(0) ->second(0); $searchConditions = Hash::merge([ 'ModelHistory.created >=' => $fromDate ], $searchConditions); } if (!empty($searchValue['to']['year']) && !empty($searchValue['to']['month']) && !empty($searchValue['to']['day'])) { $toDate = Time::now() ->year($searchValue['to']['year']) ->month($searchValue['to']['month']) ->day($searchValue['to']['day']) ->hour(23) ->minute(59) ->second(59); $searchConditions = Hash::merge([ 'ModelHistory.created <=' => $toDate ], $searchConditions); } break; case 'context_type': $searchConditions = Hash::merge([ 'context_type' => $searchValue ], $searchConditions); break; case 'context_slug': $searchConditions = Hash::merge([ 'context_slug' => $searchValue ], $searchConditions); break; } } } $conditions = Hash::merge($filterConditions, $searchConditions); $modelHistory = $this->ModelHistory->getModelHistory($model, $foreignKey, $limit, $page, $conditions, ['includeAssociated' => (bool)$includeAssociated]); $entries = TableRegistry::get('ModelHistory.ModelHistory')->getModelHistoryCount($model, $foreignKey, $conditions, ['includeAssociated' => (bool)$includeAssociated]); $showNextEntriesButton = $entries > 0 && $limit * $page < $entries; $showPrevEntriesButton = $page > 1; $this->FrontendBridge->setBoth('showPrevEntriesButton', $showPrevEntriesButton); $this->FrontendBridge->setBoth('showNextEntriesButton', $showNextEntriesButton); $this->FrontendBridge->setBoth('showFilterBox', $showFilterBox); $this->FrontendBridge->setBoth('showCommentBox', $showCommentBox); $this->FrontendBridge->setBoth('includeAssociated', $includeAssociated); $this->FrontendBridge->setBoth('modelHistory', $modelHistory); $this->FrontendBridge->setBoth('limit', $limit); $this->FrontendBridge->setBoth('model', $model); $this->FrontendBridge->setBoth('page', $page); $this->FrontendBridge->setBoth('columnClass', $columnClass); $this->FrontendBridge->setBoth('foreignKey', $foreignKey); $this->FrontendBridge->setBoth('searchableFields', TableRegistry::get($model)->getTranslatedFields()); $this->FrontendBridge->set('filter', isset($this->request->data['filter']) ? $this->request->data['filter'] : []); $entity = $this->ModelHistory->getEntityWithHistory($model, $foreignKey); $contexts = []; if (method_exists($entity, 'getContexts')) { $contexts = $entity::getContexts(); } $this->FrontendBridge->setBoth('contexts', $contexts); return $this->render('index'); }
[ "public", "function", "filter", "(", "string", "$", "model", "=", "null", ",", "string", "$", "foreignKey", "=", "null", ",", "int", "$", "limit", "=", "null", ",", "int", "$", "page", "=", "null", ",", "bool", "$", "showFilterBox", "=", "null", ",",...
Load entries and filter them if necessary. @param string $model Model name @param string $foreignKey Model's foreign key @param int $limit Entries limit @param int $page Current page to view @param bool $showFilterBox Show Filter Box @param bool $showCommentBox Show comment Box @param mixed $includeAssociated Included Assocation @param string $columnClass Div classes for column @return \Cake\Http\Response Index View
[ "Load", "entries", "and", "filter", "them", "if", "necessary", "." ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Controller/ModelHistoryController.php#L109-L215
scherersoftware/cake-model-history
src/Controller/ModelHistoryController.php
ModelHistoryController.diff
public function diff(string $currentId = null): void { $historyEntry = $this->ModelHistory->get($currentId); $this->FrontendBridge->setBoth('diffOutput', $this->ModelHistory->buildDiff($historyEntry)); }
php
public function diff(string $currentId = null): void { $historyEntry = $this->ModelHistory->get($currentId); $this->FrontendBridge->setBoth('diffOutput', $this->ModelHistory->buildDiff($historyEntry)); }
[ "public", "function", "diff", "(", "string", "$", "currentId", "=", "null", ")", ":", "void", "{", "$", "historyEntry", "=", "$", "this", "->", "ModelHistory", "->", "get", "(", "$", "currentId", ")", ";", "$", "this", "->", "FrontendBridge", "->", "se...
Build diff for a given modelHistory entry @param string $currentId UUID of ModelHistory entry to get diff for @return void
[ "Build", "diff", "for", "a", "given", "modelHistory", "entry" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Controller/ModelHistoryController.php#L223-L227
baleen/migrations
src/Service/DomainBus/Migrate/Converge/ConvergeHandler.php
ConvergeHandler.handle
public function handle(ConvergeCommand $command) { $collection = $command->getCollection(); $targetUp = $command->getTarget(); $options = $command->getOptions(); $domainBus = $command->getDomainBus(); $position = $collection->getPosition($targetUp); $targetDown = $collection->getByPosition($position + 1); $changed = clone $collection; $changed->clear(); $upCommand = new CollectionCommand( $collection, $targetUp, $options->withDirection(Direction::up()), $command->getVersionRepository() ); $upChanges = $domainBus->handle($upCommand); if (!empty($upChanges)) { $changed->merge($upChanges); } // if we're not yet at the end of the queue (where no migrations can go down) if (null !== $targetDown) { $downCommand = new CollectionCommand( $collection, $targetDown, $options->withDirection(Direction::down()), $command->getVersionRepository() ); $downChanges = $domainBus->handle($downCommand); if (!empty($downChanges)) { $changed->merge($downChanges); } } return $changed->sort(); }
php
public function handle(ConvergeCommand $command) { $collection = $command->getCollection(); $targetUp = $command->getTarget(); $options = $command->getOptions(); $domainBus = $command->getDomainBus(); $position = $collection->getPosition($targetUp); $targetDown = $collection->getByPosition($position + 1); $changed = clone $collection; $changed->clear(); $upCommand = new CollectionCommand( $collection, $targetUp, $options->withDirection(Direction::up()), $command->getVersionRepository() ); $upChanges = $domainBus->handle($upCommand); if (!empty($upChanges)) { $changed->merge($upChanges); } // if we're not yet at the end of the queue (where no migrations can go down) if (null !== $targetDown) { $downCommand = new CollectionCommand( $collection, $targetDown, $options->withDirection(Direction::down()), $command->getVersionRepository() ); $downChanges = $domainBus->handle($downCommand); if (!empty($downChanges)) { $changed->merge($downChanges); } } return $changed->sort(); }
[ "public", "function", "handle", "(", "ConvergeCommand", "$", "command", ")", "{", "$", "collection", "=", "$", "command", "->", "getCollection", "(", ")", ";", "$", "targetUp", "=", "$", "command", "->", "getTarget", "(", ")", ";", "$", "options", "=", ...
converge (v): come together from different directions so as eventually to meet. @param ConvergeCommand $command @return \Baleen\Migrations\Common\Collection\CollectionInterface
[ "converge", "(", "v", ")", ":", "come", "together", "from", "different", "directions", "so", "as", "eventually", "to", "meet", "." ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Service/DomainBus/Migrate/Converge/ConvergeHandler.php#L40-L79
skrz/meta
gen-src/Google/Protobuf/Meta/SourceCodeInfoMeta.php
SourceCodeInfoMeta.create
public static function create() { switch (func_num_args()) { case 0: return new SourceCodeInfo(); case 1: return new SourceCodeInfo(func_get_arg(0)); case 2: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1)); case 3: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new SourceCodeInfo(); case 1: return new SourceCodeInfo(func_get_arg(0)); case 2: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1)); case 3: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new SourceCodeInfo(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "SourceCodeInfo", "(", ")", ";", "case", "1", ":", "return", "new", "SourceCodeInfo", "(", "func_get_arg", "("...
Creates new instance of \Google\Protobuf\SourceCodeInfo @throws \InvalidArgumentException @return SourceCodeInfo
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "SourceCodeInfo" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/SourceCodeInfoMeta.php#L58-L82
skrz/meta
gen-src/Google/Protobuf/Meta/SourceCodeInfoMeta.php
SourceCodeInfoMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->location)) { hash_update($ctx, 'location'); foreach ($object->location instanceof \Traversable ? $object->location : (array)$object->location as $v0) { LocationMeta::hash($v0, $ctx); } } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
php
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->location)) { hash_update($ctx, 'location'); foreach ($object->location instanceof \Traversable ? $object->location : (array)$object->location as $v0) { LocationMeta::hash($v0, $ctx); } } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
[ "public", "static", "function", "hash", "(", "$", "object", ",", "$", "algoOrCtx", "=", "'md5'", ",", "$", "raw", "=", "FALSE", ")", "{", "if", "(", "is_string", "(", "$", "algoOrCtx", ")", ")", "{", "$", "ctx", "=", "hash_init", "(", "$", "algoOrC...
Computes hash of \Google\Protobuf\SourceCodeInfo @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "SourceCodeInfo" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/SourceCodeInfoMeta.php#L113-L133
skrz/meta
gen-src/Google/Protobuf/Meta/SourceCodeInfoMeta.php
SourceCodeInfoMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new SourceCodeInfo(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->location) && is_array($object->location))) { $object->location = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->location[] = LocationMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
php
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new SourceCodeInfo(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->location) && is_array($object->location))) { $object->location = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->location[] = LocationMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
[ "public", "static", "function", "fromProtobuf", "(", "$", "input", ",", "$", "object", "=", "NULL", ",", "&", "$", "start", "=", "0", ",", "$", "end", "=", "NULL", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "$", "object", "=", ...
Creates \Google\Protobuf\SourceCodeInfo object from serialized Protocol Buffers message. @param string $input @param SourceCodeInfo $object @param int $start @param int $end @throws \Exception @return SourceCodeInfo
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "SourceCodeInfo", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/SourceCodeInfoMeta.php#L148-L201
skrz/meta
gen-src/Google/Protobuf/Meta/SourceCodeInfoMeta.php
SourceCodeInfoMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->location) && ($filter === null || isset($filter['location']))) { foreach ($object->location instanceof \Traversable ? $object->location : (array)$object->location as $k => $v) { $output .= "\x0a"; $buffer = LocationMeta::toProtobuf($v, $filter === null ? null : $filter['location']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->location) && ($filter === null || isset($filter['location']))) { foreach ($object->location instanceof \Traversable ? $object->location : (array)$object->location as $k => $v) { $output .= "\x0a"; $buffer = LocationMeta::toProtobuf($v, $filter === null ? null : $filter['location']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "location", ")", "&&", "(", "$", "filter", "===", "null", "||"...
Serialized \Google\Protobuf\SourceCodeInfo to Protocol Buffers message. @param SourceCodeInfo $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "SourceCodeInfo", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/SourceCodeInfoMeta.php#L214-L228
kaliop-uk/kueueingbundle
Service/MessageConsumer/HTTPRequest.php
HTTPRequest.executeRequest
protected function executeRequest($url, array $options = array()) { $ch = curl_init($url); foreach ($options as $name => $value) { if (!curl_setopt($ch, $name, $value)) { if ($this->logger) { $this->logger->warning("Option could not be set to Curl: $name, value: $value"); } } } // some options we have to force curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $results = curl_exec($ch); if ($results === false) { if ($this->logger) { $this->logger->error("Curl request failed: " . curl_error($ch)); } } // close cURL resource, and free up system resources curl_close($ch); return $results; }
php
protected function executeRequest($url, array $options = array()) { $ch = curl_init($url); foreach ($options as $name => $value) { if (!curl_setopt($ch, $name, $value)) { if ($this->logger) { $this->logger->warning("Option could not be set to Curl: $name, value: $value"); } } } // some options we have to force curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $results = curl_exec($ch); if ($results === false) { if ($this->logger) { $this->logger->error("Curl request failed: " . curl_error($ch)); } } // close cURL resource, and free up system resources curl_close($ch); return $results; }
[ "protected", "function", "executeRequest", "(", "$", "url", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "ch", "=", "curl_init", "(", "$", "url", ")", ";", "foreach", "(", "$", "options", "as", "$", "name", "=>", "$", "value...
Runs an sf command as a separate php process - this way we insure the worker is stable (no memleaks or crashes) @param string $url @param array $options @return string|false
[ "Runs", "an", "sf", "command", "as", "a", "separate", "php", "process", "-", "this", "way", "we", "insure", "the", "worker", "is", "stable", "(", "no", "memleaks", "or", "crashes", ")" ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/MessageConsumer/HTTPRequest.php#L45-L72
budde377/Part
lib/util/file/ImageFileImpl.php
ImageFileImpl.scaleToOuterBox
public function scaleToOuterBox($width, $height, $saveAsNewFile = false) { $width_ratio = $width == 0 ? $height / $this->getHeight() : $width / $this->getWidth(); $height_ratio = $height == 0 ? $width / $this->getWidth() : $height / $this->getHeight(); if ($width_ratio < $height_ratio) { return $this->forceSize($this->getWidth() * $width_ratio, 0, $saveAsNewFile); } return $this->forceSize(0, $this->getHeight() * $height_ratio, $saveAsNewFile); }
php
public function scaleToOuterBox($width, $height, $saveAsNewFile = false) { $width_ratio = $width == 0 ? $height / $this->getHeight() : $width / $this->getWidth(); $height_ratio = $height == 0 ? $width / $this->getWidth() : $height / $this->getHeight(); if ($width_ratio < $height_ratio) { return $this->forceSize($this->getWidth() * $width_ratio, 0, $saveAsNewFile); } return $this->forceSize(0, $this->getHeight() * $height_ratio, $saveAsNewFile); }
[ "public", "function", "scaleToOuterBox", "(", "$", "width", ",", "$", "height", ",", "$", "saveAsNewFile", "=", "false", ")", "{", "$", "width_ratio", "=", "$", "width", "==", "0", "?", "$", "height", "/", "$", "this", "->", "getHeight", "(", ")", ":...
Will scale the image such that the image will become the inner box to the box given. @param int $width @param int $height @param bool $saveAsNewFile @return null | ImageFile
[ "Will", "scale", "the", "image", "such", "that", "the", "image", "will", "become", "the", "inner", "box", "to", "the", "box", "given", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/ImageFileImpl.php#L106-L116
budde377/Part
lib/util/file/ImageFileImpl.php
ImageFileImpl.forceSize
public function forceSize($width, $height, $saveAsNewFile = false) { $width = $width <= 0 ? round($this->getRatio() * $height) : $width; $height = $height <= 0 ? round($width / $this->getRatio()) : $height; return $this->modifyImageHelper( function (Imagick $imagick) use ($width, $height) { $imagick->resizeimage($width, $height, Imagick::FILTER_CATROM, 1); }, function () use ($width, $height) { return $this->newForceImageSizeBasename($width, $height); }, function (ImageFile $file) use ($width, $height) { $file->forceSize($width, $height); }, $saveAsNewFile); }
php
public function forceSize($width, $height, $saveAsNewFile = false) { $width = $width <= 0 ? round($this->getRatio() * $height) : $width; $height = $height <= 0 ? round($width / $this->getRatio()) : $height; return $this->modifyImageHelper( function (Imagick $imagick) use ($width, $height) { $imagick->resizeimage($width, $height, Imagick::FILTER_CATROM, 1); }, function () use ($width, $height) { return $this->newForceImageSizeBasename($width, $height); }, function (ImageFile $file) use ($width, $height) { $file->forceSize($width, $height); }, $saveAsNewFile); }
[ "public", "function", "forceSize", "(", "$", "width", ",", "$", "height", ",", "$", "saveAsNewFile", "=", "false", ")", "{", "$", "width", "=", "$", "width", "<=", "0", "?", "round", "(", "$", "this", "->", "getRatio", "(", ")", "*", "$", "height",...
Will force the size of the image, ignoring the ratio. @param int $width @param int $height @param bool $saveAsNewFile @return null | ImageFile
[ "Will", "force", "the", "size", "of", "the", "image", "ignoring", "the", "ratio", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/ImageFileImpl.php#L125-L143
budde377/Part
lib/util/file/ImageFileImpl.php
ImageFileImpl.crop
public function crop($x, $y, $width, $height, $saveAsNewFile = false) { return $this->modifyImageHelper( function (Imagick $imagick) use ($width, $height, $x, $y) { $imagick->cropImage($width, $height, $x, $y); }, function () use ($x, $y, $width, $height) { return $this->newCropBasename($x, $y, $width, $height); }, function (ImageFile $file) use ($x, $y, $width, $height) { $file->crop($x, $y, $width, $height); }, $saveAsNewFile); }
php
public function crop($x, $y, $width, $height, $saveAsNewFile = false) { return $this->modifyImageHelper( function (Imagick $imagick) use ($width, $height, $x, $y) { $imagick->cropImage($width, $height, $x, $y); }, function () use ($x, $y, $width, $height) { return $this->newCropBasename($x, $y, $width, $height); }, function (ImageFile $file) use ($x, $y, $width, $height) { $file->crop($x, $y, $width, $height); }, $saveAsNewFile); }
[ "public", "function", "crop", "(", "$", "x", ",", "$", "y", ",", "$", "width", ",", "$", "height", ",", "$", "saveAsNewFile", "=", "false", ")", "{", "return", "$", "this", "->", "modifyImageHelper", "(", "function", "(", "Imagick", "$", "imagick", "...
Will crop the image. If some of the cropped area is outside of the image, it will not be in the cropped area. @param int $x @param int $y @param int $width @param int $height @param bool $saveAsNewFile @return null | ImageFile
[ "Will", "crop", "the", "image", ".", "If", "some", "of", "the", "cropped", "area", "is", "outside", "of", "the", "image", "it", "will", "not", "be", "in", "the", "cropped", "area", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/ImageFileImpl.php#L155-L170
budde377/Part
lib/util/file/ImageFileImpl.php
ImageFileImpl.limitToOuterBox
public function limitToOuterBox($width, $height, $saveAsNewFile = false) { if ($this->getWidth() < $width && $this->getHeight() < $height) { return $saveAsNewFile ? $this : null; } return $this->scaleToOuterBox($width, $height, $saveAsNewFile); }
php
public function limitToOuterBox($width, $height, $saveAsNewFile = false) { if ($this->getWidth() < $width && $this->getHeight() < $height) { return $saveAsNewFile ? $this : null; } return $this->scaleToOuterBox($width, $height, $saveAsNewFile); }
[ "public", "function", "limitToOuterBox", "(", "$", "width", ",", "$", "height", ",", "$", "saveAsNewFile", "=", "false", ")", "{", "if", "(", "$", "this", "->", "getWidth", "(", ")", "<", "$", "width", "&&", "$", "this", "->", "getHeight", "(", ")", ...
Will limit the image to an outer box. If the image is contained in the box, nothing will happen. @param int $width @param int $height @param bool $saveAsNewFile @return mixed
[ "Will", "limit", "the", "image", "to", "an", "outer", "box", ".", "If", "the", "image", "is", "contained", "in", "the", "box", "nothing", "will", "happen", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/ImageFileImpl.php#L185-L191
budde377/Part
lib/util/file/ImageFileImpl.php
ImageFileImpl.limitToInnerBox
public function limitToInnerBox($width, $height, $saveAsNewFile = false) { if ($this->getWidth() < $width || $this->getHeight() < $height) { return $saveAsNewFile ? $this : null; } return $this->scaleToInnerBox($width, $height, $saveAsNewFile); }
php
public function limitToInnerBox($width, $height, $saveAsNewFile = false) { if ($this->getWidth() < $width || $this->getHeight() < $height) { return $saveAsNewFile ? $this : null; } return $this->scaleToInnerBox($width, $height, $saveAsNewFile); }
[ "public", "function", "limitToInnerBox", "(", "$", "width", ",", "$", "height", ",", "$", "saveAsNewFile", "=", "false", ")", "{", "if", "(", "$", "this", "->", "getWidth", "(", ")", "<", "$", "width", "||", "$", "this", "->", "getHeight", "(", ")", ...
Will limit the image to an inner box. If the image is contained in the box, nothing will happen. @param int $width @param int $height @param bool $saveAsNewFile @return null | ImageFile
[ "Will", "limit", "the", "image", "to", "an", "inner", "box", ".", "If", "the", "image", "is", "contained", "in", "the", "box", "nothing", "will", "happen", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/ImageFileImpl.php#L200-L206
budde377/Part
lib/util/file/ImageFileImpl.php
ImageFileImpl.mirrorVertical
public function mirrorVertical($saveAsNewFile = false) { return $this->modifyImageHelper( function (Imagick $imagick) { $imagick->flopImage(); }, function () { return $this->newMirrorBasename(1, 0); }, function (ImageFile $file) { $file->mirrorVertical(); }, $saveAsNewFile); }
php
public function mirrorVertical($saveAsNewFile = false) { return $this->modifyImageHelper( function (Imagick $imagick) { $imagick->flopImage(); }, function () { return $this->newMirrorBasename(1, 0); }, function (ImageFile $file) { $file->mirrorVertical(); }, $saveAsNewFile); }
[ "public", "function", "mirrorVertical", "(", "$", "saveAsNewFile", "=", "false", ")", "{", "return", "$", "this", "->", "modifyImageHelper", "(", "function", "(", "Imagick", "$", "imagick", ")", "{", "$", "imagick", "->", "flopImage", "(", ")", ";", "}", ...
Mirrors the image vertically @param bool $saveAsNewFile @return null | ImageFile
[ "Mirrors", "the", "image", "vertically" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/ImageFileImpl.php#L267-L281