示例#1
0
 /**
  * Tries to find content that matches the input query
  * @param string $query
  */
 public function find($query)
 {
     $q = implode('%', explode(' ', $query));
     $sql = 'SELECT content.* FROM content JOIN idiom ON content.idiom_id = idiom.id
         WHERE idiom.code = ? AND content.publish = 1 
             AND (
                 content.keywords like (?)
                 OR content.alias like (?) 
                 OR content.title like (?)
                 OR content.description like (?)
                 OR content.intro like (?)
                 OR content.html like (?)
                 )
         ORDER BY visits DESC';
     // Prepare values and run query
     $q = "%{$q}%";
     $rows = R::getAll($sql, array(BootWiki::getIdiom(), $q, $q, $q, $q, $q, $q));
     $results = R::convertToBeans('content', $rows);
     if (!empty($results)) {
         foreach ($results as $item) {
             $content = new Content($item->alias);
             $content->importBean($item);
             $this->items[] = $content;
         }
     }
 }
示例#2
0
 /**
  * Loads Content based on unique alias
  * @param string $alias
  * @return boolean
  */
 public function visit($content)
 {
     // Add visit
     $content->addVisits();
     $content->save();
     // Load versions
     if (BootWiki::getLoggedAccount() !== null) {
         $this->versions = $content->loadVersions();
     }
     // set content
     $this->content = $content;
     return true;
 }
示例#3
0
<div>

    <h1 itemprop="headline" id="content_title"><a href="<?php 
echo BASEURL . '/' . $this->content->alias;
?>
"><?php 
echo $this->content->title;
?>
</a>
        <?php 
if (BootWiki::getLoggedAccount()) {
    ?>
        &nbsp;<a class="label label-danger small" href="<?php 
    echo BASEURL . '/edit/' . $this->content->alias;
    ?>
">edit</a>
        <?php 
}
?>
    </h1>
    
    <p id="content_meta" class="well">
        <span class="label label-warning">
            <em itemprop="lastReviewed" class="label"><?php 
echo date(DATE_FORMAT, strtotime($this->content->date));
?>
</em>
        </span>&nbsp;
        <?php 
if (is_object($this->content->author) && !empty($this->content->author->profile)) {
    ?>
示例#4
0
        <input name="password" type="password" required placeholder="Password" class="form-control" />
    </div>
    <div class="form-group">
        <label>Confirme Password</label>
        <input name="password_confirm" type="password" required placeholder="Confirm password" class="form-control" />
    </div>

    <?php 
if (BootWiki::hasMessage()) {
    ?>
    <div class="bg-danger" id="login_error"><?php 
    echo BootWiki::getMessage();
    ?>
</div>
    <script>
        jQuery(function($) {
            for(i=0;i<3;i++) {
                $('#login_error').fadeTo('fast', 0).fadeTo('fast', 1);
            }
        });
    </script>
    <?php 
}
?>

    <input type="text" name="reserved" style="display: none" />
    <button class="btn btn-primary" type="submit">Register</button>
</form>
<?php 
BootWiki::clearMessage();
示例#5
0
        $account->update($app->request()->post());
    }
    // Process change password
    if ($app->request()->post('password_confirm')) {
        $main = new Account();
        $main->changePassword($app->request()->post());
    }
    // Apply redirects
    $app->redirect(BASEURL . '/mod/myaccount');
});
/*
 * Process logout
 */
$app->get('/mod/auth/logout', function () use($app) {
    // Process logout
    BootWiki::logout();
    $app->redirect(BASEURL);
});
/*
 * Load image gallery
 */
$app->get('/mod/gallery', function () use($app) {
    // Create Gallery
    $gallery = new Gallery();
    $gallery->loadFolder(DATAPATH);
    // Print layout
    $app->response()->body((string) $gallery);
});
/*
 * File downloader
 */
示例#6
0
 /**
  * Validates password
  * $post has $post['password'] and $post['password_confirm']
  * @param array $post
  * @return boolean
  */
 public function validatePassword($post)
 {
     // Validate password strength
     $score = BootWiki::checkPassword($post['password']);
     if ($score < 1) {
         BootWiki::setMessage('Invalid password. Password is ' . BootWiki::getPasswordDescription($score));
         return false;
     }
     // Validate password match
     if ($post['password'] != $post['password_confirm']) {
         BootWiki::setMessage('Password was not confirmed');
         return false;
     }
     return true;
 }
示例#7
0
 /**
  * Creates a new Block
  * @param string $template_name
  * @param string $html It may hold a sub-content
  */
 public function __construct($template_name, $html = '')
 {
     $this->template_path = BootWiki::template($template_name);
     $this->html = $html;
 }
示例#8
0
            <div class="col-md-12">
              <?php 
    echo $this->html;
    ?>
            </div><!--/span-->
          </div><!--/row-->
          <?php 
}
?>

          </div>
        </div>
      </div>
    </div>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="web/js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="web/js/ie10-viewport-bug-workaround.js"></script>
    
    <!-- Include google analytics if exists -->
    <?php 
if (file_exists(TEMPLATEPATH . '/' . BootWiki::getIdiom() . '/ga.php')) {
    include TEMPLATEPATH . '/' . BootWiki::getIdiom() . '/ga.php';
}
?>
  </body>
</html>
示例#9
0
 /**
  * This loads all content items
  */
 public function loadAll()
 {
     // Load featured
     $sql = '
     SELECT content.* FROM content 
     LEFT JOIN idiom ON content.idiom_id = idiom.id
     WHERE idiom.code = ? AND content.featured = 1 AND content.publish = 1';
     $rows = R::getAll($sql, array(BootWiki::getIdiom()));
     $beans = R::convertToBeans('content', $rows);
     $featured = array();
     foreach ($beans as $item) {
         $content = new Content();
         $content->importBean($item);
         $featured[] = $content;
     }
     $this->featured = $featured;
 }
示例#10
0
if ($_SESSION['step'] == 6 && $_SESSION['step5_ok']) {
    $step6_results = array();
    try {
        require_once 'vendor/autoload.php';
        require_once 'lib/Link.php';
        require_once 'lib/BootWiki.php';
        require_once 'lib/Idiom.php';
        require_once 'lib/Image.php';
        require_once 'lib/Content.php';
        require_once 'lib/BootWiki.php';
        if ($_SESSION['step2']['dbdriver'] == 'mysql') {
            $dsn = $_SESSION['step2']['dbdriver'] . ':host=' . $_SESSION['step2']['dbhost'] . ';dbname=' . $_SESSION['step2']['dbname'];
        } else {
            $dsn = $_SESSION['step2']['dbdriver'] . ':' . $_SESSION['step2']['dbfile'];
        }
        RedBean_Facade::setup($dsn, $_SESSION['step2']['dbuser'], $_SESSION['step2']['dbpass']);
        define('ENCRYPT_SALT', $_SESSION['step4']['encrypt_salt']);
        BootWiki::install();
        $step6_results[] = 'Database instalation was completed';
        $_SESSION['step6_ok'] = true;
    } catch (\PDOException $e) {
        $step6_results[] = 'Database error: ' . $e->getMessage();
    }
}
/**
 * Do not let to go further than step 6 if database is not installed
 */
if (!$_SESSION['step6_ok'] && $_SESSION['step'] > 6) {
    $_SESSION['step'] = 5;
}
require_once $_SESSION['step1']['templatepath'] . DIRECTORY_SEPARATOR . 'en' . DIRECTORY_SEPARATOR . 'installer.php';
示例#11
0
 /**
  * Saves form data
  * @param array $post
  * @param array $upload_image
  */
 public function savePost($post, $upload_image)
 {
     // Import fields (ugly i know)
     $fields = 'title,alias,publish,featured,date,description,keywords,author,intro,html,visits';
     // Find record
     $bean = R::findOne('content', 'alias = ?', array($this->alias));
     if (empty($bean)) {
         $bean = R::dispense('content');
     } else {
         // Save last version
         $version = R::dispense('contentversion');
         $version->import($bean->export(), $fields);
         $version->date = date('Y-m-d H:i:s');
         $version->content = $bean;
         R::store($version);
     }
     // Import changes
     $bean->import($post, $fields);
     $bean->idiom = R::findOne('idiom', 'code = ?', array($post['idiom']));
     $new_image = Image::upload($upload_image);
     if ($new_image) {
         $bean->image = $new_image;
     }
     // Save
     try {
         R::store($bean);
         $this->importBean($bean);
     } catch (Exception $e) {
         BootWiki::setMessage($e->getMessage());
     }
 }