コード例 #1
0
/**
 * Transforms an array into a string
 *
 * @author Basilio Briceno <*****@*****.**>
 * @param mixed $element
 * @param mixed $parent;
 */
function tlalokes_str_from_array($element, $parent = false)
{
    $response = '';
    if (is_array($element)) {
        foreach ($element as $k => $v) {
            $parent = preg_replace('/(\\[\')*(.*)(\'\\])*/', '$2', $parent);
            $key = ($parent ? "['{$parent}']" : '') . "['{$k}']";
            $response .= tlalokes_str_from_array($v, $key);
        }
    } else {
        $response .= str_replace("']']", "']", $parent) . " = '{$element}';\n";
    }
    return $response;
}
コード例 #2
0
/**
 * Main function for the Authentication builder by array
 *
 * @param array $conf
 * @author Basilio Briceno <*****@*****.**>
 * @copyright Copyright &copy; 2009 Basilio Brice&ntilde;o Hern&aacute;ndez
 * @license http://www.gnu.org/licenses/gpl.html GNU GPL
 */
function auth_array_builder_main ( &$reg )
{
  $conf =& $reg->conf;
  $builder = $conf['path']['builder'];

  $bss_path = $conf['path']['app'].$conf['path']['bss'];
  $ctl_path = $conf['path']['app'].$conf['path']['controllers'];
  $viw_path = $conf['path']['app'].$conf['path']['views'];
  $loc_path = $conf['path']['app'].$conf['path']['locales'].'eng.php';

  // coping of authentication controller
  if ( !file_exists( $ctl_path.'AuthCtl.php' ) ) {

    // copy AuthCtl
    if ( !@copy( $builder.'/classes/AuthCtl.php', $ctl_path.'AuthCtl.php' ) ) {
      tlalokes_error_msg( 'Cannot copy AuthCtl.php', true );
    } else {
      echo '<p>AuthCtl.php copied to '.$ctl_path."</p>\n";
    }
  }

  // coping of authentication model
  if ( !file_exists( $bss_path.'AuthBss.php' ) ) {

    // copy AuthBss
    if ( !@copy( $builder.'/classes/AuthBss.php', $bss_path.'AuthBss.php' ) ) {
      tlalokes_error_msg( 'Cannot copy AuthBss.php', true );
    } else {
      echo '<p>AuthBss.php copied to '.$bss_path."</p>\n";
    }
  }

  // coping of authentication view
  if ( !file_exists( $viw_path.'tlalokes_auth.tpl' ) ) {

    // copy auth.tpl
    if ( !@copy( $builder.'/view/tlalokes_auth.tpl',
                $viw_path.'tlalokes_auth.tpl' ) ) {
      tlalokes_error_msg( 'Cannot copy authentication view', true );
    } else {
      echo '<p>tlalokes_auth.tpl view copied to '.$viw_path."</p>\n";
    }
  }

  // configuration file
  if ( !file_exists( $conf['path']['app'].'auth.php' ) ) {

    // copy auth.tpl
    if ( !@copy( $builder.'/conf/auth.php', $conf['path']['app'].'auth.php' ) ) {
      tlalokes_error_msg( 'Cannot copy authentication configuration', true );
    } else {
      echo '<p>Authentication configuration file copied to '.$viw_path."</p>\n";
    }
  }

  // locale
  if ( @file_exists( $loc_path ) ) {
    require $loc_path;
  } else {
    $locale['name'] = 'English';
  }
  if ( !isset( $l['controllers']['AuthCtl'] ) ) {

    $l['controllers']['AuthCtl']['title'] = 'Login';
    $l['controllers']['AuthCtl']['welcome'] = 'Welcome';
    $l['controllers']['AuthCtl']['email'] = 'email';
    $l['controllers']['AuthCtl']['password'] = '******';
    $l['controllers']['AuthCtl']['submit'] = 'Login';
    $l['controllers']['AuthCtl']['back'] = 'Back';
    $l['controllers']['AuthCtl']['exit'] = 'Exit';

    $nodes = tlalokes_str_from_array( $l );
    $nodes = preg_replace( '/^(\[.*)\n/m', "\$l$1\n", $nodes );

    $info = tlalokes_str_from_array( $locale );
    $info = preg_replace( '/^(\[.*)\n/m', "\$locale$1\n", $info );

    if ( !@file_put_contents( $loc_path, "<?\n$info\n$nodes", LOCK_EX ) ) {
      tlalokes_error_msg( "Builder: eng.php could not be generated", true );
    }
    echo "<p>English locale generated</p>\n";
  }
}
コード例 #3
0
  /**
   * Returns a string with the code for a locale
   *
   * @return string
   */
  private function getLocale ( $path )
  {
    if ( file_exists( $path ) ) {
      require $path;
    }
    $locale['name'] = 'English';

    $l['home'] = 'Home';
    $l['back'] = 'Back';
    $l['next'] = 'Next';
    $l['page'] = 'Page';
    $l['of'] = 'of';

    $l['controllers']["{$this->name}Ctl"]['title'] = $this->name;
    foreach ( $this->columns as $name => $column ) {
      $l['controllers']["{$this->name}Ctl"][$name] = $name;
    }
    $l['controllers']["{$this->name}Ctl"]['add'] = 'Add';
    $l['controllers']["{$this->name}Ctl"]['edit'] = 'Edit';
    $l['controllers']["{$this->name}Ctl"]['delete'] = 'Delete';
    $l['controllers']["{$this->name}Ctl"]['save'] = 'Save';
    $l['controllers']["{$this->name}Ctl"]['filter'] = 'Filter';
    $l['controllers']["{$this->name}Ctl"]['true'] = 'True';
    $l['controllers']["{$this->name}Ctl"]['false'] = 'False';

    $nodes = tlalokes_str_from_array( $l );
    $nodes = preg_replace( '/^(\[.*)\n/m', "\$l$1\n", $nodes );

    $info = tlalokes_str_from_array( $locale );
    $info = preg_replace( '/^(\[.*)\n/m', "\$locale$1\n", $info );

    return "<?\n$info\n$nodes";
  }