| 112 | | |
| 113 | | $db = AbstractDb :: getObject(); |
| 114 | | |
| 115 | | // Init values |
| 116 | | $row = null; |
| 117 | | |
| 118 | | // Get content from database |
| 119 | | $content_id = $db->escapeString($content_id); |
| 120 | | $sql = "SELECT * FROM content WHERE content_id='$content_id'"; |
| 121 | | $db->execSqlUniqueRes($sql, $row, false); |
| 122 | | |
| 123 | | if ($row == null) { |
| 124 | | throw new Exception(_("The content with the following id could not be found in the database: ") . $content_id); |
| 125 | | } |
| 126 | | |
| 127 | | $this->content_row = $row; |
| 128 | | $this->id = $row['content_id']; |
| 129 | | $this->content_type = $row['content_type']; |
| 130 | | $kvp_rows = null; |
| 131 | | $sql = "SELECT key, value FROM content_key_value_pairs WHERE content_id='$content_id'"; |
| 132 | | $db->execSql($sql, $kvp_rows, false); |
| 133 | | if ($kvp_rows) { |
| 134 | | foreach ($kvp_rows as $kvp_row) { |
| 135 | | $this->kvps[$kvp_row['key']] = $kvp_row['value']; |
| 136 | | } |
| 137 | | } |
| 138 | | // By default content display logging is enabled |
| 139 | | $this->setLoggingStatus(true); |
| 140 | | $this->log_as_content = & $this; |
| | 112 | //echo "Content::__construct($content_id)<br/>\n"; |
| | 113 | $db = AbstractDb :: getObject(); |
| | 114 | |
| | 115 | // Init values |
| | 116 | $row = null; |
| | 117 | |
| | 118 | // Get content from database |
| | 119 | $content_id = $db->escapeString($content_id); |
| | 120 | $sql = "SELECT * FROM content WHERE content_id='$content_id'"; |
| | 121 | $db->execSqlUniqueRes($sql, $row, false); |
| | 122 | |
| | 123 | if ($row == null) { |
| | 124 | throw new Exception(_("The content with the following id could not be found in the database: ") . $content_id); |
| | 125 | } |
| | 126 | |
| | 127 | $this->content_row = $row; |
| | 128 | $this->id = $row['content_id']; |
| | 129 | $this->content_type = $row['content_type']; |
| | 130 | $kvp_rows = null; |
| | 131 | $sql = "SELECT key, value FROM content_key_value_pairs WHERE content_id='$content_id'"; |
| | 132 | $db->execSql($sql, $kvp_rows, false); |
| | 133 | if ($kvp_rows) { |
| | 134 | foreach ($kvp_rows as $kvp_row) { |
| | 135 | $this->kvps[$kvp_row['key']] = $kvp_row['value']; |
| | 136 | } |
| | 137 | } |
| | 138 | // By default content display logging is enabled |
| | 139 | $this->setLoggingStatus(true); |
| | 140 | $this->log_as_content = & $this; |
| 296 | | // Init values |
| 297 | | $contentTypes = array (); |
| 298 | | $useCache = false; |
| 299 | | $cachedData = null; |
| 300 | | |
| 301 | | // Create new cache object with a lifetime of one week |
| 302 | | $cache = new Cache("ContentClasses", "ClassFileCaches", 604800); |
| 303 | | |
| 304 | | // Check if caching has been enabled. |
| 305 | | if ($cache->isCachingEnabled) { |
| 306 | | $cachedData = $cache->getCachedData("mixed"); |
| 307 | | |
| 308 | | if ($cachedData) { |
| 309 | | // Return cached data. |
| 310 | | $useCache = true; |
| 311 | | $contentTypes = $cachedData; |
| 312 | | } |
| 313 | | } |
| 314 | | |
| 315 | | if (!$useCache) { |
| 316 | | $dir = WIFIDOG_ABS_FILE_PATH . "classes/Content"; |
| 317 | | $dirHandle = @ opendir($dir); |
| 318 | | |
| 319 | | if ($dirHandle) { |
| 320 | | // Loop over the directory |
| 321 | | while (false !== ($subDir = readdir($dirHandle))) { |
| 322 | | // Loop through sub-directories of Content |
| 323 | | if ($subDir != '.' && $subDir != '..' && is_dir("{$dir}/{$subDir}")) { |
| 324 | | // Only add directories containing corresponding initial Content class |
| 325 | | if (is_file("{$dir}/{$subDir}/{$subDir}.php")) { |
| 326 | | $contentTypes[] = $subDir; |
| 327 | | } |
| 328 | | } |
| 329 | | } |
| 330 | | |
| 331 | | closedir($dirHandle); |
| 332 | | } else { |
| 333 | | throw new Exception(_('Unable to open directory ') . $dir); |
| 334 | | } |
| 335 | | |
| 336 | | // Cleanup PHP file extensions and sort the result array |
| 337 | | $contentTypes = str_ireplace('.php', '', $contentTypes); |
| 338 | | sort($contentTypes); |
| 339 | | |
| 340 | | // Check if caching has been enabled. |
| 341 | | if ($cache->isCachingEnabled) { |
| 342 | | // Save results into cache, because it wasn't saved into cache before. |
| 343 | | $cache->saveCachedData($contentTypes, "mixed"); |
| 344 | | } |
| 345 | | } |
| 346 | | |
| 347 | | return $contentTypes; |
| 348 | | } |
| 349 | | /** |
| 350 | | * Check if this specific ContentType is usable (all dependencies |
| 351 | | * met,etc. |
| 352 | | * This method is meant to be overloaded by the different content classes |
| 353 | | * @return true or flase |
| 354 | | */ |
| | 298 | // Init values |
| | 299 | $contentTypes = array (); |
| | 300 | $useCache = false; |
| | 301 | $cachedData = null; |
| | 302 | |
| | 303 | // Create new cache object with a lifetime of one week |
| | 304 | $cache = new Cache("ContentClasses", "ClassFileCaches", 604800); |
| | 305 | |
| | 306 | // Check if caching has been enabled. |
| | 307 | if ($cache->isCachingEnabled) { |
| | 308 | $cachedData = $cache->getCachedData("mixed"); |
| | 309 | |
| | 310 | if ($cachedData) { |
| | 311 | // Return cached data. |
| | 312 | $useCache = true; |
| | 313 | $contentTypes = $cachedData; |
| | 314 | } |
| | 315 | } |
| | 316 | |
| | 317 | if (!$useCache) { |
| | 318 | $dir = WIFIDOG_ABS_FILE_PATH . "classes/Content"; |
| | 319 | $dirHandle = @ opendir($dir); |
| | 320 | |
| | 321 | if ($dirHandle) { |
| | 322 | // Loop over the directory |
| | 323 | while (false !== ($subDir = readdir($dirHandle))) { |
| | 324 | // Loop through sub-directories of Content |
| | 325 | if ($subDir != '.' && $subDir != '..' && is_dir("{$dir}/{$subDir}")) { |
| | 326 | // Only add directories containing corresponding initial Content class |
| | 327 | if (is_file("{$dir}/{$subDir}/{$subDir}.php")) { |
| | 328 | $contentTypes[] = $subDir; |
| | 329 | } |
| | 330 | } |
| | 331 | } |
| | 332 | |
| | 333 | closedir($dirHandle); |
| | 334 | } else { |
| | 335 | throw new Exception(_('Unable to open directory ') . $dir); |
| | 336 | } |
| | 337 | |
| | 338 | // Cleanup PHP file extensions and sort the result array |
| | 339 | $contentTypes = str_ireplace('.php', '', $contentTypes); |
| | 340 | sort($contentTypes); |
| | 341 | |
| | 342 | // Check if caching has been enabled. |
| | 343 | if ($cache->isCachingEnabled) { |
| | 344 | // Save results into cache, because it wasn't saved into cache before. |
| | 345 | $cache->saveCachedData($contentTypes, "mixed"); |
| | 346 | } |
| | 347 | } |
| | 348 | |
| | 349 | return $contentTypes; |
| | 350 | } |
| | 351 | /** |
| | 352 | * Check if this specific ContentType is usable (all dependencies |
| | 353 | * met,etc. |
| | 354 | * This method is meant to be overloaded by the different content classes |
| | 355 | * @return true or flase |
| | 356 | */ |
| 421 | | $db = AbstractDb :: getObject(); |
| 422 | | |
| 423 | | // Init values |
| 424 | | $whereClause = ""; |
| 425 | | $rows = null; |
| 426 | | $objects = array (); |
| 427 | | |
| 428 | | if (!empty ($content_type)) { |
| 429 | | $content_type = $db->escapeString($content_type); |
| 430 | | $whereClause = "WHERE content_type = '$content_type'"; |
| 431 | | } |
| 432 | | |
| 433 | | $db->execSql("SELECT content_id FROM content $whereClause", $rows, false); |
| 434 | | |
| 435 | | if ($rows) { |
| 436 | | foreach ($rows as $row) { |
| 437 | | $objects[] = self :: getObject($row['content_id']); |
| 438 | | } |
| 439 | | } |
| 440 | | |
| 441 | | return $objects; |
| | 423 | $db = AbstractDb :: getObject(); |
| | 424 | |
| | 425 | // Init values |
| | 426 | $whereClause = ""; |
| | 427 | $rows = null; |
| | 428 | $objects = array (); |
| | 429 | |
| | 430 | if (!empty ($content_type)) { |
| | 431 | $content_type = $db->escapeString($content_type); |
| | 432 | $whereClause = "WHERE content_type = '$content_type'"; |
| | 433 | } |
| | 434 | |
| | 435 | $db->execSql("SELECT content_id FROM content $whereClause", $rows, false); |
| | 436 | |
| | 437 | if ($rows) { |
| | 438 | foreach ($rows as $row) { |
| | 439 | $objects[] = self :: getObject($row['content_id']); |
| | 440 | } |
| | 441 | } |
| | 442 | |
| | 443 | return $objects; |
| | 444 | } |
| | 445 | |
| | 446 | /** |
| | 447 | * This method contains the interface to add an additional element to a |
| | 448 | * content object. (For example, a new string in a Langstring) |
| | 449 | * It is called when getNewContentUI has only a single possible object type. |
| | 450 | * It may also be called by the object getAdminUI to avoid code duplication. |
| | 451 | * |
| | 452 | * @param string $contentId The id of the (possibly not yet created) content object. |
| | 453 | * |
| | 454 | * @param string $userData=null Array of contextual data optionally sent by displayAdminUI(), |
| | 455 | * and only understood by the class (or subclasses) where getNewUI() is defined. |
| | 456 | * The function must still function if none of it is present. |
| | 457 | * |
| | 458 | * This function understands: |
| | 459 | * $userData['contentTypeFilter'] |
| | 460 | * $userData['calledFromBaseClassNewUI'] |
| | 461 | * @return HTML markup or false. False means that this object does not support this interface. |
| | 462 | */ |
| | 463 | public static function getNewUI($contentId, $userData=null) { |
| | 464 | $db = AbstractDb :: getObject(); |
| | 465 | //echo "Content::getNewUI($contentId,$userData)<br/>\n"; |
| | 466 | |
| | 467 | if(!empty($userData['calledFromBaseClassNewUI'])) { |
| | 468 | //Break recursion if the subclass doesn't overload this method. |
| | 469 | return false; |
| | 470 | } |
| | 471 | |
| | 472 | // Init values |
| | 473 | $html = ""; |
| | 474 | $getNewUIData = null; |
| | 475 | $availableContentTypes = self :: getAvailableContentTypes(); |
| | 476 | |
| | 477 | //echo "Content::getNewUI: userData";pretty_print_r($userData); |
| | 478 | !empty($userData['contentTypeFilter'])?$contentTypeFilter=$userData['contentTypeFilter']:$contentTypeFilter=null; |
| | 479 | //echo "Content::getNewUI: contentTypeFilter";pretty_print_r($contentTypeFilter); |
| | 480 | if (!$contentTypeFilter) { |
| | 481 | //echo "Get an empty filter"; |
| | 482 | $contentTypeFilter = ContentTypeFilter :: getObject(array ()); |
| | 483 | } |
| | 484 | //pretty_print_r($content_type_filter); |
| | 485 | $i = 0; |
| | 486 | $tab = array (); |
| | 487 | foreach ($availableContentTypes as $className) { |
| | 488 | if ($contentTypeFilter->isAcceptableContentClass($className)) { |
| | 489 | $tab[$i][0] = $className; |
| | 490 | $tab[$i][1] = $className; |
| | 491 | $i++; |
| | 492 | } |
| | 493 | } |
| | 494 | $name = "get_new_ui_{$contentId}_content_type"; |
| | 495 | if (count($tab) > 1) { |
| | 496 | $label = _("Add new Content of type") . ": "; |
| | 497 | $html .= "<div class='admin_element_data content_add'>"; |
| | 498 | $html .= $label; |
| | 499 | $html .= FormSelectGenerator :: generateFromArray($tab, 'TrivialLangstring', $name, null, false); |
| | 500 | $html .= "</div>"; |
| | 501 | } else |
| | 502 | if (count($tab) == 1) { |
| | 503 | $html .= '<input type="hidden" name="' . $name . '" value="' . $tab[0][0] . '">'; |
| | 504 | $name = "get_new_ui_{$contentId}_content_type_is_unique"; |
| | 505 | $html .= '<input type="hidden" name="' . $name . '" value="true">'; |
| | 506 | $userData['calledFromBaseClassNewUI']=true; |
| | 507 | $getNewUIData = call_user_func(array ($tab[0][0], 'getNewUI'), $contentId, $userData); |
| | 508 | |
| | 509 | } else { |
| | 510 | throw new Exception(_("No content type matches the filter.")); |
| | 511 | } |
| | 512 | |
| | 513 | if($getNewUIData != null) { |
| | 514 | //If the single possible content type given by the filter defined an interface to directly create a new instance |
| | 515 | $html .= $getNewUIData; |
| | 516 | } |
| | 517 | else { |
| | 518 | if (count($tab) == 1) { |
| | 519 | $value = sprintf(_("Add a %s"), $tab[0][1]); |
| | 520 | } else { |
| | 521 | $value = _("Add"); |
| | 522 | } |
| | 523 | $html .= "<div class='admin_element_tools'>"; |
| | 524 | $name = "get_new_content_{$contentId}_add"; |
| | 525 | $html .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">'; |
| | 526 | $html .= "</div>"; |
| | 527 | } |
| | 528 | return $html; |
| | 529 | } |
| | 530 | |
| | 531 | /** |
| | 532 | * |
| | 533 | * |
| | 534 | * @param string $contentId The id of the (possibly not yet created) content object. |
| | 535 | * |
| | 536 | * @param string $checkOnly If true, only check if there is data to be processed. |
| | 537 | * Will be used to decide if an object is to be created. If there is |
| | 538 | * processNewUI will typically be called again with $chechOnly=false |
| | 539 | * |
| | 540 | * @return true if there was data to be processed, false otherwise |
| | 541 | |
| | 542 | */ |
| | 543 | public static function processNewUI($contentId, $checkOnly=false, $userData=null) { |
| | 544 | //echo "Content::processNewUI($contentId, $checkOnly)"; |
| | 545 | $retval=false; |
| | 546 | if(!empty($userData['calledFromBaseClassNewUI'])) { |
| | 547 | //Break recursion if the subclass doesn't overload this method. |
| | 548 | return false; |
| | 549 | } |
| | 550 | $processNewUIHasData = false; |
| | 551 | $name = "get_new_ui_{$contentId}_content_type"; |
| | 552 | $contentType = FormSelectGenerator :: getResult($name, null); |
| | 553 | |
| | 554 | //Was there data to process |
| | 555 | $name = "get_new_ui_{$contentId}_content_type_is_unique"; |
| | 556 | if(!empty($_REQUEST[$name])){ |
| | 557 | $userData['calledFromBaseClassNewUI']=true; |
| | 558 | $processNewUIHasData = call_user_func(array ($contentType, 'processNewUI'), $contentId, true, $userData); |
| | 559 | } |
| | 560 | //Was add button clicked, or was there data in the new admin UI |
| | 561 | $name = "get_new_content_{$contentId}_add"; |
| | 562 | if ((!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) || $processNewUIHasData) { |
| | 563 | $retval=true; |
| | 564 | if($checkOnly == false) { |
| | 565 | $object = self::getObject($contentId); |
| | 566 | $object->setContentType($contentType); |
| | 567 | if($processNewUIHasData) { |
| | 568 | //If there was data to processs, process it for real |
| | 569 | call_user_func(array ($contentType, 'processNewUI'), $contentId, false); |
| | 570 | } |
| | 571 | } |
| | 572 | } |
| | 573 | |
| | 574 | return $retval; |
| 456 | | |
| 457 | | $db = AbstractDb :: getObject(); |
| 458 | | |
| 459 | | // Init values |
| 460 | | $html = ""; |
| 461 | | $html .= "<fieldset class='admin_container Content'>\n"; |
| 462 | | if (!empty ($title)) { |
| 463 | | $html .= "<legend>$title</legend>\n"; |
| 464 | | } |
| 465 | | |
| 466 | | $availableContentTypes = self :: getAvailableContentTypes(); |
| 467 | | |
| 468 | | $name = "get_new_content_{$user_prefix}_content_type"; |
| 469 | | |
| 470 | | if (!$content_type_filter) { |
| 471 | | //Get an empty filter |
| 472 | | $content_type_filter = ContentTypeFilter :: getObject(array ()); |
| 473 | | } |
| 474 | | //pretty_print_r($content_type_filter); |
| 475 | | $i = 0; |
| 476 | | $tab = array (); |
| 477 | | foreach ($availableContentTypes as $className) { |
| 478 | | if ($content_type_filter->isAcceptableContentClass($className)) { |
| 479 | | $tab[$i][0] = $className; |
| 480 | | $tab[$i][1] = $className; |
| 481 | | $i++; |
| 482 | | } |
| 483 | | } |
| 484 | | if (count($tab) > 1) { |
| 485 | | $label = _("Add new Content of type") . ": "; |
| 486 | | $html .= "<div class='admin_element_data content_add'>"; |
| 487 | | $html .= $label; |
| 488 | | $html .= FormSelectGenerator :: generateFromArray($tab, 'TrivialLangstring', $name, null, false); |
| 489 | | $html .= "</div>"; |
| 490 | | } else |
| 491 | | if (count($tab) == 1) { |
| 492 | | $html .= '<input type="hidden" name="' . $name . '" value="' . $tab[0][0] . '">'; |
| 493 | | } else { |
| 494 | | throw new Exception(_("No content type matches the filter.")); |
| 495 | | } |
| 496 | | |
| 497 | | $name = "get_new_content_{$user_prefix}_add"; |
| 498 | | |
| 499 | | if (count($tab) == 1) { |
| 500 | | $value = sprintf(_("Add a %s"), $tab[0][1]); |
| 501 | | } else { |
| 502 | | $value = _("Add"); |
| 503 | | } |
| 504 | | |
| 505 | | $html .= "<div class='admin_element_tools'>"; |
| 506 | | $html .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">'; |
| 507 | | $html .= "</div>"; |
| 508 | | $html .= "</fieldset>\n"; |
| 509 | | return $html; |
| | 589 | //echo "Content::getNewContentUI()"; |
| | 590 | // Init values |
| | 591 | $html = ""; |
| | 592 | $getNewUIData = null; |
| | 593 | $html .= "<fieldset class='admin_container Content'>\n"; |
| | 594 | if (!empty ($title)) { |
| | 595 | $html .= "<legend>$title</legend>\n"; |
| | 596 | } |
| | 597 | $futureContentId = get_guid(); |
| | 598 | $name = "get_new_content_{$user_prefix}_future_id"; |
| | 599 | $html .= '<input type="hidden" name="' . $name . '" value="' . $futureContentId . '">'; |
| | 600 | $userData['contentTypeFilter']=$content_type_filter; |
| | 601 | |
| | 602 | $html .= Content::getNewUI($futureContentId, $userData); |
| | 603 | $html .= "</fieldset>\n"; |
| | 604 | return $html; |
| 523 | | |
| 524 | | */ |
| 525 | | public static function processNewContentUI($user_prefix, $associate_existing_content = false) { |
| 526 | | // Init values |
| 527 | | $object = null; |
| 528 | | |
| 529 | | if ($associate_existing_content == true) { |
| 530 | | $name = "{$user_prefix}_add"; |
| 531 | | } else { |
| 532 | | $name = "get_new_content_{$user_prefix}_add"; |
| 533 | | } |
| 534 | | |
| 535 | | if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { |
| 536 | | if ($associate_existing_content == true) { |
| 537 | | $name = "{$user_prefix}"; |
| 538 | | } else { |
| 539 | | $name = "get_new_content_{$user_prefix}_content_type"; |
| 540 | | } |
| 541 | | |
| 542 | | /* |
| 543 | | * The result can be either a content type or a content ID |
| 544 | | * depending on the form (associate_existing_content or NOT) |
| 545 | | */ |
| 546 | | $contentUiResult = FormSelectGenerator :: getResult($name, null); |
| 547 | | |
| 548 | | if ($associate_existing_content == true) { |
| 549 | | $object = self :: getObject($contentUiResult); |
| 550 | | } else { |
| 551 | | $object = self :: createNewObject($contentUiResult); |
| 552 | | } |
| 553 | | } |
| 554 | | |
| 555 | | return $object; |
| | 618 | |
| | 619 | */ |
| | 620 | public static function processNewContentUI($user_prefix) { |
| | 621 | //echo "Content::processNewContentUI()"; |
| | 622 | // Init values |
| | 623 | $object = null; |
| | 624 | $name = "get_new_content_{$user_prefix}_future_id"; |
| | 625 | $futureContentId = $_REQUEST[$name]; |
| | 626 | |
| | 627 | if(Content::processNewUI($futureContentId, true)) { |
| | 628 | self :: createNewObject('Content', $futureContentId);//The true content type will be set by processNewUI() |
| | 629 | //If there was data to processs, process it for real |
| | 630 | Content::processNewUI($futureContentId, false); |
| | 631 | $object = self :: getObject($futureContentId);//Content type has changed... |
| | 632 | } |
| | 633 | //pretty_print_r($object); |
| | 634 | return $object; |
| | 635 | } |
| | 636 | /** |
| | 637 | * Get the created content object, IF one was created OR get existing |
| | 638 | * content (depending on what the user clicked) |
| | 639 | * |
| | 640 | * @param string $user_prefix A identifier provided by the |
| | 641 | * programmer to recognise it's |
| | 642 | * generated form |
| | 643 | * @return object The Content object, or null if the user didn't create one |
| | 644 | |
| | 645 | */ |
| | 646 | public static function processSelectExistingContentUI($user_prefix) { |
| | 647 | // Init values |
| | 648 | $object = null; |
| | 649 | $name = "{$user_prefix}"; |
| | 650 | /* |
| | 651 | * The result is a content ID |
| | 652 | */ |
| | 653 | $contentUiResult = FormSelectGenerator :: getResult($name, null); |
| | 654 | $name = "{$user_prefix}_add"; |
| | 655 | |
| | 656 | //Was add button clicked, or whare there data in the new admin UI |
| | 657 | if ((!empty($_REQUEST[$name]) && $_REQUEST[$name] == true)) { |
| | 658 | $object = self :: getObject($contentUiResult); |
| | 659 | } |
| | 660 | return $object; |
| 575 | | $db = AbstractDb :: getObject(); |
| 576 | | |
| 577 | | // Init values |
| 578 | | $html = ""; |
| 579 | | |
| 580 | | $link_table = $db->escapeString($link_table); |
| 581 | | $link_table_obj_key_col = $db->escapeString($link_table_obj_key_col); |
| 582 | | $link_table_obj_key = $db->escapeString($link_table_obj_key); |
| 583 | | |
| 584 | | /* Content already linked */ |
| 585 | | $current_content_sql = "SELECT * FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key' ORDER BY display_page, display_area, display_order, subscribe_timestamp DESC"; |
| 586 | | $rows = null; |
| 587 | | $db->execSql($current_content_sql, $rows, false); |
| 588 | | |
| 589 | | $html .= "<table class='content_management_tools'>\n"; |
| 590 | | $html .= "<th>" . _('Display page') . '</th><th>' . _('Area') . '</th><th>' . _('Order') . '</th><th>' . _('Content') . '</th><th>' . _('Actions') . '</th>' . "\n"; |
| 591 | | if ($rows) |
| 592 | | foreach ($rows as $row) { |
| 593 | | $content = self :: getObject($row['content_id']); |
| 594 | | $html .= "<tr class='already_linked_content'>\n"; |
| 595 | | /* Display page */ |
| 596 | | $name = "{$user_prefix}_" . $content->GetId() . "_display_page"; |
| 597 | | $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $row['display_page'], $name, null) . "</td>\n"; |
| 598 | | $name = "{$user_prefix}_" . $content->GetId() . "_display_area"; |
| 599 | | $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $row['display_area'], $name, null) . "</td>\n"; |
| 600 | | $name = "{$user_prefix}_" . $content->GetId() . "_display_order"; |
| 601 | | $html .= "<td><input type='text' name='$name' value='{$row['display_order']}' size=2 class='linked_content_order'></td>\n"; |
| 602 | | $html .= "<td>\n"; |
| 603 | | $html .= $content->getListUI(); |
| 604 | | $html .= "</td>\n"; |
| 605 | | $html .= "<td>\n"; |
| 606 | | $name = "{$user_prefix}_" . $content->GetId() . "_edit"; |
| 607 | | $html .= "<input type='button' class='submit' name='$name' value='" . _("Edit") . "' onClick='window.open(\"" . GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_class=Content&action=edit&object_id=" . $content->GetId() . "\");'>\n"; |
| 608 | | $name = "{$user_prefix}_" . $content->GetId() . "_erase"; |
| 609 | | $html .= "<input type='submit' class='submit' name='$name' value='" . _("Remove") . "'>"; |
| 610 | | $html .= "</td>\n"; |
| 611 | | $html .= "</tr>\n"; |
| 612 | | } |
| 613 | | |
| 614 | | /* Add existing content */ |
| 615 | | $html .= "<tr class='add_existing_content'>\n"; |
| 616 | | $name = "{$user_prefix}_new_existing_display_page"; |
| 617 | | $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $default_display_page, $name, null) . "</td>\n"; |
| 618 | | $name = "{$user_prefix}_new_existing_display_area"; |
| 619 | | $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $default_display_area, $name, null) . "</td>\n"; |
| 620 | | $name = "{$user_prefix}_new_existing_display_order"; |
| 621 | | $html .= "<td><input type='text' name='$name' value='1' size=2 class='linked_content_order'></td>\n"; |
| 622 | | $html .= "<td colspan=2>\n"; |
| 623 | | $name = "{$user_prefix}_new_existing"; |
| 624 | | $contentSelector = Content :: getSelectExistingContentUI($name, "AND is_persistent=TRUE AND content_id NOT IN (SELECT content_id FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key')"); |
| 625 | | $html .= $contentSelector; |
| 626 | | $html .= "</td>\n"; |
| 627 | | $html .= "</tr>\n"; |
| 628 | | |
| 629 | | /* Add new content */ |
| 630 | | $html .= "<tr class='add_new_content'>\n"; |
| 631 | | $name = "{$user_prefix}_new_display_page"; |
| 632 | | $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $default_display_page, $name, null) . "</td>\n"; |
| 633 | | $name = "{$user_prefix}_new_display_area"; |
| 634 | | $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $default_display_area, $name, null) . "</td>\n"; |
| 635 | | $name = "{$user_prefix}_new_display_order"; |
| 636 | | $html .= "<td><input type='text' name='$name' value='1' size=2 class='linked_content_order'></td>\n"; |
| 637 | | $html .= "<td colspan=2>\n"; |
| 638 | | $name = "{$user_prefix}_new"; |
| 639 | | $html .= self :: getNewContentUI($name, $content_type = null); |
| 640 | | $html .= "</td>\n"; |
| 641 | | $html .= "</table>\n"; |
| 642 | | return $html; |
| | 680 | $db = AbstractDb :: getObject(); |
| | 681 | |
| | 682 | // Init values |
| | 683 | $html = ""; |
| | 684 | |
| | 685 | $link_table = $db->escapeString($link_table); |
| | 686 | $link_table_obj_key_col = $db->escapeString($link_table_obj_key_col); |
| | 687 | $link_table_obj_key = $db->escapeString($link_table_obj_key); |
| | 688 | |
| | 689 | /* Content already linked */ |
| | 690 | $current_content_sql = "SELECT * FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key' ORDER BY display_page, display_area, display_order, subscribe_timestamp DESC"; |
| | 691 | $rows = null; |
| | 692 | $db->execSql($current_content_sql, $rows, false); |
| | 693 | |
| | 694 | $html .= "<table class='content_management_tools'>\n"; |
| | 695 | $html .= "<th>" . _('Display page') . '</th><th>' . _('Area') . '</th><th>' . _('Order') . '</th><th>' . _('Content') . '</th><th>' . _('Actions') . '</th>' . "\n"; |
| | 696 | if ($rows) |
| | 697 | foreach ($rows as $row) { |
| | 698 | $content = self :: getObject($row['content_id']); |
| | 699 | $html .= "<tr class='already_linked_content'>\n"; |
| | 700 | /* Display page */ |
| | 701 | $name = "{$user_prefix}_" . $content->GetId() . "_display_page"; |
| | 702 | $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $row['display_page'], $name, null) . "</td>\n"; |
| | 703 | $name = "{$user_prefix}_" . $content->GetId() . "_display_area"; |
| | 704 | $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $row['display_area'], $name, null) . "</td>\n"; |
| | 705 | $name = "{$user_prefix}_" . $content->GetId() . "_display_order"; |
| | 706 | $html .= "<td><input type='text' name='$name' value='{$row['display_order']}' size=2 class='linked_content_order'></td>\n"; |
| | 707 | $html .= "<td>\n"; |
| | 708 | $html .= $content->getListUI(); |
| | 709 | $html .= "</td>\n"; |
| | 710 | $html .= "<td>\n"; |
| | 711 | $name = "{$user_prefix}_" . $content->GetId() . "_edit"; |
| | 712 | $html .= "<input type='button' class='submit' name='$name' value='" . _("Edit") . "' onClick='window.open(\"" . GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_class=Content&action=edit&object_id=" . $content->GetId() . "\");'>\n"; |
| | 713 | $name = "{$user_prefix}_" . $content->GetId() . "_erase"; |
| | 714 | $html .= "<input type='submit' class='submit' name='$name' value='" . _("Remove") . "'>"; |
| | 715 | $html .= "</td>\n"; |
| | 716 | $html .= "</tr>\n"; |
| | 717 | } |
| | 718 | |
| | 719 | /* Add existing content */ |
| | 720 | $html .= "<tr class='add_existing_content'>\n"; |
| | 721 | $name = "{$user_prefix}_new_existing_display_page"; |
| | 722 | $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $default_display_page, $name, null) . "</td>\n"; |
| | 723 | $name = "{$user_prefix}_new_existing_display_area"; |
| | 724 | $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $default_display_area, $name, null) . "</td>\n"; |
| | 725 | $name = "{$user_prefix}_new_existing_display_order"; |
| | 726 | $html .= "<td><input type='text' name='$name' value='1' size=2 class='linked_content_order'></td>\n"; |
| | 727 | $html .= "<td colspan=2>\n"; |
| | 728 | $name = "{$user_prefix}_new_existing"; |
| | 729 | $contentSelector = Content :: getSelectExistingContentUI($name, "AND is_persistent=TRUE AND content_id NOT IN (SELECT content_id FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key')"); |
| | 730 | $html .= $contentSelector; |
| | 731 | $html .= "</td>\n"; |
| | 732 | $html .= "</tr>\n"; |
| | 733 | |
| | 734 | /* Add new content */ |
| | 735 | $html .= "<tr class='add_new_content'>\n"; |
| | 736 | $name = "{$user_prefix}_new_display_page"; |
| | 737 | $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $default_display_page, $name, null) . "</td>\n"; |
| | 738 | $name = "{$user_prefix}_new_display_area"; |
| | 739 | $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $default_display_area, $name, null) . "</td>\n"; |
| | 740 | $name = "{$user_prefix}_new_display_order"; |
| | 741 | $html .= "<td><input type='text' name='$name' value='1' size=2 class='linked_content_order'></td>\n"; |
| | 742 | $html .= "<td colspan=2>\n"; |
| | 743 | $name = "{$user_prefix}_new"; |
| | 744 | $html .= self :: getNewContentUI($name, $content_type = null); |
| | 745 | $html .= "</td>\n"; |
| | 746 | $html .= "</table>\n"; |
| | 747 | return $html; |
| 653 | | $db = AbstractDb :: getObject(); |
| 654 | | $link_table = $db->escapeString($link_table); |
| 655 | | $link_table_obj_key_col = $db->escapeString($link_table_obj_key_col); |
| 656 | | $link_table_obj_key = $db->escapeString($link_table_obj_key); |
| 657 | | /* Content already linked */ |
| 658 | | $current_content_sql = "SELECT * FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key'"; |
| 659 | | $rows = null; |
| 660 | | $db->execSql($current_content_sql, $rows, false); |
| 661 | | if ($rows) |
| 662 | | foreach ($rows as $row) { |
| 663 | | $content = Content :: getObject($row['content_id']); |
| 664 | | $content_id = $db->escapeString($content->getId()); |
| 665 | | $sql = null; |
| 666 | | $name = "{$user_prefix}_" . $content->GetId() . "_erase"; |
| 667 | | if (!empty ($_REQUEST[$name])) { |
| 668 | | $sql .= "DELETE FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key' AND content_id = '$content_id';\n"; |
| 669 | | |
| 670 | | } else { |
| 671 | | /* Display page */ |
| 672 | | $name = "{$user_prefix}_" . $content->GetId() . "_display_page"; |
| 673 | | $new_display_page = FormSelectGenerator :: getResult($name, null); |
| 674 | | if ($new_display_page != $row['display_page']) { |
| 675 | | $new_display_page = $db->escapeString($new_display_page); |
| 676 | | $sql .= "UPDATE $link_table SET display_page='$new_display_page' WHERE $link_table_obj_key_col='$link_table_obj_key' AND content_id = '$content_id';\n"; |
| 677 | | |
| 678 | | } |
| 679 | | /* Display area */ |
| 680 | | $name = "{$user_prefix}_" . $content->GetId() . "_display_area"; |
| 681 | | $new_display_area = FormSelectGenerator :: getResult($name, null); |
| 682 | | if ($new_display_area != $row['display_area']) { |
| 683 | | $new_display_area = $db->escapeString($new_display_area); |
| 684 | | $sql .= "UPDATE $link_table SET display_area='$new_display_area' WHERE $link_table_obj_key_col='$link_table_obj_key' AND content_id = '$content_id';\n"; |
| 685 | | } |
| 686 | | /* Display order */ |
| 687 | | $name = "{$user_prefix}_" . $content->GetId() . "_display_order"; |
| 688 | | if ($_REQUEST[$name] != $row['display_order']) { |
| 689 | | $new_display_order = $db->escapeString($_REQUEST[$name]); |
| 690 | | $sql .= "UPDATE $link_table SET display_order='$new_display_order' WHERE $link_table_obj_key_col='$link_table_obj_key' AND content_id = '$content_id';\n"; |
| 691 | | } |
| 692 | | } |
| 693 | | if ($sql) { |
| 694 | | $db->execSqlUpdate($sql, false); |
| 695 | | } |
| 696 | | } |
| 697 | | /* Add existing content */ |
| 698 | | $name = "{$user_prefix}_new_existing_add"; |
| 699 | | if (!empty ($_REQUEST[$name])) { |
| 700 | | $name = "{$user_prefix}_new_existing"; |
| 701 | | $content = Content :: processSelectContentUI($name); |
| 702 | | if ($content) { |
| 703 | | /* Display page */ |
| 704 | | $name = "{$user_prefix}_new_existing_display_page"; |
| 705 | | $new_display_page = $db->escapeString(FormSelectGenerator :: getResult($name, null)); |
| 706 | | /* Display area */ |
| 707 | | $name = "{$user_prefix}_new_existing_display_area"; |
| 708 | | $new_display_area = $db->escapeString(FormSelectGenerator :: getResult($name, null)); |
| 709 | | /* Display order */ |
| 710 | | $name = "{$user_prefix}_new_existing_display_order"; |
| 711 | | $new_display_order = $db->escapeString($_REQUEST[$name]); |
| 712 | | $content_id = $db->escapeString($content->getId()); |
| 713 | | $sql = "INSERT INTO $link_table (content_id, $link_table_obj_key_col, display_page, display_area, display_order) VALUES ('$content_id', '$link_table_obj_key', '$new_display_page', '$new_display_area', $new_display_order);\n"; |
| 714 | | $db->execSqlUpdate($sql, false); |
| 715 | | } |
| 716 | | } |
| 717 | | /* Add new content */ |
| 718 | | $name = "{$user_prefix}_new"; |
| 719 | | $content = self :: processNewContentUI($name); |
| 720 | | if ($content) { |
| 721 | | /* Display page */ |
| 722 | | $name = "{$user_prefix}_new_display_page"; |
| 723 | | $new_display_page = $db->escapeString(FormSelectGenerator :: getResult($name, null)); |
| 724 | | /* Display area */ |
| 725 | | $name = "{$user_prefix}_new_display_area"; |
| 726 | | $new_display_area = $db->escapeString(FormSelectGenerator :: getResult($name, null)); |
| 727 | | /* Display order */ |
| 728 | | $name = "{$user_prefix}_new_display_order"; |
| 729 | | $new_display_order = $db->escapeString($_REQUEST[$name]); |
| 730 | | $content_id = $db->escapeString($content->getId()); |
| 731 | | $sql = "INSERT INTO $link_table (content_id, $link_table_obj_key_col, display_page, display_area, display_order) VALUES ('$content_id', '$link_table_obj_key', '$new_display_page', '$new_display_area', $new_display_order);\n"; |
| 732 | | $db->execSqlUpdate($sql, false); |
| 733 | | } |
| | 758 | $db = AbstractDb :: getObject(); |
| | 759 | $link_table = $db->escapeString($link_table); |
| | 760 | $link_table_obj_key_col = $db->escapeString($link_table_obj_key_col); |
| | 761 | $link_table_obj_key = $db->escapeString($link_table_obj_key); |
| | 762 | /* Content already linked */ |
| | 763 | $current_content_sql = "SELECT * FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key'"; |
| | 764 | $rows = null; |
| | 765 | $db->execSql($current_content_sql, $rows, false); |
| | 766 | if ($rows) |
| | 767 | foreach ($rows as $row) { |
| | 768 | $content = Content :: getObject($row['content_id']); |
| | 769 | $content_id = $db->escapeString($content->getId()); |
| | 770 | $sql = null; |
| | 771 | $name = "{$user_prefix}_" . $content->GetId() . "_erase"; |
| | 772 | if (!empty ($_REQUEST[$name])) { |
| | 773 | $sql .= "DELETE FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key' AND content_id = '$content_id';\n"; |
| | 774 | |
| | 775 | } else { |
| | 776 | /* Display page */ |
| | 777 | $name = "{$user_prefix}_" . $content->GetId() . "_display_page"; |
| | 778 | $new_display_page = FormSelectGenerator :: getResult($name, null); |
| | 779 | if ($new_display_page != $row['display_page']) { |
| | 780 | $new_display_page = $db->escapeString($new_display_page); |
| | 781 | $sql .= "UPDATE $link_table SET display_page='$new_display_page' WHERE $link_table_obj_key_col='$link_table_obj_key' AND content_id = '$content_id';\n"; |
| | 782 | |
| | 783 | } |
| | 784 | /* Display area */ |
| | 785 | $name = "{$user_prefix}_" . $content->GetId() . "_display_area"; |
| | 786 | $new_display_area = FormSelectGenerator :: getResult($name, null); |
| | 787 | if ($new_display_area != $row['display_area']) { |
| | 788 | $new_display_area = $db->escapeString($new_display_area); |
| | 789 | $sql .= "UPDATE $link_table SET display_area='$new_display_area' WHERE $link_table_obj_key_col='$link_table_obj_key' AND content_id = '$content_id';\n"; |
| | 790 | } |
| | 791 | /* Display order */ |
| | 792 | $name = "{$user_prefix}_" . $content->GetId() . "_display_order"; |
| | 793 | if ($_REQUEST[$name] != $row['display_order']) { |
| | 794 | $new_display_order = $db->escapeString($_REQUEST[$name]); |
| | 795 | $sql .= "UPDATE $link_table SET display_order='$new_display_order' WHERE $link_table_obj_key_col='$link_table_obj_key' AND content_id = '$content_id';\n"; |
| | 796 | } |
| | 797 | } |
| | 798 | if ($sql) { |
| | 799 | $db->execSqlUpdate($sql, false); |
| | 800 | } |
| | 801 | } |
| | 802 | /* Add existing content */ |
| | 803 | $name = "{$user_prefix}_new_existing_add"; |
| | 804 | if (!empty ($_REQUEST[$name])) { |
| | 805 | $name = "{$user_prefix}_new_existing"; |
| | 806 | $content = Content :: processSelectContentUI($name); |
| | 807 | if ($content) { |
| | 808 | /* Display page */ |
| | 809 | $name = "{$user_prefix}_new_existing_display_page"; |
| | 810 | $new_display_page = $db->escapeString(FormSelectGenerator :: getResult($name, null)); |
| | 811 | /* Display area */ |
| | 812 | $name = "{$user_prefix}_new_existing_display_area"; |
| | 813 | $new_display_area = $db->escapeString(FormSelectGenerator :: getResult($name, null)); |
| | 814 | /* Display order */ |
| | 815 | $name = "{$user_prefix}_new_existing_display_order"; |
| | 816 | $new_display_order = $db->escapeString($_REQUEST[$name]); |
| | 817 | $content_id = $db->escapeString($content->getId()); |
| | 818 | $sql = "INSERT INTO $link_table (content_id, $link_table_obj_key_col, display_page, display_area, display_order) VALUES ('$content_id', '$link_table_obj_key', '$new_display_page', '$new_display_area', $new_display_order);\n"; |
| | 819 | $db->execSqlUpdate($sql, false); |
| | 820 | } |
| | 821 | } |
| | 822 | /* Add new content */ |
| | 823 | $name = "{$user_prefix}_new"; |
| | 824 | $content = self :: processNewContentUI($name); |
| | 825 | if ($content) { |
| | 826 | /* Display page */ |
| | 827 | $name = "{$user_prefix}_new_display_page"; |
| | 828 | $new_display_page = $db->escapeString(FormSelectGenerator :: getResult($name, null)); |
| | 829 | /* Display area */ |
| | 830 | $name = "{$user_prefix}_new_display_area"; |
| | 831 | $new_display_area = $db->escapeString(FormSelectGenerator :: getResult($name, null)); |
| | 832 | /* Display order */ |
| | 833 | $name = "{$user_prefix}_new_display_order"; |
| | 834 | $new_display_order = $db->escapeString($_REQUEST[$name]); |
| | 835 | $content_id = $db->escapeString($content->getId()); |
| | 836 | $sql = "INSERT INTO $link_table (content_id, $link_table_obj_key_col, display_page, display_area, display_order) VALUES ('$content_id', '$link_table_obj_key', '$new_display_page', '$new_display_area', $new_display_order);\n"; |
| | 837 | $db->execSqlUpdate($sql, false); |
| | 838 | } |
| 760 | | $db = AbstractDb :: getObject(); |
| 761 | | |
| 762 | | // Init values |
| 763 | | $html = ''; |
| 764 | | $retVal = array (); |
| 765 | | $contentRows = null; |
| 766 | | if ($content_type_filter == null) { |
| 767 | | //Get an empty filter |
| 768 | | $content_type_filter = ContentTypeFilter :: getObject(array ()); |
| 769 | | } |
| 770 | | |
| 771 | | if (!User :: getCurrentUser()) { |
| 772 | | throw new Exception(_('Access denied!')); |
| 773 | | } |
| 774 | | |
| 775 | | if ($type_interface != "table") { |
| 776 | | $html .= "<fieldset class='admin_container Content'>\n"; |
| 777 | | |
| 778 | | if (!empty ($title)) { |
| 779 | | $html .= "<legend>$title</legend>\n"; |
| 780 | | } |
| 781 | | |
| 782 | | $html .= _("Select from reusable content library") . ": "; |
| 783 | | } |
| 784 | | |
| 785 | | $name = "{$user_prefix}"; |
| 786 | | |
| 787 | | $sql = "SELECT * FROM content WHERE 1=1 $sql_additional_where ORDER BY $order"; |
| 788 | | |
| 789 | | $db->execSql($sql, $contentRows, false); |
| 790 | | |
| 791 | | if ($contentRows != null) { |
| 792 | | $i = 0; |
| 793 | | |
| 794 | | if ($type_interface == "table") { |
| 795 | | $html .= "<table class='content_admin'>\n"; |
| 796 | | $html .= "<tr><th>" . _("Title") . "</th><th>" . _("Content type") . "</th><th>" . _("Description") . "</th><th></th></tr>\n"; |
| 797 | | } |
| 798 | | |
| 799 | | foreach ($contentRows as $contentRow) { |
| 800 | | $content = Content :: getObject($contentRow['content_id']); |
| 801 | | //echo get_class($content)." ".$contentRow['content_id']."<br>"; |
| 802 | | if ($content && $content_type_filter->isAcceptableContentClass(get_class($content))) { |
| 803 | | if ($type_interface != "table") { |
| 804 | | $tab[$i][0] = $content->getId(); |
| 805 | | $tab[$i][1] = $content->__toString() . " (" . get_class($content) . ")"; |
| 806 | | $i++; |
| 807 | | } else { |
| 808 | | if (!empty ($contentRow['title'])) { |
| 809 | | $title = Content :: getObject($contentRow['title']); |
| 810 | | $titleUI = $title->__toString(); |
| 811 | | } else { |
| 812 | | $titleUI = ""; |
| 813 | | } |
| 814 | | |
| 815 | | if (!empty ($contentRow['description'])) { |
| 816 | | $description = Content :: getObject($contentRow['description']); |
| 817 | | $descriptionUI = $description->__toString(); |
| 818 | | } else { |
| 819 | | $descriptionUI = ""; |
| 820 | | } |
| 821 | | |
| 822 | | $href = GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_id={$contentRow['content_id']}&object_class=Content&action=edit"; |
| 823 | | $html .= "<tr><td>$titleUI</td><td><a href='$href'>{$contentRow['content_type']}</a></td><td>$descriptionUI</td>\n"; |
| 824 | | |
| 825 | | $href = GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_id={$contentRow['content_id']}&object_class=Content&action=delete"; |
| 826 | | $html .= "<td><a href='$href'>" . _("Delete") . "</a></td>"; |
| 827 | | |
| 828 | | $html .= "</tr>\n"; |
| 829 | | } |
| 830 | | } |
| 831 | | } |
| 832 | | |
| 833 | | if ($type_interface != "table") { |
| 834 | | if (isset ($tab)) { |
| 835 | | $html .= FormSelectGenerator :: generateFromArray($tab, null, $name, null, false, null, null, 40); |
| 836 | | //DEBUG!! get_existing_content_ |
| 837 | | $name = "{$user_prefix}_add"; |
| 838 | | $value = _("Add"); |
| 839 | | $html .= "<div class='admin_element_tools'>"; |
| 840 | | $html .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">'; |
| 841 | | $html .= "</div>"; |
| 842 | | } else { |
| 843 | | $html .= "<div class='warningmsg'>" . _("Sorry, no elligible content available in the database") . "</div>\n"; |
| 844 | | } |
| 845 | | $html .= "</fieldset>\n"; |
| 846 | | } else { |
| 847 | | $html .= "</table>\n"; |
| 848 | | } |
| 849 | | } else { |
| 850 | | $html .= "<div class='warningmsg'>" . _("Sorry, no elligible content available in the database") . "</div>\n"; |
| 851 | | } |
| 852 | | |
| 853 | | return $html; |
| | 865 | $db = AbstractDb :: getObject(); |
| | 866 | |
| | 867 | // Init values |
| | 868 | $html = ''; |
| | 869 | $retVal = array (); |
| | 870 | $contentRows = null; |
| | 871 | if ($content_type_filter == null) { |
| | 872 | //Get an empty filter |
| | 873 | $content_type_filter = ContentTypeFilter :: getObject(array ()); |
| | 874 | } |
| | 875 | |
| | 876 | if (!User :: getCurrentUser()) { |
| | 877 | throw new Exception(_('Access denied!')); |
| | 878 | } |
| | 879 | |
| | 880 | if ($type_interface != "table") { |
| | 881 | $html .= "<fieldset class='admin_container Content'>\n"; |
| | 882 | |
| | 883 | if (!empty ($title)) { |
| | 884 | $html .= "<legend>$title</legend>\n"; |
| | 885 | } |
| | 886 | |
| | 887 | $html .= _("Select from reusable content library") . ": "; |
| | 888 | } |
| | 889 | |
| | 890 | $name = "{$user_prefix}"; |
| | 891 | |
| | 892 | $sql = "SELECT * FROM content WHERE 1=1 $sql_additional_where ORDER BY $order"; |
| | 893 | |
| | 894 | $db->execSql($sql, $contentRows, false); |
| | 895 | |
| | 896 | if ($contentRows != null) { |
| | 897 | $i = 0; |
| | 898 | |
| | 899 | if ($type_interface == "table") { |
| | 900 | $html .= "<table class='content_admin'>\n"; |
| | 901 | $html .= "<tr><th>" . _("Title") . "</th><th>" . _("Content type") . "</th><th>" . _("Description") . "</th><th></th></tr>\n"; |
| | 902 | } |
| | 903 | |
| | 904 | foreach ($contentRows as $contentRow) { |
| | 905 | $content = Content :: getObject($contentRow['content_id']); |
| | 906 | //echo get_class($content)." ".$contentRow['content_id']."<br>"; |
| | 907 | if ($content && $content_type_filter->isAcceptableContentClass(get_class($content))) { |
| | 908 | if ($type_interface != "table") { |
| | 909 | $tab[$i][0] = $content->getId(); |
| | 910 | $tab[$i][1] = $content->__toString() . " (" . get_class($content) . ")"; |
| | 911 | $i++; |
| | 912 | } else { |
| | 913 | if (!empty ($contentRow['title'])) { |
| | 914 | $title = Content :: getObject($contentRow['title']); |
| | 915 | $titleUI = $title->__toString(); |
| | 916 | } else { |
| | 917 | $titleUI = ""; |
| | 918 | } |
| | 919 | |
| | 920 | if (!empty ($contentRow['description'])) { |
| | 921 | $description = Content :: getObject($contentRow['description']); |
| | 922 | $descriptionUI = $description->__toString(); |
| | 923 | } else { |
| | 924 | $descriptionUI = ""; |
| | 925 | } |
| | 926 | |
| | 927 | $href = GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_id={$contentRow['content_id']}&object_class=Content&action=edit"; |
| | 928 | $html .= "<tr><td>$titleUI</td><td><a href='$href'>{$contentRow['content_type']}</a></td><td>$descriptionUI</td>\n"; |
| | 929 | |
| | 930 | $href = GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_id={$contentRow['content_id']}&object_class=Content&action=delete"; |
| | 931 | $html .= "<td><a href='$href'>" . _("Delete") . "</a></td>"; |
| | 932 | |
| | 933 | $html .= "</tr>\n"; |
| | 934 | } |
| | 935 | } |
| | 936 | } |
| | 937 | |
| | 938 | if ($type_interface != "table") { |
| | 939 | if (isset ($tab)) { |
| | 940 | $html .= FormSelectGenerator :: generateFromArray($tab, null, $name, null, false, null, null, 40); |
| | 941 | //DEBUG!! get_existing_content_ |
| | 942 | $name = "{$user_prefix}_add"; |
| | 943 | $value = _("Add"); |
| | 944 | $html .= "<div class='admin_element_tools'>"; |
| | 945 | $html .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">'; |
| | 946 | $html .= "</div>"; |
| | 947 | } else { |
| | 948 | $html .= "<div class='warningmsg'>" . _("Sorry, no elligible content available in the database") . "</div>\n"; |
| | 949 | } |
| | 950 | $html .= "</fieldset>\n"; |
| | 951 | } else { |
| | 952 | $html .= "</table>\n"; |
| | 953 | } |
| | 954 | } else { |
| | 955 | $html .= "<div class='warningmsg'>" . _("Sorry, no elligible content available in the database") . "</div>\n"; |
| | 956 | } |
| | 957 | |
| | 958 | return $html; |
| 913 | | $retval = true; |
| 914 | | $db = AbstractDb :: getObject(); |
| 915 | | $value_sql = $db->escapeString($value); |
| 916 | | $key_sql = $db->escapeString($key); |
| 917 | | //pretty_print_r($this->kvps); |
| 918 | | if($key==null) { |
| 919 | | throw new Exception (_("KVP key cannot be null")); |
| 920 | | } else if($value===null) { |
| 921 | | //Delete the KVP |
| 922 | | $retval = $db->execSqlUpdate("DELETE FROM content_key_value_pairs WHERE content_id='" . $this->getId() . "' AND key='$key_sql'", false); |
| 923 | | if(isset ($this->kvps[$key])) { |
| 924 | | unset ($this->kvps[$key]); |
| 925 | | } |
| 926 | | } else if (!isset ($this->kvps[$key])) { |
| 927 | | //This is a new key |
| 928 | | $retval = $db->execSqlUpdate("INSERT INTO content_key_value_pairs (content_id, key, value) VALUES ('" . $this->getId() . "', '$key_sql', '$value_sql')", false); |
| 929 | | } else |
| 930 | | if ($this->kvps[$key] != $value) { |
| 931 | | //This is an existing key, and it's been modified |
| 932 | | $retval = $db->execSqlUpdate("UPDATE content_key_value_pairs SET value ='" . $value_sql . "' WHERE content_id='" . $this->getId() . "' AND key='$key_sql'", false); |
| 933 | | } |
| 934 | | $this->refresh(); |
| 935 | | return $retval; |
| | 1018 | $retval = true; |
| | 1019 | $db = AbstractDb :: getObject(); |
| | 1020 | $value_sql = $db->escapeString($value); |
| | 1021 | $key_sql = $db->escapeString($key); |
| | 1022 | //pretty_print_r($this->kvps); |
| | 1023 | if($key==null) { |
| | 1024 | throw new Exception (_("KVP key cannot be null")); |
| | 1025 | } else if($value===null) { |
| | 1026 | //Delete the KVP |
| | 1027 | $retval = $db->execSqlUpdate("DELETE FROM content_key_value_pairs WHERE content_id='" . $this->getId() . "' AND key='$key_sql'", false); |
| | 1028 | if(isset ($this->kvps[$key])) { |
| | 1029 | unset ($this->kvps[$key]); |
| | 1030 | } |
| | 1031 | } else if (!isset ($this->kvps[$key])) { |
| | 1032 | //This is a new key |
| | 1033 | $retval = $db->execSqlUpdate("INSERT INTO content_key_value_pairs (content_id, key, value) VALUES ('" . $this->getId() . "', '$key_sql', '$value_sql')", false); |
| | 1034 | } else |
| | 1035 | if ($this->kvps[$key] != $value) { |
| | 1036 | //This is an existing key, and it's been modified |
| | 1037 | $retval = $db->execSqlUpdate("UPDATE content_key_value_pairs SET value ='" . $value_sql . "' WHERE content_id='" . $this->getId() . "' AND key='$key_sql'", false); |
| | 1038 | } |
| | 1039 | $this->refresh(); |
| | 1040 | return $retval; |
| 1185 | | $html = ''; |
| 1186 | | $hasDisplayableMetadata = $this->hasDisplayableMetadata(); |
| 1187 | | $hasDisplayableMetadata ? $hasDisplayableMetadataClass = 'hasDisplayableMetadata' : $hasDisplayableMetadataClass = null; |
| 1188 | | $html .= "<div class='user_ui_main_outer " . get_class($this) . " $hasDisplayableMetadataClass'>\n"; |
| 1189 | | $html .= "<div class='user_ui_main_inner'>\n"; |
| 1190 | | if (!empty ($this->content_row['title']) && $this->titleShouldDisplay()) { |
| 1191 | | $html .= "<div class='user_ui_title'>\n"; |
| 1192 | | $title = self :: getObject($this->content_row['title']); |
| 1193 | | $title->setLogAsContent($this); |
| 1194 | | // If the content logging is disabled, all the children will inherit this property temporarly |
| 1195 | | if ($this->getLoggingStatus() == false) |
| 1196 | | $title->setLoggingStatus(false); |
| 1197 | | $html .= $title->getUserUI(); |
| 1198 | | $html .= "</div>\n"; |
| 1199 | | } |
| 1200 | | if($this->user_ui_main_content) { |
| 1201 | | if (!$hasDisplayableMetadata) { |
| 1202 | | $html .= "\n<div class='user_ui_main_content'>$this->user_ui_main_content</div>\n"; |
| 1203 | | } else { |
| 1204 | | $html .= "<table><tr>\n"; |
| 1205 | | $html .= "<td class='user_ui_main_content'>\n$this->user_ui_main_content</td>\n"; |
| 1206 | | $html .= "<td>\n"; |
| 1207 | | } |
| 1208 | | } |
| 1209 | | $authors = $this->getAuthors(); |
| 1210 | | if (count($authors) > 0) { |
| 1211 | | $html .= "<div class='user_ui_authors'>\n"; |
| 1212 | | $html .= _("Author(s):"); |
| 1213 | | foreach ($authors as $user) { |
| 1214 | | $html .= $user->getListUI() . " "; |
| 1215 | | } |
| 1216 | | $html .= "</div>\n"; |
| 1217 | | } |
| 1218 | | |
| 1219 | | if (!empty ($this->content_row['description'])) { |
| 1220 | | $html .= "<div class='user_ui_description'>\n"; |
| 1221 | | $description = self :: getObject($this->content_row['description']); |
| 1222 | | $description->setLogAsContent($this); |
| 1223 | | // If the content logging is disabled, all the children will inherit this property temporarly |
| 1224 | | if ($this->getLoggingStatus() == false) |
| 1225 | | $description->setLoggingStatus(false); |
| 1226 | | $html .= $description->getUserUI(); |
| 1227 | | $html .= "</div>\n"; |
| 1228 | | } |
| 1229 | | |
| 1230 | | if (!empty ($this->content_row['project_info'])) { |
| 1231 | | if (!empty ($this->content_row['project_info'])) { |
| 1232 | | $html .= "<div class='user_ui_projet_info'>\n"; |
| 1233 | | $html .= "<b>" . _("Project information:") . "</b>"; |
| 1234 | | $project_info = self :: getObject($this->content_row['project_info']); |
| 1235 | | $project_info->setLogAsContent($this); |
| 1236 | | // If the content logging is disabled, all the children will inherit this property temporarly |
| 1237 | | if ($this->getLoggingStatus() == false) |
| 1238 | | $project_info->setLoggingStatus(false); |
| 1239 | | $html .= $project_info->getUserUI(); |
| 1240 | | $html .= "</div>\n"; |
| 1241 | | } |
| 1242 | | } |
| 1243 | | if ($hasDisplayableMetadata) { |
| 1244 | | $html .= "</td>\n"; |
| 1245 | | $html .= "</tr>\n"; |
| 1246 | | } |
| 1247 | | if($this->user_ui_interaction_area) { |
| 1248 | | if (!$hasDisplayableMetadata) { |
| 1249 | | $html .= "\n<div class='user_ui_interaction_area'>$this->user_ui_interaction_area</div>\n"; |
| 1250 | | } else { |
| 1251 | | $html .= "<tr>\n"; |
| 1252 | | $html .= "<td colspan=2 class='user_ui_interaction_area'>\n$this->user_ui_interaction_area</td>\n"; |
| 1253 | | $html .= "</tr>\n"; |
| 1254 | | } |
| 1255 | | } |
| 1256 | | |
| 1257 | | if ($hasDisplayableMetadata) { |
| 1258 | | $html .= "</table>\n"; |
| 1259 | | } |
| 1260 | | $html .= "</div>\n"; |
| 1261 | | $html .= "</div>\n"; |
| 1262 | | |
| 1263 | | |
| 1264 | | $this->logContentDisplay(); |
| 1265 | | return $html; |
| | 1290 | $html = ''; |
| | 1291 | $hasDisplayableMetadata = $this->hasDisplayableMetadata(); |
| | 1292 | $hasDisplayableMetadata ? $hasDisplayableMetadataClass = 'hasDisplayableMetadata' : $hasDisplayableMetadataClass = null; |
| | 1293 | $html .= "<div class='user_ui_main_outer " . get_class($this) . " $hasDisplayableMetadataClass'>\n"; |
| | 1294 | $html .= "<div class='user_ui_main_inner'>\n"; |
| | 1295 | if (!empty ($this->content_row['title']) && $this->titleShouldDisplay()) { |
| | 1296 | $html .= "<div class='user_ui_title'>\n"; |
| | 1297 | $title = self :: getObject($this->content_row['title']); |
| | 1298 | $title->setLogAsContent($this); |
| | 1299 | // If the content logging is disabled, all the children will inherit this property temporarly |
| | 1300 | if ($this->getLoggingStatus() == false) |
| | 1301 | $title->setLoggingStatus(false); |
| | 1302 | $html .= $title->getUserUI(); |
| | 1303 | $html .= "</div>\n"; |
| | 1304 | } |
| | 1305 | if($this->user_ui_main_content) { |
| | 1306 | if (!$hasDisplayableMetadata) { |
| | 1307 | $html .= "\n<div class='user_ui_main_content'>$this->user_ui_main_content</div>\n"; |
| | 1308 | } else { |
| | 1309 | $html .= "<table><tr>\n"; |
| | 1310 | $html .= "<td class='user_ui_main_content'>\n$this->user_ui_main_content</td>\n"; |
| | 1311 | $html .= "<td>\n"; |
| | 1312 | } |
| | 1313 | } |
| | 1314 | $authors = $this->getAuthors(); |
| | 1315 | if (count($authors) > 0) { |
| | 1316 | $html .= "<div class='user_ui_authors'>\n"; |
| | 1317 | $html .= _("Author(s):"); |
| | 1318 | foreach ($authors as $user) { |
| | 1319 | $html .= $user->getListUI() . " "; |
| | 1320 | } |
| | 1321 | $html .= "</div>\n"; |
| | 1322 | } |
| | 1323 | |
| | 1324 | if (!empty ($this->content_row['description'])) { |
| | 1325 | $html .= "<div class='user_ui_description'>\n"; |
| | 1326 | $description = self :: getObject($this->content_row['description']); |
| | 1327 | $description->setLogAsContent($this); |
| | 1328 | // If the content logging is disabled, all the children will inherit this property temporarly |
| | 1329 | if ($this->getLoggingStatus() == false) |
| | 1330 | $description->setLoggingStatus(false); |
| | 1331 | $html .= $description->getUserUI(); |
| | 1332 | $html .= "</div>\n"; |
| | 1333 | } |
| | 1334 | |
| | 1335 | if (!empty ($this->content_row['project_info'])) { |
| | 1336 | if (!empty ($this->content_row['project_info'])) { |
| | 1337 | $html .= "<div class='user_ui_projet_info'>\n"; |
| | 1338 | $html .= "<b>" . _("Project information:") . "</b>"; |
| | 1339 | $project_info = self :: getObject($this->content_row['project_info']); |
| | 1340 | $project_info->setLogAsContent($this); |
| | 1341 | // If the content logging is disabled, all the children will inherit this property temporarly |
| | 1342 | if ($this->getLoggingStatus() == false) |
| | 1343 | $project_info->setLoggingStatus(false); |
| | 1344 | $html .= $project_info->getUserUI(); |
| | 1345 | $html .= "</div>\n"; |
| | 1346 | } |
| | 1347 | } |
| | 1348 | if ($hasDisplayableMetadata) { |
| | 1349 | $html .= "</td>\n"; |
| | 1350 | $html .= "</tr>\n"; |
| | 1351 | } |
| | 1352 | if($this->user_ui_interaction_area) { |
| | 1353 | if (!$hasDisplayableMetadata) { |
| | 1354 | $html .= "\n<div class='user_ui_interaction_area'>$this->user_ui_interaction_area</div>\n"; |
| | 1355 | } else { |
| | 1356 | $html .= "<tr>\n"; |
| | 1357 | $html .= "<td colspan=2 class='user_ui_interaction_area'>\n$this->user_ui_interaction_area</td>\n"; |
| | 1358 | $html .= "</tr>\n"; |
| | 1359 | } |
| | 1360 | } |
| | 1361 | |
| | 1362 | if ($hasDisplayableMetadata) { |
| | 1363 | $html .= "</table>\n"; |
| | 1364 | } |
| | 1365 | $html .= "</div>\n"; |
| | 1366 | $html .= "</div>\n"; |
| | 1367 | |
| | 1368 | |
| | 1369 | $this->logContentDisplay(); |
| | 1370 | return $html; |
| 1298 | | if ($this->getLoggingStatus() == true && $this->log_as_content->getId() == $this->getId()) { |
| 1299 | | // DEBUG:: |
| 1300 | | //echo "Logging ".get_class($this)." :: ".$this->__toString()."<br>"; |
| 1301 | | $user = User :: getCurrentUser(); |
| 1302 | | $node = Node :: getCurrentNode(); |
| 1303 | | if ($user != null && $node != null) { |
| 1304 | | $user_id = $user->getId(); |
| 1305 | | $node_id = $node->getId(); |
| 1306 | | $db = AbstractDb :: getObject(); |
| 1307 | | |
| 1308 | | $sql = "SELECT * FROM content_display_log WHERE content_id='$this->id' AND user_id='$user_id' AND node_id='$node_id'"; |
| 1309 | | $db->execSql($sql, $log_rows, false); |
| 1310 | | if ($log_rows != null) { |
| 1311 | | $sql = "UPDATE content_display_log SET num_display = num_display +1, last_display_timestamp = CURRENT_TIMESTAMP WHERE content_id='$this->id' AND user_id='$user_id' AND node_id='$node_id'"; |
| 1312 | | } else { |
| 1313 | | $sql = "INSERT INTO content_display_log (user_id, content_id, node_id) VALUES ('$user_id', '$this->id', '$node_id')"; |
| 1314 | | } |
| 1315 | | $db->execSqlUpdate($sql, false); |
| 1316 | | } |
| 1317 | | } |
| | 1403 | if ($this->getLoggingStatus() == true && $this->log_as_content->getId() == $this->getId()) { |
| | 1404 | // DEBUG:: |
| | 1405 | //echo "Logging ".get_class($this)." :: ".$this->__toString()."<br>"; |
| | 1406 | $user = User :: getCurrentUser(); |
| | 1407 | $node = Node :: getCurrentNode(); |
| | 1408 | if ($user != null && $node != null) { |
| | 1409 | $user_id = $user->getId(); |
| | 1410 | $node_id = $node->getId(); |
| | 1411 | $db = AbstractDb :: getObject(); |
| | 1412 | |
| | 1413 | $sql = "SELECT * FROM content_display_log WHERE content_id='$this->id' AND user_id='$user_id' AND node_id='$node_id'"; |
| | 1414 | $db->execSql($sql, $log_rows, false); |
| | 1415 | if ($log_rows != null) { |
| | 1416 | $sql = "UPDATE content_display_log SET num_display = num_display +1, last_display_timestamp = CURRENT_TIMESTAMP WHERE content_id='$this->id' AND user_id='$user_id' AND node_id='$node_id'"; |
| | 1417 | } else { |
| | 1418 | $sql = "INSERT INTO content_display_log (user_id, content_id, node_id) VALUES ('$user_id', '$this->id', '$node_id')"; |
| | 1419 | } |
| | 1420 | $db->execSqlUpdate($sql, false); |
| | 1421 | } |
| | 1422 | } |
| 1349 | | $db = AbstractDb :: getObject(); |
| 1350 | | |
| 1351 | | $html = ''; |
| 1352 | | if (!(User :: getCurrentUser()->isSuperAdmin() || $this->isOwner(User :: getCurrentUser()))) { |
| 1353 | | $html .= $this->getListUI(); |
| 1354 | | $html .= ' ' . _("(You do not have access to edit this piece of content)"); |
| 1355 | | } else { |
| 1356 | | $html .= "<fieldset class='admin_container " . get_class($this) . "'>\n"; |
| 1357 | | if (!empty ($title)) { |
| 1358 | | $html .= "<legend>$title</legend>\n"; |
| 1359 | | } |
| 1360 | | $html .= "<ul class='admin_element_list'>\n"; |
| 1361 | | if ($this->getObjectType() == 'Content') { |
| 1362 | | // The object hasn't yet been typed. |
| 1363 | | $html .= _("You must select a content type: "); |
| 1364 | | $i = 0; |
| 1365 | | |
| 1366 | | foreach (self :: getAvailableContentTypes() as $classname) { |
| 1367 | | $tab[$i][0] = $classname; |
| 1368 | | $tab[$i][1] = $classname; |
| 1369 | | $i++; |
| 1370 | | } |
| 1371 | | |
| 1372 | | $html .= FormSelectGenerator :: generateFromArray($tab, null, "content_" . $this->id . "_content_type", "Content", false); |
| 1373 | | } else { |
| 1374 | | $criteria_array = array ( |
| 1375 | | array ( |
| 1376 | | 'isSimpleContent' |
| | 1454 | $db = AbstractDb :: getObject(); |
| | 1455 | |
| | 1456 | $html = ''; |
| | 1457 | if (!(User :: getCurrentUser()->isSuperAdmin() || $this->isOwner(User :: getCurrentUser()))) { |
| | 1458 | $html .= $this->getListUI(); |
| | 1459 | $html .= ' ' . _("(You do not have access to edit this piece of content)"); |
| | 1460 | } else { |
| | 1461 | $html .= "<fieldset class='admin_container " . get_class($this) . "'>\n"; |
| | 1462 | if (!empty ($title)) { |
| | 1463 | $html .= "<legend>$title</legend>\n"; |
| | 1464 | } |
| | 1465 | $html .= "<ul class='admin_element_list'>\n"; |
| | 1466 | if ($this->getObjectType() == 'Content') { |
| | 1467 | // The object hasn't yet been typed. |
| | 1468 | $html .= _("You must select a content type: "); |
| | 1469 | $i = 0; |
| | 1470 | |
| | 1471 | foreach (self :: getAvailableContentTypes() as $classname) { |
| | 1472 | $tab[$i][0] = $classname; |
| | 1473 | $tab[$i][1] = $classname; |
| | 1474 | $i++; |
| | 1475 | } |
| | 1476 | |
| | 1477 | $html .= FormSelectGenerator :: generateFromArray($tab, null, "content_" . $this->id . "_content_type", "Content", false); |
| | 1478 | } else { |
| | 1479 | $criteria_array = array ( |
| | 1480 | array ( |
| | 1481 | 'isSimpleContent' |
| 1378 | | ); |
| 1379 | | $metadada_allowed_content_types = ContentTypeFilter :: getObject($criteria_array); |
| 1380 | | |
| 1381 | | // Content metadata |
| 1382 | | if ($this->isSimpleContent() == false || $this->isPersistent()) { |
| 1383 | | $html .= "<fieldset class='admin_element_group'>\n"; |
| 1384 | | $html .= "<legend>" . sprintf(_("%s MetaData"), get_class($this)) . "</legend>\n"; |
| 1385 | | |
| 1386 | | /* title_is_displayed */ |
| 1387 | | $html_title_is_displayed = _("Display the title?") . ": \n"; |
| 1388 | | $name = "content_" . $this->id . "_title_is_displayed"; |
| 1389 | | $this->titleShouldDisplay() ? $checked = 'CHECKED' : $checked = ''; |
| 1390 | | $html_title_is_displayed .= "<input type='checkbox' name='$name' $checked>\n"; |
| 1391 | | |
| 1392 | | /* title */ |
| 1393 | | $html .= "<li class='admin_element_item_container admin_section_edit_title'>\n"; |
| 1394 | | $html .= "<div class='admin_element_data'>\n"; |
| 1395 | | if (empty ($this->content_row['title'])) { |
| 1396 | | $html .= self :: getNewContentUI("title_{$this->id}_new", $metadada_allowed_content_types, _("Title:")); |
| 1397 | | $html .= "</div>\n"; |
| 1398 | | } else { |
| 1399 | | $html .= $html_title_is_displayed; |
| 1400 | | $title = self :: getObject($this->content_row['title']); |
| 1401 | | $html .= $title->getAdminUI(null, _("Title:")); |
| 1402 | | $html .= "</div>\n"; |
| 1403 | | $html .= "<div class='admin_element_tools admin_section_delete_title'>\n"; |
| 1404 | | $name = "content_" . $this->id . "_title_erase"; |
| 1405 | | $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("title"), get_class($title)) . "'>"; |
| 1406 | | $html .= "</div>\n"; |
| 1407 | | } |
| 1408 | | $html .= "</li>\n"; |
| | 1483 | ); |
| | 1484 | $metadada_allowed_content_types = ContentTypeFilter :: getObject($criteria_array); |
| | 1485 | |
| | 1486 | // Content metadata |
| | 1487 | if ($this->isSimpleContent() == false || $this->isPersistent()) { |
| | 1488 | $html .= "<fieldset class='admin_element_group'>\n"; |
| | 1489 | $html .= "<legend>" . sprintf(_("%s MetaData"), get_class($this)) . "</legend>\n"; |
| | 1490 | |
| | 1491 | /* title_is_displayed */ |
| | 1492 | $html_title_is_displayed = _("Display the title?") . ": \n"; |
| | 1493 | $name = "content_" . $this->id . "_title_is_displayed"; |
| | 1494 | $this->titleShouldDisplay() ? $checked = 'CHECKED' : $checked = ''; |
| | 1495 | $html_title_is_displayed .= "<input type='checkbox' name='$name' $checked>\n"; |
| | 1496 | |
| | 1497 | /* title */ |
| | 1498 | $html .= "<li class='admin_element_item_container admin_section_edit_title'>\n"; |
| | 1499 | $html .= "<div class='admin_element_data'>\n"; |
| | 1500 | if (empty ($this->content_row['title'])) { |
| | 1501 | $html .= self :: getNewContentUI("title_{$this->id}_new", $metadada_allowed_content_types, _("Title:")); |
| | 1502 | $html .= "</div>\n"; |
| | 1503 | } else { |
| | 1504 | $html .= $html_title_is_displayed; |
| | 1505 | $title = self :: getObject($this->content_row['title']); |
| | 1506 | $html .= $title->getAdminUI(null, _("Title:")); |
| | 1507 | $html .= "</div>\n"; |
| | 1508 | $html .= "<div class='admin_element_tools admin_section_delete_title'>\n"; |
| | 1509 | $name = "content_" . $this->id . "_title_erase"; |
| | 1510 | $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("title"), get_class($title)) . "'>"; |
| | 1511 | $html .= "</div>\n"; |
| | 1512 | } |
| | 1513 | $html .= "</li>\n"; |
| | 1514 | } |
| | 1515 | |
| | 1516 | if ($this->isSimpleContent() == false) { |
| | 1517 | /* description */ |
| | 1518 | $html .= "<li class='admin_element_item_container admin_section_edit_description'>\n"; |
| | 1519 | $html .= "<div class='admin_element_data'>\n"; |
| | 1520 | if (empty ($this->content_row['description'])) { |
| | 1521 | $html .= self :: getNewContentUI("description_{$this->id}_new", $metadada_allowed_content_types, _("Description:")); |
| | 1522 | $html .= "</div>\n"; |
| | 1523 | } else { |
| | 1524 | $description = self :: getObject($this->content_row['description']); |
| | 1525 | $html .= $description->getAdminUI(null, _("Description:")); |
| | 1526 | $html .= "</div>\n"; |
| | 1527 | $html .= "<div class='admin_element_tools'>\n"; |
| | 1528 | $name = "content_" . $this->id . "_description_erase"; |
| | 1529 | $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("description"), get_class($description)) . "'>"; |
| | 1530 | $html .= "</div>\n"; |
| | 1531 | } |
| | 1532 | $html .= "</li>\n"; |
| | 1533 | |
| | 1534 | /* long description */ |
| | 1535 | $html .= "<li class='admin_element_item_container admin_section_edit_long_description'>\n"; |
| | 1536 | $html .= "<div class='admin_element_data'>\n"; |
| | 1537 | if (empty ($this->content_row['long_description'])) { |
| | 1538 | $html .= self :: getNewContentUI("long_description_{$this->id}_new", $metadada_allowed_content_types, _("Long description:")); |
| | 1539 | $html .= "</div>\n"; |
| | 1540 | } else { |
| | 1541 | $description = self :: getObject($this->content_row['long_description']); |
| | 1542 | $html .= $description->getAdminUI(null, _("Long description:")); |
| | 1543 | $html .= "</div>\n"; |
| | 1544 | $html .= "<div class='admin_element_tools'>\n"; |
| | 1545 | $name = "content_" . $this->id . "_long_description_erase"; |
| | 1546 | $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("long description"), get_class($description)) . "'>"; |
| | 1547 | $html .= "</div>\n"; |
| | 1548 | } |
| | 1549 | $html .= "</li>\n"; |
| | 1550 | |
| | 1551 | /* project_info */ |
| | 1552 | $html .= "<li class='admin_element_item_container admin_section_edit_project'>\n"; |
| | 1553 | $html .= "<div class='admin_element_data'>\n"; |
| | 1554 | if (empty ($this->content_row['project_info'])) { |
| | 1555 | $html .= self :: getNewContentUI("project_info_{$this->id}_new", $metadada_allowed_content_types, _("Information on this project:")); |
| | 1556 | $html .= "</div>\n"; |
| | 1557 | } else { |
| | 1558 | $project_info = self :: getObject($this->content_row['project_info']); |
| | 1559 | $html .= $project_info->getAdminUI(null, _("Information on this project:")); |
| | 1560 | $html .= "</div>\n"; |
| | 1561 | $html .= "<div class='admin_element_tools'>\n"; |
| | 1562 | $name = "content_" . $this->id . "_project_info_erase"; |
| | 1563 | $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("project information"), get_class($project_info)) . "'>"; |
| | 1564 | $html .= "</div>\n"; |
| | 1565 | } |
| | 1566 | $html .= "</li>\n"; |
| | 1567 | } |
| | 1568 | |
| | 1569 | //End content medatada |
| | 1570 | if ($this->isSimpleContent() == false || $this->isPersistent()) { |
| | 1571 | $html .= "</fieldset>\n"; |
| | 1572 | } |
| | 1573 | |
| | 1574 | if ($this->isSimpleContent() == false || $this->isPersistent()) { |
| | 1575 | |
| | 1576 | $html .= "<fieldset class='admin_element_group'>\n"; |
| | 1577 | $html .= "<legend>" . sprintf(_("%s access control"), get_class($this)) . "</legend>\n"; |
| | 1578 | |
| | 1579 | /* is_persistent */ |
| | 1580 | $html .= "<li class='admin_element_item_container admin_section_edit_persistant'>\n"; |
| | 1581 | $html .= "<div class='admin_element_label'>" . _("Is part of reusable content library (protected from deletion)?") . ": </div>\n"; |
| | 1582 | $html .= "<div class='admin_element_data'>\n"; |
| | 1583 | $name = "content_" . $this->id . "_is_persistent"; |
| | 1584 | $this->isPersistent() ? $checked = 'CHECKED' : $checked = ''; |
| | 1585 | $html .= "<input type='checkbox' name='$name' $checked onChange='submit();'>\n"; |
| | 1586 | $html .= "</div>\n"; |
| | 1587 | $html .= "</li>\n"; |
| | 1588 | |
| | 1589 | /* content_has_owners */ |
| | 1590 | $html .= "<li class='admin_element_item_container content_has_owners'>\n"; |
| | 1591 | $html .= "<div class='admin_element_label'>" . _("Content owner list") . "</div>\n"; |
| | 1592 | $html .= "<ul class='admin_element_list'>\n"; |
| | 1593 | |
| | 1594 | $db = AbstractDb :: getObject(); |
| | 1595 | $sql = "SELECT * FROM content_has_owners WHERE content_id='$this->id'"; |
| | 1596 | $db->execSql($sql, $content_owner_rows, false); |
| | 1597 | if ($content_owner_rows != null) { |
| | 1598 | foreach ($content_owner_rows as $content_owner_row) { |
| | 1599 | $html .= "<li class='admin_element_item_container'>\n"; |
| | 1600 | $html .= "<div class='admin_element_data'>\n"; |
| | 1601 | $user = User :: getObject($content_owner_row['user_id']); |
| | 1602 | |
| | 1603 | $html .= $user->getListUI(); |
| | 1604 | $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_is_author"; |
| | 1605 | $html .= " Is content author? "; |
| | 1606 | |
| | 1607 | $content_owner_row['is_author'] == 't' ? $checked = 'CHECKED' : $checked = ''; |
| | 1608 | $html .= "<input type='checkbox' name='$name' $checked>\n"; |
| | 1609 | $html .= "</div>\n"; |
| | 1610 | $html .= "<div class='admin_element_tools'>\n"; |
| | 1611 | $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_remove"; |
| | 1612 | $html .= "<input type='submit' class='submit' name='$name' value='" . _("Remove owner") . "'>"; |
| | 1613 | $html .= "</div>\n"; |
| | 1614 | $html .= "</li>\n"; |
| 1410 | | |
| 1411 | | if ($this->isSimpleContent() == false) { |
| 1412 | | /* description */ |
| 1413 | | $html .= "<li class='admin_element_item_container admin_section_edit_description'>\n"; |
| 1414 | | $html .= "<div class='admin_element_data'>\n"; |
| 1415 | | if (empty ($this->content_row['description'])) { |
| 1416 | | $html .= self :: getNewContentUI("description_{$this->id}_new", $metadada_allowed_content_types, _("Description:")); |
| 1417 | | $html .= "</div>\n"; |
| 1418 | | } else { |
| 1419 | | $description = self :: getObject($this->content_row['description']); |
| 1420 | | $html .= $description->getAdminUI(null, _("Description:")); |
| 1421 | | $html .= "</div>\n"; |
| 1422 | | $html .= "<div class='admin_element_tools'>\n"; |
| 1423 | | $name = "content_" . $this->id . "_description_erase"; |
| 1424 | | $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("description"), get_class($description)) . "'>"; |
| 1425 | | $html .= "</div>\n"; |
| 1426 | | } |
| 1427 | | $html .= "</li>\n"; |
| 1428 | | |
| 1429 | | /* long description */ |
| 1430 | | $html .= "<li class='admin_element_item_container admin_section_edit_long_description'>\n"; |
| 1431 | | $html .= "<div class='admin_element_data'>\n"; |
| 1432 | | if (empty ($this->content_row['long_description'])) { |
| 1433 | | $html .= self :: getNewContentUI("long_description_{$this->id}_new", $metadada_allowed_content_types, _("Long description:")); |
| 1434 | | $html .= "</div>\n"; |
| 1435 | | } else { |
| 1436 | | $description = self :: getObject($this->content_row['long_description']); |
| 1437 | | $html .= $description->getAdminUI(null, _("Long description:")); |
| 1438 | | $html .= "</div>\n"; |
| 1439 | | $html .= "<div class='admin_element_tools'>\n"; |
| 1440 | | $name = "content_" . $this->id . "_long_description_erase"; |
| 1441 | | $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("long description"), get_class($description)) . "'>"; |
| 1442 | | $html .= "</div>\n"; |
| 1443 | | } |
| 1444 | | $html .= "</li>\n"; |
| 1445 | | |
| 1446 | | /* project_info */ |
| 1447 | | $html .= "<li class='admin_element_item_container admin_section_edit_project'>\n"; |
| 1448 | | $html .= "<div class='admin_element_data'>\n"; |
| 1449 | | if (empty ($this->content_row['project_info'])) { |
| 1450 | | $html .= self :: getNewContentUI("project_info_{$this->id}_new", $metadada_allowed_content_types, _("Information on this project:")); |
| 1451 | | $html .= "</div>\n"; |
| 1452 | | } else { |
| 1453 | | $project_info = self :: getObject($this->content_row['project_info']); |
| 1454 | | $html .= $project_info->getAdminUI(null, _("Information on this project:")); |
| 1455 | | $html .= "</div>\n"; |
| 1456 | | $html .= "<div class='admin_element_tools'>\n"; |
| 1457 | | $name = "content_" . $this->id . "_project_info_erase"; |
| 1458 | | $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("project information"), get_class($project_info)) . "'>"; |
| 1459 | | $html .= "</div>\n"; |
| 1460 | | } |
| 1461 | | $html .= "</li>\n"; |
| 1462 | | } |
| 1463 | | |
| 1464 | | //End content medatada |
| 1465 | | if ($this->isSimpleContent() == false || $this->isPersistent()) { |
| 1466 | | $html .= "</fieldset>\n"; |
| 1467 | | } |
| 1468 | | |
| 1469 | | if ($this->isSimpleContent() == false || $this->isPersistent()) { |
| 1470 | | |
| 1471 | | $html .= "<fieldset class='admin_element_group'>\n"; |
| 1472 | | $html .= "<legend>" . sprintf(_("%s access control"), get_class($this)) . "</legend>\n"; |
| 1473 | | |
| 1474 | | /* is_persistent */ |
| 1475 | | $html .= "<li class='admin_element_item_container admin_section_edit_persistant'>\n"; |
| 1476 | | $html .= "<div class='admin_element_label'>" . _("Is part of reusable content library (protected from deletion)?") . ": </div>\n"; |
| 1477 | | $html .= "<div class='admin_element_data'>\n"; |
| 1478 | | $name = "content_" . $this->id . "_is_persistent"; |
| 1479 | | $this->isPersistent() ? $checked = 'CHECKED' : $checked = ''; |
| 1480 | | $html .= "<input type='checkbox' name='$name' $checked onChange='submit();'>\n"; |
| 1481 | | $html .= "</div>\n"; |
| 1482 | | $html .= "</li>\n"; |
| 1483 | | |
| 1484 | | /* content_has_owners */ |
| 1485 | | $html .= "<li class='admin_element_item_container content_has_owners'>\n"; |
| 1486 | | $html .= "<div class='admin_element_label'>" . _("Content owner list") . "</div>\n"; |
| 1487 | | $html .= "<ul class='admin_element_list'>\n"; |
| 1488 | | |
| 1489 | | $db = AbstractDb :: getObject(); |
| 1490 | | $sql = "SELECT * FROM content_has_owners WHERE content_id='$this->id'"; |
| 1491 | | $db->execSql($sql, $content_owner_rows, false); |
| 1492 | | if ($content_owner_rows != null) { |
| 1493 | | foreach ($content_owner_rows as $content_owner_row) { |
| 1494 | | $html .= "<li class='admin_element_item_container'>\n"; |
| 1495 | | $html .= "<div class='admin_element_data'>\n"; |
| 1496 | | $user = User :: getObject($content_owner_row['user_id']); |
| 1497 | | |
| 1498 | | $html .= $user->getListUI(); |
| 1499 | | $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_is_author"; |
| 1500 | | $html .= " Is content author? "; |
| 1501 | | |
| 1502 | | $content_owner_row['is_author'] == 't' ? $checked = 'CHECKED' : $checked = ''; |
| 1503 | | $html .= "<input type='checkbox' name='$name' $checked>\n"; |
| 1504 | | $html .= "</div>\n"; |
| 1505 | | $html .= "<div class='admin_element_tools'>\n"; |
| 1506 | | $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_remove"; |
| 1507 | | $html .= "<input type='submit' class='submit' name='$name' value='" . _("Remove owner") . "'>"; |
| 1508 | | $html .= "</div>\n"; |
| 1509 | | $html .= "</li>\n"; |
| 1510 | | } |
| 1511 | | } |
| 1512 | | |
| 1513 | | $html .= "<li class='admin_element_item_container'>\n"; |
| 1514 | | $html .= "<div class='admin_element_data'>\n"; |
| 1515 | | $add_button_name = "content_{$this->id}_add_owner_submit"; |
| 1516 | | $add_button_value = _("Add owner"); |
| 1517 | | $html .= User :: getSelectUserUI("content_{$this->id}_new_owner", $add_button_name, $add_button_value); |
| 1518 | | $html .= "</div>\n"; |
| 1519 | | $html .= "</li>\n"; |
| 1520 | | $html .= "</ul>\n"; |
| 1521 | | $html .= "</li>\n"; |
| 1522 | | $html .= "</fieldset>\n"; |
| 1523 | | |
| 1524 | | } |
| 1525 | | } |
| 1526 | | $html .= $subclass_admin_interface; |
| 1527 | | $html .= "</ul>\n"; |
| 1528 | | $html .= "</fieldset>\n"; |
| 1529 | | } |
| 1530 | | return $html; |
| | 1616 | } |
| | 1617 | |
| | 1618 | $html .= "<li class='admin_element_item_container'>\n"; |
| | 1619 | $html .= "<div class='admin_element_data'>\n"; |
| | 1620 | $add_button_name = "content_{$this->id}_add_owner_submit"; |
| | 1621 | $add_button_value = _("Add owner"); |
| | 1622 | $html .= User :: getSelectUserUI("content_{$this->id}_new_owner", $add_button_name, $add_button_value); |
| | 1623 | $html .= "</div>\n"; |
| | 1624 | $html .= "</li>\n"; |
| | 1625 | $html .= "</ul>\n"; |
| | 1626 | $html .= "</li>\n"; |
| | 1627 | $html .= "</fieldset>\n"; |
| | 1628 | |
| | 1629 | } |
| | 1630 | } |
| | 1631 | $html .= $subclass_admin_interface; |
| | 1632 | $html .= "</ul>\n"; |
| | 1633 | $html .= "</fieldset>\n"; |
| | 1634 | } |
| | 1635 | return $html; |
| 1536 | | if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { |
| 1537 | | $db = AbstractDb :: getObject(); |
| 1538 | | if ($this->getObjectType() == 'Content') /* The object hasn't yet been typed */ { |
| 1539 | | $content_type = FormSelectGenerator :: getResult("content_" . $this->id . "_content_type", "Content"); |
| 1540 | | $this->setContentType($content_type); |
| 1541 | | } else { |
| 1542 | | //Content medatada |
| 1543 | | |
| 1544 | | if ($this->isSimpleContent() == false || $this->isPersistent()) { |
| 1545 | | /* title_is_displayed */ |
| 1546 | | if (!empty ($this->content_row['title'])) { |
| 1547 | | $name = "content_" . $this->id . "_title_is_displayed"; |
| 1548 | | !empty ($_REQUEST[$name]) ? $this->setTitleIsDisplayed(true) : $this->setTitleIsDisplayed(false); |
| 1549 | | } |
| 1550 | | /* title */ |
| 1551 | | if (empty ($this->content_row['title'])) { |
| 1552 | | $title = self :: processNewContentUI("title_{$this->id}_new"); |
| 1553 | | if ($title != null) { |
| 1554 | | $title_id = $title->GetId(); |
| 1555 | | $db->execSqlUpdate("UPDATE content SET title = '$title_id' WHERE content_id = '$this->id'", FALSE); |
| 1556 | | } |
| 1557 | | } else { |
| 1558 | | $title = self :: getObject($this->content_row['title']); |
| 1559 | | $name = "content_" . $this->id . "_title_erase"; |
| 1560 | | if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { |
| 1561 | | $db->execSqlUpdate("UPDATE content SET title = NULL WHERE content_id = '$this->id'", FALSE); |
| 1562 | | $title->delete($errmsg); |
| 1563 | | } else { |
| 1564 | | $title->processAdminUI(); |
| 1565 | | } |
| 1566 | | } |
| 1567 | | } |
| 1568 | | if ($this->isSimpleContent() == false) { |
| 1569 | | /* description */ |
| 1570 | | if (empty ($this->content_row['description'])) { |
| 1571 | | $description = self :: processNewContentUI("description_{$this->id}_new"); |
| 1572 | | if ($description != null) { |
| 1573 | | $description_id = $description->GetId(); |
| 1574 | | $db->execSqlUpdate("UPDATE content SET description = '$description_id' WHERE content_id = '$this->id'", FALSE); |
| 1575 | | } |
| 1576 | | } else { |
| 1577 | | $description = self :: getObject($this->content_row['description']); |
| 1578 | | $name = "content_" . $this->id . "_description_erase"; |
| 1579 | | if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { |
| 1580 | | $db->execSqlUpdate("UPDATE content SET description = NULL WHERE content_id = '$this->id'", FALSE); |
| 1581 | | $description->delete($errmsg); |
| 1582 | | } else { |
| 1583 | | $description->processAdminUI(); |
| 1584 | | } |
| 1585 | | } |
| 1586 | | |
| 1587 | | /* long description */ |
| 1588 | | if (empty ($this->content_row['long_description'])) { |
| 1589 | | $long_description = self :: processNewContentUI("long_description_{$this->id}_new"); |
| 1590 | | if ($long_description != null) { |
| 1591 | | $long_description_id = $long_description->GetId(); |
| 1592 | | $db->execSqlUpdate("UPDATE content SET long_description = '$long_description_id' WHERE content_id = '$this->id'", FALSE); |
| 1593 | | } |
| 1594 | | } else { |
| 1595 | | $long_description = self :: getObject($this->content_row['long_description']); |
| 1596 | | $name = "content_" . $this->id . "_long_description_erase"; |
| 1597 | | if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { |
| 1598 | | $db->execSqlUpdate("UPDATE content SET long_description = NULL WHERE content_id = '$this->id'", FALSE); |
| 1599 | | $long_description->delete($errmsg); |
| 1600 | | } else { |
| 1601 | | $long_description->processAdminUI(); |
| 1602 | | } |
| 1603 | | } |
| 1604 | | |
| 1605 | | /* project_info */ |
| 1606 | | if (empty ($this->content_row['project_info'])) { |
| 1607 | | $project_info = self :: processNewContentUI("project_info_{$this->id}_new"); |
| 1608 | | if ($project_info != null) { |
| 1609 | | $project_info_id = $project_info->GetId(); |
| 1610 | | $db->execSqlUpdate("UPDATE content SET project_info = '$project_info_id' WHERE content_id = '$this->id'", FALSE); |
| 1611 | | } |
| 1612 | | } else { |
| 1613 | | $project_info = self :: getObject($this->content_row['project_info']); |
| 1614 | | $name = "content_" . $this->id . "_project_info_erase"; |
| 1615 | | if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { |
| 1616 | | $db->execSqlUpdate("UPDATE content SET project_info = NULL WHERE content_id = '$this->id'", FALSE); |
| 1617 | | $project_info->delete($errmsg); |
| 1618 | | } else { |
| 1619 | | $project_info->processAdminUI(); |
| 1620 | | } |
| 1621 | | } |
| 1622 | | } //End content metadata |
| 1623 | | |
| 1624 | | if ($this->isSimpleContent() == false || $this->isPersistent()) { |
| 1625 | | /* is_persistent */ |
| 1626 | | $name = "content_" . $this->id . "_is_persistent"; |
| 1627 | | !empty ($_REQUEST[$name]) ? $this->setIsPersistent(true) : $this->setIsPersistent(false); |
| 1628 | | |
| 1629 | | /* content_has_owners */ |
| 1630 | | $sql = "SELECT * FROM content_has_owners WHERE content_id='$this->id'"; |
| 1631 | | $db->execSql($sql, $content_owner_rows, false); |
| 1632 | | if ($content_owner_rows != null) { |
| 1633 | | foreach ($content_owner_rows as $content_owner_row) { |
| 1634 | | $user = User :: getObject($content_owner_row['user_id']); |
| 1635 | | $user_id = $user->getId(); |
| 1636 | | $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_remove"; |
| 1637 | | if (!empty ($_REQUEST[$name])) { |
| 1638 | | $this->deleteOwner($user); |
| 1639 | | } else { |
| 1640 | | $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_is_author"; |
| 1641 | | $content_owner_row['is_author'] == 't' ? $is_author = true : $is_author = false; |
| 1642 | | !empty ($_REQUEST[$name]) ? $should_be_author = true : $should_be_author = false; |
| 1643 | | if ($is_author != $should_be_author) { |
| 1644 | | $should_be_author ? $is_author_sql = 'TRUE' : $is_author_sql = 'FALSE'; |
| 1645 | | $sql = "UPDATE content_has_owners SET is_author=$is_author_sql WHERE content_id='$this->id' AND user_id='$user_id'"; |
| 1646 | | |
| 1647 | | if (!$db->execSqlUpdate($sql, false)) { |
| 1648 | | throw new Exception(_('Unable to set as author in the database.')); |
| 1649 | | } |
| 1650 | | |
| 1651 | | } |
| 1652 | | |
| 1653 | | } |
| 1654 | | } |
| 1655 | | } |
| 1656 | | $user = User :: processSelectUserUI("content_{$this->id}_new_owner"); |
| 1657 | | $name = "content_{$this->id}_add_owner_submit"; |
| 1658 | | if (!empty ($_REQUEST[$name]) && $user != null) { |
| 1659 | | $this->addOwner($user); |
| 1660 | | } |
| 1661 | | } |
| 1662 | | } |
| 1663 | | $this->refresh(); |
| 1664 | | } |
| | 1641 | if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { |
| | 1642 | $db = AbstractDb :: getObject(); |
| | 1643 | if ($this->getObjectType() == 'Content') /* The object hasn't yet been typed */ { |
| | 1644 | $content_type = FormSelectGenerator :: getResult("content_" . $this->id . "_content_type", "Content"); |
| | 1645 | $this->setContentType($content_type); |
| | 1646 | } else { |
| | 1647 | //Content medatada |
| | 1648 | |
| | 1649 | if ($this->isSimpleContent() == false || $this->isPersistent()) { |
| | 1650 | /* title_is_displayed */ |
| | 1651 | if (!empty ($this->content_row['title'])) { |
| | 1652 | $name = "content_" . $this->id . "_title_is_displayed"; |
| | 1653 | !empty ($_REQUEST[$name]) ? $this->setTitleIsDisplayed(true) : $this->setTitleIsDisplayed(false); |
| | 1654 | } |
| | 1655 | /* title */ |
| | 1656 | if (empty ($this->content_row['title'])) { |
| | 1657 | $title = self :: processNewContentUI("title_{$this->id}_new"); |
| | 1658 | if ($title != null) { |
| | 1659 | $title_id = $title->GetId(); |
| | 1660 | $db->execSqlUpdate("UPDATE content SET title = '$title_id' WHERE content_id = '$this->id'", FALSE); |
| | 1661 | } |
| | 1662 | } else { |
| | 1663 | $title = self :: getObject($this->content_row['title']); |
| | 1664 | $name = "content_" . $this->id . "_title_erase"; |
| | 1665 | if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { |
| | 1666 | $db->execSqlUpdate("UPDATE content SET title = NULL WHERE content_id = '$this->id'", FALSE); |
| | 1667 | $title->delete($errmsg); |
| | 1668 | } else { |
| | 1669 | $title->processAdminUI(); |
| | 1670 | } |
| | 1671 | } |
| | 1672 | } |
| | 1673 | if ($this->isSimpleContent() == false) { |
| | 1674 | /* description */ |
| | 1675 | if (empty ($this->content_row['description'])) { |
| | 1676 | $description = self :: processNewContentUI("description_{$this->id}_new"); |
| | 1677 | if ($description != null) { |
| | 1678 | $description_id = $description->GetId(); |
| | 1679 | $db->execSqlUpdate("UPDATE content SET description = '$description_id' WHERE content_id = '$this->id'", FALSE); |
| | 1680 | } |
| | 1681 | } else { |
| | 1682 | $description = self :: getObject($this->content_row['description']); |
| | 1683 | $name = "content_" . $this->id . "_description_erase"; |
| | 1684 | if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { |
| | 1685 | $db->execSqlUpdate("UPDATE content SET description = NULL WHERE content_id = '$this->id'", FALSE); |
| | 1686 | $description->delete($errmsg); |
| | 1687 | } else { |
| | 1688 | $description->processAdminUI(); |
| | 1689 | } |
| | 1690 | } |
| | 1691 | |
| | 1692 | /* long description */ |
| | 1693 | if (empty ($this->content_row['long_description'])) { |
| | 1694 | $long_description = self :: processNewContentUI("long_description_{$this->id}_new"); |
| | 1695 | if ($long_description != null) { |
| | 1696 | $long_description_id = $long_description->GetId(); |
| | 1697 | $db->execSqlUpdate("UPDATE content SET long_description = '$long_description_id' WHERE content_id = '$this->id'", FALSE); |
| | 1698 | } |
| | 1699 | } else { |
| | 1700 | $long_description = self :: getObject($this->content_row['long_description']); |
| | 1701 | $name = "content_" . $this->id . "_long_description_erase"; |
| | 1702 | if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { |
| | 1703 | $db->execSqlUpdate("UPDATE content SET long_description = NULL WHERE content_id = '$this->id'", FALSE); |
| | 1704 | $long_description->delete($errmsg); |
| | 1705 | } else { |
| | 1706 | $long_description->processAdminUI(); |
| | 1707 | } |
| | 1708 | } |
| | 1709 | |
| | 1710 | /* project_info */ |
| | 1711 | if (empty ($this->content_row['project_info'])) { |
| | 1712 | $project_info = self :: processNewContentUI("project_info_{$this->id}_new"); |
| | 1713 | if ($project_info != null) { |
| | 1714 | $project_info_id = $project_info->GetId(); |
| | 1715 | $db->execSqlUpdate("UPDATE content SET project_info = '$project_info_id' WHERE content_id = '$this->id'", FALSE); |
| | 1716 | } |
| | 1717 | } else { |
| | 1718 | $project_info = self :: getObject($this->content_row['project_info']); |
| | 1719 | $name = "content_" . $this->id . "_project_info_erase"; |
| | 1720 | if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { |
| | 1721 | $db->execSqlUpdate("UPDATE content SET project_info = NULL WHERE content_id = '$this->id'", FALSE); |
| | 1722 | $project_info->delete($errmsg); |
| | 1723 | } else { |
| | 1724 | $project_info->processAdminUI(); |
| | 1725 | } |
| | 1726 | } |
| | 1727 | } //End content metadata |
| | 1728 | |
| | 1729 | if ($this->isSimpleContent() == false || $this->isPersistent()) { |
| | 1730 | /* is_persistent */ |
| | 1731 | $name = "content_" . $this->id . "_is_persistent"; |
| | 1732 | !empty ($_REQUEST[$name]) ? $this->setIsPersistent(true) : $this->setIsPersistent(false); |
| | 1733 | |
| | 1734 | /* content_has_owners */ |
| | 1735 | $sql = "SELECT * FROM content_has_owners WHERE content_id='$this->id'"; |
| | 1736 | $db->execSql($sql, $content_owner_rows, false); |
| | 1737 | if ($content_owner_rows != null) { |
| | 1738 | foreach ($content_owner_rows as $content_owner_row) { |
| | 1739 | $user = User :: getObject($content_owner_row['user_id']); |
| | 1740 | $user_id = $user->getId(); |
| | 1741 | $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_remove"; |
| | 1742 | if (!empty ($_REQUEST[$name])) { |
| | 1743 | $this->deleteOwner($user); |
| | 1744 | } else { |
| | 1745 | $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_is_author"; |
| | 1746 | $content_owner_row['is_author'] == 't' ? $is_author = true : $is_author = false; |
| | 1747 | !empty ($_REQUEST[$name]) ? $should_be_author = true : $should_be_author = false; |
| | 1748 | if ($is_author != $should_be_author) { |
| | 1749 | $should_be_author ? $is_author_sql = 'TRUE' : $is_author_sql = 'FALSE'; |
| | 1750 | $sql = "UPDATE content_has_owners SET is_author=$is_author_sql WHERE content_id='$this->id' AND user_id='$user_id'"; |
| | 1751 | |
| | 1752 | if (!$db->execSqlUpdate($sql, false)) { |
| | 1753 | throw new Exception(_('Unable to set as author in the database.')); |
| | 1754 | } |
| | 1755 | |
| | 1756 | } |
| | 1757 | |
| | 1758 | } |
| | 1759 | } |
| | 1760 | } |
| | 1761 | $user = User :: processSelectUserUI("content_{$this->id}_new_owner"); |
| | 1762 | $name = "content_{$this->id}_add_owner_submit"; |
| | 1763 | if (!empty ($_REQUEST[$name]) && $user != null) { |
| | 1764 | $this->addOwner($user); |
| | 1765 | } |
| | 1766 | } |
| | 1767 | } |
| | 1768 | $this->refresh(); |
| | 1769 | } |