| 1 |
<?php |
| 2 |
/** |
| 3 |
* TermObjectController.php |
| 4 |
* |
| 5 |
* The TermObjectController class file. |
| 6 |
* |
| 7 |
* PHP versions 5 |
| 8 |
* |
| 9 |
* @author Alexander Schneider <alexanderschneider85@gmail.com> |
| 10 |
* @copyright 2008-2017 Alexander Schneider |
| 11 |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 |
| 12 |
* @version SVN: $id$ |
| 13 |
* @link http://wordpress.org/extend/plugins/user-access-manager/ |
| 14 |
*/ |
| 15 |
namespace UserAccessManager\Controller\Backend; |
| 16 |
|
| 17 |
use UserAccessManager\Object\ObjectHandler; |
| 18 |
|
| 19 |
/** |
| 20 |
* Class TermObjectController |
| 21 |
* |
| 22 |
* @package UserAccessManager\Controller\Backend |
| 23 |
*/ |
| 24 |
class TermObjectController extends ObjectController |
| 25 |
{ |
| 26 |
/** |
| 27 |
* The function for the manage_categories_columns filter. |
| 28 |
* |
| 29 |
* @param array $defaults The table headers. |
| 30 |
* |
| 31 |
* @return array |
| 32 |
*/ |
| 33 |
public function addTermColumnsHeader($defaults) |
| 34 |
{ |
| 35 |
$defaults[self::COLUMN_NAME] = TXT_UAM_COLUMN_ACCESS; |
| 36 |
return $defaults; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* The function for the manage_categories_custom_column action. |
| 41 |
* |
| 42 |
* @param string $content Content for the column. Multiple filter calls are possible, so we need to append. |
| 43 |
* @param string $columnName The column name. |
| 44 |
* @param integer $id The id. |
| 45 |
* |
| 46 |
* @return string $content with content appended for self::COLUMN_NAME column |
| 47 |
*/ |
| 48 |
public function addTermColumn($content, $columnName, $id) |
| 49 |
{ |
| 50 |
if ($columnName === self::COLUMN_NAME) { |
| 51 |
$term = $this->objectHandler->getTerm($id); |
| 52 |
$objectType = ($term !== false) ? $term->taxonomy : ObjectHandler::GENERAL_TERM_OBJECT_TYPE; |
| 53 |
$content .= $this->getGroupColumn($objectType, $id); |
| 54 |
} |
| 55 |
|
| 56 |
return $content; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* The function for the edit_{term}_form action. |
| 61 |
* |
| 62 |
* @param string|\WP_Term $term The term. |
| 63 |
*/ |
| 64 |
public function showTermEditForm($term) |
| 65 |
{ |
| 66 |
if ($term instanceof \WP_Term) { |
| 67 |
$this->setObjectInformation($term->taxonomy, $term->term_id); |
| 68 |
} else { |
| 69 |
$this->setObjectInformation($term, null); |
| 70 |
} |
| 71 |
|
| 72 |
echo $this->getIncludeContents('TermEditForm.php'); |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* The function for the edit_{term} action. |
| 77 |
* |
| 78 |
* @param integer $termId The term id. |
| 79 |
*/ |
| 80 |
public function saveTermData($termId) |
| 81 |
{ |
| 82 |
$term = $this->objectHandler->getTerm($termId); |
| 83 |
$objectType = ($term !== false) ? $term->taxonomy : ObjectHandler::GENERAL_TERM_OBJECT_TYPE; |
| 84 |
$this->saveObjectData($objectType, $termId); |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* The function for the delete_{term} action. |
| 89 |
* |
| 90 |
* @param integer $termId The id of the term. |
| 91 |
*/ |
| 92 |
public function removeTermData($termId) |
| 93 |
{ |
| 94 |
$this->removeObjectData(ObjectHandler::GENERAL_TERM_OBJECT_TYPE, $termId); |
| 95 |
} |
| 96 |
} |
| 97 |
|