Inheritance: extends DatabaseObject
 /**
  * Tests for success at creating the object.
  */
 public function testCreate()
 {
     $test_type = "killer_whale";
     $nice_type = "Killer Whale";
     $t = new AuthorType();
     $t->setType($test_type);
     $this->assertTrue($t instanceof AuthorType);
     $this->assertEquals($t->__toString(), $nice_type);
 }
 /**
  * @param int $p_authorId
  */
 public static function GetAuthorTypesByAuthor($p_authorId)
 {
     global $g_ado_db;
     $queryStr = 'SELECT * FROM ' . self::TABLE . '
         WHERE fk_author_id = ' . $p_authorId;
     $query = $g_ado_db->Execute($queryStr);
     $authorTypes = array();
     while ($row = $query->FetchRow()) {
         $tmpAuthorType = new AuthorType();
         $tmpAuthorType->fetch($row);
         $authorTypes[] = $tmpAuthorType;
     }
     return $authorTypes;
 }
 function drawComboContent($id = 0) {
     $types = AuthorType::GetAuthorTypes();
     foreach ($types as $xtype) {
         $combo .=  '<option value="' . $xtype->getId() . '"';
         if ($id == $xtype->getId()) {
             $combo.= ' selected="selected" ';
         }
         $combo .= '>' . $xtype->getName() . '</option>';
     }
     return $combo;
 }
示例#4
0
    }
}
// Add new author type
$add_author_type = Input::Get('add_author', 'string', null);
if ($add_author_type !== null) {
    $authorTypeObj = new AuthorType();
    if ($authorTypeObj->create($add_author_type) === true) {
        camp_html_add_msg($translator->trans('Author type added.', array(), 'users'), 'ok');
    } else {
        camp_html_add_msg($translator->trans('Cannot add author type, this type already exists.', array(), 'users'));
    }
}
// Delete author type
$del_id_type = Input::Get('del_id_type', 'int', -1);
if ($del_id_type > -1) {
    $authorTypeObj = new AuthorType($del_id_type);
    if ($authorTypeObj->delete()) {
        camp_html_add_msg($translator->trans('Author type removed.', array(), 'users'), 'ok');
    } else {
        camp_html_add_msg($translator->trans('Cannot remove author type.', array(), 'users'));
    }
}
// Delete author alias
$del_id_alias = Input::Get('del_id_alias', 'int', -1);
if ($del_id_alias > -1) {
    $authorAliasObj = new AuthorAlias($del_id_alias);
    if ($authorAliasObj->delete()) {
        camp_html_add_msg($translator->trans('Author alias removed.', array(), 'users'), 'ok');
    } else {
        camp_html_add_msg($translator->trans('Cannot remove author alias.', array(), 'users'));
    }
示例#5
0
 private function __getDefaultType()
 {
     $types = AuthorType::GetAuthorTypes();
     foreach ((array) $types as $type) {
         if (strtoupper($type->getName()) === self::DEFAULT_TYPE) {
             return $type->getId();
         }
     }
     return (int) $types[0]->getId();
 }
示例#6
0
           }
       }
       ?>
         <div class="authorAliasItem">
           <input type="text" name="alias[]" value="" class="input_text" size="41" spellcheck="false" style="width:325px;" />
           <a class="ui-state-default icon-button no-text" href="#"><span class="ui-icon ui-icon-closethick"></span></a>
         </div>
       </div>
       <span onclick="addAlias();"><a href="#" class="addButton"></a></span>
     </li>
     <li>
       <span id="types">
         <label><?php putGS('Type'); ?>:</label>
         <select name="type[]" class="input_select2" onchange="" style="width:362px;height:100%" multiple="multiple">
         <?php
         $types = AuthorType::GetAuthorTypes();
         foreach ($types as $xtype) {
             $str =  '<option value="' . $xtype->getId() . '"';
             if (is_array($type) && in_array(array('fk_type_id' => $xtype->getId()), $type)) {
                 $str .= ' selected="selected"';
             }
             $str .= '>' . $xtype->getName() . '</option>';
             echo $str;
         }
         ?>
         </select>
       </span>
     </li>
   </ul>
 </fieldset>
 <fieldset class="frame">
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
/**
 * This is an example class of sfTestFunctional
 * It may require some attention to work with the default values (line 40).
 */
$browser = new sfBrowser();
$test_browser = new sfTestFunctional($browser);
$test_browser->setTester('json.response', 'sfTesterJsonResponse');
$test_browser->get('/authortype')->with('request')->begin()->isParameter('module', 'authortype')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->end()->with('json.response')->begin()->isJson()->end();
/**
 * Test the creation
 */
$entity = new AuthorType();
$entity_array = $entity->exportTo('array');
$identifier = $entity->getTable()->getIdentifier();
/**
 * Please build a valid $entity_array here
 */
unset($entity_array[$identifier]);
//$entity_array['name'] = "pony";
//$entity_array['created_at'] = date('Y-m-d H:i:s');
//$entity_array['updated_at'] = date('Y-m-d H:i:s');
$test_browser->call('/authortype', 'post', array('content' => json_encode($entity_array)))->with('request')->begin()->isParameter('module', 'authortype')->isParameter('action', 'create')->end()->with('response')->begin()->isStatusCode(200)->end();
/**
 * If the new entity has been created
 */
$location = $browser->getResponse()->getHttpHeader('Location');
if ($location) {
    // Get ?