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
ezsystems/ezpublish-legacy
kernel/classes/ezsearch.php
eZSearch.updateObjectState
public static function updateObjectState( $objectID, $objectStateList ) { $searchEngine = eZSearch::getEngine(); if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'updateObjectState' ) ) { return $searchEngine->updateObjectState( $objectID, $objectStateList ); } return false; }
php
public static function updateObjectState( $objectID, $objectStateList ) { $searchEngine = eZSearch::getEngine(); if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'updateObjectState' ) ) { return $searchEngine->updateObjectState( $objectID, $objectStateList ); } return false; }
[ "public", "static", "function", "updateObjectState", "(", "$", "objectID", ",", "$", "objectStateList", ")", "{", "$", "searchEngine", "=", "eZSearch", "::", "getEngine", "(", ")", ";", "if", "(", "$", "searchEngine", "instanceof", "ezpSearchEngine", "&&", "me...
Notifies search engine about updates to object states @since 4.1 @param int $objectID @param array $objectStateList @return false|mixed False in case method is undefined, otherwise return the result of the search engine call
[ "Notifies", "search", "engine", "about", "updates", "to", "object", "states" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsearch.php#L625-L635
train
ezsystems/ezpublish-legacy
kernel/classes/ezsearch.php
eZSearch.swapNode
public static function swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() ) { $searchEngine = eZSearch::getEngine(); if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'swapNode' ) ) { return $searchEngine->swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() ); } return false; }
php
public static function swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() ) { $searchEngine = eZSearch::getEngine(); if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'swapNode' ) ) { return $searchEngine->swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() ); } return false; }
[ "public", "static", "function", "swapNode", "(", "$", "nodeID", ",", "$", "selectedNodeID", ",", "$", "nodeIdList", "=", "array", "(", ")", ")", "{", "$", "searchEngine", "=", "eZSearch", "::", "getEngine", "(", ")", ";", "if", "(", "$", "searchEngine", ...
Notifies search engine about an swap node operation @since 4.1 @param int $nodeID @param int $selectedNodeID @param array $nodeIdList @return false|mixed False in case method is undefined, otherwise return the result of the search engine call
[ "Notifies", "search", "engine", "about", "an", "swap", "node", "operation" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsearch.php#L646-L656
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/renderers/xhtml_content_renderer.php
ezpContentXHTMLRenderer.render
public function render() { $tpl = eZTemplate::factory(); $ini = eZINI::instance( 'rest.ini' ); $nodeViewData = eZNodeviewfunctions::generateNodeViewData( $tpl, $this->content->main_node, $this->content->main_node->attribute( 'object' ), $this->content->activeLanguage, 'rest', 0 ); $tpl->setVariable( 'module_result', $nodeViewData ); $routingInfos = $this->controller->getRouter()->getRoutingInformation(); $templateName = $ini->variable( $routingInfos->controllerClass . '_'. $routingInfos->action . '_OutputSettings', 'Template' ); return $tpl->fetch( 'design:' . $templateName ); }
php
public function render() { $tpl = eZTemplate::factory(); $ini = eZINI::instance( 'rest.ini' ); $nodeViewData = eZNodeviewfunctions::generateNodeViewData( $tpl, $this->content->main_node, $this->content->main_node->attribute( 'object' ), $this->content->activeLanguage, 'rest', 0 ); $tpl->setVariable( 'module_result', $nodeViewData ); $routingInfos = $this->controller->getRouter()->getRoutingInformation(); $templateName = $ini->variable( $routingInfos->controllerClass . '_'. $routingInfos->action . '_OutputSettings', 'Template' ); return $tpl->fetch( 'design:' . $templateName ); }
[ "public", "function", "render", "(", ")", "{", "$", "tpl", "=", "eZTemplate", "::", "factory", "(", ")", ";", "$", "ini", "=", "eZINI", "::", "instance", "(", "'rest.ini'", ")", ";", "$", "nodeViewData", "=", "eZNodeviewfunctions", "::", "generateNodeViewD...
Returns string with rendered content @return string
[ "Returns", "string", "with", "rendered", "content" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/renderers/xhtml_content_renderer.php#L29-L42
train
ezsystems/ezpublish-legacy
kernel/classes/datatypes/ezobjectrelationlist/ezobjectrelationlisttype.php
eZObjectRelationListType.appendObject
public function appendObject( $objectID, $priority, $contentObjectAttribute ) { $object = eZContentObject::fetch( $objectID ); if ( null === $object ) { return; } $class = $object->attribute( 'content_class' ); $sectionID = $object->attribute( 'section_id' ); $relationItem = array( 'identifier' => false, 'priority' => $priority, 'in_trash' => false, 'contentobject_id' => $object->attribute( 'id' ), 'contentobject_version' => $object->attribute( 'current_version' ), 'contentobject_remote_id' => $object->attribute( 'remote_id' ), 'node_id' => $object->attribute( 'main_node_id' ), 'parent_node_id' => $object->attribute( 'main_parent_node_id' ), 'contentclass_id' => $class->attribute( 'id' ), 'contentclass_identifier' => $class->attribute( 'identifier' ), 'is_modified' => false ); $relationItem['object'] = $object; return $relationItem; }
php
public function appendObject( $objectID, $priority, $contentObjectAttribute ) { $object = eZContentObject::fetch( $objectID ); if ( null === $object ) { return; } $class = $object->attribute( 'content_class' ); $sectionID = $object->attribute( 'section_id' ); $relationItem = array( 'identifier' => false, 'priority' => $priority, 'in_trash' => false, 'contentobject_id' => $object->attribute( 'id' ), 'contentobject_version' => $object->attribute( 'current_version' ), 'contentobject_remote_id' => $object->attribute( 'remote_id' ), 'node_id' => $object->attribute( 'main_node_id' ), 'parent_node_id' => $object->attribute( 'main_parent_node_id' ), 'contentclass_id' => $class->attribute( 'id' ), 'contentclass_identifier' => $class->attribute( 'identifier' ), 'is_modified' => false ); $relationItem['object'] = $object; return $relationItem; }
[ "public", "function", "appendObject", "(", "$", "objectID", ",", "$", "priority", ",", "$", "contentObjectAttribute", ")", "{", "$", "object", "=", "eZContentObject", "::", "fetch", "(", "$", "objectID", ")", ";", "if", "(", "null", "===", "$", "object", ...
Generate array with object relation info @param integer $objectID The id of the object to add as relation @param integer $priority The priortity of the relation @param eZContentObjectAttribute $contentObjectAttribute Not used @return array|null A array containing relation information or null if object does not exist
[ "Generate", "array", "with", "object", "relation", "info" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezobjectrelationlist/ezobjectrelationlisttype.php#L1313-L1337
train
ezsystems/ezpublish-legacy
extension/ezoe/modules/ezoe/classes/GoogleSpell.php
GoogleSpell.&
function &getSuggestions($lang, $word) { $sug = array(); $osug = array(); $matches = $this->_getMatches($lang, $word); if (count($matches) > 0) $sug = explode("\t", $this->_unhtmlentities($matches[0][4])); // Remove empty foreach ($sug as $item) { if ($item) $osug[] = $item; } return $osug; }
php
function &getSuggestions($lang, $word) { $sug = array(); $osug = array(); $matches = $this->_getMatches($lang, $word); if (count($matches) > 0) $sug = explode("\t", $this->_unhtmlentities($matches[0][4])); // Remove empty foreach ($sug as $item) { if ($item) $osug[] = $item; } return $osug; }
[ "function", "&", "getSuggestions", "(", "$", "lang", ",", "$", "word", ")", "{", "$", "sug", "=", "array", "(", ")", ";", "$", "osug", "=", "array", "(", ")", ";", "$", "matches", "=", "$", "this", "->", "_getMatches", "(", "$", "lang", ",", "$...
Returns suggestions of for a specific word. @param {String} $lang Language code like sv or en. @param {String} $word Specific word to get suggestions for. @return {Array} Array of suggestions for the specified word.
[ "Returns", "suggestions", "of", "for", "a", "specific", "word", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezoe/modules/ezoe/classes/GoogleSpell.php#L35-L50
train
ezsystems/ezpublish-legacy
kernel/classes/ezscript.php
eZScript.updateSettings
private function updateSettings( array $settings = array() ) { if ( isset( $settings['debug-message'] ) ) $this->DebugMessage = $settings['debug-message']; if ( isset( $settings['debug-output'] ) ) $this->UseDebugOutput = $settings['debug-output']; if ( isset( $settings['debug-levels'] ) ) $this->AllowedDebugLevels = $settings['debug-levels']; if ( isset( $settings['debug-accumulator'] ) ) $this->UseDebugAccumulators = $settings['debug-accumulator']; if ( isset( $settings['debug-timing'] ) ) $this->UseDebugTimingPoints = $settings['debug-timing']; if ( isset( $settings['debug-include'] ) ) $this->UseIncludeFiles = $settings['debug-include']; if ( isset( $settings['use-session'] ) ) $this->UseSession = $settings['use-session']; if ( isset( $settings['use-modules'] ) ) $this->UseModules = $settings['use-modules']; if ( isset( $settings['use-extensions'] ) ) $this->UseExtensions = $settings['use-extensions']; if ( isset( $settings['user'] ) ) $this->User = $settings['user']; if ( isset( $settings['site-access'] ) ) $this->SiteAccess = $settings['site-access']; if ( isset( $settings['description'] ) ) $this->Description = $settings['description']; if ( isset( $settings['min_version'] ) ) $this->MinVersion = $settings['min_version']; if ( isset( $settings['max_version'] ) ) $this->MaxVersion = $settings['max_version']; }
php
private function updateSettings( array $settings = array() ) { if ( isset( $settings['debug-message'] ) ) $this->DebugMessage = $settings['debug-message']; if ( isset( $settings['debug-output'] ) ) $this->UseDebugOutput = $settings['debug-output']; if ( isset( $settings['debug-levels'] ) ) $this->AllowedDebugLevels = $settings['debug-levels']; if ( isset( $settings['debug-accumulator'] ) ) $this->UseDebugAccumulators = $settings['debug-accumulator']; if ( isset( $settings['debug-timing'] ) ) $this->UseDebugTimingPoints = $settings['debug-timing']; if ( isset( $settings['debug-include'] ) ) $this->UseIncludeFiles = $settings['debug-include']; if ( isset( $settings['use-session'] ) ) $this->UseSession = $settings['use-session']; if ( isset( $settings['use-modules'] ) ) $this->UseModules = $settings['use-modules']; if ( isset( $settings['use-extensions'] ) ) $this->UseExtensions = $settings['use-extensions']; if ( isset( $settings['user'] ) ) $this->User = $settings['user']; if ( isset( $settings['site-access'] ) ) $this->SiteAccess = $settings['site-access']; if ( isset( $settings['description'] ) ) $this->Description = $settings['description']; if ( isset( $settings['min_version'] ) ) $this->MinVersion = $settings['min_version']; if ( isset( $settings['max_version'] ) ) $this->MaxVersion = $settings['max_version']; }
[ "private", "function", "updateSettings", "(", "array", "$", "settings", "=", "array", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "settings", "[", "'debug-message'", "]", ")", ")", "$", "this", "->", "DebugMessage", "=", "$", "settings", "[", "'d...
Updates settings for current script. Valid keys for $settings are : - use-session - use-modules - use-extensions - user - site-access - description - min_version - max_version - debug-message - debug-output - debug-levels - debug-accumulator - debug-timing - debug-include @param array $settings
[ "Updates", "settings", "for", "current", "script", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezscript.php#L114-L144
train
ezsystems/ezpublish-legacy
kernel/classes/ezscript.php
eZScript.instance
static function instance( $settings = array() ) { if ( !isset( $GLOBALS['eZScriptInstance'] ) || !( $GLOBALS['eZScriptInstance'] instanceof eZScript ) ) { $GLOBALS['eZScriptInstance'] = new eZScript( $settings ); } else if ( !empty( $settings ) ) { $GLOBALS['eZScriptInstance']->updateSettings( $settings ); } return $GLOBALS['eZScriptInstance']; }
php
static function instance( $settings = array() ) { if ( !isset( $GLOBALS['eZScriptInstance'] ) || !( $GLOBALS['eZScriptInstance'] instanceof eZScript ) ) { $GLOBALS['eZScriptInstance'] = new eZScript( $settings ); } else if ( !empty( $settings ) ) { $GLOBALS['eZScriptInstance']->updateSettings( $settings ); } return $GLOBALS['eZScriptInstance']; }
[ "static", "function", "instance", "(", "$", "settings", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "GLOBALS", "[", "'eZScriptInstance'", "]", ")", "||", "!", "(", "$", "GLOBALS", "[", "'eZScriptInstance'", "]", "instanceof", "...
Returns a shared instance of the eZScript class. @param array $settings Used by the first generated instance, but ignored for subsequent calls. @return eZScript
[ "Returns", "a", "shared", "instance", "of", "the", "eZScript", "class", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezscript.php#L1103-L1118
train
ezsystems/ezpublish-legacy
kernel/classes/ezrole.php
eZRole.fetchByUser
static function fetchByUser( $idArray, $recursive = false ) { if ( count( $idArray ) < 1 ) { return array(); } $db = eZDB::instance(); if ( !$recursive ) { $groupINSQL = $db->generateSQLINStatement( $idArray, 'ezuser_role.contentobject_id', false, false, 'int' ); $query = "SELECT DISTINCT ezrole.id, ezrole.name, ezuser_role.limit_identifier, ezuser_role.limit_value, ezuser_role.id as user_role_id FROM ezrole, ezuser_role WHERE $groupINSQL AND ezuser_role.role_id = ezrole.id"; } else { $userNodeIDArray = array(); foreach( $idArray as $id ) { $nodeDefinition = eZContentObjectTreeNode::fetchByContentObjectID( $id ); foreach ( $nodeDefinition as $nodeDefinitionElement ) { $userNodeIDArray = array_merge( $nodeDefinitionElement->attribute( 'path_array' ), $userNodeIDArray ); } } if ( count( $userNodeIDArray ) < 1 ) { return array(); } $roleTreeINSQL = $db->generateSQLINStatement( $userNodeIDArray, 'role_tree.node_id', false, false, 'int' ); $query = "SELECT DISTINCT ezrole.id, ezrole.name, ezuser_role.limit_identifier, ezuser_role.limit_value, ezuser_role.id as user_role_id FROM ezrole, ezuser_role, ezcontentobject_tree role_tree WHERE ezuser_role.contentobject_id = role_tree.contentobject_id AND ezuser_role.role_id = ezrole.id AND $roleTreeINSQL"; } $roleArray = $db->arrayQuery( $query ); $roles = array(); foreach ( $roleArray as $roleRow ) { $role = new eZRole( $roleRow ); $roles[] = $role; } return $roles; }
php
static function fetchByUser( $idArray, $recursive = false ) { if ( count( $idArray ) < 1 ) { return array(); } $db = eZDB::instance(); if ( !$recursive ) { $groupINSQL = $db->generateSQLINStatement( $idArray, 'ezuser_role.contentobject_id', false, false, 'int' ); $query = "SELECT DISTINCT ezrole.id, ezrole.name, ezuser_role.limit_identifier, ezuser_role.limit_value, ezuser_role.id as user_role_id FROM ezrole, ezuser_role WHERE $groupINSQL AND ezuser_role.role_id = ezrole.id"; } else { $userNodeIDArray = array(); foreach( $idArray as $id ) { $nodeDefinition = eZContentObjectTreeNode::fetchByContentObjectID( $id ); foreach ( $nodeDefinition as $nodeDefinitionElement ) { $userNodeIDArray = array_merge( $nodeDefinitionElement->attribute( 'path_array' ), $userNodeIDArray ); } } if ( count( $userNodeIDArray ) < 1 ) { return array(); } $roleTreeINSQL = $db->generateSQLINStatement( $userNodeIDArray, 'role_tree.node_id', false, false, 'int' ); $query = "SELECT DISTINCT ezrole.id, ezrole.name, ezuser_role.limit_identifier, ezuser_role.limit_value, ezuser_role.id as user_role_id FROM ezrole, ezuser_role, ezcontentobject_tree role_tree WHERE ezuser_role.contentobject_id = role_tree.contentobject_id AND ezuser_role.role_id = ezrole.id AND $roleTreeINSQL"; } $roleArray = $db->arrayQuery( $query ); $roles = array(); foreach ( $roleArray as $roleRow ) { $role = new eZRole( $roleRow ); $roles[] = $role; } return $roles; }
[ "static", "function", "fetchByUser", "(", "$", "idArray", ",", "$", "recursive", "=", "false", ")", "{", "if", "(", "count", "(", "$", "idArray", ")", "<", "1", ")", "{", "return", "array", "(", ")", ";", "}", "$", "db", "=", "eZDB", "::", "insta...
Returns the roles matching the given users' eZContentObject ID array @param array $idArray Array of eZContentObject IDs, either groups + user id or user id's only If only user id's, then remember to set $recursive to true @param bool $recursive If true, roles will be looked up for all nodes of the id's and it's parents @return array(eZRole)
[ "Returns", "the", "roles", "matching", "the", "given", "users", "eZContentObject", "ID", "array" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezrole.php#L463-L526
train
ezsystems/ezpublish-legacy
kernel/classes/ezrole.php
eZRole.accessArrayByUserID
static function accessArrayByUserID( $idArray, $recursive = false ) { $roles = eZRole::fetchByUser( $idArray, $recursive ); $userLimitation = false; $accessArray = array(); foreach ( array_keys ( $roles ) as $roleKey ) { $accessArray = array_merge_recursive( $accessArray, $roles[$roleKey]->accessArray() ); if ( $roles[$roleKey]->attribute( 'limit_identifier' ) ) { $userLimitation = true; } } if ( $userLimitation ) { foreach( $accessArray as $moduleKey => $functionList ) { foreach( $functionList as $functionKey => $policyList ) { foreach( $policyList as $policyKey => $limitationList ) { if ( is_array( $limitationList ) ) { foreach( $limitationList as $limitationKey => $limitKeyArray ) { if ( is_array( $limitKeyArray ) ) { $accessArray[$moduleKey][$functionKey][$policyKey][$limitationKey] = array_unique( $limitKeyArray ); } } } } } } } return $accessArray; }
php
static function accessArrayByUserID( $idArray, $recursive = false ) { $roles = eZRole::fetchByUser( $idArray, $recursive ); $userLimitation = false; $accessArray = array(); foreach ( array_keys ( $roles ) as $roleKey ) { $accessArray = array_merge_recursive( $accessArray, $roles[$roleKey]->accessArray() ); if ( $roles[$roleKey]->attribute( 'limit_identifier' ) ) { $userLimitation = true; } } if ( $userLimitation ) { foreach( $accessArray as $moduleKey => $functionList ) { foreach( $functionList as $functionKey => $policyList ) { foreach( $policyList as $policyKey => $limitationList ) { if ( is_array( $limitationList ) ) { foreach( $limitationList as $limitationKey => $limitKeyArray ) { if ( is_array( $limitKeyArray ) ) { $accessArray[$moduleKey][$functionKey][$policyKey][$limitationKey] = array_unique( $limitKeyArray ); } } } } } } } return $accessArray; }
[ "static", "function", "accessArrayByUserID", "(", "$", "idArray", ",", "$", "recursive", "=", "false", ")", "{", "$", "roles", "=", "eZRole", "::", "fetchByUser", "(", "$", "idArray", ",", "$", "recursive", ")", ";", "$", "userLimitation", "=", "false", ...
Return access array by passing in list of groups user belongs to and his user id @param array $idArray Array of eZContentObject IDs, either groups + user id or user id's only If only user id's, then remember to set $recursive to true @param bool $recursive See {@link eZRole::fetchByUser()} @return array Hash with complete access limitation description
[ "Return", "access", "array", "by", "passing", "in", "list", "of", "groups", "user", "belongs", "to", "and", "his", "user", "id" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezrole.php#L550-L588
train
ezsystems/ezpublish-legacy
kernel/classes/ezrole.php
eZRole.roleCount
static function roleCount( $ignoreNew = true ) { $conds = array( 'version' => 0 ); if ( $ignoreNew === true ) { $conds['is_new'] = 0; } return eZPersistentObject::count( eZRole::definition(), $conds ); }
php
static function roleCount( $ignoreNew = true ) { $conds = array( 'version' => 0 ); if ( $ignoreNew === true ) { $conds['is_new'] = 0; } return eZPersistentObject::count( eZRole::definition(), $conds ); }
[ "static", "function", "roleCount", "(", "$", "ignoreNew", "=", "true", ")", "{", "$", "conds", "=", "array", "(", "'version'", "=>", "0", ")", ";", "if", "(", "$", "ignoreNew", "===", "true", ")", "{", "$", "conds", "[", "'is_new'", "]", "=", "0", ...
Fetches the count of created roles @static @param boolean $ignoreNew Wether to ignore draft roles @return int
[ "Fetches", "the", "count", "of", "created", "roles" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezrole.php#L892-L900
train
ezsystems/ezpublish-legacy
kernel/classes/ezrssexport.php
eZRSSExport.rssXmlContent
function rssXmlContent() { try { switch ( $this->attribute( 'rss_version' ) ) { case '1.0': { return $this->generateFeed( 'rss1' ); } break; case '2.0': { return $this->generateFeed( 'rss2' ); } break; case 'ATOM': { return $this->generateFeed( 'atom' ); } break; default: { return null; } break; } } catch ( ezcFeedException $e ) { return '<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang=""><title>The RSS feed you were trying to access contains some errors and cannot be generated: ' . $e->getMessage() . ' Please contact the webmaster.</title></feed>'; } return null; }
php
function rssXmlContent() { try { switch ( $this->attribute( 'rss_version' ) ) { case '1.0': { return $this->generateFeed( 'rss1' ); } break; case '2.0': { return $this->generateFeed( 'rss2' ); } break; case 'ATOM': { return $this->generateFeed( 'atom' ); } break; default: { return null; } break; } } catch ( ezcFeedException $e ) { return '<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang=""><title>The RSS feed you were trying to access contains some errors and cannot be generated: ' . $e->getMessage() . ' Please contact the webmaster.</title></feed>'; } return null; }
[ "function", "rssXmlContent", "(", ")", "{", "try", "{", "switch", "(", "$", "this", "->", "attribute", "(", "'rss_version'", ")", ")", "{", "case", "'1.0'", ":", "{", "return", "$", "this", "->", "generateFeed", "(", "'rss1'", ")", ";", "}", "break", ...
Generates an RSS feed document based on the rss_version attribute. It uses the Feed component from eZ Components. Supported types: 'rss1', 'rss2', 'atom'. @since 4.2 @return string XML document as a string
[ "Generates", "an", "RSS", "feed", "document", "based", "on", "the", "rss_version", "attribute", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezrssexport.php#L293-L326
train
ezsystems/ezpublish-legacy
kernel/user/ezuseroperationcollection.php
eZUserOperationCollection.setSettings
static public function setSettings( $userID, $isEnabled, $maxLogin ) { $userSetting = eZUserSetting::fetch( $userID ); if ( $userSetting ) { $userSetting->setAttribute( 'max_login', $maxLogin ); $isUserEnabled = $isEnabled != 0; if ( $userSetting->attribute( 'is_enabled' ) != $isUserEnabled ) { eZContentCacheManager::clearContentCacheIfNeeded( $userID ); eZContentCacheManager::generateObjectViewCache( $userID ); } $userSetting->setAttribute( "is_enabled", $isUserEnabled ); $userSetting->store(); if ( !$isUserEnabled ) { eZUser::removeSessionData( $userID ); } else { eZUserAccountKey::removeByUserID( $userID ); } return array( 'status' => true ); } else { eZDebug::writeError( "Failed to change settings of user $userID ", __METHOD__ ); return array( 'status' => false ); } }
php
static public function setSettings( $userID, $isEnabled, $maxLogin ) { $userSetting = eZUserSetting::fetch( $userID ); if ( $userSetting ) { $userSetting->setAttribute( 'max_login', $maxLogin ); $isUserEnabled = $isEnabled != 0; if ( $userSetting->attribute( 'is_enabled' ) != $isUserEnabled ) { eZContentCacheManager::clearContentCacheIfNeeded( $userID ); eZContentCacheManager::generateObjectViewCache( $userID ); } $userSetting->setAttribute( "is_enabled", $isUserEnabled ); $userSetting->store(); if ( !$isUserEnabled ) { eZUser::removeSessionData( $userID ); } else { eZUserAccountKey::removeByUserID( $userID ); } return array( 'status' => true ); } else { eZDebug::writeError( "Failed to change settings of user $userID ", __METHOD__ ); return array( 'status' => false ); } }
[ "static", "public", "function", "setSettings", "(", "$", "userID", ",", "$", "isEnabled", ",", "$", "maxLogin", ")", "{", "$", "userSetting", "=", "eZUserSetting", "::", "fetch", "(", "$", "userID", ")", ";", "if", "(", "$", "userSetting", ")", "{", "$...
Changes user settings @param int $userID @param int $isEnabled @param int $maxLogin @return array An array with operation status, always true if userID is ok
[ "Changes", "user", "settings" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/user/ezuseroperationcollection.php#L28-L61
train
ezsystems/ezpublish-legacy
kernel/user/ezuseroperationcollection.php
eZUserOperationCollection.publishUserContentObject
static public function publishUserContentObject( $userID ) { $object = eZContentObject::fetch( $userID ); if( $object->attribute( 'current_version' ) !== '1' ) { eZDebug::writeError( 'Current version is wrong for the user object. User ID: ' . $userID , 'user/register' ); return array( 'status' => eZModuleOperationInfo::STATUS_CANCELLED ); } eZDebugSetting::writeNotice( 'kernel-user' , 'publishing user object', 'user register' ); // if the object is already published, continue the operation if( $object->attribute( 'status' ) ) { eZDebugSetting::writeNotice( 'kernel-user', 'User object publish is published.', 'user register' ); return array( 'status' => eZModuleOperationInfo::STATUS_CONTINUE ); } $result = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $userID, 'version' => 1 ) ); if( $result['status'] === eZModuleOperationInfo::STATUS_HALTED ) { eZDebugSetting::writeNotice( 'kernel-user', 'User object publish is in pending.', 'user register' ); return array( 'status' => eZModuleOperationInfo::STATUS_HALTED ); } return $result; }
php
static public function publishUserContentObject( $userID ) { $object = eZContentObject::fetch( $userID ); if( $object->attribute( 'current_version' ) !== '1' ) { eZDebug::writeError( 'Current version is wrong for the user object. User ID: ' . $userID , 'user/register' ); return array( 'status' => eZModuleOperationInfo::STATUS_CANCELLED ); } eZDebugSetting::writeNotice( 'kernel-user' , 'publishing user object', 'user register' ); // if the object is already published, continue the operation if( $object->attribute( 'status' ) ) { eZDebugSetting::writeNotice( 'kernel-user', 'User object publish is published.', 'user register' ); return array( 'status' => eZModuleOperationInfo::STATUS_CONTINUE ); } $result = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $userID, 'version' => 1 ) ); if( $result['status'] === eZModuleOperationInfo::STATUS_HALTED ) { eZDebugSetting::writeNotice( 'kernel-user', 'User object publish is in pending.', 'user register' ); return array( 'status' => eZModuleOperationInfo::STATUS_HALTED ); } return $result; }
[ "static", "public", "function", "publishUserContentObject", "(", "$", "userID", ")", "{", "$", "object", "=", "eZContentObject", "::", "fetch", "(", "$", "userID", ")", ";", "if", "(", "$", "object", "->", "attribute", "(", "'current_version'", ")", "!==", ...
publish the object
[ "publish", "the", "object" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/user/ezuseroperationcollection.php#L179-L201
train
ezsystems/ezpublish-legacy
kernel/user/ezuseroperationcollection.php
eZUserOperationCollection.sendUserNotification
static public function sendUserNotification( $userID ) { $ini = eZINI::instance(); if ( $ini->variable( 'UserSettings', 'EmailRegistrationInfo' ) === "disabled" ) { return array( 'status' => eZModuleOperationInfo::STATUS_CONTINUE ); } eZDebugSetting::writeNotice( 'Sending approval notification to the user.' , 'kernel-user', 'user register' ); $user = eZUser::fetch( $userID ); // Send mail $tpl = eZTemplate::factory(); $tpl->setVariable( 'user', $user ); $templateResult = $tpl->fetch( 'design:user/registrationapproved.tpl' ); $mail = new eZMail(); if ( $tpl->hasVariable( 'content_type' ) ) $mail->setContentType( $tpl->variable( 'content_type' ) ); $emailSender = $ini->variable( 'MailSettings', 'EmailSender' ); if ( $tpl->hasVariable( 'email_sender' ) ) $emailSender = $tpl->variable( 'email_sender' ); else if ( !$emailSender ) $emailSender = $ini->variable( 'MailSettings', 'AdminEmail' ); if ( $tpl->hasVariable( 'subject' ) ) $subject = $tpl->variable( 'subject' ); else $subject = ezpI18n::tr( 'kernel/user/register', 'User registration approved' ); $mail->setSender( $emailSender ); $receiver = $user->attribute( 'email' ); $mail->setReceiver( $receiver ); $mail->setSubject( $subject ); $mail->setBody( $templateResult ); $mailResult = eZMailTransport::send( $mail ); return array( 'status' => eZModuleOperationInfo::STATUS_CONTINUE ); }
php
static public function sendUserNotification( $userID ) { $ini = eZINI::instance(); if ( $ini->variable( 'UserSettings', 'EmailRegistrationInfo' ) === "disabled" ) { return array( 'status' => eZModuleOperationInfo::STATUS_CONTINUE ); } eZDebugSetting::writeNotice( 'Sending approval notification to the user.' , 'kernel-user', 'user register' ); $user = eZUser::fetch( $userID ); // Send mail $tpl = eZTemplate::factory(); $tpl->setVariable( 'user', $user ); $templateResult = $tpl->fetch( 'design:user/registrationapproved.tpl' ); $mail = new eZMail(); if ( $tpl->hasVariable( 'content_type' ) ) $mail->setContentType( $tpl->variable( 'content_type' ) ); $emailSender = $ini->variable( 'MailSettings', 'EmailSender' ); if ( $tpl->hasVariable( 'email_sender' ) ) $emailSender = $tpl->variable( 'email_sender' ); else if ( !$emailSender ) $emailSender = $ini->variable( 'MailSettings', 'AdminEmail' ); if ( $tpl->hasVariable( 'subject' ) ) $subject = $tpl->variable( 'subject' ); else $subject = ezpI18n::tr( 'kernel/user/register', 'User registration approved' ); $mail->setSender( $emailSender ); $receiver = $user->attribute( 'email' ); $mail->setReceiver( $receiver ); $mail->setSubject( $subject ); $mail->setBody( $templateResult ); $mailResult = eZMailTransport::send( $mail ); return array( 'status' => eZModuleOperationInfo::STATUS_CONTINUE ); }
[ "static", "public", "function", "sendUserNotification", "(", "$", "userID", ")", "{", "$", "ini", "=", "eZINI", "::", "instance", "(", ")", ";", "if", "(", "$", "ini", "->", "variable", "(", "'UserSettings'", ",", "'EmailRegistrationInfo'", ")", "===", "\"...
Send the notification after registeration
[ "Send", "the", "notification", "after", "registeration" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/user/ezuseroperationcollection.php#L206-L245
train
ezsystems/ezpublish-legacy
kernel/user/ezuseroperationcollection.php
eZUserOperationCollection.updateUserDraft
static private function updateUserDraft( $user ) { $userObject = eZContentObject::fetch( $user->id() ); foreach ( $userObject->dataMap() as $attribute ) { if ( $attribute->ContentClassAttributeIdentifier == 'user_account' ) { $attribute->setAttribute( 'data_text', eZUserType::serializeDraft( $user ) ); $attribute->store(); break; } } }
php
static private function updateUserDraft( $user ) { $userObject = eZContentObject::fetch( $user->id() ); foreach ( $userObject->dataMap() as $attribute ) { if ( $attribute->ContentClassAttributeIdentifier == 'user_account' ) { $attribute->setAttribute( 'data_text', eZUserType::serializeDraft( $user ) ); $attribute->store(); break; } } }
[ "static", "private", "function", "updateUserDraft", "(", "$", "user", ")", "{", "$", "userObject", "=", "eZContentObject", "::", "fetch", "(", "$", "user", "->", "id", "(", ")", ")", ";", "foreach", "(", "$", "userObject", "->", "dataMap", "(", ")", "a...
Update the "draft" of a given user @param $user eZUser
[ "Update", "the", "draft", "of", "a", "given", "user" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/user/ezuseroperationcollection.php#L340-L353
train
ezsystems/ezpublish-legacy
kernel/user/ezuseroperationcollection.php
eZUserOperationCollection.forgotpassword
static public function forgotpassword( $userID, $passwordHash, $time ) { $user = eZUser::fetch( $userID ); if ( $user instanceof eZUser ) { $forgotPasswdObj = eZForgotPassword::createNew( $userID, $passwordHash, $time ); $forgotPasswdObj->store(); return array( 'status' => true ); } else { eZDebug::writeError( "Failed to generate password hash for user $userID (could not fetch user)", __METHOD__ ); return array( 'status' => false ); } }
php
static public function forgotpassword( $userID, $passwordHash, $time ) { $user = eZUser::fetch( $userID ); if ( $user instanceof eZUser ) { $forgotPasswdObj = eZForgotPassword::createNew( $userID, $passwordHash, $time ); $forgotPasswdObj->store(); return array( 'status' => true ); } else { eZDebug::writeError( "Failed to generate password hash for user $userID (could not fetch user)", __METHOD__ ); return array( 'status' => false ); } }
[ "static", "public", "function", "forgotpassword", "(", "$", "userID", ",", "$", "passwordHash", ",", "$", "time", ")", "{", "$", "user", "=", "eZUser", "::", "fetch", "(", "$", "userID", ")", ";", "if", "(", "$", "user", "instanceof", "eZUser", ")", ...
Generate forgotpassword object @param int $userID @param string $passwordHash @param int $time @return array An array with operation status, always true if userID is ok
[ "Generate", "forgotpassword", "object" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/user/ezuseroperationcollection.php#L364-L379
train
ezsystems/ezpublish-legacy
kernel/classes/datatypes/ezxmltext/ezxmlschema.php
eZXMLSchema.isInline
function isInline( $element ) { if ( is_string( $element ) ) $elementName = $element; else $elementName = $element->nodeName; $isInline = $this->Schema[$elementName]['isInline']; // Special workaround for custom tags. if ( is_array( $isInline ) && !is_string( $element ) ) { $isInline = false; $name = $element->getAttribute( 'name' ); if ( isset( $this->Schema['custom']['isInline'][$name] ) ) { if ( $this->Schema['custom']['isInline'][$name] != 'false' ) $isInline = true; } } return $isInline; }
php
function isInline( $element ) { if ( is_string( $element ) ) $elementName = $element; else $elementName = $element->nodeName; $isInline = $this->Schema[$elementName]['isInline']; // Special workaround for custom tags. if ( is_array( $isInline ) && !is_string( $element ) ) { $isInline = false; $name = $element->getAttribute( 'name' ); if ( isset( $this->Schema['custom']['isInline'][$name] ) ) { if ( $this->Schema['custom']['isInline'][$name] != 'false' ) $isInline = true; } } return $isInline; }
[ "function", "isInline", "(", "$", "element", ")", "{", "if", "(", "is_string", "(", "$", "element", ")", ")", "$", "elementName", "=", "$", "element", ";", "else", "$", "elementName", "=", "$", "element", "->", "nodeName", ";", "$", "isInline", "=", ...
Determines if the tag is inline
[ "Determines", "if", "the", "tag", "is", "inline" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezxmltext/ezxmlschema.php#L234-L256
train
ezsystems/ezpublish-legacy
lib/eztemplate/classes/eztemplatecompiler.php
eZTemplateCompiler.executeCompilation
static function executeCompilation( $tpl, &$textElements, $key, &$resourceData, $rootNamespace, $currentNamespace ) { if ( !eZTemplateCompiler::isCompilationEnabled() ) return false; if ( !eZTemplateCompiler::isExecutionEnabled() ) return false; $cacheFileName = eZTemplateCompiler::compilationFilename( $key, $resourceData ); $resourceData['use-comments'] = eZTemplateCompiler::isCommentsEnabled(); $directory = eZTemplateCompiler::compilationDirectory(); $phpScript = eZDir::path( array( $directory, $cacheFileName ) ); if ( file_exists( $phpScript ) ) { $text = false; $helperStatus = eZTemplateCompiler::executeCompilationHelper( $phpScript, $text, $tpl, $key, $resourceData, $rootNamespace, $currentNamespace ); if ( $helperStatus ) { $textElements[] = $text; return true; } else { eZDebug::writeError( "Failed executing compiled template '$phpScript'," . " if this file is valid, then the error is probably" . " related to APC usage, try restarting the webserver", __METHOD__ ); throw new eZTemplateFailedExecutingCompiledTemplate( "Failed executing a compiled template, see error.log for details" ); } } else eZDebug::writeError( "Unknown compiled template '$phpScript'", __METHOD__ ); return false; }
php
static function executeCompilation( $tpl, &$textElements, $key, &$resourceData, $rootNamespace, $currentNamespace ) { if ( !eZTemplateCompiler::isCompilationEnabled() ) return false; if ( !eZTemplateCompiler::isExecutionEnabled() ) return false; $cacheFileName = eZTemplateCompiler::compilationFilename( $key, $resourceData ); $resourceData['use-comments'] = eZTemplateCompiler::isCommentsEnabled(); $directory = eZTemplateCompiler::compilationDirectory(); $phpScript = eZDir::path( array( $directory, $cacheFileName ) ); if ( file_exists( $phpScript ) ) { $text = false; $helperStatus = eZTemplateCompiler::executeCompilationHelper( $phpScript, $text, $tpl, $key, $resourceData, $rootNamespace, $currentNamespace ); if ( $helperStatus ) { $textElements[] = $text; return true; } else { eZDebug::writeError( "Failed executing compiled template '$phpScript'," . " if this file is valid, then the error is probably" . " related to APC usage, try restarting the webserver", __METHOD__ ); throw new eZTemplateFailedExecutingCompiledTemplate( "Failed executing a compiled template, see error.log for details" ); } } else eZDebug::writeError( "Unknown compiled template '$phpScript'", __METHOD__ ); return false; }
[ "static", "function", "executeCompilation", "(", "$", "tpl", ",", "&", "$", "textElements", ",", "$", "key", ",", "&", "$", "resourceData", ",", "$", "rootNamespace", ",", "$", "currentNamespace", ")", "{", "if", "(", "!", "eZTemplateCompiler", "::", "isCo...
Tries to execute the compiled template. Returns true if successful, returns false if the compilation is disabled or the compiled template does not exist. @param eZTemplate $tpl @param array $textElements @param string $key @param array $resourceData @param $rootNamespace @param $currentNamespace @throws eZTemplateFailedExecutingCompiledTemplate if the compiled template could not be executed @return bool
[ "Tries", "to", "execute", "the", "compiled", "template", ".", "Returns", "true", "if", "successful", "returns", "false", "if", "the", "compilation", "is", "disabled", "or", "the", "compiled", "template", "does", "not", "exist", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/eztemplate/classes/eztemplatecompiler.php#L387-L426
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/controllers/error.php
ezpRestErrorController.doShow
public function doShow() { if ( ($this->exception instanceof ezcMvcRouteNotFoundException) || ($this->exception instanceof ezpContentNotFoundException ) ) { // we want to return a 404 to the user $result = new ezcMvcResult; $result->status = new ezpRestHttpResponse( ezpHttpResponseCodes::NOT_FOUND, "Not Found" ); return $result; } else if ( $this->exception instanceof ezpOauthBadRequestException ) { $result = new ezcMvcResult; $result->status = new ezpRestOauthErrorStatus( $this->exception->errorType, $this->exception->getMessage() ); $result->variables['message'] = $this->exception->getMessage(); return $result; } else if ( $this->exception instanceof ezpOauthRequiredException ) { $result = new ezcMvcResult; $result->status = new ezpOauthRequired( "eZ Publish REST", $this->exception->errorType, $this->exception->getMessage() ); $result->variables['message'] = $this->exception->getMessage(); return $result; } else if ( $this->exception instanceof ezpContentAccessDeniedException ) { $result = new ezcMvcResult; $result->variables['message'] = $this->exception->getMessage(); $result->status = new ezpRestHttpResponse( ezpHttpResponseCodes::FORBIDDEN, $this->exception->getMessage() ); return $result; } else if ( $this->exception instanceof ezpRouteMethodNotAllowedException ) { $result = new ezpRestMvcResult; $result->status = new ezpRestStatusResponse( ezpHttpResponseCodes::METHOD_NOT_ALLOWED, $this->exception->getMessage(), array( 'Allow' => implode( ', ', $this->exception->getAllowedMethods() ) ) ); return $result; } $result = new ezcMvcResult; $result->variables['message'] = $this->exception->getMessage(); $result->status = new ezpRestHttpResponse( ezpHttpResponseCodes::SERVER_ERROR, $this->exception->getMessage() ); return $result; }
php
public function doShow() { if ( ($this->exception instanceof ezcMvcRouteNotFoundException) || ($this->exception instanceof ezpContentNotFoundException ) ) { // we want to return a 404 to the user $result = new ezcMvcResult; $result->status = new ezpRestHttpResponse( ezpHttpResponseCodes::NOT_FOUND, "Not Found" ); return $result; } else if ( $this->exception instanceof ezpOauthBadRequestException ) { $result = new ezcMvcResult; $result->status = new ezpRestOauthErrorStatus( $this->exception->errorType, $this->exception->getMessage() ); $result->variables['message'] = $this->exception->getMessage(); return $result; } else if ( $this->exception instanceof ezpOauthRequiredException ) { $result = new ezcMvcResult; $result->status = new ezpOauthRequired( "eZ Publish REST", $this->exception->errorType, $this->exception->getMessage() ); $result->variables['message'] = $this->exception->getMessage(); return $result; } else if ( $this->exception instanceof ezpContentAccessDeniedException ) { $result = new ezcMvcResult; $result->variables['message'] = $this->exception->getMessage(); $result->status = new ezpRestHttpResponse( ezpHttpResponseCodes::FORBIDDEN, $this->exception->getMessage() ); return $result; } else if ( $this->exception instanceof ezpRouteMethodNotAllowedException ) { $result = new ezpRestMvcResult; $result->status = new ezpRestStatusResponse( ezpHttpResponseCodes::METHOD_NOT_ALLOWED, $this->exception->getMessage(), array( 'Allow' => implode( ', ', $this->exception->getAllowedMethods() ) ) ); return $result; } $result = new ezcMvcResult; $result->variables['message'] = $this->exception->getMessage(); $result->status = new ezpRestHttpResponse( ezpHttpResponseCodes::SERVER_ERROR, $this->exception->getMessage() ); return $result; }
[ "public", "function", "doShow", "(", ")", "{", "if", "(", "(", "$", "this", "->", "exception", "instanceof", "ezcMvcRouteNotFoundException", ")", "||", "(", "$", "this", "->", "exception", "instanceof", "ezpContentNotFoundException", ")", ")", "{", "// we want t...
Default method, currently used for fatal error handling @return ezcMvcResult
[ "Default", "method", "currently", "used", "for", "fatal", "error", "handling" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/controllers/error.php#L20-L66
train
ezsystems/ezpublish-legacy
kernel/content/ezcontentfunctioncollection.php
eZContentFunctionCollection.fetchRelatedObjectsID
static public function fetchRelatedObjectsID( $objectID, $attributeID, $allRelations) { if ( !is_array( $allRelations ) || $allRelations === array() ) { $allRelations = array( 'common', 'xml_embed', 'attribute' ); if ( eZContentObject::isObjectRelationTyped() ) { $allRelations[] = 'xml_link'; } } $relatedObjectsTyped = array(); foreach ( $allRelations as $relationType ) { $relatedObjectsTyped[$relationType] = eZContentFunctionCollection::fetchRelatedObjects( $objectID, $attributeID, array( $relationType ), false, array() ); } $relatedObjectsTypedIDArray = array(); foreach ( $relatedObjectsTyped as $relationTypeName => $relatedObjectsByType ) { $relatedObjectsTypedIDArray[$relationTypeName] = array(); foreach ( $relatedObjectsByType['result'] as $relatedObjectByType ) { $relatedObjectsTypedIDArray[$relationTypeName][] = $relatedObjectByType->ID; } } return array( 'result' => $relatedObjectsTypedIDArray ); }
php
static public function fetchRelatedObjectsID( $objectID, $attributeID, $allRelations) { if ( !is_array( $allRelations ) || $allRelations === array() ) { $allRelations = array( 'common', 'xml_embed', 'attribute' ); if ( eZContentObject::isObjectRelationTyped() ) { $allRelations[] = 'xml_link'; } } $relatedObjectsTyped = array(); foreach ( $allRelations as $relationType ) { $relatedObjectsTyped[$relationType] = eZContentFunctionCollection::fetchRelatedObjects( $objectID, $attributeID, array( $relationType ), false, array() ); } $relatedObjectsTypedIDArray = array(); foreach ( $relatedObjectsTyped as $relationTypeName => $relatedObjectsByType ) { $relatedObjectsTypedIDArray[$relationTypeName] = array(); foreach ( $relatedObjectsByType['result'] as $relatedObjectByType ) { $relatedObjectsTypedIDArray[$relationTypeName][] = $relatedObjectByType->ID; } } return array( 'result' => $relatedObjectsTypedIDArray ); }
[ "static", "public", "function", "fetchRelatedObjectsID", "(", "$", "objectID", ",", "$", "attributeID", ",", "$", "allRelations", ")", "{", "if", "(", "!", "is_array", "(", "$", "allRelations", ")", "||", "$", "allRelations", "===", "array", "(", ")", ")",...
Fetches related objects id grouped by relation types
[ "Fetches", "related", "objects", "id", "grouped", "by", "relation", "types" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentfunctioncollection.php#L1160-L1189
train
ezsystems/ezpublish-legacy
kernel/content/ezcontentfunctioncollection.php
eZContentFunctionCollection.fetchReverseRelatedObjectsID
static public function fetchReverseRelatedObjectsID( $objectID, $attributeID, $allRelations ) { if ( !is_array( $allRelations ) || $allRelations === array() ) { $allRelations = array( 'common', 'xml_embed', 'attribute' ); if ( eZContentObject::isObjectRelationTyped() ) { $allRelations[] = 'xml_link'; } } $relatedObjectsTyped = array(); foreach ( $allRelations as $relationType ) { $relatedObjectsTyped[$relationType] = eZContentFunctionCollection::fetchReverseRelatedObjects( $objectID, $attributeID, array( $relationType ), false, array(), null ); } $relatedObjectsTypedIDArray = array(); foreach ( $relatedObjectsTyped as $relationTypeName => $relatedObjectsByType ) { $relatedObjectsTypedIDArray[$relationTypeName] = array(); foreach ( $relatedObjectsByType['result'] as $relatedObjectByType ) { $relatedObjectsTypedIDArray[$relationTypeName][] = $relatedObjectByType->ID; } } return array( 'result' =>$relatedObjectsTypedIDArray ); }
php
static public function fetchReverseRelatedObjectsID( $objectID, $attributeID, $allRelations ) { if ( !is_array( $allRelations ) || $allRelations === array() ) { $allRelations = array( 'common', 'xml_embed', 'attribute' ); if ( eZContentObject::isObjectRelationTyped() ) { $allRelations[] = 'xml_link'; } } $relatedObjectsTyped = array(); foreach ( $allRelations as $relationType ) { $relatedObjectsTyped[$relationType] = eZContentFunctionCollection::fetchReverseRelatedObjects( $objectID, $attributeID, array( $relationType ), false, array(), null ); } $relatedObjectsTypedIDArray = array(); foreach ( $relatedObjectsTyped as $relationTypeName => $relatedObjectsByType ) { $relatedObjectsTypedIDArray[$relationTypeName] = array(); foreach ( $relatedObjectsByType['result'] as $relatedObjectByType ) { $relatedObjectsTypedIDArray[$relationTypeName][] = $relatedObjectByType->ID; } } return array( 'result' =>$relatedObjectsTypedIDArray ); }
[ "static", "public", "function", "fetchReverseRelatedObjectsID", "(", "$", "objectID", ",", "$", "attributeID", ",", "$", "allRelations", ")", "{", "if", "(", "!", "is_array", "(", "$", "allRelations", ")", "||", "$", "allRelations", "===", "array", "(", ")",...
Fetches reverse related objects id grouped by relation types
[ "Fetches", "reverse", "related", "objects", "id", "grouped", "by", "relation", "types" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentfunctioncollection.php#L1192-L1221
train
ezsystems/ezpublish-legacy
extension/ezjscore/classes/ezjscpacker.php
ezjscPacker.buildJavascriptFiles
static function buildJavascriptFiles( $scriptFiles, $packLevel = 2, $indexDirInCacheHash = true ) { return ezjscPacker::packFiles( $scriptFiles, 'javascript/', '.js', $packLevel, $indexDirInCacheHash ); }
php
static function buildJavascriptFiles( $scriptFiles, $packLevel = 2, $indexDirInCacheHash = true ) { return ezjscPacker::packFiles( $scriptFiles, 'javascript/', '.js', $packLevel, $indexDirInCacheHash ); }
[ "static", "function", "buildJavascriptFiles", "(", "$", "scriptFiles", ",", "$", "packLevel", "=", "2", ",", "$", "indexDirInCacheHash", "=", "true", ")", "{", "return", "ezjscPacker", "::", "packFiles", "(", "$", "scriptFiles", ",", "'javascript/'", ",", "'.j...
Builds javascript files @param array|string $scriptFiles Either array of file paths, or string with file path @param int $packLevel Level of packing, values: 0-3 @param bool $indexDirInCacheHash To add index path in cache hash or not @return array List of javascript files
[ "Builds", "javascript", "files" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscpacker.php#L151-L154
train
ezsystems/ezpublish-legacy
extension/ezjscore/classes/ezjscpacker.php
ezjscPacker.buildStylesheetFiles
static function buildStylesheetFiles( $cssFiles, $packLevel = 3, $indexDirInCacheHash = true ) { return ezjscPacker::packFiles( $cssFiles, 'stylesheets/', '.css', $packLevel, $indexDirInCacheHash, '_all' ); }
php
static function buildStylesheetFiles( $cssFiles, $packLevel = 3, $indexDirInCacheHash = true ) { return ezjscPacker::packFiles( $cssFiles, 'stylesheets/', '.css', $packLevel, $indexDirInCacheHash, '_all' ); }
[ "static", "function", "buildStylesheetFiles", "(", "$", "cssFiles", ",", "$", "packLevel", "=", "3", ",", "$", "indexDirInCacheHash", "=", "true", ")", "{", "return", "ezjscPacker", "::", "packFiles", "(", "$", "cssFiles", ",", "'stylesheets/'", ",", "'.css'",...
Builds stylesheet files @param array|string $cssFiles Either array of file paths, or string with file path @param int $packLevel Level of packing, values: 0-3 @param bool $indexDirInCacheHash To add index path in cache hash or not @return array List of css files
[ "Builds", "stylesheet", "files" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscpacker.php#L164-L167
train
ezsystems/ezpublish-legacy
extension/ezjscore/classes/ezjscpacker.php
ezjscPacker.fixImgPaths
static function fixImgPaths( $fileContent, $file ) { if ( preg_match_all( "/url\(\s*[\'|\"]?([A-Za-z0-9_\-\/\.\\%?&@#=]+)[\'|\"]?\s*\)/ix", $fileContent, $urlMatches ) ) { $urlPaths = array(); $urlMatches = array_unique( $urlMatches[1] ); $cssPathArray = explode( '/', $file ); $wwwDir = self::getWwwDir(); // Pop the css file name array_pop( $cssPathArray ); $cssPathCount = count( $cssPathArray ); foreach ( $urlMatches as $match ) { $match = str_replace( '\\', '/', $match ); $relativeCount = substr_count( $match, '../' ); // Replace path if it is realtive if ( $match[0] !== '/' and strpos( $match, 'http:' ) === false ) { $cssPathSlice = $relativeCount === 0 ? $cssPathArray : array_slice( $cssPathArray , 0, $cssPathCount - $relativeCount ); $newMatchPath = $wwwDir; if ( !empty( $cssPathSlice ) ) { $newMatchPath .= implode( '/', $cssPathSlice ) . '/'; } $newMatchPath .= str_replace( '../', '', $match ); $urlPaths[$match] = $newMatchPath; } } $fileContent = strtr( $fileContent, $urlPaths ); } return $fileContent; }
php
static function fixImgPaths( $fileContent, $file ) { if ( preg_match_all( "/url\(\s*[\'|\"]?([A-Za-z0-9_\-\/\.\\%?&@#=]+)[\'|\"]?\s*\)/ix", $fileContent, $urlMatches ) ) { $urlPaths = array(); $urlMatches = array_unique( $urlMatches[1] ); $cssPathArray = explode( '/', $file ); $wwwDir = self::getWwwDir(); // Pop the css file name array_pop( $cssPathArray ); $cssPathCount = count( $cssPathArray ); foreach ( $urlMatches as $match ) { $match = str_replace( '\\', '/', $match ); $relativeCount = substr_count( $match, '../' ); // Replace path if it is realtive if ( $match[0] !== '/' and strpos( $match, 'http:' ) === false ) { $cssPathSlice = $relativeCount === 0 ? $cssPathArray : array_slice( $cssPathArray , 0, $cssPathCount - $relativeCount ); $newMatchPath = $wwwDir; if ( !empty( $cssPathSlice ) ) { $newMatchPath .= implode( '/', $cssPathSlice ) . '/'; } $newMatchPath .= str_replace( '../', '', $match ); $urlPaths[$match] = $newMatchPath; } } $fileContent = strtr( $fileContent, $urlPaths ); } return $fileContent; }
[ "static", "function", "fixImgPaths", "(", "$", "fileContent", ",", "$", "file", ")", "{", "if", "(", "preg_match_all", "(", "\"/url\\(\\s*[\\'|\\\"]?([A-Za-z0-9_\\-\\/\\.\\\\%?&@#=]+)[\\'|\\\"]?\\s*\\)/ix\"", ",", "$", "fileContent", ",", "$", "urlMatches", ")", ")", ...
Fix image paths in css. @param string $fileContent Css string @param string $file File incl path to calculate relative paths from. @return string
[ "Fix", "image", "paths", "in", "css", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscpacker.php#L494-L525
train
ezsystems/ezpublish-legacy
extension/ezjscore/classes/ezjscpacker.php
ezjscPacker.serverCallHelper
static function serverCallHelper( $strServerCall ) { $server = ezjscServerRouter::getInstance( $strServerCall ); if ( !$server instanceof ezjscServerRouter ) { eZDebug::writeError( 'Not a valid ezjscServer function: ' . implode( '::', $strServerCall ), __METHOD__ ); return null; } // Make sure the function is present on the class if ( !$server->hasFunction() ) { eZDebug::writeError( 'Could not find function: ' . $server->getName() . '()', __METHOD__ ); return null; } return $server; }
php
static function serverCallHelper( $strServerCall ) { $server = ezjscServerRouter::getInstance( $strServerCall ); if ( !$server instanceof ezjscServerRouter ) { eZDebug::writeError( 'Not a valid ezjscServer function: ' . implode( '::', $strServerCall ), __METHOD__ ); return null; } // Make sure the function is present on the class if ( !$server->hasFunction() ) { eZDebug::writeError( 'Could not find function: ' . $server->getName() . '()', __METHOD__ ); return null; } return $server; }
[ "static", "function", "serverCallHelper", "(", "$", "strServerCall", ")", "{", "$", "server", "=", "ezjscServerRouter", "::", "getInstance", "(", "$", "strServerCall", ")", ";", "if", "(", "!", "$", "server", "instanceof", "ezjscServerRouter", ")", "{", "eZDeb...
Helper function to get and validate server functions @param string $strServerCall @return ezjscServerRouter|null
[ "Helper", "function", "to", "get", "and", "validate", "server", "functions" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscpacker.php#L533-L548
train
ezsystems/ezpublish-legacy
extension/ezjscore/classes/ezjscpacker.php
ezjscPacker.printDebugReport
static public function printDebugReport( $as_html = true ) { if ( !eZTemplate::isTemplatesUsageStatisticsEnabled() ) return ''; $stats = ''; if ( $as_html ) { $stats .= '<h3>CSS/JS files loaded with "ezjscPacker" during request:</h3>'; $stats .= '<table id="ezjscpackerusage" class="debug_resource_usage" title="List of used files, hover over italic text for more info!">'; $stats .= '<tr><th>Cache</th><th>Type</th><th>Packlevel</th><th>SourceFiles</th></tr>'; } else { $stats .= "CSS/JS files loaded with 'ezjscPacker' during request\n"; $stats .= sprintf( "%-40s%-40s%-40s\n", 'Cache', 'Type', 'Packlevel' ); } foreach( self::$log as $data ) { $extension = $data['file_extension'] === '.js' ? 'JS' : 'CSS'; if ( $as_html ) { $sourceFilesStats = self::printDebugReportFiles( $data, $as_html ); $cache = $data['cache_path'] === '' ? '' : "<span class='debuginfo' title='Full path: {$data['cache_path']}'>{$data['cache_hash']}</span>"; $stats .= "<tr class='data'><td>{$cache}</td><td>{$extension}</td><td>{$data['pack_level']}</td><td>{$sourceFilesStats}</td></tr>"; } else { $stats .= sprintf( "%-40s%-40s%-40s\n", $data['cache_hash'], $extension, $data['pack_level'] ); } } if ( $as_html ) { $stats .= '</table>'; } return $stats; }
php
static public function printDebugReport( $as_html = true ) { if ( !eZTemplate::isTemplatesUsageStatisticsEnabled() ) return ''; $stats = ''; if ( $as_html ) { $stats .= '<h3>CSS/JS files loaded with "ezjscPacker" during request:</h3>'; $stats .= '<table id="ezjscpackerusage" class="debug_resource_usage" title="List of used files, hover over italic text for more info!">'; $stats .= '<tr><th>Cache</th><th>Type</th><th>Packlevel</th><th>SourceFiles</th></tr>'; } else { $stats .= "CSS/JS files loaded with 'ezjscPacker' during request\n"; $stats .= sprintf( "%-40s%-40s%-40s\n", 'Cache', 'Type', 'Packlevel' ); } foreach( self::$log as $data ) { $extension = $data['file_extension'] === '.js' ? 'JS' : 'CSS'; if ( $as_html ) { $sourceFilesStats = self::printDebugReportFiles( $data, $as_html ); $cache = $data['cache_path'] === '' ? '' : "<span class='debuginfo' title='Full path: {$data['cache_path']}'>{$data['cache_hash']}</span>"; $stats .= "<tr class='data'><td>{$cache}</td><td>{$extension}</td><td>{$data['pack_level']}</td><td>{$sourceFilesStats}</td></tr>"; } else { $stats .= sprintf( "%-40s%-40s%-40s\n", $data['cache_hash'], $extension, $data['pack_level'] ); } } if ( $as_html ) { $stats .= '</table>'; } return $stats; }
[ "static", "public", "function", "printDebugReport", "(", "$", "as_html", "=", "true", ")", "{", "if", "(", "!", "eZTemplate", "::", "isTemplatesUsageStatisticsEnabled", "(", ")", ")", "return", "''", ";", "$", "stats", "=", "''", ";", "if", "(", "$", "as...
Generate a debug report of packer use @internal @param bool $as_html @return string
[ "Generate", "a", "debug", "report", "of", "packer", "use" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscpacker.php#L557-L597
train
ezsystems/ezpublish-legacy
kernel/classes/ezdatatype.php
eZDataType.preStoreVersionedClassAttribute
function preStoreVersionedClassAttribute( $classAttribute, $version ) { switch ( $version ) { case eZContentClass::VERSION_STATUS_DEFINED: $this->preStoreDefinedClassAttribute( $classAttribute ); break; case eZContentClass::VERSION_STATUS_MODIFIED: $this->preStoreModifiedClassAttribute( $classAttribute ); break; } }
php
function preStoreVersionedClassAttribute( $classAttribute, $version ) { switch ( $version ) { case eZContentClass::VERSION_STATUS_DEFINED: $this->preStoreDefinedClassAttribute( $classAttribute ); break; case eZContentClass::VERSION_STATUS_MODIFIED: $this->preStoreModifiedClassAttribute( $classAttribute ); break; } }
[ "function", "preStoreVersionedClassAttribute", "(", "$", "classAttribute", ",", "$", "version", ")", "{", "switch", "(", "$", "version", ")", "{", "case", "eZContentClass", "::", "VERSION_STATUS_DEFINED", ":", "$", "this", "->", "preStoreDefinedClassAttribute", "(",...
Hook function which is called before an content class attribute is stored @see eZContentClassAttribute::storeVersioned() @param eZContentClassAttribute $classAttribute Content class attribute of the datatype @param int $version Version of the attribute to be stored
[ "Hook", "function", "which", "is", "called", "before", "an", "content", "class", "attribute", "is", "stored" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezdatatype.php#L740-L752
train
ezsystems/ezpublish-legacy
kernel/classes/ezdatatype.php
eZDataType.createContentObjectAttributeDOMNode
function createContentObjectAttributeDOMNode( $objectAttribute ) { $dom = new DOMDocument( '1.0', 'utf-8' ); $node = $dom->createElementNS( 'http://ez.no/object/', 'ezobject:attribute' ); $node->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:id', $objectAttribute->attribute( 'id' ) ); $node->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:identifier', $objectAttribute->contentClassAttributeIdentifier() ); $node->setAttribute( 'name', $objectAttribute->contentClassAttributeName() ); $node->setAttribute( 'type', $this->isA() ); return $node; }
php
function createContentObjectAttributeDOMNode( $objectAttribute ) { $dom = new DOMDocument( '1.0', 'utf-8' ); $node = $dom->createElementNS( 'http://ez.no/object/', 'ezobject:attribute' ); $node->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:id', $objectAttribute->attribute( 'id' ) ); $node->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:identifier', $objectAttribute->contentClassAttributeIdentifier() ); $node->setAttribute( 'name', $objectAttribute->contentClassAttributeName() ); $node->setAttribute( 'type', $this->isA() ); return $node; }
[ "function", "createContentObjectAttributeDOMNode", "(", "$", "objectAttribute", ")", "{", "$", "dom", "=", "new", "DOMDocument", "(", "'1.0'", ",", "'utf-8'", ")", ";", "$", "node", "=", "$", "dom", "->", "createElementNS", "(", "'http://ez.no/object/'", ",", ...
Create empty content object attribute DOM node. The result is intended to be used in a datatype's serializeContentObjectAttribute() method. \return "Empty" DOM node
[ "Create", "empty", "content", "object", "attribute", "DOM", "node", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezdatatype.php#L1370-L1382
train
ezsystems/ezpublish-legacy
kernel/classes/ezcontentcachemanager.php
eZContentCacheManager.addAdditionalNodeIDPerObject
public static function addAdditionalNodeIDPerObject( $contentObjectID, $additionalNodeID ) { if ( !isset( self::$additionalNodeIDsPerObject[$contentObjectID] ) ) { self::$additionalNodeIDsPerObject[$contentObjectID] = array(); } self::$additionalNodeIDsPerObject[$contentObjectID][] = $additionalNodeID; }
php
public static function addAdditionalNodeIDPerObject( $contentObjectID, $additionalNodeID ) { if ( !isset( self::$additionalNodeIDsPerObject[$contentObjectID] ) ) { self::$additionalNodeIDsPerObject[$contentObjectID] = array(); } self::$additionalNodeIDsPerObject[$contentObjectID][] = $additionalNodeID; }
[ "public", "static", "function", "addAdditionalNodeIDPerObject", "(", "$", "contentObjectID", ",", "$", "additionalNodeID", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "additionalNodeIDsPerObject", "[", "$", "contentObjectID", "]", ")", ")", "{", ...
Adds an additional NodeID to be appended to the node list for clearing view cache. @param int $contentObjectID @param int $additionalNodeID
[ "Adds", "an", "additional", "NodeID", "to", "be", "appended", "to", "the", "node", "list", "for", "clearing", "view", "cache", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentcachemanager.php#L51-L59
train
ezsystems/ezpublish-legacy
kernel/classes/ezcontentcachemanager.php
eZContentCacheManager.appendAdditionalNodeIDs
private static function appendAdditionalNodeIDs( eZContentObject $contentObject, &$nodeIDList ) { $contentObjectId = $contentObject->attribute( 'id' ); if ( !isset( self::$additionalNodeIDsPerObject[$contentObjectId] ) ) return; foreach ( self::$additionalNodeIDsPerObject[$contentObjectId] as $nodeID ) { $nodeIDList[] = $nodeID; } }
php
private static function appendAdditionalNodeIDs( eZContentObject $contentObject, &$nodeIDList ) { $contentObjectId = $contentObject->attribute( 'id' ); if ( !isset( self::$additionalNodeIDsPerObject[$contentObjectId] ) ) return; foreach ( self::$additionalNodeIDsPerObject[$contentObjectId] as $nodeID ) { $nodeIDList[] = $nodeID; } }
[ "private", "static", "function", "appendAdditionalNodeIDs", "(", "eZContentObject", "$", "contentObject", ",", "&", "$", "nodeIDList", ")", "{", "$", "contentObjectId", "=", "$", "contentObject", "->", "attribute", "(", "'id'", ")", ";", "if", "(", "!", "isset...
Appends additional node IDs. @param eZContentObject $contentObject @param array $nodeIDList
[ "Appends", "additional", "node", "IDs", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentcachemanager.php#L67-L77
train
ezsystems/ezpublish-legacy
kernel/classes/ezcontentcachemanager.php
eZContentCacheManager.clearNodeViewCacheArray
public static function clearNodeViewCacheArray( array $nodeList, array $contentObjectList = null ) { if ( count( $nodeList ) == 0 ) { return false; } eZDebugSetting::writeDebug( 'kernel-content-edit', count( $nodeList ), "count in nodeList" ); if ( eZINI::instance()->variable( 'ContentSettings', 'StaticCache' ) === 'enabled' ) { $staticCacheHandler = eZExtension::getHandlerClass( new ezpExtensionOptions( array( 'iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler', ) ) ); $staticCacheHandler->generateAlwaysUpdatedCache(); $staticCacheHandler->generateNodeListCache( $nodeList ); } eZDebug::accumulatorStart( 'node_cleanup', '', 'Node cleanup' ); eZContentObject::expireComplexViewModeCache(); $cleanupValue = eZContentCache::calculateCleanupValue( count( $nodeList ) ); if ( eZContentCache::inCleanupThresholdRange( $cleanupValue ) ) { $nodeList = ezpEvent::getInstance()->filter( 'content/cache', $nodeList, $contentObjectList ); eZContentCache::cleanup( $nodeList ); } else { eZDebug::writeDebug( "Expiring all view cache since list of nodes({$cleanupValue}) exceeds site.ini\[ContentSettings]\CacheThreshold", __METHOD__ ); ezpEvent::getInstance()->notify( 'content/cache/all' ); eZContentObject::expireAllViewCache(); } eZDebug::accumulatorStop( 'node_cleanup' ); return true; }
php
public static function clearNodeViewCacheArray( array $nodeList, array $contentObjectList = null ) { if ( count( $nodeList ) == 0 ) { return false; } eZDebugSetting::writeDebug( 'kernel-content-edit', count( $nodeList ), "count in nodeList" ); if ( eZINI::instance()->variable( 'ContentSettings', 'StaticCache' ) === 'enabled' ) { $staticCacheHandler = eZExtension::getHandlerClass( new ezpExtensionOptions( array( 'iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler', ) ) ); $staticCacheHandler->generateAlwaysUpdatedCache(); $staticCacheHandler->generateNodeListCache( $nodeList ); } eZDebug::accumulatorStart( 'node_cleanup', '', 'Node cleanup' ); eZContentObject::expireComplexViewModeCache(); $cleanupValue = eZContentCache::calculateCleanupValue( count( $nodeList ) ); if ( eZContentCache::inCleanupThresholdRange( $cleanupValue ) ) { $nodeList = ezpEvent::getInstance()->filter( 'content/cache', $nodeList, $contentObjectList ); eZContentCache::cleanup( $nodeList ); } else { eZDebug::writeDebug( "Expiring all view cache since list of nodes({$cleanupValue}) exceeds site.ini\[ContentSettings]\CacheThreshold", __METHOD__ ); ezpEvent::getInstance()->notify( 'content/cache/all' ); eZContentObject::expireAllViewCache(); } eZDebug::accumulatorStop( 'node_cleanup' ); return true; }
[ "public", "static", "function", "clearNodeViewCacheArray", "(", "array", "$", "nodeList", ",", "array", "$", "contentObjectList", "=", "null", ")", "{", "if", "(", "count", "(", "$", "nodeList", ")", "==", "0", ")", "{", "return", "false", ";", "}", "eZD...
Clears view caches for an array of nodes. @param array $nodeList List of node IDs to clear @param array|null $contentObjectList List of content object IDs to clear @return boolean returns true on success
[ "Clears", "view", "caches", "for", "an", "array", "of", "nodes", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentcachemanager.php#L741-L785
train
ezsystems/ezpublish-legacy
kernel/classes/ezcontentcachemanager.php
eZContentCacheManager.clearTemplateBlockCache
public static function clearTemplateBlockCache( $objectID, $checkViewCacheClassSettings = false ) { // ordinary template block cache eZContentObject::expireTemplateBlockCache(); if ( empty( $objectID ) ) return; // subtree template block cache $nodeList = false; if ( is_array( $objectID ) ) { $objects = eZContentObject::fetchIDArray( $objectID ); } else { $objects = array( $objectID => eZContentObject::fetch( $objectID ) ); } $ini = eZINI::instance( 'viewcache.ini' ); foreach ( $objects as $object ) { if ( $object instanceof eZContentObject ) { $getAssignedNodes = true; if ( $checkViewCacheClassSettings ) { $objectClassIdentifier = $object->attribute('class_identifier'); if ( $ini->hasVariable( $objectClassIdentifier, 'ClearCacheBlocks' ) && $ini->variable( $objectClassIdentifier, 'ClearCacheBlocks' ) === 'disabled' ) { $getAssignedNodes = false; } } if ( $getAssignedNodes ) { $nodeList = array_merge( ( $nodeList !== false ? $nodeList : array() ), $object->assignedNodes() ); } } } eZSubtreeCache::cleanup( $nodeList ); }
php
public static function clearTemplateBlockCache( $objectID, $checkViewCacheClassSettings = false ) { // ordinary template block cache eZContentObject::expireTemplateBlockCache(); if ( empty( $objectID ) ) return; // subtree template block cache $nodeList = false; if ( is_array( $objectID ) ) { $objects = eZContentObject::fetchIDArray( $objectID ); } else { $objects = array( $objectID => eZContentObject::fetch( $objectID ) ); } $ini = eZINI::instance( 'viewcache.ini' ); foreach ( $objects as $object ) { if ( $object instanceof eZContentObject ) { $getAssignedNodes = true; if ( $checkViewCacheClassSettings ) { $objectClassIdentifier = $object->attribute('class_identifier'); if ( $ini->hasVariable( $objectClassIdentifier, 'ClearCacheBlocks' ) && $ini->variable( $objectClassIdentifier, 'ClearCacheBlocks' ) === 'disabled' ) { $getAssignedNodes = false; } } if ( $getAssignedNodes ) { $nodeList = array_merge( ( $nodeList !== false ? $nodeList : array() ), $object->assignedNodes() ); } } } eZSubtreeCache::cleanup( $nodeList ); }
[ "public", "static", "function", "clearTemplateBlockCache", "(", "$", "objectID", ",", "$", "checkViewCacheClassSettings", "=", "false", ")", "{", "// ordinary template block cache", "eZContentObject", "::", "expireTemplateBlockCache", "(", ")", ";", "if", "(", "empty", ...
Clears template-block cache and template-block with subtree_expiry parameter caches for specified object without checking 'TemplateCache' ini setting. @param int|array|bool $objectID (list of) object ID, if false only ordinary template block caches will be cleared Support for array value available {@since 5.0}. @param bool $checkViewCacheClassSettings Check whether ViewCache class settings should be verified
[ "Clears", "template", "-", "block", "cache", "and", "template", "-", "block", "with", "subtree_expiry", "parameter", "caches", "for", "specified", "object", "without", "checking", "TemplateCache", "ini", "setting", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentcachemanager.php#L838-L882
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.ezpdf.php
Cezpdf.ezSetCmMargins
function ezSetCmMargins( $top, $bottom, $left, $right ) { $top = ( $top / 2.54 ) * 72; $bottom = ( $bottom / 2.54 ) * 72; $left = ( $left / 2.54 ) * 72; $right = ( $right / 2.54 ) * 72; $this->ezSetMargins( $top, $bottom, $left, $right ); }
php
function ezSetCmMargins( $top, $bottom, $left, $right ) { $top = ( $top / 2.54 ) * 72; $bottom = ( $bottom / 2.54 ) * 72; $left = ( $left / 2.54 ) * 72; $right = ( $right / 2.54 ) * 72; $this->ezSetMargins( $top, $bottom, $left, $right ); }
[ "function", "ezSetCmMargins", "(", "$", "top", ",", "$", "bottom", ",", "$", "left", ",", "$", "right", ")", "{", "$", "top", "=", "(", "$", "top", "/", "2.54", ")", "*", "72", ";", "$", "bottom", "=", "(", "$", "bottom", "/", "2.54", ")", "*...
Set Margins in centimeters
[ "Set", "Margins", "in", "centimeters" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.ezpdf.php#L153-L160
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.ezpdf.php
Cezpdf.ezShadedRectangle
function ezShadedRectangle( $x1, $y1, $width, $height, $col1, $col2, $direction = 'vertical' ) { $this->shadedRectangle( $x1, $y1, $width, $height, array( 'orientation' => $direction, 'color0' => $col1, 'color1' => $col2, 'size' => array( 'x1' => $x1, 'y1' => $y1, 'width' => $width, 'height' => $height ) ) ); }
php
function ezShadedRectangle( $x1, $y1, $width, $height, $col1, $col2, $direction = 'vertical' ) { $this->shadedRectangle( $x1, $y1, $width, $height, array( 'orientation' => $direction, 'color0' => $col1, 'color1' => $col2, 'size' => array( 'x1' => $x1, 'y1' => $y1, 'width' => $width, 'height' => $height ) ) ); }
[ "function", "ezShadedRectangle", "(", "$", "x1", ",", "$", "y1", ",", "$", "width", ",", "$", "height", ",", "$", "col1", ",", "$", "col2", ",", "$", "direction", "=", "'vertical'", ")", "{", "$", "this", "->", "shadedRectangle", "(", "$", "x1", ",...
Draw a shaded rectangle direction is optional and set to vertical by default \param x1 \param y1 \param width \param height \param col1 \param col2 \param direction ('vertical', 'horizontal', or angle)
[ "Draw", "a", "shaded", "rectangle" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.ezpdf.php#L814-L823
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.ezpdf.php
Cezpdf.loadTemplate
function loadTemplate( $templateFile ) { // this function will load the requested template ($file includes full or relative pathname) // the code for the template will be modified to make it name safe, and then stored in // an array for later use // The id of the template will be returned for the user to operate on it later if ( !file_exists( $templateFile ) ) { return -1; } $code = implode( '', file( $templateFile ) ); if ( !strlen( $code ) ) { return; } $code = trim( $code ); if ( substr( $code, 0, 5 ) == '<?php' ) { $code = substr( $code, 5 ); } if ( substr( $code, -2 ) == '?>' ) { $code = substr( $code, 0, strlen( $code ) - 2 ); } if ( isset( $this->ez['numTemplates'] ) ) { $newNum = $this->ez['numTemplates']; $this->ez['numTemplates']++; } else { $newNum = 0; $this->ez['numTemplates'] = 1; $this->ez['templates'] = array(); } $this->ez['templates'][$newNum]['code'] = $code; return $newNum; }
php
function loadTemplate( $templateFile ) { // this function will load the requested template ($file includes full or relative pathname) // the code for the template will be modified to make it name safe, and then stored in // an array for later use // The id of the template will be returned for the user to operate on it later if ( !file_exists( $templateFile ) ) { return -1; } $code = implode( '', file( $templateFile ) ); if ( !strlen( $code ) ) { return; } $code = trim( $code ); if ( substr( $code, 0, 5 ) == '<?php' ) { $code = substr( $code, 5 ); } if ( substr( $code, -2 ) == '?>' ) { $code = substr( $code, 0, strlen( $code ) - 2 ); } if ( isset( $this->ez['numTemplates'] ) ) { $newNum = $this->ez['numTemplates']; $this->ez['numTemplates']++; } else { $newNum = 0; $this->ez['numTemplates'] = 1; $this->ez['templates'] = array(); } $this->ez['templates'][$newNum]['code'] = $code; return $newNum; }
[ "function", "loadTemplate", "(", "$", "templateFile", ")", "{", "// this function will load the requested template ($file includes full or relative pathname)", "// the code for the template will be modified to make it name safe, and then stored in", "// an array for later use", "// The id of the...
out a good way of doing this yet.
[ "out", "a", "good", "way", "of", "doing", "this", "yet", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.ezpdf.php#L1157-L1198
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.ezpdf.php
Cezpdf.lineHeight
function lineHeight( $options = array() ) { if ( is_array( $options ) && isset( $options['size'] ) ) { $size = $options['size']; } else { $size = $this->ez['fontSize']; } if ( is_array( $options ) && isset( $options['leading'] ) ) { // use leading instead of spacing $height = $options['leading']; } else if ( is_array( $options ) && isset( $options['spacing'] ) ) { $height = $this->getFontHeight( $size ) * $options['spacing']; } else { $height = $this->getFontHeight( $size ); } return $height; }
php
function lineHeight( $options = array() ) { if ( is_array( $options ) && isset( $options['size'] ) ) { $size = $options['size']; } else { $size = $this->ez['fontSize']; } if ( is_array( $options ) && isset( $options['leading'] ) ) { // use leading instead of spacing $height = $options['leading']; } else if ( is_array( $options ) && isset( $options['spacing'] ) ) { $height = $this->getFontHeight( $size ) * $options['spacing']; } else { $height = $this->getFontHeight( $size ); } return $height; }
[ "function", "lineHeight", "(", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "is_array", "(", "$", "options", ")", "&&", "isset", "(", "$", "options", "[", "'size'", "]", ")", ")", "{", "$", "size", "=", "$", "options", "[", "'size...
Get current line height
[ "Get", "current", "line", "height" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.ezpdf.php#L1365-L1390
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/cache/apc.php
ezpRestCacheStorageApcCluster.store
public function store( $id, $data, $attributes = array() ) { $this->forceStoreRegistry = true; $storeResult = parent::store( $id, $data, $attributes ); // Update clustered expiry timestamp $expiryTime = time() + $this->properties['options']['ttl']; $this->expiryHandler->setTimestamp( ezpRestRouter::ROUTE_CACHE_KEY, $expiryTime ); return $storeResult; }
php
public function store( $id, $data, $attributes = array() ) { $this->forceStoreRegistry = true; $storeResult = parent::store( $id, $data, $attributes ); // Update clustered expiry timestamp $expiryTime = time() + $this->properties['options']['ttl']; $this->expiryHandler->setTimestamp( ezpRestRouter::ROUTE_CACHE_KEY, $expiryTime ); return $storeResult; }
[ "public", "function", "store", "(", "$", "id", ",", "$", "data", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "this", "->", "forceStoreRegistry", "=", "true", ";", "$", "storeResult", "=", "parent", "::", "store", "(", "$", "id", ...
Direct store instruction. Makes the registry to be stored @see lib/ezc/Cache/src/storage/ezcCacheStorageMemory::store()
[ "Direct", "store", "instruction", ".", "Makes", "the", "registry", "to", "be", "stored" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/cache/apc.php#L96-L106
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/cache/apc.php
ezpRestCacheStorageApcCluster.delete
public function delete( $id = null, $attributes = array(), $search = false ) { $this->forceStoreRegistry = true; parent::delete( $id, $attributes, $search ); }
php
public function delete( $id = null, $attributes = array(), $search = false ) { $this->forceStoreRegistry = true; parent::delete( $id, $attributes, $search ); }
[ "public", "function", "delete", "(", "$", "id", "=", "null", ",", "$", "attributes", "=", "array", "(", ")", ",", "$", "search", "=", "false", ")", "{", "$", "this", "->", "forceStoreRegistry", "=", "true", ";", "parent", "::", "delete", "(", "$", ...
Direct delete instruction. Registry will be stored @see lib/ezc/Cache/src/storage/ezcCacheStorageMemory::delete()
[ "Direct", "delete", "instruction", ".", "Registry", "will", "be", "stored" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/cache/apc.php#L112-L116
train
ezsystems/ezpublish-legacy
kernel/classes/ezpendingactions.php
eZPendingActions.fetchByAction
public static function fetchByAction( $action, array $aCreationDateFilter = array() ) { $filterConds = array( 'action' => $action ); // Handle creation date filter if( !empty( $aCreationDateFilter ) ) { if( count( $aCreationDateFilter ) != 2 ) { eZDebug::writeError( __CLASS__.'::'.__METHOD__.' : Wrong number of entries for Creation date filter array' ); return null; } list( $filterToken, $filterValue ) = $aCreationDateFilter; $aAuthorizedFilterTokens = array( '=', '<', '>', '<=', '>=' ); if( !is_string( $filterToken ) || !in_array( $filterToken, $aAuthorizedFilterTokens ) ) { eZDebug::writeError( __CLASS__.'::'.__METHOD__.' : Wrong filter type for creation date filter' ); return null; } $filterConds['created'] = array( $filterToken, $filterValue ); } $result = parent::fetchObjectList( self::definition(), null, $filterConds ); return $result; }
php
public static function fetchByAction( $action, array $aCreationDateFilter = array() ) { $filterConds = array( 'action' => $action ); // Handle creation date filter if( !empty( $aCreationDateFilter ) ) { if( count( $aCreationDateFilter ) != 2 ) { eZDebug::writeError( __CLASS__.'::'.__METHOD__.' : Wrong number of entries for Creation date filter array' ); return null; } list( $filterToken, $filterValue ) = $aCreationDateFilter; $aAuthorizedFilterTokens = array( '=', '<', '>', '<=', '>=' ); if( !is_string( $filterToken ) || !in_array( $filterToken, $aAuthorizedFilterTokens ) ) { eZDebug::writeError( __CLASS__.'::'.__METHOD__.' : Wrong filter type for creation date filter' ); return null; } $filterConds['created'] = array( $filterToken, $filterValue ); } $result = parent::fetchObjectList( self::definition(), null, $filterConds ); return $result; }
[ "public", "static", "function", "fetchByAction", "(", "$", "action", ",", "array", "$", "aCreationDateFilter", "=", "array", "(", ")", ")", "{", "$", "filterConds", "=", "array", "(", "'action'", "=>", "$", "action", ")", ";", "// Handle creation date filter",...
Fetches a pending actions list by action name @param string $action @param array $aCreationDateFilter Created date filter array (default is empty array). Must be a 2 entries array. First entry is the filter token (can be '=', '<', '<=', '>', '>=') Second entry is the filter value (timestamp) @return array|null Array of eZPendingActions or null if no entry has been found
[ "Fetches", "a", "pending", "actions", "list", "by", "action", "name" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezpendingactions.php#L63-L90
train
ezsystems/ezpublish-legacy
extension/ezjscore/classes/ezjscjavascriptoptimizer.php
ezjscJavascriptOptimizer.optimize
public static function optimize( $script, $packLevel = 2 ) { // Normalize line feeds $script = str_replace( array( "\r\n", "\r" ), "\n", $script ); // Remove whitespace from start & end of line + singelline comment + multiple linefeeds $script = preg_replace( array( '/\n\s+/', '/\s+\n/', '#\n\s*//.*#', '/\n+/' ), "\n", $script ); // Remove multiline comments $script = preg_replace( '!(?:\n|\s|^)/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $script ); $script = preg_replace( '!(?:;)/\*[^*]*\*+([^/][^*]*\*+)*/!', ';', $script ); return $script; }
php
public static function optimize( $script, $packLevel = 2 ) { // Normalize line feeds $script = str_replace( array( "\r\n", "\r" ), "\n", $script ); // Remove whitespace from start & end of line + singelline comment + multiple linefeeds $script = preg_replace( array( '/\n\s+/', '/\s+\n/', '#\n\s*//.*#', '/\n+/' ), "\n", $script ); // Remove multiline comments $script = preg_replace( '!(?:\n|\s|^)/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $script ); $script = preg_replace( '!(?:;)/\*[^*]*\*+([^/][^*]*\*+)*/!', ';', $script ); return $script; }
[ "public", "static", "function", "optimize", "(", "$", "script", ",", "$", "packLevel", "=", "2", ")", "{", "// Normalize line feeds", "$", "script", "=", "str_replace", "(", "array", "(", "\"\\r\\n\"", ",", "\"\\r\"", ")", ",", "\"\\n\"", ",", "$", "script...
'compress' javascript code by removing whitespace @param string $script Concated JavaScript string @param int $packLevel Level of packing, values: 2-3 @return string
[ "compress", "javascript", "code", "by", "removing", "whitespace" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscjavascriptoptimizer.php#L40-L53
train
ezsystems/ezpublish-legacy
lib/ezutils/classes/ezmoduleoperationinfo.php
eZModuleOperationInfo.executeTrigger
function executeTrigger( &$bodyReturnValue, $body, $operationParameterDefinitions, $operationParameters, &$bodyCallCount, $currentLoopData, $triggerRestored, $operationName, &$operationKeys ) { $triggerName = $body['name']; $triggerKeys = $body['keys']; $status = eZTrigger::runTrigger( $triggerName, $this->ModuleName, $operationName, $operationParameters, $triggerKeys ); if ( $status['Status'] == eZTrigger::WORKFLOW_DONE || $status['Status'] == eZTrigger::NO_CONNECTED_WORKFLOWS ) { ++$bodyCallCount['loop_run'][$triggerName]; return eZModuleOperationInfo::STATUS_CONTINUE; } else if ( $status['Status'] == eZTrigger::STATUS_CRON_JOB || $status['Status'] == eZTrigger::FETCH_TEMPLATE || $status['Status'] == eZTrigger::FETCH_TEMPLATE_REPEAT || $status['Status'] == eZTrigger::REDIRECT ) { $bodyMemento = $this->storeBodyMemento( $triggerName, $triggerKeys, $operationKeys, $operationParameterDefinitions, $operationParameters, $bodyCallCount, $currentLoopData, $operationName ); $workflowProcess = $status['WorkflowProcess']; if ( $workflowProcess !== null ) { $workflowProcess->setAttribute( 'memento_key', $bodyMemento->attribute( 'memento_key' ) ); $workflowProcess->store(); } $bodyReturnValue['result'] = $status['Result']; if ( $status['Status'] == eZTrigger::REDIRECT ) { $bodyReturnValue['redirect_url'] = $status['Result']; } if ( $status['Status'] == eZTrigger::FETCH_TEMPLATE_REPEAT ) { // Hack for project issue #14371 (fetch template repeat) // The object version's status is set to REPEAT so that it can // be submitted again if ( $operationName == 'publish' && $this->ModuleName == 'content' ) { eZContentOperationCollection::setVersionStatus( $operationParameters['object_id'], $operationParameters['version'], eZContentObjectVersion::STATUS_REPEAT ); } return eZModuleOperationInfo::STATUS_REPEAT; } else { return eZModuleOperationInfo::STATUS_HALTED; } } else if ( $status['Status'] == eZTrigger::WORKFLOW_CANCELLED or $status['Status'] == eZTrigger::WORKFLOW_RESET ) { return eZModuleOperationInfo::STATUS_CANCELLED; $bodyReturnValue['result'] = $status['Result']; } }
php
function executeTrigger( &$bodyReturnValue, $body, $operationParameterDefinitions, $operationParameters, &$bodyCallCount, $currentLoopData, $triggerRestored, $operationName, &$operationKeys ) { $triggerName = $body['name']; $triggerKeys = $body['keys']; $status = eZTrigger::runTrigger( $triggerName, $this->ModuleName, $operationName, $operationParameters, $triggerKeys ); if ( $status['Status'] == eZTrigger::WORKFLOW_DONE || $status['Status'] == eZTrigger::NO_CONNECTED_WORKFLOWS ) { ++$bodyCallCount['loop_run'][$triggerName]; return eZModuleOperationInfo::STATUS_CONTINUE; } else if ( $status['Status'] == eZTrigger::STATUS_CRON_JOB || $status['Status'] == eZTrigger::FETCH_TEMPLATE || $status['Status'] == eZTrigger::FETCH_TEMPLATE_REPEAT || $status['Status'] == eZTrigger::REDIRECT ) { $bodyMemento = $this->storeBodyMemento( $triggerName, $triggerKeys, $operationKeys, $operationParameterDefinitions, $operationParameters, $bodyCallCount, $currentLoopData, $operationName ); $workflowProcess = $status['WorkflowProcess']; if ( $workflowProcess !== null ) { $workflowProcess->setAttribute( 'memento_key', $bodyMemento->attribute( 'memento_key' ) ); $workflowProcess->store(); } $bodyReturnValue['result'] = $status['Result']; if ( $status['Status'] == eZTrigger::REDIRECT ) { $bodyReturnValue['redirect_url'] = $status['Result']; } if ( $status['Status'] == eZTrigger::FETCH_TEMPLATE_REPEAT ) { // Hack for project issue #14371 (fetch template repeat) // The object version's status is set to REPEAT so that it can // be submitted again if ( $operationName == 'publish' && $this->ModuleName == 'content' ) { eZContentOperationCollection::setVersionStatus( $operationParameters['object_id'], $operationParameters['version'], eZContentObjectVersion::STATUS_REPEAT ); } return eZModuleOperationInfo::STATUS_REPEAT; } else { return eZModuleOperationInfo::STATUS_HALTED; } } else if ( $status['Status'] == eZTrigger::WORKFLOW_CANCELLED or $status['Status'] == eZTrigger::WORKFLOW_RESET ) { return eZModuleOperationInfo::STATUS_CANCELLED; $bodyReturnValue['result'] = $status['Result']; } }
[ "function", "executeTrigger", "(", "&", "$", "bodyReturnValue", ",", "$", "body", ",", "$", "operationParameterDefinitions", ",", "$", "operationParameters", ",", "&", "$", "bodyCallCount", ",", "$", "currentLoopData", ",", "$", "triggerRestored", ",", "$", "ope...
Executes an operation trigger @param array $bodyReturnValue The current return value @param array $body Body data for the trigger being executed @param array $operationParameterDefinitions Operation parameters definition @param array $operationParameters Operation parameters values @param int $bodyCallCount Number of times the body was called @param array $currentLoopData Memento data for the operation @param bool $triggerRestored Boolean that indicates if operation data (memento) was restored @param string $operationName The operation name @param array $operationKeys Additional parameters. Only used by looping so far. @return
[ "Executes", "an", "operation", "trigger" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmoduleoperationinfo.php#L597-L657
train
ezsystems/ezpublish-legacy
lib/ezutils/classes/ezmoduleoperationinfo.php
eZModuleOperationInfo.executeClassMethod
function executeClassMethod( $includeFile, $className, $methodName, $operationParameterDefinitions, $operationParameters ) { if ( !class_exists( $className ) ) { include_once( $includeFile ); if ( !class_exists( $className, false ) ) { return array( 'internal_error' => eZModuleOperationInfo::ERROR_NO_CLASS, 'internal_error_class_name' => $className ); } } $classObject = $this->objectForClass( $className ); if ( $classObject === null ) { return array( 'internal_error' => eZModuleOperationInfo::ERROR_CLASS_INSTANTIATE_FAILED, 'internal_error_class_name' => $className ); } if ( !method_exists( $classObject, $methodName ) ) { return array( 'internal_error' => eZModuleOperationInfo::ERROR_NO_CLASS_METHOD, 'internal_error_class_name' => $className, 'internal_error_class_method_name' => $methodName ); } $parameterArray = array(); foreach ( $operationParameterDefinitions as $operationParameterDefinition ) { $parameterName = $operationParameterDefinition['name']; if ( isset( $operationParameterDefinition['constant'] ) ) { $constantValue = $operationParameterDefinition['constant']; $parameterArray[] = $constantValue; } else if ( isset( $operationParameters[$parameterName] ) ) { // Do type checking $parameterArray[] = $operationParameters[$parameterName]; } else { if ( $operationParameterDefinition['required'] ) { return array( 'internal_error' => eZModuleOperationInfo::ERROR_MISSING_PARAMETER, 'internal_error_parameter_name' => $parameterName ); } else if ( isset( $operationParameterDefinition['default'] ) ) { $parameterArray[] = $operationParameterDefinition['default']; } else { $parameterArray[] = null; } } } return call_user_func_array( array( $classObject, $methodName ), $parameterArray ); }
php
function executeClassMethod( $includeFile, $className, $methodName, $operationParameterDefinitions, $operationParameters ) { if ( !class_exists( $className ) ) { include_once( $includeFile ); if ( !class_exists( $className, false ) ) { return array( 'internal_error' => eZModuleOperationInfo::ERROR_NO_CLASS, 'internal_error_class_name' => $className ); } } $classObject = $this->objectForClass( $className ); if ( $classObject === null ) { return array( 'internal_error' => eZModuleOperationInfo::ERROR_CLASS_INSTANTIATE_FAILED, 'internal_error_class_name' => $className ); } if ( !method_exists( $classObject, $methodName ) ) { return array( 'internal_error' => eZModuleOperationInfo::ERROR_NO_CLASS_METHOD, 'internal_error_class_name' => $className, 'internal_error_class_method_name' => $methodName ); } $parameterArray = array(); foreach ( $operationParameterDefinitions as $operationParameterDefinition ) { $parameterName = $operationParameterDefinition['name']; if ( isset( $operationParameterDefinition['constant'] ) ) { $constantValue = $operationParameterDefinition['constant']; $parameterArray[] = $constantValue; } else if ( isset( $operationParameters[$parameterName] ) ) { // Do type checking $parameterArray[] = $operationParameters[$parameterName]; } else { if ( $operationParameterDefinition['required'] ) { return array( 'internal_error' => eZModuleOperationInfo::ERROR_MISSING_PARAMETER, 'internal_error_parameter_name' => $parameterName ); } else if ( isset( $operationParameterDefinition['default'] ) ) { $parameterArray[] = $operationParameterDefinition['default']; } else { $parameterArray[] = null; } } } return call_user_func_array( array( $classObject, $methodName ), $parameterArray ); }
[ "function", "executeClassMethod", "(", "$", "includeFile", ",", "$", "className", ",", "$", "methodName", ",", "$", "operationParameterDefinitions", ",", "$", "operationParameters", ")", "{", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{"...
Executes a class method in an operation body @param string $includeFile The file where the class & method are defined @param string $className The class where the method is implemented @param string $methodName The method to call @param mixed $operationParameterDefinitions The method parameters definition @param mixed $operationParameters The method parameters values @return array
[ "Executes", "a", "class", "method", "in", "an", "operation", "body" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmoduleoperationinfo.php#L770-L830
train
ezsystems/ezpublish-legacy
lib/ezutils/classes/ezmoduleoperationinfo.php
eZModuleOperationInfo.objectForClass
function objectForClass( $className ) { if ( !isset( $GLOBALS['eZModuleOperationClassObjectList'] ) ) { $GLOBALS['eZModuleOperationClassObjectList'] = array(); } if ( isset( $GLOBALS['eZModuleOperationClassObjectList'][$className] ) ) { return $GLOBALS['eZModuleOperationClassObjectList'][$className]; } return $GLOBALS['eZModuleOperationClassObjectList'][$className] = new $className(); }
php
function objectForClass( $className ) { if ( !isset( $GLOBALS['eZModuleOperationClassObjectList'] ) ) { $GLOBALS['eZModuleOperationClassObjectList'] = array(); } if ( isset( $GLOBALS['eZModuleOperationClassObjectList'][$className] ) ) { return $GLOBALS['eZModuleOperationClassObjectList'][$className]; } return $GLOBALS['eZModuleOperationClassObjectList'][$className] = new $className(); }
[ "function", "objectForClass", "(", "$", "className", ")", "{", "if", "(", "!", "isset", "(", "$", "GLOBALS", "[", "'eZModuleOperationClassObjectList'", "]", ")", ")", "{", "$", "GLOBALS", "[", "'eZModuleOperationClassObjectList'", "]", "=", "array", "(", ")", ...
Helper method that keeps and returns the instances of operation objects @param string $className The class the method should return an object for @return $className @private @todo Use a static variable instead of globals
[ "Helper", "method", "that", "keeps", "and", "returns", "the", "instances", "of", "operation", "objects" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmoduleoperationinfo.php#L839-L851
train
ezsystems/ezpublish-legacy
kernel/classes/ezstaticcache.php
eZStaticCache.generateAlwaysUpdatedCache
public function generateAlwaysUpdatedCache( $quiet = false, $cli = false, $delay = true ) { foreach ( $this->alwaysUpdate as $uri ) { if ( !$quiet and $cli ) $cli->output( "caching: $uri ", false ); $this->storeCache( $uri, $this->staticStorageDir, array(), false, $delay ); if ( !$quiet and $cli ) $cli->output( "done" ); } }
php
public function generateAlwaysUpdatedCache( $quiet = false, $cli = false, $delay = true ) { foreach ( $this->alwaysUpdate as $uri ) { if ( !$quiet and $cli ) $cli->output( "caching: $uri ", false ); $this->storeCache( $uri, $this->staticStorageDir, array(), false, $delay ); if ( !$quiet and $cli ) $cli->output( "done" ); } }
[ "public", "function", "generateAlwaysUpdatedCache", "(", "$", "quiet", "=", "false", ",", "$", "cli", "=", "false", ",", "$", "delay", "=", "true", ")", "{", "foreach", "(", "$", "this", "->", "alwaysUpdate", "as", "$", "uri", ")", "{", "if", "(", "!...
Generates the caches for all URLs that must always be generated. @param bool $quiet If true then the function will not output anything. @param eZCLI|false $cli The eZCLI object or false if no output can be done. @param bool $delay
[ "Generates", "the", "caches", "for", "all", "URLs", "that", "must", "always", "be", "generated", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezstaticcache.php#L166-L176
train
ezsystems/ezpublish-legacy
kernel/classes/ezstaticcache.php
eZStaticCache.generateCache
public function generateCache( $force = false, $quiet = false, $cli = false, $delay = true ) { $staticURLArray = $this->cachedURLArray(); $db = eZDB::instance(); $configSettingCount = count( $staticURLArray ); $currentSetting = 0; // This contains parent elements which must checked to find new urls and put them in $generateList // Each entry contains: // - url - Url of parent // - glob - A glob string to filter direct children based on name // - org_url - The original url which was requested // - parent_id - The element ID of the parent (optional) // The parent_id will be used to quickly fetch the children, if not it will use the url $parentList = array(); // A list of urls which must generated, each entry is a string with the url $generateList = array(); foreach ( $staticURLArray as $url ) { $currentSetting++; if ( strpos( $url, '*') === false ) { $generateList[] = $url; } else { $queryURL = ltrim( str_replace( '*', '', $url ), '/' ); $dir = dirname( $queryURL ); if ( $dir == '.' ) $dir = ''; $glob = basename( $queryURL ); $parentList[] = array( 'url' => $dir, 'glob' => $glob, 'org_url' => $url ); } } // As long as we have urls to generate or parents to check we loop while ( count( $generateList ) > 0 || count( $parentList ) > 0 ) { // First generate single urls foreach ( $generateList as $generateURL ) { if ( !$quiet and $cli ) $cli->output( "caching: $generateURL ", false ); $this->cacheURL( $generateURL, false, !$force, $delay ); if ( !$quiet and $cli ) $cli->output( "done" ); } $generateList = array(); // Then check for more data $newParentList = array(); foreach ( $parentList as $parentURL ) { if ( isset( $parentURL['parent_id'] ) ) { $elements = eZURLAliasML::fetchByParentID( $parentURL['parent_id'], true, true, false ); foreach ( $elements as $element ) { $path = '/' . $element->getPath(); $generateList[] = $path; $newParentList[] = array( 'parent_id' => $element->attribute( 'id' ) ); } } else { if ( !$quiet and $cli and $parentURL['glob'] ) $cli->output( "wildcard cache: " . $parentURL['url'] . '/' . $parentURL['glob'] . "*" ); $elements = eZURLAliasML::fetchByPath( $parentURL['url'], $parentURL['glob'] ); foreach ( $elements as $element ) { $path = '/' . $element->getPath(); $generateList[] = $path; $newParentList[] = array( 'parent_id' => $element->attribute( 'id' ) ); } } } $parentList = $newParentList; } }
php
public function generateCache( $force = false, $quiet = false, $cli = false, $delay = true ) { $staticURLArray = $this->cachedURLArray(); $db = eZDB::instance(); $configSettingCount = count( $staticURLArray ); $currentSetting = 0; // This contains parent elements which must checked to find new urls and put them in $generateList // Each entry contains: // - url - Url of parent // - glob - A glob string to filter direct children based on name // - org_url - The original url which was requested // - parent_id - The element ID of the parent (optional) // The parent_id will be used to quickly fetch the children, if not it will use the url $parentList = array(); // A list of urls which must generated, each entry is a string with the url $generateList = array(); foreach ( $staticURLArray as $url ) { $currentSetting++; if ( strpos( $url, '*') === false ) { $generateList[] = $url; } else { $queryURL = ltrim( str_replace( '*', '', $url ), '/' ); $dir = dirname( $queryURL ); if ( $dir == '.' ) $dir = ''; $glob = basename( $queryURL ); $parentList[] = array( 'url' => $dir, 'glob' => $glob, 'org_url' => $url ); } } // As long as we have urls to generate or parents to check we loop while ( count( $generateList ) > 0 || count( $parentList ) > 0 ) { // First generate single urls foreach ( $generateList as $generateURL ) { if ( !$quiet and $cli ) $cli->output( "caching: $generateURL ", false ); $this->cacheURL( $generateURL, false, !$force, $delay ); if ( !$quiet and $cli ) $cli->output( "done" ); } $generateList = array(); // Then check for more data $newParentList = array(); foreach ( $parentList as $parentURL ) { if ( isset( $parentURL['parent_id'] ) ) { $elements = eZURLAliasML::fetchByParentID( $parentURL['parent_id'], true, true, false ); foreach ( $elements as $element ) { $path = '/' . $element->getPath(); $generateList[] = $path; $newParentList[] = array( 'parent_id' => $element->attribute( 'id' ) ); } } else { if ( !$quiet and $cli and $parentURL['glob'] ) $cli->output( "wildcard cache: " . $parentURL['url'] . '/' . $parentURL['glob'] . "*" ); $elements = eZURLAliasML::fetchByPath( $parentURL['url'], $parentURL['glob'] ); foreach ( $elements as $element ) { $path = '/' . $element->getPath(); $generateList[] = $path; $newParentList[] = array( 'parent_id' => $element->attribute( 'id' ) ); } } } $parentList = $newParentList; } }
[ "public", "function", "generateCache", "(", "$", "force", "=", "false", ",", "$", "quiet", "=", "false", ",", "$", "cli", "=", "false", ",", "$", "delay", "=", "true", ")", "{", "$", "staticURLArray", "=", "$", "this", "->", "cachedURLArray", "(", ")...
Generates the static cache from the configured INI settings. @param bool $force If true then it will create all static caches even if it is not outdated. @param bool $quiet If true then the function will not output anything. @param eZCLI|false $cli The eZCLI object or false if no output can be done. @param bool $delay
[ "Generates", "the", "static", "cache", "from", "the", "configured", "INI", "settings", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezstaticcache.php#L227-L307
train
ezsystems/ezpublish-legacy
kernel/classes/ezstaticcache.php
eZStaticCache.buildCacheDirPath
private function buildCacheDirPath( $siteAccess ) { $dirParts = array(); $ini = eZINI::instance(); $matchOderArray = $ini->variableArray( 'SiteAccessSettings', 'MatchOrder' ); foreach ( $matchOderArray as $matchOrderItem ) { switch ( $matchOrderItem ) { case 'host_uri': foreach ( $ini->variable( 'SiteAccessSettings', 'HostUriMatchMapItems' ) as $hostUriMatchMapItem ) { $parts = explode( ';', $hostUriMatchMapItem ); if ( $parts[2] === $siteAccess ) { $dirParts[] = $this->buildCacheDirPart( ( $parts[0] ? '/' . $parts[0] : '' ) . ( $parts[1] ? '/' . $parts[1] : '' ), $siteAccess ); } } break; case 'host': foreach ( $ini->variable( 'SiteAccessSettings', 'HostMatchMapItems' ) as $hostMatchMapItem ) { $parts = explode( ';', $hostMatchMapItem ); if ( $parts[1] === $siteAccess ) { $dirParts[] = $this->buildCacheDirPart( ( $parts[0] ? '/' . $parts[0] : '' ), $siteAccess ); } } break; default: $dirParts[] = $this->buildCacheDirPart( '/' . $siteAccess, $siteAccess ); break; } } return $dirParts; }
php
private function buildCacheDirPath( $siteAccess ) { $dirParts = array(); $ini = eZINI::instance(); $matchOderArray = $ini->variableArray( 'SiteAccessSettings', 'MatchOrder' ); foreach ( $matchOderArray as $matchOrderItem ) { switch ( $matchOrderItem ) { case 'host_uri': foreach ( $ini->variable( 'SiteAccessSettings', 'HostUriMatchMapItems' ) as $hostUriMatchMapItem ) { $parts = explode( ';', $hostUriMatchMapItem ); if ( $parts[2] === $siteAccess ) { $dirParts[] = $this->buildCacheDirPart( ( $parts[0] ? '/' . $parts[0] : '' ) . ( $parts[1] ? '/' . $parts[1] : '' ), $siteAccess ); } } break; case 'host': foreach ( $ini->variable( 'SiteAccessSettings', 'HostMatchMapItems' ) as $hostMatchMapItem ) { $parts = explode( ';', $hostMatchMapItem ); if ( $parts[1] === $siteAccess ) { $dirParts[] = $this->buildCacheDirPart( ( $parts[0] ? '/' . $parts[0] : '' ), $siteAccess ); } } break; default: $dirParts[] = $this->buildCacheDirPart( '/' . $siteAccess, $siteAccess ); break; } } return $dirParts; }
[ "private", "function", "buildCacheDirPath", "(", "$", "siteAccess", ")", "{", "$", "dirParts", "=", "array", "(", ")", ";", "$", "ini", "=", "eZINI", "::", "instance", "(", ")", ";", "$", "matchOderArray", "=", "$", "ini", "->", "variableArray", "(", "...
Generates a cache directory parts including path, siteaccess name, site URL depending on the match order type. @param string $siteAccess @return array
[ "Generates", "a", "cache", "directory", "parts", "including", "path", "siteaccess", "name", "site", "URL", "depending", "on", "the", "match", "order", "type", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezstaticcache.php#L450-L492
train
ezsystems/ezpublish-legacy
kernel/classes/ezstaticcache.php
eZStaticCache.executeActions
static function executeActions() { if ( empty( self::$actionList ) ) { return; } $fileContentCache = array(); $doneDestList = array(); $ini = eZINI::instance( 'staticcache.ini'); $clearByCronjob = ( $ini->variable( 'CacheSettings', 'CronjobCacheClear' ) == 'enabled' ); if ( $clearByCronjob ) { $db = eZDB::instance(); } foreach ( self::$actionList as $action ) { list( $action, $parameters ) = $action; switch( $action ) { case 'store': list( $destination, $source ) = $parameters; if ( isset( $doneDestList[$destination] ) ) continue 2; if ( $clearByCronjob ) { $param = $db->escapeString( $destination . ',' . $source ); $db->query( 'INSERT INTO ezpending_actions( action, param ) VALUES ( \'static_store\', \''. $param . '\' )' ); $doneDestList[$destination] = 1; } else { if ( !isset( $fileContentCache[$source] ) ) { if ( eZHTTPTool::getDataByURL( $source, true, eZStaticCache::USER_AGENT ) ) $fileContentCache[$source] = eZHTTPTool::getDataByURL( $source, false, eZStaticCache::USER_AGENT ); else $fileContentCache[$source] = false; } if ( $fileContentCache[$source] === false ) { eZDebug::writeError( "Could not grab content (from $source), is the hostname correct and Apache running?", 'Static Cache' ); } else { eZStaticCache::storeCachedFile( $destination, $fileContentCache[$source] ); $doneDestList[$destination] = 1; } } break; } } self::$actionList = array(); }
php
static function executeActions() { if ( empty( self::$actionList ) ) { return; } $fileContentCache = array(); $doneDestList = array(); $ini = eZINI::instance( 'staticcache.ini'); $clearByCronjob = ( $ini->variable( 'CacheSettings', 'CronjobCacheClear' ) == 'enabled' ); if ( $clearByCronjob ) { $db = eZDB::instance(); } foreach ( self::$actionList as $action ) { list( $action, $parameters ) = $action; switch( $action ) { case 'store': list( $destination, $source ) = $parameters; if ( isset( $doneDestList[$destination] ) ) continue 2; if ( $clearByCronjob ) { $param = $db->escapeString( $destination . ',' . $source ); $db->query( 'INSERT INTO ezpending_actions( action, param ) VALUES ( \'static_store\', \''. $param . '\' )' ); $doneDestList[$destination] = 1; } else { if ( !isset( $fileContentCache[$source] ) ) { if ( eZHTTPTool::getDataByURL( $source, true, eZStaticCache::USER_AGENT ) ) $fileContentCache[$source] = eZHTTPTool::getDataByURL( $source, false, eZStaticCache::USER_AGENT ); else $fileContentCache[$source] = false; } if ( $fileContentCache[$source] === false ) { eZDebug::writeError( "Could not grab content (from $source), is the hostname correct and Apache running?", 'Static Cache' ); } else { eZStaticCache::storeCachedFile( $destination, $fileContentCache[$source] ); $doneDestList[$destination] = 1; } } break; } } self::$actionList = array(); }
[ "static", "function", "executeActions", "(", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "actionList", ")", ")", "{", "return", ";", "}", "$", "fileContentCache", "=", "array", "(", ")", ";", "$", "doneDestList", "=", "array", "(", ")", ";"...
This function goes over the list of recorded actions and excecutes them.
[ "This", "function", "goes", "over", "the", "list", "of", "recorded", "actions", "and", "excecutes", "them", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezstaticcache.php#L576-L634
train
ezsystems/ezpublish-legacy
kernel/classes/eznamepatternresolver.php
eZNamePatternResolver.resolveNamePattern
public function resolveNamePattern( $limit = 0, $sequence = '' ) { // Fetch attributes for present identifiers $this->fetchContentAttributes(); // Replace tokens with real values $objectName = $this->translatePattern(); $db = eZDB::instance(); $limit = $limit ?: self::FIELD_NAME_MAX_SIZE; if ( $db->countStringSize( $objectName ) <= $limit ) { return $objectName; } return preg_replace( "/[\pZ\pC]+$/u", '', $db->truncateString( $objectName, $limit, 'name', $sequence ) ). $sequence; }
php
public function resolveNamePattern( $limit = 0, $sequence = '' ) { // Fetch attributes for present identifiers $this->fetchContentAttributes(); // Replace tokens with real values $objectName = $this->translatePattern(); $db = eZDB::instance(); $limit = $limit ?: self::FIELD_NAME_MAX_SIZE; if ( $db->countStringSize( $objectName ) <= $limit ) { return $objectName; } return preg_replace( "/[\pZ\pC]+$/u", '', $db->truncateString( $objectName, $limit, 'name', $sequence ) ). $sequence; }
[ "public", "function", "resolveNamePattern", "(", "$", "limit", "=", "0", ",", "$", "sequence", "=", "''", ")", "{", "// Fetch attributes for present identifiers", "$", "this", "->", "fetchContentAttributes", "(", ")", ";", "// Replace tokens with real values", "$", ...
Return the real name for an object name pattern @param int $limit The limit on the string length, by defaul 0 aka none @param string $sequence End sequence applied to string if limit has been reached @return string
[ "Return", "the", "real", "name", "for", "an", "object", "name", "pattern" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/eznamepatternresolver.php#L127-L149
train
ezsystems/ezpublish-legacy
kernel/classes/eznamepatternresolver.php
eZNamePatternResolver.fetchContentAttributes
private function fetchContentAttributes() { $returnAttributeArray = array(); $identifierArray = $this->getIdentifiers( $this->origNamePattern ); $attributes = $this->contentObject->fetchAttributesByIdentifier( $identifierArray, $this->version, array( $this->translation ) ); if ( is_array( $attributes ) ) { foreach ( $attributes as $attribute ) { $identifier = $attribute->contentClassAttributeIdentifier(); $returnAttributeArray[$identifier] = $attribute->title(); } } else { $returnAttributeArray = array(); } $this->attributeArray = $returnAttributeArray; }
php
private function fetchContentAttributes() { $returnAttributeArray = array(); $identifierArray = $this->getIdentifiers( $this->origNamePattern ); $attributes = $this->contentObject->fetchAttributesByIdentifier( $identifierArray, $this->version, array( $this->translation ) ); if ( is_array( $attributes ) ) { foreach ( $attributes as $attribute ) { $identifier = $attribute->contentClassAttributeIdentifier(); $returnAttributeArray[$identifier] = $attribute->title(); } } else { $returnAttributeArray = array(); } $this->attributeArray = $returnAttributeArray; }
[ "private", "function", "fetchContentAttributes", "(", ")", "{", "$", "returnAttributeArray", "=", "array", "(", ")", ";", "$", "identifierArray", "=", "$", "this", "->", "getIdentifiers", "(", "$", "this", "->", "origNamePattern", ")", ";", "$", "attributes", ...
Fetches the list of available class-identifiers in the token, and it will only fetch the attributes which appear amongst the identifiers found in tokens. @return void
[ "Fetches", "the", "list", "of", "available", "class", "-", "identifiers", "in", "the", "token", "and", "it", "will", "only", "fetch", "the", "attributes", "which", "appear", "amongst", "the", "identifiers", "found", "in", "tokens", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/eznamepatternresolver.php#L158-L179
train
ezsystems/ezpublish-legacy
kernel/classes/eznamepatternresolver.php
eZNamePatternResolver.translatePattern
private function translatePattern() { $tokenArray = $this->extractTokens( $this->namePattern ); $objectName = $this->namePattern; foreach( $tokenArray as $token ) { $string = $this->resolveToken( $token ); $objectName = str_replace( $token, $string, $objectName ); } return $objectName; }
php
private function translatePattern() { $tokenArray = $this->extractTokens( $this->namePattern ); $objectName = $this->namePattern; foreach( $tokenArray as $token ) { $string = $this->resolveToken( $token ); $objectName = str_replace( $token, $string, $objectName ); } return $objectName; }
[ "private", "function", "translatePattern", "(", ")", "{", "$", "tokenArray", "=", "$", "this", "->", "extractTokens", "(", "$", "this", "->", "namePattern", ")", ";", "$", "objectName", "=", "$", "this", "->", "namePattern", ";", "foreach", "(", "$", "to...
Replaces tokens in the name pattern with their resolved values. @return string
[ "Replaces", "tokens", "in", "the", "name", "pattern", "with", "their", "resolved", "values", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/eznamepatternresolver.php#L187-L199
train
Novactive/NovaeZSEOBundle
Core/FieldType/Metas/MetasStorage/Gateway/LegacyStorage.php
LegacyStorage.storeFieldData
public function storeFieldData( VersionInfo $versionInfo, Field $field ) { $connection = $this->getConnection(); foreach ( $field->value->externalData as $meta ) { $insertQuery = $connection->createInsertQuery(); $insertQuery ->insertInto( $connection->quoteTable( self::TABLE ) ) ->set( $connection->quoteColumn( "meta_name" ), $insertQuery->bindValue( $meta["meta_name"], null, PDO::PARAM_STR ) )->set( $connection->quoteColumn( "meta_content" ), $insertQuery->bindValue( $meta["meta_content"], null, PDO::PARAM_STR ) )->set( $connection->quoteColumn( "objectattribute_id" ), $insertQuery->bindValue( $field->id, null, PDO::PARAM_INT ) )->set( $connection->quoteColumn( "objectattribute_version" ), $insertQuery->bindValue( $versionInfo->versionNo, null, PDO::PARAM_INT ) ); $insertQuery->prepare()->execute(); } }
php
public function storeFieldData( VersionInfo $versionInfo, Field $field ) { $connection = $this->getConnection(); foreach ( $field->value->externalData as $meta ) { $insertQuery = $connection->createInsertQuery(); $insertQuery ->insertInto( $connection->quoteTable( self::TABLE ) ) ->set( $connection->quoteColumn( "meta_name" ), $insertQuery->bindValue( $meta["meta_name"], null, PDO::PARAM_STR ) )->set( $connection->quoteColumn( "meta_content" ), $insertQuery->bindValue( $meta["meta_content"], null, PDO::PARAM_STR ) )->set( $connection->quoteColumn( "objectattribute_id" ), $insertQuery->bindValue( $field->id, null, PDO::PARAM_INT ) )->set( $connection->quoteColumn( "objectattribute_version" ), $insertQuery->bindValue( $versionInfo->versionNo, null, PDO::PARAM_INT ) ); $insertQuery->prepare()->execute(); } }
[ "public", "function", "storeFieldData", "(", "VersionInfo", "$", "versionInfo", ",", "Field", "$", "field", ")", "{", "$", "connection", "=", "$", "this", "->", "getConnection", "(", ")", ";", "foreach", "(", "$", "field", "->", "value", "->", "externalDat...
Stores the metas in the database based on the given field data @param VersionInfo $versionInfo @param Field $field
[ "Stores", "the", "metas", "in", "the", "database", "based", "on", "the", "given", "field", "data" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Core/FieldType/Metas/MetasStorage/Gateway/LegacyStorage.php#L85-L108
train
Novactive/NovaeZSEOBundle
Core/FieldType/Metas/MetasStorage/Gateway/LegacyStorage.php
LegacyStorage.getFieldData
public function getFieldData( VersionInfo $versionInfo, Field $field ) { $field->value->externalData = $this->loadFieldData( $versionInfo, $field ); }
php
public function getFieldData( VersionInfo $versionInfo, Field $field ) { $field->value->externalData = $this->loadFieldData( $versionInfo, $field ); }
[ "public", "function", "getFieldData", "(", "VersionInfo", "$", "versionInfo", ",", "Field", "$", "field", ")", "{", "$", "field", "->", "value", "->", "externalData", "=", "$", "this", "->", "loadFieldData", "(", "$", "versionInfo", ",", "$", "field", ")",...
Gets the metas stored in the field @param VersionInfo $versionInfo @param Field $field
[ "Gets", "the", "metas", "stored", "in", "the", "field" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Core/FieldType/Metas/MetasStorage/Gateway/LegacyStorage.php#L116-L119
train
Novactive/NovaeZSEOBundle
DependencyInjection/Compiler/CustomFallbackPass.php
CustomFallbackPass.process
public function process(ContainerBuilder $container) { $configs = $container->getExtensionConfig('nova_ezseo'); //@todo: How to do that by SiteAccess if (isset($configs[0]['system']['default']['custom_fallback_service'])) { $fallbackService = $configs[0]['system']['default']['custom_fallback_service']; if ($fallbackService !== null) { $container->getDefinition('novactive.novaseobundle.twig_extension')->addMethodCall( "setCustomFallbackService", [new Reference($fallbackService)] ); } } }
php
public function process(ContainerBuilder $container) { $configs = $container->getExtensionConfig('nova_ezseo'); //@todo: How to do that by SiteAccess if (isset($configs[0]['system']['default']['custom_fallback_service'])) { $fallbackService = $configs[0]['system']['default']['custom_fallback_service']; if ($fallbackService !== null) { $container->getDefinition('novactive.novaseobundle.twig_extension')->addMethodCall( "setCustomFallbackService", [new Reference($fallbackService)] ); } } }
[ "public", "function", "process", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "configs", "=", "$", "container", "->", "getExtensionConfig", "(", "'nova_ezseo'", ")", ";", "//@todo: How to do that by SiteAccess", "if", "(", "isset", "(", "$", "configs"...
Process the configuration @param ContainerBuilder $container
[ "Process", "the", "configuration" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/DependencyInjection/Compiler/CustomFallbackPass.php#L26-L40
train
Novactive/NovaeZSEOBundle
Core/FieldType/Metas/FormMapper.php
FormMapper.mapFieldValueForm
public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data) { $fieldDefinition = $data->fieldDefinition; $formConfig = $fieldForm->getConfig(); $metasConfig = $this->configResolver->getParameter('fieldtype_metas', 'nova_ezseo'); if (empty($data->value->metas)) { foreach ($metasConfig as $key => $meta) { $data->value->metas[$key] = new Meta($key, ''); } } $fieldForm ->add( $formConfig->getFormFactory()->createBuilder() ->create('value', MetasFieldType::class, [ 'required' => $fieldDefinition->isRequired, 'label' => $fieldDefinition->getName($formConfig->getOption('languageCode')), ]) ->setAutoInitialize(false) ->getForm() ); }
php
public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data) { $fieldDefinition = $data->fieldDefinition; $formConfig = $fieldForm->getConfig(); $metasConfig = $this->configResolver->getParameter('fieldtype_metas', 'nova_ezseo'); if (empty($data->value->metas)) { foreach ($metasConfig as $key => $meta) { $data->value->metas[$key] = new Meta($key, ''); } } $fieldForm ->add( $formConfig->getFormFactory()->createBuilder() ->create('value', MetasFieldType::class, [ 'required' => $fieldDefinition->isRequired, 'label' => $fieldDefinition->getName($formConfig->getOption('languageCode')), ]) ->setAutoInitialize(false) ->getForm() ); }
[ "public", "function", "mapFieldValueForm", "(", "FormInterface", "$", "fieldForm", ",", "FieldData", "$", "data", ")", "{", "$", "fieldDefinition", "=", "$", "data", "->", "fieldDefinition", ";", "$", "formConfig", "=", "$", "fieldForm", "->", "getConfig", "("...
Maps Field form to current FieldType. Allows to add form fields for content edition. @param FormInterface $fieldForm Form for the current Field. @param FieldData $data Underlying data for current Field form.
[ "Maps", "Field", "form", "to", "current", "FieldType", ".", "Allows", "to", "add", "form", "fields", "for", "content", "edition", "." ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Core/FieldType/Metas/FormMapper.php#L78-L101
train
Novactive/NovaeZSEOBundle
Installer/Field.php
Field.addToContentType
public function addToContentType($fieldName, ContentType $contentType) { try { $contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentType->id); } catch (NotFoundException $e) { $contentTypeDraft = $this->contentTypeService->createContentTypeDraft($contentType); } $typeUpdate = $this->contentTypeService->newContentTypeUpdateStruct(); $typeUpdate->modificationDate = new DateTime(); $knowLanguage = array_keys($contentType->getDescriptions()); if (!in_array($contentType->mainLanguageCode, $knowLanguage)) { $knowLanguage[] = $contentType->mainLanguageCode; } $fieldCreateStruct = $this->contentTypeService->newFieldDefinitionCreateStruct( $fieldName, 'novaseometas' ); $fieldCreateStruct->names = array_fill_keys($knowLanguage, $this->metaFieldName); $fieldCreateStruct->descriptions = array_fill_keys($knowLanguage, $this->metaFieldDescription); $fieldCreateStruct->fieldGroup = $this->metaFieldGroup; $fieldCreateStruct->position = 100; $fieldCreateStruct->isTranslatable = true; $fieldCreateStruct->isRequired = false; $fieldCreateStruct->isSearchable = false; $fieldCreateStruct->isInfoCollector = false; try { $this->contentTypeService->updateContentTypeDraft($contentTypeDraft, $typeUpdate); if ($contentTypeDraft->getFieldDefinition($fieldName) == null) { $this->contentTypeService->addFieldDefinition($contentTypeDraft, $fieldCreateStruct); } $this->contentTypeService->publishContentTypeDraft($contentTypeDraft); return true; } catch (Exception $e) { $this->errorMessage = $e->getMessage(); return false; } }
php
public function addToContentType($fieldName, ContentType $contentType) { try { $contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentType->id); } catch (NotFoundException $e) { $contentTypeDraft = $this->contentTypeService->createContentTypeDraft($contentType); } $typeUpdate = $this->contentTypeService->newContentTypeUpdateStruct(); $typeUpdate->modificationDate = new DateTime(); $knowLanguage = array_keys($contentType->getDescriptions()); if (!in_array($contentType->mainLanguageCode, $knowLanguage)) { $knowLanguage[] = $contentType->mainLanguageCode; } $fieldCreateStruct = $this->contentTypeService->newFieldDefinitionCreateStruct( $fieldName, 'novaseometas' ); $fieldCreateStruct->names = array_fill_keys($knowLanguage, $this->metaFieldName); $fieldCreateStruct->descriptions = array_fill_keys($knowLanguage, $this->metaFieldDescription); $fieldCreateStruct->fieldGroup = $this->metaFieldGroup; $fieldCreateStruct->position = 100; $fieldCreateStruct->isTranslatable = true; $fieldCreateStruct->isRequired = false; $fieldCreateStruct->isSearchable = false; $fieldCreateStruct->isInfoCollector = false; try { $this->contentTypeService->updateContentTypeDraft($contentTypeDraft, $typeUpdate); if ($contentTypeDraft->getFieldDefinition($fieldName) == null) { $this->contentTypeService->addFieldDefinition($contentTypeDraft, $fieldCreateStruct); } $this->contentTypeService->publishContentTypeDraft($contentTypeDraft); return true; } catch (Exception $e) { $this->errorMessage = $e->getMessage(); return false; } }
[ "public", "function", "addToContentType", "(", "$", "fieldName", ",", "ContentType", "$", "contentType", ")", "{", "try", "{", "$", "contentTypeDraft", "=", "$", "this", "->", "contentTypeService", "->", "loadContentTypeDraft", "(", "$", "contentType", "->", "id...
Adds `metas` field to existing ContentType. @param string $fieldName @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType @return bool
[ "Adds", "metas", "field", "to", "existing", "ContentType", "." ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Installer/Field.php#L54-L100
train
Novactive/NovaeZSEOBundle
Installer/Field.php
Field.fieldExists
public function fieldExists($fieldName, ContentType $contentType) { $fieldDefinition = $contentType->getFieldDefinition($fieldName); if (empty($fieldDefinition)) { return false; } return true; }
php
public function fieldExists($fieldName, ContentType $contentType) { $fieldDefinition = $contentType->getFieldDefinition($fieldName); if (empty($fieldDefinition)) { return false; } return true; }
[ "public", "function", "fieldExists", "(", "$", "fieldName", ",", "ContentType", "$", "contentType", ")", "{", "$", "fieldDefinition", "=", "$", "contentType", "->", "getFieldDefinition", "(", "$", "fieldName", ")", ";", "if", "(", "empty", "(", "$", "fieldDe...
Checks if `metas` field exists in specified ContentType. @param string $fieldName @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType @return bool
[ "Checks", "if", "metas", "field", "exists", "in", "specified", "ContentType", "." ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Installer/Field.php#L110-L119
train
Novactive/NovaeZSEOBundle
Twig/NovaeZSEOExtension.php
NovaeZSEOExtension.computeMetas
public function computeMetas( Field $field, ContentInfo $contentInfo ) { $fallback = false; $languages = $this->configResolver->getParameter( 'languages' ); $contentType = $this->eZRepository->getContentTypeService()->loadContentType( $contentInfo->contentTypeId ); $content = $this->eZRepository->getContentService()->loadContentByContentInfo( $contentInfo, $languages ); $contentMetas = $this->innerComputeMetas( $content, $field, $contentType, $fallback ); if ( $fallback && !$this->customFallBackService) { $rootNode = $this->eZRepository->getLocationService()->loadLocation( $this->configResolver->getParameter( "content.tree_root.location_id" ) ); $rootContent = $this->eZRepository->getContentService()->loadContentByContentInfo( $rootNode->contentInfo, $languages ); $rootContentType = $this->eZRepository->getContentTypeService()->loadContentType( $rootContent->contentInfo->contentTypeId ); // We need to load the good field too $metasIdentifier = $this->configResolver->getParameter( 'fieldtype_metas_identifier', 'nova_ezseo' ); $rootMetas = $this->innerComputeMetas( $rootContent, $metasIdentifier, $rootContentType, $fallback ); foreach ( $contentMetas as $key => $metaContent ) { if ( array_key_exists( $key, $rootMetas ) ) { $metaContent->setContent( $metaContent->isEmpty() ? $rootMetas[$key]->getContent() : $metaContent->getContent() ); } } } return ''; }
php
public function computeMetas( Field $field, ContentInfo $contentInfo ) { $fallback = false; $languages = $this->configResolver->getParameter( 'languages' ); $contentType = $this->eZRepository->getContentTypeService()->loadContentType( $contentInfo->contentTypeId ); $content = $this->eZRepository->getContentService()->loadContentByContentInfo( $contentInfo, $languages ); $contentMetas = $this->innerComputeMetas( $content, $field, $contentType, $fallback ); if ( $fallback && !$this->customFallBackService) { $rootNode = $this->eZRepository->getLocationService()->loadLocation( $this->configResolver->getParameter( "content.tree_root.location_id" ) ); $rootContent = $this->eZRepository->getContentService()->loadContentByContentInfo( $rootNode->contentInfo, $languages ); $rootContentType = $this->eZRepository->getContentTypeService()->loadContentType( $rootContent->contentInfo->contentTypeId ); // We need to load the good field too $metasIdentifier = $this->configResolver->getParameter( 'fieldtype_metas_identifier', 'nova_ezseo' ); $rootMetas = $this->innerComputeMetas( $rootContent, $metasIdentifier, $rootContentType, $fallback ); foreach ( $contentMetas as $key => $metaContent ) { if ( array_key_exists( $key, $rootMetas ) ) { $metaContent->setContent( $metaContent->isEmpty() ? $rootMetas[$key]->getContent() : $metaContent->getContent() ); } } } return ''; }
[ "public", "function", "computeMetas", "(", "Field", "$", "field", ",", "ContentInfo", "$", "contentInfo", ")", "{", "$", "fallback", "=", "false", ";", "$", "languages", "=", "$", "this", "->", "configResolver", "->", "getParameter", "(", "'languages'", ")",...
Compute Metas of the Field thanks to its Content and the Fallback @param Field $field @param ContentInfo $contentInfo @return string
[ "Compute", "Metas", "of", "the", "Field", "thanks", "to", "its", "Content", "and", "the", "Fallback" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Twig/NovaeZSEOExtension.php#L142-L172
train
Novactive/NovaeZSEOBundle
Twig/NovaeZSEOExtension.php
NovaeZSEOExtension.innerComputeMetas
protected function innerComputeMetas( Content $content, $fieldDefIdentifier, ContentType $contentType, &$needFallback = false ) { if ( $fieldDefIdentifier instanceof Field ) { $metasFieldValue = $fieldDefIdentifier->value; $fieldDefIdentifier = $fieldDefIdentifier->fieldDefIdentifier; } else { $metasFieldValue = $content->getFieldValue( $fieldDefIdentifier ); } if ( $metasFieldValue instanceof MetasFieldValue ) { $metasConfig = $this->configResolver->getParameter( 'fieldtype_metas', 'nova_ezseo' ); // as the configuration is the last fallback we need to loop on it. foreach ( $metasConfig as $metaName => $metasSettings ) { if ( $metasFieldValue->nameExists( $metaName ) ) { $meta = $metasFieldValue->metas[$metaName]; } else { $meta = new Meta( $metaName ); $metasFieldValue->metas[$metaName] = $meta; } /** @var Meta $meta */ if ( $meta->isEmpty() ) { $meta->setContent( $metasConfig[$meta->getName()]['default_pattern'] ); $fieldDefinition = $contentType->getFieldDefinition( $fieldDefIdentifier ); $configuration = $fieldDefinition->getFieldSettings()['configuration']; // but if we need something is the configuration we take it if ( isset($configuration[$meta->getName()]) && !empty($configuration[$meta->getName()]) ) { $meta->setContent( $configuration[$meta->getName()] ); } } if ( !$this->metaNameSchema->resolveMeta( $meta, $content, $contentType ) ) { $needFallback = true; } } return $metasFieldValue->metas; } return []; }
php
protected function innerComputeMetas( Content $content, $fieldDefIdentifier, ContentType $contentType, &$needFallback = false ) { if ( $fieldDefIdentifier instanceof Field ) { $metasFieldValue = $fieldDefIdentifier->value; $fieldDefIdentifier = $fieldDefIdentifier->fieldDefIdentifier; } else { $metasFieldValue = $content->getFieldValue( $fieldDefIdentifier ); } if ( $metasFieldValue instanceof MetasFieldValue ) { $metasConfig = $this->configResolver->getParameter( 'fieldtype_metas', 'nova_ezseo' ); // as the configuration is the last fallback we need to loop on it. foreach ( $metasConfig as $metaName => $metasSettings ) { if ( $metasFieldValue->nameExists( $metaName ) ) { $meta = $metasFieldValue->metas[$metaName]; } else { $meta = new Meta( $metaName ); $metasFieldValue->metas[$metaName] = $meta; } /** @var Meta $meta */ if ( $meta->isEmpty() ) { $meta->setContent( $metasConfig[$meta->getName()]['default_pattern'] ); $fieldDefinition = $contentType->getFieldDefinition( $fieldDefIdentifier ); $configuration = $fieldDefinition->getFieldSettings()['configuration']; // but if we need something is the configuration we take it if ( isset($configuration[$meta->getName()]) && !empty($configuration[$meta->getName()]) ) { $meta->setContent( $configuration[$meta->getName()] ); } } if ( !$this->metaNameSchema->resolveMeta( $meta, $content, $contentType ) ) { $needFallback = true; } } return $metasFieldValue->metas; } return []; }
[ "protected", "function", "innerComputeMetas", "(", "Content", "$", "content", ",", "$", "fieldDefIdentifier", ",", "ContentType", "$", "contentType", ",", "&", "$", "needFallback", "=", "false", ")", "{", "if", "(", "$", "fieldDefIdentifier", "instanceof", "Fiel...
Compute Meta by reference @param Content $content @param string|Field $fieldDefIdentifier @param ContentType $contentType @param bool $needFallback @return Meta[]
[ "Compute", "Meta", "by", "reference" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Twig/NovaeZSEOExtension.php#L184-L232
train
Novactive/NovaeZSEOBundle
Controller/SEOController.php
SEOController.robotsAction
public function robotsAction() { $response = new Response(); $response->setSharedMaxAge( 24 * 3600 ); $robots = [ "User-agent: *" ]; if ( $this->get( 'kernel' )->getEnvironment() != "prod" ) { $robots[] = "Disallow: /"; } $rules = $this->getConfigResolver()->getParameter( 'robots_disallow', 'nova_ezseo' ); if ( is_array( $rules ) ) { foreach ( $rules as $rule ) { $robots[] = "Disallow: {$rule}"; } } $response->setContent( implode( "\n", $robots ) ); $response->headers->set( "Content-Type", "text/plain" ); return $response; }
php
public function robotsAction() { $response = new Response(); $response->setSharedMaxAge( 24 * 3600 ); $robots = [ "User-agent: *" ]; if ( $this->get( 'kernel' )->getEnvironment() != "prod" ) { $robots[] = "Disallow: /"; } $rules = $this->getConfigResolver()->getParameter( 'robots_disallow', 'nova_ezseo' ); if ( is_array( $rules ) ) { foreach ( $rules as $rule ) { $robots[] = "Disallow: {$rule}"; } } $response->setContent( implode( "\n", $robots ) ); $response->headers->set( "Content-Type", "text/plain" ); return $response; }
[ "public", "function", "robotsAction", "(", ")", "{", "$", "response", "=", "new", "Response", "(", ")", ";", "$", "response", "->", "setSharedMaxAge", "(", "24", "*", "3600", ")", ";", "$", "robots", "=", "[", "\"User-agent: *\"", "]", ";", "if", "(", ...
Robots.txt route @Route("/robots.txt") @Method("GET") @return Response
[ "Robots", ".", "txt", "route" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Controller/SEOController.php#L33-L54
train
Novactive/NovaeZSEOBundle
Controller/SEOController.php
SEOController.googleVerifAction
public function googleVerifAction( $key ) { if ( $this->getConfigResolver()->getParameter( 'google_verification', 'nova_ezseo' ) != $key ) { throw new NotFoundHttpException( "Google Verification Key not found" ); } $response = new Response(); $response->setSharedMaxAge( 24 * 3600 ); $response->setContent( "google-site-verification: google{$key}.html" ); return $response; }
php
public function googleVerifAction( $key ) { if ( $this->getConfigResolver()->getParameter( 'google_verification', 'nova_ezseo' ) != $key ) { throw new NotFoundHttpException( "Google Verification Key not found" ); } $response = new Response(); $response->setSharedMaxAge( 24 * 3600 ); $response->setContent( "google-site-verification: google{$key}.html" ); return $response; }
[ "public", "function", "googleVerifAction", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "getConfigResolver", "(", ")", "->", "getParameter", "(", "'google_verification'", ",", "'nova_ezseo'", ")", "!=", "$", "key", ")", "{", "throw", "new", "No...
Google Verification route @param string $key @Route("/google{key}.html", requirements={ "key": "[a-zA-Z0-9]*" }) @Method("GET") @throws NotFoundHttpException @return Response
[ "Google", "Verification", "route" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Controller/SEOController.php#L65-L75
train
Novactive/NovaeZSEOBundle
Controller/SEOController.php
SEOController.bingVerifAction
public function bingVerifAction() { if ( !$this->getConfigResolver()->hasParameter( 'bing_verification', 'nova_ezseo' ) ) { throw new NotFoundHttpException( "Bing Verification Key not found" ); } $key = $this->getConfigResolver()->getParameter( 'bing_verification', 'nova_ezseo' ); $xml = new DOMDocument("1.0", "UTF-8"); $xml->formatOutput = true; $root = $xml->createElement("users"); $root->appendChild($xml->createElement("user", $key)); $xml->appendChild($root); $response = new Response($xml->saveXML()); $response->setSharedMaxAge( 24 * 3600 ); $response->headers->set("Content-Type", "text/xml"); return $response; }
php
public function bingVerifAction() { if ( !$this->getConfigResolver()->hasParameter( 'bing_verification', 'nova_ezseo' ) ) { throw new NotFoundHttpException( "Bing Verification Key not found" ); } $key = $this->getConfigResolver()->getParameter( 'bing_verification', 'nova_ezseo' ); $xml = new DOMDocument("1.0", "UTF-8"); $xml->formatOutput = true; $root = $xml->createElement("users"); $root->appendChild($xml->createElement("user", $key)); $xml->appendChild($root); $response = new Response($xml->saveXML()); $response->setSharedMaxAge( 24 * 3600 ); $response->headers->set("Content-Type", "text/xml"); return $response; }
[ "public", "function", "bingVerifAction", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getConfigResolver", "(", ")", "->", "hasParameter", "(", "'bing_verification'", ",", "'nova_ezseo'", ")", ")", "{", "throw", "new", "NotFoundHttpException", "(", "\"Bin...
Bing Verification route @Route("/BingSiteAuth.xml") @Method("GET") @throws NotFoundHttpException @return Response
[ "Bing", "Verification", "route" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Controller/SEOController.php#L85-L105
train
Novactive/NovaeZSEOBundle
Core/MetaNameSchema.php
MetaNameSchema.resolveMeta
public function resolveMeta(Meta $meta, Content $content, ContentType $contentType = null) { if ($contentType === null) { $contentType = $this->repository->getContentTypeService()->loadContentType( $content->contentInfo->contentTypeId ); } $resolveMultilingue = $this->resolve( $meta->getContent(), $contentType, $content->fields, $content->versionInfo->languageCodes ); // we don't fallback on the other languages... it would be very bad for SEO to mix the languages if ((array_key_exists($this->languages[0], $resolveMultilingue)) && ($resolveMultilingue[$this->languages[0]] != '') ) { $meta->setContent($resolveMultilingue[$this->languages[0]]); return true; } $meta->setContent(""); return false; }
php
public function resolveMeta(Meta $meta, Content $content, ContentType $contentType = null) { if ($contentType === null) { $contentType = $this->repository->getContentTypeService()->loadContentType( $content->contentInfo->contentTypeId ); } $resolveMultilingue = $this->resolve( $meta->getContent(), $contentType, $content->fields, $content->versionInfo->languageCodes ); // we don't fallback on the other languages... it would be very bad for SEO to mix the languages if ((array_key_exists($this->languages[0], $resolveMultilingue)) && ($resolveMultilingue[$this->languages[0]] != '') ) { $meta->setContent($resolveMultilingue[$this->languages[0]]); return true; } $meta->setContent(""); return false; }
[ "public", "function", "resolveMeta", "(", "Meta", "$", "meta", ",", "Content", "$", "content", ",", "ContentType", "$", "contentType", "=", "null", ")", "{", "if", "(", "$", "contentType", "===", "null", ")", "{", "$", "contentType", "=", "$", "this", ...
Resolve a Meta Value @param Meta $meta @param Content $content @param ContentType $contentType @return boolean
[ "Resolve", "a", "Meta", "Value" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Core/MetaNameSchema.php#L170-L195
train
Novactive/NovaeZSEOBundle
Core/MetaNameSchema.php
MetaNameSchema.handleRichTextValue
protected function handleRichTextValue(RichTextValue $value) { return trim(strip_tags($this->richTextConverter->convert($value->xml)->saveHTML())); }
php
protected function handleRichTextValue(RichTextValue $value) { return trim(strip_tags($this->richTextConverter->convert($value->xml)->saveHTML())); }
[ "protected", "function", "handleRichTextValue", "(", "RichTextValue", "$", "value", ")", "{", "return", "trim", "(", "strip_tags", "(", "$", "this", "->", "richTextConverter", "->", "convert", "(", "$", "value", "->", "xml", ")", "->", "saveHTML", "(", ")", ...
Get a Text from a Rich text field type @param RichTextValue $value @return string
[ "Get", "a", "Text", "from", "a", "Rich", "text", "field", "type" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Core/MetaNameSchema.php#L318-L321
train
Novactive/NovaeZSEOBundle
Core/MetaNameSchema.php
MetaNameSchema.handleRelationValue
protected function handleRelationValue(RelationValue $value, $languageCode) { if (!$value->destinationContentId) { return ''; } $relatedContent = $this->repository->getContentService()->loadContent($value->destinationContentId); // @todo: we can probably be better here and handle more than just "image" if ($fieldImageValue = $relatedContent->getFieldValue('image')) { if ($fieldImageValue->uri) { return $this->getVariation($fieldImageValue, "image", $languageCode, "social_network_image"); } } return $this->translationHelper->getTranslatedContentName($relatedContent, $languageCode); }
php
protected function handleRelationValue(RelationValue $value, $languageCode) { if (!$value->destinationContentId) { return ''; } $relatedContent = $this->repository->getContentService()->loadContent($value->destinationContentId); // @todo: we can probably be better here and handle more than just "image" if ($fieldImageValue = $relatedContent->getFieldValue('image')) { if ($fieldImageValue->uri) { return $this->getVariation($fieldImageValue, "image", $languageCode, "social_network_image"); } } return $this->translationHelper->getTranslatedContentName($relatedContent, $languageCode); }
[ "protected", "function", "handleRelationValue", "(", "RelationValue", "$", "value", ",", "$", "languageCode", ")", "{", "if", "(", "!", "$", "value", "->", "destinationContentId", ")", "{", "return", "''", ";", "}", "$", "relatedContent", "=", "$", "this", ...
Get the Relation in text or URL @param RelationValue $value @param string $languageCode @return string
[ "Get", "the", "Relation", "in", "text", "or", "URL" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Core/MetaNameSchema.php#L331-L345
train
Novactive/NovaeZSEOBundle
Core/MetaNameSchema.php
MetaNameSchema.handleImageValue
protected function handleImageValue(ImageValue $value, $fieldDefinitionIdentifier, $languageCode) { if (!$value->uri) { return ''; } return $this->getVariation( $value, $fieldDefinitionIdentifier, $languageCode, "social_network_image" ); }
php
protected function handleImageValue(ImageValue $value, $fieldDefinitionIdentifier, $languageCode) { if (!$value->uri) { return ''; } return $this->getVariation( $value, $fieldDefinitionIdentifier, $languageCode, "social_network_image" ); }
[ "protected", "function", "handleImageValue", "(", "ImageValue", "$", "value", ",", "$", "fieldDefinitionIdentifier", ",", "$", "languageCode", ")", "{", "if", "(", "!", "$", "value", "->", "uri", ")", "{", "return", "''", ";", "}", "return", "$", "this", ...
Handle a Image attribute @param ImageValue $value @param string $fieldDefinitionIdentifier @param string $languageCode @return string
[ "Handle", "a", "Image", "attribute" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Core/MetaNameSchema.php#L361-L373
train
Novactive/NovaeZSEOBundle
Core/MetaNameSchema.php
MetaNameSchema.handleImageAssetValue
protected function handleImageAssetValue(ImageAssetValue $value, $fieldDefinitionIdentifier, $languageCode) { if (!$value->destinationContentId) { return ''; } $content = $this->repository->getContentService()->loadContent($value->destinationContentId); foreach ($content->getFields() as $field) { if ($field->value instanceof ImageValue) { return $this->handleImageValue($field->value, $fieldDefinitionIdentifier, $languageCode); } } return ''; }
php
protected function handleImageAssetValue(ImageAssetValue $value, $fieldDefinitionIdentifier, $languageCode) { if (!$value->destinationContentId) { return ''; } $content = $this->repository->getContentService()->loadContent($value->destinationContentId); foreach ($content->getFields() as $field) { if ($field->value instanceof ImageValue) { return $this->handleImageValue($field->value, $fieldDefinitionIdentifier, $languageCode); } } return ''; }
[ "protected", "function", "handleImageAssetValue", "(", "ImageAssetValue", "$", "value", ",", "$", "fieldDefinitionIdentifier", ",", "$", "languageCode", ")", "{", "if", "(", "!", "$", "value", "->", "destinationContentId", ")", "{", "return", "''", ";", "}", "...
Handle a Image Asset attribute @param ImageAssetValue $value @param string $fieldDefinitionIdentifier @param string $languageCode @return string
[ "Handle", "a", "Image", "Asset", "attribute" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Core/MetaNameSchema.php#L384-L399
train
Novactive/NovaeZSEOBundle
Controller/SitemapController.php
SitemapController.getQuery
protected function getQuery() { $locationService = $this->get( "ezpublish.api.repository" )->getLocationService(); $limitToRootLocation = $this->getConfigResolver()->getParameter( 'limit_to_rootlocation', 'nova_ezseo' ); $excludes = $this->getConfigResolver()->getParameter( 'sitemap_excludes', 'nova_ezseo' ); $query = new Query(); $criterion[] = new Criterion\Visibility( Criterion\Visibility::VISIBLE ); if ( true === $limitToRootLocation ) { $criterion[] = new Criterion\Subtree( $this->getRootLocation()->pathString ); } foreach ( $excludes['contentTypeIdentifiers'] as $contentTypeIdentifier ) { $criterion[] = new Criterion\LogicalNot( new Criterion\ContentTypeIdentifier( $contentTypeIdentifier ) ); } foreach ( $excludes['subtrees'] as $locationId ) { $excludedLocation = $this->getRepository()->sudo( function () use ($locationService, $locationId) { try { return $locationService->loadLocation( $locationId ); } catch (\Exception $e) { return false; } } ); if ($excludedLocation) { $criterion[] = new Criterion\LogicalNot( new Criterion\Subtree( $excludedLocation->pathString ) ); } } foreach ( $excludes['locations'] as $locationId ) { $criterion[] = new Criterion\LogicalNot( new Criterion\LocationId( $locationId ) ); } $query->query = new Criterion\LogicalAnd( $criterion ); $query->sortClauses = [ new SortClause\DatePublished( Query::SORT_DESC) ]; return $query; }
php
protected function getQuery() { $locationService = $this->get( "ezpublish.api.repository" )->getLocationService(); $limitToRootLocation = $this->getConfigResolver()->getParameter( 'limit_to_rootlocation', 'nova_ezseo' ); $excludes = $this->getConfigResolver()->getParameter( 'sitemap_excludes', 'nova_ezseo' ); $query = new Query(); $criterion[] = new Criterion\Visibility( Criterion\Visibility::VISIBLE ); if ( true === $limitToRootLocation ) { $criterion[] = new Criterion\Subtree( $this->getRootLocation()->pathString ); } foreach ( $excludes['contentTypeIdentifiers'] as $contentTypeIdentifier ) { $criterion[] = new Criterion\LogicalNot( new Criterion\ContentTypeIdentifier( $contentTypeIdentifier ) ); } foreach ( $excludes['subtrees'] as $locationId ) { $excludedLocation = $this->getRepository()->sudo( function () use ($locationService, $locationId) { try { return $locationService->loadLocation( $locationId ); } catch (\Exception $e) { return false; } } ); if ($excludedLocation) { $criterion[] = new Criterion\LogicalNot( new Criterion\Subtree( $excludedLocation->pathString ) ); } } foreach ( $excludes['locations'] as $locationId ) { $criterion[] = new Criterion\LogicalNot( new Criterion\LocationId( $locationId ) ); } $query->query = new Criterion\LogicalAnd( $criterion ); $query->sortClauses = [ new SortClause\DatePublished( Query::SORT_DESC) ]; return $query; }
[ "protected", "function", "getQuery", "(", ")", "{", "$", "locationService", "=", "$", "this", "->", "get", "(", "\"ezpublish.api.repository\"", ")", "->", "getLocationService", "(", ")", ";", "$", "limitToRootLocation", "=", "$", "this", "->", "getConfigResolver...
Get the common Query @return Query
[ "Get", "the", "common", "Query" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Controller/SitemapController.php#L46-L85
train
Novactive/NovaeZSEOBundle
Controller/SitemapController.php
SitemapController.indexAction
public function indexAction() { $searchService = $this->get( "ezpublish.api.repository" )->getSearchService(); $query = $this->getQuery(); $query->limit = 0; $resultCount = $searchService->findLocations( $query )->totalCount; // Dom Doc $sitemap = new DOMDocument( "1.0", "UTF-8" ); $sitemap->formatOutput = true; // create an index if we are greater than th PACKET_MAX if ( $resultCount > static::PACKET_MAX ) { $root = $sitemap->createElement( "sitemapindex" ); $root->setAttribute( "xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9" ); $sitemap->appendChild( $root ); $this->fillSitemapIndex( $sitemap, $resultCount, $root ); return new Response( $sitemap->saveXML(), 200, [ "Content-type" => "text/xml" ] ); } // if we are less or equal than the PACKET_SIZE, redo the search with no limit and list directly the urlmap $query->limit = $resultCount; $results = $searchService->findLocations( $query ); $root = $sitemap->createElement( "urlset" ); $root->setAttribute( "xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9" ); $this->fillSitemap( $sitemap, $root, $results ); $sitemap->appendChild( $root ); $response = new Response( $sitemap->saveXML(), 200, [ "Content-type" => "text/xml" ] ); $response->setSharedMaxAge( 24 * 3600 ); return $response; }
php
public function indexAction() { $searchService = $this->get( "ezpublish.api.repository" )->getSearchService(); $query = $this->getQuery(); $query->limit = 0; $resultCount = $searchService->findLocations( $query )->totalCount; // Dom Doc $sitemap = new DOMDocument( "1.0", "UTF-8" ); $sitemap->formatOutput = true; // create an index if we are greater than th PACKET_MAX if ( $resultCount > static::PACKET_MAX ) { $root = $sitemap->createElement( "sitemapindex" ); $root->setAttribute( "xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9" ); $sitemap->appendChild( $root ); $this->fillSitemapIndex( $sitemap, $resultCount, $root ); return new Response( $sitemap->saveXML(), 200, [ "Content-type" => "text/xml" ] ); } // if we are less or equal than the PACKET_SIZE, redo the search with no limit and list directly the urlmap $query->limit = $resultCount; $results = $searchService->findLocations( $query ); $root = $sitemap->createElement( "urlset" ); $root->setAttribute( "xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9" ); $this->fillSitemap( $sitemap, $root, $results ); $sitemap->appendChild( $root ); $response = new Response( $sitemap->saveXML(), 200, [ "Content-type" => "text/xml" ] ); $response->setSharedMaxAge( 24 * 3600 ); return $response; }
[ "public", "function", "indexAction", "(", ")", "{", "$", "searchService", "=", "$", "this", "->", "get", "(", "\"ezpublish.api.repository\"", ")", "->", "getSearchService", "(", ")", ";", "$", "query", "=", "$", "this", "->", "getQuery", "(", ")", ";", "...
Sitemaps.xml route @Route("/sitemap.xml", name="_novaseo_sitemap_index") @Method("GET") @return Response
[ "Sitemaps", ".", "xml", "route" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Controller/SitemapController.php#L95-L130
train
Novactive/NovaeZSEOBundle
Controller/SitemapController.php
SitemapController.fillSitemap
protected function fillSitemap( $sitemap, $root, SearchResult $results ) { foreach ( $results->searchHits as $searchHit ) { /** * @var SearchHit $searchHit * @var Location $location * */ $location = $searchHit->valueObject; $url = $this->generateUrl( $location, [ ], UrlGeneratorInterface::ABSOLUTE_URL ); $modified = $location->contentInfo->modificationDate->format( "c" ); $loc = $sitemap->createElement( "loc", $url ); $lastmod = $sitemap->createElement( "lastmod", $modified ); $urlElt = $sitemap->createElement( "url" ); $urlElt->appendChild( $loc ); $urlElt->appendChild( $lastmod ); $root->appendChild( $urlElt ); } }
php
protected function fillSitemap( $sitemap, $root, SearchResult $results ) { foreach ( $results->searchHits as $searchHit ) { /** * @var SearchHit $searchHit * @var Location $location * */ $location = $searchHit->valueObject; $url = $this->generateUrl( $location, [ ], UrlGeneratorInterface::ABSOLUTE_URL ); $modified = $location->contentInfo->modificationDate->format( "c" ); $loc = $sitemap->createElement( "loc", $url ); $lastmod = $sitemap->createElement( "lastmod", $modified ); $urlElt = $sitemap->createElement( "url" ); $urlElt->appendChild( $loc ); $urlElt->appendChild( $lastmod ); $root->appendChild( $urlElt ); } }
[ "protected", "function", "fillSitemap", "(", "$", "sitemap", ",", "$", "root", ",", "SearchResult", "$", "results", ")", "{", "foreach", "(", "$", "results", "->", "searchHits", "as", "$", "searchHit", ")", "{", "/**\n * @var SearchHit $searchHit\n ...
Fill a sitemap @param DOMDocument $sitemap @param DOMElement $root @param SearchResult $results
[ "Fill", "a", "sitemap" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Controller/SitemapController.php#L168-L187
train
Novactive/NovaeZSEOBundle
Controller/SitemapController.php
SitemapController.fillSitemapIndex
protected function fillSitemapIndex( $sitemap, $numberOfResults, $root ) { $numberOfPage = (int)ceil( $numberOfResults / static::PACKET_MAX ); for ( $sitemapNumber = 1; $sitemapNumber <= $numberOfPage; $sitemapNumber++ ) { $sitemapElt = $sitemap->createElement( "sitemap" ); $locUrl = $this->generateUrl( "_novaseo_sitemap_page", [ "page" => $sitemapNumber ], UrlGeneratorInterface::ABSOLUTE_URL ); $loc = $sitemap->createElement( "loc", $locUrl ); $date = new DateTime(); $modificationDate = $date->format( 'c' ); $mod = $sitemap->createElement( 'lastmod', $modificationDate ); $sitemapElt->appendChild( $loc ); $sitemapElt->appendChild( $mod ); $root->appendChild( $sitemapElt ); } }
php
protected function fillSitemapIndex( $sitemap, $numberOfResults, $root ) { $numberOfPage = (int)ceil( $numberOfResults / static::PACKET_MAX ); for ( $sitemapNumber = 1; $sitemapNumber <= $numberOfPage; $sitemapNumber++ ) { $sitemapElt = $sitemap->createElement( "sitemap" ); $locUrl = $this->generateUrl( "_novaseo_sitemap_page", [ "page" => $sitemapNumber ], UrlGeneratorInterface::ABSOLUTE_URL ); $loc = $sitemap->createElement( "loc", $locUrl ); $date = new DateTime(); $modificationDate = $date->format( 'c' ); $mod = $sitemap->createElement( 'lastmod', $modificationDate ); $sitemapElt->appendChild( $loc ); $sitemapElt->appendChild( $mod ); $root->appendChild( $sitemapElt ); } }
[ "protected", "function", "fillSitemapIndex", "(", "$", "sitemap", ",", "$", "numberOfResults", ",", "$", "root", ")", "{", "$", "numberOfPage", "=", "(", "int", ")", "ceil", "(", "$", "numberOfResults", "/", "static", "::", "PACKET_MAX", ")", ";", "for", ...
Fill the sitemap index @param DOMDocument $sitemap @param integer $numberOfResults @param DOMElement $root
[ "Fill", "the", "sitemap", "index" ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Controller/SitemapController.php#L196-L211
train
Novactive/NovaeZSEOBundle
Converter/ContentTypesHelper.php
ContentTypesHelper.getContentTypesByIdentifier
public function getContentTypesByIdentifier($identifier) { if (strstr($identifier, ',')) { $contentTypeArray = explode(',', $identifier); } else { $contentTypeArray[] = $identifier; } $contentTypesCollection = array(); foreach ($contentTypeArray as $contentTypeIdentifier) { if (!empty($contentTypeIdentifier)) { $contentTypesCollection[] = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier); } } return $contentTypesCollection; }
php
public function getContentTypesByIdentifier($identifier) { if (strstr($identifier, ',')) { $contentTypeArray = explode(',', $identifier); } else { $contentTypeArray[] = $identifier; } $contentTypesCollection = array(); foreach ($contentTypeArray as $contentTypeIdentifier) { if (!empty($contentTypeIdentifier)) { $contentTypesCollection[] = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier); } } return $contentTypesCollection; }
[ "public", "function", "getContentTypesByIdentifier", "(", "$", "identifier", ")", "{", "if", "(", "strstr", "(", "$", "identifier", ",", "','", ")", ")", "{", "$", "contentTypeArray", "=", "explode", "(", "','", ",", "$", "identifier", ")", ";", "}", "el...
Returns ContentTypes array by ContentType identifier. @param string $identifier @return \eZ\Publish\API\Repository\Values\ContentType\ContentType[]
[ "Returns", "ContentTypes", "array", "by", "ContentType", "identifier", "." ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Converter/ContentTypesHelper.php#L30-L46
train
Novactive/NovaeZSEOBundle
Converter/ContentTypesHelper.php
ContentTypesHelper.getContentTypesByGroup
public function getContentTypesByGroup($identifier) { $contentTypesCollection = array(); if ($contentTypeGroupIdentifier = $identifier) { $contentTypeGroup = $this->contentTypeService->loadContentTypeGroupByIdentifier($contentTypeGroupIdentifier); $contentTypesCollection = $this->contentTypeService->loadContentTypes($contentTypeGroup); } return $contentTypesCollection; }
php
public function getContentTypesByGroup($identifier) { $contentTypesCollection = array(); if ($contentTypeGroupIdentifier = $identifier) { $contentTypeGroup = $this->contentTypeService->loadContentTypeGroupByIdentifier($contentTypeGroupIdentifier); $contentTypesCollection = $this->contentTypeService->loadContentTypes($contentTypeGroup); } return $contentTypesCollection; }
[ "public", "function", "getContentTypesByGroup", "(", "$", "identifier", ")", "{", "$", "contentTypesCollection", "=", "array", "(", ")", ";", "if", "(", "$", "contentTypeGroupIdentifier", "=", "$", "identifier", ")", "{", "$", "contentTypeGroup", "=", "$", "th...
Returns ContentTypes array by ContentType group. @param string $identifier @return \eZ\Publish\API\Repository\Values\ContentType\ContentType[]
[ "Returns", "ContentTypes", "array", "by", "ContentType", "group", "." ]
057ae9611102d4d777724960d148a38a6e9624ef
https://github.com/Novactive/NovaeZSEOBundle/blob/057ae9611102d4d777724960d148a38a6e9624ef/Converter/ContentTypesHelper.php#L55-L65
train
acquia/headless-lightning
modules/json_content/src/Controller/FrontController.php
FrontController.frontpage
public function frontpage() { $build = []; if ($this->currentUser()->isAnonymous()) { $build['heading'] = [ '#type' => 'markup', '#markup' => $this->t('Please log in for access to the content repository.'), ]; $build['form'] = $this->formBuilder()->getForm(UserLoginForm::class); } else { if ($this->currentUser()->hasPermission('access content overview')) { // Permitted users are directed to the admin content page. return $this->redirect('view.content.page_1'); } $build['heading'] = [ '#type' => 'markup', '#markup' => $this->t('This site has no homepage content.'), ]; } return $build; }
php
public function frontpage() { $build = []; if ($this->currentUser()->isAnonymous()) { $build['heading'] = [ '#type' => 'markup', '#markup' => $this->t('Please log in for access to the content repository.'), ]; $build['form'] = $this->formBuilder()->getForm(UserLoginForm::class); } else { if ($this->currentUser()->hasPermission('access content overview')) { // Permitted users are directed to the admin content page. return $this->redirect('view.content.page_1'); } $build['heading'] = [ '#type' => 'markup', '#markup' => $this->t('This site has no homepage content.'), ]; } return $build; }
[ "public", "function", "frontpage", "(", ")", "{", "$", "build", "=", "[", "]", ";", "if", "(", "$", "this", "->", "currentUser", "(", ")", "->", "isAnonymous", "(", ")", ")", "{", "$", "build", "[", "'heading'", "]", "=", "[", "'#type'", "=>", "'...
Displays the login form on the homepage and redirects authenticated users.
[ "Displays", "the", "login", "form", "on", "the", "homepage", "and", "redirects", "authenticated", "users", "." ]
3e47c5193c38b8189d919876b3538293db254678
https://github.com/acquia/headless-lightning/blob/3e47c5193c38b8189d919876b3538293db254678/modules/json_content/src/Controller/FrontController.php#L13-L33
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/Output/Json.php
Json.output
public function output(\stdClass $object, ResponseInterface $response) { $response->setContentType('application/json'); $response->setJsonContent($object); $response->send(); }
php
public function output(\stdClass $object, ResponseInterface $response) { $response->setContentType('application/json'); $response->setJsonContent($object); $response->send(); }
[ "public", "function", "output", "(", "\\", "stdClass", "$", "object", ",", "ResponseInterface", "$", "response", ")", "{", "$", "response", "->", "setContentType", "(", "'application/json'", ")", ";", "$", "response", "->", "setJsonContent", "(", "$", "object"...
This takes in object, and outputs it in the respective format, including sending the headers @param \stdClass $object @param ResponseInterface $response @return void
[ "This", "takes", "in", "object", "and", "outputs", "it", "in", "the", "respective", "format", "including", "sending", "the", "headers" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Output/Json.php#L16-L20
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/Behavior/Upload/File.php
File.validateError
private function validateError(UploadedFile $uploadedFile) { switch($uploadedFile->getError()) { case UPLOAD_ERR_OK: //Do Nothing break; case UPLOAD_ERR_INI_SIZE: throw new Exception('File too large, must not be greater than ' . ini_get('upload_max_filesize'), 401); break; case UPLOAD_ERR_NO_FILE: throw new Exception('No File Uploaded', 401); break; default: throw new Exception($uploadedFile->getError(), 401); break; } }
php
private function validateError(UploadedFile $uploadedFile) { switch($uploadedFile->getError()) { case UPLOAD_ERR_OK: //Do Nothing break; case UPLOAD_ERR_INI_SIZE: throw new Exception('File too large, must not be greater than ' . ini_get('upload_max_filesize'), 401); break; case UPLOAD_ERR_NO_FILE: throw new Exception('No File Uploaded', 401); break; default: throw new Exception($uploadedFile->getError(), 401); break; } }
[ "private", "function", "validateError", "(", "UploadedFile", "$", "uploadedFile", ")", "{", "switch", "(", "$", "uploadedFile", "->", "getError", "(", ")", ")", "{", "case", "UPLOAD_ERR_OK", ":", "//Do Nothing", "break", ";", "case", "UPLOAD_ERR_INI_SIZE", ":", ...
Validates if there are any errors @param UploadedFile $uploadedFile @return void @throws Exception
[ "Validates", "if", "there", "are", "any", "errors" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Behavior/Upload/File.php#L100-L115
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/Behavior/Upload/File.php
File.validateExtension
private function validateExtension(UploadedFile $uploadedFile) { $pathInfo = pathinfo($uploadedFile->getName()); if(!isset($pathInfo['extension'])) { throw new Exception('No Extension Found(' . $uploadedFile->getName() . ')', 401); } $extension = strtolower($pathInfo['extension']); if(!in_array($extension, $this->getAllowedExtensions())) { throw new Exception('Invalid Type of File Uploaded, valid types: ' . implode(', ', $this->getAllowedExtensions()), 401); } }
php
private function validateExtension(UploadedFile $uploadedFile) { $pathInfo = pathinfo($uploadedFile->getName()); if(!isset($pathInfo['extension'])) { throw new Exception('No Extension Found(' . $uploadedFile->getName() . ')', 401); } $extension = strtolower($pathInfo['extension']); if(!in_array($extension, $this->getAllowedExtensions())) { throw new Exception('Invalid Type of File Uploaded, valid types: ' . implode(', ', $this->getAllowedExtensions()), 401); } }
[ "private", "function", "validateExtension", "(", "UploadedFile", "$", "uploadedFile", ")", "{", "$", "pathInfo", "=", "pathinfo", "(", "$", "uploadedFile", "->", "getName", "(", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "pathInfo", "[", "'extension...
Validates the file extension @param UploadedFile $uploadedFile @return void @throws Exception
[ "Validates", "the", "file", "extension" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Behavior/Upload/File.php#L125-L134
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/Behavior/Upload/File.php
File.handle
public function handle(UploadedFile $uploadedFile) { $this->setUsed(true); $this->validateError($uploadedFile); $this->validateExtension($uploadedFile); $handler = $this->getHandler(); $handler($uploadedFile); }
php
public function handle(UploadedFile $uploadedFile) { $this->setUsed(true); $this->validateError($uploadedFile); $this->validateExtension($uploadedFile); $handler = $this->getHandler(); $handler($uploadedFile); }
[ "public", "function", "handle", "(", "UploadedFile", "$", "uploadedFile", ")", "{", "$", "this", "->", "setUsed", "(", "true", ")", ";", "$", "this", "->", "validateError", "(", "$", "uploadedFile", ")", ";", "$", "this", "->", "validateExtension", "(", ...
Handles the file being uploaded @param UploadedFile $uploadedFile @return void @throws Exception
[ "Handles", "the", "file", "being", "uploaded" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Behavior/Upload/File.php#L144-L150
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php
Index.addToWhiteList
private function addToWhiteList(array $whiteList) { $current = $this->getWhiteList(); $current = array_merge($current, $whiteList); $this->setWhiteList($current); }
php
private function addToWhiteList(array $whiteList) { $current = $this->getWhiteList(); $current = array_merge($current, $whiteList); $this->setWhiteList($current); }
[ "private", "function", "addToWhiteList", "(", "array", "$", "whiteList", ")", "{", "$", "current", "=", "$", "this", "->", "getWhiteList", "(", ")", ";", "$", "current", "=", "array_merge", "(", "$", "current", ",", "$", "whiteList", ")", ";", "$", "th...
Add Fields to the white list so they are ignored @param array $whiteList @return void
[ "Add", "Fields", "to", "the", "white", "list", "so", "they", "are", "ignored" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php#L95-L99
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php
Index.buildSearchCriteria
private function buildSearchCriteria() { $this->buildSearchFieldsRecursive($this->getIndexCriteria()->getSearch(), $this->getEntityFactory()); if(!is_null($this->getIndexCriteria()->getSearchTerm())) { $this->buildSearchTerm(); } }
php
private function buildSearchCriteria() { $this->buildSearchFieldsRecursive($this->getIndexCriteria()->getSearch(), $this->getEntityFactory()); if(!is_null($this->getIndexCriteria()->getSearchTerm())) { $this->buildSearchTerm(); } }
[ "private", "function", "buildSearchCriteria", "(", ")", "{", "$", "this", "->", "buildSearchFieldsRecursive", "(", "$", "this", "->", "getIndexCriteria", "(", ")", "->", "getSearch", "(", ")", ",", "$", "this", "->", "getEntityFactory", "(", ")", ")", ";", ...
Builds the search criteria @return void
[ "Builds", "the", "search", "criteria" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php#L178-L183
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php
Index.buildSearchFieldsRecursive
private function buildSearchFieldsRecursive(Search $search, ApiInterface $entity) { $isRoot = false; $alias = $search->getAlias(); if(is_null($alias)) { $isRoot = true; $alias = get_class($entity); } foreach($search->getFields() as $field => $value) { if(in_array(preg_replace("/[<|>]$/", "", $field), $entity->getModelsMetaData()->getColumnMap($entity))) { $this->addSearchField($field, $value, $entity, $alias); } else { if(!$isRoot || !in_array($field, $this->getWhiteList())) { throw new Exception('Could not find the field: ' . ($isRoot ? '' : $alias . '.') . $field, 400); } } } foreach($search->getChildren() as $child) { if(in_array($child->getAlias(), $entity->getParentRelationships())) { $subEntity = $this->addJoin($entity, $child->getAlias(), false); $this->buildSearchFieldsRecursive($child, $subEntity); } elseif(in_array($child->getAlias(), $entity->getChildrenRelationships())) { throw new Exception('Cannot search on children: ' . ($isRoot ? '' : $alias . '.') . $child->getAlias(), 400); } else { throw new Exception('Could not find the parent: ' . ($isRoot ? '' : $alias . '.') . $child->getAlias(), 400); } } $this->addSoftDelete($entity, $alias); }
php
private function buildSearchFieldsRecursive(Search $search, ApiInterface $entity) { $isRoot = false; $alias = $search->getAlias(); if(is_null($alias)) { $isRoot = true; $alias = get_class($entity); } foreach($search->getFields() as $field => $value) { if(in_array(preg_replace("/[<|>]$/", "", $field), $entity->getModelsMetaData()->getColumnMap($entity))) { $this->addSearchField($field, $value, $entity, $alias); } else { if(!$isRoot || !in_array($field, $this->getWhiteList())) { throw new Exception('Could not find the field: ' . ($isRoot ? '' : $alias . '.') . $field, 400); } } } foreach($search->getChildren() as $child) { if(in_array($child->getAlias(), $entity->getParentRelationships())) { $subEntity = $this->addJoin($entity, $child->getAlias(), false); $this->buildSearchFieldsRecursive($child, $subEntity); } elseif(in_array($child->getAlias(), $entity->getChildrenRelationships())) { throw new Exception('Cannot search on children: ' . ($isRoot ? '' : $alias . '.') . $child->getAlias(), 400); } else { throw new Exception('Could not find the parent: ' . ($isRoot ? '' : $alias . '.') . $child->getAlias(), 400); } } $this->addSoftDelete($entity, $alias); }
[ "private", "function", "buildSearchFieldsRecursive", "(", "Search", "$", "search", ",", "ApiInterface", "$", "entity", ")", "{", "$", "isRoot", "=", "false", ";", "$", "alias", "=", "$", "search", "->", "getAlias", "(", ")", ";", "if", "(", "is_null", "(...
Builds the search fields @param Search $search @param ApiInterface $entity @return void @throws Exception
[ "Builds", "the", "search", "fields" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php#L213-L242
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php
Index.addSoftDelete
public function addSoftDelete(ApiInterface $entity, $alias) { $reflectionClass = new \ReflectionClass(SoftDelete::class); $reflectionMethod = $reflectionClass->getMethod("getOptions"); $reflectionMethod->setAccessible(true); /** @var SoftDelete[] $softDeleteBehaviors */ $softDeleteBehaviors = $entity->getAllBehaviorsByClassName(SoftDelete::class); foreach($softDeleteBehaviors as $softDeleteBehavior) { $options = $reflectionMethod->invoke($softDeleteBehavior); $sql = $alias . '.' . $options["field"] . '!=?0'; $params = [$options["value"]]; $this->getCriteriaHelper()->andWhere($sql, $params); } }
php
public function addSoftDelete(ApiInterface $entity, $alias) { $reflectionClass = new \ReflectionClass(SoftDelete::class); $reflectionMethod = $reflectionClass->getMethod("getOptions"); $reflectionMethod->setAccessible(true); /** @var SoftDelete[] $softDeleteBehaviors */ $softDeleteBehaviors = $entity->getAllBehaviorsByClassName(SoftDelete::class); foreach($softDeleteBehaviors as $softDeleteBehavior) { $options = $reflectionMethod->invoke($softDeleteBehavior); $sql = $alias . '.' . $options["field"] . '!=?0'; $params = [$options["value"]]; $this->getCriteriaHelper()->andWhere($sql, $params); } }
[ "public", "function", "addSoftDelete", "(", "ApiInterface", "$", "entity", ",", "$", "alias", ")", "{", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "SoftDelete", "::", "class", ")", ";", "$", "reflectionMethod", "=", "$", "reflectionClass...
Add soft delete to the where clause if the entity supports it @param ApiInterface $entity @param string $alias @return void
[ "Add", "soft", "delete", "to", "the", "where", "clause", "if", "the", "entity", "supports", "it" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php#L252-L266
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php
Index.addSearchField
private function addSearchField($name, $value, ApiInterface $entity, $alias) { $operator = "="; if(preg_match("/[<|>]$/", $name)) { $operator = substr($name, -1) . "="; $name = substr($name, 0, -1); $fieldTypes = $entity->getFieldTypes(); $fieldTypesWhiteList = [ApiInterface::FIELD_TYPE_DATE, ApiInterface::FIELD_TYPE_DATE_TIME, ApiInterface::FIELD_TYPE_DOUBLE, ApiInterface::FIELD_TYPE_INT]; if(!in_array($fieldTypes[$name], $fieldTypesWhiteList)) { throw new Exception( 'Cannot perform ' . $operator . ' search on any fields that are not in ' . implode(", ", $fieldTypesWhiteList) . ': ' . $name . ' has a type of ' . $fieldTypes[$name], 400 ); } } $sql = $alias . '.' . $name; if(is_array($value)) { $attributes = []; foreach($value as $subValue) { $entity->writeAttribute($name, $subValue); $attributes[] = $entity->readAttribute($name); } $this->getCriteria()->inWhere($sql, $attributes); } else { $entity->writeAttribute($name, $value); $attribute = $entity->readAttribute($name); $params = []; if (is_null($attribute)) { $sql .= " IS NULL"; } else { $attribute .= ''; //Make sure to convert to string, for Date and DateTime if (preg_match('@(^|[^\\\])%@', $attribute)) { $operator = ' LIKE '; } $sql .= $operator . '?0'; $params[] = $attribute; } $this->getCriteriaHelper()->andWhere($sql, $params); } }
php
private function addSearchField($name, $value, ApiInterface $entity, $alias) { $operator = "="; if(preg_match("/[<|>]$/", $name)) { $operator = substr($name, -1) . "="; $name = substr($name, 0, -1); $fieldTypes = $entity->getFieldTypes(); $fieldTypesWhiteList = [ApiInterface::FIELD_TYPE_DATE, ApiInterface::FIELD_TYPE_DATE_TIME, ApiInterface::FIELD_TYPE_DOUBLE, ApiInterface::FIELD_TYPE_INT]; if(!in_array($fieldTypes[$name], $fieldTypesWhiteList)) { throw new Exception( 'Cannot perform ' . $operator . ' search on any fields that are not in ' . implode(", ", $fieldTypesWhiteList) . ': ' . $name . ' has a type of ' . $fieldTypes[$name], 400 ); } } $sql = $alias . '.' . $name; if(is_array($value)) { $attributes = []; foreach($value as $subValue) { $entity->writeAttribute($name, $subValue); $attributes[] = $entity->readAttribute($name); } $this->getCriteria()->inWhere($sql, $attributes); } else { $entity->writeAttribute($name, $value); $attribute = $entity->readAttribute($name); $params = []; if (is_null($attribute)) { $sql .= " IS NULL"; } else { $attribute .= ''; //Make sure to convert to string, for Date and DateTime if (preg_match('@(^|[^\\\])%@', $attribute)) { $operator = ' LIKE '; } $sql .= $operator . '?0'; $params[] = $attribute; } $this->getCriteriaHelper()->andWhere($sql, $params); } }
[ "private", "function", "addSearchField", "(", "$", "name", ",", "$", "value", ",", "ApiInterface", "$", "entity", ",", "$", "alias", ")", "{", "$", "operator", "=", "\"=\"", ";", "if", "(", "preg_match", "(", "\"/[<|>]$/\"", ",", "$", "name", ")", ")",...
Adds a specific field @param string $name @param string $value @param ApiInterface $entity @param string $alias @return void
[ "Adds", "a", "specific", "field" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php#L278-L321
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php
Index.addJoin
private function addJoin(ApiInterface $entity, $alias, $forceFind) { if(in_array($alias, $entity->getParentRelationships())) { $referencedModel = $entity->addJoin($this->getCriteriaHelper(), $alias); return new $referencedModel(); } else { if($forceFind) { throw new Exception('Could Not Find Part in current entity: ' . $alias, 400); } return false; } }
php
private function addJoin(ApiInterface $entity, $alias, $forceFind) { if(in_array($alias, $entity->getParentRelationships())) { $referencedModel = $entity->addJoin($this->getCriteriaHelper(), $alias); return new $referencedModel(); } else { if($forceFind) { throw new Exception('Could Not Find Part in current entity: ' . $alias, 400); } return false; } }
[ "private", "function", "addJoin", "(", "ApiInterface", "$", "entity", ",", "$", "alias", ",", "$", "forceFind", ")", "{", "if", "(", "in_array", "(", "$", "alias", ",", "$", "entity", "->", "getParentRelationships", "(", ")", ")", ")", "{", "$", "refer...
Adds a join @param ApiInterface $entity @param string $alias @param bool $forceFind @return ApiInterface|false False if sub part was not found @throws Exception
[ "Adds", "a", "join" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php#L333-L343
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php
Index.buildSortParameter
protected function buildSortParameter() { $sorts = $this->getIndexCriteria()->getSorts(); if(!empty($sorts)) { $orderBy = ''; foreach($sorts as $sort) { $this->buildSortRecursive($this->getEntityFactory(), $sort->getFields(), $sort->isAsc(), $orderBy); } $this->getCriteria()->orderBy($orderBy); } }
php
protected function buildSortParameter() { $sorts = $this->getIndexCriteria()->getSorts(); if(!empty($sorts)) { $orderBy = ''; foreach($sorts as $sort) { $this->buildSortRecursive($this->getEntityFactory(), $sort->getFields(), $sort->isAsc(), $orderBy); } $this->getCriteria()->orderBy($orderBy); } }
[ "protected", "function", "buildSortParameter", "(", ")", "{", "$", "sorts", "=", "$", "this", "->", "getIndexCriteria", "(", ")", "->", "getSorts", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "sorts", ")", ")", "{", "$", "orderBy", "=", "''", ...
Gets sort parameters from the URL. @return void
[ "Gets", "sort", "parameters", "from", "the", "URL", "." ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php#L351-L360
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php
Index.buildSortRecursive
private function buildSortRecursive(ApiInterface $entity, $parts, $isAsc, &$orderBy, $alias = null) { if(is_null($alias)) { $alias = get_class($entity); } $part = array_shift($parts); if(sizeOf($parts) == 0) { //Is Last part if(in_array($part, $entity->getModelsMetaData()->getColumnMap($entity))) { if($orderBy != '') { $orderBy .= ','; } $orderBy .= $alias . '.' . $part . ' ' . ($isAsc ? 'ASC' : 'DESC'); } else { throw new Exception('Could Not Find sort part: ' . $part, 400); } } else { $subAlias = ucfirst($part); $subEntity = $this->addJoin($entity, $subAlias, true); //Throws an exception if not found $this->buildSortRecursive($subEntity, $parts, $isAsc, $orderBy, $subAlias); } }
php
private function buildSortRecursive(ApiInterface $entity, $parts, $isAsc, &$orderBy, $alias = null) { if(is_null($alias)) { $alias = get_class($entity); } $part = array_shift($parts); if(sizeOf($parts) == 0) { //Is Last part if(in_array($part, $entity->getModelsMetaData()->getColumnMap($entity))) { if($orderBy != '') { $orderBy .= ','; } $orderBy .= $alias . '.' . $part . ' ' . ($isAsc ? 'ASC' : 'DESC'); } else { throw new Exception('Could Not Find sort part: ' . $part, 400); } } else { $subAlias = ucfirst($part); $subEntity = $this->addJoin($entity, $subAlias, true); //Throws an exception if not found $this->buildSortRecursive($subEntity, $parts, $isAsc, $orderBy, $subAlias); } }
[ "private", "function", "buildSortRecursive", "(", "ApiInterface", "$", "entity", ",", "$", "parts", ",", "$", "isAsc", ",", "&", "$", "orderBy", ",", "$", "alias", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "alias", ")", ")", "{", "$", ...
Builds the order by @param ApiInterface $entity @param string[] $parts @param bool $isAsc @param string &$orderBy @param string $alias @return void @throws Exception
[ "Builds", "the", "order", "by" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php#L374-L393
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php
Index.buildLimit
private function buildLimit() { $this->getCriteria()->limit($this->getIndexCriteria()->getLimit(), $this->getIndexCriteria()->getOffset()); }
php
private function buildLimit() { $this->getCriteria()->limit($this->getIndexCriteria()->getLimit(), $this->getIndexCriteria()->getOffset()); }
[ "private", "function", "buildLimit", "(", ")", "{", "$", "this", "->", "getCriteria", "(", ")", "->", "limit", "(", "$", "this", "->", "getIndexCriteria", "(", ")", "->", "getLimit", "(", ")", ",", "$", "this", "->", "getIndexCriteria", "(", ")", "->",...
Builds the limit query @return void
[ "Builds", "the", "limit", "query" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php#L399-L401
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php
Index.generateUrl
private function generateUrl($queryParams) { $params = $this->getRequest()->getQuery(); //Remove htaccess mod rewrite query if(array_key_exists('_url', $params)) { unset($params['_url']); } //Override with the new parameters foreach($queryParams as $name => $value) { $params[$name] = $value; } $url = new Url(); return 'https://' . $this->getRequest()->getHttpHost() . substr($url->get($this->getRequest()->getQuery('_url'), $params), 1); }
php
private function generateUrl($queryParams) { $params = $this->getRequest()->getQuery(); //Remove htaccess mod rewrite query if(array_key_exists('_url', $params)) { unset($params['_url']); } //Override with the new parameters foreach($queryParams as $name => $value) { $params[$name] = $value; } $url = new Url(); return 'https://' . $this->getRequest()->getHttpHost() . substr($url->get($this->getRequest()->getQuery('_url'), $params), 1); }
[ "private", "function", "generateUrl", "(", "$", "queryParams", ")", "{", "$", "params", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getQuery", "(", ")", ";", "//Remove htaccess mod rewrite query", "if", "(", "array_key_exists", "(", "'_url'", ",", ...
Gets the url @param string[] $queryParams @return string
[ "Gets", "the", "url" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php#L434-L446
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php
Index.generateLinks
public function generateLinks() { return '<' . $this->generateUrl($this->getNextPageQueryCriteria()) . '>; rel="next",' . '<' . $this->generateUrl($this->getLastPageQueryCriteria()) . '>; rel="last",' . '<' . $this->generateUrl($this->getFirstPageQueryCriteria()) . '>; rel="first",' . '<' . $this->generateUrl($this->getPreviousPageQueryCriteria()) . '>; rel="prev"'; }
php
public function generateLinks() { return '<' . $this->generateUrl($this->getNextPageQueryCriteria()) . '>; rel="next",' . '<' . $this->generateUrl($this->getLastPageQueryCriteria()) . '>; rel="last",' . '<' . $this->generateUrl($this->getFirstPageQueryCriteria()) . '>; rel="first",' . '<' . $this->generateUrl($this->getPreviousPageQueryCriteria()) . '>; rel="prev"'; }
[ "public", "function", "generateLinks", "(", ")", "{", "return", "'<'", ".", "$", "this", "->", "generateUrl", "(", "$", "this", "->", "getNextPageQueryCriteria", "(", ")", ")", ".", "'>; rel=\"next\",'", ".", "'<'", ".", "$", "this", "->", "generateUrl", "...
Generates the links for the link header @return string
[ "Generates", "the", "links", "for", "the", "link", "header" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php#L452-L457
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Generator/ModelBuilder.php
ModelBuilder.buildTableComment
private function buildTableComment() { /** @var ResultSet $results */ $results = $this->getConfiguration()->getConnection()->query('SHOW TABLE STATUS WHERE Name="' . $this->getTableName() . '"'); $result = (object)$results->fetch(); $this->setComment($result->Comment); }
php
private function buildTableComment() { /** @var ResultSet $results */ $results = $this->getConfiguration()->getConnection()->query('SHOW TABLE STATUS WHERE Name="' . $this->getTableName() . '"'); $result = (object)$results->fetch(); $this->setComment($result->Comment); }
[ "private", "function", "buildTableComment", "(", ")", "{", "/** @var ResultSet $results */", "$", "results", "=", "$", "this", "->", "getConfiguration", "(", ")", "->", "getConnection", "(", ")", "->", "query", "(", "'SHOW TABLE STATUS WHERE Name=\"'", ".", "$", "...
Builds the table comment @return void
[ "Builds", "the", "table", "comment" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L118-L123
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Generator/ModelBuilder.php
ModelBuilder.buildIndexes
private function buildIndexes() { $indexes = array(); /** @var ResultSet $results */ $results = $this->getConfiguration()->getConnection()->query('SHOW INDEX FROM `' . $this->getTableName() . '`'); while($result = $results->fetch()) { $result = (object)$result; if(!array_key_exists($result->Key_name, $indexes)) { $indexes[$result->Key_name] = new Index(); } /** @var Index $index */ $index = $indexes[$result->Key_name]; $index->setUnique(!$result->Non_unique); $index->addColumn($result->Column_name); $index->setPrimary($result->Key_name == 'PRIMARY'); } $this->setIndexes($indexes); }
php
private function buildIndexes() { $indexes = array(); /** @var ResultSet $results */ $results = $this->getConfiguration()->getConnection()->query('SHOW INDEX FROM `' . $this->getTableName() . '`'); while($result = $results->fetch()) { $result = (object)$result; if(!array_key_exists($result->Key_name, $indexes)) { $indexes[$result->Key_name] = new Index(); } /** @var Index $index */ $index = $indexes[$result->Key_name]; $index->setUnique(!$result->Non_unique); $index->addColumn($result->Column_name); $index->setPrimary($result->Key_name == 'PRIMARY'); } $this->setIndexes($indexes); }
[ "private", "function", "buildIndexes", "(", ")", "{", "$", "indexes", "=", "array", "(", ")", ";", "/** @var ResultSet $results */", "$", "results", "=", "$", "this", "->", "getConfiguration", "(", ")", "->", "getConnection", "(", ")", "->", "query", "(", ...
Builds the indexes @return void
[ "Builds", "the", "indexes" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L162-L178
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Generator/ModelBuilder.php
ModelBuilder.writeAll
public static function writeAll(Configuration $configuration, $ignoredTablesRegex = null) { $results = $configuration->getConnection()->query('SHOW FULL TABLES WHERE Table_Type!="VIEW"'); while($result = $results->fetch()) { $result = (object)$result; $table = null; foreach($result as $column) { $table = $column; break; } if(!is_null($ignoredTablesRegex) && preg_match($ignoredTablesRegex, $table)) { continue; } echo 'Writing: '.$table."\n"; $index = new self($configuration, $table); $index->write(); } }
php
public static function writeAll(Configuration $configuration, $ignoredTablesRegex = null) { $results = $configuration->getConnection()->query('SHOW FULL TABLES WHERE Table_Type!="VIEW"'); while($result = $results->fetch()) { $result = (object)$result; $table = null; foreach($result as $column) { $table = $column; break; } if(!is_null($ignoredTablesRegex) && preg_match($ignoredTablesRegex, $table)) { continue; } echo 'Writing: '.$table."\n"; $index = new self($configuration, $table); $index->write(); } }
[ "public", "static", "function", "writeAll", "(", "Configuration", "$", "configuration", ",", "$", "ignoredTablesRegex", "=", "null", ")", "{", "$", "results", "=", "$", "configuration", "->", "getConnection", "(", ")", "->", "query", "(", "'SHOW FULL TABLES WHER...
Writes all of the models @param Configuration $configuration @param string $ignoredTablesRegex @return void
[ "Writes", "all", "of", "the", "models" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L205-L221
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Generator/ModelBuilder.php
ModelBuilder.buildFields
private function buildFields() { $fields = array(); /** @var ResultSet $results */ $results = $this->getConfiguration()->getConnection()->query('SHOW COLUMNS FROM `' . $this->getTableName() . '`'); $dbName = $this->getCurrentDatabaseName(); while($result = $results->fetch()) { $result = (object)$result; $params = array($dbName, $this->getTableName(), $result->Field); /** @var ResultSet $informationResults */ $informationResults = $this->getConfiguration()->getInformationSchemaConnection()->query( 'SELECT * FROM `COLUMNS` WHERE TABLE_SCHEMA=? AND TABLE_NAME=? AND COLUMN_NAME=?', $params ); /** @var \stdClass $informationResult */ $informationResult = (object)$informationResults->fetch(); $field = new Field($result, $this->getTableName(), $informationResult); switch($field->getType()) { case 'Date': $this->getAbstractClass()->addUse($this->getConfiguration()->getDateClassName()); break; case 'DateTime': $this->getAbstractClass()->addUse($this->getConfiguration()->getDateTimeClassName()); break; } $fields[] = $field; } usort( $fields, function (Field $fieldA, Field $fieldB) { return strcasecmp($fieldA->getShortName(), $fieldB->getShortName()); } ); $this->setFields($fields); }
php
private function buildFields() { $fields = array(); /** @var ResultSet $results */ $results = $this->getConfiguration()->getConnection()->query('SHOW COLUMNS FROM `' . $this->getTableName() . '`'); $dbName = $this->getCurrentDatabaseName(); while($result = $results->fetch()) { $result = (object)$result; $params = array($dbName, $this->getTableName(), $result->Field); /** @var ResultSet $informationResults */ $informationResults = $this->getConfiguration()->getInformationSchemaConnection()->query( 'SELECT * FROM `COLUMNS` WHERE TABLE_SCHEMA=? AND TABLE_NAME=? AND COLUMN_NAME=?', $params ); /** @var \stdClass $informationResult */ $informationResult = (object)$informationResults->fetch(); $field = new Field($result, $this->getTableName(), $informationResult); switch($field->getType()) { case 'Date': $this->getAbstractClass()->addUse($this->getConfiguration()->getDateClassName()); break; case 'DateTime': $this->getAbstractClass()->addUse($this->getConfiguration()->getDateTimeClassName()); break; } $fields[] = $field; } usort( $fields, function (Field $fieldA, Field $fieldB) { return strcasecmp($fieldA->getShortName(), $fieldB->getShortName()); } ); $this->setFields($fields); }
[ "private", "function", "buildFields", "(", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "/** @var ResultSet $results */", "$", "results", "=", "$", "this", "->", "getConfiguration", "(", ")", "->", "getConnection", "(", ")", "->", "query", "(", "'...
Builds the fields and types @return void
[ "Builds", "the", "fields", "and", "types" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L296-L329
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Generator/ModelBuilder.php
ModelBuilder.buildRelationshipsBuffer
private function buildRelationshipsBuffer() { $buffer = ''; foreach($this->getRelationships() as $relationship) { $buffer .= ' $this->' . $relationship->getRelationshipType() . '( \'' . $this->getField($relationship->getLocalColumn())->getShortName() . '\', \'' . $relationship->getRemoteModel() . '\', \'' . $relationship->getRemoteShortColumn() . '\', array( \'alias\' => \'' . $relationship->getAlias() . '\', \'foreignKey\' => array( \'message\' => \'The ' . $this->getTableName() . ' cannot be deleted because other ' . $relationship->getRemoteTable() . '(s) are attached\', \'action\' => Relation::' . $relationship->getAction() . ' ), \'reusable\' => true ) );' . "\n"; } return $buffer; }
php
private function buildRelationshipsBuffer() { $buffer = ''; foreach($this->getRelationships() as $relationship) { $buffer .= ' $this->' . $relationship->getRelationshipType() . '( \'' . $this->getField($relationship->getLocalColumn())->getShortName() . '\', \'' . $relationship->getRemoteModel() . '\', \'' . $relationship->getRemoteShortColumn() . '\', array( \'alias\' => \'' . $relationship->getAlias() . '\', \'foreignKey\' => array( \'message\' => \'The ' . $this->getTableName() . ' cannot be deleted because other ' . $relationship->getRemoteTable() . '(s) are attached\', \'action\' => Relation::' . $relationship->getAction() . ' ), \'reusable\' => true ) );' . "\n"; } return $buffer; }
[ "private", "function", "buildRelationshipsBuffer", "(", ")", "{", "$", "buffer", "=", "''", ";", "foreach", "(", "$", "this", "->", "getRelationships", "(", ")", "as", "$", "relationship", ")", "{", "$", "buffer", ".=", "'\t\t$this->'", ".", "$", "relation...
Builds the relationship buffer @return string
[ "Builds", "the", "relationship", "buffer" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L596-L614
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Generator/ModelBuilder.php
ModelBuilder.getField
private function getField($columnName) { foreach($this->getFields() as $field) { if($field->getName() == $columnName) { return $field; } } echo 'Could Not Find Field '.$this->getTableName().'.'.$columnName."\n"; return false; }
php
private function getField($columnName) { foreach($this->getFields() as $field) { if($field->getName() == $columnName) { return $field; } } echo 'Could Not Find Field '.$this->getTableName().'.'.$columnName."\n"; return false; }
[ "private", "function", "getField", "(", "$", "columnName", ")", "{", "foreach", "(", "$", "this", "->", "getFields", "(", ")", "as", "$", "field", ")", "{", "if", "(", "$", "field", "->", "getName", "(", ")", "==", "$", "columnName", ")", "{", "ret...
Gets a field by it's original name @param string $columnName @return Field|bool
[ "Gets", "a", "field", "by", "it", "s", "original", "name" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L623-L631
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Generator/ModelBuilder.php
ModelBuilder.buildVariableDefinitions
private function buildVariableDefinitions() { foreach($this->getFields() as $field) { $variable = new Object\Variable(); $variable->setName($field->getShortName()); $variable->setAccess('protected'); $variable->setAutoIncrementing($field->isAutoIncrementing()); $variable->setDescription($field->getDescription()); $variable->setLength($field->getLength()); $variable->setNullable($field->isNullable()); $variable->setPrimary($field->isPrimary()); $variable->setType($field->getType()); $this->getAbstractClass()->addVariable($variable); } }
php
private function buildVariableDefinitions() { foreach($this->getFields() as $field) { $variable = new Object\Variable(); $variable->setName($field->getShortName()); $variable->setAccess('protected'); $variable->setAutoIncrementing($field->isAutoIncrementing()); $variable->setDescription($field->getDescription()); $variable->setLength($field->getLength()); $variable->setNullable($field->isNullable()); $variable->setPrimary($field->isPrimary()); $variable->setType($field->getType()); $this->getAbstractClass()->addVariable($variable); } }
[ "private", "function", "buildVariableDefinitions", "(", ")", "{", "foreach", "(", "$", "this", "->", "getFields", "(", ")", "as", "$", "field", ")", "{", "$", "variable", "=", "new", "Object", "\\", "Variable", "(", ")", ";", "$", "variable", "->", "se...
Builds the variable definitions @return void
[ "Builds", "the", "variable", "definitions" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L701-L714
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Generator/ModelBuilder.php
ModelBuilder.buildColumnMap
private function buildColumnMap() { $content = ' return $this->columnMapMissingColumnsFix(array(' . "\n"; foreach($this->getFields() as $field) { $content .= ' \'' . $field->getName() . '\' => \'' . $field->getShortName() . '\',' . "\n"; } $content = substr($content, 0, -2) . "\n"; //Remove trailing comma $content .= ' ));'; $method = new Object\Method(); $method->setAccess('public'); $method->setDescription('Updates so we can use the shortened names, without changing the database'); $method->setName('columnMap'); $method->setReturnType('string[] keys are the real names, values are the names in the application'); $method->setContent($content); $this->getAbstractClass()->addMethod($method); $this->getAbstractClass()->addUse('Phalcon\Db\Column'); $content = ' return ['; foreach($this->getFields() as $field) { $content .= ' \'' . $field->getShortName() . '\' => Column::' . $field->getPhalconColumnType() . ',' . "\n"; } $content .= ' ];'; $method = new Object\Method(); $method->setAccess('public'); $method->setDescription('Used for determining the database type'); $method->setName('getDatabaseTypes'); $method->setReturnType('string[] keys are the column names, values are the DB\Column'); $method->setContent($content); $this->getAbstractClass()->addMethod($method); }
php
private function buildColumnMap() { $content = ' return $this->columnMapMissingColumnsFix(array(' . "\n"; foreach($this->getFields() as $field) { $content .= ' \'' . $field->getName() . '\' => \'' . $field->getShortName() . '\',' . "\n"; } $content = substr($content, 0, -2) . "\n"; //Remove trailing comma $content .= ' ));'; $method = new Object\Method(); $method->setAccess('public'); $method->setDescription('Updates so we can use the shortened names, without changing the database'); $method->setName('columnMap'); $method->setReturnType('string[] keys are the real names, values are the names in the application'); $method->setContent($content); $this->getAbstractClass()->addMethod($method); $this->getAbstractClass()->addUse('Phalcon\Db\Column'); $content = ' return ['; foreach($this->getFields() as $field) { $content .= ' \'' . $field->getShortName() . '\' => Column::' . $field->getPhalconColumnType() . ',' . "\n"; } $content .= ' ];'; $method = new Object\Method(); $method->setAccess('public'); $method->setDescription('Used for determining the database type'); $method->setName('getDatabaseTypes'); $method->setReturnType('string[] keys are the column names, values are the DB\Column'); $method->setContent($content); $this->getAbstractClass()->addMethod($method); }
[ "private", "function", "buildColumnMap", "(", ")", "{", "$", "content", "=", "'\t\treturn $this->columnMapMissingColumnsFix(array('", ".", "\"\\n\"", ";", "foreach", "(", "$", "this", "->", "getFields", "(", ")", "as", "$", "field", ")", "{", "$", "content", "...
Builds the column maps @return void
[ "Builds", "the", "column", "maps" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L861-L889
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Generator/ModelBuilder.php
ModelBuilder.buildRelationshipsList
private function buildRelationshipsList() { $content = ' return array(' . "\n"; $added = false; foreach($this->getRelationships() as $relationship) { if(!$relationship->isPlural()) { $added = true; $content .= ' \'' . $relationship->getAlias() . '\',' . "\n"; } } if($added) { $content = substr($content, 0, -2) . "\n"; //Remove trailing comma } $content .= ' );'; $method = new Object\Method(); $method->setAccess('public'); $method->setDescription('Returns a list of all parent relationships, these will all return a Base Model instance'); $method->setName('getParentRelationships'); $method->setReturnType('string[] values are the alias of the relationship'); $method->setContent($content); $this->getAbstractClass()->addMethod($method); $content = ' return array(' . "\n"; $added = false; foreach($this->getRelationships() as $relationship) { if($relationship->isPlural()) { $added = true; $content .= ' \'' . $relationship->getAlias() . '\',' . "\n"; } } if($added) { $content = substr($content, 0, -2) . "\n"; //Remove trailing comma } $content .= ' );'; $method = new Object\Method(); $method->setAccess('public'); $method->setDescription('Returns a list of all children relationships, these will all return a ResultSet'); $method->setName('getChildrenRelationships'); $method->setReturnType('string[] values are the alias of the relationship'); $method->setContent($content); $this->getAbstractClass()->addMethod($method); }
php
private function buildRelationshipsList() { $content = ' return array(' . "\n"; $added = false; foreach($this->getRelationships() as $relationship) { if(!$relationship->isPlural()) { $added = true; $content .= ' \'' . $relationship->getAlias() . '\',' . "\n"; } } if($added) { $content = substr($content, 0, -2) . "\n"; //Remove trailing comma } $content .= ' );'; $method = new Object\Method(); $method->setAccess('public'); $method->setDescription('Returns a list of all parent relationships, these will all return a Base Model instance'); $method->setName('getParentRelationships'); $method->setReturnType('string[] values are the alias of the relationship'); $method->setContent($content); $this->getAbstractClass()->addMethod($method); $content = ' return array(' . "\n"; $added = false; foreach($this->getRelationships() as $relationship) { if($relationship->isPlural()) { $added = true; $content .= ' \'' . $relationship->getAlias() . '\',' . "\n"; } } if($added) { $content = substr($content, 0, -2) . "\n"; //Remove trailing comma } $content .= ' );'; $method = new Object\Method(); $method->setAccess('public'); $method->setDescription('Returns a list of all children relationships, these will all return a ResultSet'); $method->setName('getChildrenRelationships'); $method->setReturnType('string[] values are the alias of the relationship'); $method->setContent($content); $this->getAbstractClass()->addMethod($method); }
[ "private", "function", "buildRelationshipsList", "(", ")", "{", "$", "content", "=", "'\t\treturn array('", ".", "\"\\n\"", ";", "$", "added", "=", "false", ";", "foreach", "(", "$", "this", "->", "getRelationships", "(", ")", "as", "$", "relationship", ")",...
Builds the relationships list methods @return void
[ "Builds", "the", "relationships", "list", "methods" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L895-L936
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Generator/ModelBuilder.php
ModelBuilder.buildEnumConstants
private function buildEnumConstants() { foreach($this->getFields() as $field) { $options = $field->getEnumOptions(); if(!is_null($options)) { $enumClass = new Object\Index($this->getConfiguration()); $enumClass->setNamespace($this->getAbstractClass()->getNamespace().'\\'.$this->getAbstractClass()->getName()); $enumClass->setName(ucfirst($field->getShortName())); $enumClass->addUse('Bullhorn\FastRest\Api\Services\SplEnum'); $enumClass->setExtends('SplEnum'); foreach($options as $option) { $optionName = lcfirst($option); if($optionName == '') { $optionName = 'EMPTY'; } $this->getAbstractClass()->addConstant($this->filterConstant($field->getShortName() . '_' . $optionName), $option); $enumClass->addConstant($this->filterConstant($optionName), $option); } $enumClass->write(); } } }
php
private function buildEnumConstants() { foreach($this->getFields() as $field) { $options = $field->getEnumOptions(); if(!is_null($options)) { $enumClass = new Object\Index($this->getConfiguration()); $enumClass->setNamespace($this->getAbstractClass()->getNamespace().'\\'.$this->getAbstractClass()->getName()); $enumClass->setName(ucfirst($field->getShortName())); $enumClass->addUse('Bullhorn\FastRest\Api\Services\SplEnum'); $enumClass->setExtends('SplEnum'); foreach($options as $option) { $optionName = lcfirst($option); if($optionName == '') { $optionName = 'EMPTY'; } $this->getAbstractClass()->addConstant($this->filterConstant($field->getShortName() . '_' . $optionName), $option); $enumClass->addConstant($this->filterConstant($optionName), $option); } $enumClass->write(); } } }
[ "private", "function", "buildEnumConstants", "(", ")", "{", "foreach", "(", "$", "this", "->", "getFields", "(", ")", "as", "$", "field", ")", "{", "$", "options", "=", "$", "field", "->", "getEnumOptions", "(", ")", ";", "if", "(", "!", "is_null", "...
Builds the enum constants @return void @throws \Exception
[ "Builds", "the", "enum", "constants" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L986-L1008
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Generator/ModelBuilder.php
ModelBuilder.buildOnConstruct
private function buildOnConstruct() { $content = ''; foreach($this->getFields() as $field) { if(in_array($field->getType(), array('Date', 'DateTime'))) { $content .= ' $this->set' . ucfirst($field->getShortName()) . '(new ' . $field->getType() . '($this->get' . ucfirst($field->getShortName()) . '())); '; } } $content .= ' parent::onConstruct();'; $method = new Object\Method(); $method->setAccess('public'); $method->setDescription('Used to Construct an instance'); $method->setName('onConstruct'); $method->setReturnType('void'); $method->setContent($content); $this->getAbstractClass()->addMethod($method); }
php
private function buildOnConstruct() { $content = ''; foreach($this->getFields() as $field) { if(in_array($field->getType(), array('Date', 'DateTime'))) { $content .= ' $this->set' . ucfirst($field->getShortName()) . '(new ' . $field->getType() . '($this->get' . ucfirst($field->getShortName()) . '())); '; } } $content .= ' parent::onConstruct();'; $method = new Object\Method(); $method->setAccess('public'); $method->setDescription('Used to Construct an instance'); $method->setName('onConstruct'); $method->setReturnType('void'); $method->setContent($content); $this->getAbstractClass()->addMethod($method); }
[ "private", "function", "buildOnConstruct", "(", ")", "{", "$", "content", "=", "''", ";", "foreach", "(", "$", "this", "->", "getFields", "(", ")", "as", "$", "field", ")", "{", "if", "(", "in_array", "(", "$", "field", "->", "getType", "(", ")", "...
Builds the on construct method @return void @throws \Exception
[ "Builds", "the", "on", "construct", "method" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L1032-L1048
train
bullhorn/fast-rest
Library/Bullhorn/FastRest/Generator/ModelBuilder.php
ModelBuilder.buildGetSource
private function buildGetSource() { $method = new Object\Method(); $method->setAccess('public'); $method->setDescription('This returns the table name'); $method->setName('getSource'); $method->setReturnType('string'); $method->setContent('return \'' . $this->getTableName() . '\';'); $this->getAbstractClass()->addMethod($method); }
php
private function buildGetSource() { $method = new Object\Method(); $method->setAccess('public'); $method->setDescription('This returns the table name'); $method->setName('getSource'); $method->setReturnType('string'); $method->setContent('return \'' . $this->getTableName() . '\';'); $this->getAbstractClass()->addMethod($method); }
[ "private", "function", "buildGetSource", "(", ")", "{", "$", "method", "=", "new", "Object", "\\", "Method", "(", ")", ";", "$", "method", "->", "setAccess", "(", "'public'", ")", ";", "$", "method", "->", "setDescription", "(", "'This returns the table name...
Builds the getSource @return void @throws \Exception
[ "Builds", "the", "getSource" ]
ac808abf6245144a1a885a3192a8f84debdf3118
https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L1076-L1084
train