summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-10-22 01:27:18 +0000
committerDries Buytaert <dries@buytaert.net>2009-10-22 01:27:18 +0000
commit891512c22912527d54f29fe30ef9f3be110746a3 (patch)
treed3474a4dfb2f05c86c4dfb993a1f0b6c4ff9c7b0
parenteb84b868885ba818d8d6c1698c581916a519ff09 (diff)
downloadbrdo-891512c22912527d54f29fe30ef9f3be110746a3.tar.gz
brdo-891512c22912527d54f29fe30ef9f3be110746a3.tar.bz2
- Patch #332333 by sun: moving some functions, no API changes, no new features.
-rw-r--r--includes/path.inc84
-rw-r--r--modules/path/path.module83
2 files changed, 84 insertions, 83 deletions
diff --git a/includes/path.inc b/includes/path.inc
index 96ac711e4..f1542323e 100644
--- a/includes/path.inc
+++ b/includes/path.inc
@@ -374,3 +374,87 @@ function drupal_path_alias_whitelist_rebuild() {
variable_set('path_alias_whitelist', $whitelist);
return $whitelist;
}
+
+/**
+ * Fetch a specific URL alias from the database.
+ *
+ * @param $conditions
+ * A string representing the source, a number representing the pid, or an
+ * array of query conditions.
+ *
+ * @return
+ * FALSE if no alias was found or an associative array containing the
+ * following keys:
+ * - source: The internal system path.
+ * - alias: The URL alias.
+ * - pid: Unique path alias identifier.
+ * - language: The language of the alias.
+ */
+function path_load($conditions) {
+ if (is_numeric($conditions)) {
+ $conditions = array('pid' => $conditions);
+ }
+ elseif (is_string($conditions)) {
+ $conditions = array('source' => $conditions);
+ }
+ elseif (!is_array($conditions)) {
+ return FALSE;
+ }
+ $select = db_select('url_alias');
+ foreach ($conditions as $field => $value) {
+ $select->condition($field, $value);
+ }
+ return $select
+ ->fields('url_alias')
+ ->execute()
+ ->fetchAssoc();
+}
+
+/**
+ * Save a path alias to the database.
+ *
+ * @param $path
+ * An associative array containing the following keys:
+ * - source: The internal system path.
+ * - alias: The URL alias.
+ * - pid: (optional) Unique path alias identifier.
+ * - language: (optional) The language of the alias.
+ */
+function path_save(&$path) {
+ $path += array('pid' => NULL, 'language' => '');
+
+ // Insert or update the alias.
+ $status = drupal_write_record('url_alias', $path, (!empty($path['pid']) ? 'pid' : NULL));
+
+ // Verify that a record was written.
+ if (isset($status) && $status) {
+ if ($status === SAVED_NEW) {
+ module_invoke_all('path_insert', $path);
+ }
+ else {
+ module_invoke_all('path_update', $path);
+ }
+ drupal_clear_path_cache();
+ }
+}
+
+/**
+ * Delete a URL alias.
+ *
+ * @param $criteria
+ * A number representing the pid or an array of criteria.
+ */
+function path_delete($criteria) {
+ if (!is_array($criteria)) {
+ $criteria = array('pid' => $criteria);
+ }
+ $path = path_load($criteria);
+ $query = db_delete('url_alias');
+ foreach ($criteria as $field => $value) {
+ $query->condition($field, $value);
+ }
+ $query->execute();
+ module_invoke_all('path_delete', $path);
+ drupal_clear_path_cache();
+}
+
diff --git a/modules/path/path.module b/modules/path/path.module
index ca3c16d55..9417f8eba 100644
--- a/modules/path/path.module
+++ b/modules/path/path.module
@@ -91,89 +91,6 @@ function path_menu() {
}
/**
- * Fetch a specific URL alias from the database.
- *
- * @param $conditions
- * A string representing the source, a number representing the pid, or an
- * array of query conditions.
- *
- * @return
- * FALSE if no alias was found or an associative array containing the
- * following keys:
- * - source: The internal system path.
- * - alias: The URL alias.
- * - pid: Unique path alias identifier.
- * - language: The language of the alias.
- */
-function path_load($conditions) {
- if (is_numeric($conditions)) {
- $conditions = array('pid' => $conditions);
- }
- elseif (is_string($conditions)) {
- $conditions = array('source' => $conditions);
- }
- elseif (!is_array($conditions)) {
- return FALSE;
- }
- $select = db_select('url_alias');
- foreach ($conditions as $field => $value) {
- $select->condition($field, $value);
- }
- return $select
- ->fields('url_alias')
- ->execute()
- ->fetchAssoc();
-}
-
-/**
- * Save a path alias to the database.
- *
- * @param $path
- * An associative array containing the following keys:
- * - source: The internal system path.
- * - alias: The URL alias.
- * - pid: (optional) Unique path alias identifier.
- * - language: (optional) The language of the alias.
- */
-function path_save(&$path) {
- $path += array('pid' => NULL, 'language' => '');
-
- // Insert or update the alias.
- $status = drupal_write_record('url_alias', $path, (!empty($path['pid']) ? 'pid' : NULL));
-
- // Verify that a record was written.
- if (isset($status) && $status) {
- if ($status === SAVED_NEW) {
- module_invoke_all('path_insert', $path);
- }
- else {
- module_invoke_all('path_update', $path);
- }
- drupal_clear_path_cache();
- }
-}
-
-/**
- * Delete a URL alias.
- *
- * @param $criteria
- * A number representing the pid or an array of criteria.
- */
-function path_delete($criteria) {
- if (!is_array($criteria)) {
- $criteria = array('pid' => $criteria);
- }
- $path = path_load($criteria);
- $query = db_delete('url_alias');
- foreach ($criteria as $field => $value) {
- $query->condition($field, $value);
- }
- $query->execute();
- module_invoke_all('path_delete', $path);
- drupal_clear_path_cache();
-}
-
-/**
* Implement hook_form_alter().
*/
function path_form_alter(&$form, $form_state, $form_id) {