get() public method

public get ( $id, array $with = ['posts', 'membersCount', 'createUser'] ) : mixed
$id
$with array
return mixed
 public function getCMSFields()
 {
     $fields = FieldList::create();
     $fields->push(DropdownField::create("BlogID", _t("BlogTagsWidget.Blog", "Blog"), Blog::get()->map()));
     $this->extend("updateCMSFields", $fields);
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = FieldList::create();
     $fields->merge(array(DropdownField::create("BlogID", _t("BlogRecentPostsWidget.Blog", "Blog"), Blog::get()->map()), NumericField::create("NumberOfPosts", _t("BlogRecentPostsWidget.NumberOfPosts", "Number of Posts"))));
     $this->extend("updateCMSFields", $fields);
     return $fields;
 }
 /**
  * {@inheritdoc}
  */
 public function getCMSFields()
 {
     $this->beforeUpdateCMSFields(function ($fields) {
         /**
          * @var FieldList $fields
          */
         $fields->merge(array(DropdownField::create('BlogID', _t('BlogRecentPostsWidget.Blog', 'Blog'), Blog::get()->map()), NumericField::create('NumberOfPosts', _t('BlogRecentPostsWidget.NumberOfPosts', 'Number of Posts'))));
     });
     return parent::getCMSFields();
 }
 /**
  * {@inheritdoc}
  */
 public function getCMSFields()
 {
     $this->beforeUpdateCMSFields(function ($fields) {
         /**
          * @var FieldList $fields
          */
         $fields->push(DropdownField::create('BlogID', _t('BlogTagsWidget.Blog', 'Blog'), Blog::get()->map()));
     });
     return parent::getCMSFields();
 }
 /**
  * {@inheritdoc}
  */
 public function getCMSFields()
 {
     $this->beforeUpdateCMSFields(function (FieldList $fields) {
         $fields[] = DropdownField::create('BlogID', _t('BlogCategoriesWidget.Blog', 'Blog'), Blog::get()->map());
         $fields[] = NumericField::create('Limit', _t('BlogCategoriesWidget.Limit.Label', 'Limit'), 0)->setDescription(_t('BlogCategoriesWidget.Limit.Description', 'Limit the number of categories shown by this widget (set to 0 to show all categories).'))->setMaxLength(3);
         $fields[] = DropdownField::create('Order', _t('BlogCategoriesWidget.Sort.Label', 'Sort'), array('Title' => 'Title', 'Created' => 'Created', 'LastUpdated' => 'Updated'))->setDescription(_t('BlogCategoriesWidget.Sort.Description', 'Change the order of categories shown by this widget.'));
         $fields[] = DropdownField::create('Direction', _t('BlogCategoriesWidget.Direction.Label', 'Direction'), array('ASC' => 'Ascending', 'DESC' => 'Descending'))->setDescription(_t('BlogCategoriesWidget.Direction.Description', 'Change the direction of ordering of categories shown by this widget.'));
     });
     return parent::getCMSFields();
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $type = $this->dbObject("Type")->enumValues();
     foreach ($type as $k => $v) {
         $type[$k] = _t("BlogArchiveWidget." . ucfirst(strtolower($v)), $v);
     }
     $fields->merge(array(DropdownField::create("BlogID", _t("BlogArchiveWidget.Blog", "Blog"), Blog::get()->map()), DropdownField::create("Type", _t("BlogArchiveWidget.Type", "Type"), $type), NumericField::create("NumberToDisplay", _t("BlogArchiveWidget.NumberToDisplay", "No. to Display"))));
     $this->extend("updateCMSFields", $fields);
     return $fields;
 }
 function BlogLink()
 {
     if (empty($this->owner->BlogID)) {
         $entry = Director::get_current_page();
         if (is_a($entry, 'BlogPost')) {
             $this->owner->BlogID = $entry->Parent()->ID;
         } else {
             if (is_a($entry, 'Blog')) {
                 $this->owner->BlogID = $entry->ID;
             } else {
                 $this->owner->BlogID = Blog::get()->First()->ID;
             }
         }
     }
     return Blog::get()->byId($this->owner->BlogID)->Link();
 }
 /**
  * {@inheritdoc}
  */
 public function getCMSFields()
 {
     $self =& $this;
     $this->beforeUpdateCMSFields(function ($fields) use($self) {
         /**
          * @var Enum $archiveType
          */
         $archiveType = $self->dbObject('ArchiveType');
         $type = $archiveType->enumValues();
         foreach ($type as $k => $v) {
             $type[$k] = _t('BlogArchiveWidget.' . ucfirst(strtolower($v)), $v);
         }
         /**
          * @var FieldList $fields
          */
         $fields->merge(array(DropdownField::create('BlogID', _t('BlogArchiveWidget.Blog', 'Blog'), Blog::get()->map()), DropdownField::create('ArchiveType', _t('BlogArchiveWidget.ArchiveType', 'ArchiveType'), $type), NumericField::create('NumberToDisplay', _t('BlogArchiveWidget.NumberToDisplay', 'No. to Display'))));
     });
     return parent::getCMSFields();
 }
Beispiel #9
0
    include "notification_system.inc.php";
}
?>
			<?php 
$p = isset($_GET["p"]) ? $_GET["p"] : "add";
switch ($p) {
    case "mod":
    case "add":
        $blog = new Blog();
        $data = array("head" => "", "subh" => "", "body" => "");
        $meta = array("allow_comments" => 1, "tags" => "", "published" => 1, "author" => $_SESSION["admin_user"]);
        $root = get_entities("zombie_roots", $_SESSION["id"], array("groups"));
        $root = explode(", ", $root["groups"]);
        $meta["groups"] = array("all");
        if (isset($_GET["id"]) && isset($_GET["p"]) && $_GET["p"] == "mod") {
            $data = $blog->get($_GET["id"], array("head", "subh", "body"));
            $meta = $blog->get_sub("meta", $_GET["id"], array("allow_comments", "tags", "author", "groups", "published"));
            $groups = explode(", ", $meta["groups"]);
        }
        ?>
			<form method="post" id="article_form" action="engine.php?action=<?php 
        echo $p == "add" ? "add_article" : "mod_article";
        if (isset($_GET["id"])) {
            echo "&amp;id=" . $_GET["id"];
        }
        ?>
" enctype="plain/text">
				<p>
				<label for="head">Header</label> <input type="text" name="head" id="head" value="<?php 
        echo $data["head"];
        ?>
 /**
  * Resolves dynamic authors linked to this post.
  *
  * @return ArrayList
  */
 protected function getDynamicCredits()
 {
     // Find best page to host user profiles
     $parent = $this->Parent();
     if (!$parent instanceof Blog) {
         $parent = Blog::get()->first();
     }
     // If there is no parent blog, return list undecorated
     if (!$parent) {
         $items = $this->Authors()->toArray();
         return new ArrayList($items);
     }
     // Update all authors
     $items = new ArrayList();
     foreach ($this->Authors() as $author) {
         // Add link for each author
         $author = $author->customise(array('URL' => $parent->ProfileLink($author->URLSegment)));
         $items->push($author);
     }
     return $items;
 }
 /**
  * Search blog
  * 
  * @param  Array     $data
  * @param  FieldList $fields
  * @return FieldList
  */
 public function doSearch(array $data, FieldList $fields)
 {
     $this->redirect(Blog::get()->First()->Link() . '?Search=' . $data['Keyword']);
 }
Beispiel #12
0
			<?php 
if (isset($_GET["type"]) && isset($_GET["query"])) {
    $type = $_GET["type"];
    $query = strtolower($_GET["query"]);
    $search = new Search();
    switch ($type) {
        case "blog":
            $blog = new Blog();
            $results = $search->find_articles($query);
            if ($search->num_results() > 0) {
                ?>
<p>Order By: <a href="#" id="order_relevance">Relevance</a> | <a href="#" id="order_name">Name</a></p><?php 
                $sum = array_sum($results);
                $q = explode(" ", $query);
                foreach ($results as $key => $value) {
                    $current = $blog->get($key);
                    $current_meta = $blog->get_sub("meta", $key, array("tags", "author"));
                    echo "<div class=\"search_result\"><h2><a href=\"blog.php?p=read&amp;id={$key}\" rel=\"{$value}\" id=\"r{$key}\">", $current["head"], "</a></h2><h3>", $current["subh"], "</h3><span>Relevance: <strong>", substr($value / $sum * 100, 0, 5), "%</strong> ({$value} pts)</span><div class=\"article_body\" style=\"display: none; margin: 10px;\">";
                    echo "<p>";
                    $special_chars = array(".", ",", "-", "[", "]", "\\", "/", "|", "(", ")", "!", "@", "#", "\$", "%", "&", "*", "_", "?");
                    $body = str_replace(array("\n\n", "\n"), array("</p><p>", " <br /> "), $current["body"]);
                    $body = str_replace($special_chars, "", $body);
                    $body = explode(" ", $body);
                    foreach ($q as $qk => $qv) {
                        $color = "ff" . dechex($qk . "20") . "0f";
                        foreach ($body as $bk => $bv) {
                            if (ereg($qv, $bv)) {
                                $body[$bk] = str_replace($bv, "<span style=\"color: #{$color}; font-size: 18px; font-family: Tahoma\">" . $bv . "</span>", $body[$bk]);
                            }
                        }
                    }
Beispiel #13
0
     break;
 case 'create':
     // Insert into DB:
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('collection');
     // Check permissions:
     $current_User->check_perm('blogs', 'create', true);
     $edited_Blog = new Blog(NULL);
     $edited_Blog->set('owner_user_ID', $current_User->ID);
     param('kind', 'string', true);
     $edited_Blog->init_by_kind($kind);
     if (!$current_User->check_perm('blog_admin', 'edit', false, $edited_Blog->ID)) {
         // validate the urlname, which was already set by init_by_kind() function
         // It needs to validated, because the user can not set the blog urlname, and every new blog would have the same urlname without validation.
         // When user has edit permission to blog admin part, the urlname will be validated in load_from_request() function.
         $edited_Blog->set('urlname', urltitle_validate($edited_Blog->get('urlname'), '', 0, false, 'blog_urlname', 'blog_ID', 'T_blogs'));
     }
     param('skin_ID', 'integer', true);
     $edited_Blog->set_setting('normal_skin_ID', $skin_ID);
     if ($edited_Blog->load_from_Request(array())) {
         // create the new blog
         $edited_Blog->create($kind);
         // We want to highlight the edited object on next list display:
         // $Session->set( 'fadeout_array', array( 'blog_ID' => array($edited_Blog->ID) ) );
         header_redirect($dispatcher . '?ctrl=coll_settings&tab=features&blog=' . $edited_Blog->ID);
         // will save $Messages into Session
     }
     break;
 case 'delete':
     // ----------  Delete a blog from DB ----------
     // Check that this action request is not a CSRF hacked request:
 function getAllArchive()
 {
     $linkingMode = '';
     if (is_a($this->owner, 'Blog_Controller')) {
         $blog = $this->owner;
         $year = $blog->getArchiveYear();
         $month = $blog->getArchiveMonth();
         $day = $blog->getArchiveDay();
         if (!$year && !$month && !$day) {
             $linkingMode = 'current';
         }
     } else {
         if (is_a($this->owner, 'BlogPost_Controller')) {
             $blog = $this->owner->Parent();
         } else {
             $blog = Blog::get()->First();
         }
     }
     return new ArrayData(array('Title' => 'All', 'LinkingMode' => $linkingMode, 'Link' => $blog->Link()));
 }
Beispiel #15
0
        }
        ?>
/>
				<input type="submit" class="btn" <?php 
        echo $p == "add" ? "value=\"Create a bloody masterpiece\" id=\"add_article\"" : "value=\"Re-animate\" id=\"mod_article\"";
        ?>
 /><img src="images/btn_right.png" alt="btn_right" class="btn_right" />
				</p>
			</form>
			<?php 
        break;
    case "read":
        if (isset($_GET['id'])) {
            $id = $_GET["id"];
            $blog = new Blog();
            $article = $blog->get($id);
            $meta = $blog->get_sub("meta", $id, array("author"));
            echo "<a href=\"blog.php?p=mod&amp;id=", $id, "\">Modify this Article</a> or <a href=\"blog.php?p=del&amp;id=", $id, "\">delete it</a>";
            echo "<h2>", $article["head"], "</h2>";
            if ($article["subh"] != null) {
                echo "<h3>", $article["subh"], " - By: ", $meta["author"], "</h3>";
            }
            $body = str_replace(array("\n\n", "\n"), array("</p><p>", "<br />"), $article["body"]);
            echo "<p>", $body, "</p>";
            echo "<a href=\"blog.php?p=mod&amp;id=", $id, "\">Modify this Article</a> or <a href=\"blog.php?p=del&amp;id=", $id, "\">delete it</a>";
        } else {
            echo "No article selected";
        }
        break;
    case "del":
        $id = $_GET["id"];
Beispiel #16
0
// Tell SimpleOrm to use the connection you just created.
SimpleOrm::useConnection($conn, $params['database']['name']);
// Define an object that relates to a table.
class Blog extends SimpleOrm
{
}
// Create an entry.
$entry = new Blog();
$entry->title = 'Hello';
$entry->body = 'World!';
$entry->save();
// Use the object.
printf("%s\n", $entry->title);
// prints 'Hello';
// Dump all the fields in the object.
print_r($entry->get());
// Retrieve a record from the table.
$entry = Blog::retrieveByPK($entry->id());
// by primary key
// Retrieve a record from the table using another column.
$entry = Blog::retrieveByTitle('Hello', SimpleOrm::FETCH_ONE);
// by field (subject = hello)
// Update the object.
$entry->body = 'Mars!';
$entry->save();
// Delete the record from the table.
$entry->delete();
/*
vm1:/home/alex.joyce/SimpleOrm# php example.php 
Hello
Array