/**
  * Can be used inside a magic __call method to allow for a class to be extended
  * 
  * This method will throw a class_name.method_not_found event,
  * where class_name is the "tableized" class name.
  * 
  * @example
  * public function __call($method, $arguments)
  * {
  *   return sfSympalExtendClass::extendEvent($this, $method, $arguments);
  * }
  * 
  * @param mixed $subject Instance of the class being extended
  * @param string $method The current method being called
  * @param array $arguments The arguments being passed to the above methid
  */
 public static function extendEvent($subject, $method, $arguments)
 {
     $name = sfInflector::tableize(get_class($subject));
     $event = ProjectConfiguration::getActive()->getEventDispatcher()->notifyUntil(new sfEvent($subject, $name . '.method_not_found', array('method' => $method, 'arguments' => $arguments)));
     if (!$event->isProcessed()) {
         throw new sfException(sprintf('Call to undefined method %s::%s.', get_class($subject), $method));
     }
     return $event->getReturnValue();
 }
  public function linkToObject($class, $html, $params)
  {
    $showRoute = sfInflector::tableize($class) . '_show';
    $routes    = sfContext::getInstance()->getRouting()->getRoutes();

    if (isset($routes[$showRoute]) && $routes[$showRoute] instanceof sfDoctrineRoute) {
      $options = $routes[$showRoute]->getOptions();
      if ($options['model'] == $class) {
        $html = sprintf("link_to(%s, '%s', %s)", $html, $showRoute, $html);
      }
    }

    return $html;
  }
Ejemplo n.º 3
0
function installPlugin($name, $t)
{
    // Install the plugin
    $manager = sfSympalPluginManager::getActionInstance($name, 'install');
    $manager->install();
    // Check that content type was created
    $contentTypeName = $manager->getContentTypeForPlugin($name);
    $contentType = Doctrine_Core::getTable('sfSympalContentType')->findOneByName($contentTypeName);
    $t->is($contentType['name'], $contentTypeName, 'Test content type name set');
    $t->is($contentType['label'], sfInflector::humanize(sfInflector::tableize(str_replace('sfSympal', null, $contentTypeName))), 'Test content type label set');
    $t->is($contentType['plugin_name'], $name, 'Test content type plugin name set');
    $contentList = Doctrine_Core::getTable('sfSympalContentList')->findOneByContentTypeId($contentType['id']);
    $t->is($contentList instanceof sfSympalContentList, true, 'Test sample content list was created.');
    $menuItem = Doctrine_Core::getTable('sfSympalMenuItem')->findOneByContentId($contentList['content_id']);
    $t->is($menuItem instanceof sfSympalMenuItem, true, 'Test menu item to sample content list was created.');
}
 public function joinForTableProxy(Doctrine_Query $q, array $options = array())
 {
     $options = Doctrine_Lib::arrayDeepMerge($this->_options, $options);
     $q->getRootAlias();
     // fix for initialize root
     if (empty($options['parentTable'])) {
         $parentTable = $q->getRoot();
         $parentTableAlias = $q->getRootAlias();
     } else {
         $parentTable = Doctrine::getTable($options['parentTable']);
         $parentTableAlias = empty($options['parentTableAlias']) ? $q->getSqlTableAlias(sfInflector::tableize($options['parentTable'])) : $options['parentTableAlias'];
     }
     if (!empty($options['componentAlias'])) {
         $componentAlias = $options['componentAlias'];
     } elseif ($parentTable->hasRelation($this->_table->getComponentName())) {
         $componentAlias = $this->_table->getComponentName();
     } else {
         $componentName = $this->_table->getComponentName();
         $relations = $parentTable->getRelations();
         foreach ($relations as $relation) {
             if ($relation['class'] == $componentName) {
                 $componentAlias = $relation['alias'];
                 break;
             }
         }
     }
     $tableAlias = empty($options['tableAlias']) ? $this->_table->getAlias() : $options['tableAlias'];
     $q->addSqlTableAlias($tableAlias, sfInflector::tableize($this->_table->getComponentName()));
     $q->leftJoin($parentTableAlias . '.' . $componentAlias . ' ' . $tableAlias);
     if ($options['withI18n'] == true && $this->_table->hasTemplate('Doctrine_Template_I18nMod')) {
         $cultures = empty($options['cultures']) ? sfContext::getInstance()->getUser()->getCulture() : $options['cultures'];
         $chunkWith = implode(' AND ', array_fill(0, count($cultures), ' ' . $tableAlias . '_trans.lang = ? '));
         $q->leftJoin($tableAlias . '.Translation ' . $tableAlias . '_trans WITH ' . $chunkWith, $cultures);
     }
     return $q;
 }
 /**
  * Execute share by email method
  * 
  * @param sfWebRequest $request
  */
 public function executeEmail(sfWebRequest $request)
 {
     $user = $this->getUser();
     $search_public_models = sfConfig::get('app_rt_search_public_models', array('rtShopProduct', 'rtShopCategory', 'rtBlogPage', 'rtSitePage', 'rtWikiPage'));
     $this->model = $request->getParameter('model');
     $this->model_id = $request->getParameter('model_id');
     $this->route_name = sfInflector::tableize($this->model) . '_show';
     $this->object = Doctrine_Core::getTable($this->model)->find(array($this->model_id));
     // Exception handling
     if (!in_array($this->model, $search_public_models) || !$this->object) {
         throw new sfException(sprintf('Object %s does not exist.', $this->model));
     }
     // Form
     $this->form = new rtSocialEmailPublicForm();
     if ($this->getRequest()->isMethod('PUT') || $this->getRequest()->isMethod('POST')) {
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             $form_values = $this->form->getValues();
             $this->notifyAudience($this->object, $form_values, $this->route_name);
         } else {
             $this->getUser()->setFlash('default_error', true, false);
         }
     }
 }
Ejemplo n.º 6
0
    echo get_partial('sympal_default/render_form', array('form' => $embeddedForms[$name]));
    ?>
  </div>
<?php 
} else {
    ?>
  <div class="sf_admin_form_row<?php 
    $widget->hasError() and print ' errors';
    $validatorSchema[$name]->getOption('required') and print ' required';
    ?>
">
    <?php 
    if ($help = $widget->renderHelp()) {
        ?>
      <?php 
        $helpId = sfInflector::tableize($name) . '_help';
        ?>
      <span id="<?php 
        echo $helpId;
        ?>
" class="help" style="float: right;" title="<?php 
        echo strip_tags($help);
        ?>
">
        <?php 
        echo image_tag('/sf/sf_admin/images/help.png');
        ?>
      </span>
    <?php 
    }
    ?>
Ejemplo n.º 7
0
<tr>  
  <td class="values">
      <?php 
echo $form->renderHiddenFields();
?>
      <?php 
echo sfInflector::humanize(sfInflector::tableize($form['keyword_type']->getValue()));
?>
  </td>
  <td>
    <?php 
echo $form['keyword_type']->renderError();
?>
    <?php 
echo $form['keyword'];
?>
  </td>
  <td class="widget_row_delete">
      <?php 
echo image_tag('remove.png', 'alt=Delete class=clear_prop id=' . $form['keyword_type']->getValue());
?>
  </td>
</tr>
Ejemplo n.º 8
0
<?php

/*
 * Important set of helper variables for usage in the layout template.
 *
 * 
 */
use_helper('rtTemplate');
$routes = $sf_context->getRouting()->getRoutes();
$module = $sf_request->getParameter('module');
$action = $sf_request->getParameter('action');
$area_class = Doctrine_Inflector::urlize(sfInflector::tableize($module));
$area_class .= ' ' . $area_class . '-' . Doctrine_Inflector::urlize(sfInflector::tableize($action));
$snippet_area = Doctrine_Inflector::urlize(sfInflector::tableize($module) . '-' . sfInflector::tableize($action));
Ejemplo n.º 9
0
 /**
  * Camel case to underscored.
  *
  * @param $string
  * @return string
  */
 private function tableize($string)
 {
     return sfInflector::tableize($string);
 }
 public function init()
 {
     $this->_eventName = sfInflector::tableize($this->_table->getOption('name'));
 }
 /**
  * Override the setInvoker() method to allow us to generate the event name
  *
  * @param Doctrine_Record_Abstract $invoker 
  * @return void
  */
 public function setInvoker(Doctrine_Record_Abstract $invoker)
 {
     parent::setInvoker($invoker);
     $this->_eventName = sfInflector::tableize(get_class($invoker));
 }
Ejemplo n.º 12
0
<?php

include_stylesheets_for_form($form);
include_javascripts_for_form($form);
?>

<span id="sympal_content_slot_<?php 
echo $contentSlot->getId();
?>
_editor_form" class="sympal_<?php 
echo sfInflector::tableize($contentSlot->getType());
?>
_content_slot_editor_form">
  <?php 
echo $form->renderHiddenFields();
?>

  <?php 
echo sfSympalToolkit::getSymfonyResource($contentSlot->getSlotEditFormRenderer(), array('contentSlot' => $contentSlot, 'form' => $form));
?>
</span>

<script type="text/javascript">
<?php 
if ($contentSlot->getType() == 'Markdown' && sfSympalConfig::get('enable_markdown_editor', null, true)) {
    ?>
$(function() {
  $('#sympal_content_slot_<?php 
    echo $contentSlot->getId();
    ?>
_editor_form textarea').markItUp(mySettings);
 /**
  * Rename model functionality
  *
  * @param string $name 
  * @return afResponse
  * @author Sergey Startsev
  */
 public function renameModel($name)
 {
     $response = afResponseHelper::create();
     $are_writable = $this->isModelWritable();
     if ($are_writable !== true) {
         return $are_writable;
     }
     if (!afStudioModelCommandHelper::isValidName($name)) {
         return $response->success(false)->message('Model name can only consist from alphabetical characters and begins from letter or "_"');
     }
     $this->originalSchemaArray[$this->getSchemaFile()]['propel'][$this->getTableName()]['_attributes']['phpName'] = $name;
     $newTableName = sfInflector::tableize($name);
     $this->originalSchemaArray[$this->getSchemaFile()]['propel'][$newTableName] = $this->originalSchemaArray[$this->getSchemaFile()]['propel'][$this->getTableName()];
     unset($this->originalSchemaArray[$this->getSchemaFile()]['propel'][$this->getTableName()]);
     if ($this->saveSchema()) {
         afStudioConsole::getInstance()->execute('sf afs:fix-perms');
         list($status, $message) = afStudioModelCommandHelper::renameModel($this->getModelName(), $name);
         afStudioModelCommandHelper::removeModelFiles($this->getModelName());
         return $response->success(true)->message("Renamed model's phpName from <b>{$this->getModelName()}</b> to <b>{$name}</b><br><b style=\"color:red;\">Please make sure you'll update all the widgets that are using the old model name with the renamed model name, else you'll be facing some errors when trying to load those widgets!</b>!" . (!empty($message) ? "<br/>" . nl2br($message) : ''))->console(afStudioModelCommandHelper::deploy());
     }
     return $response->success(false)->message("Can't rename model's phpName from <b>{$this->getModelName()}</b> to <b>{$name}</b>!");
 }
Ejemplo n.º 14
0
 public function __call($method, $arguments)
 {
     if (substr($method, 0, 3) == 'get') {
         $name = substr($method, 3, strlen($method));
         $name = sfInflector::tableize($name);
         return $this->get($name, $arguments);
     }
 }
 public function getReadableKeywordType()
 {
     return sfInflector::humanize(sfInflector::tableize($this->getKeywordType()));
 }
Ejemplo n.º 16
0
 public function getId()
 {
     if (!$this->_id) {
         $this->_id = sfInflector::tableize($this->_modelName . 'DataGrid');
     }
     return $this->_id;
 }
Ejemplo n.º 17
0
 public function newContentType($name, $properties = array())
 {
     $contentType = new sfSympalContentType();
     $contentType->name = $name;
     $contentType->label = sfInflector::humanize(sfInflector::tableize(str_replace('sfSympal', null, $name)));
     $contentType->slug = Doctrine_Inflector::urlize($contentType->label);
     $contentType->default_path = '/' . $contentType->slug . '/:slug';
     $this->_setDoctrineProperties($contentType, $properties);
     $this->logSection('sympal', sprintf('...instantiating new content type "%s"', $contentType), null, 'COMMENT');
     return $contentType;
 }
Ejemplo n.º 18
0
/**
 * run_doctrine_load_nested_set 
 * 
 * @param mixed $task 
 * @param mixed $args 
 * @access public
 * @return void
 */
function run_doctrine_load_nested_set($task, $args)
{
    if (!count($args)) {
        throw new Exception('You must provide the app.');
    }
    $app = $args[0];
    if (!is_dir(sfConfig::get('sf_app_dir') . DIRECTORY_SEPARATOR . $app)) {
        throw new Exception('The app "' . $app . '" does not exist.');
    }
    if (!isset($args[1])) {
        throw new Exception('You must provide a filename.');
    }
    $filename = $args[1];
    $env = empty($args[2]) ? 'dev' : $args[2];
    _load_application_environment($app, $env);
    $model = sfInflector::classify($args[1]);
    $ymlName = sfInflector::tableize($args[1]);
    $ymlPath = sfConfig::get('sf_data_dir') . '/' . $ymlName . '.yml';
    pake_echo_action('doctrine', 'loading nested set data for ' . $model);
    pake_echo_action('doctrine', 'loading ' . $ymlPath);
    $nestedSetData = sfYaml::load($ymlPath);
    _doctrine_load_nested_set_data($model, $nestedSetData);
}