コード例 #1
0
 public function getAll()
 {
     if (!isset($this->Elements) || $this->countElements() < 0) {
         return ContentGroup::getEmptyInstance();
     }
     return $this->Elements;
 }
コード例 #2
0
 /**
  * Processes the input of the administration interface for Picture
  *
  * @return void
  */
 public function processAdminUI()
 {
     if ($this->DEPRECATEDisOwner(User::getCurrentUser()) || User::getCurrentUser()->DEPRECATEDisSuperAdmin()) {
         parent::processAdminUI();
         /* width and height */
         $name = "banner_add_group_{this->getId()}_widthxheight";
         $widthxheight = FormSelectGenerator::getResult($name, null);
         //pretty_print_r($widthxheight);
         $name = "banner_add_group_{this->getId()}_max_width";
         $max_width = $_REQUEST[$name];
         /*max_height*/
         $name = "banner_add_group_{this->getId()}_max_height";
         $max_height = $_REQUEST[$name];
         if (!empty($widthxheight)) {
             $widthxheightArray = explode('/', $widthxheight);
             $max_width_select = $widthxheightArray[0];
             $max_height_select = $widthxheightArray[1];
             if (($max_width_select != $max_width || $max_height_select != $max_height) && ($max_width == $this->getKVP(get_class($this) . '_max_width') && $max_height == $this->getKVP(get_class($this) . '_max_height'))) {
                 /* Width and height weren't manually changed, or were empty */
                 $max_width = $max_width_select;
                 $max_height = $max_height_select;
             }
         }
         $this->setKVP(get_class($this) . '_max_width', $max_width);
         $this->setKVP(get_class($this) . '_max_height', $max_height);
     }
 }
コード例 #3
0
 /**
  * Like the same method as defined in Content, this method will create a
  * ContentGroupElement based on the content type specified by
  * getNewContentUI OR get an existing element by getSelectExistingContentUI
  *
  * @param string $user_prefix                A identifier provided by the programmer to
  *                                           recognise it's generated form
  * @param string $content_group              Must be present
  * @param bool   $associate_existing_content If set to true, will get an
  *                                           existing element instead of creating a
  *                                           new content.
  *
  * @return object The ContentGroup object, or null if the user didn't greate one
  * @static
  */
 public static function processNewContentUI($user_prefix, ContentGroup $content_group, $associate_existing_content = false)
 {
     $db = AbstractDb::getObject();
     // Init values
     $content_group_element_object = null;
     $max_display_order_row = null;
     if ($associate_existing_content == true) {
         $displayed_content_object = Content::processSelectExistingContentUI($user_prefix);
     } else {
         $displayed_content_object = Content::processNewContentUI($user_prefix);
     }
     if ($displayed_content_object) {
         /* Get the display order to add the GontentGroupElement at the end */
         $sql = "SELECT MAX(display_order) as max_display_order FROM content_group_element WHERE content_group_id='" . $content_group->getId() . "'";
         $db->execSqlUniqueRes($sql, $max_display_order_row, false);
         $display_order = $max_display_order_row['max_display_order'] + 1;
         $content_id = get_guid();
         $content_type = 'ContentGroupElement';
         $sql = "INSERT INTO content (content_id, content_type) VALUES ('{$content_id}', '{$content_type}');";
         if (!$db->execSqlUpdate($sql, false)) {
             throw new Exception(_('Unable to insert new content group element into database!'));
         }
         $sql = "INSERT INTO content_group_element (content_group_element_id, content_group_id, display_order) VALUES ('{$content_id}', '" . $content_group->GetId() . "', {$display_order});";
         if (!$db->execSqlUpdate($sql, false)) {
             throw new Exception(_('Unable to insert new content group element into database!'));
         }
         $content_group_element_object = self::getObject($content_id);
         $content_group_element_object->replaceDisplayedContent($displayed_content_object);
     }
     return $content_group_element_object;
 }
コード例 #4
0
 /**
  * Retreives the user interface of this object.
  * @return The HTML fragment for this interface
  */
 public function getUserUI()
 {
     // Init values
     $html = '';
     // Check if the user has already subscribed to Pattern language
     $current_user = User::getCurrentUser();
     if ($current_user == null || $this->isUserSubscribed($current_user) == false) {
         // hyperlink to all users narrative
         $html .= "<ul class='pattern_language_menu'>";
         $html .= "<li><a class='pattern_language_big_links' href='/content/PatternLanguage/subscription.php'>" . _("Subscribe to Pattern Language") . "</a></li>";
         $html .= "<li><a class='pattern_language_big_links' href='/content/PatternLanguage/archives.php'>" . _("Read narratives archives") . "</a></li>";
         $html .= "</ul>";
         // Until subscription is done DO NOT log this !
         $this->setLoggingStatus(false);
         $this->setUserUIMainDisplayContent($html);
         // Tell the content group not to display elements until subscription is done
         $parent_output = parent::getUserUI(true);
     } else {
         /*
          * The user is subscribed to the pattern language show an element!
          * hyperlink to user's narrative
          */
         $html .= "<ul class='pattern_language_menu'>";
         $html .= "<li><a href='/content/PatternLanguage/narrative.php'>" . _("Read my narrative") . "</a></li>";
         $html .= "<li><a href='/content/PatternLanguage/archives.php'>" . _("Read narratives archives") . "</a></li>";
         $html .= "<li><a href='/content/PatternLanguage/subscription.php'>" . _("Unsubscribe") . "</a></li>";
         $html .= "</ul>";
         $this->setUserUIMainDisplayContent($html);
         // Display the random pattern
         $parent_output = parent::getUserUI();
     }
     return $parent_output;
 }
コード例 #5
0
 public function __construct($content)
 {
     parent::__construct($content);
 }