repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
webdevops/TYPO3-metaseo
Classes/Utility/SitemapUtility.php
SitemapUtility.expire
public static function expire() { // ##################### // Delete expired entries // ##################### $query = 'DELETE FROM tx_metaseo_sitemap WHERE is_blacklisted = 0 AND expire <= ' . (int)time(); DatabaseUtility::exec($query); // ##################### // Deleted or // excluded pages // ##################### $query = 'SELECT ts.uid FROM tx_metaseo_sitemap ts LEFT JOIN pages p ON p.uid = ts.page_uid AND p.deleted = 0 AND p.hidden = 0 AND p.tx_metaseo_is_exclude = 0 AND ' . DatabaseUtility::conditionNotIn('p.doktype', self::getDoktypeBlacklist()) . ' WHERE p.uid IS NULL'; $deletedSitemapPages = DatabaseUtility::getColWithIndex($query); // delete pages if (!empty($deletedSitemapPages)) { $query = 'DELETE FROM tx_metaseo_sitemap WHERE uid IN (' . implode(',', $deletedSitemapPages) . ') AND is_blacklisted = 0'; DatabaseUtility::exec($query); } }
php
public static function expire() { // ##################### // Delete expired entries // ##################### $query = 'DELETE FROM tx_metaseo_sitemap WHERE is_blacklisted = 0 AND expire <= ' . (int)time(); DatabaseUtility::exec($query); // ##################### // Deleted or // excluded pages // ##################### $query = 'SELECT ts.uid FROM tx_metaseo_sitemap ts LEFT JOIN pages p ON p.uid = ts.page_uid AND p.deleted = 0 AND p.hidden = 0 AND p.tx_metaseo_is_exclude = 0 AND ' . DatabaseUtility::conditionNotIn('p.doktype', self::getDoktypeBlacklist()) . ' WHERE p.uid IS NULL'; $deletedSitemapPages = DatabaseUtility::getColWithIndex($query); // delete pages if (!empty($deletedSitemapPages)) { $query = 'DELETE FROM tx_metaseo_sitemap WHERE uid IN (' . implode(',', $deletedSitemapPages) . ') AND is_blacklisted = 0'; DatabaseUtility::exec($query); } }
[ "public", "static", "function", "expire", "(", ")", "{", "// #####################", "// Delete expired entries", "// #####################", "$", "query", "=", "'DELETE FROM tx_metaseo_sitemap\n WHERE is_blacklisted = 0\n AND expire <= '", ...
Clear outdated and invalid pages from sitemap table
[ "Clear", "outdated", "and", "invalid", "pages", "from", "sitemap", "table" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/SitemapUtility.php#L160-L194
train
webdevops/TYPO3-metaseo
Classes/Utility/SitemapUtility.php
SitemapUtility.getList
public static function getList($rootPid, $languageId = null) { $sitemapList = array(); $pageList = array(); $typo3Pids = array(); $query = 'SELECT ts.* FROM tx_metaseo_sitemap ts INNER JOIN pages p ON p.uid = ts.page_uid AND p.deleted = 0 AND p.hidden = 0 AND p.tx_metaseo_is_exclude = 0 AND ' . DatabaseUtility::conditionNotIn('p.doktype', self::getDoktypeBlacklist()) . ' WHERE ts.page_rootpid = ' . (int)$rootPid . ' AND ts.is_blacklisted = 0'; if ($languageId !== null) { $query .= ' AND ts.page_language = ' . (int)$languageId; } $query .= ' ORDER BY ts.page_depth ASC, p.pid ASC, p.sorting ASC'; $resultRows = DatabaseUtility::getAll($query); if (!$resultRows) { return self::getListArray(); //empty } foreach ($resultRows as $row) { $sitemapList[] = $row; $sitemapPageId = $row['page_uid']; $typo3Pids[$sitemapPageId] = (int)$sitemapPageId; } if (!empty($typo3Pids)) { $query = 'SELECT * FROM pages WHERE ' . DatabaseUtility::conditionIn('uid', $typo3Pids); $pageList = DatabaseUtility::getAllWithIndex($query, 'uid'); if (empty($pageList)) { return self::getListArray(); //empty } } return self::getListArray($sitemapList, $pageList); }
php
public static function getList($rootPid, $languageId = null) { $sitemapList = array(); $pageList = array(); $typo3Pids = array(); $query = 'SELECT ts.* FROM tx_metaseo_sitemap ts INNER JOIN pages p ON p.uid = ts.page_uid AND p.deleted = 0 AND p.hidden = 0 AND p.tx_metaseo_is_exclude = 0 AND ' . DatabaseUtility::conditionNotIn('p.doktype', self::getDoktypeBlacklist()) . ' WHERE ts.page_rootpid = ' . (int)$rootPid . ' AND ts.is_blacklisted = 0'; if ($languageId !== null) { $query .= ' AND ts.page_language = ' . (int)$languageId; } $query .= ' ORDER BY ts.page_depth ASC, p.pid ASC, p.sorting ASC'; $resultRows = DatabaseUtility::getAll($query); if (!$resultRows) { return self::getListArray(); //empty } foreach ($resultRows as $row) { $sitemapList[] = $row; $sitemapPageId = $row['page_uid']; $typo3Pids[$sitemapPageId] = (int)$sitemapPageId; } if (!empty($typo3Pids)) { $query = 'SELECT * FROM pages WHERE ' . DatabaseUtility::conditionIn('uid', $typo3Pids); $pageList = DatabaseUtility::getAllWithIndex($query, 'uid'); if (empty($pageList)) { return self::getListArray(); //empty } } return self::getListArray($sitemapList, $pageList); }
[ "public", "static", "function", "getList", "(", "$", "rootPid", ",", "$", "languageId", "=", "null", ")", "{", "$", "sitemapList", "=", "array", "(", ")", ";", "$", "pageList", "=", "array", "(", ")", ";", "$", "typo3Pids", "=", "array", "(", ")", ...
Return list of sitemap pages @param integer $rootPid Root page id of tree @param integer $languageId Limit to language id @return array
[ "Return", "list", "of", "sitemap", "pages" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/SitemapUtility.php#L241-L293
train
webdevops/TYPO3-metaseo
Classes/Sitemap/Generator/AbstractGenerator.php
AbstractGenerator.pageCount
public function pageCount() { $pageLimit = GeneralUtility::getRootSettingValue('sitemap_page_limit', null); if (empty($pageLimit)) { $pageLimit = 1000; } $pageItems = count($this->sitemapPages); $pageCount = ceil($pageItems / $pageLimit); return $pageCount; }
php
public function pageCount() { $pageLimit = GeneralUtility::getRootSettingValue('sitemap_page_limit', null); if (empty($pageLimit)) { $pageLimit = 1000; } $pageItems = count($this->sitemapPages); $pageCount = ceil($pageItems / $pageLimit); return $pageCount; }
[ "public", "function", "pageCount", "(", ")", "{", "$", "pageLimit", "=", "GeneralUtility", "::", "getRootSettingValue", "(", "'sitemap_page_limit'", ",", "null", ")", ";", "if", "(", "empty", "(", "$", "pageLimit", ")", ")", "{", "$", "pageLimit", "=", "10...
Return page count @return integer
[ "Return", "page", "count" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Sitemap/Generator/AbstractGenerator.php#L131-L143
train
webdevops/TYPO3-metaseo
Classes/Hook/Extension/TtnewsExtension.php
TtnewsExtension.extraItemMarkerProcessor
public function extraItemMarkerProcessor(array $markerArray, array $row, array $lConf, AbstractPlugin $ttnewsObj) { $theCode = (string)strtoupper(trim($ttnewsObj->theCode)); $connector = GeneralUtility::makeInstance('Metaseo\\Metaseo\\Connector'); switch ($theCode) { case 'SINGLE': case 'SINGLE2': // Title if (!empty($row['title'])) { $connector->setMetaTag('title', $row['title']); } // Description if (!empty($row['short'])) { $connector->setMetaTag('description', $row['short']); } // Keywords if (!empty($row['keywords'])) { $connector->setMetaTag('keywords', $row['keywords']); } // Short/Description if (!empty($row['short'])) { $connector->setMetaTag('description', $row['short']); } // Author if (!empty($row['author'])) { $connector->setMetaTag('author', $row['author']); } // E-Mail if (!empty($row['author_email'])) { $connector->setMetaTag('email', $row['author_email']); } break; } return $markerArray; }
php
public function extraItemMarkerProcessor(array $markerArray, array $row, array $lConf, AbstractPlugin $ttnewsObj) { $theCode = (string)strtoupper(trim($ttnewsObj->theCode)); $connector = GeneralUtility::makeInstance('Metaseo\\Metaseo\\Connector'); switch ($theCode) { case 'SINGLE': case 'SINGLE2': // Title if (!empty($row['title'])) { $connector->setMetaTag('title', $row['title']); } // Description if (!empty($row['short'])) { $connector->setMetaTag('description', $row['short']); } // Keywords if (!empty($row['keywords'])) { $connector->setMetaTag('keywords', $row['keywords']); } // Short/Description if (!empty($row['short'])) { $connector->setMetaTag('description', $row['short']); } // Author if (!empty($row['author'])) { $connector->setMetaTag('author', $row['author']); } // E-Mail if (!empty($row['author_email'])) { $connector->setMetaTag('email', $row['author_email']); } break; } return $markerArray; }
[ "public", "function", "extraItemMarkerProcessor", "(", "array", "$", "markerArray", ",", "array", "$", "row", ",", "array", "$", "lConf", ",", "AbstractPlugin", "$", "ttnewsObj", ")", "{", "$", "theCode", "=", "(", "string", ")", "strtoupper", "(", "trim", ...
Extra item marker hook for metatag fetching @param array $markerArray Marker array @param array $row Current tt_news row @param array $lConf Local configuration @param AbstractPlugin $ttnewsObj Pi-object from tt_news @return array Marker array (not changed)
[ "Extra", "item", "marker", "hook", "for", "metatag", "fetching" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Hook/Extension/TtnewsExtension.php#L48-L90
train
webdevops/TYPO3-metaseo
Classes/Sitemap/Generator/XmlGenerator.php
XmlGenerator.sitemapIndex
public function sitemapIndex() { $pageLimit = 10000; if (isset($this->tsSetup['pageLimit']) && $this->tsSetup['pageLimit'] != '') { $pageLimit = (int)$this->tsSetup['pageLimit']; } $sitemaps = array(); $pageItems = count($this->sitemapPages); $pageCount = ceil($pageItems / $pageLimit); $linkConf = array( 'parameter' => GeneralUtility::getCurrentPid() . ',' . $GLOBALS['TSFE']->type, 'additionalParams' => '', 'useCacheHash' => 1, ); for ($i = 0; $i < $pageCount; $i++) { if ($this->indexPathTemplate) { $link = GeneralUtility::fullUrl(str_replace('###PAGE###', $i, $this->indexPathTemplate)); $sitemaps[] = $link; } else { $linkConf['additionalParams'] = '&page=' . ($i + 1); $sitemaps[] = GeneralUtility::fullUrl($GLOBALS['TSFE']->cObj->typoLink_URL($linkConf)); } } $ret = '<?xml version="1.0" encoding="UTF-8"?>'; $ret .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" ' . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'; $ret .= ' xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 ' . 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">'; // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'sitemapXmlIndexSitemapList', $this, $sitemaps); foreach ($sitemaps as $sitemapPage) { $ret .= '<sitemap><loc>' . htmlspecialchars($sitemapPage) . '</loc></sitemap>'; } $ret .= '</sitemapindex>'; // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'sitemapXmlIndexOutput', $this, $ret); return $ret; }
php
public function sitemapIndex() { $pageLimit = 10000; if (isset($this->tsSetup['pageLimit']) && $this->tsSetup['pageLimit'] != '') { $pageLimit = (int)$this->tsSetup['pageLimit']; } $sitemaps = array(); $pageItems = count($this->sitemapPages); $pageCount = ceil($pageItems / $pageLimit); $linkConf = array( 'parameter' => GeneralUtility::getCurrentPid() . ',' . $GLOBALS['TSFE']->type, 'additionalParams' => '', 'useCacheHash' => 1, ); for ($i = 0; $i < $pageCount; $i++) { if ($this->indexPathTemplate) { $link = GeneralUtility::fullUrl(str_replace('###PAGE###', $i, $this->indexPathTemplate)); $sitemaps[] = $link; } else { $linkConf['additionalParams'] = '&page=' . ($i + 1); $sitemaps[] = GeneralUtility::fullUrl($GLOBALS['TSFE']->cObj->typoLink_URL($linkConf)); } } $ret = '<?xml version="1.0" encoding="UTF-8"?>'; $ret .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" ' . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'; $ret .= ' xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 ' . 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">'; // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'sitemapXmlIndexSitemapList', $this, $sitemaps); foreach ($sitemaps as $sitemapPage) { $ret .= '<sitemap><loc>' . htmlspecialchars($sitemapPage) . '</loc></sitemap>'; } $ret .= '</sitemapindex>'; // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'sitemapXmlIndexOutput', $this, $ret); return $ret; }
[ "public", "function", "sitemapIndex", "(", ")", "{", "$", "pageLimit", "=", "10000", ";", "if", "(", "isset", "(", "$", "this", "->", "tsSetup", "[", "'pageLimit'", "]", ")", "&&", "$", "this", "->", "tsSetup", "[", "'pageLimit'", "]", "!=", "''", ")...
Create sitemap index @return string
[ "Create", "sitemap", "index" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Sitemap/Generator/XmlGenerator.php#L46-L95
train
webdevops/TYPO3-metaseo
Classes/Page/SitemapXmlPage.php
SitemapXmlPage.build
protected function build() { $page = Typo3GeneralUtility::_GP('page'); /** @var \Metaseo\Metaseo\Sitemap\Generator\XmlGenerator $generator */ $generator = $this->objectManager->get('Metaseo\\Metaseo\\Sitemap\\Generator\\XmlGenerator'); if (empty($page) || $page === 'index') { return $generator->sitemapIndex(); } else { return $generator->sitemap($page); } }
php
protected function build() { $page = Typo3GeneralUtility::_GP('page'); /** @var \Metaseo\Metaseo\Sitemap\Generator\XmlGenerator $generator */ $generator = $this->objectManager->get('Metaseo\\Metaseo\\Sitemap\\Generator\\XmlGenerator'); if (empty($page) || $page === 'index') { return $generator->sitemapIndex(); } else { return $generator->sitemap($page); } }
[ "protected", "function", "build", "(", ")", "{", "$", "page", "=", "Typo3GeneralUtility", "::", "_GP", "(", "'page'", ")", ";", "/** @var \\Metaseo\\Metaseo\\Sitemap\\Generator\\XmlGenerator $generator */", "$", "generator", "=", "$", "this", "->", "objectManager", "-...
Build sitemap index or specific page @return string
[ "Build", "sitemap", "index", "or", "specific", "page" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/SitemapXmlPage.php#L70-L82
train
webdevops/TYPO3-metaseo
Classes/Hook/SitemapIndexHook.php
SitemapIndexHook.getPageChangeFrequency
protected function getPageChangeFrequency(array $page) { $ret = 0; if (!empty($page['tx_metaseo_change_frequency'])) { $ret = (int)$page['tx_metaseo_change_frequency']; } elseif (!empty($this->conf['sitemap.']['changeFrequency'])) { $ret = (int)$this->conf['sitemap.']['changeFrequency']; } if (empty($pageChangeFrequency)) { $ret = 0; } return $ret; }
php
protected function getPageChangeFrequency(array $page) { $ret = 0; if (!empty($page['tx_metaseo_change_frequency'])) { $ret = (int)$page['tx_metaseo_change_frequency']; } elseif (!empty($this->conf['sitemap.']['changeFrequency'])) { $ret = (int)$this->conf['sitemap.']['changeFrequency']; } if (empty($pageChangeFrequency)) { $ret = 0; } return $ret; }
[ "protected", "function", "getPageChangeFrequency", "(", "array", "$", "page", ")", "{", "$", "ret", "=", "0", ";", "if", "(", "!", "empty", "(", "$", "page", "[", "'tx_metaseo_change_frequency'", "]", ")", ")", "{", "$", "ret", "=", "(", "int", ")", ...
Return page change frequency @param array $page Page data @return integer
[ "Return", "page", "change", "frequency" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Hook/SitemapIndexHook.php#L214-L229
train
webdevops/TYPO3-metaseo
Classes/Hook/SitemapIndexHook.php
SitemapIndexHook.checkIfSitemapIndexingIsEnabled
protected function checkIfSitemapIndexingIsEnabled($indexingType) { // check if sitemap is enabled in root if (!GeneralUtility::getRootSettingValue('is_sitemap', true) || !GeneralUtility::getRootSettingValue('is_sitemap_' . $indexingType . '_indexer', true) ) { return false; } // check current page if (!$this->checkIfCurrentPageIsIndexable()) { return false; } return true; }
php
protected function checkIfSitemapIndexingIsEnabled($indexingType) { // check if sitemap is enabled in root if (!GeneralUtility::getRootSettingValue('is_sitemap', true) || !GeneralUtility::getRootSettingValue('is_sitemap_' . $indexingType . '_indexer', true) ) { return false; } // check current page if (!$this->checkIfCurrentPageIsIndexable()) { return false; } return true; }
[ "protected", "function", "checkIfSitemapIndexingIsEnabled", "(", "$", "indexingType", ")", "{", "// check if sitemap is enabled in root", "if", "(", "!", "GeneralUtility", "::", "getRootSettingValue", "(", "'is_sitemap'", ",", "true", ")", "||", "!", "GeneralUtility", "...
Check if sitemap indexing is enabled @param string $indexingType Indexing type (page or typolink) @return bool
[ "Check", "if", "sitemap", "indexing", "is", "enabled" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Hook/SitemapIndexHook.php#L238-L253
train
webdevops/TYPO3-metaseo
Classes/Hook/SitemapIndexHook.php
SitemapIndexHook.checkIfCurrentPageIsIndexable
protected function checkIfCurrentPageIsIndexable() { // check caching status if ($this->pageIndexFlag !== null) { return $this->pageIndexFlag; } // by default page is not cacheable $this->pageIndexFlag = false; // ############################ // Basic checks // ############################ $cacheConf = array( 'allowNoStaticCachable' => (bool)$this->conf['sitemap.']['index.']['allowNoStaticCachable'], 'allowNoCache' => (bool)$this->conf['sitemap.']['index.']['allowNoCache'] ); if (!FrontendUtility::isCacheable($cacheConf)) { return false; } $tsfe = self::getTsfe(); // Check for type blacklisting (from typoscript PAGE object) if (in_array($tsfe->type, $this->pageTypeBlacklist)) { return false; } // Check if page is excluded from search engines if (!empty($tsfe->page['tx_metaseo_is_exclude'])) { return false; } // Check for doktype blacklisting (from current page record) if (in_array((int)$tsfe->page['doktype'], $this->doktypeBlacklist)) { return false; } // all checks successful, page is cacheable $this->pageIndexFlag = true; return true; }
php
protected function checkIfCurrentPageIsIndexable() { // check caching status if ($this->pageIndexFlag !== null) { return $this->pageIndexFlag; } // by default page is not cacheable $this->pageIndexFlag = false; // ############################ // Basic checks // ############################ $cacheConf = array( 'allowNoStaticCachable' => (bool)$this->conf['sitemap.']['index.']['allowNoStaticCachable'], 'allowNoCache' => (bool)$this->conf['sitemap.']['index.']['allowNoCache'] ); if (!FrontendUtility::isCacheable($cacheConf)) { return false; } $tsfe = self::getTsfe(); // Check for type blacklisting (from typoscript PAGE object) if (in_array($tsfe->type, $this->pageTypeBlacklist)) { return false; } // Check if page is excluded from search engines if (!empty($tsfe->page['tx_metaseo_is_exclude'])) { return false; } // Check for doktype blacklisting (from current page record) if (in_array((int)$tsfe->page['doktype'], $this->doktypeBlacklist)) { return false; } // all checks successful, page is cacheable $this->pageIndexFlag = true; return true; }
[ "protected", "function", "checkIfCurrentPageIsIndexable", "(", ")", "{", "// check caching status", "if", "(", "$", "this", "->", "pageIndexFlag", "!==", "null", ")", "{", "return", "$", "this", "->", "pageIndexFlag", ";", "}", "// by default page is not cacheable", ...
Check if current page is indexable Will do following checks: - REQUEST_METHOD (must be GET) - If there is a feuser session - Page type blacklisting - Exclusion from search engines - If page is static cacheable - If no_cache is not set (checks will be cached) @return bool
[ "Check", "if", "current", "page", "is", "indexable" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Hook/SitemapIndexHook.php#L270-L315
train
webdevops/TYPO3-metaseo
Classes/Command/MetaseoCommandController.php
MetaseoCommandController.clearSitemapCommand
public function clearSitemapCommand($rootPageId) { $rootPageId = $this->getRootPageIdFromId($rootPageId); if ($rootPageId !== null) { $query = 'DELETE FROM tx_metaseo_sitemap WHERE page_rootpid = ' . DatabaseUtility::quote($rootPageId, 'tx_metaseo_sitemap') . ' AND is_blacklisted = 0'; DatabaseUtility::exec($query); ConsoleUtility::writeLine('Sitemap cleared'); } else { ConsoleUtility::writeErrorLine('No such root page found'); ConsoleUtility::terminate(1); } }
php
public function clearSitemapCommand($rootPageId) { $rootPageId = $this->getRootPageIdFromId($rootPageId); if ($rootPageId !== null) { $query = 'DELETE FROM tx_metaseo_sitemap WHERE page_rootpid = ' . DatabaseUtility::quote($rootPageId, 'tx_metaseo_sitemap') . ' AND is_blacklisted = 0'; DatabaseUtility::exec($query); ConsoleUtility::writeLine('Sitemap cleared'); } else { ConsoleUtility::writeErrorLine('No such root page found'); ConsoleUtility::terminate(1); } }
[ "public", "function", "clearSitemapCommand", "(", "$", "rootPageId", ")", "{", "$", "rootPageId", "=", "$", "this", "->", "getRootPageIdFromId", "(", "$", "rootPageId", ")", ";", "if", "(", "$", "rootPageId", "!==", "null", ")", "{", "$", "query", "=", "...
Clear sitemap for one root page @param string $rootPageId Site root page id or domain
[ "Clear", "sitemap", "for", "one", "root", "page" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Command/MetaseoCommandController.php#L57-L72
train
webdevops/TYPO3-metaseo
Classes/Command/MetaseoCommandController.php
MetaseoCommandController.sitemapCommand
public function sitemapCommand($rootPageId) { $rootPageId = $this->getRootPageIdFromId($rootPageId); if ($rootPageId !== null) { $domain = RootPageUtility::getDomain($rootPageId); $query = 'SELECT page_url FROM tx_metaseo_sitemap WHERE page_rootpid = ' . DatabaseUtility::quote($rootPageId, 'tx_metaseo_sitemap') . ' AND is_blacklisted = 0'; $urlList = DatabaseUtility::getCol($query); foreach ($urlList as $url) { if ($domain) { $url = GeneralUtility::fullUrl($url, $domain); } ConsoleUtility::writeLine($url); } } else { ConsoleUtility::writeErrorLine('No such root page found'); ConsoleUtility::terminate(1); } }
php
public function sitemapCommand($rootPageId) { $rootPageId = $this->getRootPageIdFromId($rootPageId); if ($rootPageId !== null) { $domain = RootPageUtility::getDomain($rootPageId); $query = 'SELECT page_url FROM tx_metaseo_sitemap WHERE page_rootpid = ' . DatabaseUtility::quote($rootPageId, 'tx_metaseo_sitemap') . ' AND is_blacklisted = 0'; $urlList = DatabaseUtility::getCol($query); foreach ($urlList as $url) { if ($domain) { $url = GeneralUtility::fullUrl($url, $domain); } ConsoleUtility::writeLine($url); } } else { ConsoleUtility::writeErrorLine('No such root page found'); ConsoleUtility::terminate(1); } }
[ "public", "function", "sitemapCommand", "(", "$", "rootPageId", ")", "{", "$", "rootPageId", "=", "$", "this", "->", "getRootPageIdFromId", "(", "$", "rootPageId", ")", ";", "if", "(", "$", "rootPageId", "!==", "null", ")", "{", "$", "domain", "=", "Root...
Get whole list of sitemap entries @param string $rootPageId Site root page id or domain
[ "Get", "whole", "list", "of", "sitemap", "entries" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Command/MetaseoCommandController.php#L79-L103
train
webdevops/TYPO3-metaseo
Classes/Scheduler/Task/AbstractSitemapTask.php
AbstractSitemapTask.cleanupDirectory
protected function cleanupDirectory() { if (empty($this->sitemapDir)) { throw new \Exception('Basedir not set'); } $fullPath = PATH_site . '/' . $this->sitemapDir; if (!is_dir($fullPath)) { Typo3GeneralUtility::mkdir($fullPath); } foreach (new \DirectoryIterator($fullPath) as $file) { if ($file->isFile() && !$file->isDot()) { $fileName = $file->getFilename(); unlink($fullPath . '/' . $fileName); } } }
php
protected function cleanupDirectory() { if (empty($this->sitemapDir)) { throw new \Exception('Basedir not set'); } $fullPath = PATH_site . '/' . $this->sitemapDir; if (!is_dir($fullPath)) { Typo3GeneralUtility::mkdir($fullPath); } foreach (new \DirectoryIterator($fullPath) as $file) { if ($file->isFile() && !$file->isDot()) { $fileName = $file->getFilename(); unlink($fullPath . '/' . $fileName); } } }
[ "protected", "function", "cleanupDirectory", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "sitemapDir", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Basedir not set'", ")", ";", "}", "$", "fullPath", "=", "PATH_site", ".", "'/'"...
Cleanup sitemap directory
[ "Cleanup", "sitemap", "directory" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Scheduler/Task/AbstractSitemapTask.php#L84-L102
train
webdevops/TYPO3-metaseo
Classes/Scheduler/Task/AbstractSitemapTask.php
AbstractSitemapTask.generateSitemapLinkTemplate
protected function generateSitemapLinkTemplate($template) { $ret = null; // Set link template for index file $linkConf = array( 'parameter' => $this->sitemapDir . '/' . $template, ); if (strlen($GLOBALS['TSFE']->baseUrl) > 1) { $ret = $GLOBALS['TSFE']->baseUrlWrap($GLOBALS['TSFE']->cObj->typoLink_URL($linkConf)); } elseif (strlen($GLOBALS['TSFE']->absRefPrefix) > 1) { $ret = $GLOBALS['TSFE']->absRefPrefix . $GLOBALS['TSFE']->cObj->typoLink_URL($linkConf); } else { $ret = $GLOBALS['TSFE']->cObj->typoLink_URL($linkConf); } return $ret; }
php
protected function generateSitemapLinkTemplate($template) { $ret = null; // Set link template for index file $linkConf = array( 'parameter' => $this->sitemapDir . '/' . $template, ); if (strlen($GLOBALS['TSFE']->baseUrl) > 1) { $ret = $GLOBALS['TSFE']->baseUrlWrap($GLOBALS['TSFE']->cObj->typoLink_URL($linkConf)); } elseif (strlen($GLOBALS['TSFE']->absRefPrefix) > 1) { $ret = $GLOBALS['TSFE']->absRefPrefix . $GLOBALS['TSFE']->cObj->typoLink_URL($linkConf); } else { $ret = $GLOBALS['TSFE']->cObj->typoLink_URL($linkConf); } return $ret; }
[ "protected", "function", "generateSitemapLinkTemplate", "(", "$", "template", ")", "{", "$", "ret", "=", "null", ";", "// Set link template for index file", "$", "linkConf", "=", "array", "(", "'parameter'", "=>", "$", "this", "->", "sitemapDir", ".", "'/'", "."...
Generate sitemap link template @param string $template File link template @return string
[ "Generate", "sitemap", "link", "template" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Scheduler/Task/AbstractSitemapTask.php#L124-L142
train
webdevops/TYPO3-metaseo
Classes/Scheduler/Task/AbstractTask.php
AbstractTask.initLanguages
protected function initLanguages() { $this->languageIdList[0] = 0; $query = 'SELECT uid FROM sys_language WHERE hidden = 0'; $langIdList = DatabaseUtility::getColWithIndex($query); $this->languageIdList = $langIdList; }
php
protected function initLanguages() { $this->languageIdList[0] = 0; $query = 'SELECT uid FROM sys_language WHERE hidden = 0'; $langIdList = DatabaseUtility::getColWithIndex($query); $this->languageIdList = $langIdList; }
[ "protected", "function", "initLanguages", "(", ")", "{", "$", "this", "->", "languageIdList", "[", "0", "]", "=", "0", ";", "$", "query", "=", "'SELECT uid\n FROM sys_language\n WHERE hidden = 0'", ";", "$", "langIdList", "...
Get list of root pages in current typo3
[ "Get", "list", "of", "root", "pages", "in", "current", "typo3" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Scheduler/Task/AbstractTask.php#L97-L107
train
webdevops/TYPO3-metaseo
Classes/Utility/GeneralUtility.php
GeneralUtility.getLanguageId
public static function getLanguageId() { $ret = 0; if (!empty($GLOBALS['TSFE']->tmpl->setup['config.']['sys_language_uid'])) { $ret = (int)$GLOBALS['TSFE']->tmpl->setup['config.']['sys_language_uid']; } return $ret; }
php
public static function getLanguageId() { $ret = 0; if (!empty($GLOBALS['TSFE']->tmpl->setup['config.']['sys_language_uid'])) { $ret = (int)$GLOBALS['TSFE']->tmpl->setup['config.']['sys_language_uid']; } return $ret; }
[ "public", "static", "function", "getLanguageId", "(", ")", "{", "$", "ret", "=", "0", ";", "if", "(", "!", "empty", "(", "$", "GLOBALS", "[", "'TSFE'", "]", "->", "tmpl", "->", "setup", "[", "'config.'", "]", "[", "'sys_language_uid'", "]", ")", ")",...
Get current language id @return integer
[ "Get", "current", "language", "id" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/GeneralUtility.php#L65-L74
train
webdevops/TYPO3-metaseo
Classes/Utility/GeneralUtility.php
GeneralUtility.isMountpointInRootLine
public static function isMountpointInRootLine($uid = null) { $ret = false; // Performance check, there must be an MP-GET value if (Typo3GeneralUtility::_GET('MP')) { // Possible mount point detected, let's check the rootline foreach (self::getRootLine($uid) as $page) { if (!empty($page['_MOUNT_OL'])) { // Mountpoint detected in rootline $ret = true; } } } return $ret; }
php
public static function isMountpointInRootLine($uid = null) { $ret = false; // Performance check, there must be an MP-GET value if (Typo3GeneralUtility::_GET('MP')) { // Possible mount point detected, let's check the rootline foreach (self::getRootLine($uid) as $page) { if (!empty($page['_MOUNT_OL'])) { // Mountpoint detected in rootline $ret = true; } } } return $ret; }
[ "public", "static", "function", "isMountpointInRootLine", "(", "$", "uid", "=", "null", ")", "{", "$", "ret", "=", "false", ";", "// Performance check, there must be an MP-GET value", "if", "(", "Typo3GeneralUtility", "::", "_GET", "(", "'MP'", ")", ")", "{", "/...
Check if there is any mountpoint in rootline @param integer|null $uid Page UID @return boolean
[ "Check", "if", "there", "is", "any", "mountpoint", "in", "rootline" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/GeneralUtility.php#L93-L109
train
webdevops/TYPO3-metaseo
Classes/Utility/GeneralUtility.php
GeneralUtility.getRootLine
public static function getRootLine($uid = null) { if ($uid === null) { ################# # Current rootline ################# if (empty(self::$rootlineCache['__CURRENT__'])) { // Current rootline $rootline = $GLOBALS['TSFE']->tmpl->rootLine; // Filter rootline by siteroot $rootline = self::filterRootlineBySiteroot((array)$rootline); self::$rootlineCache['__CURRENT__'] = $rootline; } $ret = self::$rootlineCache['__CURRENT__']; } else { ################# # Other rootline ################# if (empty(self::$rootlineCache[$uid])) { // Fetch full rootline to TYPO3 root (0) $rootline = self::getSysPageObj()->getRootLine($uid); // Filter rootline by siteroot $rootline = self::filterRootlineBySiteroot((array)$rootline); self::$rootlineCache[$uid] = $rootline; } $ret = self::$rootlineCache[$uid]; } return $ret; }
php
public static function getRootLine($uid = null) { if ($uid === null) { ################# # Current rootline ################# if (empty(self::$rootlineCache['__CURRENT__'])) { // Current rootline $rootline = $GLOBALS['TSFE']->tmpl->rootLine; // Filter rootline by siteroot $rootline = self::filterRootlineBySiteroot((array)$rootline); self::$rootlineCache['__CURRENT__'] = $rootline; } $ret = self::$rootlineCache['__CURRENT__']; } else { ################# # Other rootline ################# if (empty(self::$rootlineCache[$uid])) { // Fetch full rootline to TYPO3 root (0) $rootline = self::getSysPageObj()->getRootLine($uid); // Filter rootline by siteroot $rootline = self::filterRootlineBySiteroot((array)$rootline); self::$rootlineCache[$uid] = $rootline; } $ret = self::$rootlineCache[$uid]; } return $ret; }
[ "public", "static", "function", "getRootLine", "(", "$", "uid", "=", "null", ")", "{", "if", "(", "$", "uid", "===", "null", ")", "{", "#################", "# Current rootline", "#################", "if", "(", "empty", "(", "self", "::", "$", "rootlineCache"...
Get current root line @param integer|null $uid Page UID @return array
[ "Get", "current", "root", "line" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/GeneralUtility.php#L118-L153
train
webdevops/TYPO3-metaseo
Classes/Utility/GeneralUtility.php
GeneralUtility.filterRootlineBySiteroot
protected static function filterRootlineBySiteroot(array $rootline) { $ret = array(); // Make sure sorting is right (first root, last page) ksort($rootline, SORT_NUMERIC); //reverse rootline $rootline = array_reverse($rootline); foreach ($rootline as $page) { $ret[] = $page; if (!empty($page['is_siteroot'])) { break; } } $ret = array_reverse($ret); return $ret; }
php
protected static function filterRootlineBySiteroot(array $rootline) { $ret = array(); // Make sure sorting is right (first root, last page) ksort($rootline, SORT_NUMERIC); //reverse rootline $rootline = array_reverse($rootline); foreach ($rootline as $page) { $ret[] = $page; if (!empty($page['is_siteroot'])) { break; } } $ret = array_reverse($ret); return $ret; }
[ "protected", "static", "function", "filterRootlineBySiteroot", "(", "array", "$", "rootline", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "// Make sure sorting is right (first root, last page)", "ksort", "(", "$", "rootline", ",", "SORT_NUMERIC", ")", ";", ...
Filter rootline to get the real one up to siteroot page @param $rootline @return array
[ "Filter", "rootline", "to", "get", "the", "real", "one", "up", "to", "siteroot", "page" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/GeneralUtility.php#L162-L181
train
webdevops/TYPO3-metaseo
Classes/Utility/GeneralUtility.php
GeneralUtility.getSysPageObj
protected static function getSysPageObj() { if (self::$sysPageObj === null) { /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */ $objectManager = Typo3GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Object\\ObjectManager' ); /** @var \TYPO3\CMS\Frontend\Page\PageRepository $sysPageObj */ $sysPageObj = $objectManager->get('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); self::$sysPageObj = $sysPageObj; } return self::$sysPageObj; }
php
protected static function getSysPageObj() { if (self::$sysPageObj === null) { /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */ $objectManager = Typo3GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Object\\ObjectManager' ); /** @var \TYPO3\CMS\Frontend\Page\PageRepository $sysPageObj */ $sysPageObj = $objectManager->get('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); self::$sysPageObj = $sysPageObj; } return self::$sysPageObj; }
[ "protected", "static", "function", "getSysPageObj", "(", ")", "{", "if", "(", "self", "::", "$", "sysPageObj", "===", "null", ")", "{", "/** @var \\TYPO3\\CMS\\Extbase\\Object\\ObjectManager $objectManager */", "$", "objectManager", "=", "Typo3GeneralUtility", "::", "ma...
Get sys page object @return \TYPO3\CMS\Frontend\Page\PageRepository
[ "Get", "sys", "page", "object" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/GeneralUtility.php#L188-L203
train
webdevops/TYPO3-metaseo
Classes/Utility/GeneralUtility.php
GeneralUtility.getRootPid
public static function getRootPid($uid = null) { static $cache = array(); $ret = null; if ($uid === null) { ################# # Current root PID ################# $rootline = self::getRootLine(); if (!empty($rootline[0])) { $ret = $rootline[0]['uid']; } } else { ################# # Other root PID ################# if (!isset($cache[$uid])) { $cache[$uid] = null; $rootline = self::getRootLine($uid); if (!empty($rootline[0])) { $cache[$uid] = $rootline[0]['uid']; } } $ret = $cache[$uid]; } return $ret; }
php
public static function getRootPid($uid = null) { static $cache = array(); $ret = null; if ($uid === null) { ################# # Current root PID ################# $rootline = self::getRootLine(); if (!empty($rootline[0])) { $ret = $rootline[0]['uid']; } } else { ################# # Other root PID ################# if (!isset($cache[$uid])) { $cache[$uid] = null; $rootline = self::getRootLine($uid); if (!empty($rootline[0])) { $cache[$uid] = $rootline[0]['uid']; } } $ret = $cache[$uid]; } return $ret; }
[ "public", "static", "function", "getRootPid", "(", "$", "uid", "=", "null", ")", "{", "static", "$", "cache", "=", "array", "(", ")", ";", "$", "ret", "=", "null", ";", "if", "(", "$", "uid", "===", "null", ")", "{", "#################", "# Current r...
Get current root pid @param integer|null $uid Page UID @return integer
[ "Get", "current", "root", "pid" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/GeneralUtility.php#L238-L268
train
webdevops/TYPO3-metaseo
Classes/Utility/GeneralUtility.php
GeneralUtility.getRootSettingValue
public static function getRootSettingValue($name, $defaultValue = null, $rootPid = null) { $setting = self::getRootSetting($rootPid); if (isset($setting[$name])) { $ret = $setting[$name]; } else { $ret = $defaultValue; } return $ret; }
php
public static function getRootSettingValue($name, $defaultValue = null, $rootPid = null) { $setting = self::getRootSetting($rootPid); if (isset($setting[$name])) { $ret = $setting[$name]; } else { $ret = $defaultValue; } return $ret; }
[ "public", "static", "function", "getRootSettingValue", "(", "$", "name", ",", "$", "defaultValue", "=", "null", ",", "$", "rootPid", "=", "null", ")", "{", "$", "setting", "=", "self", "::", "getRootSetting", "(", "$", "rootPid", ")", ";", "if", "(", "...
Get root setting value @param string $name Name of configuration @param mixed|NULL $defaultValue Default value @param integer|NULL $rootPid Root Page Id @return array
[ "Get", "root", "setting", "value" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/GeneralUtility.php#L279-L290
train
webdevops/TYPO3-metaseo
Classes/Utility/GeneralUtility.php
GeneralUtility.getRootSetting
public static function getRootSetting($rootPid = null) { static $ret = null; if ($ret !== null) { return $ret; } if ($rootPid === null) { $rootPid = self::getRootPid(); } $query = 'SELECT * FROM tx_metaseo_setting_root WHERE pid = ' . (int)$rootPid . ' AND deleted = 0 LIMIT 1'; $ret = DatabaseUtility::getRow($query); return $ret; }
php
public static function getRootSetting($rootPid = null) { static $ret = null; if ($ret !== null) { return $ret; } if ($rootPid === null) { $rootPid = self::getRootPid(); } $query = 'SELECT * FROM tx_metaseo_setting_root WHERE pid = ' . (int)$rootPid . ' AND deleted = 0 LIMIT 1'; $ret = DatabaseUtility::getRow($query); return $ret; }
[ "public", "static", "function", "getRootSetting", "(", "$", "rootPid", "=", "null", ")", "{", "static", "$", "ret", "=", "null", ";", "if", "(", "$", "ret", "!==", "null", ")", "{", "return", "$", "ret", ";", "}", "if", "(", "$", "rootPid", "===", ...
Get root setting row @param integer $rootPid Root Page Id @return array
[ "Get", "root", "setting", "row" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/GeneralUtility.php#L299-L319
train
webdevops/TYPO3-metaseo
Classes/Utility/GeneralUtility.php
GeneralUtility.getExtConf
public static function getExtConf($name, $default = null) { static $conf = null; $ret = $default; if ($conf === null) { // Load ext conf $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['metaseo']); if (!is_array($conf)) { $conf = array(); } } if (isset($conf[$name])) { $ret = $conf[$name]; } return $ret; }
php
public static function getExtConf($name, $default = null) { static $conf = null; $ret = $default; if ($conf === null) { // Load ext conf $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['metaseo']); if (!is_array($conf)) { $conf = array(); } } if (isset($conf[$name])) { $ret = $conf[$name]; } return $ret; }
[ "public", "static", "function", "getExtConf", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "static", "$", "conf", "=", "null", ";", "$", "ret", "=", "$", "default", ";", "if", "(", "$", "conf", "===", "null", ")", "{", "// Load ext...
Get extension configuration @param string $name Name of config @param boolean $default Default value @return mixed
[ "Get", "extension", "configuration" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/GeneralUtility.php#L329-L348
train
webdevops/TYPO3-metaseo
Classes/Utility/GeneralUtility.php
GeneralUtility.callHookAndSignal
public static function callHookAndSignal($class, $name, $obj, &$args = null) { static $hookConf = null; static $signalSlotDispatcher = null; // Fetch hooks config for metaseo, minimize array lookups if ($hookConf === null) { $hookConf = array(); if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['metaseo']['hooks']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['metaseo']['hooks']) ) { $hookConf = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['metaseo']['hooks']; } } // Call hooks if (!empty($hookConf[$name]) && is_array($hookConf[$name])) { foreach ($hookConf[$name] as $_funcRef) { if ($_funcRef) { Typo3GeneralUtility::callUserFunction($_funcRef, $args, $obj); } } } // Call signal if ($signalSlotDispatcher === null) { /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */ $objectManager = Typo3GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Object\\ObjectManager' ); /** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */ $signalSlotDispatcher = $objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); } list($args) = $signalSlotDispatcher->dispatch($class, $name, array($args, $obj)); }
php
public static function callHookAndSignal($class, $name, $obj, &$args = null) { static $hookConf = null; static $signalSlotDispatcher = null; // Fetch hooks config for metaseo, minimize array lookups if ($hookConf === null) { $hookConf = array(); if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['metaseo']['hooks']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['metaseo']['hooks']) ) { $hookConf = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['metaseo']['hooks']; } } // Call hooks if (!empty($hookConf[$name]) && is_array($hookConf[$name])) { foreach ($hookConf[$name] as $_funcRef) { if ($_funcRef) { Typo3GeneralUtility::callUserFunction($_funcRef, $args, $obj); } } } // Call signal if ($signalSlotDispatcher === null) { /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */ $objectManager = Typo3GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Object\\ObjectManager' ); /** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */ $signalSlotDispatcher = $objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); } list($args) = $signalSlotDispatcher->dispatch($class, $name, array($args, $obj)); }
[ "public", "static", "function", "callHookAndSignal", "(", "$", "class", ",", "$", "name", ",", "$", "obj", ",", "&", "$", "args", "=", "null", ")", "{", "static", "$", "hookConf", "=", "null", ";", "static", "$", "signalSlotDispatcher", "=", "null", ";...
Call hook and signal @param string $class Name of the class containing the signal @param string $name Name of hook @param mixed $obj Reference to be passed along (typically "$this" - being a reference to the calling object) (REFERENCE!) @param mixed|NULL $args Args
[ "Call", "hook", "and", "signal" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/GeneralUtility.php#L359-L394
train
webdevops/TYPO3-metaseo
Classes/Utility/GeneralUtility.php
GeneralUtility.fullUrl
public static function fullUrl($url, $domain = null) { if (!preg_match('/^https?:\/\//i', $url)) { // Fix for root page link if ($url === '/') { $url = ''; } // remove first / if (strpos($url, '/') === 0) { $url = substr($url, 1); } if ($domain !== null) { // specified domain $url = 'http://' . $domain . '/' . $url; } else { // domain from env $url = Typo3GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $url; } } // Fix url stuff $url = str_replace('?&', '?', $url); return $url; }
php
public static function fullUrl($url, $domain = null) { if (!preg_match('/^https?:\/\//i', $url)) { // Fix for root page link if ($url === '/') { $url = ''; } // remove first / if (strpos($url, '/') === 0) { $url = substr($url, 1); } if ($domain !== null) { // specified domain $url = 'http://' . $domain . '/' . $url; } else { // domain from env $url = Typo3GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $url; } } // Fix url stuff $url = str_replace('?&', '?', $url); return $url; }
[ "public", "static", "function", "fullUrl", "(", "$", "url", ",", "$", "domain", "=", "null", ")", "{", "if", "(", "!", "preg_match", "(", "'/^https?:\\/\\//i'", ",", "$", "url", ")", ")", "{", "// Fix for root page link", "if", "(", "$", "url", "===", ...
Generate full url Makes sure the url is absolute (http://....) @param string $url URL @param string $domain Domain @return string
[ "Generate", "full", "url" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/GeneralUtility.php#L407-L433
train
webdevops/TYPO3-metaseo
Classes/Utility/GeneralUtility.php
GeneralUtility.checkUrlForBlacklisting
public static function checkUrlForBlacklisting($url, array $blacklistConf) { // check for valid url if (empty($url)) { return true; } $blacklistConf = (array)$blacklistConf; foreach ($blacklistConf as $blacklistRegExp) { if (preg_match($blacklistRegExp, $url)) { return true; } } return false; }
php
public static function checkUrlForBlacklisting($url, array $blacklistConf) { // check for valid url if (empty($url)) { return true; } $blacklistConf = (array)$blacklistConf; foreach ($blacklistConf as $blacklistRegExp) { if (preg_match($blacklistRegExp, $url)) { return true; } } return false; }
[ "public", "static", "function", "checkUrlForBlacklisting", "(", "$", "url", ",", "array", "$", "blacklistConf", ")", "{", "// check for valid url", "if", "(", "empty", "(", "$", "url", ")", ")", "{", "return", "true", ";", "}", "$", "blacklistConf", "=", "...
Check if url is blacklisted @param string $url URL @param array $blacklistConf Blacklist configuration (list of regexp) @return bool
[ "Check", "if", "url", "is", "blacklisted" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/GeneralUtility.php#L447-L462
train
webdevops/TYPO3-metaseo
Classes/Page/RobotsTxtPage.php
RobotsTxtPage.main
public function main() { $ret = ''; $settings = GeneralUtility::getRootSetting(); // INIT $this->tsSetup = $GLOBALS['TSFE']->tmpl->setup; $this->cObj = $GLOBALS['TSFE']->cObj; $this->rootPid = GeneralUtility::getRootPid(); $this->tsSetupSeo = null; if (!empty($this->tsSetup['plugin.']['metaseo.']['robotsTxt.'])) { $this->tsSetupSeo = $this->tsSetup['plugin.']['metaseo.']['robotsTxt.']; } // check if sitemap is enabled in root if (!GeneralUtility::getRootSettingValue('is_robotstxt', true)) { return true; } $this->linkToStaticSitemap = GeneralUtility::getRootSettingValue('is_robotstxt_sitemap_static', false); // Language lock $this->sitemapLanguageLock = GeneralUtility::getRootSettingValue('is_sitemap_language_lock', false); $this->languageId = GeneralUtility::getLanguageId(); // ############################### // Fetch robots.txt content // ############################### $settings['robotstxt'] = trim($settings['robotstxt']); if (!empty($settings['robotstxt'])) { // Custom Robots.txt $ret .= $settings['robotstxt']; } elseif ($this->tsSetupSeo) { // Default robots.txt $ret .= $this->cObj->cObjGetSingle($this->tsSetupSeo['default'], $this->tsSetupSeo['default.']); } // ############################### // Fetch extra robots.txt content // ############################### // User additional if (!empty($settings['robotstxt_additional'])) { $ret .= "\n\n" . $settings['robotstxt_additional']; } // Setup additional if ($this->tsSetupSeo) { // Default robots.txt $tmp = $this->cObj->cObjGetSingle($this->tsSetupSeo['extra'], $this->tsSetupSeo['extra.']); if (!empty($tmp)) { $ret .= "\n\n" . $tmp; } } // ############################### // Marker // ############################### if (!empty($this->tsSetupSeo['marker.'])) { $ret = $this->applyMarker($ret); } // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'robotsTxtOutput', $this, $ret); return $ret; }
php
public function main() { $ret = ''; $settings = GeneralUtility::getRootSetting(); // INIT $this->tsSetup = $GLOBALS['TSFE']->tmpl->setup; $this->cObj = $GLOBALS['TSFE']->cObj; $this->rootPid = GeneralUtility::getRootPid(); $this->tsSetupSeo = null; if (!empty($this->tsSetup['plugin.']['metaseo.']['robotsTxt.'])) { $this->tsSetupSeo = $this->tsSetup['plugin.']['metaseo.']['robotsTxt.']; } // check if sitemap is enabled in root if (!GeneralUtility::getRootSettingValue('is_robotstxt', true)) { return true; } $this->linkToStaticSitemap = GeneralUtility::getRootSettingValue('is_robotstxt_sitemap_static', false); // Language lock $this->sitemapLanguageLock = GeneralUtility::getRootSettingValue('is_sitemap_language_lock', false); $this->languageId = GeneralUtility::getLanguageId(); // ############################### // Fetch robots.txt content // ############################### $settings['robotstxt'] = trim($settings['robotstxt']); if (!empty($settings['robotstxt'])) { // Custom Robots.txt $ret .= $settings['robotstxt']; } elseif ($this->tsSetupSeo) { // Default robots.txt $ret .= $this->cObj->cObjGetSingle($this->tsSetupSeo['default'], $this->tsSetupSeo['default.']); } // ############################### // Fetch extra robots.txt content // ############################### // User additional if (!empty($settings['robotstxt_additional'])) { $ret .= "\n\n" . $settings['robotstxt_additional']; } // Setup additional if ($this->tsSetupSeo) { // Default robots.txt $tmp = $this->cObj->cObjGetSingle($this->tsSetupSeo['extra'], $this->tsSetupSeo['extra.']); if (!empty($tmp)) { $ret .= "\n\n" . $tmp; } } // ############################### // Marker // ############################### if (!empty($this->tsSetupSeo['marker.'])) { $ret = $this->applyMarker($ret); } // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'robotsTxtOutput', $this, $ret); return $ret; }
[ "public", "function", "main", "(", ")", "{", "$", "ret", "=", "''", ";", "$", "settings", "=", "GeneralUtility", "::", "getRootSetting", "(", ")", ";", "// INIT", "$", "this", "->", "tsSetup", "=", "$", "GLOBALS", "[", "'TSFE'", "]", "->", "tmpl", "-...
Fetch and build robots.txt
[ "Fetch", "and", "build", "robots", ".", "txt" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/RobotsTxtPage.php#L90-L159
train
webdevops/TYPO3-metaseo
Classes/Page/RobotsTxtPage.php
RobotsTxtPage.applyMarker
protected function applyMarker($robotsTxt) { $ret = $robotsTxt; $markerList = array(); $markerConfList = array(); foreach ($this->tsSetupSeo['marker.'] as $name => $data) { if (strpos($name, '.') === false) { $markerConfList[$name] = null; } } if ($this->linkToStaticSitemap) { // remove sitemap-marker because we link to static url unset($markerConfList['sitemap']); } // Fetch marker content foreach ($markerConfList as $name => $conf) { $markerList['%' . $name . '%'] = $this->cObj->cObjGetSingle( $this->tsSetupSeo['marker.'][$name], $this->tsSetupSeo['marker.'][$name . '.'] ); } // generate sitemap-static marker if ($this->linkToStaticSitemap) { if ($this->sitemapLanguageLock) { $path = 'uploads/tx_metaseo/sitemap_xml/index-r' . (int)$this->rootPid . '-l' . (int)$this->languageId . '.xml.gz'; } else { $path = 'uploads/tx_metaseo/sitemap_xml/index-r' . (int)$this->rootPid . '.xml.gz'; } $conf = array( 'parameter' => $path ); $markerList['%sitemap%'] = $this->cObj->typoLink_URL($conf); } // Fix sitemap-marker url (add prefix if needed) $markerList['%sitemap%'] = GeneralUtility::fullUrl($markerList['%sitemap%']); // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'robotsTxtMarker', $this, $markerList); // Apply marker list if (!empty($markerList)) { $ret = strtr($ret, $markerList); } return $ret; }
php
protected function applyMarker($robotsTxt) { $ret = $robotsTxt; $markerList = array(); $markerConfList = array(); foreach ($this->tsSetupSeo['marker.'] as $name => $data) { if (strpos($name, '.') === false) { $markerConfList[$name] = null; } } if ($this->linkToStaticSitemap) { // remove sitemap-marker because we link to static url unset($markerConfList['sitemap']); } // Fetch marker content foreach ($markerConfList as $name => $conf) { $markerList['%' . $name . '%'] = $this->cObj->cObjGetSingle( $this->tsSetupSeo['marker.'][$name], $this->tsSetupSeo['marker.'][$name . '.'] ); } // generate sitemap-static marker if ($this->linkToStaticSitemap) { if ($this->sitemapLanguageLock) { $path = 'uploads/tx_metaseo/sitemap_xml/index-r' . (int)$this->rootPid . '-l' . (int)$this->languageId . '.xml.gz'; } else { $path = 'uploads/tx_metaseo/sitemap_xml/index-r' . (int)$this->rootPid . '.xml.gz'; } $conf = array( 'parameter' => $path ); $markerList['%sitemap%'] = $this->cObj->typoLink_URL($conf); } // Fix sitemap-marker url (add prefix if needed) $markerList['%sitemap%'] = GeneralUtility::fullUrl($markerList['%sitemap%']); // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'robotsTxtMarker', $this, $markerList); // Apply marker list if (!empty($markerList)) { $ret = strtr($ret, $markerList); } return $ret; }
[ "protected", "function", "applyMarker", "(", "$", "robotsTxt", ")", "{", "$", "ret", "=", "$", "robotsTxt", ";", "$", "markerList", "=", "array", "(", ")", ";", "$", "markerConfList", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "t...
Apply marker to robots.txt @param string $robotsTxt Content of robots.txt @return string
[ "Apply", "marker", "to", "robots", ".", "txt" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/RobotsTxtPage.php#L168-L222
train
webdevops/TYPO3-metaseo
Classes/Hook/SitemapIndexPageHook.php
SitemapIndexPageHook.addPageToSitemapIndex
public function addPageToSitemapIndex() { if (!$this->checkIfSitemapIndexingIsEnabled('page')) { return; } if (!$this->checkIfNoLanguageFallback()) { // got content in fallback language => don't index return; } $pageUrl = $this->getPageUrl(); // check blacklisting if (GeneralUtility::checkUrlForBlacklisting($pageUrl, $this->blacklistConf)) { return; } // Index page $pageData = $this->generateSitemapPageData($pageUrl); if (!empty($pageData)) { SitemapUtility::index($pageData); } }
php
public function addPageToSitemapIndex() { if (!$this->checkIfSitemapIndexingIsEnabled('page')) { return; } if (!$this->checkIfNoLanguageFallback()) { // got content in fallback language => don't index return; } $pageUrl = $this->getPageUrl(); // check blacklisting if (GeneralUtility::checkUrlForBlacklisting($pageUrl, $this->blacklistConf)) { return; } // Index page $pageData = $this->generateSitemapPageData($pageUrl); if (!empty($pageData)) { SitemapUtility::index($pageData); } }
[ "public", "function", "addPageToSitemapIndex", "(", ")", "{", "if", "(", "!", "$", "this", "->", "checkIfSitemapIndexingIsEnabled", "(", "'page'", ")", ")", "{", "return", ";", "}", "if", "(", "!", "$", "this", "->", "checkIfNoLanguageFallback", "(", ")", ...
Add Page to sitemap table @return void
[ "Add", "Page", "to", "sitemap", "table" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Hook/SitemapIndexPageHook.php#L88-L111
train
webdevops/TYPO3-metaseo
Classes/Hook/SitemapIndexPageHook.php
SitemapIndexPageHook.checkIfNoLanguageFallback
protected function checkIfNoLanguageFallback() { $tsfe = self::getTsfe(); // Check if we have fallen back to a default language if (GeneralUtility::getLanguageId() !== $tsfe->sys_language_uid) { return false; //don't index untranslated page } return true; }
php
protected function checkIfNoLanguageFallback() { $tsfe = self::getTsfe(); // Check if we have fallen back to a default language if (GeneralUtility::getLanguageId() !== $tsfe->sys_language_uid) { return false; //don't index untranslated page } return true; }
[ "protected", "function", "checkIfNoLanguageFallback", "(", ")", "{", "$", "tsfe", "=", "self", "::", "getTsfe", "(", ")", ";", "// Check if we have fallen back to a default language", "if", "(", "GeneralUtility", "::", "getLanguageId", "(", ")", "!==", "$", "tsfe", ...
Returns True if language chosen by L= parameter matches language of content Returns False if content is in fallback language @return bool
[ "Returns", "True", "if", "language", "chosen", "by", "L", "=", "parameter", "matches", "language", "of", "content", "Returns", "False", "if", "content", "is", "in", "fallback", "language" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Hook/SitemapIndexPageHook.php#L119-L127
train
webdevops/TYPO3-metaseo
Classes/Page/Part/PagetitlePart.php
PagetitlePart.checkIfPageTitleCachingEnabled
protected function checkIfPageTitleCachingEnabled() { $cachingEnabled = !empty($GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['pageTitle.']['caching']); // Ajax: disable pagetitle caching when in backend mode if (defined('TYPO3_MODE') && TYPO3_MODE == 'BE') { $cachingEnabled = false; } // Enable caching only if caching is enabled in SetupTS // And if there is any USER_INT on the current page // // -> USER_INT will break Connector pagetitle setting // because the plugin output is cached but not the whole // page. so the Connector will not be called again // and the default page title will be shown // which is wrong // -> if the page is fully cacheable we don't have anything // to do return $cachingEnabled && !FrontendUtility::isCacheable(); }
php
protected function checkIfPageTitleCachingEnabled() { $cachingEnabled = !empty($GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['pageTitle.']['caching']); // Ajax: disable pagetitle caching when in backend mode if (defined('TYPO3_MODE') && TYPO3_MODE == 'BE') { $cachingEnabled = false; } // Enable caching only if caching is enabled in SetupTS // And if there is any USER_INT on the current page // // -> USER_INT will break Connector pagetitle setting // because the plugin output is cached but not the whole // page. so the Connector will not be called again // and the default page title will be shown // which is wrong // -> if the page is fully cacheable we don't have anything // to do return $cachingEnabled && !FrontendUtility::isCacheable(); }
[ "protected", "function", "checkIfPageTitleCachingEnabled", "(", ")", "{", "$", "cachingEnabled", "=", "!", "empty", "(", "$", "GLOBALS", "[", "'TSFE'", "]", "->", "tmpl", "->", "setup", "[", "'plugin.'", "]", "[", "'metaseo.'", "]", "[", "'pageTitle.'", "]",...
Check if page title caching is enabled @return bool
[ "Check", "if", "page", "title", "caching", "is", "enabled" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/PagetitlePart.php#L162-L182
train
webdevops/TYPO3-metaseo
Classes/Controller/Ajax/PageSeo/AdvancedController.php
AdvancedController.clearMetaTags
protected function clearMetaTags($pid, $sysLanguage) { $query = 'DELETE FROM tx_metaseo_metatag WHERE pid = ' . (int)$pid . ' AND sys_language_uid = ' . (int)$sysLanguage; DatabaseUtility::exec($query); }
php
protected function clearMetaTags($pid, $sysLanguage) { $query = 'DELETE FROM tx_metaseo_metatag WHERE pid = ' . (int)$pid . ' AND sys_language_uid = ' . (int)$sysLanguage; DatabaseUtility::exec($query); }
[ "protected", "function", "clearMetaTags", "(", "$", "pid", ",", "$", "sysLanguage", ")", "{", "$", "query", "=", "'DELETE FROM tx_metaseo_metatag\n WHERE pid = '", ".", "(", "int", ")", "$", "pid", ".", "'\n AND sys_language...
Clear all meta tags for one page @param integer $pid PID @param integer|null $sysLanguage system language id
[ "Clear", "all", "meta", "tags", "for", "one", "page" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Controller/Ajax/PageSeo/AdvancedController.php#L133-L139
train
webdevops/TYPO3-metaseo
Classes/Utility/FrontendUtility.php
FrontendUtility.isCacheable
public static function isCacheable($conf = null) { $TSFE = self::getTsfe(); if ($_SERVER['REQUEST_METHOD'] !== 'GET' || !empty($TSFE->fe_user->user['uid'])) { return false; } // don't parse if page is not cacheable if (empty($conf['allowNoStaticCachable']) && !$TSFE->isStaticCacheble()) { return false; } // Skip no_cache-pages if (empty($conf['allowNoCache']) && !empty($TSFE->no_cache)) { return false; } return true; }
php
public static function isCacheable($conf = null) { $TSFE = self::getTsfe(); if ($_SERVER['REQUEST_METHOD'] !== 'GET' || !empty($TSFE->fe_user->user['uid'])) { return false; } // don't parse if page is not cacheable if (empty($conf['allowNoStaticCachable']) && !$TSFE->isStaticCacheble()) { return false; } // Skip no_cache-pages if (empty($conf['allowNoCache']) && !empty($TSFE->no_cache)) { return false; } return true; }
[ "public", "static", "function", "isCacheable", "(", "$", "conf", "=", "null", ")", "{", "$", "TSFE", "=", "self", "::", "getTsfe", "(", ")", ";", "if", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", "!==", "'GET'", "||", "!", "empty", "(", "$", ...
Check if frontend page is cacheable @param array|null $conf Configuration @return bool
[ "Check", "if", "frontend", "page", "is", "cacheable" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/FrontendUtility.php#L164-L183
train
webdevops/TYPO3-metaseo
Classes/Utility/FrontendUtility.php
FrontendUtility.getCurrentUrl
public static function getCurrentUrl() { //former $TSFE->anchorPrefix got deprecated in TYPO3 7.x $tsfeAnchorPrefix = Typo3GeneralUtility::getIndpEnv('TYPO3_SITE_SCRIPT'); if ($tsfeAnchorPrefix !== false && !empty($tsfeAnchorPrefix)) { return $tsfeAnchorPrefix; } else { return (string) self::getTsfe()->siteScript; } }
php
public static function getCurrentUrl() { //former $TSFE->anchorPrefix got deprecated in TYPO3 7.x $tsfeAnchorPrefix = Typo3GeneralUtility::getIndpEnv('TYPO3_SITE_SCRIPT'); if ($tsfeAnchorPrefix !== false && !empty($tsfeAnchorPrefix)) { return $tsfeAnchorPrefix; } else { return (string) self::getTsfe()->siteScript; } }
[ "public", "static", "function", "getCurrentUrl", "(", ")", "{", "//former $TSFE->anchorPrefix got deprecated in TYPO3 7.x", "$", "tsfeAnchorPrefix", "=", "Typo3GeneralUtility", "::", "getIndpEnv", "(", "'TYPO3_SITE_SCRIPT'", ")", ";", "if", "(", "$", "tsfeAnchorPrefix", "...
Return current URL @return string
[ "Return", "current", "URL" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/FrontendUtility.php#L190-L200
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/style.cls.php
Style.get_font_family
function get_font_family() { $DEBUGCSS=DEBUGCSS; //=DEBUGCSS; Allow override of global setting for ad hoc debug // Select the appropriate font. First determine the subtype, then check // the specified font-families for a candidate. // Resolve font-weight $weight = $this->__get("font_weight"); if ( is_numeric($weight) ) { if ( $weight < 600 ) $weight = "normal"; else $weight = "bold"; } else if ( $weight === "bold" || $weight === "bolder" ) { $weight = "bold"; } else { $weight = "normal"; } // Resolve font-style $font_style = $this->__get("font_style"); if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") ) $subtype = "bold_italic"; else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" ) $subtype = "bold"; else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") ) $subtype = "italic"; else $subtype = "normal"; // Resolve the font family if ($DEBUGCSS) { print "<pre>[get_font_family:"; print '('.$this->_props["font_family"].'.'.$font_style.'.'.$this->__get("font_weight").'.'.$weight.'.'.$subtype.')'; } $families = explode(",", $this->_props["font_family"]); $families = array_map('trim',$families); reset($families); $font = null; while ( current($families) ) { list(,$family) = each($families); //remove leading and trailing string delimiters, e.g. on font names with spaces; //remove leading and trailing whitespace $family = trim($family, " \t\n\r\x0B\"'"); if ($DEBUGCSS) print '('.$family.')'; $font = Font_Metrics::get_font($family, $subtype); if ( $font ) { if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; return $font; } } $family = null; if ($DEBUGCSS) print '(default)'; $font = Font_Metrics::get_font($family, $subtype); if ( $font ) { if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; return $font; } throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '" . $this->_props["font_family"] ."'"); }
php
function get_font_family() { $DEBUGCSS=DEBUGCSS; //=DEBUGCSS; Allow override of global setting for ad hoc debug // Select the appropriate font. First determine the subtype, then check // the specified font-families for a candidate. // Resolve font-weight $weight = $this->__get("font_weight"); if ( is_numeric($weight) ) { if ( $weight < 600 ) $weight = "normal"; else $weight = "bold"; } else if ( $weight === "bold" || $weight === "bolder" ) { $weight = "bold"; } else { $weight = "normal"; } // Resolve font-style $font_style = $this->__get("font_style"); if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") ) $subtype = "bold_italic"; else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" ) $subtype = "bold"; else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") ) $subtype = "italic"; else $subtype = "normal"; // Resolve the font family if ($DEBUGCSS) { print "<pre>[get_font_family:"; print '('.$this->_props["font_family"].'.'.$font_style.'.'.$this->__get("font_weight").'.'.$weight.'.'.$subtype.')'; } $families = explode(",", $this->_props["font_family"]); $families = array_map('trim',$families); reset($families); $font = null; while ( current($families) ) { list(,$family) = each($families); //remove leading and trailing string delimiters, e.g. on font names with spaces; //remove leading and trailing whitespace $family = trim($family, " \t\n\r\x0B\"'"); if ($DEBUGCSS) print '('.$family.')'; $font = Font_Metrics::get_font($family, $subtype); if ( $font ) { if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; return $font; } } $family = null; if ($DEBUGCSS) print '(default)'; $font = Font_Metrics::get_font($family, $subtype); if ( $font ) { if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; return $font; } throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '" . $this->_props["font_family"] ."'"); }
[ "function", "get_font_family", "(", ")", "{", "$", "DEBUGCSS", "=", "DEBUGCSS", ";", "//=DEBUGCSS; Allow override of global setting for ad hoc debug", "// Select the appropriate font. First determine the subtype, then check", "// the specified font-families for a candidate.", "// Resolve ...
Getter for the 'font-family' CSS property. Uses the {@link Font_Metrics} class to resolve the font family into an actual font file. @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-family @return string
[ "Getter", "for", "the", "font", "-", "family", "CSS", "property", "." ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/style.cls.php#L736-L807
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/style.cls.php
Style.get_border_properties
function get_border_properties() { return array("top" => array("width" => $this->__get("border_top_width"), "style" => $this->__get("border_top_style"), "color" => $this->__get("border_top_color")), "bottom" => array("width" => $this->__get("border_bottom_width"), "style" => $this->__get("border_bottom_style"), "color" => $this->__get("border_bottom_color")), "right" => array("width" => $this->__get("border_right_width"), "style" => $this->__get("border_right_style"), "color" => $this->__get("border_right_color")), "left" => array("width" => $this->__get("border_left_width"), "style" => $this->__get("border_left_style"), "color" => $this->__get("border_left_color"))); }
php
function get_border_properties() { return array("top" => array("width" => $this->__get("border_top_width"), "style" => $this->__get("border_top_style"), "color" => $this->__get("border_top_color")), "bottom" => array("width" => $this->__get("border_bottom_width"), "style" => $this->__get("border_bottom_style"), "color" => $this->__get("border_bottom_color")), "right" => array("width" => $this->__get("border_right_width"), "style" => $this->__get("border_right_style"), "color" => $this->__get("border_right_color")), "left" => array("width" => $this->__get("border_left_width"), "style" => $this->__get("border_left_style"), "color" => $this->__get("border_left_color"))); }
[ "function", "get_border_properties", "(", ")", "{", "return", "array", "(", "\"top\"", "=>", "array", "(", "\"width\"", "=>", "$", "this", "->", "__get", "(", "\"border_top_width\"", ")", ",", "\"style\"", "=>", "$", "this", "->", "__get", "(", "\"border_top...
Return an array of all border properties. The returned array has the following structure: <code> array("top" => array("width" => [border-width], "style" => [border-style], "color" => [border-color (array)]), "bottom" ... ) </code> @return array
[ "Return", "an", "array", "of", "all", "border", "properties", "." ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/style.cls.php#L1146-L1159
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/style.cls.php
Style.set_font
function set_font($val) { $this->__font_size_calculated = false; //see __set and __get, on all assignments clear cache, not needed on direct set through __set $this->_prop_cache["font"] = null; $this->_props["font"] = $val; $important = isset($this->_important_props["font"]); if ( preg_match("/^(italic|oblique|normal)\s*(.*)$/i",$val,$match) ) { $this->_set_style("font_style", $match[1], $important); $val = $match[2]; } else { $this->_set_style("font_style", self::$_defaults["font_style"], $important); } if ( preg_match("/^(small-caps|normal)\s*(.*)$/i",$val,$match) ) { $this->_set_style("font_variant", $match[1], $important); $val = $match[2]; } else { $this->_set_style("font_variant", self::$_defaults["font_variant"], $important); } //matching numeric value followed by unit -> this is indeed a subsequent font size. Skip! if ( preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i",$val,$match) && !preg_match("/^(?:pt|px|pc|em|ex|in|cm|mm|%)/",$match[2]) ) { $this->_set_style("font_weight", $match[1], $important); $val = $match[2]; } else { $this->_set_style("font_weight", self::$_defaults["font_weight"], $important); } if ( preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) { $this->_set_style("font_size", $match[1], $important); $val = $match[2]; if (preg_match("/^\/\s*(\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) { $this->_set_style("line_height", $match[1], $important); $val = $match[2]; } else { $this->_set_style("line_height", self::$_defaults["line_height"], $important); } } else { $this->_set_style("font_size", self::$_defaults["font_size"], $important); $this->_set_style("line_height", self::$_defaults["line_height"], $important); } if(strlen($val) != 0) { $this->_set_style("font_family", $val, $important); } else { $this->_set_style("font_family", self::$_defaults["font_family"], $important); } }
php
function set_font($val) { $this->__font_size_calculated = false; //see __set and __get, on all assignments clear cache, not needed on direct set through __set $this->_prop_cache["font"] = null; $this->_props["font"] = $val; $important = isset($this->_important_props["font"]); if ( preg_match("/^(italic|oblique|normal)\s*(.*)$/i",$val,$match) ) { $this->_set_style("font_style", $match[1], $important); $val = $match[2]; } else { $this->_set_style("font_style", self::$_defaults["font_style"], $important); } if ( preg_match("/^(small-caps|normal)\s*(.*)$/i",$val,$match) ) { $this->_set_style("font_variant", $match[1], $important); $val = $match[2]; } else { $this->_set_style("font_variant", self::$_defaults["font_variant"], $important); } //matching numeric value followed by unit -> this is indeed a subsequent font size. Skip! if ( preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i",$val,$match) && !preg_match("/^(?:pt|px|pc|em|ex|in|cm|mm|%)/",$match[2]) ) { $this->_set_style("font_weight", $match[1], $important); $val = $match[2]; } else { $this->_set_style("font_weight", self::$_defaults["font_weight"], $important); } if ( preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) { $this->_set_style("font_size", $match[1], $important); $val = $match[2]; if (preg_match("/^\/\s*(\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) { $this->_set_style("line_height", $match[1], $important); $val = $match[2]; } else { $this->_set_style("line_height", self::$_defaults["line_height"], $important); } } else { $this->_set_style("font_size", self::$_defaults["font_size"], $important); $this->_set_style("line_height", self::$_defaults["line_height"], $important); } if(strlen($val) != 0) { $this->_set_style("font_family", $val, $important); } else { $this->_set_style("font_family", self::$_defaults["font_family"], $important); } }
[ "function", "set_font", "(", "$", "val", ")", "{", "$", "this", "->", "__font_size_calculated", "=", "false", ";", "//see __set and __get, on all assignments clear cache, not needed on direct set through __set", "$", "this", "->", "_prop_cache", "[", "\"font\"", "]", "=",...
Sets the font style combined attributes set individual attributes also, respecting !important mark exactly this order, separate by space. Multiple fonts separated by comma: font-style, font-variant, font-weight, font-size, line-height, font-family Other than with border and list, existing partial attributes should reset when starting here, even when not mentioned. If individual attribute is !important and explicite or implicite replacement is not, keep individual attribute require whitespace as delimiters for single value attributes On delimiter "/" treat first as font height, second as line height treat all remaining at the end of line as font font-style, font-variant, font-weight, font-size, line-height, font-family missing font-size and font-family might be not allowed, but accept it here and use default (medium size, enpty font name) @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style @param $val
[ "Sets", "the", "font", "style" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/style.cls.php#L1569-L1620
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/style.cls.php
Style.set_transform_origin
function set_transform_origin($val) { $values = preg_split("/\s+/", $val); if ( count($values) === 0) { return; } foreach($values as &$value) { if ( in_array($value, array("top", "left")) ) { $value = 0; } if ( in_array($value, array("bottom", "right")) ) { $value = "100%"; } } if ( !isset($values[1]) ) { $values[1] = $values[0]; } //see __set and __get, on all assignments clear cache, not needed on direct set through __set $this->_prop_cache["transform_origin"] = null; $this->_props["transform_origin"] = $values; }
php
function set_transform_origin($val) { $values = preg_split("/\s+/", $val); if ( count($values) === 0) { return; } foreach($values as &$value) { if ( in_array($value, array("top", "left")) ) { $value = 0; } if ( in_array($value, array("bottom", "right")) ) { $value = "100%"; } } if ( !isset($values[1]) ) { $values[1] = $values[0]; } //see __set and __get, on all assignments clear cache, not needed on direct set through __set $this->_prop_cache["transform_origin"] = null; $this->_props["transform_origin"] = $values; }
[ "function", "set_transform_origin", "(", "$", "val", ")", "{", "$", "values", "=", "preg_split", "(", "\"/\\s+/\"", ",", "$", "val", ")", ";", "if", "(", "count", "(", "$", "values", ")", "===", "0", ")", "{", "return", ";", "}", "foreach", "(", "$...
Sets the CSS3 transform-origin property @link http://www.w3.org/TR/css3-2d-transforms/#transform-origin @param string $val
[ "Sets", "the", "CSS3", "transform", "-", "origin", "property" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/style.cls.php#L2095-L2119
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/renderer.cls.php
Renderer._check_callbacks
protected function _check_callbacks($event, $frame) { if (!isset($this->_callbacks)) { $this->_callbacks = $this->_dompdf->get_callbacks(); } if (is_array($this->_callbacks) && isset($this->_callbacks[$event])) { $info = array(0 => $this->_canvas, "canvas" => $this->_canvas, 1 => $frame, "frame" => $frame); $fs = $this->_callbacks[$event]; foreach ($fs as $f) { if (is_callable($f)) { if (is_array($f)) { $f[0]->$f[1]($info); } else { $f($info); } } } } }
php
protected function _check_callbacks($event, $frame) { if (!isset($this->_callbacks)) { $this->_callbacks = $this->_dompdf->get_callbacks(); } if (is_array($this->_callbacks) && isset($this->_callbacks[$event])) { $info = array(0 => $this->_canvas, "canvas" => $this->_canvas, 1 => $frame, "frame" => $frame); $fs = $this->_callbacks[$event]; foreach ($fs as $f) { if (is_callable($f)) { if (is_array($f)) { $f[0]->$f[1]($info); } else { $f($info); } } } } }
[ "protected", "function", "_check_callbacks", "(", "$", "event", ",", "$", "frame", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_callbacks", ")", ")", "{", "$", "this", "->", "_callbacks", "=", "$", "this", "->", "_dompdf", "->", "get_...
Check for callbacks that need to be performed when a given event gets triggered on a frame @param string $event the type of event @param Frame $frame the frame that event is triggered on
[ "Check", "for", "callbacks", "that", "need", "to", "be", "performed", "when", "a", "given", "event", "gets", "triggered", "on", "a", "frame" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/renderer.cls.php#L210-L229
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/frame.cls.php
Frame.get_containing_block
function get_containing_block($i = null) { if ( isset($i) ) { return $this->_containing_block[$i]; } return $this->_containing_block; }
php
function get_containing_block($i = null) { if ( isset($i) ) { return $this->_containing_block[$i]; } return $this->_containing_block; }
[ "function", "get_containing_block", "(", "$", "i", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "i", ")", ")", "{", "return", "$", "this", "->", "_containing_block", "[", "$", "i", "]", ";", "}", "return", "$", "this", "->", "_containing_bloc...
Containing block dimensions @param $i string The key of the wanted containing block's dimension (x, y, x, h) @return array|float
[ "Containing", "block", "dimensions" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/frame.cls.php#L388-L393
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/frame.cls.php
Frame.is_text_node
function is_text_node() { if ( isset($this->_is_cache["text_node"]) ) { return $this->_is_cache["text_node"]; } return $this->_is_cache["text_node"] = ($this->get_node()->nodeName === "#text"); }
php
function is_text_node() { if ( isset($this->_is_cache["text_node"]) ) { return $this->_is_cache["text_node"]; } return $this->_is_cache["text_node"] = ($this->get_node()->nodeName === "#text"); }
[ "function", "is_text_node", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_is_cache", "[", "\"text_node\"", "]", ")", ")", "{", "return", "$", "this", "->", "_is_cache", "[", "\"text_node\"", "]", ";", "}", "return", "$", "this", "->", ...
Tells if the frame is a text node @return bool
[ "Tells", "if", "the", "frame", "is", "a", "text", "node" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/frame.cls.php#L624-L630
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/frame.cls.php
Frame.append_child
function append_child(Frame $child, $update_node = true) { if ( $update_node ) $this->_node->appendChild($child->_node); // Remove the child from its parent if ( $child->_parent ) $child->_parent->remove_child($child, false); $child->_parent = $this; $child->_next_sibling = null; // Handle the first child if ( !$this->_last_child ) { $this->_first_child = $child; $this->_last_child = $child; $child->_prev_sibling = null; } else { $this->_last_child->_next_sibling = $child; $child->_prev_sibling = $this->_last_child; $this->_last_child = $child; } }
php
function append_child(Frame $child, $update_node = true) { if ( $update_node ) $this->_node->appendChild($child->_node); // Remove the child from its parent if ( $child->_parent ) $child->_parent->remove_child($child, false); $child->_parent = $this; $child->_next_sibling = null; // Handle the first child if ( !$this->_last_child ) { $this->_first_child = $child; $this->_last_child = $child; $child->_prev_sibling = null; } else { $this->_last_child->_next_sibling = $child; $child->_prev_sibling = $this->_last_child; $this->_last_child = $child; } }
[ "function", "append_child", "(", "Frame", "$", "child", ",", "$", "update_node", "=", "true", ")", "{", "if", "(", "$", "update_node", ")", "$", "this", "->", "_node", "->", "appendChild", "(", "$", "child", "->", "_node", ")", ";", "// Remove the child ...
Inserts a new child at the end of the Frame @param $child Frame The new Frame to insert @param $update_node boolean Whether or not to update the DOM
[ "Inserts", "a", "new", "child", "at", "the", "end", "of", "the", "Frame" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/frame.cls.php#L724-L745
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/frame.cls.php
Frame.insert_child_before
function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { if ( $ref === $this->_first_child ) { $this->prepend_child($new_child, $update_node); return; } if ( is_null($ref) ) { $this->append_child($new_child, $update_node); return; } if ( $ref->_parent !== $this ) throw new DOMPDF_Exception("Reference child is not a child of this node."); // Update the node if ( $update_node ) $this->_node->insertBefore($new_child->_node, $ref->_node); // Remove the child from its parent if ( $new_child->_parent ) $new_child->_parent->remove_child($new_child, false); $new_child->_parent = $this; $new_child->_next_sibling = $ref; $new_child->_prev_sibling = $ref->_prev_sibling; if ( $ref->_prev_sibling ) $ref->_prev_sibling->_next_sibling = $new_child; $ref->_prev_sibling = $new_child; }
php
function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { if ( $ref === $this->_first_child ) { $this->prepend_child($new_child, $update_node); return; } if ( is_null($ref) ) { $this->append_child($new_child, $update_node); return; } if ( $ref->_parent !== $this ) throw new DOMPDF_Exception("Reference child is not a child of this node."); // Update the node if ( $update_node ) $this->_node->insertBefore($new_child->_node, $ref->_node); // Remove the child from its parent if ( $new_child->_parent ) $new_child->_parent->remove_child($new_child, false); $new_child->_parent = $this; $new_child->_next_sibling = $ref; $new_child->_prev_sibling = $ref->_prev_sibling; if ( $ref->_prev_sibling ) $ref->_prev_sibling->_next_sibling = $new_child; $ref->_prev_sibling = $new_child; }
[ "function", "insert_child_before", "(", "Frame", "$", "new_child", ",", "Frame", "$", "ref", ",", "$", "update_node", "=", "true", ")", "{", "if", "(", "$", "ref", "===", "$", "this", "->", "_first_child", ")", "{", "$", "this", "->", "prepend_child", ...
Inserts a new child immediately before the specified frame @param $new_child Frame The new Frame to insert @param $ref Frame The Frame after the new Frame @param $update_node boolean Whether or not to update the DOM
[ "Inserts", "a", "new", "child", "immediately", "before", "the", "specified", "frame" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/frame.cls.php#L754-L784
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/frame.cls.php
Frame.insert_child_after
function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { if ( $ref === $this->_last_child ) { $this->append_child($new_child, $update_node); return; } if ( is_null($ref) ) { $this->prepend_child($new_child, $update_node); return; } if ( $ref->_parent !== $this ) throw new DOMPDF_Exception("Reference child is not a child of this node."); // Update the node if ( $update_node ) { if ( $ref->_next_sibling ) { $next_node = $ref->_next_sibling->_node; $this->_node->insertBefore($new_child->_node, $next_node); } else { $new_child->_node = $this->_node->appendChild($new_child); } } // Remove the child from its parent if ( $new_child->_parent) $new_child->_parent->remove_child($new_child, false); $new_child->_parent = $this; $new_child->_prev_sibling = $ref; $new_child->_next_sibling = $ref->_next_sibling; if ( $ref->_next_sibling ) $ref->_next_sibling->_prev_sibling = $new_child; $ref->_next_sibling = $new_child; }
php
function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { if ( $ref === $this->_last_child ) { $this->append_child($new_child, $update_node); return; } if ( is_null($ref) ) { $this->prepend_child($new_child, $update_node); return; } if ( $ref->_parent !== $this ) throw new DOMPDF_Exception("Reference child is not a child of this node."); // Update the node if ( $update_node ) { if ( $ref->_next_sibling ) { $next_node = $ref->_next_sibling->_node; $this->_node->insertBefore($new_child->_node, $next_node); } else { $new_child->_node = $this->_node->appendChild($new_child); } } // Remove the child from its parent if ( $new_child->_parent) $new_child->_parent->remove_child($new_child, false); $new_child->_parent = $this; $new_child->_prev_sibling = $ref; $new_child->_next_sibling = $ref->_next_sibling; if ( $ref->_next_sibling ) $ref->_next_sibling->_prev_sibling = $new_child; $ref->_next_sibling = $new_child; }
[ "function", "insert_child_after", "(", "Frame", "$", "new_child", ",", "Frame", "$", "ref", ",", "$", "update_node", "=", "true", ")", "{", "if", "(", "$", "ref", "===", "$", "this", "->", "_last_child", ")", "{", "$", "this", "->", "append_child", "("...
Inserts a new child immediately after the specified frame @param $new_child Frame The new Frame to insert @param $ref Frame The Frame before the new Frame @param $update_node boolean Whether or not to update the DOM
[ "Inserts", "a", "new", "child", "immediately", "after", "the", "specified", "frame" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/frame.cls.php#L793-L829
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/frame.cls.php
Frame.remove_child
function remove_child(Frame $child, $update_node = true) { if ( $child->_parent !== $this ) throw new DOMPDF_Exception("Child not found in this frame"); if ( $update_node ) $this->_node->removeChild($child->_node); if ( $child === $this->_first_child ) $this->_first_child = $child->_next_sibling; if ( $child === $this->_last_child ) $this->_last_child = $child->_prev_sibling; if ( $child->_prev_sibling ) $child->_prev_sibling->_next_sibling = $child->_next_sibling; if ( $child->_next_sibling ) $child->_next_sibling->_prev_sibling = $child->_prev_sibling; $child->_next_sibling = null; $child->_prev_sibling = null; $child->_parent = null; return $child; }
php
function remove_child(Frame $child, $update_node = true) { if ( $child->_parent !== $this ) throw new DOMPDF_Exception("Child not found in this frame"); if ( $update_node ) $this->_node->removeChild($child->_node); if ( $child === $this->_first_child ) $this->_first_child = $child->_next_sibling; if ( $child === $this->_last_child ) $this->_last_child = $child->_prev_sibling; if ( $child->_prev_sibling ) $child->_prev_sibling->_next_sibling = $child->_next_sibling; if ( $child->_next_sibling ) $child->_next_sibling->_prev_sibling = $child->_prev_sibling; $child->_next_sibling = null; $child->_prev_sibling = null; $child->_parent = null; return $child; }
[ "function", "remove_child", "(", "Frame", "$", "child", ",", "$", "update_node", "=", "true", ")", "{", "if", "(", "$", "child", "->", "_parent", "!==", "$", "this", ")", "throw", "new", "DOMPDF_Exception", "(", "\"Child not found in this frame\"", ")", ";",...
Remove a child frame @param $child Frame @param $update_node boolean Whether or not to remove the DOM node @return Frame The removed child frame
[ "Remove", "a", "child", "frame" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/frame.cls.php#L839-L862
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/cellmap.cls.php
Cellmap.set_frame_heights
function set_frame_heights($table_height, $content_height) { // Distribute the increased height proportionally amongst each row foreach ( $this->_frames as $arr ) { $frame = $arr["frame"]; $h = 0; foreach ($arr["rows"] as $row ) { if ( !isset($this->_rows[$row]) ) continue; $h += $this->_rows[$row]["height"]; } if ( $content_height > 0 ) $new_height = ($h / $content_height) * $table_height; else $new_height = 0; if ( $frame instanceof Table_Cell_Frame_Decorator ) $frame->set_cell_height($new_height); else $frame->get_style()->height = $new_height; } }
php
function set_frame_heights($table_height, $content_height) { // Distribute the increased height proportionally amongst each row foreach ( $this->_frames as $arr ) { $frame = $arr["frame"]; $h = 0; foreach ($arr["rows"] as $row ) { if ( !isset($this->_rows[$row]) ) continue; $h += $this->_rows[$row]["height"]; } if ( $content_height > 0 ) $new_height = ($h / $content_height) * $table_height; else $new_height = 0; if ( $frame instanceof Table_Cell_Frame_Decorator ) $frame->set_cell_height($new_height); else $frame->get_style()->height = $new_height; } }
[ "function", "set_frame_heights", "(", "$", "table_height", ",", "$", "content_height", ")", "{", "// Distribute the increased height proportionally amongst each row", "foreach", "(", "$", "this", "->", "_frames", "as", "$", "arr", ")", "{", "$", "frame", "=", "$", ...
Re-adjust frame height if the table height is larger than its content
[ "Re", "-", "adjust", "frame", "height", "if", "the", "table", "height", "is", "larger", "than", "its", "content" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/cellmap.cls.php#L677-L703
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/table_row_frame_decorator.cls.php
Table_Row_Frame_Decorator.normalise
function normalise() { // Find our table parent $p = Table_Frame_Decorator::find_parent_table($this); $erroneous_frames = array(); foreach ($this->get_children() as $child) { $display = $child->get_style()->display; if ( $display !== "table-cell" ) $erroneous_frames[] = $child; } // dump the extra nodes after the table. foreach ($erroneous_frames as $frame) $p->move_after($frame); }
php
function normalise() { // Find our table parent $p = Table_Frame_Decorator::find_parent_table($this); $erroneous_frames = array(); foreach ($this->get_children() as $child) { $display = $child->get_style()->display; if ( $display !== "table-cell" ) $erroneous_frames[] = $child; } // dump the extra nodes after the table. foreach ($erroneous_frames as $frame) $p->move_after($frame); }
[ "function", "normalise", "(", ")", "{", "// Find our table parent", "$", "p", "=", "Table_Frame_Decorator", "::", "find_parent_table", "(", "$", "this", ")", ";", "$", "erroneous_frames", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "get_c...
Remove all non table-cell frames from this row and move them after the table.
[ "Remove", "all", "non", "table", "-", "cell", "frames", "from", "this", "row", "and", "move", "them", "after", "the", "table", "." ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/table_row_frame_decorator.cls.php#L30-L46
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/lib/html5lib/TreeBuilder.php
HTML5_TreeBuilder.strConst
private function strConst($number) { static $lookup; if (!$lookup) { $lookup = array(); $r = new ReflectionClass('HTML5_TreeBuilder'); $consts = $r->getConstants(); foreach ($consts as $const => $num) { if (!is_int($num)) continue; $lookup[$num] = $const; } } return $lookup[$number]; }
php
private function strConst($number) { static $lookup; if (!$lookup) { $lookup = array(); $r = new ReflectionClass('HTML5_TreeBuilder'); $consts = $r->getConstants(); foreach ($consts as $const => $num) { if (!is_int($num)) continue; $lookup[$num] = $const; } } return $lookup[$number]; }
[ "private", "function", "strConst", "(", "$", "number", ")", "{", "static", "$", "lookup", ";", "if", "(", "!", "$", "lookup", ")", "{", "$", "lookup", "=", "array", "(", ")", ";", "$", "r", "=", "new", "ReflectionClass", "(", "'HTML5_TreeBuilder'", "...
Converts a magic number to a readable name. Use for debugging.
[ "Converts", "a", "magic", "number", "to", "a", "readable", "name", ".", "Use", "for", "debugging", "." ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/lib/html5lib/TreeBuilder.php#L107-L119
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/lib/html5lib/Tokenizer.php
HTML5_Tokenizer.emitToken
protected function emitToken($token, $checkStream = true, $dry = false) { if ($checkStream) { // Emit errors from input stream. while ($this->stream->errors) { $this->emitToken(array_shift($this->stream->errors), false); } } if($token['type'] === self::ENDTAG && !empty($token['attr'])) { for ($i = 0; $i < count($token['attr']); $i++) { $this->emitToken(array( 'type' => self::PARSEERROR, 'data' => 'attributes-in-end-tag' )); } } if($token['type'] === self::ENDTAG && !empty($token['self-closing'])) { $this->emitToken(array( 'type' => self::PARSEERROR, 'data' => 'self-closing-flag-on-end-tag', )); } if($token['type'] === self::STARTTAG) { // This could be changed to actually pass the tree-builder a hash $hash = array(); foreach ($token['attr'] as $keypair) { if (isset($hash[$keypair['name']])) { $this->emitToken(array( 'type' => self::PARSEERROR, 'data' => 'duplicate-attribute', )); } else { $hash[$keypair['name']] = $keypair['value']; } } } if(!$dry) { // the current structure of attributes is not a terribly good one $this->tree->emitToken($token); } if(!$dry && is_int($this->tree->content_model)) { $this->content_model = $this->tree->content_model; $this->tree->content_model = null; } elseif($token['type'] === self::ENDTAG) { $this->content_model = self::PCDATA; } }
php
protected function emitToken($token, $checkStream = true, $dry = false) { if ($checkStream) { // Emit errors from input stream. while ($this->stream->errors) { $this->emitToken(array_shift($this->stream->errors), false); } } if($token['type'] === self::ENDTAG && !empty($token['attr'])) { for ($i = 0; $i < count($token['attr']); $i++) { $this->emitToken(array( 'type' => self::PARSEERROR, 'data' => 'attributes-in-end-tag' )); } } if($token['type'] === self::ENDTAG && !empty($token['self-closing'])) { $this->emitToken(array( 'type' => self::PARSEERROR, 'data' => 'self-closing-flag-on-end-tag', )); } if($token['type'] === self::STARTTAG) { // This could be changed to actually pass the tree-builder a hash $hash = array(); foreach ($token['attr'] as $keypair) { if (isset($hash[$keypair['name']])) { $this->emitToken(array( 'type' => self::PARSEERROR, 'data' => 'duplicate-attribute', )); } else { $hash[$keypair['name']] = $keypair['value']; } } } if(!$dry) { // the current structure of attributes is not a terribly good one $this->tree->emitToken($token); } if(!$dry && is_int($this->tree->content_model)) { $this->content_model = $this->tree->content_model; $this->tree->content_model = null; } elseif($token['type'] === self::ENDTAG) { $this->content_model = self::PCDATA; } }
[ "protected", "function", "emitToken", "(", "$", "token", ",", "$", "checkStream", "=", "true", ",", "$", "dry", "=", "false", ")", "{", "if", "(", "$", "checkStream", ")", "{", "// Emit errors from input stream.", "while", "(", "$", "this", "->", "stream",...
Emits a token, passing it on to the tree builder.
[ "Emits", "a", "token", "passing", "it", "on", "to", "the", "tree", "builder", "." ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/lib/html5lib/Tokenizer.php#L2379-L2427
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/lib/html5lib/Data.php
HTML5_Data.utf8chr
public static function utf8chr($code) { /* We don't care: we live dangerously * if($code > 0x10FFFF or $code < 0x0 or ($code >= 0xD800 and $code <= 0xDFFF) ) { // bits are set outside the "valid" range as defined // by UNICODE 4.1.0 return "\xEF\xBF\xBD"; }*/ $x = $y = $z = $w = 0; if ($code < 0x80) { // regular ASCII character $x = $code; } else { // set up bits for UTF-8 $x = ($code & 0x3F) | 0x80; if ($code < 0x800) { $y = (($code & 0x7FF) >> 6) | 0xC0; } else { $y = (($code & 0xFC0) >> 6) | 0x80; if($code < 0x10000) { $z = (($code >> 12) & 0x0F) | 0xE0; } else { $z = (($code >> 12) & 0x3F) | 0x80; $w = (($code >> 18) & 0x07) | 0xF0; } } } // set up the actual character $ret = ''; if($w) $ret .= chr($w); if($z) $ret .= chr($z); if($y) $ret .= chr($y); $ret .= chr($x); return $ret; }
php
public static function utf8chr($code) { /* We don't care: we live dangerously * if($code > 0x10FFFF or $code < 0x0 or ($code >= 0xD800 and $code <= 0xDFFF) ) { // bits are set outside the "valid" range as defined // by UNICODE 4.1.0 return "\xEF\xBF\xBD"; }*/ $x = $y = $z = $w = 0; if ($code < 0x80) { // regular ASCII character $x = $code; } else { // set up bits for UTF-8 $x = ($code & 0x3F) | 0x80; if ($code < 0x800) { $y = (($code & 0x7FF) >> 6) | 0xC0; } else { $y = (($code & 0xFC0) >> 6) | 0x80; if($code < 0x10000) { $z = (($code >> 12) & 0x0F) | 0xE0; } else { $z = (($code >> 12) & 0x3F) | 0x80; $w = (($code >> 18) & 0x07) | 0xF0; } } } // set up the actual character $ret = ''; if($w) $ret .= chr($w); if($z) $ret .= chr($z); if($y) $ret .= chr($y); $ret .= chr($x); return $ret; }
[ "public", "static", "function", "utf8chr", "(", "$", "code", ")", "{", "/* We don't care: we live dangerously\n * if($code > 0x10FFFF or $code < 0x0 or\n ($code >= 0xD800 and $code <= 0xDFFF) ) {\n // bits are set outside the \"valid\" range as defined\n // b...
Converts a Unicode codepoint to sequence of UTF-8 bytes. @note Shamelessly stolen from HTML Purifier, which is also shamelessly stolen from Feyd (which is in public domain).
[ "Converts", "a", "Unicode", "codepoint", "to", "sequence", "of", "UTF", "-", "8", "bytes", "." ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/lib/html5lib/Data.php#L76-L112
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/list_bullet_frame_decorator.cls.php
List_Bullet_Frame_Decorator.get_margin_height
function get_margin_height() { $style = $this->_frame->get_style(); if ( $style->list_style_type === "none" ) { return 0; } return $style->get_font_size() * self::BULLET_SIZE + 2 * self::BULLET_PADDING; }
php
function get_margin_height() { $style = $this->_frame->get_style(); if ( $style->list_style_type === "none" ) { return 0; } return $style->get_font_size() * self::BULLET_SIZE + 2 * self::BULLET_PADDING; }
[ "function", "get_margin_height", "(", ")", "{", "$", "style", "=", "$", "this", "->", "_frame", "->", "get_style", "(", ")", ";", "if", "(", "$", "style", "->", "list_style_type", "===", "\"none\"", ")", "{", "return", "0", ";", "}", "return", "$", "...
hits only on "inset" lists items, to increase height of box
[ "hits", "only", "on", "inset", "lists", "items", "to", "increase", "height", "of", "box" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/list_bullet_frame_decorator.cls.php#L47-L55
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/pdflib_adapter.cls.php
PDFLib_Adapter.close_object
function close_object() { $this->_pdf->restore(); $this->_pdf->end_template(); $this->_pdf->resume_page("pagenumber=".$this->_page_number); }
php
function close_object() { $this->_pdf->restore(); $this->_pdf->end_template(); $this->_pdf->resume_page("pagenumber=".$this->_page_number); }
[ "function", "close_object", "(", ")", "{", "$", "this", "->", "_pdf", "->", "restore", "(", ")", ";", "$", "this", "->", "_pdf", "->", "end_template", "(", ")", ";", "$", "this", "->", "_pdf", "->", "resume_page", "(", "\"pagenumber=\"", ".", "$", "t...
Close the current template @see PDFLib_Adapter::open_object()
[ "Close", "the", "current", "template" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/pdflib_adapter.cls.php#L297-L301
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/pdflib_adapter.cls.php
PDFLib_Adapter.add_object
function add_object($object, $where = 'all') { if ( mb_strpos($where, "next") !== false ) { $this->_objs[$object]["start_page"]++; $where = str_replace("next", "", $where); if ( $where == "" ) $where = "add"; } $this->_objs[$object]["where"] = $where; }
php
function add_object($object, $where = 'all') { if ( mb_strpos($where, "next") !== false ) { $this->_objs[$object]["start_page"]++; $where = str_replace("next", "", $where); if ( $where == "" ) $where = "add"; } $this->_objs[$object]["where"] = $where; }
[ "function", "add_object", "(", "$", "object", ",", "$", "where", "=", "'all'", ")", "{", "if", "(", "mb_strpos", "(", "$", "where", ",", "\"next\"", ")", "!==", "false", ")", "{", "$", "this", "->", "_objs", "[", "$", "object", "]", "[", "\"start_p...
Adds the specified object to the document $where can be one of: - 'add' add to current page only - 'all' add to every page from the current one onwards - 'odd' add to all odd numbered pages from now on - 'even' add to all even numbered pages from now on - 'next' add the object to the next page only - 'nextodd' add to all odd numbered pages from the next one - 'nexteven' add to all even numbered pages from the next one @param int $object the object handle returned by open_object() @param string $where
[ "Adds", "the", "specified", "object", "to", "the", "document" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/pdflib_adapter.cls.php#L318-L328
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/pdflib_adapter.cls.php
PDFLib_Adapter.stop_object
function stop_object($object) { if ( !isset($this->_objs[$object]) ) return; $start = $this->_objs[$object]["start_page"]; $where = $this->_objs[$object]["where"]; // Place the object on this page if required if ( $this->_page_number >= $start && (($this->_page_number % 2 == 0 && $where === "even") || ($this->_page_number % 2 == 1 && $where === "odd") || ($where === "all")) ) $this->_pdf->fit_image($object,0,0,""); $this->_objs[$object] = null; unset($this->_objs[$object]); }
php
function stop_object($object) { if ( !isset($this->_objs[$object]) ) return; $start = $this->_objs[$object]["start_page"]; $where = $this->_objs[$object]["where"]; // Place the object on this page if required if ( $this->_page_number >= $start && (($this->_page_number % 2 == 0 && $where === "even") || ($this->_page_number % 2 == 1 && $where === "odd") || ($where === "all")) ) $this->_pdf->fit_image($object,0,0,""); $this->_objs[$object] = null; unset($this->_objs[$object]); }
[ "function", "stop_object", "(", "$", "object", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_objs", "[", "$", "object", "]", ")", ")", "return", ";", "$", "start", "=", "$", "this", "->", "_objs", "[", "$", "object", "]", "[", "\...
Stops the specified template from appearing in the document. The object will stop being displayed on the page following the current one. @param int $object
[ "Stops", "the", "specified", "template", "from", "appearing", "in", "the", "document", "." ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/pdflib_adapter.cls.php#L338-L355
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/pdflib_adapter.cls.php
PDFLib_Adapter._set_stroke_color
protected function _set_stroke_color($color) { if($this->_last_stroke_color == $color) return; $this->_last_stroke_color = $color; if (isset($color[3])) { $type = "cmyk"; list($c1, $c2, $c3, $c4) = array($color[0], $color[1], $color[2], $color[3]); } elseif (isset($color[2])) { $type = "rgb"; list($c1, $c2, $c3, $c4) = array($color[0], $color[1], $color[2], null); } else { $type = "gray"; list($c1, $c2, $c3, $c4) = array($color[0], $color[1], null, null); } $this->_pdf->setcolor("stroke", $type, $c1, $c2, $c3, $c4); }
php
protected function _set_stroke_color($color) { if($this->_last_stroke_color == $color) return; $this->_last_stroke_color = $color; if (isset($color[3])) { $type = "cmyk"; list($c1, $c2, $c3, $c4) = array($color[0], $color[1], $color[2], $color[3]); } elseif (isset($color[2])) { $type = "rgb"; list($c1, $c2, $c3, $c4) = array($color[0], $color[1], $color[2], null); } else { $type = "gray"; list($c1, $c2, $c3, $c4) = array($color[0], $color[1], null, null); } $this->_pdf->setcolor("stroke", $type, $c1, $c2, $c3, $c4); }
[ "protected", "function", "_set_stroke_color", "(", "$", "color", ")", "{", "if", "(", "$", "this", "->", "_last_stroke_color", "==", "$", "color", ")", "return", ";", "$", "this", "->", "_last_stroke_color", "=", "$", "color", ";", "if", "(", "isset", "(...
Sets the line color @param array $color array(r,g,b)
[ "Sets", "the", "line", "color" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/pdflib_adapter.cls.php#L451-L471
train
thujohn/pdf-l4
src/Thujohn/Pdf/dompdf/include/pdflib_adapter.cls.php
PDFLib_Adapter._set_fill_color
protected function _set_fill_color($color) { if($this->_last_fill_color == $color) return; $this->_last_fill_color = $color; if (isset($color[3])) { $type = "cmyk"; list($c1, $c2, $c3, $c4) = array($color[0], $color[1], $color[2], $color[3]); } elseif (isset($color[2])) { $type = "rgb"; list($c1, $c2, $c3, $c4) = array($color[0], $color[1], $color[2], null); } else { $type = "gray"; list($c1, $c2, $c3, $c4) = array($color[0], $color[1], null, null); } $this->_pdf->setcolor("fill", $type, $c1, $c2, $c3, $c4); }
php
protected function _set_fill_color($color) { if($this->_last_fill_color == $color) return; $this->_last_fill_color = $color; if (isset($color[3])) { $type = "cmyk"; list($c1, $c2, $c3, $c4) = array($color[0], $color[1], $color[2], $color[3]); } elseif (isset($color[2])) { $type = "rgb"; list($c1, $c2, $c3, $c4) = array($color[0], $color[1], $color[2], null); } else { $type = "gray"; list($c1, $c2, $c3, $c4) = array($color[0], $color[1], null, null); } $this->_pdf->setcolor("fill", $type, $c1, $c2, $c3, $c4); }
[ "protected", "function", "_set_fill_color", "(", "$", "color", ")", "{", "if", "(", "$", "this", "->", "_last_fill_color", "==", "$", "color", ")", "return", ";", "$", "this", "->", "_last_fill_color", "=", "$", "color", ";", "if", "(", "isset", "(", "...
Sets the fill color @param array $color array(r,g,b)
[ "Sets", "the", "fill", "color" ]
e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9
https://github.com/thujohn/pdf-l4/blob/e42bc4aff4512b742c8b7e9a2eb493b92ed9c5e9/src/Thujohn/Pdf/dompdf/include/pdflib_adapter.cls.php#L478-L498
train
claroline/Distribution
main/core/Manager/AuthenticationManager.php
AuthenticationManager.getService
public function getService($driver) { $parts = $driver = explode(':', $driver); $driver = explode('.', $parts[0]); if (isset($driver[1])) { $serviceName = $driver[0].'.'.$driver[1].'_bundle.manager.'.$driver[1].'_manager'; if ($this->container->has($serviceName)) { return $this->container->get($serviceName); } } }
php
public function getService($driver) { $parts = $driver = explode(':', $driver); $driver = explode('.', $parts[0]); if (isset($driver[1])) { $serviceName = $driver[0].'.'.$driver[1].'_bundle.manager.'.$driver[1].'_manager'; if ($this->container->has($serviceName)) { return $this->container->get($serviceName); } } }
[ "public", "function", "getService", "(", "$", "driver", ")", "{", "$", "parts", "=", "$", "driver", "=", "explode", "(", "':'", ",", "$", "driver", ")", ";", "$", "driver", "=", "explode", "(", "'.'", ",", "$", "parts", "[", "0", "]", ")", ";", ...
Return authentication driver manager. @param $driver The name of the driver including the server, example: claroline.ldap:server1
[ "Return", "authentication", "driver", "manager", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/AuthenticationManager.php#L91-L102
train
claroline/Distribution
main/core/Twig/SerializerExtension.php
SerializerExtension.apiSerialize
public function apiSerialize($object, $options = []) { if (!empty($object)) { return $this->serializerProvider->serialize($object, $options); } return $object; }
php
public function apiSerialize($object, $options = []) { if (!empty($object)) { return $this->serializerProvider->serialize($object, $options); } return $object; }
[ "public", "function", "apiSerialize", "(", "$", "object", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "object", ")", ")", "{", "return", "$", "this", "->", "serializerProvider", "->", "serialize", "(", "$", "objec...
Serializes data to JSON using the SerializerProvider. @param mixed $object @param array $options @return mixed
[ "Serializes", "data", "to", "JSON", "using", "the", "SerializerProvider", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Twig/SerializerExtension.php#L70-L77
train
claroline/Distribution
main/core/Twig/SerializerExtension.php
SerializerExtension.serialize
public function serialize($data, $group = null) { $context = new SerializationContext(); if ($group) { $context->setGroups($group); } return $this->serializer->serialize($data, 'json', $context); }
php
public function serialize($data, $group = null) { $context = new SerializationContext(); if ($group) { $context->setGroups($group); } return $this->serializer->serialize($data, 'json', $context); }
[ "public", "function", "serialize", "(", "$", "data", ",", "$", "group", "=", "null", ")", "{", "$", "context", "=", "new", "SerializationContext", "(", ")", ";", "if", "(", "$", "group", ")", "{", "$", "context", "->", "setGroups", "(", "$", "group",...
Serializes data to JSON, optionally filtering on a serialization group. @param mixed $data @param string $group @deprecated serialization should be handled by SerializerProvider
[ "Serializes", "data", "to", "JSON", "optionally", "filtering", "on", "a", "serialization", "group", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Twig/SerializerExtension.php#L87-L96
train
claroline/Distribution
plugin/blog/Controller/API/BlogController.php
BlogController.getOptionsAction
public function getOptionsAction(Request $request, Blog $blog) { $this->checkPermission('EDIT', $blog->getResourceNode(), [], true); return new JsonResponse($this->blogOptionsSerializer->serialize($blog, $blog->getOptions(), $this->blogManager->getPanelInfos())); }
php
public function getOptionsAction(Request $request, Blog $blog) { $this->checkPermission('EDIT', $blog->getResourceNode(), [], true); return new JsonResponse($this->blogOptionsSerializer->serialize($blog, $blog->getOptions(), $this->blogManager->getPanelInfos())); }
[ "public", "function", "getOptionsAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ")", "{", "$", "this", "->", "checkPermission", "(", "'EDIT'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ",", "[", "]", ",", "true", ")", ";"...
Get blog options. @EXT\Route("options", name="apiv2_blog_options") @EXT\Method("GET") @param Blog $blog @return array
[ "Get", "blog", "options", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/BlogController.php#L83-L88
train
claroline/Distribution
plugin/blog/Controller/API/BlogController.php
BlogController.updateOptionsAction
public function updateOptionsAction(Request $request, Blog $blog) { $this->checkPermission('EDIT', $blog->getResourceNode(), [], true); $data = json_decode($request->getContent(), true); $this->blogManager->updateOptions($blog, $this->blogOptionsSerializer->deserialize($data), $data['infos']); return new JsonResponse($this->blogOptionsSerializer->serialize($blog, $blog->getOptions())); }
php
public function updateOptionsAction(Request $request, Blog $blog) { $this->checkPermission('EDIT', $blog->getResourceNode(), [], true); $data = json_decode($request->getContent(), true); $this->blogManager->updateOptions($blog, $this->blogOptionsSerializer->deserialize($data), $data['infos']); return new JsonResponse($this->blogOptionsSerializer->serialize($blog, $blog->getOptions())); }
[ "public", "function", "updateOptionsAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ")", "{", "$", "this", "->", "checkPermission", "(", "'EDIT'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ",", "[", "]", ",", "true", ")", ...
Update blog options. @EXT\Route("options/update", name="apiv2_blog_options_update") @EXT\Method("PUT") @param Blog $blog @return array
[ "Update", "blog", "options", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/BlogController.php#L100-L107
train
claroline/Distribution
plugin/blog/Controller/API/BlogController.php
BlogController.getTagsAction
public function getTagsAction(Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); $parameters['limit'] = -1; $posts = $this->postManager->getPosts( $blog->getId(), $parameters, $this->checkPermission('ADMINISTRATE', $blog->getResourceNode()) || $this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('MODERATE', $blog->getResourceNode()) ? PostManager::GET_ALL_POSTS : PostManager::GET_PUBLISHED_POSTS, true); $postsData = []; if (!empty($posts)) { $postsData = $posts['data']; } return new JsonResponse($this->blogManager->getTags($blog, $postsData)); }
php
public function getTagsAction(Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); $parameters['limit'] = -1; $posts = $this->postManager->getPosts( $blog->getId(), $parameters, $this->checkPermission('ADMINISTRATE', $blog->getResourceNode()) || $this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('MODERATE', $blog->getResourceNode()) ? PostManager::GET_ALL_POSTS : PostManager::GET_PUBLISHED_POSTS, true); $postsData = []; if (!empty($posts)) { $postsData = $posts['data']; } return new JsonResponse($this->blogManager->getTags($blog, $postsData)); }
[ "public", "function", "getTagsAction", "(", "Blog", "$", "blog", ")", "{", "$", "this", "->", "checkPermission", "(", "'OPEN'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ",", "[", "]", ",", "true", ")", ";", "$", "parameters", "[", "'limit'"...
Get tag cloud, tags used in blog posts. @EXT\Route("tags", name="apiv2_blog_tags") @EXT\Method("GET")
[ "Get", "tag", "cloud", "tags", "used", "in", "blog", "posts", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/BlogController.php#L115-L136
train
claroline/Distribution
plugin/tag/Serializer/TagSerializer.php
TagSerializer.serialize
public function serialize(Tag $tag, array $options = []): array { $serialized = [ 'id' => $tag->getUuid(), 'name' => $tag->getName(), 'color' => $tag->getColor(), ]; if (!in_array(Options::SERIALIZE_MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'meta' => [ 'description' => $tag->getDescription(), 'creator' => $tag->getUser() ? $this->userSerializer->serialize($tag->getUser(), [Options::SERIALIZE_MINIMAL]) : null, ], 'elements' => $this->taggedObjectRepo->countByTag($tag), ]); } return $serialized; }
php
public function serialize(Tag $tag, array $options = []): array { $serialized = [ 'id' => $tag->getUuid(), 'name' => $tag->getName(), 'color' => $tag->getColor(), ]; if (!in_array(Options::SERIALIZE_MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'meta' => [ 'description' => $tag->getDescription(), 'creator' => $tag->getUser() ? $this->userSerializer->serialize($tag->getUser(), [Options::SERIALIZE_MINIMAL]) : null, ], 'elements' => $this->taggedObjectRepo->countByTag($tag), ]); } return $serialized; }
[ "public", "function", "serialize", "(", "Tag", "$", "tag", ",", "array", "$", "options", "=", "[", "]", ")", ":", "array", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "tag", "->", "getUuid", "(", ")", ",", "'name'", "=>", "$", "tag", "->...
Serializes a Tag entity into a serializable array. @param Tag $tag @param array $options @return array
[ "Serializes", "a", "Tag", "entity", "into", "a", "serializable", "array", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/tag/Serializer/TagSerializer.php#L66-L87
train
claroline/Distribution
plugin/tag/Serializer/TagSerializer.php
TagSerializer.deserialize
public function deserialize(array $data, Tag $tag): Tag { $this->sipe('name', 'setName', $data, $tag); $this->sipe('color', 'setColor', $data, $tag); $this->sipe('meta.description', 'setDescription', $data, $tag); if (isset($data['meta']) && isset($data['meta']['creator'])) { $user = $this->om->getRepository(User::class)->findBy(['uuid' => $data['meta']['creator']['id']]); if ($user) { $tag->setUser($user); } } return $tag; }
php
public function deserialize(array $data, Tag $tag): Tag { $this->sipe('name', 'setName', $data, $tag); $this->sipe('color', 'setColor', $data, $tag); $this->sipe('meta.description', 'setDescription', $data, $tag); if (isset($data['meta']) && isset($data['meta']['creator'])) { $user = $this->om->getRepository(User::class)->findBy(['uuid' => $data['meta']['creator']['id']]); if ($user) { $tag->setUser($user); } } return $tag; }
[ "public", "function", "deserialize", "(", "array", "$", "data", ",", "Tag", "$", "tag", ")", ":", "Tag", "{", "$", "this", "->", "sipe", "(", "'name'", ",", "'setName'", ",", "$", "data", ",", "$", "tag", ")", ";", "$", "this", "->", "sipe", "(",...
Deserializes tag data into an Entity. @param array $data @param Tag $tag @return Tag
[ "Deserializes", "tag", "data", "into", "an", "Entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/tag/Serializer/TagSerializer.php#L97-L111
train
claroline/Distribution
plugin/collecticiel/Entity/GradingCriteria.php
GradingCriteria.addChoiceCriteria
public function addChoiceCriteria(\Innova\CollecticielBundle\Entity\ChoiceCriteria $choiceCriteria) { $this->choiceCriterias[] = $choiceCriteria; return $this; }
php
public function addChoiceCriteria(\Innova\CollecticielBundle\Entity\ChoiceCriteria $choiceCriteria) { $this->choiceCriterias[] = $choiceCriteria; return $this; }
[ "public", "function", "addChoiceCriteria", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "ChoiceCriteria", "$", "choiceCriteria", ")", "{", "$", "this", "->", "choiceCriterias", "[", "]", "=", "$", "choiceCriteria", ";", "return", "$", ...
Add choiceCriteria. @param \Innova\CollecticielBundle\Entity\ChoiceCriteria $choiceCriteria @return GradingCriteria
[ "Add", "choiceCriteria", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/GradingCriteria.php#L131-L136
train
claroline/Distribution
plugin/collecticiel/Entity/GradingCriteria.php
GradingCriteria.removeChoiceCriteria
public function removeChoiceCriteria(\Innova\CollecticielBundle\Entity\ChoiceCriteria $choiceCriteria) { $this->choiceCriterias->removeElement($choiceCriteria); }
php
public function removeChoiceCriteria(\Innova\CollecticielBundle\Entity\ChoiceCriteria $choiceCriteria) { $this->choiceCriterias->removeElement($choiceCriteria); }
[ "public", "function", "removeChoiceCriteria", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "ChoiceCriteria", "$", "choiceCriteria", ")", "{", "$", "this", "->", "choiceCriterias", "->", "removeElement", "(", "$", "choiceCriteria", ")", ";...
Remove choiceCriteria. @param \Innova\CollecticielBundle\Entity\ChoiceCriteria $choiceCriteria
[ "Remove", "choiceCriteria", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/GradingCriteria.php#L143-L146
train
claroline/Distribution
plugin/path/Listener/Resource/PathListener.php
PathListener.onLoad
public function onLoad(LoadResourceEvent $event) { /** @var Path $path */ $path = $event->getResource(); $event->setData([ 'path' => $this->serializer->serialize($path), 'userEvaluation' => $this->serializer->serialize( $this->userProgressionManager->getUpdatedResourceUserEvaluation($path) ), ]); $event->stopPropagation(); }
php
public function onLoad(LoadResourceEvent $event) { /** @var Path $path */ $path = $event->getResource(); $event->setData([ 'path' => $this->serializer->serialize($path), 'userEvaluation' => $this->serializer->serialize( $this->userProgressionManager->getUpdatedResourceUserEvaluation($path) ), ]); $event->stopPropagation(); }
[ "public", "function", "onLoad", "(", "LoadResourceEvent", "$", "event", ")", "{", "/** @var Path $path */", "$", "path", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "event", "->", "setData", "(", "[", "'path'", "=>", "$", "this", "->", "s...
Loads the Path resource. @DI\Observe("resource.innova_path.load") @param LoadResourceEvent $event
[ "Loads", "the", "Path", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Listener/Resource/PathListener.php#L96-L108
train
claroline/Distribution
plugin/path/Listener/Resource/PathListener.php
PathListener.onCopy
public function onCopy(CopyResourceEvent $event) { // Start the transaction. We'll copy every resource in one go that way. $this->om->startFlushSuite(); /** @var Path $path */ $path = $event->getCopy(); $pathNode = $path->getResourceNode(); if ($path->hasResources()) { // create a directory to store copied resources $resourcesDirectory = $this->createResourcesCopyDirectory($pathNode->getParent(), $pathNode->getName()); // A forced flush is required for rights propagation on the copied resources $this->om->forceFlush(); // copy resources for all steps $copiedResources = []; foreach ($path->getSteps() as $step) { if ($step->hasResources()) { $copiedResources = $this->copyStepResources($step, $resourcesDirectory->getResourceNode(), $copiedResources); } } } $this->om->persist($path); // End the transaction $this->om->endFlushSuite(); $event->setCopy($path); $event->stopPropagation(); }
php
public function onCopy(CopyResourceEvent $event) { // Start the transaction. We'll copy every resource in one go that way. $this->om->startFlushSuite(); /** @var Path $path */ $path = $event->getCopy(); $pathNode = $path->getResourceNode(); if ($path->hasResources()) { // create a directory to store copied resources $resourcesDirectory = $this->createResourcesCopyDirectory($pathNode->getParent(), $pathNode->getName()); // A forced flush is required for rights propagation on the copied resources $this->om->forceFlush(); // copy resources for all steps $copiedResources = []; foreach ($path->getSteps() as $step) { if ($step->hasResources()) { $copiedResources = $this->copyStepResources($step, $resourcesDirectory->getResourceNode(), $copiedResources); } } } $this->om->persist($path); // End the transaction $this->om->endFlushSuite(); $event->setCopy($path); $event->stopPropagation(); }
[ "public", "function", "onCopy", "(", "CopyResourceEvent", "$", "event", ")", "{", "// Start the transaction. We'll copy every resource in one go that way.", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "/** @var Path $path */", "$", "path", "=", "$",...
Fired when a ResourceNode of type Path is duplicated. @DI\Observe("resource.innova_path.copy") @param CopyResourceEvent $event @throws \Exception
[ "Fired", "when", "a", "ResourceNode", "of", "type", "Path", "is", "duplicated", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Listener/Resource/PathListener.php#L131-L162
train
claroline/Distribution
plugin/path/Listener/Resource/PathListener.php
PathListener.createResourcesCopyDirectory
private function createResourcesCopyDirectory(ResourceNode $destination, $pathName) { // Get current User $user = $this->tokenStorage->getToken()->getUser(); $resourcesDir = $this->resourceManager->createResource( Directory::class, $pathName.' ('.$this->translator->trans('resources', [], 'platform').')' ); return $this->resourceManager->create( $resourcesDir, $destination->getResourceType(), $user, $destination->getWorkspace(), $destination ); }
php
private function createResourcesCopyDirectory(ResourceNode $destination, $pathName) { // Get current User $user = $this->tokenStorage->getToken()->getUser(); $resourcesDir = $this->resourceManager->createResource( Directory::class, $pathName.' ('.$this->translator->trans('resources', [], 'platform').')' ); return $this->resourceManager->create( $resourcesDir, $destination->getResourceType(), $user, $destination->getWorkspace(), $destination ); }
[ "private", "function", "createResourcesCopyDirectory", "(", "ResourceNode", "$", "destination", ",", "$", "pathName", ")", "{", "// Get current User", "$", "user", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", "->", "getUser", "(", ")", "...
Create directory to store copies of resources. @param ResourceNode $destination @param string $pathName @return AbstractResource
[ "Create", "directory", "to", "store", "copies", "of", "resources", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Listener/Resource/PathListener.php#L172-L189
train
claroline/Distribution
main/core/Manager/WorkspaceUserQueueManager.php
WorkspaceUserQueueManager.validateRegistration
public function validateRegistration(WorkspaceRegistrationQueue $workspaceRegistration) { $this->roleManager->associateRolesToSubjects( [$workspaceRegistration->getUser()], [$workspaceRegistration->getRole()], true ); $this->om->remove($workspaceRegistration); $this->om->flush(); }
php
public function validateRegistration(WorkspaceRegistrationQueue $workspaceRegistration) { $this->roleManager->associateRolesToSubjects( [$workspaceRegistration->getUser()], [$workspaceRegistration->getRole()], true ); $this->om->remove($workspaceRegistration); $this->om->flush(); }
[ "public", "function", "validateRegistration", "(", "WorkspaceRegistrationQueue", "$", "workspaceRegistration", ")", "{", "$", "this", "->", "roleManager", "->", "associateRolesToSubjects", "(", "[", "$", "workspaceRegistration", "->", "getUser", "(", ")", "]", ",", ...
Validates a pending workspace registration. @param WorkspaceRegistrationQueue $workspaceRegistration
[ "Validates", "a", "pending", "workspace", "registration", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/WorkspaceUserQueueManager.php#L59-L69
train
claroline/Distribution
main/core/Manager/WorkspaceUserQueueManager.php
WorkspaceUserQueueManager.removeRegistration
public function removeRegistration(WorkspaceRegistrationQueue $workspaceRegistration) { $this->dispatcher->dispatch( 'log', 'Log\LogWorkspaceRegistrationDecline', [$workspaceRegistration] ); $this->om->remove($workspaceRegistration); $this->om->flush(); }
php
public function removeRegistration(WorkspaceRegistrationQueue $workspaceRegistration) { $this->dispatcher->dispatch( 'log', 'Log\LogWorkspaceRegistrationDecline', [$workspaceRegistration] ); $this->om->remove($workspaceRegistration); $this->om->flush(); }
[ "public", "function", "removeRegistration", "(", "WorkspaceRegistrationQueue", "$", "workspaceRegistration", ")", "{", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'log'", ",", "'Log\\LogWorkspaceRegistrationDecline'", ",", "[", "$", "workspaceRegistration", ...
Removes a pending workspace registration. @param WorkspaceRegistrationQueue $workspaceRegistration
[ "Removes", "a", "pending", "workspace", "registration", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/WorkspaceUserQueueManager.php#L76-L86
train
claroline/Distribution
plugin/exo/Entity/Attempt/Paper.php
Paper.getQuestion
public function getQuestion($questionUuid) { $question = null; if (empty($this->decodedStructure)) { $this->decodeStructure(); } foreach ($this->decodedStructure['steps'] as $step) { foreach ($step['items'] as $item) { if ($item['id'] === $questionUuid) { $question = $item; break 2; } } } return $question; }
php
public function getQuestion($questionUuid) { $question = null; if (empty($this->decodedStructure)) { $this->decodeStructure(); } foreach ($this->decodedStructure['steps'] as $step) { foreach ($step['items'] as $item) { if ($item['id'] === $questionUuid) { $question = $item; break 2; } } } return $question; }
[ "public", "function", "getQuestion", "(", "$", "questionUuid", ")", "{", "$", "question", "=", "null", ";", "if", "(", "empty", "(", "$", "this", "->", "decodedStructure", ")", ")", "{", "$", "this", "->", "decodeStructure", "(", ")", ";", "}", "foreac...
Gets a question in the paper structure. @param $questionUuid @return array
[ "Gets", "a", "question", "in", "the", "paper", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Attempt/Paper.php#L332-L350
train
claroline/Distribution
plugin/exo/Entity/Attempt/Paper.php
Paper.getAnswer
public function getAnswer($questionUuid) { $found = null; foreach ($this->answers as $answer) { if ($answer->getQuestionId() === $questionUuid) { $found = $answer; break; } } return $found; }
php
public function getAnswer($questionUuid) { $found = null; foreach ($this->answers as $answer) { if ($answer->getQuestionId() === $questionUuid) { $found = $answer; break; } } return $found; }
[ "public", "function", "getAnswer", "(", "$", "questionUuid", ")", "{", "$", "found", "=", "null", ";", "foreach", "(", "$", "this", "->", "answers", "as", "$", "answer", ")", "{", "if", "(", "$", "answer", "->", "getQuestionId", "(", ")", "===", "$",...
Gets the answer to a question if any exist. @param string $questionUuid @return Answer
[ "Gets", "the", "answer", "to", "a", "question", "if", "any", "exist", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Attempt/Paper.php#L359-L370
train
claroline/Distribution
plugin/exo/Entity/Attempt/Paper.php
Paper.addAnswer
public function addAnswer(Answer $answer) { if (!$this->answers->contains($answer)) { $this->answers->add($answer); $answer->setPaper($this); } }
php
public function addAnswer(Answer $answer) { if (!$this->answers->contains($answer)) { $this->answers->add($answer); $answer->setPaper($this); } }
[ "public", "function", "addAnswer", "(", "Answer", "$", "answer", ")", "{", "if", "(", "!", "$", "this", "->", "answers", "->", "contains", "(", "$", "answer", ")", ")", "{", "$", "this", "->", "answers", "->", "add", "(", "$", "answer", ")", ";", ...
Adds an answer. @param Answer $answer
[ "Adds", "an", "answer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Attempt/Paper.php#L377-L383
train
claroline/Distribution
plugin/exo/Entity/Attempt/Paper.php
Paper.removeAnswer
public function removeAnswer(Answer $answer) { if ($this->answers->contains($answer)) { $this->answers->removeElement($answer); } }
php
public function removeAnswer(Answer $answer) { if ($this->answers->contains($answer)) { $this->answers->removeElement($answer); } }
[ "public", "function", "removeAnswer", "(", "Answer", "$", "answer", ")", "{", "if", "(", "$", "this", "->", "answers", "->", "contains", "(", "$", "answer", ")", ")", "{", "$", "this", "->", "answers", "->", "removeElement", "(", "$", "answer", ")", ...
Removes an answer. @param Answer $answer
[ "Removes", "an", "answer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Attempt/Paper.php#L390-L395
train
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.serialize
public function serialize(Item $question, array $options = []) { // Serialize specific data for the item type $serialized = $this->serializeQuestionType($question, $options); if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $question->getMimeType())) { $canEdit = $this->tokenStorage->getToken() && $this->tokenStorage->getToken()->getUser() instanceof User ? $this->container->get('ujm_exo.manager.item')->canEdit($question, $this->tokenStorage->getToken()->getUser()) : false; // Adds minimal information $serialized = array_merge($serialized, [ 'id' => $question->getUuid(), 'autoId' => $question->getId(), 'type' => $question->getMimeType(), 'content' => $question->getContent(), 'title' => $question->getTitle(), 'meta' => $this->serializeMetadata($question, $options), 'score' => json_decode($question->getScoreRule(), true), 'rights' => ['edit' => $canEdit], ]); // Adds full definition of the item if (!in_array(Transfer::MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'description' => $question->getDescription(), 'hints' => $this->serializeHints($question, $options), 'objects' => $this->serializeObjects($question), 'resources' => $this->serializeResources($question), 'tags' => $this->serializeTags($question), ]); // Adds item feedback if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['feedback'] = $question->getFeedback(); } } } else { $serialized = array_merge($serialized, [ 'id' => $question->getUuid(), 'type' => $question->getMimeType(), 'title' => $question->getTitle(), 'meta' => $this->serializeMetadata($question, $options), ]); // Adds full definition of the item if (!in_array(Transfer::MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'description' => $question->getDescription(), 'tags' => $this->serializeTags($question), ]); } } return $serialized; }
php
public function serialize(Item $question, array $options = []) { // Serialize specific data for the item type $serialized = $this->serializeQuestionType($question, $options); if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $question->getMimeType())) { $canEdit = $this->tokenStorage->getToken() && $this->tokenStorage->getToken()->getUser() instanceof User ? $this->container->get('ujm_exo.manager.item')->canEdit($question, $this->tokenStorage->getToken()->getUser()) : false; // Adds minimal information $serialized = array_merge($serialized, [ 'id' => $question->getUuid(), 'autoId' => $question->getId(), 'type' => $question->getMimeType(), 'content' => $question->getContent(), 'title' => $question->getTitle(), 'meta' => $this->serializeMetadata($question, $options), 'score' => json_decode($question->getScoreRule(), true), 'rights' => ['edit' => $canEdit], ]); // Adds full definition of the item if (!in_array(Transfer::MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'description' => $question->getDescription(), 'hints' => $this->serializeHints($question, $options), 'objects' => $this->serializeObjects($question), 'resources' => $this->serializeResources($question), 'tags' => $this->serializeTags($question), ]); // Adds item feedback if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['feedback'] = $question->getFeedback(); } } } else { $serialized = array_merge($serialized, [ 'id' => $question->getUuid(), 'type' => $question->getMimeType(), 'title' => $question->getTitle(), 'meta' => $this->serializeMetadata($question, $options), ]); // Adds full definition of the item if (!in_array(Transfer::MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'description' => $question->getDescription(), 'tags' => $this->serializeTags($question), ]); } } return $serialized; }
[ "public", "function", "serialize", "(", "Item", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// Serialize specific data for the item type", "$", "serialized", "=", "$", "this", "->", "serializeQuestionType", "(", "$", "question", ",",...
Converts a Item into a JSON-encodable structure. @param Item $question @param array $options @return array
[ "Converts", "a", "Item", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L120-L174
train
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.serializeQuestionType
private function serializeQuestionType(Item $question, array $options = []) { $type = $this->itemDefinitions->getConvertedType($question->getMimeType()); $definition = $this->itemDefinitions->get($type); return $definition->serializeQuestion($question->getInteraction(), $options); }
php
private function serializeQuestionType(Item $question, array $options = []) { $type = $this->itemDefinitions->getConvertedType($question->getMimeType()); $definition = $this->itemDefinitions->get($type); return $definition->serializeQuestion($question->getInteraction(), $options); }
[ "private", "function", "serializeQuestionType", "(", "Item", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "type", "=", "$", "this", "->", "itemDefinitions", "->", "getConvertedType", "(", "$", "question", "->", "getMimeType", ...
Serializes Item data specific to its type. Forwards the serialization to the correct handler. @param Item $question @param array $options @return array
[ "Serializes", "Item", "data", "specific", "to", "its", "type", ".", "Forwards", "the", "serialization", "to", "the", "correct", "handler", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L259-L265
train
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.deserializeQuestionType
private function deserializeQuestionType(Item $question, array $data, array $options = []) { $type = $this->itemDefinitions->getConvertedType($question->getMimeType()); $definition = $this->itemDefinitions->get($type); // Deserialize item type data $type = $definition->deserializeQuestion($data, $question->getInteraction(), $options); $type->setQuestion($question); if (in_array(Transfer::REFRESH_UUID, $options)) { $definition->refreshIdentifiers($question->getInteraction()); } }
php
private function deserializeQuestionType(Item $question, array $data, array $options = []) { $type = $this->itemDefinitions->getConvertedType($question->getMimeType()); $definition = $this->itemDefinitions->get($type); // Deserialize item type data $type = $definition->deserializeQuestion($data, $question->getInteraction(), $options); $type->setQuestion($question); if (in_array(Transfer::REFRESH_UUID, $options)) { $definition->refreshIdentifiers($question->getInteraction()); } }
[ "private", "function", "deserializeQuestionType", "(", "Item", "$", "question", ",", "array", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "type", "=", "$", "this", "->", "itemDefinitions", "->", "getConvertedType", "(", "$", ...
Deserializes Item data specific to its type. Forwards the serialization to the correct handler. @param Item $question @param array $data @param array $options
[ "Deserializes", "Item", "data", "specific", "to", "its", "type", ".", "Forwards", "the", "serialization", "to", "the", "correct", "handler", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L275-L286
train
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.serializeMetadata
private function serializeMetadata(Item $question, array $options = []) { $metadata = ['protectQuestion' => $question->getProtectUpdate()]; $creator = $question->getCreator(); if (!empty($creator)) { $metadata['creator'] = $this->userSerializer->serialize($creator, $options); // TODO : remove me. for retro compatibility with old schema $metadata['authors'] = [$this->userSerializer->serialize($creator, $options)]; } if ($question->getDateCreate()) { $metadata['created'] = DateNormalizer::normalize($question->getDateCreate()); } if ($question->getDateModify()) { $metadata['updated'] = DateNormalizer::normalize($question->getDateModify()); } if (in_array(Transfer::INCLUDE_ADMIN_META, $options)) { /** @var ExerciseRepository $exerciseRepo */ $exerciseRepo = $this->om->getRepository(Exercise::class); // Gets exercises that use this item $exercises = $exerciseRepo->findByQuestion($question); $metadata['usedBy'] = array_map(function (Exercise $exercise) { return $exercise->getUuid(); }, $exercises); // Gets users who have access to this item $users = $this->om->getRepository(Shared::class)->findBy(['question' => $question]); $metadata['sharedWith'] = array_map(function (Shared $sharedQuestion) use ($options) { $shared = [ 'adminRights' => $sharedQuestion->hasAdminRights(), 'user' => $this->userSerializer->serialize($sharedQuestion->getUser(), $options), ]; return $shared; }, $users); } return $metadata; }
php
private function serializeMetadata(Item $question, array $options = []) { $metadata = ['protectQuestion' => $question->getProtectUpdate()]; $creator = $question->getCreator(); if (!empty($creator)) { $metadata['creator'] = $this->userSerializer->serialize($creator, $options); // TODO : remove me. for retro compatibility with old schema $metadata['authors'] = [$this->userSerializer->serialize($creator, $options)]; } if ($question->getDateCreate()) { $metadata['created'] = DateNormalizer::normalize($question->getDateCreate()); } if ($question->getDateModify()) { $metadata['updated'] = DateNormalizer::normalize($question->getDateModify()); } if (in_array(Transfer::INCLUDE_ADMIN_META, $options)) { /** @var ExerciseRepository $exerciseRepo */ $exerciseRepo = $this->om->getRepository(Exercise::class); // Gets exercises that use this item $exercises = $exerciseRepo->findByQuestion($question); $metadata['usedBy'] = array_map(function (Exercise $exercise) { return $exercise->getUuid(); }, $exercises); // Gets users who have access to this item $users = $this->om->getRepository(Shared::class)->findBy(['question' => $question]); $metadata['sharedWith'] = array_map(function (Shared $sharedQuestion) use ($options) { $shared = [ 'adminRights' => $sharedQuestion->hasAdminRights(), 'user' => $this->userSerializer->serialize($sharedQuestion->getUser(), $options), ]; return $shared; }, $users); } return $metadata; }
[ "private", "function", "serializeMetadata", "(", "Item", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "metadata", "=", "[", "'protectQuestion'", "=>", "$", "question", "->", "getProtectUpdate", "(", ")", "]", ";", "$", "cr...
Serializes Item metadata. @param Item $question @param array $options @return array
[ "Serializes", "Item", "metadata", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L296-L339
train
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.serializeHints
private function serializeHints(Item $question, array $options = []) { return array_map(function (Hint $hint) use ($options) { return $this->hintSerializer->serialize($hint, $options); }, $question->getHints()->toArray()); }
php
private function serializeHints(Item $question, array $options = []) { return array_map(function (Hint $hint) use ($options) { return $this->hintSerializer->serialize($hint, $options); }, $question->getHints()->toArray()); }
[ "private", "function", "serializeHints", "(", "Item", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "array_map", "(", "function", "(", "Hint", "$", "hint", ")", "use", "(", "$", "options", ")", "{", "return", "$", ...
Serializes Item hints. Forwards the hint serialization to HintSerializer. @param Item $question @param array $options @return array
[ "Serializes", "Item", "hints", ".", "Forwards", "the", "hint", "serialization", "to", "HintSerializer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L361-L366
train
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.deserializeHints
private function deserializeHints(Item $question, array $hints = [], array $options = []) { $hintEntities = $question->getHints()->toArray(); foreach ($hints as $hintData) { $existingHint = null; // Searches for an existing hint entity. foreach ($hintEntities as $entityIndex => $entityHint) { /** @var Hint $entityHint */ if ($entityHint->getUuid() === $hintData['id']) { $existingHint = $entityHint; unset($hintEntities[$entityIndex]); break; } } $entity = $this->hintSerializer->deserialize($hintData, $existingHint, $options); if (empty($existingHint)) { // Creation of a new hint (we need to link it to the question) $question->addHint($entity); } } // Remaining hints are no longer in the Exercise if (0 < count($hintEntities)) { foreach ($hintEntities as $hintToRemove) { $question->removeHint($hintToRemove); } } }
php
private function deserializeHints(Item $question, array $hints = [], array $options = []) { $hintEntities = $question->getHints()->toArray(); foreach ($hints as $hintData) { $existingHint = null; // Searches for an existing hint entity. foreach ($hintEntities as $entityIndex => $entityHint) { /** @var Hint $entityHint */ if ($entityHint->getUuid() === $hintData['id']) { $existingHint = $entityHint; unset($hintEntities[$entityIndex]); break; } } $entity = $this->hintSerializer->deserialize($hintData, $existingHint, $options); if (empty($existingHint)) { // Creation of a new hint (we need to link it to the question) $question->addHint($entity); } } // Remaining hints are no longer in the Exercise if (0 < count($hintEntities)) { foreach ($hintEntities as $hintToRemove) { $question->removeHint($hintToRemove); } } }
[ "private", "function", "deserializeHints", "(", "Item", "$", "question", ",", "array", "$", "hints", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "hintEntities", "=", "$", "question", "->", "getHints", "(", ")", "->", "t...
Deserializes Item hints. Forwards the hint deserialization to HintSerializer. @param Item $question @param array $hints @param array $options
[ "Deserializes", "Item", "hints", ".", "Forwards", "the", "hint", "deserialization", "to", "HintSerializer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L376-L407
train
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.serializeObjects
private function serializeObjects(Item $question, array $options = []) { return array_values(array_map(function (ItemObject $object) use ($options) { return $this->itemObjectSerializer->serialize($object, $options); }, $question->getObjects()->toArray())); }
php
private function serializeObjects(Item $question, array $options = []) { return array_values(array_map(function (ItemObject $object) use ($options) { return $this->itemObjectSerializer->serialize($object, $options); }, $question->getObjects()->toArray())); }
[ "private", "function", "serializeObjects", "(", "Item", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "array_values", "(", "array_map", "(", "function", "(", "ItemObject", "$", "object", ")", "use", "(", "$", "options", ...
Serializes Item objects. Forwards the object serialization to ItemObjectSerializer. @param Item $question @param array $options @return array
[ "Serializes", "Item", "objects", ".", "Forwards", "the", "object", "serialization", "to", "ItemObjectSerializer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L418-L423
train
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.deserializeObjects
private function deserializeObjects(Item $question, array $objects = [], array $options = []) { $objectEntities = $question->getObjects()->toArray(); $question->emptyObjects(); foreach ($objects as $index => $objectData) { $existingObject = null; // Searches for an existing object entity. foreach ($objectEntities as $entityIndex => $entityObject) { /** @var ItemObject $entityObject */ if ($entityObject->getUuid() === $objectData['id']) { $existingObject = $entityObject; unset($objectEntities[$entityIndex]); break; } } $itemObject = $this->itemObjectSerializer->deserialize($objectData, $existingObject, $options); $itemObject->setOrder($index); $question->addObject($itemObject); } // Remaining objects are no longer in the Item if (0 < count($objectEntities)) { foreach ($objectEntities as $objectToRemove) { $this->om->remove($objectToRemove); } } }
php
private function deserializeObjects(Item $question, array $objects = [], array $options = []) { $objectEntities = $question->getObjects()->toArray(); $question->emptyObjects(); foreach ($objects as $index => $objectData) { $existingObject = null; // Searches for an existing object entity. foreach ($objectEntities as $entityIndex => $entityObject) { /** @var ItemObject $entityObject */ if ($entityObject->getUuid() === $objectData['id']) { $existingObject = $entityObject; unset($objectEntities[$entityIndex]); break; } } $itemObject = $this->itemObjectSerializer->deserialize($objectData, $existingObject, $options); $itemObject->setOrder($index); $question->addObject($itemObject); } // Remaining objects are no longer in the Item if (0 < count($objectEntities)) { foreach ($objectEntities as $objectToRemove) { $this->om->remove($objectToRemove); } } }
[ "private", "function", "deserializeObjects", "(", "Item", "$", "question", ",", "array", "$", "objects", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "objectEntities", "=", "$", "question", "->", "getObjects", "(", ")", "-...
Deserializes Item objects. @param Item $question @param array $objects @param array $options
[ "Deserializes", "Item", "objects", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L432-L460
train
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.serializeResources
private function serializeResources(Item $question, array $options = []) { return array_map(function (ItemResource $resource) use ($options) { return $this->resourceContentSerializer->serialize($resource->getResourceNode(), $options); }, $question->getResources()->toArray()); }
php
private function serializeResources(Item $question, array $options = []) { return array_map(function (ItemResource $resource) use ($options) { return $this->resourceContentSerializer->serialize($resource->getResourceNode(), $options); }, $question->getResources()->toArray()); }
[ "private", "function", "serializeResources", "(", "Item", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "array_map", "(", "function", "(", "ItemResource", "$", "resource", ")", "use", "(", "$", "options", ")", "{", "re...
Serializes Item resources. Forwards the resource serialization to ResourceContentSerializer. @param Item $question @param array $options @return array
[ "Serializes", "Item", "resources", ".", "Forwards", "the", "resource", "serialization", "to", "ResourceContentSerializer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L471-L476
train
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.deserializeResources
private function deserializeResources(Item $question, array $resources = [], array $options = []) { $resourceEntities = $question->getResources()->toArray(); foreach ($resources as $resourceData) { $existingResource = null; // Searches for an existing resource entity. foreach ($resourceEntities as $entityIndex => $entityResource) { /** @var ItemResource $entityResource */ if ((string) $entityResource->getId() === $resourceData['id']) { $existingResource = $entityResource; unset($resourceEntities[$entityIndex]); break; } } // Link resource to item if (empty($existingResource)) { $obj = $this->resourceContentSerializer->deserialize($resourceData, $existingResource, $options); if ($obj) { if ($obj instanceof ResourceNode) { $itemResource = new ItemResource(); $itemResource->setResourceNode($obj); $itemResource->setQuestion($question); $obj = $itemResource; } $question->addResource($obj); } } } // Remaining resources are no longer in the Item if (0 < count($resourceEntities)) { foreach ($resourceEntities as $resourceToRemove) { $question->removeResource($resourceToRemove); } } }
php
private function deserializeResources(Item $question, array $resources = [], array $options = []) { $resourceEntities = $question->getResources()->toArray(); foreach ($resources as $resourceData) { $existingResource = null; // Searches for an existing resource entity. foreach ($resourceEntities as $entityIndex => $entityResource) { /** @var ItemResource $entityResource */ if ((string) $entityResource->getId() === $resourceData['id']) { $existingResource = $entityResource; unset($resourceEntities[$entityIndex]); break; } } // Link resource to item if (empty($existingResource)) { $obj = $this->resourceContentSerializer->deserialize($resourceData, $existingResource, $options); if ($obj) { if ($obj instanceof ResourceNode) { $itemResource = new ItemResource(); $itemResource->setResourceNode($obj); $itemResource->setQuestion($question); $obj = $itemResource; } $question->addResource($obj); } } } // Remaining resources are no longer in the Item if (0 < count($resourceEntities)) { foreach ($resourceEntities as $resourceToRemove) { $question->removeResource($resourceToRemove); } } }
[ "private", "function", "deserializeResources", "(", "Item", "$", "question", ",", "array", "$", "resources", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "resourceEntities", "=", "$", "question", "->", "getResources", "(", "...
Deserializes Item resources. @param Item $question @param array $resources @param array $options
[ "Deserializes", "Item", "resources", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L485-L523
train
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.sanitizeScore
private function sanitizeScore($score) { $sanitized = ['type' => $score['type']]; switch ($score['type']) { case 'fixed': $sanitized['success'] = $score['success']; $sanitized['failure'] = $score['failure']; break; case 'manual': $sanitized['max'] = $score['max']; break; case 'rules': $sanitized['noWrongChoice'] = isset($score['noWrongChoice']) ? $score['noWrongChoice'] : false; $sanitized['rules'] = $score['rules']; break; } return $sanitized; }
php
private function sanitizeScore($score) { $sanitized = ['type' => $score['type']]; switch ($score['type']) { case 'fixed': $sanitized['success'] = $score['success']; $sanitized['failure'] = $score['failure']; break; case 'manual': $sanitized['max'] = $score['max']; break; case 'rules': $sanitized['noWrongChoice'] = isset($score['noWrongChoice']) ? $score['noWrongChoice'] : false; $sanitized['rules'] = $score['rules']; break; } return $sanitized; }
[ "private", "function", "sanitizeScore", "(", "$", "score", ")", "{", "$", "sanitized", "=", "[", "'type'", "=>", "$", "score", "[", "'type'", "]", "]", ";", "switch", "(", "$", "score", "[", "'type'", "]", ")", "{", "case", "'fixed'", ":", "$", "sa...
The client may send dirty data, we need to clean them before storing it in DB. @param $score @return array
[ "The", "client", "may", "send", "dirty", "data", "we", "need", "to", "clean", "them", "before", "storing", "it", "in", "DB", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L532-L553
train
claroline/Distribution
main/core/Listener/Tool/HomeListener.php
HomeListener.onDisplayDesktop
public function onDisplayDesktop(DisplayToolEvent $event) { $currentUser = $this->tokenStorage->getToken()->getUser(); $allTabs = $this->finder->search(HomeTab::class, [ 'filters' => ['user' => $currentUser->getUuid()], ]); // Order tabs. We want : // - Administration tabs to be at first // - Tabs to be ordered by position // For this, we separate administration tabs and user ones, order them by position // and then concat all tabs with admin in first (I don't have a easier solution to achieve this) $adminTabs = []; $userTabs = []; foreach ($allTabs['data'] as $tab) { if (!empty($tab)) { // we use the define position for array keys for easier sort if (HomeTab::TYPE_ADMIN_DESKTOP === $tab['type']) { $adminTabs[$tab['position']] = $tab; } else { $userTabs[$tab['position']] = $tab; } } } // order tabs by position ksort($adminTabs); ksort($userTabs); // generate the final list of tabs $orderedTabs = array_merge(array_values($adminTabs), array_values($userTabs)); // we rewrite tab position because an admin and a user tab may have the same position foreach ($orderedTabs as $index => &$tab) { $tab['position'] = $index; } $content = $this->templating->render( 'ClarolineCoreBundle:tool:home.html.twig', [ 'editable' => true, 'context' => [ 'type' => Widget::CONTEXT_DESKTOP, ], 'tabs' => $orderedTabs, ] ); $event->setContent($content); $event->stopPropagation(); }
php
public function onDisplayDesktop(DisplayToolEvent $event) { $currentUser = $this->tokenStorage->getToken()->getUser(); $allTabs = $this->finder->search(HomeTab::class, [ 'filters' => ['user' => $currentUser->getUuid()], ]); // Order tabs. We want : // - Administration tabs to be at first // - Tabs to be ordered by position // For this, we separate administration tabs and user ones, order them by position // and then concat all tabs with admin in first (I don't have a easier solution to achieve this) $adminTabs = []; $userTabs = []; foreach ($allTabs['data'] as $tab) { if (!empty($tab)) { // we use the define position for array keys for easier sort if (HomeTab::TYPE_ADMIN_DESKTOP === $tab['type']) { $adminTabs[$tab['position']] = $tab; } else { $userTabs[$tab['position']] = $tab; } } } // order tabs by position ksort($adminTabs); ksort($userTabs); // generate the final list of tabs $orderedTabs = array_merge(array_values($adminTabs), array_values($userTabs)); // we rewrite tab position because an admin and a user tab may have the same position foreach ($orderedTabs as $index => &$tab) { $tab['position'] = $index; } $content = $this->templating->render( 'ClarolineCoreBundle:tool:home.html.twig', [ 'editable' => true, 'context' => [ 'type' => Widget::CONTEXT_DESKTOP, ], 'tabs' => $orderedTabs, ] ); $event->setContent($content); $event->stopPropagation(); }
[ "public", "function", "onDisplayDesktop", "(", "DisplayToolEvent", "$", "event", ")", "{", "$", "currentUser", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "$", "allTabs", "=", "$", "this", "->", "fi...
Displays home on Desktop. @DI\Observe("open_tool_desktop_home") @param DisplayToolEvent $event
[ "Displays", "home", "on", "Desktop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Tool/HomeListener.php#L81-L132
train
claroline/Distribution
main/core/Listener/Tool/HomeListener.php
HomeListener.onDisplayWorkspace
public function onDisplayWorkspace(DisplayToolEvent $event) { $orderedTabs = []; $workspace = $event->getWorkspace(); $tabs = $this->finder->search(HomeTab::class, [ 'filters' => ['workspace' => $workspace->getUuid()], ]); // but why ? finder should never give you an empty row $tabs = array_filter($tabs['data'], function ($data) { return $data !== []; }); foreach ($tabs as $tab) { $orderedTabs[$tab['position']] = $tab; } ksort($orderedTabs); $content = $this->templating->render( 'ClarolineCoreBundle:tool:home.html.twig', [ 'workspace' => $workspace, 'editable' => $this->authorization->isGranted(['home', 'edit'], $workspace), 'context' => [ 'type' => Widget::CONTEXT_WORKSPACE, 'data' => $this->serializer->serialize($workspace), ], 'tabs' => array_values($orderedTabs), ] ); $event->setContent($content); $event->stopPropagation(); }
php
public function onDisplayWorkspace(DisplayToolEvent $event) { $orderedTabs = []; $workspace = $event->getWorkspace(); $tabs = $this->finder->search(HomeTab::class, [ 'filters' => ['workspace' => $workspace->getUuid()], ]); // but why ? finder should never give you an empty row $tabs = array_filter($tabs['data'], function ($data) { return $data !== []; }); foreach ($tabs as $tab) { $orderedTabs[$tab['position']] = $tab; } ksort($orderedTabs); $content = $this->templating->render( 'ClarolineCoreBundle:tool:home.html.twig', [ 'workspace' => $workspace, 'editable' => $this->authorization->isGranted(['home', 'edit'], $workspace), 'context' => [ 'type' => Widget::CONTEXT_WORKSPACE, 'data' => $this->serializer->serialize($workspace), ], 'tabs' => array_values($orderedTabs), ] ); $event->setContent($content); $event->stopPropagation(); }
[ "public", "function", "onDisplayWorkspace", "(", "DisplayToolEvent", "$", "event", ")", "{", "$", "orderedTabs", "=", "[", "]", ";", "$", "workspace", "=", "$", "event", "->", "getWorkspace", "(", ")", ";", "$", "tabs", "=", "$", "this", "->", "finder", ...
Displays home on Workspace. @DI\Observe("open_tool_workspace_home") @param DisplayToolEvent $event
[ "Displays", "home", "on", "Workspace", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Tool/HomeListener.php#L141-L174
train
claroline/Distribution
main/core/Controller/APINew/User/OrganizationController.php
OrganizationController.addManagersAction
public function addManagersAction(Organization $organization, Request $request) { $users = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\User'); $this->crud->patch($organization, 'administrator', Crud::COLLECTION_ADD, $users); return new JsonResponse($this->serializer->serialize($organization)); }
php
public function addManagersAction(Organization $organization, Request $request) { $users = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\User'); $this->crud->patch($organization, 'administrator', Crud::COLLECTION_ADD, $users); return new JsonResponse($this->serializer->serialize($organization)); }
[ "public", "function", "addManagersAction", "(", "Organization", "$", "organization", ",", "Request", "$", "request", ")", "{", "$", "users", "=", "$", "this", "->", "decodeIdsString", "(", "$", "request", ",", "'Claroline\\CoreBundle\\Entity\\User'", ")", ";", "...
Adds managers to the collection. @Route("/{id}/manager", name="apiv2_organization_add_managers") @Method("PATCH") @ParamConverter("organization", options={"mapping": {"id": "uuid"}}) @param Organization $organization @param Request $request @return JsonResponse
[ "Adds", "managers", "to", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/User/OrganizationController.php#L96-L102
train
claroline/Distribution
main/core/Controller/APINew/User/OrganizationController.php
OrganizationController.removeManagersAction
public function removeManagersAction(Organization $organization, Request $request) { $users = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\User'); $this->crud->patch($organization, 'administrator', Crud::COLLECTION_REMOVE, $users); return new JsonResponse($this->serializer->serialize($organization)); }
php
public function removeManagersAction(Organization $organization, Request $request) { $users = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\User'); $this->crud->patch($organization, 'administrator', Crud::COLLECTION_REMOVE, $users); return new JsonResponse($this->serializer->serialize($organization)); }
[ "public", "function", "removeManagersAction", "(", "Organization", "$", "organization", ",", "Request", "$", "request", ")", "{", "$", "users", "=", "$", "this", "->", "decodeIdsString", "(", "$", "request", ",", "'Claroline\\CoreBundle\\Entity\\User'", ")", ";", ...
Removes managers from the collection. @Route("/{id}/manager", name="apiv2_organization_remove_managers") @Method("DELETE") @ParamConverter("organization", options={"mapping": {"id": "uuid"}}) @param Organization $organization @param Request $request @return JsonResponse
[ "Removes", "managers", "from", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/User/OrganizationController.php#L116-L122
train
claroline/Distribution
main/app/API/Crud.php
Crud.create
public function create($class, $data, array $options = []) { // validates submitted data. if (!in_array(self::NO_VALIDATE, $options)) { $errors = $this->validate($class, $data, ValidatorProvider::CREATE, $options); if (count($errors) > 0) { return $errors; // todo : it should throw an Exception otherwise it makes return inconsistent } } // gets entity from raw data. $object = new $class(); $object = $this->serializer->deserialize($data, $object, $options); // creates the entity if allowed $this->checkPermission('CREATE', $object, [], true); if ($this->dispatch('create', 'pre', [$object, $options])) { $this->om->save($object); if (!in_array(Options::IGNORE_CRUD_POST_EVENT, $options)) { $this->dispatch('create', 'post', [$object, $options]); } } return $object; }
php
public function create($class, $data, array $options = []) { // validates submitted data. if (!in_array(self::NO_VALIDATE, $options)) { $errors = $this->validate($class, $data, ValidatorProvider::CREATE, $options); if (count($errors) > 0) { return $errors; // todo : it should throw an Exception otherwise it makes return inconsistent } } // gets entity from raw data. $object = new $class(); $object = $this->serializer->deserialize($data, $object, $options); // creates the entity if allowed $this->checkPermission('CREATE', $object, [], true); if ($this->dispatch('create', 'pre', [$object, $options])) { $this->om->save($object); if (!in_array(Options::IGNORE_CRUD_POST_EVENT, $options)) { $this->dispatch('create', 'post', [$object, $options]); } } return $object; }
[ "public", "function", "create", "(", "$", "class", ",", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// validates submitted data.", "if", "(", "!", "in_array", "(", "self", "::", "NO_VALIDATE", ",", "$", "options", ")", ")", "{"...
Creates a new entry for `class` and populates it with `data`. @param string $class - the class of the entity to create @param mixed $data - the serialized data of the object to create @param array $options - additional creation options @return object
[ "Creates", "a", "new", "entry", "for", "class", "and", "populates", "it", "with", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L77-L103
train
claroline/Distribution
main/app/API/Crud.php
Crud.update
public function update($class, $data, array $options = []) { // validates submitted data. if (!in_array(self::NO_VALIDATE, $options)) { $errors = $this->validate($class, $data, ValidatorProvider::UPDATE); if (count($errors) > 0) { return $errors; } } $oldObject = $this->om->getObject($data, $class) ?? new $class(); $this->checkPermission('EDIT', $oldObject, [], true); $oldData = $this->serializer->serialize($oldObject); if (!$oldData) { $oldData = []; } $object = $this->serializer->deserialize($data, $oldObject, $options); if ($this->dispatch('update', 'pre', [$object, $options, $oldData])) { $this->om->save($object); $this->dispatch('update', 'post', [$object, $options, $oldData]); } return $object; }
php
public function update($class, $data, array $options = []) { // validates submitted data. if (!in_array(self::NO_VALIDATE, $options)) { $errors = $this->validate($class, $data, ValidatorProvider::UPDATE); if (count($errors) > 0) { return $errors; } } $oldObject = $this->om->getObject($data, $class) ?? new $class(); $this->checkPermission('EDIT', $oldObject, [], true); $oldData = $this->serializer->serialize($oldObject); if (!$oldData) { $oldData = []; } $object = $this->serializer->deserialize($data, $oldObject, $options); if ($this->dispatch('update', 'pre', [$object, $options, $oldData])) { $this->om->save($object); $this->dispatch('update', 'post', [$object, $options, $oldData]); } return $object; }
[ "public", "function", "update", "(", "$", "class", ",", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// validates submitted data.", "if", "(", "!", "in_array", "(", "self", "::", "NO_VALIDATE", ",", "$", "options", ")", ")", "{"...
Updates an entry of `class` with `data`. @param string $class - the class of the entity to updates @param mixed $data - the serialized data of the object to create @param array $options - additional update options @return object
[ "Updates", "an", "entry", "of", "class", "with", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L114-L141
train
claroline/Distribution
main/app/API/Crud.php
Crud.delete
public function delete($object, array $options = []) { $this->checkPermission('DELETE', $object, [], true); if ($this->dispatch('delete', 'pre', [$object, $options])) { if (!in_array(Options::SOFT_DELETE, $options)) { $this->om->remove($object); $this->om->flush(); } $this->dispatch('delete', 'post', [$object, $options]); } }
php
public function delete($object, array $options = []) { $this->checkPermission('DELETE', $object, [], true); if ($this->dispatch('delete', 'pre', [$object, $options])) { if (!in_array(Options::SOFT_DELETE, $options)) { $this->om->remove($object); $this->om->flush(); } $this->dispatch('delete', 'post', [$object, $options]); } }
[ "public", "function", "delete", "(", "$", "object", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "checkPermission", "(", "'DELETE'", ",", "$", "object", ",", "[", "]", ",", "true", ")", ";", "if", "(", "$", "this", "-...
Deletes an entry `object`. @param object $object - the entity to delete @param array $options - additional delete options
[ "Deletes", "an", "entry", "object", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L149-L160
train
claroline/Distribution
main/app/API/Crud.php
Crud.deleteBulk
public function deleteBulk(array $data, array $options = []) { $this->om->startFlushSuite(); foreach ($data as $el) { //get the element $this->delete($el, $options); } $this->om->endFlushSuite(); }
php
public function deleteBulk(array $data, array $options = []) { $this->om->startFlushSuite(); foreach ($data as $el) { //get the element $this->delete($el, $options); } $this->om->endFlushSuite(); }
[ "public", "function", "deleteBulk", "(", "array", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "el", ")", "{", "//get th...
Deletes a list of entries of `class`. @param array $data - the list of entries to delete @param array $options - additional delete options
[ "Deletes", "a", "list", "of", "entries", "of", "class", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L168-L178
train
claroline/Distribution
main/app/API/Crud.php
Crud.copy
public function copy($object, array $options = []) { $this->checkPermission('COPY', $object, [], true); $class = get_class($object); $new = new $class(); $this->serializer->deserialize( $this->serializer->serialize($object), $new ); $this->om->persist($new); //first event is the pre one if ($this->dispatch('copy', 'pre', [$object, $options, $new])) { //second event is the post one //we could use only one event afaik $this->dispatch('copy', 'post', [$object, $options, $new]); } $this->om->flush(); return $new; }
php
public function copy($object, array $options = []) { $this->checkPermission('COPY', $object, [], true); $class = get_class($object); $new = new $class(); $this->serializer->deserialize( $this->serializer->serialize($object), $new ); $this->om->persist($new); //first event is the pre one if ($this->dispatch('copy', 'pre', [$object, $options, $new])) { //second event is the post one //we could use only one event afaik $this->dispatch('copy', 'post', [$object, $options, $new]); } $this->om->flush(); return $new; }
[ "public", "function", "copy", "(", "$", "object", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "checkPermission", "(", "'COPY'", ",", "$", "object", ",", "[", "]", ",", "true", ")", ";", "$", "class", "=", "get_class", ...
Copy an entry `object` of `class`. @param object $object - the entity to copy @param array $options - additional copy options
[ "Copy", "an", "entry", "object", "of", "class", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L186-L209
train
claroline/Distribution
main/app/API/Crud.php
Crud.copyBulk
public function copyBulk($class, array $data, array $options = []) { $this->om->startFlushSuite(); $copies = []; foreach ($data as $el) { //get the element $copies[] = $this->copy($el, $options); } $this->om->endFlushSuite(); return $copies; }
php
public function copyBulk($class, array $data, array $options = []) { $this->om->startFlushSuite(); $copies = []; foreach ($data as $el) { //get the element $copies[] = $this->copy($el, $options); } $this->om->endFlushSuite(); return $copies; }
[ "public", "function", "copyBulk", "(", "$", "class", ",", "array", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "copies", "=", "[", "]", ";", "foreach", ...
Copy a list of entries of `class`. @param string $class - the class of the entries to copy @param array $data - the list of entries to copy @param array $options - additional copy options
[ "Copy", "a", "list", "of", "entries", "of", "class", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L218-L231
train
claroline/Distribution
main/app/API/Crud.php
Crud.replace
public function replace($object, $property, $data, array $options = []) { $methodName = 'set'.ucfirst($property); if (!method_exists($object, $methodName)) { throw new \LogicException( sprintf('You have requested a non implemented action \'set\' on %s (looked for %s)', get_class($object), $methodName) ); } //add the options to pass on here $this->checkPermission('PATCH', $object, [], true); //we'll need to pass the $action and $data here aswell later if ($this->dispatch('patch', 'pre', [$object, $options, $property, $data, self::PROPERTY_SET])) { $object->$methodName($data); $this->om->save($object); $this->dispatch('patch', 'post', [$object, $options, $property, $data, self::PROPERTY_SET]); } }
php
public function replace($object, $property, $data, array $options = []) { $methodName = 'set'.ucfirst($property); if (!method_exists($object, $methodName)) { throw new \LogicException( sprintf('You have requested a non implemented action \'set\' on %s (looked for %s)', get_class($object), $methodName) ); } //add the options to pass on here $this->checkPermission('PATCH', $object, [], true); //we'll need to pass the $action and $data here aswell later if ($this->dispatch('patch', 'pre', [$object, $options, $property, $data, self::PROPERTY_SET])) { $object->$methodName($data); $this->om->save($object); $this->dispatch('patch', 'post', [$object, $options, $property, $data, self::PROPERTY_SET]); } }
[ "public", "function", "replace", "(", "$", "object", ",", "$", "property", ",", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "methodName", "=", "'set'", ".", "ucfirst", "(", "$", "property", ")", ";", "if", "(", "!", "...
Patches a property in `object`. @param object $object - the entity to update @param string $property - the property to update @param mixed $data - the data that must be set @param array $options - an array of options
[ "Patches", "a", "property", "in", "object", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L274-L293
train
claroline/Distribution
main/app/API/Crud.php
Crud.validate
public function validate($class, $data, $mode, array $options = []) { return $this->validator->validate($class, $data, $mode, true, $options); }
php
public function validate($class, $data, $mode, array $options = []) { return $this->validator->validate($class, $data, $mode, true, $options); }
[ "public", "function", "validate", "(", "$", "class", ",", "$", "data", ",", "$", "mode", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "validator", "->", "validate", "(", "$", "class", ",", "$", "data", ",", ...
Validates `data` with the available validator for `class`. @param string $class - the class of the entity used for validation @param mixed $data - the serialized data to validate @param string $mode - the validation mode
[ "Validates", "data", "with", "the", "available", "validator", "for", "class", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L302-L305
train
claroline/Distribution
main/core/Controller/APINew/DataSourceController.php
DataSourceController.listAction
public function listAction($context = null) { $widgets = $this->manager->getAvailable($context); return new JsonResponse(array_map(function (DataSource $dataSource) { return $this->serializer->serialize($dataSource); }, $widgets)); }
php
public function listAction($context = null) { $widgets = $this->manager->getAvailable($context); return new JsonResponse(array_map(function (DataSource $dataSource) { return $this->serializer->serialize($dataSource); }, $widgets)); }
[ "public", "function", "listAction", "(", "$", "context", "=", "null", ")", "{", "$", "widgets", "=", "$", "this", "->", "manager", "->", "getAvailable", "(", "$", "context", ")", ";", "return", "new", "JsonResponse", "(", "array_map", "(", "function", "(...
Lists available data sources for a given context. @EXT\Route("/{context}", name="apiv2_data_source_list", defaults={"context"=null}) @EXT\Method("GET") @param string $context @return JsonResponse
[ "Lists", "available", "data", "sources", "for", "a", "given", "context", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/DataSourceController.php#L63-L70
train
claroline/Distribution
main/core/Controller/APINew/DataSourceController.php
DataSourceController.loadAction
public function loadAction(Request $request, $type, $context, $contextId = null) { if (!$this->manager->check($type, $context)) { return new JsonResponse('Unknown data source.', 404); } return new JsonResponse( $this->manager->load($type, $context, $contextId, $request->query->all()) ); }
php
public function loadAction(Request $request, $type, $context, $contextId = null) { if (!$this->manager->check($type, $context)) { return new JsonResponse('Unknown data source.', 404); } return new JsonResponse( $this->manager->load($type, $context, $contextId, $request->query->all()) ); }
[ "public", "function", "loadAction", "(", "Request", "$", "request", ",", "$", "type", ",", "$", "context", ",", "$", "contextId", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "manager", "->", "check", "(", "$", "type", ",", "$", "conte...
Gets data from a data source. @EXT\Route("/{type}/{context}/{contextId}", name="apiv2_data_source", defaults={"contextId"=null}) @EXT\Method("GET") @param Request $request @param string $type @param string $context @param string $contextId @return JsonResponse
[ "Gets", "data", "from", "a", "data", "source", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/DataSourceController.php#L85-L94
train