本文整理汇总了PHP中sfLoader类的典型用法代码示例。如果您正苦于以下问题:PHP sfLoader类的具体用法?PHP sfLoader怎么用?PHP sfLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticateUserRequest
public function authenticateUserRequest()
{
$authResult = $this->authenticateKey($this->request->getParameter('_key'));
switch ($authResult) {
case self::AUTH_FAIL_KEY:
$this->response->setStatusCode(401);
sfLoader::loadHelpers('Partial');
$partial = get_partial('global/401');
$this->response->setContent($partial);
$this->response->setHttpHeader('WWW-Authenticate', 'Your request must include a query parameter named "_key" with a valid API key value. To obtain an API key, visit http://api.littlesis.org/register');
$this->response->sendHttpHeaders();
$this->response->sendContent();
throw new sfStopException();
break;
case self::AUTH_FAIL_LIMIT:
$this->response = sfContext::getInstance()->getResponse();
$this->response->setStatusCode(403);
$user = Doctrine::getTable('ApiUser')->findOneByApiKey($this->request->getParameter('_key'));
sfLoader::loadHelpers('Partial');
$partial = get_partial('global/403', array('request_limit' => $user->request_limit));
$this->response->setContent($partial);
$this->response->sendHttpHeaders();
$this->response->sendContent();
throw new sfStopException();
break;
case self::AUTH_SUCCESS:
break;
default:
throw new Exception("Invalid return value from LsApi::autheticate()");
}
}
示例2: run_propel_init_admin
function run_propel_init_admin($task, $args)
{
if (count($args) < 2) {
throw new Exception('You must provide your module name.');
}
if (count($args) < 3) {
throw new Exception('You must provide your model class name.');
}
$app = $args[0];
$module = $args[1];
$model_class = $args[2];
$theme = isset($args[3]) ? $args[3] : 'default';
try {
$author_name = $task->get_property('author', 'symfony');
} catch (pakeException $e) {
$author_name = 'Your name here';
}
$constants = array('PROJECT_NAME' => $task->get_property('name', 'symfony'), 'APP_NAME' => $app, 'MODULE_NAME' => $module, 'MODEL_CLASS' => $model_class, 'AUTHOR_NAME' => $author_name, 'THEME' => $theme);
$moduleDir = sfConfig::get('sf_root_dir') . '/' . sfConfig::get('sf_apps_dir_name') . '/' . $app . '/' . sfConfig::get('sf_app_module_dir_name') . '/' . $module;
// create module structure
$finder = pakeFinder::type('any')->ignore_version_control()->discard('.sf');
$dirs = sfLoader::getGeneratorSkeletonDirs('sfPropelAdmin', $theme);
foreach ($dirs as $dir) {
if (is_dir($dir)) {
pake_mirror($finder, $dir, $moduleDir);
break;
}
}
// customize php and yml files
$finder = pakeFinder::type('file')->ignore_version_control()->name('*.php', '*.yml');
pake_replace_tokens($finder, $moduleDir, '##', '##', $constants);
}
示例3: getCacheManifestFilesForConfig
protected function getCacheManifestFilesForConfig($config, $callback, $files = array())
{
$context = $this->getContext();
// compatibility with symfony 1.0:
if (method_exists($context, 'getConfiguration') && method_exists($context->getConfiguration(), 'loadHelpers')) {
$context->getConfiguration()->loadHelpers('Asset');
} else {
if (method_exists('sfLoader', 'loadHelpers')) {
sfLoader::loadHelpers('Asset');
//maintain compatibility to symfony versions prior to 1.3
}
}
foreach ($config as $key => $value) {
if (is_string($value)) {
$files[] = $callback($value);
} else {
if (is_array($value)) {
foreach ($value as $filename => $options) {
$files[] = $callback($filename);
}
}
}
}
return $files;
}
示例4: loadMapBuilderClasses
/**
* Loads map builder classes.
*
* This method is ORM dependant.
*
* @throws sfException
*/
protected function loadMapBuilderClasses()
{
// we must load all map builder classes to be able to deal with foreign keys (cf. editSuccess.php template)
$classes = sfFinder::type('file')->ignore_version_control()->name('*MapBuilder.php')->in(sfLoader::getModelDirs());
foreach ($classes as $class)
{
$class_map_builder = basename($class, '.php');
$maps[$class_map_builder] = new $class_map_builder();
if (!$maps[$class_map_builder]->isBuilt())
{
$maps[$class_map_builder]->doBuild();
}
if ($this->className == str_replace('MapBuilder', '', $class_map_builder))
{
$this->map = $maps[$class_map_builder];
}
}
if (!$this->map)
{
throw new sfException('The model class "'.$this->className.'" does not exist.');
}
$this->tableMap = $this->map->getDatabaseMap()->getTable(constant($this->className.'Peer::TABLE_NAME'));
}
示例5: getDecorator
public function getDecorator()
{
sfLoader::loadHelpers('Url');
sfLoader::loadHelpers('Tag');
$decorator = link_to('%s', '@hyperword_processor?word=%s', array('class' => 'hyperword'));
return str_replace('%25s', '%s', $decorator);
}
示例6: extractSummaryArray
public static function extractSummaryArray($body, $min, $total)
{
//replace whitespaces with space
$body = preg_replace("/(\\r?\\n[ \\t]*)+/", " ", $body);
//find paragraphs
$matches = array();
preg_match_all("/<p>(.+)<\\/p>/isU", $body, $matches, PREG_SET_ORDER);
//put paragraphs to a fresh array and calculate total length
$total_length = 0;
$paragraphs = array();
foreach ($matches as $match) {
$len = 0;
if (($len = strlen($match[1])) > $min) {
$paragraphs[] = $match[1];
$total_length += strlen($match[1]);
}
}
//chop paragraphs
sfLoader::loadHelpers('Text');
$final = array();
for ($i = 0; $i < sizeof($paragraphs); $i++) {
$share = (int) ($total * strlen($paragraphs[$i]) / $total_length);
if ($share < $min) {
$total_length -= strlen($paragraphs[$i]);
continue;
}
$final[] = truncate_text($paragraphs[$i], $share, "", true);
}
return $final;
}
示例7: loadHelper
public function loadHelper() {
sfLoader::loadHelpers('Date');
sfLoader::loadHelpers('Url');
sfLoader::loadHelpers('CalculateDate');
sfLoader::loadHelpers('ColorBuilder');
sfLoader::loadHelpers('I18N');
sfLoader::loadHelpers('Icon');
}
示例8: __construct
public function __construct(array $workflowtemplate, $workflowversionid) {
sfLoader::loadHelpers('Partial');
$this->workflowtemplate = $workflowtemplate;
$this->version = $workflowversionid;
$this->setUserSettings($workflowtemplate['sender_id']);
$this->sendWorkflowCompletedEmail();
}
示例9: get_config_dirs
function get_config_dirs($configPath)
{
$dirs = array();
foreach (sfLoader::getConfigPaths($configPath) as $dir) {
$dirs[] = $dir;
}
return array_map('strip_paths', $dirs);
}
示例10: __construct
public function __construct(sfContext $context_in, myUser $user) {
sfLoader::loadHelpers('I18N');
sfLoader::loadHelpers('Date');
sfLoader::loadHelpers('Url');
sfLoader::loadHelpers('CalculateDate');
sfLoader::loadHelpers('ColorBuilder');
$this->context = $context_in;
$this->user = $user;
}
示例11: render
public function render($name, $value = null, $attributes = array(), $errors = array())
{
sfLoader::loadHelpers('Javascript');
if ($this->getOption("plain")) {
return $value . input_hidden_tag($name, $value);
} else {
return input_auto_complete_tag($name, $value, 'tag/searchTag?src=' . $this->getOption('src'), array('autocomplete' => 'off', 'size' => '15'), array('use_style' => 'true'));
}
}
示例12: prepareRelData
public static function prepareRelData($rel)
{
sfLoader::loadHelpers(array("Asset", "Url"));
try {
$url = url_for(RelationshipTable::generateRoute($rel));
} catch (Exception $e) {
$url = "http://littlesis.org/relationship/view/id/" . $rel['id'];
}
return array("id" => self::integerize($rel["id"]), "entity1_id" => self::integerize($rel["entity1_id"]), "entity2_id" => self::integerize($rel["entity2_id"]), "category_id" => self::integerize($rel["category_id"]), "category_ids" => (array) self::integerize($rel["category_ids"]), "is_current" => self::integerize($rel["is_current"]), "end_date" => @$rel["end_date"], "value" => 1, "label" => $rel["label"], "url" => $url, "x1" => @$rel["x1"], "y1" => @$rel["y1"], "fixed" => true);
}
示例13: configure
/**
* Configures template for this view.
*/
public function configure()
{
$this->setDecorator(false);
$this->setTemplate($this->actionName . $this->getExtension());
if ('global' == $this->moduleName) {
$this->setDirectory(sfConfig::get('sf_app_template_dir'));
} else {
$this->setDirectory(sfLoader::getTemplateDir($this->moduleName, $this->getTemplate()));
}
}
示例14: executeGetIFrame
/**
* Action loads an IFrame for the email, when settings are set IFRAME and HTML
* the template getIframeSuccess.php adds the needed fields to the iframe
* @param sfWebRequest $request
* @return <type>
*/
public function executeGetIFrame(sfWebRequest $request) {
sfLoader::loadHelpers('Url', 'I18N');
$serverUrl = str_replace('/layout', '', url_for('layout/index', true));
$versionId = $request->getParameter('versionid');
$templateId = $request->getParameter('workflowid');
$userId = $request->getParameter('userid');
$userSettings = new UserMailSettings($userId);
$context = sfContext::getInstance();
$sf_i18n = $context->getI18N();
$sf_i18n->setCulture($userSettings->userSettings['language']);
$this->linkto = $context->getI18N()->__('Direct link to workflow' ,null,'sendstationmail');
$wfSettings = WorkflowVersionTable::instance()->getWorkflowVersionById($versionId);
$workflow = $wfSettings[0]->getWorkflowTemplate()->toArray();
$detailObj = new WorkflowDetail(false);
$detailObj->setServerUrl($serverUrl);
$detailObj->setCulture($userSettings->userSettings['language']);
$detailObj->setContext($context);
$editObj = new WorkflowEdit(false);
$editObj->setServerUrl($serverUrl);
$editObj->setContext($context);
$editObj->setCulture($userSettings->userSettings['language']);
$editObj->setUserId($userId);
$this->slots = $editObj->buildSlots($wfSettings , $versionId);
$content['workflow'][0] = $context->getI18N()->__('You have to fill out the fields in the workflow' ,null,'sendstationmail');
$content['workflow'][1] = $workflow[0]['name'];
$content['workflow'][2] = $context->getI18N()->__('Slot' ,null,'sendstationmail');
$content['workflow'][3] = $context->getI18N()->__('Yes' ,null,'sendstationmail');
$content['workflow'][4] = $context->getI18N()->__('No' ,null,'sendstationmail');
$content['workflow'][5] = $context->getI18N()->__('Field' ,null,'sendstationmail');
$content['workflow'][6] = $context->getI18N()->__('Value' ,null,'sendstationmail');
$content['workflow'][7] = $context->getI18N()->__('File' ,null,'sendstationmail');
$content['workflow'][8] = $context->getI18N()->__('Accept Workflow' ,null,'sendstationmail');
$content['workflow'][9] = $context->getI18N()->__('Deny Workflow' ,null,'sendstationmail');
$content['workflow'][10] = $context->getI18N()->__('Save' ,null,'sendstationmail');
$this->error = $request->getParameter('error',0);
$this->serverPath = $serverUrl;
$this->workflowverion = $versionId;
$this->userid = $userId;
$this->workflow = $templateId;
$this->text = $content;
$this->setLayout(false);
$this->setTemplate('getIFrame');
return sfView::SUCCESS;
}
示例15: display_page_header
function display_page_header($module, $document, $id, $metadata, $current_version, $options = array())
{
$is_archive = $document->isArchive();
$mobile_version = c2cTools::mobileVersion();
$content_class = $module . '_content';
$lang = $document->getCulture();
$version = $is_archive ? $document->getVersion() : NULL;
$slug = '';
$prepend = _option($options, 'prepend', '');
$separator = _option($options, 'separator', '');
$nav_options = _option($options, 'nav_options');
$item_type = _option($options, 'item_type', '');
$nb_comments = _option($options, 'nb_comments');
$creator_id = _option($options, 'creator_id');
if (!$is_archive) {
if ($module != 'users') {
$slug = get_slug($document);
$url = "@document_by_id_lang_slug?module={$module}&id={$id}&lang={$lang}&slug={$slug}";
} else {
$url = "@document_by_id_lang?module={$module}&id={$id}&lang={$lang}";
}
} else {
$url = "@document_by_id_lang_version?module={$module}&id={$id}&lang={$lang}&version={$version}";
}
if (!empty($prepend)) {
$prepend .= $separator;
}
echo display_title($prepend . $document->get('name'), $module, true, 'default_nav', $url);
if (!$mobile_version) {
echo '<div id="nav_space"> </div>';
sfLoader::loadHelpers('WikiTabs');
$tabs = tabs_list_tag($id, $lang, $document->isAvailable(), 'view', $version, $slug, $nb_comments);
echo $tabs;
// liens internes vers les sections repliables du document
if ($nav_options == null) {
include_partial("{$module}/nav_anchor");
} else {
include_partial("{$module}/nav_anchor", array('section_list' => $nav_options));
}
// boutons vers des fonctions annexes et de gestion du document
include_partial("{$module}/nav", isset($creator_id) ? array('id' => $id, 'document' => $document, 'creator_id' => $creator_id) : array('id' => $id, 'document' => $document));
if ($module != 'users') {
sfLoader::loadHelpers('Button');
echo '<div id="nav_share" class="nav_box">' . button_share() . '</div>';
}
}
echo display_content_top('doc_content', $item_type);
echo start_content_tag($content_class);
if ($merged_into = $document->get('redirects_to')) {
include_partial('documents/merged_warning', array('merged_into' => $merged_into));
}
if ($is_archive) {
include_partial('documents/versions_browser', array('id' => $id, 'document' => $document, 'metadata' => $metadata, 'current_version' => $current_version));
}
}