_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q258800 | HierarchicalTrait.children | test | public function children()
{
if ($this->children !== null) {
return $this->children;
}
$this->children = $this->loadChildren();
return $this->children;
} | php | {
"resource": ""
} |
q258801 | HierarchicalTrait.siblings | test | public function siblings()
{
if ($this->siblings !== null) {
return $this->siblings;
}
$master = $this->master();
if ($master === null) {
// Todo: return all top-level objects.
$siblings = [];
} else {
// Todo: Remove "current" ... | php | {
"resource": ""
} |
q258802 | HierarchicalTrait.loadObjectFromSource | test | private function loadObjectFromSource($id)
{
$obj = $this->modelFactory()->create($this->objType());
$obj->load($id);
if ($obj->id()) {
return $obj;
} else {
return null;
}
} | php | {
"resource": ""
} |
q258803 | HierarchicalTrait.loadObjectFromCache | test | private function loadObjectFromCache($id)
{
$objType = $this->objType();
if (isset(static::$objectCache[$objType][$id])) {
return static::$objectCache[$objType][$id];
} else {
return null;
}
} | php | {
"resource": ""
} |
q258804 | HierarchicalTrait.addObjectToCache | test | private function addObjectToCache(ModelInterface $obj)
{
static::$objectCache[$this->objType()][$obj->id()] = $obj;
return $this;
} | php | {
"resource": ""
} |
q258805 | CategoryTrait.categoryItems | test | public function categoryItems()
{
if ($this->categoryItems === null) {
$this->categoryItems = $this->loadCategoryItems();
}
return $this->categoryItems;
} | php | {
"resource": ""
} |
q258806 | RoutableTrait.slugPattern | test | public function slugPattern()
{
if (!$this->slugPattern) {
$metadata = $this->metadata();
if (isset($metadata['routable']['pattern'])) {
$this->setSlugPattern($metadata['routable']['pattern']);
} elseif (isset($metadata['slug_pattern'])) {
... | php | {
"resource": ""
} |
q258807 | RoutableTrait.slugPrefix | test | public function slugPrefix()
{
if (!$this->slugPrefix) {
$metadata = $this->metadata();
if (isset($metadata['routable']['prefix'])) {
$this->slugPrefix = $this->translator()->translation($metadata['routable']['prefix']);
}
}
return $this-... | php | {
"resource": ""
} |
q258808 | RoutableTrait.slugSuffix | test | public function slugSuffix()
{
if (!$this->slugSuffix) {
$metadata = $this->metadata();
if (isset($metadata['routable']['suffix'])) {
$this->slugSuffix = $this->translator()->translation($metadata['routable']['suffix']);
}
}
return $this-... | php | {
"resource": ""
} |
q258809 | RoutableTrait.isSlugEditable | test | public function isSlugEditable()
{
if ($this->isSlugEditable === null) {
$metadata = $this->metadata();
if (isset($metadata['routable']['editable'])) {
$this->isSlugEditable = !!$metadata['routable']['editable'];
} else {
$this->isSlugEdit... | php | {
"resource": ""
} |
q258810 | RoutableTrait.setSlug | test | public function setSlug($slug)
{
$slug = $this->translator()->translation($slug);
if ($slug !== null) {
$this->slug = $slug;
$values = $this->slug->data();
foreach ($values as $lang => $val) {
$this->slug[$lang] = $this->slugify($val);
... | php | {
"resource": ""
} |
q258811 | RoutableTrait.generateSlug | test | public function generateSlug()
{
$languages = $this->translator()->availableLocales();
$patterns = $this->slugPattern();
$curSlug = $this->slug();
$newSlug = [];
$origLang = $this->translator()->getLocale();
foreach ($languages as $lang) {
$pattern =... | php | {
"resource": ""
} |
q258812 | RoutableTrait.generateRoutePattern | test | protected function generateRoutePattern($pattern)
{
if ($this instanceof ViewableInterface && $this->view() !== null) {
$route = $this->view()->render($pattern, $this->viewController());
} else {
$route = preg_replace_callback('~\{\{\s*(.*?)\s*\}\}~i', [ $this, 'parseRouteTok... | php | {
"resource": ""
} |
q258813 | RoutableTrait.filterRouteToken | test | protected function filterRouteToken($value, $token = null)
{
unset($token);
if ($value instanceof \Closure) {
$value = $value();
}
if ($value instanceof \DateTime) {
$value = $value->format('Y-m-d-H:i');
}
if (method_exists($value, '__toStri... | php | {
"resource": ""
} |
q258814 | RoutableTrait.generateObjectRoute | test | protected function generateObjectRoute($slug = null, array $data = [])
{
if (!$slug) {
$slug = $this->generateSlug();
}
if ($slug instanceof Translation) {
$slugs = $slug->data();
} else {
throw new InvalidArgumentException(sprintf(
... | php | {
"resource": ""
} |
q258815 | RoutableTrait.url | test | public function url($lang = null)
{
$slug = $this->slug();
if ($slug instanceof Translation && $lang) {
return $slug[$lang];
}
if ($slug) {
return $slug;
}
$url = (string)$this->getLatestObjectRoute($lang)->slug();
return $url;
} | php | {
"resource": ""
} |
q258816 | RoutableTrait.slugify | test | public function slugify($str)
{
static $sluggedArray;
if (isset($sluggedArray[$str])) {
return $sluggedArray[$str];
}
$metadata = $this->metadata();
$separator = isset($metadata['routable']['separator']) ? $metadata['routable']['separator'] : '-';
$... | php | {
"resource": ""
} |
q258817 | RoutableTrait.finalizeSlug | test | protected function finalizeSlug($slug)
{
$prefix = $this->slugPrefix();
if ($prefix) {
$prefix = $this->generateRoutePattern((string)$prefix);
if ($slug === $prefix) {
throw new UnexpectedValueException('The slug is the same as the prefix.');
}
... | php | {
"resource": ""
} |
q258818 | RoutableTrait.deleteObjectRoutes | test | protected function deleteObjectRoutes()
{
if (!$this->objType()) {
return false;
}
if (!$this->id()) {
return false;
}
$loader = $this->createRouteObjectCollectionLoader();
$loader
->addFilters([
[
... | php | {
"resource": ""
} |
q258819 | RoutableTrait.createRouteObjectCollectionLoader | test | public function createRouteObjectCollectionLoader()
{
$loader = new CollectionLoader([
'logger' => $this->logger,
'factory' => $this->modelFactory(),
'model' => $this->getRouteObjectPrototype(),
]);
return $loader;
} | php | {
"resource": ""
} |
q258820 | RevisionableTrait.allRevisions | test | public function allRevisions(callable $callback = null)
{
$loader = new CollectionLoader([
'logger' => $this->logger,
'factory' => $this->modelFactory()
]);
$loader->setModel($this->createRevisionObject());
$loader->addFilter('target_type', $this->objType... | php | {
"resource": ""
} |
q258821 | PublishableTrait.setPublishDate | test | public function setPublishDate($time)
{
if ($time === null || $time === '') {
$this->publishDate = null;
return $this;
}
if (is_string($time)) {
try {
$time = new DateTime($time);
} catch (Exception $e) {
throw ... | php | {
"resource": ""
} |
q258822 | PublishableTrait.setExpiryDate | test | public function setExpiryDate($time)
{
if ($time === null || $time === '') {
$this->expiryDate = null;
return $this;
}
if (is_string($time)) {
try {
$time = new DateTime($time);
} catch (Exception $e) {
throw ne... | php | {
"resource": ""
} |
q258823 | PublishableTrait.setPublishStatus | test | public function setPublishStatus($status)
{
if ($status === null || $status === '') {
$this->publishStatus = null;
return $this;
}
$specialStatus = [
static::STATUS_EXPIRED => static::STATUS_PUBLISHED,
static::STATUS_UPCOMING => static::STATU... | php | {
"resource": ""
} |
q258824 | PublishableTrait.publishDateStatus | test | public function publishDateStatus()
{
$now = new DateTime();
$publish = $this->publishDate();
$expiry = $this->expiryDate();
$status = $this->publishStatus();
if ($status !== static::STATUS_PUBLISHED) {
return $status;
}
if (!$publish) {
... | php | {
"resource": ""
} |
q258825 | Help.index | test | public function index()
{
if (!userHasPermission('admin:admin:help:view')) {
unauthorised();
}
// --------------------------------------------------------------------------
// Page Title
$this->data['page']->title = 'Help Videos';
// ------------------... | php | {
"resource": ""
} |
q258826 | Utilities.rewrite_routes | test | public function rewrite_routes()
{
if (!userHasPermission('admin:admin:utilities:rewriteRoutes')) {
unauthorised();
}
// --------------------------------------------------------------------------
$oInput = Factory::service('Input');
if ($oInput->post('go')) {
... | php | {
"resource": ""
} |
q258827 | SourceResponse.reset | test | public function reset()
{
if (!empty($this->aData)) {
reset($this->aData);
} elseif ($this->oSource instanceof \PDOStatement) {
// unsupported
} elseif ($this->oSource instanceof \CI_DB_mysqli_result) {
$this->oSource->data_seek(0);
}
} | php | {
"resource": ""
} |
q258828 | SourceResponse.getNextItem | test | public function getNextItem()
{
$oRow = null;
if (!empty($this->aData)) {
$oRow = current($this->aData);
next($this->aData);
} elseif ($this->oSource instanceof \PDOStatement) {
$oRow = $this->oSource->fetch(\PDO::FETCH_ASSOC);
} elseif ($this->oS... | php | {
"resource": ""
} |
q258829 | Logs.site | test | public function site()
{
if (!userHasPermission('admin:admin:logs:site:browse')) {
unauthorised();
}
// --------------------------------------------------------------------------
Factory::helper('string');
$oUri = Factory::service('Uri');
$sMethod = $... | php | {
"resource": ""
} |
q258830 | Logs.siteIndex | test | protected function siteIndex()
{
if (!userHasPermission('admin:admin:logs:site:browse')) {
unauthorised();
}
// --------------------------------------------------------------------------
$this->data['page']->title = 'Browse Logs';
$oAsset = Factory::service('As... | php | {
"resource": ""
} |
q258831 | Logs.siteView | test | protected function siteView()
{
if (!userHasPermission('admin:admin:logs:site:browse')) {
unauthorised();
}
// --------------------------------------------------------------------------
$oUri = Factory::service('Uri');
$sFile ... | php | {
"resource": ""
} |
q258832 | Logs.event | test | public function event()
{
if (!userHasPermission('admin:admin:logs:event:browse')) {
unauthorised();
}
// --------------------------------------------------------------------------
// Set method info
$this->data['page']->title = 'Browse Events';
// ---... | php | {
"resource": ""
} |
q258833 | DefaultController.permissions | test | public static function permissions(): array
{
$aPermissions = parent::permissions();
if (!empty(static::CONFIG_PERMISSION)) {
$aPermissions['browse'] = 'Can browse items';
$aPermissions['create'] = 'Can create items';
$aPermissions['edit'] = 'Can edit items'... | php | {
"resource": ""
} |
q258834 | DefaultController.index | test | public function index(): void
{
if (!static::userCan('browse')) {
unauthorised();
}
$oInput = Factory::service('Input');
$oModel = $this->getModel();
$aConfig = $this->getConfig();
$sAlias = $oModel->getTableAlias();
$aSortConfig = $aConfi... | php | {
"resource": ""
} |
q258835 | DefaultController.delete | test | public function delete(): void
{
$aConfig = $this->getConfig();
if (!$aConfig['CAN_DELETE']) {
show404();
} elseif (!static::userCan('delete')) {
unauthorised();
}
$oDb = Factory::service('Database');
$oModel = $this->getModel();
$o... | php | {
"resource": ""
} |
q258836 | DefaultController.restore | test | public function restore(): void
{
$aConfig = $this->getConfig();
if (!$aConfig['CAN_RESTORE']) {
show404();
} elseif (!static::userCan('restore')) {
unauthorised();
}
$oUri = Factory::service('Uri');
$oDb = Factory::service('Database'... | php | {
"resource": ""
} |
q258837 | DefaultController.sort | test | public function sort(): void
{
$aConfig = $this->getConfig();
if (!$aConfig['CAN_EDIT']) {
show404();
} elseif (!static::userCan('edit')) {
unauthorised();
}
$oModel = $this->getModel();
$oInput = Factory::service('Input');
$oDb = F... | php | {
"resource": ""
} |
q258838 | DefaultController.localisedItemCanBeDeleted | test | protected static function localisedItemCanBeDeleted(Resource $oItem)
{
/** @var Locale $oLocale */
$oLocale = Factory::service('Locale');
$sDefaultLocale = (string) $oLocale->getDefautLocale();
$sItemLocale = (string) $oItem->locale;
if ($sDefaultLocale !== $sItemLo... | php | {
"resource": ""
} |
q258839 | DefaultController.getTitleSingle | test | protected static function getTitleSingle(): string
{
if (!empty(static::CONFIG_TITLE_SINGLE)) {
return static::CONFIG_TITLE_SINGLE;
}
$sTitle = preg_replace('/([a-z])([A-Z])/', '$1 $2', static::CONFIG_MODEL_NAME);
$sTitle = strtolower($sTitle);
$sTitle = ucwords(... | php | {
"resource": ""
} |
q258840 | DefaultController.indexDropdownFilters | test | protected function indexDropdownFilters(): array
{
$aFilters = [];
if (classUses(static::getModel(), Localised::class)) {
/** @var Locale $oLocale */
$oLocale = Factory::service('Locale');
$aOptions = [];
$aOptions[] = Factory::factory('IndexFilter... | php | {
"resource": ""
} |
q258841 | DefaultController.getPostObject | test | protected function getPostObject(): array
{
$aConfig = $this->getConfig();
$oModel = static::getModel();
$oInput = Factory::service('Input');
$oUri = Factory::service('Uri');
$aOut = [];
foreach ($aConfig['FIELDS'] as $oField) {
if (in_array($oFie... | php | {
"resource": ""
} |
q258842 | DefaultController.getItem | test | protected function getItem(array $aData = [], int $iSegment = null, bool $bIncludeDeleted = false, bool $b404 = true)
{
$iSegment = $iSegment ?? 5;
$oUri = Factory::service('Uri');
$oModel = $this->getModel();
$iItemId = (int) $oUri->segment($iSegment);
if (classUses(... | php | {
"resource": ""
} |
q258843 | DefaultController.returnToIndex | test | protected function returnToIndex(): void
{
$oInput = Factory::service('Input');
$sReferrer = $oInput->server('HTTP_REFERER');
if (!empty($sReferrer)) {
redirect($sReferrer);
} else {
redirect($this->getConfig()['BASE_URL']);
}
} | php | {
"resource": ""
} |
q258844 | IndexFilter.addOption | test | public function addOption($sLabel, $mValue = null, $bIsSelected = false, $bIsQuery = null)
{
if ($sLabel instanceof Option) {
$this->aOptions[] = $sLabel;
} else {
$this->aOptions[] = Factory::factory('IndexFilterOption', 'nails/module-admin')
->setLabel($sLab... | php | {
"resource": ""
} |
q258845 | IndexFilter.addOptions | test | public function addOptions($aOptions)
{
foreach ($aOptions as $aOption) {
if ($aOption instanceof Option) {
$this->aOptions[] = $aOption;
} else {
$sLabel = getFromArray('label', $aOption, getFromArray(0, $aOption));
$mValue =... | php | {
"resource": ""
} |
q258846 | IndexFilter.getOption | test | public function getOption($iOptionIndex)
{
return array_key_exists($iOptionIndex, $this->aOptions) ? $this->aOptions[$iOptionIndex] : null;
} | php | {
"resource": ""
} |
q258847 | Option.handleMethodCall | test | private function handleMethodCall($aMethods, $sMethod, $mValue)
{
if (substr($sMethod, 0, 3) !== 'set') {
return $this->{$aMethods[$sMethod]};
}
$this->{$aMethods[$sMethod]} = $mValue;
return $this;
} | php | {
"resource": ""
} |
q258848 | Export.setBatchStatus | test | public function setBatchStatus(array $aIds, $sStatus, $sError = '')
{
if (is_object(reset($aIds))) {
$aIds = arrayExtractProperty($aIds, 'id');
}
if (!empty($aIds)) {
$oDb = Factory::service('Database');
$oDb->set('status', $sStatus);
$oDb->set... | php | {
"resource": ""
} |
q258849 | Export.setBatchDownloadId | test | public function setBatchDownloadId(array $aIds, $iDownloadId)
{
if (is_object(reset($aIds))) {
$aIds = arrayExtractProperty($aIds, 'id');
}
if (!empty($aIds)) {
$oDb = Factory::service('Database');
$oDb->set('download_id', $iDownloadId);
$oDb->... | php | {
"resource": ""
} |
q258850 | AdminRouter.index | test | public function index()
{
// When executing on the CLI we don't need to perform a few bit's of sense checking
$oInput = Factory::service('Input');
if (!$oInput::isCli()) {
// Is there an AdminIP whitelist?
$whitelistIp = (array) appSetting('whitelist', 'admin');
... | php | {
"resource": ""
} |
q258851 | AdminRouter.findAdminControllers | test | protected function findAdminControllers()
{
// Look in the admin module
$this->loadAdminControllers(
'admin',
NAILS_PATH . 'module-admin/admin/controllers/',
NAILS_APP_PATH . 'application/modules/admin/controllers/',
['adminRouter.php']
);
... | php | {
"resource": ""
} |
q258852 | AdminRouter.loadAdminControllers | test | protected function loadAdminControllers($moduleName, $controllerPath, $appPath, $ignore = [])
{
// Does a path exist? Don't pollute the array with empty modules
if (is_dir($controllerPath)) {
// Look for controllers
$files = directory_map($controllerPath, 1);
f... | php | {
"resource": ""
} |
q258853 | AdminRouter.loadAdminController | test | protected function loadAdminController($file, $moduleName, $controllerPath, $appPath)
{
$fileName = substr($file, 0, strpos($file, '.php'));
// PHP file, no leading underscore
if (!$this->isValidAdminFile($file)) {
return;
}
// Valid file, load it up and defin... | php | {
"resource": ""
} |
q258854 | AdminRouter.loadAdminClass | test | protected function loadAdminClass($fileName, $className, $classPath, $moduleName)
{
// Does the expected class exist?
if (!class_exists($className)) {
return false;
}
// Does it have an announce method?
if (!method_exists($className, 'announce')) {
... | php | {
"resource": ""
} |
q258855 | AdminRouter.routeRequest | test | protected function routeRequest()
{
// What are we trying to access?
$oUri = Factory::service('Uri');
$sModule = $oUri->rsegment(3) ? $oUri->rsegment(3) : '';
$sController = ucfirst($oUri->rsegment(4) ? $oUri->rsegment(4) : $sModule);
$sMethod = $oUri->rsegmen... | php | {
"resource": ""
} |
q258856 | Helper.loadView | test | public static function loadView($sViewFile, $bLoadStructure = true, $bReturnView = false)
{
$aData =& getControllerData();
$oInput = Factory::service('Input');
$oView = Factory::service('View');
// Are we in a modal?
if ($oInput->get('isModal')) {
if (!isset(... | php | {
"resource": ""
} |
q258857 | Helper.loadCsv | test | public static function loadCsv($mData, $sFilename = '', $bHeaderRow = true)
{
// Determine what type of data has been supplied
if (is_array($mData) || get_class($mData) == 'CI_DB_mysqli_result') {
// If filename has been specified then set some additional headers
if (!empt... | php | {
"resource": ""
} |
q258858 | Helper.loadInlineView | test | public static function loadInlineView($sViewFile, $aViewData = [], $bReturnView = false)
{
$aCtrlData =& getControllerData();
$sCtrlPath = !empty($aCtrlData['currentRequest']['path']) ? $aCtrlData['currentRequest']['path'] : '';
$sCtrlName = basename($sCtrlPath, '.php');
$aCtrl... | php | {
"resource": ""
} |
q258859 | Helper.loadSearch | test | public static function loadSearch($oSearchObj, $bReturnView = true)
{
$aData = [
'searchable' => isset($oSearchObj->searchable) ? $oSearchObj->searchable : true,
'sortColumns' => isset($oSearchObj->sortColumns) ? $oSearchObj->sortColumns : [],
'sortOn' => i... | php | {
"resource": ""
} |
q258860 | Helper.searchFilterGetValueAtKey | test | public static function searchFilterGetValueAtKey($oFilterObj, $iKey)
{
return isset($oFilterObj->options[$iKey]->value) ? $oFilterObj->options[$iKey]->value : null;
} | php | {
"resource": ""
} |
q258861 | Helper.loadPagination | test | public static function loadPagination($oPaginationObject, $bReturnView = true)
{
$aData = [
'page' => isset($oPaginationObject->page) ? $oPaginationObject->page : null,
'perPage' => isset($oPaginationObject->perPage) ? $oPaginationObject->perPage : null,
'totalRows... | php | {
"resource": ""
} |
q258862 | Helper.loadCellAuto | test | public static function loadCellAuto($mValue, $sCellClass = '', $sCellAdditional = '')
{
// @todo - handle more field types
if (is_bool($mValue)) {
return Helper::loadBoolCell($mValue);
} elseif (preg_match('/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/', $mValue)) {
return Hel... | php | {
"resource": ""
} |
q258863 | Helper.loadUserCell | test | public static function loadUserCell($mUser)
{
if (is_numeric($mUser)) {
$oUserModel = Factory::model('User', 'nails/module-auth');
$oUser = $oUserModel->getById($mUser);
} elseif (is_string($mUser)) {
$oUserModel = Factory::model('User', 'nails/module-auth... | php | {
"resource": ""
} |
q258864 | Helper.loadDateCell | test | public static function loadDateCell($sDate, $sNoData = '—')
{
$aData = [
'date' => $sDate,
'noData' => $sNoData,
];
$oView = Factory::service('View');
return $oView->load('admin/_components/table-cell-date', $aData, true);
} | php | {
"resource": ""
} |
q258865 | Helper.loadDateTimeCell | test | public static function loadDateTimeCell($sDateTime, $sNoData = '—')
{
$aData = [
'dateTime' => $sDateTime,
'noData' => $sNoData,
];
$oView = Factory::service('View');
return $oView->load('admin/_components/table-cell-datetime', $aData, true);
} | php | {
"resource": ""
} |
q258866 | Helper.loadBoolCell | test | public static function loadBoolCell($value, $sDateTime = null)
{
$aData = [
'value' => $value,
'dateTime' => $sDateTime,
];
$oView = Factory::service('View');
return $oView->load('admin/_components/table-cell-boolean', $aData, true);
} | php | {
"resource": ""
} |
q258867 | Helper.loadSettingsComponentTable | test | public static function loadSettingsComponentTable($sComponentService, $sProvider, $sComponentType = 'component')
{
$oModel = Factory::service($sComponentService, $sProvider);
$sKey = $oModel->getSettingKey();
$aComponents = $oModel->getAll();
$aEnabled ... | php | {
"resource": ""
} |
q258868 | Helper.addHeaderButton | test | public static function addHeaderButton(
$sUrl,
$sLabel,
$sContext = null,
$sConfirmTitle = null,
$sConfirmBody = null
) {
$sContext = empty($sContext) ? 'primary' : $sContext;
self::$aHeaderButtons[] = [
'url' => $sUrl,
'label... | php | {
"resource": ""
} |
q258869 | Helper.dynamicTable | test | public static function dynamicTable($sKey, array $aFields, array $aData = [])
{
return Factory::service('View')
->load(
'admin/_components/dynamic-table',
[
'sKey' => $sKey,
'aFields' => $aFields,
'aDa... | php | {
"resource": ""
} |
q258870 | Nav.postSave | test | public function postSave()
{
$oInput = Factory::service('Input');
$aPrefRaw = array_filter((array) $oInput->post('preferences'));
$oPref = new \stdClass();
foreach ($aPrefRaw as $sModule => $aOptions) {
$oPref->{$sModule} = new \stdClass();
$oPref-... | php | {
"resource": ""
} |
q258871 | Create.execute | test | protected function execute(InputInterface $oInput, OutputInterface $oOutput): int
{
parent::execute($oInput, $oOutput);
// --------------------------------------------------------------------------
try {
// Ensure the paths exist
$this->createPath(self::EXPORT_PATH... | php | {
"resource": ""
} |
q258872 | Create.createSource | test | private function createSource(): void
{
$aFields = $this->getArguments();
$aFields['CLASS_NAME'] = str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z ]/', '', $aFields['NAME'])));
$aFields['FILENAME'] = strtolower(url_title($aFields['NAME']));
try {
$t... | php | {
"resource": ""
} |
q258873 | Csv.formatRow | test | protected function formatRow($oRow)
{
$aItems = array_map(
function ($sItem) {
return str_replace('"', '""', trim($sItem));
},
(array) $oRow
);
return '"' . implode('","', $aItems) . '"' . "\n";
} | php | {
"resource": ""
} |
q258874 | Nav.addAction | test | public function addAction($label, $url = 'index', $alerts = [], $order = null)
{
$this->actions[$url] = new \stdClass();
$this->actions[$url]->label = $label;
$this->actions[$url]->alerts = !is_array($alerts) ? [$alerts] : $alerts;
if (is_null($order)) {
$this->... | php | {
"resource": ""
} |
q258875 | Admin.setAdminData | test | public function setAdminData($key, $value, $userId = null)
{
return $this->setUnsetAdminData($key, $value, $userId, true);
} | php | {
"resource": ""
} |
q258876 | Admin.unsetAdminData | test | public function unsetAdminData($key, $userId = null)
{
return $this->setUnsetAdminData($key, null, $userId, false);
} | php | {
"resource": ""
} |
q258877 | Admin.setUnsetAdminData | test | protected function setUnsetAdminData($key, $value, $userId, $set)
{
// Get the user ID
$userId = $this->adminDataGetUserId($userId);
// Get the existing data for this user
$existing = $this->getAdminData(null, $userId);
if ($set) {
// Set the new key
... | php | {
"resource": ""
} |
q258878 | Admin.clearAdminData | test | public function clearAdminData($userId)
{
// Get the user ID
$userId = $this->adminDataGetUserId($userId);
$bResult = $this->oUserMetaService->update(
NAILS_DB_PREFIX . 'user_meta_admin',
$userId,
[
'nav_state' => null,
]
... | php | {
"resource": ""
} |
q258879 | SiteLog.getAll | test | public function getAll($iPage = null, $iPerPage = null, array $aData = [], $bIncludeDeleted = false): array
{
$dirMap = directory_map($this->logPath, 0);
$logFiles = [];
$filenameRegex = '/^log\-(\d{4}\-\d{2}\-\d{2})\.php$/';
foreach ($dirMap as $logFile) {
... | php | {
"resource": ""
} |
q258880 | Ckeditor.findConfig | test | protected function findConfig($sFile)
{
// @todo (Pablo - 2018-07-13) - The paths and URLs should probably be determined by the Asset service
if (file_exists(NAILS_APP_PATH . 'assets/build/js/' . $sFile)) {
return site_url('assets/build/js/' . $sFile);
} elseif (file_exists(NAIL... | php | {
"resource": ""
} |
q258881 | Base.loadJs | test | protected function loadJs()
{
\Nails\Common\Controller\Base::setNailsJs();
$oAsset = Factory::service('Asset');
// Module assets
$oAsset->load('admin.min.js', 'nails/module-admin');
$oAsset->load('nails.default.min.js', 'NAILS');
$oAsset->load('nails.admin.js', 'NA... | php | {
"resource": ""
} |
q258882 | Base.loadCss | test | protected function loadCss()
{
$oAsset = Factory::service('Asset');
// Module assets
$oAsset->load('nails.admin.css', 'NAILS');
$oAsset->load('admin.css', 'nails/module-admin');
// Component assets
foreach (Components::available() as $oComponent) {
if ... | php | {
"resource": ""
} |
q258883 | Base.loadLibraries | test | protected function loadLibraries()
{
$oAsset = Factory::service('Asset');
// jQuery
$oAsset->load('jquery/dist/jquery.min.js', 'NAILS-BOWER');
// Fancybox
$oAsset->load('fancybox/source/jquery.fancybox.pack.js', 'NAILS-BOWER');
$oAsset->load('fancybox/source/jquer... | php | {
"resource": ""
} |
q258884 | Base.autoLoad | test | protected function autoLoad()
{
foreach (Components::available() as $oComponent) {
if (!empty($oComponent->data->{'nails/module-admin'}->autoload)) {
$oAutoLoad = $oComponent->data->{'nails/module-admin'}->autoload;
// Libraries
if (!empty($oAut... | php | {
"resource": ""
} |
q258885 | Base.backwardsCompatibility | test | public static function backwardsCompatibility(&$oBindTo)
{
// @todo (Pablo - 2017-06-08) - Try and remove these dependencies
$oBindTo->load =& get_instance()->load;
$oBindTo->lang =& get_instance()->lang;
} | php | {
"resource": ""
} |
q258886 | Settings.site | test | public function site()
{
if (!userHasPermission('admin:admin:settings:site:.*')) {
unauthorised();
}
// --------------------------------------------------------------------------
$oInput = Factory::service('Input');
if ($oInput->post()) {
$aSettings... | php | {
"resource": ""
} |
q258887 | Settings.prepareWhitelist | test | protected function prepareWhitelist($sInput)
{
$sWhitelistRaw = $sInput;
$sWhitelistRaw = str_replace("\n\r", "\n", $sWhitelistRaw);
$aWhitelistRaw = explode("\n", $sWhitelistRaw);
$aWhitelist = [];
foreach ($aWhitelistRaw as $sLine) {
$aWhitelist = array_merg... | php | {
"resource": ""
} |
q258888 | Settings.extractFieldsets | test | protected function extractFieldsets($sComponentSlug, $aSettings, $fieldSetIndex = 0)
{
foreach ($aSettings as $oSetting) {
// If the object contains a `fields` property then consider this a fieldset and inception
if (isset($oSetting->fields)) {
$fieldSetIndex++;
... | php | {
"resource": ""
} |
q258889 | DataExport.getSourceBySlug | test | public function getSourceBySlug($sSlug)
{
foreach ($this->aSources as $oSource) {
if ($sSlug === $oSource->slug) {
return $oSource;
}
}
return null;
} | php | {
"resource": ""
} |
q258890 | DataExport.getFormatBySlug | test | public function getFormatBySlug($sSlug)
{
foreach ($this->aFormats as $oFormat) {
if ($sSlug === $oFormat->slug) {
return $oFormat;
}
}
return null;
} | php | {
"resource": ""
} |
q258891 | DataExport.export | test | public function export($sSourceSlug, $sFormatSlug, $aOptions = [])
{
$oSource = $this->getSourceBySlug($sSourceSlug);
if (empty($oSource)) {
throw new NailsException('Invalid data source "' . $sSourceSlug . '"');
}
$oFormat = $this->getFormatBySlug($sFormatSlug);
... | php | {
"resource": ""
} |
q258892 | Export.executionFailed | test | protected function executionFailed(
\Exception $oException,
\stdClass $oRequest,
\Nails\Admin\Model\Export $oModel,
\Nails\Admin\Factory\Email\DataExport $oEmail
) {
$this->writeLog('Exception: ' . $oException->getMessage());
$oModel->setBatchStatus($oRequest->ids, $o... | php | {
"resource": ""
} |
q258893 | ChangeLog.add | test | public function add(
$sVerb,
$sArticle,
$sItem,
$iItemId,
$sTitle,
$sUrl = null,
$sField = null,
$mOldValue = null,
$mNewValue = null,
$bStrict = true
) {
/**
* if the old_value and the new_value are the same then why a... | php | {
"resource": ""
} |
q258894 | ChangeLog.save | test | public function save()
{
// Process all the items and save to the DB, then clean up
if ($this->aChanges) {
$this->aChanges = array_values($this->aChanges);
$oDate = Factory::factory('DateTime');
for ($i = 0; $i < count($this->aChanges); $i++) {
... | php | {
"resource": ""
} |
q258895 | ChangeLog.getAll | test | public function getAll($iPage = null, $iPerPage = null, array $aData = [], $bIncludeDeleted = false): array
{
// If the first value is an array then treat as if called with getAll(null, null, $aData);
// @todo (Pablo - 2017-06-29) - Refactor how this join works (use expandable field)
if (i... | php | {
"resource": ""
} |
q258896 | ChangeLog.getCountCommon | test | protected function getCountCommon(array $aData = [])
{
// Join user tables
$oDb = Factory::service('Database');
$oDb->join(NAILS_DB_PREFIX . 'user u', 'u.id = ' . $this->getTableAlias() . '.user_id', 'LEFT');
$oDb->join(NAILS_DB_PREFIX . 'user_email ue', 'ue.user_id = ' . $this->get... | php | {
"resource": ""
} |
q258897 | ChangeLog.formatObject | test | protected function formatObject(
&$oObj,
array $aData = [],
array $aIntegers = [],
array $aBools = [],
array $aFloats = []
) {
parent::formatObject($oObj, $aData, $aIntegers, $aBools, $aFloats);
if (!empty($oObj->item_id)) {
$oObj->item_id = (int... | php | {
"resource": ""
} |
q258898 | Note.getRemap | test | public function getRemap($sMethod, array $aData = [])
{
list($sModel, $iItemId) = $this->getModelClassAndId();
$aData['where'] = [
['model', $sModel],
['item_id', $iItemId],
];
return parent::getRemap($sMethod, $aData);
} | php | {
"resource": ""
} |
q258899 | Note.validateUserInput | test | protected function validateUserInput($aData, $oItem = null)
{
$aData = parent::validateUserInput($aData, $oItem);
list($sModel) = $this->getModelClassAndId();
$aData['model'] = $sModel;
return $aData;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.