示例#1
0
 /**
  * initialize plugin
  *
  * try to keep all initialization in one method to have a clean class
  * for the plugin-user
  *
  * @param string $pluginKey
  * @deprecated since 2015-04-24; will be declared 'final'
  */
 public function initializePlugin($pluginKey)
 {
     /**
      * init $plugin property
      */
     $this->plugin['key'] = $pluginKey;
     list($vendor, $name) = explode('\\', $this->plugin['key']);
     $DS = DIRECTORY_SEPARATOR;
     $this->plugin['dir'] = PLUGINS_DIR . $vendor . $DS . $name . $DS;
     /**
      * init events
      */
     foreach ($this->events as $event => $method) {
         Event::registerEvent($event, $this);
     }
     /**
      * init plugin settings
      */
     $defaults = Utility::load($this->getPluginPath('config.php'));
     if (empty($defaults) || !is_array($defaults)) {
         $defaults = [];
     }
     $globals = Registry::get('Phile_Settings');
     if (!isset($globals['plugins'][$pluginKey])) {
         $globals['plugins'][$pluginKey] = [];
     }
     // settings precedence: global > default > class
     $this->settings = array_replace_recursive($this->settings, $defaults, $globals['plugins'][$pluginKey]);
     // backwards compatibility to Phile 1.4
     $this->injectSettings($this->settings);
     $globals['plugins'][$pluginKey]['settings'] = $this->settings;
     Registry::set('Phile_Settings', $globals);
 }
示例#2
0
文件: Page.php 项目: rafasashi/Phile
 /**
  * find all pages (*.md) files and returns an array of Page models
  *
  * @param array  $options
  * @param string $folder
  *
  * @return array of \Phile\Model\Page objects
  */
 public function findAll(array $options = array(), $folder = CONTENT_DIR)
 {
     $options += $this->settings;
     // ignore files with a leading '.' in its filename
     $files = Utility::getFiles($folder, '\\Phile\\FilterIterator\\ContentFileFilterIterator');
     $pages = array();
     foreach ($files as $file) {
         if (str_replace($folder, '', $file) == '404' . CONTENT_EXT) {
             // jump to next page if file is the 404 page
             continue;
         }
         $pages[] = $this->getPage($file, $folder);
     }
     if (empty($options['pages_order'])) {
         return $pages;
     }
     // parse search criteria
     $terms = preg_split('/\\s+/', $options['pages_order'], -1, PREG_SPLIT_NO_EMPTY);
     foreach ($terms as $term) {
         $term = explode('.', $term);
         if (count($term) > 1) {
             $type = array_shift($term);
         } else {
             $type = null;
         }
         $term = explode(':', $term[0]);
         $sorting[] = array('type' => $type, 'key' => $term[0], 'order' => $term[1]);
     }
     // prepare search criteria for array_multisort
     foreach ($sorting as $sort) {
         $key = $sort['key'];
         $column = array();
         foreach ($pages as $page) {
             /** @var \Phile\Model\Page $page */
             $meta = $page->getMeta();
             if ($sort['type'] === 'page') {
                 $method = 'get' . ucfirst($key);
                 $value = $page->{$method}();
             } elseif ($sort['type'] === 'meta') {
                 $value = $meta->get($key);
             } else {
                 continue 2;
                 // ignore unhandled search term
             }
             $column[] = $value;
         }
         $sortHelper[] = $column;
         $sortHelper[] = constant('SORT_' . strtoupper($sort['order']));
     }
     $sortHelper[] =& $pages;
     call_user_func_array('array_multisort', $sortHelper);
     return $pages;
 }
示例#3
0
<?php

use Phile\Bootstrap;
use Phile\Core\Utility;
/**
 * @author PhileCMS
 * @link https://philecms.com
 * @license http://opensource.org/licenses/MIT
 * @package Phile
 * @deprecated since 2015-05-01, file will be removed
 */
require_once __DIR__ . '/lib/Phile/Bootstrap.php';
Bootstrap::getInstance()->initializeBasics();
echo Utility::generateSecureToken(64);
echo "<br><br><br>(Please note: this file is deprecated and will be removed in an upcoming Phile release.)";
示例#4
0
 /**
  * link the class or method to the API or return the method name
  * @param $class
  * @param $method
  *
  * @return string
  */
 protected function linkClass($class, $method = null)
 {
     $title = $method ? $method : $class;
     if (strpos($class, 'Phile\\') === 0) {
         return $title;
     }
     $filename = 'docs/classes/' . str_replace('\\', '.', $class) . '.html';
     if (file_exists(Utility::resolveFilePath($filename))) {
         return $title;
     }
     $href = $this->settings['base_url'] . '/' . $filename;
     if ($method) {
         $href .= '#method_' . $method;
     }
     return $this->tag('a', $title, ['href' => $href, 'target' => '_blank']);
 }
示例#5
0
文件: config.php 项目: patrova/Phile
<?php

/**
 * the configuration file
 *
 * @see https://michelf.ca/projects/php-markdown/configuration/
 */
return array('empty_element_suffix' => ' />', 'tab_width' => 4, 'no_markup' => false, 'no_entities' => false, 'predef_urls' => array('base_url' => \Phile\Core\Utility::getBaseUrl()), 'predef_titles' => array(), 'fn_id_prefix' => "", 'fn_link_title' => "", 'fn_backlink_title' => "", 'fn_link_class' => "footnote-ref", 'fn_backlink_class' => "footnote-backref", 'code_class_prefix' => "", 'code_attr_on_pre' => false, 'predef_abbr' => array());
示例#6
0
文件: Plugin.php 项目: patrova/Phile
 /**
  * generate encryption key
  *
  * @return string
  */
 protected function generateToken()
 {
     return Utility::generateSecureToken(64);
 }
示例#7
0
 /**
  * link the method name to the API or return the method name
  * @param $class
  * @param $method
  *
  * @return string
  */
 protected function linkClassMethod($class, $method)
 {
     if (strpos($class, 'Phile\\') === 0) {
         $filename = 'docs/classes/' . str_replace('\\', '.', $class) . '.html';
         if (file_exists(Utility::resolveFilePath($filename))) {
             $method = '<a href="' . Utility::getBaseUrl() . '/' . $filename . '#method_' . $method . '" target="_blank">' . $method . '</a>';
         }
     }
     return $method;
 }