public function SetAcceptMODxURLDocIdsString($acceptMODxURLDocIdsString, $save = TRUE) { if (!is_string($acceptMODxURLDocIdsString)) { return FALSE; } $newAcceptMODxURLDocIds = preg_split('/\\s*,\\s*/x' . YamsUtils::UTF8Modifier(), $acceptMODxURLDocIdsString, -1, PREG_SPLIT_NO_EMPTY); if ($newAcceptMODxURLDocIds === FALSE) { return FALSE; } foreach ($newAcceptMODxURLDocIds as $id => $docId) { if ($docId == '*') { continue; } if (YamsUtils::IsValidId($docId)) { continue; } unset($newAcceptMODxURLDocIds[$id]); } $this->itsAcceptMODxURLDocIds = array_unique($newAcceptMODxURLDocIds); if ($save) { return $this->SaveCurrentSettings(); } return TRUE; }
// Determine the docId and langId from the alias... // The currentLangId is set if a valid document is found. $aliasDecoded = YamsUtils::UrlDecode($_GET['q']); $docId = $yams->GetDocumentIdentifierUnique($aliasDecoded, $langId); } else { // Determine the langId from the server and root name $langId = $yams->DetermineCurrentLangId(); // Determine the docId from the alias, given the language $docId = $yams->GetDocumentIdentifier($_GET['q'], $langId); } } if (is_null($docId)) { // If no docId was found... // but a standard MODx url matches... then use that. // This is for compatibility with standard MODx resources if (YamsUtils::IsValidId($modx->documentIdentifier)) { $docIdFoundByYAMS = FALSE; $docId = $modx->documentIdentifier; // However, in that case, the langauge will not have been // determined, so in the absense of other information... if (is_null($langId)) { if ($yams->IsMultilingualDocument($docId)) { // Keep to the current language... $langId = $yams->GetCurrentLangId(); } else { // Use the default. $langId = $yams->GetDefaultLangId(); } } } }
public function Expand($get, $from, $docId = NULL, $mode = '', $beforeModifier = '', $afterModifier = '') { // Determine which brackets to use depending on the action... switch ($get) { case 'text': $open = ''; $close = ''; break; case 'chunk': case '{{': $open = '{{'; $close = '}}'; break; case 'csnippet': case '[[': $open = '[['; $close = ']]'; break; case 'usnippet': case '[!': $open = '[!'; $close = '!]'; break; case 'placeholder': case '[+': $open = '[+'; $close = '+]'; break; case 'tv': case '[*': $open = '[*'; $close = '*]'; break; case 'data': case 'content': if (is_null($docId)) { $open = '((yams_data:'; $close = '))'; } else { if (YamsUtils::IsValidId($docId)) { $open = '((yams_data:' . $docId . ':'; $close = '))'; } else { return ''; } } break; default: return ''; } if (is_string($from)) { // Parse the select argument and create a lang array $langArray = array(); $langNameArray = preg_split('/\\|\\|/' . $this->itsUTF8Modifier, $from, -1); unset($from); foreach ($langNameArray as $langName) { $result = preg_match('/^([a-zA-Z0-9]+)::(.*?)$/DU' . $this->itsUTF8Modifier, $langName, $matches); if ($result != 1) { continue; } $langId = $matches[1]; $name = $matches[2]; if ($this->IsActiveLangId($langId)) { $langArray[$langId] = $name; } } } elseif (is_array($from)) { $langArray =& $from; // foreach ( $langArray as $langId => $name ) // { // if ( ! $this->IsActiveLangId( $langId ) ) // { // unset( $langArray[ $langId ] ); // continue; // } // if ( !is_string( $name ) ) // { // unset( $langArray[ $langId ] ); // continue; // } // } //// if ( ! array_key_exists( $this->itsDefaultLangId, $langArray ) ) //// { //// return ''; //// } } else { return ''; } // Get an id for this yams multilingual block $yamsCounter = $this->GetYamsCounter(); // Build the multilingual output... // Start with the default language $startBlock = '(yams-select' . $mode . ':' . $yamsCounter . ')'; // Add the other languages... $output = ''; foreach ($langArray as $langId => $name) { if (!in_array($langId, $this->itsActiveLangIds)) { continue; } $content = $open . $beforeModifier . $name . $afterModifier . $close; if ($content == '') { continue; } $output .= '(lang:' . $yamsCounter . ':' . $langId . ')' . $content; } if ($output == '') { return ''; } // Add the closing tag $endBlock = '(/yams-select' . $mode . ':' . $yamsCounter . ')'; return $startBlock . $output . $endBlock; }
function YamsRemoveAssociationsForTV($tvId, $templateIds) { global $modx; $yams = YAMS::GetInstance(); if (!is_array($templateIds)) { return FALSE; } if (count($templateIds) == 0) { return TRUE; } foreach ($templateIds as &$templateId) { if (!YamsUtils::IsValidId($templateId)) { return FALSE; } $templateId = $modx->db->escape($templateId); } $templateIdList = implode(',', $templateIds); $tblName = $modx->getFullTableName('site_tmplvar_templates'); $result = $modx->db->delete($tblName, 'tmplvarid=' . $modx->db->escape($tvId) . ' AND ' . 'templateid IN (' . $templateIdList . ')'); return $result; }