本文整理汇总了PHP中Limb类的典型用法代码示例。如果您正苦于以下问题:PHP Limb类的具体用法?PHP Limb怎么用?PHP Limb使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Limb类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run(&$filter_chain, &$request, &$response)
{
$toolkit =& Limb :: toolkit();
$action_resolver =& $toolkit->getRequestResolver('action');
$service_resolver =& $toolkit->getRequestResolver('service');
if(!is_object($service_resolver) || !is_object($action_resolver))
return throw_error(new LimbException('request resolvers not set'));
$service =& $service_resolver->resolve($request);
if(!$action =& $action_resolver->resolve($request))
{
$toolkit->setService($service);
}
elseif($service->actionExists($action))
{
$service->setCurrentAction($action);
$toolkit->setService($service);
}
else
{
$service404 = new Service('404');
$toolkit->setService($service404);
}
$filter_chain->next();
}
示例2: run
function run()
{
$this->_registerFileResolvers();
$this->_registerToolkit();
$this->_loadPackages();
$toolkit =& Limb :: toolkit();
$request =& $toolkit->getRequest();
$response =& $toolkit->getResponse();
$filter_chain = new FilterChain($request, $response);
$this->_registerFilters($filter_chain);
$filter_chain->process();
if(catch_error('LimbException', $e))
{
Debug :: writeException($e);
}
elseif(catch_error('LimbException', $e))
{
echo 'Unexpected PHP exception in ' . $e->getFile() . ' in line ' . $e->getLine();
echo '<br>';
echo '<pre>';
echo $e->getTraceAsString();
echo '</pre>';
echo 'Report this error to the LIMB developers, please.';
exit();
}
}
示例3: getValue
function getValue()
{
$value = $this->base->getValue();
$locale_value = $this->_getLocale();
$toolkit =& Limb :: toolkit();
$locale =& $toolkit->getLocale($locale_value);
if(isset($this->parameters[2]) && $this->parameters[2]->getValue())
$fract_digits = $this->parameters[2]->getValue();
else
$fract_digits = $locale->fract_digits;
if(isset($this->parameters[3]) && $this->parameters[3]->getValue())
$decimal_symbol = $this->parameters[3]->getValue();
else
$decimal_symbol = $locale->decimal_symbol;
if(isset($this->parameters[4]) && $this->parameters[4]->getValue())
$thousand_separator = $this->parameters[4]->getValue();
else
$thousand_separator = $locale->thousand_separator;
if ($this->isConstant())
return number_format($value, $fract_digits, $decimal_symbol, $thousand_separator);
else
RaiseError('compiler', 'UNRESOLVED_BINDING');
}
示例4: testFetch
function testFetch()
{
$time = mktime(6, 0, 0, 3, 6, 2005);
$day = 24 * 60 * 60;
$toolkit =& Limb::toolkit();
$db_table =& $toolkit->createDBTable('StatsUri');
$db_table->insert(array('id' => $uri_id1 = 1, 'uri' => $uri1 = '/news'));
$db_table->insert(array('id' => $uri_id2 = 2, 'uri' => $uri2 = '/articles'));
$db_table =& $toolkit->createDBTable('StatsHit');
$db_table->insert(array('stats_referer_id' => 1, 'session_id' => 'any', 'stats_uri_id' => $uri_id1, 'action' => 'any', 'time' => $time1 = $time, 'ip' => $ip = Ip::encode('192.168.0.1')));
$db_table->insert(array('stats_referer_id' => 1, 'session_id' => 'any', 'stats_uri_id' => $uri_id1, 'action' => 'any', 'time' => $time2 = $time + $day, 'ip' => $ip));
$db_table->insert(array('stats_referer_id' => 1, 'session_id' => 'any', 'stats_uri_id' => $uri_id1, 'action' => 'any', 'time' => $time3 = $time + $day, 'ip' => $ip));
$db_table->insert(array('stats_referer_id' => 1, 'session_id' => 'any', 'stats_uri_id' => $uri_id2, 'action' => 'any', 'time' => $time4 = $time + 2 * $day, 'ip' => $ip));
$db_table->insert(array('stats_referer_id' => 1, 'session_id' => 'any', 'stats_uri_id' => $uri_id1, 'action' => 'any', 'time' => $time5 = $time + 3 * $day, 'ip' => $ip));
$request =& $toolkit->getRequest();
$request->set('start_date', date('Y-m-d', $time2));
$request->set('finish_date', date('Y-m-d', $time5));
// Must find three records only
$dao = new StatsPagesReportDAO();
$rs =& $dao->fetch();
$this->assertTrue(is_a($rs, 'StatsPercentageRecordSet'));
$this->assertEqual($rs->getRowCount(), 2);
$rs->rewind();
$record =& $rs->current();
$this->assertEqual($record->get('uri'), $uri1);
$rs->next();
$record =& $rs->current();
$this->assertEqual($record->get('uri'), $uri2);
}
示例5: getDataset
public function getDataset(&$counter, $params = array())
{
$request = Limb::toolkit()->getRequest();
$datasource = Limb::toolkit()->getDatasource('RequestedObjectDatasource');
$datasource->setRequest($request);
if (!($arr = $datasource->fetch())) {
return new ArrayDataset();
}
$db_table = Limb::toolkit()->createDBTable('SysClass');
$classes = $db_table->getList('', 'class_name');
$result = array();
$params = array();
foreach ($classes as $class_id => $class_data) {
$result[$class_id] = $class_data;
$result[$class_id]['path'] = $arr['path'];
$params['class_id'] = $class_id;
$result[$class_id]['node_id'] = $arr['node_id'];
foreach ($arr['actions'] as $action_name => $action_params) {
$arr['actions'][$action_name]['extra'] = $params;
}
$result[$class_id]['actions'] = $arr['actions'];
}
$counter = sizeof($result);
return new ArrayDataset($result);
}
示例6: perform
public function perform()
{
$request = Limb::toolkit()->getRequest();
$response = Limb::toolkit()->getResponse();
$datasource = Limb::toolkit()->getDatasource('RequestedObjectDatasource');
$datasource->setRequest($request);
if (!($object_data = $datasource->fetch())) {
return Limb::STATUS_ERROR;
}
if (!file_exists(MEDIA_DIR . $object_data['media_id'] . '.media')) {
$response->header("HTTP/1.1 404 Not found");
if (!$request->hasAttribute('icon')) {
return Limb::STATUS_ERROR;
}
$response->commit();
//for speed
return;
//for tests, fix!!!
}
if ($request->hasAttribute('icon')) {
$this->_fillIconResponse($response, $request, $object_data);
$response->commit();
//for speed
return;
//for tests, fix!!!
}
$response->header("Content-type: {$object_data['mime_type']}");
$response->header('Content-Disposition: attachment; filename="' . $object_data['file_name'] . '"');
$response->readfile(MEDIA_DIR . $object_data['media_id'] . '.media');
return Limb::STATUS_OK;
}
示例7: perform
function perform(&$request, &$response)
{
if ($request->hasAttribute('popup')) {
$response->write(closePopupNoParentReloadResponse());
}
$request->setStatus(Request::STATUS_FAILURE);
if (!($version = $request->get('version'))) {
return;
}
if (!($node_id = $request->get('version_node_id'))) {
return;
}
$toolkit =& Limb::toolkit();
$datasource =& $toolkit->getDatasource('SingleObjectDatasource');
$datasource->setNodeId($node_id);
if (!($site_object = wrapWithSiteObject($datasource->fetch()))) {
return;
}
if (!is_subclass_of($site_object, 'ContentObject')) {
return;
}
if (!$site_object->recoverVersion((int) $version)) {
return;
}
if ($request->hasAttribute('popup')) {
$response->write(closePopupResponse($request));
}
$request->setStatus(Request::STATUS_SUCCESS);
}
示例8: tearDown
function tearDown()
{
$this->toolkit->tally();
$this->tree->tally();
Limb :: popToolkit();
}
示例9: tearDown
function tearDown()
{
$this->toolkit->tally();
$this->authorizer->tally();
ClearTestingTemplates();
Limb::restoreToolkit('SimpleACL');
}
示例10: getDataset
public function getDataset(&$counter, $params = array())
{
$request = Limb::toolkit()->getRequest();
if (!($class_id = $request->get('class_id'))) {
return new ArrayDataset();
}
$db_table = Limb::toolkit()->createDBTable('SysClass');
$class_data = $db_table->getRowById($class_id);
if (!$class_data) {
return new ArrayDataset();
}
$site_object = Limb::toolkit()->createSiteObject($class_data['ClassName']);
$site_object_controller = $site_object->getController();
$actions = $site_object_controller->getActionsDefinitions();
$result = array();
foreach ($actions as $action => $action_params) {
if (!isset($action_params['can_have_access_template']) || !$action_params['can_have_access_template']) {
continue;
}
if (isset($action_params['action_name'])) {
$result[$action]['action_name'] = $action_params['action_name'];
} else {
$result[$action]['action_name'] = str_replace('_', ' ', strtoupper($action[0]) . substr($action, 1));
}
}
$counter = sizeof($result);
return new ArrayDataset($result);
}
示例11: tearDown
function tearDown()
{
$this->toolkit->tally();
$this->uow->tally();
Limb :: restoreToolkit();
}
示例12: perform
public function perform()
{
$toolkit = Limb::toolkit();
$toolkit->getUser()->logout();
$toolkit->getResponse()->redirect('/');
return LIMB::STATUS_OK;
}
示例13: run
public function run($filter_chain, $request, $response)
{
Debug::addTimingPoint('authentication filter started');
$this->initializeUser();
$toolkit = Limb::toolkit();
$datasource = $toolkit->getDatasource('RequestedObjectDatasource');
if (!($node = $datasource->mapRequestToNode($request))) {
$this->process404Error($request, $response);
$filter_chain->next();
return;
}
$behaviour = $this->getBehaviourByObjectId($node['object_id']);
$controller = $this->_getController($behaviour);
if (!($action = $controller->getRequestedAction())) {
$this->process404Error($request, $response);
$filter_chain->next();
return;
}
$datasource->setRequest($request);
if (!($object_data = $datasource->fetch())) {
$response->redirect('/root/login?redirect=' . urlencode($_SERVER['REQUEST_URI']));
return;
}
$authoriser = Limb::toolkit()->getAuthorizer();
$authoriser->assignActionsToObjects($object_data);
if (!isset($object_data['actions']) || !isset($object_data['actions'][$action])) {
$response->redirect('/root/login?redirect=' . urlencode($_SERVER['REQUEST_URI']));
return;
}
$filter_chain->next();
}
示例14: validate
public function validate($dataspace)
{
if(!$value = $dataspace->get($this->field_name))
return;
$tree = Limb :: toolkit()->getTree();
if(!$tree->isNode($this->parent_node_id))
return;
if(!$nodes = $tree->getChildren($this->parent_node_id))
return;
foreach($nodes as $id => $node)
{
if($node['identifier'] != $value)
continue;
if($this->node_id == self :: UNKNOWN_NODE_ID)
{
$this->error(Strings :: get('error_duplicate_tree_identifier', 'error'));
break;
}
elseif($id != $this->node_id)
{
$this->error(Strings :: get('error_duplicate_tree_identifier', 'error'));
break;
}
}
}
示例15: getCounterRecord
function getCounterRecord()
{
$toolkit =& Limb :: toolkit();
$db =& new SimpleDb($toolkit->getDbConnection());
$db->select('sys_stat_counter', '*');
return $db->getRow();
}