コード例 #1
0
 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container $container The DI container.
  *
  * @return  Container  Returns itself to support chaining.
  */
 public function register(Container $container)
 {
     // Global Config
     $container->share('joomla.config', array('JFactory', 'getConfig'));
     // Windwalker Config
     $container->share('windwalker.config', array($this, 'loadConfig'));
     // Database
     $this->share($container, 'db', 'JDatabaseDriver', array('JFactory', 'getDbo'));
     // Language
     $this->share($container, 'language', 'JLanguage', array('JFactory', 'getLanguage'));
     // Dispatcher
     $this->share($container, 'event.dispatcher', 'JEventDispatcher', array('JEventDispatcher', 'getInstance'));
     // Date
     $this->set($container, 'date', 'JDate', function () {
         return DateHelper::getDate();
     });
     // Global
     $container->set('SplPriorityQueue', function () {
         return new \SplPriorityQueue();
     });
     // Asset
     $container->share('helper.asset', function () {
         return new \Windwalker\Helper\AssetHelper();
     });
     // Detect deferent environment
     if (defined('WINDWALKER_CONSOLE')) {
         $container->registerServiceProvider(new CliProvider());
     } else {
         $container->registerServiceProvider(new WebProvider());
     }
 }
コード例 #2
0
 /**
  * Get a query string to filter the publishing items now.
  *
  * Will return: '( publish_up < 'xxxx-xx-xx' OR publish_up = '0000-00-00' )
  *   AND ( publish_down > 'xxxx-xx-xx' OR publish_down = '0000-00-00' )'
  *
  * @param   string $prefix Prefix to columns name, eg: 'a.' will use `a`.`publish_up`.
  *
  * @return  string Query string.
  */
 public static function publishingPeriod($prefix = '')
 {
     $db = Container::getInstance()->get('db');
     $nowDate = $date = DateHelper::getDate()->toSQL();
     $nullDate = $db->getNullDate();
     $date_where = " ( {$prefix}publish_up < '{$nowDate}' OR  {$prefix}publish_up = '{$nullDate}') AND " . " ( {$prefix}publish_down > '{$nowDate}' OR  {$prefix}publish_down = '{$nullDate}') ";
     return $date_where;
 }
コード例 #3
0
 /**
  * checkPublishedDate
  *
  * @param Data $item
  *
  * @return  void
  */
 public static function checkPublishedDate(Data $item)
 {
     $pup = DateHelper::getDate($item->publish_up)->toUnix();
     $pdw = DateHelper::getDate($item->publish_down)->toUnix();
     $now = DateHelper::getDate('now')->toUnix();
     $null = DateHelper::getDate('0000-00-00 00:00:00')->toUnix();
     if ($now < $pup && $pup != $null || $now > $pdw && $pdw != $null) {
         $item->published = 0;
     }
     if ($item->modified == '0000-00-00 00:00:00') {
         $item->modified = '';
     }
 }
コード例 #4
0
 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container $container The DI container.
  *
  * @return  Container  Returns itself to support chaining.
  */
 public function register(Container $container)
 {
     // Global Config
     $container->share('joomla.config', array('JFactory', 'getConfig'));
     // Windwalker Config
     $container->share('windwalker.config', array($this, 'loadConfig'));
     // Database
     $this->share($container, 'db', 'JDatabaseDriver', array('JFactory', 'getDbo'));
     // Session
     // Global Config
     $container->share('session', function () {
         return \JFactory::getSession();
     });
     // Language
     $this->share($container, 'language', 'JLanguage', array('JFactory', 'getLanguage'));
     // Dispatcher
     $this->share($container, 'event.dispatcher', 'JEventDispatcher', array('JEventDispatcher', 'getInstance'));
     // Mailer
     $this->share($container, 'mailer', 'JMail', array('JFactory', 'getMailer'));
     // Date
     $this->set($container, 'date', 'JDate', function () {
         return DateHelper::getDate();
     });
     // Global
     $container->set('SplPriorityQueue', function () {
         return new \SplPriorityQueue();
     });
     // Asset
     $container->share('helper.asset', function () {
         return \Windwalker\Asset\AssetManager::getInstance();
     });
     // Relation
     $container->share('relation.container', function () {
         return new RelationContainer();
     });
     // Detect deferent environment
     if ($this->isConsole) {
         $container->registerServiceProvider(new CliProvider());
     } else {
         $container->registerServiceProvider(new WebProvider());
     }
 }
コード例 #5
0
ファイル: AdminModel.php プロジェクト: beingsane/quickcontent
 /**
  * Prepare and sanitise the table data prior to saving.
  *
  * @param   JTable  $table  A reference to a JTable object.
  *
  * @return  void
  */
 protected function prepareTable(\JTable $table)
 {
     $date = DateHelper::getDate();
     $user = $this->container->get('user');
     // Alias
     if (property_exists($table, 'alias')) {
         if (!$table->alias) {
             $table->alias = JFilterOutput::stringURLSafe(trim($table->title));
         } else {
             $table->alias = JFilterOutput::stringURLSafe(trim($table->alias));
         }
         if (!$table->alias) {
             $table->alias = JFilterOutput::stringURLSafe($date->toSql(true));
         }
     }
     // Created date
     if (property_exists($table, 'created') && !$table->created) {
         $table->created = $date->toSql();
     }
     // Publish_up date
     if (property_exists($table, 'publish_up') && !$table->publish_up) {
         $table->publish_up = $this->db->getNullDate();
     }
     // Modified date
     if (property_exists($table, 'modified') && $table->id) {
         $table->modified = $date->toSql();
     }
     // Created user
     if (property_exists($table, 'created_by') && !$table->created_by) {
         $table->created_by = $user->get('id');
     }
     // Modified user
     if (property_exists($table, 'modified_by') && $table->id) {
         $table->modified_by = $user->get('id');
     }
     // Set Ordering or Nested ordering
     if (property_exists($table, 'ordering')) {
         if (empty($table->id)) {
             $this->setOrderPosition($table);
         }
     }
 }
コード例 #6
0
ファイル: finder.php プロジェクト: beingsane/quickcontent
 /**
  * convertPath
  *
  * @param string $path
  *
  * @return  string
  */
 protected function convertPath($path)
 {
     $user = Container::getInstance()->get('user');
     $date = DateHelper::getDate();
     $replace = array('username' => $user->username, 'name' => $user->name, 'session' => \JFactory::getSession()->getId(), 'year' => $date->year, 'month' => $date->month, 'day' => $date->day);
     return String::parseVariable($path, $replace);
 }
コード例 #7
0
ファイル: uploadimage.php プロジェクト: ForAEdesWeb/AEW13
 /**
  * Method to attach a JForm object to the field.
  *  Catch upload files when form setup.
  *
  * @param   SimpleXMLElement $element  The JXmlElement object representing the <field /> tag for the form field object.
  * @param   mixed            $value    The form field value to validate.
  * @param   string           $group    The field name group control value. This acts as as an array container for the field.
  *                                     For example if the field has name="foo" and the group value is set to "bar" then the
  *                                     full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  */
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     parent::setup($element, $value, $group);
     $container = \Windwalker\DI\Container::getInstance();
     $input = $container->get('input');
     $delete = isset($_REQUEST['jform']['profile'][$this->element['name'] . '_delete']) ? $_REQUEST['jform']['profile'][$this->element['name'] . '_delete'] : 0;
     if ($delete == 1) {
         $this->value = '';
     } else {
         // Upload Image
         // ===============================================
         if (isset($_FILES['jform']['name']['profile'])) {
             foreach ($_FILES['jform']['name']['profile'] as $key => $var) {
                 if (!$var) {
                     continue;
                 }
                 // Get Field Attr
                 $width = $this->element['save_width'] ? $this->element['save_width'] : 800;
                 $height = $this->element['save_height'] ? $this->element['save_height'] : 800;
                 // Build File name
                 $src = $_FILES['jform']['tmp_name']['profile'][$key];
                 $var = explode('.', $var);
                 $date = DateHelper::getDate();
                 $name = md5((string) $date . $width . $height . $src) . '.' . array_pop($var);
                 $url = "images/cck/{$date->year}/{$date->month}/{$date->day}/" . $name;
                 // A Event for extend.
                 $container->get('event.dispatcher')->trigger('onCCKEngineUploadImage', array(&$url, &$this, &$this->element));
                 $dest = JPATH_ROOT . '/' . $url;
                 // Upload First
                 JFile::upload($src, $dest);
                 // Resize image
                 $img = new JImage();
                 $img->loadFile(JPATH_ROOT . '/' . $url);
                 $img = $img->resize($width, $height);
                 switch (array_pop($var)) {
                     case 'gif':
                         $type = IMAGETYPE_GIF;
                         break;
                     case 'png':
                         $type = IMAGETYPE_PNG;
                         break;
                     default:
                         $type = IMAGETYPE_JPEG;
                         break;
                 }
                 // Save
                 $img->toFile($dest, $type, array('quality' => 85));
                 // Set in Value
                 $this->value = $url;
                 // Clean cache
                 $thumb = $this->getThumbPath();
                 if (is_file(JPATH_ROOT . '/' . $thumb)) {
                     \JFile::delete(JPATH_ROOT . '/' . $thumb);
                 }
             }
         }
     }
     return true;
 }
コード例 #8
0
ファイル: item.php プロジェクト: beingsane/facebook-importer
 /**
  * replaceText
  *
  * @param \stdClass $item
  * @param string    $text
  * @param integer   $id
  *
  * @return  string
  */
 public function replaceText($item, $text, $id)
 {
     $date = DateHelper::getDate('now');
     $params = $this->getParams();
     // Video type
     $link = base64_decode($item['link']);
     $r = $this->handleVideoType($link);
     $platform = $r['platform'];
     $vid = $r['vid'];
     // Handel message
     $message = nl2br($item['message']);
     $message = str_replace("\n", '', $message);
     $message = str_replace("\r", '', $message);
     $message = explode('<br /><br />', $message);
     $intro = array_shift($message);
     $full = implode('<br /><br />', $message);
     // Handle image
     $uri = JUri::getInstance(base64_decode($item['picture']));
     $width = $params->get('image_width', 550);
     $image = $uri->getVar('url');
     if (!$image) {
         $image = str_replace('_s.', '_n.', base64_decode($item['picture']));
     }
     $width = $width ? $width . 'px' : '';
     $image = '<img src="' . $image . '" alt="' . $item['title'] . '" style="max-width: ' . $width . ';" />';
     // Set replaces
     $replace['{TITLE}'] = $item['title'];
     $replace['{VIDEO}'] = $vid ? "{{$platform}}{$vid}{/{$platform}}" : $vid;
     $replace['{INTRO_MESSAGE}'] = $this->addLink($intro);
     $replace['{IMAGE}'] = $image;
     $replace['{LINK_URL}'] = $link;
     $replace['{FULL_MESSAGE}'] = $this->addLink($full);
     $replace['{READMORE_LINK}'] = "http://www.facebook.com/" . $params->get('fb_uid') . "/posts/{$id}";
     $replace['{LINK_NAME}'] = $item['name'];
     $replace['{LIKES}'] = $item['likes'];
     $replace['{CREATED_TIME}'] = $date->toSQL(true);
     $text = strtr($text, $replace);
     return $text;
 }
コード例 #9
0
 /**
  * Method of test testNullInput()
  *
  * @return void
  *
  * @covers \Windwalker\Helper\DateHelper::getDate
  */
 public function testNullInput()
 {
     $getOutput = DateHelper::getDate(null, null)->format('Y-m-d H:i:s');
     $this->assertRegExp('(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})', $getOutput);
 }
コード例 #10
0
 /**
  * Convert some common fields to server timezone.
  *
  * @param   object  $item    The item data object.
  * @param   array   $fields  The fields we want to convert.
  *
  * @return  object  Return converted data.
  */
 public static function itemDatesToServer($item, array $fields = null)
 {
     if (!is_object($item)) {
         throw new \InvalidArgumentException('Item should be object.');
     }
     if (!$fields) {
         $fields = array('created', 'publish_up', 'publish_down', 'modified');
     }
     foreach ($fields as $field) {
         if (property_exists($item, $field)) {
             $item->{$field} = DateHelper::toServerTime($item->{$field});
         }
     }
     return $item;
 }
コード例 #11
0
<?php

use Asika\Sitemap\Sitemap;
use Ezset\Library\Article\ArticleHelper;
use Windwalker\Helper\DateHelper;
use Windwalker\Helper\UriHelper;
defined('_JEXEC') or die;
// Get some datas
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$linkCache = array();
$date = DateHelper::getDate('now');
// Routing for prepare some required info for languageFilter plugin
$uri = clone JUri::getInstance();
$router = $app::getRouter();
$result = $router->parse($uri);
// Locale
$locale = null;
if (JLanguageMultilang::isEnabled()) {
    $locale = JFactory::getLanguage()->getTag();
}
// Get XML parser
$sitemap = new Sitemap();
$xml = simplexml_load_string('<?xml version="1.0" encoding="utf-8"?' . '>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />');
// Set frontpage
$sitemap->addItem(JUri::root(), '0.9', 'daily', $date);
// Build menu map
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select("*")->from("#__menu")->where("id != 1")->where("published=1")->where("access=1");