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()");
     }
 }
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);
}
 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;
 }
  /**
   * 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'));
  }
 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);
 }
 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;
 }
 public function loadHelper() {
     sfLoader::loadHelpers('Date');
     sfLoader::loadHelpers('Url');
     sfLoader::loadHelpers('CalculateDate');
     sfLoader::loadHelpers('ColorBuilder');
     sfLoader::loadHelpers('I18N');
     sfLoader::loadHelpers('Icon');
 }
    public function __construct(array $workflowtemplate, $workflowversionid) {
        sfLoader::loadHelpers('Partial');
        $this->workflowtemplate = $workflowtemplate;
        $this->version = $workflowversionid;
        $this->setUserSettings($workflowtemplate['sender_id']);
        $this->sendWorkflowCompletedEmail();

    }
function get_config_dirs($configPath)
{
    $dirs = array();
    foreach (sfLoader::getConfigPaths($configPath) as $dir) {
        $dirs[] = $dir;
    }
    return array_map('strip_paths', $dirs);
}
 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;
 }
 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'));
     }
 }
 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);
 }
 /**
  * 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()));
     }
 }
    /**
     * 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;
    }
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">&nbsp;</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));
    }
}
 public function configure()
 {
     $response = $this->getContext()->getResponse();
     $response->setParameter($this->moduleName . '_' . $this->actionName . '_layout', false, 'symfony/action/view');
     $response->setContentType('application/x-javascript');
     $this->setTemplate($this->actionName . $this->viewName . $this->getExtension());
     // Set template directory
     if (!$this->directory) {
         $this->setDirectory(sfLoader::getTemplateDir($this->moduleName, $this->getTemplate()));
     }
 }
 public function getSlotEditor($slot)
 {
     $options = array('size' => '80x10', 'id' => 'edit_textarea' . $slot->getName(), 'tinymce_options' => sfConfig::get('app_sfSimpleCMS_tinymce_options', 'width: "100%"'));
     $script = '';
     if (sfConfig::get('app_sfSimpleCMS_rich_editing', false)) {
         sfLoader::loadHelpers(array('Javascript'));
         sfContext::getInstance()->getResponse()->addJavascript('/sfSimpleCMSPlugin/js/tiny_mce_AJAX.js', 'last');
         $script = javascript_tag('setTextareaToTinyMCE("edit_textarea' . $slot->getName() . '");');
         $options['rich'] = 'TinyMCE';
     }
     return $script . textarea_tag('slot_content', $slot->getValue(), $options);
 }
 /**
  *
  * @param int $currentWorklfowSlotId, workflowslotid of the current slot
  * @param int $nextSlotId , SlotId of the next slot
  */
 public function  __construct($currentWorklfowSlotId, $nextWorkflowSlotId, $workflowtemplateId, $workflowversionId) { 
     sfLoader::loadHelpers('EndAction');
     $this->setWorkflowTemplateSettings($workflowtemplateId);
     if($this->checkState() == 1) {
         sfLoader::loadHelpers('Partial');
         $this->workflowVersionId = $workflowversionId;
         $this->setCurrentSlot($currentWorklfowSlotId);
         $this->setNextSlot($nextWorkflowSlotId);
         $this->setUserSettings();
         $this->sendSlotReachedMail();
     }
 }
 static function convertValueForDisplay($value, $field, $excerpt = 40)
 {
     if (is_null($value)) {
         return 'NULL';
     }
     if (!($mod = self::loadModification($field))) {
         return $value;
     }
     $table = Doctrine::getTable($mod['object_model']);
     $columns = $table->getColumns();
     if ($mod['object_model'] == 'Entity') {
         if (!array_key_exists($field['field_name'], $columns)) {
             if ($extensionName = EntityTable::getExtensionNameByFieldName($field['field_name'])) {
                 $table = Doctrine::getTable($extensionName);
             }
         }
     } elseif ($mod['object_model'] == 'Relationship') {
         if (!array_key_exists($field['field_name'], $columns)) {
             $table = Doctrine::getTable(RelationshipTable::getCategoryNameByFieldName($field['field_name']));
         }
     }
     if ($alias = self::getFieldNameAlias($field)) {
         $class = $table->getRelation($alias)->getClass();
         if ($record = Doctrine::getTable($class)->find($value, Doctrine::HYDRATE_ARRAY)) {
             if ($class == 'Entity') {
                 sfLoader::loadHelpers('Ls');
                 return entity_link($record, null);
             } elseif ($class == 'sfGuardUser') {
                 sfLoader::loadHelpers('Ls');
                 return user_link($record);
             }
             return $record;
         }
     }
     if (in_array($field['field_name'], array('start_date', 'end_date'))) {
         return Dateable::convertForDisplay($value);
     }
     $def = $table->getColumnDefinition($field['field_name']);
     switch ($def['type']) {
         case 'integer':
             return (double) $value;
             break;
         case 'boolean':
             return $value ? 'yes' : 'no';
             break;
     }
     if ($excerpt) {
         $short = LsString::excerpt($value, $excerpt);
         return $short == $value ? $value : '<span title="' . strip_tags($value) . '">' . $short . '</span>';
     }
     return $value;
 }
Beispiel #20
0
 /**
  * Evaluates a template file.
  *
  * @param string The template file path
  *
  * @return string The evaluated template
  */
 protected function evalTemplate($templateFile)
 {
     $templateFile = sfLoader::getGeneratorTemplate($this->getGeneratorClass(), $this->getTheme(), $templateFile);
     // eval template file
     ob_start();
     require $templateFile;
     $content = ob_get_clean();
     // replace [?php and ?]
     $content = $this->replacePhpMarks($content);
     $retval = "<?php\n" . "// auto-generated by " . $this->getGeneratorClass() . "\n" . "// date: %s\n?>\n%s";
     $retval = sprintf($retval, date('Y/m/d H:i:s'), $content);
     return $retval;
 }
 public function executeCategories()
 {
     $installed = array_keys($this->getLuceneInstance()->getCategories()->getAllCategories());
     sfLoader::loadHelpers('I18N');
     $categories = array(null => __('All'));
     if (count($installed)) {
         sort($installed);
         $categories += array_combine($installed, $installed);
     }
     $this->categories = $categories;
     $this->show = count($categories) > 1 ? true : false;
     $this->selected = $this->getRequestParameter('category', 0);
 }
Beispiel #22
0
 public static function getNamesForAutocomplete($q)
 {
     sfLoader::loadHelpers("Url");
     $c = new Criteria();
     $c->add(TagPeer::NAME, $q . "%", Criteria::LIKE);
     $c->setLimit(10);
     $names = array();
     $tags = TagPeer::doSelect($c);
     foreach ($tags as $tag) {
         $names[] = array("id" => $tag->getId(), "name" => $tag->getName(), "searchUrl" => url_for("job_listby_tag", $tag));
     }
     return $names;
 }
Beispiel #23
0
 public function configure()
 {
     $choices = LsListTable::getNetworksForSelect();
     $this->setWidgets(array('home_network_id' => new sfWidgetFormSelect(array('choices' => $choices)), 'name_first' => new sfWidgetFormInput(array(), array('size' => 30)), 'name_last' => new sfWidgetFormInput(array(), array('size' => 30)), 'public_name' => new sfWidgetFormInput(array(), array('size' => 30)), 'email' => new sfWidgetFormInput(array(), array('size' => 30)), 'reason' => new sfWidgetFormTextarea(array(), array('cols' => 50, 'rows' => 3)), 'password1' => new sfWidgetFormInputPassword(array(), array('size' => 30)), 'password2' => new sfWidgetFormInputPassword(array(), array('size' => 30)), 'user_agrees' => new sfWidgetFormInputCheckbox(), 'captcha' => new sfWidgetFormReCaptcha(array('public_key' => sfConfig::get('app_recaptcha_public_key')))));
     $this->setValidators(array('home_network_id' => new sfValidatorChoice(array('choices' => array_keys($choices), 'required' => true)), 'name_last' => new sfValidatorString(array('max_length' => 50)), 'name_first' => new sfValidatorString(array('max_length' => 50)), 'public_name' => new sfValidatorRegex(array('pattern' => '/^[a-z0-9\\.]{4,30}$/i')), 'email' => new sfValidatorEmail(array('required' => true), array('invalid' => 'You must enter a valid email address')), 'reason' => new sfValidatorString(array('required' => true), array('required' => 'Who are you and why are you signing up?')), 'password1' => new sfValidatorRegex(array('pattern' => '/^[a-z0-9]{6,20}$/i')), 'password2' => new sfValidatorString(array(), array('required' => 'You must enter the password twice')), 'user_agrees' => new sfValidatorBoolean(array('required' => true), array('required' => 'You must accept the user agreement')), 'captcha' => new sfValidatorReCaptcha(array('private_key' => sfConfig::get('app_recaptcha_private_key')), array('invalid' => 'You didn\'t pass the spam test!'))));
     $this->validatorSchema['captcha']->addMessage('captcha', 'You didn\'t pass the spam test!');
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('password1', sfValidatorSchemaCompare::EQUAL, 'password2'), array(), array('invalid' => 'You must enter the same password twice'));
     sfLoader::loadHelpers(array('Helper', 'Tag', 'Url'));
     $this->widgetSchema->setLabels(array('home_network_id' => 'Local network', 'name_first' => 'First name', 'name_last' => 'Last name', 'reason' => 'A little about you and why you\'re signing up', 'analyst_reason' => 'Why you want to be an ' . link_to('analyst', '@howto'), 'public_name' => 'Public username', 'password1' => 'Password', 'password2' => 'Password (again)', 'user_agrees' => 'Terms of use', 'captcha' => 'Spam test'));
     $this->widgetSchema->setNameFormat('user[%s]');
     $this->validatorSchema->setOption('allow_extra_fields', true);
     $this->validatorSchema->setOption('filter_extra_fields', false);
 }
Beispiel #24
0
 /**
  *
  * @param int $versionId, id of the current workflow
  * @param String $text, the text to replace
  * @param String $culture, the language
  * @param sfContext $context , context object
  */
 public function __construct($versionId, $text, $culture, $context = false) {
     if($context == false) {
         sfLoader::loadHelpers('Date');
     }
     else {
         $context->getConfiguration()->loadHelpers('Date');
     }
     $this->setWorkflow($versionId);
     $this->setWorkflowVersion($versionId);
     $this->culture = $culture;
     $this->theSender = new UserMailSettings($this->workflow['sender_id']);
     $this->newText = $this->replacePlaceholder($text);
 }
 public static function getRelatedClass($class, $middleClass)
 {
     $column = self::getRelatedColumn($class, $middleClass);
     // we must load all map builder classes
     $classes = sfFinder::type('file')->ignore_version_control()->name('*MapBuilder.php')->in(sfLoader::getModelDirs());
     foreach ($classes as $class) {
         $class_map_builder = basename($class, '.php');
         $map = new $class_map_builder();
         $map->doBuild();
     }
     $tableMap = call_user_func(array($middleClass . 'Peer', 'getTableMap'));
     return $tableMap->getDatabaseMap()->getTable($column->getRelatedTableName())->getPhpName();
 }
Beispiel #26
0
 /**
  * Loads core and standard helpers to be use in the template.
  */
 protected function loadCoreAndStandardHelpers()
 {
     static $coreHelpersLoaded = 0;
     if ($coreHelpersLoaded) {
         return;
     }
     $coreHelpersLoaded = 1;
     $helpers = array_unique(array_merge(array('Helper', 'Url', 'Asset', 'Tag', 'Escaping'), sfConfig::get('sf_standard_helpers')));
     // remove default Form helper if compat_10 is false
     if (!sfConfig::get('sf_compat_10') && false !== ($i = array_search('Form', $helpers))) {
         unset($helpers[$i]);
     }
     sfLoader::loadHelpers($helpers);
 }
 public function convertValueForDisplay($value)
 {
     if (is_null($value)) {
         return '<span class="text_small">NULL</span>';
     }
     if (!($record = $this->Modification->getObject(true))) {
         return $value;
     }
     $table = $record->getTable();
     if ($record instanceof Entity) {
         $data = $record->getData();
         if (!array_key_exists($this->field_name, $data)) {
             if ($extensionName = EntityTable::getExtensionNameByFieldName($this->field_name)) {
                 $table = Doctrine::getTable($extensionName);
             }
         }
     } elseif ($record instanceof Relationship) {
         $data = $record->getData();
         if (!array_key_exists($this->field_name, $data)) {
             $table = Doctrine::getTable(RelationshipTable::getCategoryNameByFieldName($this->field_name));
         }
     }
     if ($alias = $this->getFieldNameAlias()) {
         $class = $table->getRelation($alias)->getClass();
         if ($record = Doctrine::getTable($class)->find($value)) {
             if ($record instanceof Entity) {
                 sfLoader::loadHelpers('Ls');
                 return entity_link($record, null);
             }
             return $record;
         }
     }
     if (in_array($this->field_name, array('start_date', 'end_date'))) {
         return Dateable::convertForDisplay($value);
     }
     $def = $table->getColumnDefinition($this->field_name);
     switch ($def['type']) {
         case 'integer':
             return (string) $value;
             break;
         case 'boolean':
             return $value ? 'yes' : 'no';
             break;
     }
     return LsString::excerpt($value);
 }
    /**
    * Show the login page
    *
    * @param sfRequest $request A request object
    */
    public function executeIndex(sfWebRequest $request) {
        $this->getUser()->setAuthenticated(false);
        sfLoader::loadHelpers('Url');
        $this->getUser()->setCulture(Language::loadDefaultLanguage());
        $tm = new ThemeManagement();
        $systemTheme = UserConfigurationTable::instance()->getUserConfiguration()->toArray();
        $this->theTheme = $systemTheme[0]['theme'];

        /*
         * -1 is set when user uses login form to login
         * int is set, when user logges in from en email link, then a workflow needs to opened
         */
        $this->version_id = $request->getParameter('versionid',-1);
        $this->workflow_id = $request->getParameter('workflow',-1);
        $this->window  = $request->getParameter('window',-1);
        return sfView::SUCCESS;
    }
 public function executeCreate(sfWebRequest $request)
 {
     $this->setLayout(FALSE);
     sfConfig::set('sf_web_debug', false);
     sfLoader::loadHelpers('I18N');
     $this->getResponse()->setTitle(__('Image Upload'));
     $this->getResponse()->addStyleSheet('/sfTinyMceImageBrowser/css/sfTinyMceImageBrowser.css', 'last');
     $this->getResponse()->addJavascript('/lib/tiny_mce/tiny_mce_popup.js');
     $this->getResponse()->addJavaScript('/sfTinyMceImageBrowser/js/sfTinyMceImageBrowser.js');
     $this->form = new sfTinyMceImageForm(new sfTinyMceImage());
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             if ($this->form->save()) {
                 $this->redirect('sfTinyMceImageBrowser/create');
             }
         }
     }
 }
Beispiel #30
0
 public static function getRegions($area_type, $user_prefered_langs, $ids = array())
 {
     sfLoader::loadHelpers(array('General'));
     $filter_type = !empty($area_type);
     $filter_ids = !empty($ids);
     $select = 'a.id, i.name';
     if (!$filter_type) {
         $select .= ', a.area_type';
     }
     $q = Doctrine_Query::create()->select($select)->from('Area a')->leftJoin('a.AreaI18n i');
     if ($filter_type) {
         $q->where('a.area_type = ?', array($area_type));
     }
     if ($filter_ids) {
         $condition_array = array();
         foreach ($ids as $id) {
             $condition_array[] = '?';
         }
         $q->where('a.id IN ( ' . implode(', ', $condition_array) . ' )', array($ids));
     }
     if ($filter_type || $filter_ids) {
         $q->orderBy('i.search_name');
     } else {
         $q->orderBy('a.area_type');
     }
     $results = $q->execute(array(), Doctrine::FETCH_ARRAY);
     // build the actual results based on the user's prefered language
     $out = array();
     foreach ($results as $result) {
         $ref_culture_rank = 10;
         // fake high value
         foreach ($result['AreaI18n'] as $translation) {
             $tmparray = array_keys($user_prefered_langs, $translation['culture']);
             $rank = array_shift($tmparray);
             if ($rank < $ref_culture_rank) {
                 $best_name = $translation['name'];
                 $ref_culture_rank = $rank;
             }
         }
         $out[$result['id']] = ucfirst($best_name);
     }
     return $out;
 }