本文整理汇总了PHP中JApplicationCli::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationCli::getInstance方法的具体用法?PHP JApplicationCli::getInstance怎么用?PHP JApplicationCli::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JApplicationCli
的用法示例。
在下文中一共展示了JApplicationCli::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
JLog::add(new JLogEntry(__METHOD__, JLOG::DEBUG, 'lib_j2xml'));
// Merge the default translation with the current translation
$jlang = JFactory::getLanguage();
$jlang->load('lib_j2xml', JPATH_SITE, 'en-GB', true);
$jlang->load('lib_j2xml', JPATH_SITE, $jlang->getDefault(), true);
$jlang->load('lib_j2xml', JPATH_SITE, null, true);
$db = JFactory::getDBO();
$user = JFactory::getUser();
$this->_nullDate = $db->getNullDate();
$this->_user_id = $user->get('id');
$this->_now = class_exists('JPlatform') && version_compare(JPlatform::RELEASE, '12', 'ge') ? JFactory::getDate()->format("%Y-%m-%d-%H-%M-%S") : JFactory::getDate()->toFormat("%Y-%m-%d-%H-%M-%S");
$this->_option = PHP_SAPI != 'cli' ? JRequest::getCmd('option') : 'cli_' . strtolower(get_class(JApplicationCli::getInstance()));
$execute = class_exists('JPlatform') && version_compare(JPlatform::RELEASE, '12', 'ge') ? 'execute' : 'query';
$db->setQuery("\r\n\t\t\tCREATE TABLE IF NOT EXISTS `#__j2xml_usergroups` (\r\n\t\t\t\t`id` int(10) unsigned NOT NULL,\r\n\t\t\t\t`parent_id` int(10) unsigned NOT NULL DEFAULT '0',\r\n\t\t\t\t`title` varchar(100) NOT NULL DEFAULT ''\r\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\t\t\t")->{$execute}();
$db->setQuery("\r\n\t\t\tTRUNCATE TABLE\r\n\t\t\t\t`#__j2xml_usergroups`;\r\n\t\t\t")->{$execute}();
$db->setQuery("\r\n\t\t\tINSERT INTO\r\n\t\t\t\t`#__j2xml_usergroups`\r\n\t\t\tSELECT\r\n\t\t\t\t`id`,`parent_id`,CONCAT('[\"',REPLACE(`title`,'\"','\\\"'),'\"]')\r\n\t\t\tFROM\r\n\t\t\t\t`#__usergroups`;\r\n\t\t\t")->{$execute}();
do {
$db->setQuery("\r\n\t\t\t\tUPDATE\r\n\t\t\t\t\t`#__j2xml_usergroups` j\r\n\t\t\t\tINNER JOIN\r\n\t\t\t\t\t`#__usergroups` g\r\n\t\t\t\tON\r\n\t\t\t\t\tj.parent_id = g.id\r\n\t\t\t\tSET\r\n\t\t\t\t\tj.parent_id = g.parent_id,\r\n\t\t\t\t\tj.title = CONCAT('[\"',REPLACE(`g`.`title`,'\"','\\\"'), '\",', SUBSTR(`j`.`title`,2));\r\n\t\t\t\t")->{$execute}();
$n = $db->setQuery("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tCOUNT(*)\r\n\t\t\t\tFROM\r\n\t\t\t\t\t`#__j2xml_usergroups`\r\n\t\t\t\tWHERE\r\n\t\t\t\t\t`parent_id` > 0;\r\n\t\t\t\t")->loadResult();
} while ($n > 0);
$db->setQuery("\r\n\t\t\tINSERT INTO\r\n\t\t\t\t`#__j2xml_usergroups`\r\n\t\t\tSELECT\r\n\t\t\t\t`id`,`parent_id`,`title`\r\n\t\t\tFROM\r\n\t\t\t\t`#__usergroups`;\r\n\t\t\t")->{$execute}();
$this->_usergroups = $db->setQuery("SELECT `title`,`id` FROM `#__j2xml_usergroups`")->loadAssocList('title', 'id');
}
示例2: __construct
/**
* CONSTRUCTOR
* @param object $subject The object to observe
* @param object $params The object that holds the plugin parameters
* @since 1.5
*/
function __construct()
{
JLog::add(new JLogEntry(__METHOD__, JLOG::DEBUG, 'lib_j2xml'));
$execute = class_exists('JPlatform') && version_compare(JPlatform::RELEASE, '12', 'ge') ? 'execute' : 'query';
$db = JFactory::getDBO();
$db->setQuery("\r\n\t\t\t\t\tCREATE TABLE IF NOT EXISTS `#__j2xml_usergroups` (\r\n\t\t\t\t\t\t`id` int(10) unsigned NOT NULL,\r\n\t\t\t\t\t\t`parent_id` int(10) unsigned NOT NULL DEFAULT '0',\r\n\t\t\t\t\t\t`title` varchar(100) NOT NULL DEFAULT ''\r\n\t\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\t\t\t\t\t")->{$execute}();
$db->setQuery("\r\n\t\t\t\t\tTRUNCATE TABLE\r\n\t\t\t\t\t\t`#__j2xml_usergroups`;\r\n\t\t\t\t\t")->{$execute}();
$db->setQuery("\r\n\t\t\t\t\tINSERT INTO\r\n\t\t\t\t\t\t`#__j2xml_usergroups`\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t`id`,`parent_id`,CONCAT('[\"',REPLACE(`title`,'\"','\\\"'),'\"]')\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\t`#__usergroups`;\r\n\t\t\t\t\t")->{$execute}();
do {
$db->setQuery("\r\n\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t`#__j2xml_usergroups` j\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t`#__usergroups` g\r\n\t\t\t\t\tON\r\n\t\t\t\t\t\tj.parent_id = g.id\r\n\t\t\t\t\tSET\r\n\t\t\t\t\t\tj.parent_id = g.parent_id,\r\n\t\t\t\t\t\tj.title = CONCAT('[\"',REPLACE(`g`.`title`,'\"','\\\"'), '\",', SUBSTR(`j`.`title`,2));\r\n\t\t\t\t\t")->{$execute}();
$n = $db->setQuery("\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\tCOUNT(*)\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\t`#__j2xml_usergroups`\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t`parent_id` > 0;\r\n\t\t\t\t\t")->loadResult();
} while ($n > 0);
$this->option = PHP_SAPI != 'cli' ? JRequest::getCmd('option') : 'cli_' . strtolower(get_class(JApplicationCli::getInstance()));
}
示例3: invoke
function invoke($numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix)
{
// ensure that we are running in a joomla context
// we've not yet figured out how to bootstrap joomla, so we should
// not execute hooks if joomla is not loaded
if (defined('_JEXEC')) {
//Invoke the Joomla plugin system to observe to civicrm events.
jimport('joomla.plugin.helper');
jimport('cms.plugin.helper');
// Joomla 3.2
JPluginHelper::importPlugin('civicrm');
// get app based on cli or web
if (PHP_SAPI != 'cli') {
$app = JFactory::getApplication('administrator');
} else {
// condition on Joomla version
if (version_compare(JVERSION, '3.0', 'lt')) {
$app = JCli::getInstance();
} else {
$app = JApplicationCli::getInstance();
}
}
$result = $app->triggerEvent($fnSuffix, array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6));
$moduleResult = $this->commonInvoke($numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $fnSuffix, 'joomla');
if (!empty($moduleResult) && is_array($moduleResult)) {
if (empty($result)) {
$result = $moduleResult;
} else {
if (is_array($moduleResult)) {
$result = array_merge($result, $moduleResult);
}
}
}
if (!empty($result)) {
// collapse result returned from hooks
// CRM-9XXX
$finalResult = array();
foreach ($result as $res) {
if (!is_array($res)) {
$res = array($res);
}
$finalResult = array_merge($finalResult, $res);
}
$result = $finalResult;
}
return $result;
}
}
示例4: jgettext
*/
function jgettext($string)
{
return $string;
}
/**
* Dummy.
*/
class JUri
{
/**
* Dummy.
*
* @static
* @return string
*/
public static function root()
{
return '';
}
}
try {
//-- Execute the application.
JApplicationCli::getInstance('EcrCliBuilder')->execute();
exit(0);
} catch (Exception $e) {
//-- An exception has been caught, just echo the message.
fwrite(STDOUT, $e->getMessage() . "\n");
exit($e->getCode());
}
//try
示例5: int
DROP TABLE IF EXISTS `#__k2_recipe_map`;';
$query_set = $this->dbo->setQuery($query);
$this->dbo->execute();
$query = 'CREATE table `#__k2_recipe_map` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`k2_item_id` INT NOT NULL ,
`new_item_id` INT NOT NULL ,
`item_type` INT NOT NULL ,
PRIMARY KEY (`id`)
) ; ';
$query_set = $this->dbo->setQuery($query);
$this->dbo->execute();
}
public function getNewItemid($id)
{
$query = 'SELECT k2_item_id,new_item_id,item_type from #__k2_recipe_map where k2_item_id = ' . $id . ';';
$query_set = $this->dbo->setQuery($query);
$newitem = $this->dbo->loadObject();
return $newitem;
}
}
// Wrap the execution in a try statement to catch any exceptions thrown anywhere in the script.
try {
// Instantiate the application object, passing the class name to JApplicationCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('FindHrefsApp')->execute();
} catch (Exception $e) {
// An exception has been caught, just echo the message.
fwrite(STDOUT, $e->getMessage() . "\n");
exit($e->getCode());
}
示例6: define
if (!defined('_JDEFINES')) {
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
// Get the framework.
require_once JPATH_LIBRARIES . '/import.legacy.php';
// Bootstrap the CMS libraries.
require_once JPATH_LIBRARIES . '/cms.php';
/**
* Cron job to trash expired cache data
*
* @package Joomla.Cli
* @since 2.5
*/
class GarbageCron extends JApplicationCli
{
/**
* Entry point for the script
*
* @return void
*
* @since 2.5
*/
public function doExecute()
{
$cache = JFactory::getCache();
$cache->gc();
}
}
JApplicationCli::getInstance('GarbageCron')->execute();
示例7: doExecute
* This script will fetch the update information for all extensions and store
* them in the database, speeding up your administrator.
*
* @package Joomla.Cli
* @since 2.5
*/
class Updatecron extends JApplicationCli
{
/**
* Entry point for the script
*
* @return void
*
* @since 2.5
*/
public function doExecute()
{
// Get the update cache time
$component = JComponentHelper::getComponent('com_installer');
$params = $component->params;
$cache_timeout = $params->get('cachetimeout', 6, 'int');
$cache_timeout = 3600 * $cache_timeout;
// Find all updates
$this->out('Fetching updates...');
$updater = JUpdater::getInstance();
$updater->findUpdates(0, $cache_timeout);
$this->out('Finished fetching updates');
}
}
JApplicationCli::getInstance('Updatecron')->execute();
示例8: getPaymentsForChecking
$paymentNew->retry_counter -= 1;
RApiPaymentHelper::updatePaymentCounter($paymentNew->id, $paymentNew->retry_counter);
$this->out('Retry checks left: ' . $paymentNew->retry_counter);
}
$this->out('============================');
}
}
$this->out('============================');
$this->out('Done !');
}
/**
* Get payments pending for checking
*
* @return mixed
*/
public function getPaymentsForChecking()
{
$db = JFactory::getDbo();
$finalStatuses = array();
$retryTime = RBootstrap::getConfig('payment_time_between_payment_check_requests', 24);
foreach ($this->finalStatuses as $status) {
$finalStatuses[] = $db->q($status);
}
$query = $db->getQuery(true)->select('p.*')->from($db->qn('#__redcore_payments', 'p'))->where('p.status NOT IN (' . implode(',', $finalStatuses) . ')')->where('p.retry_counter > 0')->where('TIMESTAMPDIFF(HOUR, p.modified_date, NOW()) > ' . (int) $retryTime);
$db->setQuery($query);
$items = $db->loadObjectList();
return $items;
}
}
JApplicationCli::getInstance('CheckpaymentsApplicationCli')->execute();
示例9: doExecute
* A command line cron job to attempt to remove files that should have been deleted at update.
*
* @package Joomla.Cli
* @since 3.0
*/
class DeletefilesCli extends JApplicationCli
{
/**
* Entry point for CLI script
*
* @return void
*
* @since 3.0
*/
public function doExecute()
{
// Import the dependencies
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
// We need the update script
JLoader::register('JoomlaInstallerScript', JPATH_ADMINISTRATOR . '/components/com_admin/script.php');
// Instantiate the class
$class = new JoomlaInstallerScript();
// Run the delete method
$class->deleteUnexistingFiles();
}
}
// Instantiate the application object, passing the class name to JCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('DeletefilesCli')->execute();
示例10: microtime
$c = $c === 0 ? 1 : $c;
try {
// Process the batches.
for ($i = 0; $i < $c; $i++) {
// Set the batch start time.
$this->_qtime = microtime(true);
// Reset the batch offset.
$state->batchOffset = 0;
// Trigger the onBuildIndex event.
JEventDispatcher::getInstance()->trigger('onBuildIndex');
// Batch reporting.
$this->out(JText::sprintf('FINDER_CLI_BATCH_COMPLETE', $i + 1, round(microtime(true) - $this->_qtime, 3)), true);
}
} catch (Exception $e) {
// Display the error
$this->out($e->getMessage(), true);
// Reset the indexer state.
FinderIndexer::resetState();
// Close the app
$this->close($e->getCode());
}
// Total reporting.
$this->out(JText::sprintf('FINDER_CLI_PROCESS_COMPLETE', round(microtime(true) - $this->_time, 3)), true);
// Reset the indexer state.
FinderIndexer::resetState();
}
}
// Instantiate the application object, passing the class name to JCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('FinderCli')->execute();
示例11: doExecute
* @since 3.0
*/
class GenerateCss extends JApplicationCli
{
/**
* Entry point for the script
*
* @return void
*
* @since 3.0
*/
public function doExecute()
{
$templates = array(JPATH_ADMINISTRATOR . '/templates/isis/less/template.less' => JPATH_ADMINISTRATOR . '/templates/isis/css/template.css', JPATH_ADMINISTRATOR . '/templates/isis/less/template-rtl.less' => JPATH_ADMINISTRATOR . '/templates/isis/css/template-rtl.css', JPATH_ADMINISTRATOR . '/templates/hathor/less/template.less' => JPATH_ADMINISTRATOR . '/templates/hathor/css/template.css', JPATH_ADMINISTRATOR . '/templates/hathor/less/colour_blue.less' => JPATH_ADMINISTRATOR . '/templates/hathor/css/colour_blue.css', JPATH_ADMINISTRATOR . '/templates/hathor/less/colour_brown.less' => JPATH_ADMINISTRATOR . '/templates/hathor/css/colour_brown.css', JPATH_ADMINISTRATOR . '/templates/hathor/less/colour_standard.less' => JPATH_ADMINISTRATOR . '/templates/hathor/css/colour_standard.css', JPATH_SITE . '/templates/protostar/less/template.less' => JPATH_SITE . '/templates/protostar/css/template.css', __DIR__ . '/less/bootstrap-extended.less' => JPATH_SITE . '/media/jui/css/bootstrap-extended.css', __DIR__ . '/less/bootstrap-rtl.less' => JPATH_SITE . '/media/jui/css/bootstrap-rtl.css');
// Load the RAD layer
if (!defined('FOF_INCLUDED')) {
require_once JPATH_LIBRARIES . '/fof/include.php';
}
$less = new FOFLess();
$less->setFormatter(new FOFLessFormatterJoomla());
foreach ($templates as $source => $output) {
try {
$less->compileFile($source, $output);
} catch (Exception $e) {
echo $e->getMessage();
}
}
}
}
JApplicationCli::getInstance('GenerateCss')->execute();
示例12: count
print "\n\n";
print "\nMatching against " . count($rules) . " rules \n";
// Get all the log files that need to be processed.
$files = JFolder::files(JPATH_BASE . "/logs", $filter = '.php');
foreach ($files as $file) {
$logs = file_get_contents(JPATH_BASE . "/logs/" . $file);
$matches = [];
preg_match_all("/(.*)\t(.*) (.*)\t(.*)\t(.*)/", $logs, $matches);
// regex based on the format in the Joomla JLogLoggerFormattedtext class
// matches 1 will have date matches 2 will have priority matches 4 will have category and matches 5 message
for ($i = 0; $i < count($matches); $i++) {
$log_date = $matches[1][$i];
$log_level = $matches[2][$i];
$log_category = $matches[4][$i];
$log_message = $matches[5][$i];
$sig = md5($log_category . $log_level);
if (isset($signatures[$sig])) {
$rule = $signatures[$sig];
// Now process the log files checking each element against a sig and if it matches taking the appropriate action via the plugin.
echo "Sig match for " . $matches[0][$i] . "\n";
JEventDispatcher::getInstance()->trigger("doSendLog", array(array("date" => $log_date, "level" => $log_level, "category" => $log_category, "log_message" => $log_message), $rule));
}
}
}
// Push into the database so that we don't keep messaging using a variation of the signature
}
}
// Instantiate the application object, passing the class name to JCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('SimpleLoggerProcessLogs')->execute();
示例13: createCategories
{
//$query = "SELECT * from #__k2_categories WHERE trash != 1 and published = 1 and extraFieldsGroup = 1 order by id;" ;
$query = "SELECT * from #__k2_categories WHERE trash != 1 and published = 1 order by id;";
$query_set = $this->dbo->setQuery($query);
$categories = $this->dbo->loadObjectList();
return $categories;
}
public function createCategories($cats)
{
foreach ($cats as $key => $category) {
//$this->out("Category Object --> " . print_r($category,true));
$k2_catid = $category->id;
//$this->out(print_r($params,true));
if ($category->extraFieldsGroup == 1) {
$this->recipe_catids = $this->recipe_catids . ', ' . $category->id;
} else {
$this->article_catids = $this->article_catids . ', ' . $category->id;
}
}
}
}
// Wrap the execution in a try statement to catch any exceptions thrown anywhere in the script.
try {
// Instantiate the application object, passing the class name to JApplicationCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('ExtractK2Ingredients')->execute();
} catch (Exception $e) {
// An exception has been caught, just echo the message.
fwrite(STDOUT, $e->getMessage() . "\n");
exit($e->getCode());
}
示例14: getTemplate
// Let's cleanup the downloaded archive and the temp folder
if (JFolder::exists($package['extractdir'])) {
JFolder::delete($package['extractdir']);
}
if (JFile::exists($package['packagefile'])) {
JFile::delete($package['packagefile']);
}
if ($installed) {
$this->out("Extension successfully installed");
$this->close(0);
} else {
$this->out("Extension installation failed");
$this->close(250);
}
}
public function getTemplate($params = false)
{
return '';
}
public function setHeader($name, $value, $replace = false)
{
return $this;
}
public function getCfg($name, $default = null)
{
return $this->get($name, $default);
}
}
$app = JApplicationCli::getInstance('JoomlaExtensionInstallerCli');
JFactory::$application = $app;
$app->execute();
示例15: limit
$this->out("\t silent - yes/no. In case set to 'yes' only error messages are going to be displayed. Default set to 'yes'");
$this->out("\t section - section id of the section you want to crawl. If not given all valid sections are going to be crawled");
$this->out("\t timeLimit - time limit (in seconds - default 3600). If the limit has been reached while crawling the crawler will stop any actions");
$this->out("\t cleanCache - yes/no If set to 'yes' the cache will be invalidated first. Default set to 'yes'");
$this->out("\t loopTimeLimit - time limit (in seconds - default 15) for a loop. When reached a new loop is going to be started");
$this->out('');
$this->out("All settings are defined like name=value (timeLimit=100). The order doesn't matter");
$this->out('');
$this->out('');
}
protected function SpOut($txt)
{
if (!$this->silent) {
$this->out($txt);
}
}
/**
* @param SPRemote $connection
* @param string $url
* @return array
*/
protected function SpConnect($connection, $url)
{
$connection->setOptions(array('url' => $url, 'connecttimeout' => 10, 'returntransfer' => true, 'useragent' => self::USER_AGENT, 'header' => true, 'verbose' => false));
$content = $connection->exec();
$response = $connection->info();
return array($content, $response);
}
}
JApplicationCli::getInstance('SobiProCrawler')->execute($argv);